In mathematics, a set is a collection of distinct objects, considered as an object in its own right. For example, the numbers 2, 4, and 6 are distinct objects when considered separately, but when they are considered collectively they form a single set of size three, written . The concept of a set is one of the most fundamental in mathematics. Developed at the end of the 19th century, set theory is now a ubiquitous part of mathematics, and can be used as a foundation from which nearly all of mathematics can be derived. In mathematics education, elementary topics from set theory such as are taught at a young age, while more advanced concepts are taught as part of a university degree.
The German word Menge, rendered as "set" in English, was coined by Bernard Bolzano in his work The Paradoxes of the Infinite.
Sets are conventionally denoted with capital letters. Sets A and B are equal if and only if they have precisely the same elements.
For technical reasons, Cantor's definition turned out to be inadequate; today, in contexts where more rigor is required, one can use axiomatic set theory, in which the notion of a "set" is taken as a primitive notion and the properties of sets are defined by a collection of . The most basic properties are that a set can have elements, and that two sets are equal (one and the same) if and only if every element of each set is an element of the other; this property is called the extensionality of sets.
The second way is by extension – that is, listing each member of the set. An extensional definition is denoted by enclosing the list of members in :
One often has the choice of specifying a set either intensionally or extensionally. In the examples above, for instance, A = C and B = D.
In an extensional definition, listing a member repeatedly does not change the set, for example, the set is identical to the set . Moreover, the order in which the elements of a set are listed is irrelevant (unlike for a sequence or tuple), so is yet again the same set.
For sets with many elements, the enumeration of members can be abbreviated. For instance, the set of the first thousand positive integers may be specified extensionally as
where the ellipsis ("...") indicates that the list continues in the obvious way.
The notation with braces may also be used in an intensional specification of a set. In this usage, the braces have the meaning "the set of all ...". So, E = is the set whose four members are spades, diamonds, hearts, and clubs. A more general form of this is setbuilder notation, through which, for instance, the set F of the twenty smallest integers that are four less than a square number can be denoted
In this notation, the colon (":") means "such that", and the description can be interpreted as " F is the set of all numbers of the form n^{2} − 4, such that n is an integer in the range from 0 to 19 inclusive". Sometimes the vertical bar ("") is used instead of the colon.
For example, with respect to the sets A = , B = , and F = defined above,
If A is a subset of B, but not equal to B, then A is called a proper subset of B, written A ⊊ B, or simply A ⊂ B ( A is a proper subset of B), or B ⊋ A ( B is a proper superset of A, B ⊃ A).
The expressions A ⊂ B and B ⊃ A are used differently by different authors; some authors use them to mean the same as A ⊆ B (respectively B ⊇ A), whereas others use them to mean the same as A ⊊ B (respectively B ⊋ A).
Examples:
There is a unique set with no members, called the empty set (or the null set), which is denoted by the symbol ∅ (other notations are used; see empty set). The empty set is a subset of every set, and every set is a subset of itself:
The above characterization of set equality can be used to show that two sets described differently are, in fact, equal:
A partition of a set S is a set of nonempty subsets of S such that every element x in S is in exactly one of these subsets, that is, any two sets of the partition contain no element in common, they are said to be disjoint, and the union of all elements of the partition that are sets themselves, make up S.
The power set of a finite set with n elements has 2^{ n} elements. For example, the set contains three elements, and the power set shown above contains 2^{3} = 8 elements.
The power set of an infinite (either countable or uncountable) set is always uncountable. Moreover, the power set of a set is always strictly "bigger" than the original set in the sense that there is no way to pair every element of S with exactly one element of P( S). (There is never an onto map or surjection from S onto P( S).)
Every partition of a set S is a subset of the powerset of S.
The cardinality of the empty set is zero. For example, the set of all threesided squares has zero members and thus is the empty set. Though it may seem trivial, the empty set, like the number zero, is important in mathematics. Indeed, the existence of this set is one of the fundamental concepts of axiomatic set theory.
Some sets have Infinite set cardinality. The set N of , for instance, is infinite. Some infinite cardinalities are greater than others. For instance, the set of has greater cardinality than the set of natural numbers. However, it can be shown that the cardinality of (which is to say, the number of points on) a straight line is the same as the cardinality of any line segment of that line, of the entire plane, and indeed of any finitedimensional Euclidean space.
Many of these sets are represented using blackboard bold or bold typeface. Special sets of numbers include
Each of the above sets of numbers has an infinite number of elements, and each can be considered to be a proper subset of the sets listed below it. The primes are used less frequently than the others outside of number theory and related fields.
Positive and negative sets are sometimes denoted by superscript plus and minus signs, respectively. For example, ℚ^{+} represents the set of positive rational numbers.
Examples:
Some basic properties of unions:
Examples:
Some basic properties of intersections:
In certain settings all sets under discussion are considered to be subsets of a given universal set U. In such cases, is called the absolute complement or simply complement of A, and is denoted by A′.
Examples:
Some basic properties of complements:
An extension of the complement is the symmetric difference, defined for sets A, B as
Examples:
Some basic properties of Cartesian products: Let A and B be finite sets; then the cardinality of the Cartesian product is the product of the cardinalities:
One of the main applications of naive set theory is constructing relations. A relation from a domain A to a codomain B is a subset of the Cartesian product A × B. Given this concept, we are quick to see that the set F of all ordered pairs ( x, x^{2}), where x is real, is quite familiar. It has a domain set R and a codomain set that is also R, because the set of all squares is subset of the set of all real numbers. If placed in functional notation, this relation becomes f( x) = x^{2}. The reason these two are equivalent is for any given value, y that the function is defined for, its corresponding ordered pair, ( y, y^{2}) is a member of the set F.
The reason is that the phrase welldefined is not very welldefined. It was important to free set theory of these paradoxes because nearly all of mathematics was being redefined in terms of set theory. In an attempt to avoid these paradoxes, set theory was axiomatized based on firstorder logic, and thus axiomatic set theory was born.
For most purposes, however, naive set theory is still useful.
A more general form of the principle can be used to find the cardinality of any finite union of sets:
If A and B are any two sets then,

