Jump to content

Set-builder notation: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m word "rule", used throughout the article, added also at the beginning
No edit summary
Line 115: Line 115:


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 (functional programming)|monad]] with a [[zero element]].<ref>{{cite web|url=http://blog.n-sch.de/2010/11/27/fun-with-monad-comprehensions/|title=Fun with monad comprehensions|author=Nils Schweinsberg|date=27 Nov. 2010|accessdate=4 July 2011}}</ref>
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 (functional programming)|monad]] with a [[zero element]].<ref>{{cite web|url=http://blog.n-sch.de/2010/11/27/fun-with-monad-comprehensions/|title=Fun with monad comprehensions|author=Nils Schweinsberg|date=27 Nov. 2010|accessdate=4 July 2011}}</ref>
oippo

== References ==
== References ==
<references/>
<references/>

Revision as of 17:27, 29 October 2013

In set theory and its applications to logic, mathematics, and computer science, set-builder notation is a mathematical notation for describing a set by stating the properties that its members must satisfy.[1] Forming sets in this manner is also known as set comprehension, set abstraction or as defining a set's intension. Although some simply refer to it as set notation, that label may be better reserved for the broader class of means of denoting sets.

Building sets

Let Φ(x) be a formula in which the variable x appears free. Set builder notation has the form {x : Φ(x)} (or {x | Φ(x)} according to the international standard ISO 31-11 using the vertical bar instead of the colon), denoting the set of all individuals in the universe of discourse satisfying the formula Φ(x), that is, the set whose members are every individual x such that Φ(x) is true: formally, the extension of the predicate. Φ(x) is here referred to as the rule. Sometimes the universe of discourse is established within the notation; writing (or sometimes , though this is done at the expense of making the set membership operator ambiguous in the formal set builder notation, as explained with some additional examples at the end of the section) establishes that the universe of discourse is for purposes of the set being built. Set builder notation binds the variable x and must be used with the same care applied to variables bound by quantifiers. Unless specifically stated the variable is universally quantified over the rule, which means we include in the set all possible values for the variable for which the rule is true.

Examples:

  • is a set holding the four numbers 3, 7, 15, and 31.
  • is the set of natural numbers.
  • is the set of integers between 1 and 100 inclusive.
  • is the set containing 'a','b', and 'c'.
  • is the set ,
  • is the set of all positive real numbers.
  • is the set of (x,y) such that y is greater than 0 and less than f(x).
  • is the set of all even natural numbers,
  • is the set of rational numbers; that is, numbers that can be written as the ratio of two integers.
  • Thus, e.g., , etc. (n.b.: in the case of sets, the order is not important; could be used). As an example,

The ellipses means that the simplest interpretation should be applied for continuing the sequence. Should no terminating value appear to the right of the ellipses then the sequence is considered to be unbounded.

The is read as "such that", and it separates the variables list on the left from the rule for assigning values to those variables on the right. Oftentimes the rule on the right is a formal logic predicate. However it can be anything that is clear to readers including simple prose. When the meaning is clear the and the rule may be omitted.

When the rule is a predicate then formal logic connectors may be used within the rule. For example, the sign stands for and, requiring both clauses to the left of it and to the right of it to be 'true'. As another example, The sign stands for "there exists" and is formally known as existential quantification. Sometimes multiple rules are given separated by a comma (,) or semicolon (;), in this case we take the rules in conjunction, i.e. we interpret the comma or semicolon to mean the same as .

The sign denotes set membership, and can be read as "member of" or informally as "in". In a predicate a clause of the form is either true or false, or when used as a constraint means that can only be one of the values 1, 2, or 3.

When the domain over which the set is defined is already clear it is not necessary to provide it within the rule clause. One could say something such as, "The universe of discourse can be taken to be the set of real numbers, where not specified inside the notation:" and then write:

  • is the set

Rather than the fuller form as shown in the original example given above.

One can also use an expression in the variable list. For example:

  • is the set of odd integers.
  • creates a set of pairs, where each pair puts an integer into correspondence with an odd integer.
  • is the set because the expression evaluates to either true or false given the various natural numbers.

It is known in the literature to just place the domain qualifiers directly in the variable list. For the prior example this would produce:

  • is the set ,

Technically this would generate the set as the expression to the left of the 'such that' evaluates to either true or false, but at the expense of introducing ambiguity into our set builder notation we may instead decide to interpret this to mean that x has an additional qualification of being a real number. As another example, consider:

If we interpret to be a domain qualifier, then this is the set ; however, if we interpret to be an expression then this set is . Such ambiguities can be resolved by convention, for example by foregoing the ability to put the set inclusion operator in variable expressions. Another convention for eliminating such ambiguity, one that does not require us to reduce the richness of expressions, is to simply not use domain qualifiers in the variable list, but instead to put them with the rule predicates. For example, the expression

denotes the first interpretation of the set given above, and can't be read in the second way.

When we do proofs that reason about the predicate rules, such as shown in the next section, the shortcut of leaving domain qualifiers with the variables is not an option, rather we must rigorously put domain qualifiers into the predicate rules we are operating on. Otherwise we may get fallacious results.

Equivalent Builder Predicates means Equivalent Sets

Suppose we have two predicates we intend to use as rules for building sets, say these two predicates are and . Suppose we have not added additional qualifiers or expressions to the variable list (left of the 'such that'). Now furthermore assume that any value x comes from a domain defined by set , i.e. . Now suppose also that we build two sets from these predicates:

and,

As we already said that the domain is we could have left out the and . Indeed, we leave out the understood qualifier in the next statement. Note also we can give the variable used for building the set any name, as we have overused here we built the sets against and . Now we have an interesting result from the field of mathematical logic:

Here we use the square brackets for purposes of grouping. This says that if the two predicates always have the same true or false value given the same argument over the domain , then the two sets T and S will be the same. Also, conversely, if the two sets T and S are identical, i.e. have the same elements,then our two predicates always produce the same logic value for the same argument over the domain U. The use of the colon here after the universal quantifier simply means the quantifier applies to what follows. Note this result is very general as it applies to any such sets and predicates over any given domain U.

The former author of this wiki section chose to state the equivalence between sets with equivalent predicates theorem in the following manner, note he uses the somewhat ambiguous shorthand of putting some simple qualifiers with the variables, and he prefers to use a ':' rather than a vertical bar for 'such that'. This usage of the colon is not to be confused with the use of the colon above after the universal quantifier that means 'apply to'. It is to avoid such confusion that many mathematicians prefer the vertical bar for 'such that':

.

This means that two sets are equal if and only if their "membership requirements" are logically equivalent.

For example, because, for any real number x, x2 = 1 if and only if |x| = 1; and, therefore, both constructions produce the same set {-1,1}.

Russell's paradox

Let denote the set R of all sets S that do not belong to themselves. The inconsistency of the existence of this set is known as Russell's paradox.

Solutions to the paradox restrict the notion of set construction in some way. To illustrate this in terms of our notation, let X = {xA | P(x)} denote the set of every element of A satisfying the predicate P(x). The canonical restriction on set builder notation asserts that X is a set only if A is already known to be a set. This restriction is codified in the axiom schema of separation present in standard axiomatic set theory. Note that this axiom schema excludes R from sethood.

Variations

Terms more complicated than a single variable

Another variation on set-builder notation replaces the single variable x with a term T which may include one or more variables, combined with functions acting on them. So instead of {x : Φ(x)}, we would have {T : Φ(x1 ... xn)}, where T is a term involving variables x1 through xn. For example:

  • {2n : nN}, where N is the set of all natural numbers, is the set of all even natural numbers.
  • {p/q : p,qZ, q≠0}, where Z is the set of all integers, is the set of all rational numbers (Q).

Z notation

In Z notation, the set of all x (in a universe of discourse A) satisfying the condition P(x) would be written . In Z, an element x's set membership is written as instead of ; the vertical bar is used to indicate a predicate. Versions of set builder notation are also available in Z which allow for terms more complicated than a single variable, using a bullet to indicate the form of members of the set. So denotes the set of all values F(x), where x is in A and P(x) holds.

Parallels in programming languages

A similar notation available in a number of programming languages (notably Python and Haskell) 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. Consider these examples given in set-builder notation, Python, and Haskell:

Example 1 Example 2
Set-builder
Python
{l for l in L}
{(k, x) for k in K for x in X if P(x)}
Haskell
[l | l <- ls]
[(k, x) | k <- ks, x <- xs, p x]

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.[2] oippo

References

  1. ^ Rosen, Kenneth (2007). Discrete Mathematics and its Applications (6th ed.). New York, NY: McGraw-Hill. pp. 111–112. ISBN 978-0-07-288008-3.
  2. ^ Nils Schweinsberg (27 Nov. 2010). "Fun with monad comprehensions". Retrieved 4 July 2011. {{cite web}}: Check date values in: |date= (help)