In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
and more specifically in
set theory
Set theory is the branch of mathematical logic that studies Set (mathematics), sets, which can be informally described as collections of objects. Although objects of any kind can be collected into a set, set theory – as a branch of mathema ...
, set-builder notation is a
notation
In linguistics and semiotics, a notation system is a system of graphics or symbols, Character_(symbol), characters and abbreviated Expression (language), expressions, used (for example) in Artistic disciplines, artistic and scientific disciplines ...
for specifying a
set by a property that characterizes its members.
Specifying sets by member properties is allowed by the
axiom schema of specification. This is also known as set comprehension and set abstraction.
Sets defined by a predicate
Set-builder notation can be used to describe a set that is defined by a
predicate, that is, a logical formula that evaluates to ''true'' for an element of the set, and ''false'' otherwise. In this form, set-builder notation has three parts: a variable, a
colon or
vertical bar
The vertical bar, , is a glyph with various uses in mathematics, computing, and typography. It has many names, often related to particular meanings: Sheffer stroke (in logic), pipe, bar, or (literally, the word "or"), vbar, and others.
Usage
...
separator, and a predicate. Thus there is a variable on the left of the separator, and a rule on the right of it. These three parts are contained in curly brackets:
:
or
:
The vertical bar (or colon) is a separator that can be read as "such that", "for which", or "with the property that". The formula is said to be the ''rule'' or the ''predicate''. All values of for which the predicate holds (is true) belong to the set being defined. All values of for which the predicate does not hold do not belong to the set. Thus
is the set of all values of that satisfy the formula . It may be the
empty set
In mathematics, the empty set or void set is the unique Set (mathematics), set having no Element (mathematics), elements; its size or cardinality (count of elements in a set) is 0, zero. Some axiomatic set theories ensure that the empty set exi ...
, if no value of satisfies the formula.
Specifying the domain
A domain can appear on the left of the vertical bar:
:
or by adjoining it to the predicate:
:
The ∈ symbol here denotes
set membership, while the
symbol denotes the logical "and" operator, known as
logical conjunction
In logic, mathematics and linguistics, ''and'' (\wedge) is the Truth function, truth-functional operator of conjunction or logical conjunction. The logical connective of this operator is typically represented as \wedge or \& or K (prefix) or ...
. This notation represents the set of all values of that belong to some given set for which the predicate is true (see "
Set existence axiom" below). If
is a conjunction
, then
is sometimes written
, using a comma instead of the symbol
.
In general, it is not a good idea to consider sets without defining a
domain of discourse, as this would represent the
subset
In mathematics, a Set (mathematics), set ''A'' is a subset of a set ''B'' if all Element (mathematics), elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they a ...
of ''all possible things that may exist'' for which the predicate is true. This can easily lead to contradictions and paradoxes. For example,
Russell's paradox shows that the expression
although seemingly well formed as a set builder expression, cannot define a set without producing a contradiction.
In cases where the set is clear from context, it may be not explicitly specified. It is common in the literature for an author to state the domain ahead of time, and then not specify it in the set-builder notation. For example, an author may say something such as, "Unless otherwise stated, variables are to be taken to be natural numbers," though in less formal contexts where the domain can be assumed, a written mention is often unnecessary.
Examples
The following examples illustrate particular sets defined by set-builder notation via predicates. In each case, the domain is specified on the left side of the vertical bar, while the rule is specified on the right side.
*
is the set of all strictly
positive real number
In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
s, which can be written in
interval notation as
.
*
is the set
. This set can also be defined as
; see
equivalent predicates yield equal sets below.
* For each integer , we can define
. As an example,
and
.
*
is the set of pairs of real numbers such that ''y'' is greater than 0 and less than , for a given
function . Here the
cartesian product
In mathematics, specifically set theory, the Cartesian product of two sets and , denoted , is the set of all ordered pairs where is an element of and is an element of . In terms of set-builder notation, that is
A\times B = \.
A table c ...
denotes the set of ordered pairs of real numbers.
*
is the set of all
even natural number
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
s. The
sign stands for "and", which is known as
logical conjunction
In logic, mathematics and linguistics, ''and'' (\wedge) is the Truth function, truth-functional operator of conjunction or logical conjunction. The logical connective of this operator is typically represented as \wedge or \& or K (prefix) or ...
. The ∃ sign stands for "there exists", which is known as
existential quantification
Existentialism is a family of philosophy, philosophical views and inquiry that explore the human individual's struggle to lead an Authenticity (philosophy), authentic life despite the apparent Absurdity#The Absurd, absurdity or incomprehensibili ...
. So for example,
is read as "there exists an such that ".
*
is a notational variant for the same set of even natural numbers. It is not necessary to specify that is a natural number, as this is implied by the formula on the right.
*
is the set of
rational number
In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (for example,
The set of all ...
s; that is, real numbers that can be written as the ratio of two
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
s.
More complex expressions on the left side of the notation
An extension of set-builder notation replaces the single variable with an
expression. So instead of
, we may have
which should be read
:
.
For example:
*
, where
is the set of all natural numbers, is the set of all even natural numbers.
*
, where
is the set of all integers, is
the set of all rational numbers.
*
is the set of odd integers.
*
creates a set of pairs, where each pair puts an integer into correspondence with an odd integer.
When inverse functions can be explicitly stated, the expression on the left can be eliminated through simple substitution. Consider the example set
. Make the substitution
, which is to say
, then replace ''t'' in the set builder notation to find
:
Equivalent predicates yield equal sets
Two sets are equal if and only if they have the same elements. Sets defined by set builder notation are equal if and only if their set builder rules, including the domain specifiers, are equivalent. That is
:
if and only if
:
Set existence axiom
In many formal set theories, such as
Zermelo–Fraenkel set theory
In set theory, Zermelo–Fraenkel set theory, named after mathematicians Ernst Zermelo and Abraham Fraenkel, is an axiomatic system that was proposed in the early twentieth century in order to formulate a theory of sets free of paradoxes suc ...
, set builder notation is not part of the formal syntax of the theory. Instead, there is a
set existence axiom scheme, which states that if is a set and is a formula in the language of set theory, then there is a set whose members are exactly the elements of that satisfy :
:
(\forall E)(\exists Y)(\forall x) \in Y \Leftrightarrow x \in E \land \Phi(x)
The set obtained from this axiom is exactly the set described in set builder notation as
\.
In programming languages
A similar notation available in a number of
programming languages (notably
Python and
Haskell
Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
) is the
list comprehension, which combines
map and
filter operations over one or more
lists.
In Python, the set-builder's braces are replaced with square brackets, parentheses, or curly braces, giving list,
generator, and set objects, respectively. Python uses an English-based syntax. Haskell replaces the set-builder's braces with square brackets and uses symbols, including the standard set-builder vertical bar.
The same can be achieved in
Scala using Sequence Comprehensions, where the "for" keyword returns a list of the yielded variables using the "yield" keyword.
Consider these set-builder notation examples in some programming languages:
The set builder notation and list comprehension notation are both instances of a more general notation known as ''monad comprehensions'', which permits map/filter-like operations over any
monad with a
zero element.
See also
*
Glossary of set theory
Notes
{{bots, deny=Yobot
Set theory
Mathematical notation
Articles with example Haskell code
Articles with example Python (programming language) code
is:Mengjaskilgreiningarritháttur