Think of a set as like a bucket of elements. Then the union of two sets is like dumping them together into a combined bucket.
Consider, for example, the sets
The union is then
Note that there is no need to repeat any duplicated elements. As we discussed earlier, a set is defined by membership, so repeating elements does not change what the set is.
Definition: union
If X and Y are any two sets then their union is defined as
Exercise for Unions of Sets of Strings
Consider the character set {'0','1'}.
Let A be the set of all strings of length 1, and B the set of all strings of length 2.
List the elements of the set .
Solution
TODO
Exercise for Pairwise Union
Suppose that A has 3 elements and B has 6.
If then how many elements are in ?
If A and B have no shared elements, then how many elements are in ?
Solution
TODO
Exercise for Emptyset Union
If A is any set then what is ?
Solution
TODO
Exercise for Algebra of Sets?
Can we solve set equations the way that we solve algebraic equations?
Suppose that X is some set which satisfies the equation
Can we determine what X must be?
If we cannot infer what X is, then can we at least make some inference about some of the elements of X?
In many settings, we will be exclusively interested in sets which are all subsets of a single set.
For instance, in some settings we will only be interested in the natural numbers, and all of the sets that we consider will be subsets of it.
Or we might only be interested in the set of real numbers, or other kinds of sets, like the set of all matrices.
Whenever we restrict our interests to the subsets of one particular set, we call that one set the "universal set". We may choose the universal set to be any set that we like.
Once we specify a universal set, we can then define the notion of "the complement of a set".
Suppose that we choose the universal set and consider the subset . Then the complement of A is the set of all elements in the universe which are not in A.
Notice that the choice of universal set will affect the complement of a given set. If the universal set is and then
Exercise
Show that for any universal set U and subset ,
Exercise
Consider the universal set and subsets and .
Find the following sets.
(1.)
(2.)
(3.)
(4.)
We can now state an important relationship between the union, intersection, and complement.
Theorem: U-C De Morgan's
Suppose the universal set is U with subsets A and B. Then
In order to prove that two sets are equal, we must prove that every element in the left set is in the right set; and every element in the right set is in the left set.
In short, the fundamental way to prove a set equality, , is to prove two subset relations.
and
We now do just that, with X identified with the left side, . Y is identified with the right side, .
Proof of of U-C De Morgan's
(1.) If then .
(1.1.) Let .
(1.2.) So .
(1.3.) So x is not in A or B.
(1.4.) So and .
(1.5.) So and .
(1.6.) So .
(2.) So .
(3.) If then .
(3.1.) Let .
(3.2.) So and .
(3.3.) So and .
(3.4.) So x is not in A or B.
(3.5.) So .
(3.6.) So .
(4.) So .
(5.) So .
Audit: U-C De Morgan's
(1.)
If then .
From
Toward
Proved on lines (1.1.) to (1.6.).
.
(1.1.)
Let .
From
Toward
Assumption.
.
(1.2.)
.
From
Toward
(1.1) by definition of complement.
Exchanging formal for logical expressions.
(1.3.)
x is not in A or B.
From
Toward
(1.2.) by definition of union.
Exchanging formal for logical expressions.
(1.4.)
x is not in A, and x is not in B.
From
Toward
(1.3.) by logical inference.
Rephrasing, in terms of "and".
(1.5.)
and .
From
Toward
(1.4.) by definition of complement.
The desired formalized expression.
(1.6.)
.
From
Toward
(1.5.) by definition of intersection.
(2.)
.
From
Toward
(1.) by definition of subsets.
.
(3.)
If then .
From
Toward
Proved on lines (3.1.) to (3.6.).
.
(3.1.)
Let .
From
Toward
Assumption.
.
(3.2.)
and
From
Toward
(3.1.) by definition of intersection.
Exchanging formal for logical expression.
(3.3.)
and .
From
Toward
(3.2.) by definition of complement.
Exchanging formal for logical expression.
(3.4.)
x is not in A or B.
From
Toward
(3.3.) by logical inference.
Rephrasing to use "or".
(3.5.)
.
From
Toward
(3.4.) by definition of union.
Toward the desired formal expression.
(3.6.)
.
From
Toward
(3.5.) by definition of complement.
(4.)
.
From
Toward
(3.) by definition of subsets.
.
(5.)
.
From
Toward
(2.) and (4.) by definition of set equality.
Notice that the way that this proof flows, is to start from formal statements, like "Let " or "Let ."
From there, we progressively "unpack" this formalism, into a language which is more like a logical or natural language. For example, from "", we eventually arrive at "" and then "x is not in A or B".
At this point we have almost entirely exchanged the formalism for logical expressions. Complements (formal) have all been exchanged for negations (logical). Union (formal) has been exchange for disjunction (logical).
Now that we have exchanged formalism for logical expression, we are free to reason logically. We use that freedom to reason that "x is not in A or B" is logically equivalent to "x is not in A and x is not in B".
After this, we return everything to formalism. At the end of this sequence, we ultimately arrive at the goal: .
In the following proof, we repeat a very similar flow. However, the logic required is a bit different from the above proof.
Theorem: I-C De Morgan's
Let A and B be two sets with universe U. Then
As is common with set equalities, we again prove two subset relations.
Proof of of I-C De Morgan's
(1.) If then .
(1.1.) Let .
(1.2.) So .
(1.3.) So x is not in A and B.
(1.4.) So either , or .
(1.5.) If then .
(1.5.1.) Assume .
(1.5.2.) Then .
(1.5.3.) Then or .
(1.5.4.) Then .
(1.6.) If then .
(1.6.1.) Repeat, mutatis mutandis, lines (1.5.1.) to (1.5.4.).
(1.7.) In all cases, we have .
(2.) So .
(3.) If then .
(3.1.) Let .
(3.2.) So or .
(3.3.) So or .
(3.4.) If then .
(3.4.1.) Assume .
(3.4.2.) Then x is not in A and B.
(3.4.3.) Then .
(3.4.4.) Then .
(3.5.) If then .
(3.5.1.) Repeat, mutatis mutandis, steps like (3.4.1.) through (3.4.4.).
(3.6.) Therefore, in all cases, .
(4.) Therefore .
(5.) Therefore .
Audit: I-C De Morgan's
(1.)
If then .
From
Toward
Proved on lines (1.1.) to (1.7.).
.
(1.1.)
Let .
From
Toward
Assumption.
.
(1.2.)
.
From
Toward
(1.1) by definition of complement.
Exchanging formal for logical expressions.
(1.3.)
x is not in A and B.
From
Toward
(1.2.) by definition of intersection.
Exchanging formal for logical expressions.
(1.4.)
, or .
From
Toward
(1.3.) by logical inference.
Rephrasing, in terms of "or".
(1.5.)
If then .
From
Toward
Proved on lines (1.5.1.) to (1.5.4.).
One case, in a proof by cases.
(1.5.1.)
Assume .
From
Toward
Assumption.
.
(1.5.2.)
.
From
Toward
(1.5.1.) by definition of complement.
.
(1.5.3.)
or .
From
Toward
(1.5.2.) by logical inference.
(1.5.4.)
.
From
Toward
(1.5.3.) by definition of union.
(1.6.)
If then .
From
Toward
Proved on lines (1.6.1.) to (1.6.4.).
Second case in a proof by cases.
(1.6.1.)
Repeat, mutatis mutandis the lines (1.5.1.) to (1.5.4.).
From
Toward
(1.7.)
.
From
Toward
(1.4.) and (1.5.) and (1.6.) by proof by cases
(2.)
.
From
Toward
(3.)
If then .
From
Toward
Proved on lines (3.1.) to (3.6.).
.
(3.1.)
Let .
From
Toward
Assumption.
.
(3.2.)
or .
From
Toward
(3.1.) by definition of union.
Exchange formal for logical expressions.
(3.3.)
or .
From
Toward
(3.2.) by definition of complement.
Exchanging formal for logical expressions.
(3.4.)
If then .
From
Toward
Proved on lines (3.4.1.) through (3.4.4.)
First case in a proof by cases.
(3.4.1.)
Assume .
From
Toward
Assumption.
.
(3.4.2.)
x is not in A and B.
From
Toward
(3.4.1.) by logical inference.
.
(3.4.3.)
From
Toward
(3.4.2.) by definition of intersection.
(3.4.4.)
.
From
Toward
(3.4.3.) by definition of complement.
(3.5.)
If then .
From
Toward
Proved on line (3.5.1.).
Second case in a proof by cases.
(3.5.1.)
Repeat, mutatis mutandis, steps like (3.4.1.) through (3.4.4.).
From
Toward
(3.6.)
In all cases, .
From
Toward
(3.3.) and (3.4.) and (3.5.) by proof by cases.
(4.)
.
From
Toward
(3.) by definition of subset.
.
(5.)
.
From
Toward
Exercise
In the style of the proofs above, prove the so-called "distribution laws"
and
for any sets A, B, C.
Exercise
Prove all of the following set identities, for sets A and B with universe U.
I have named some of the identities, to indicate an analogy between sets and familiar number properties. In many ways acts like the number zero, and U acts like one. Continuing the analogy, often, acts like plus, and acts like times.
Keep in mind that the analogy is just that, an analogy. It is not perfectly accurate, and is important to notice the ways in which the analogy breaks down.
If we have any finite collection of sets, then we can union all of them together with a finite number of pairwise unions.
However, it can be more compact and convenient to use "big union" notation instead.
What this means is "Start with and the corresponding set . Then take and the set , and then , and so on, up to with each of the corresponding sets. Take the union of all of these."
Definition: union from 1 to n
Let be any "indexed sequence of sets", where the indices are written in the subscripts, from index 1 to n. Then we define the union of for index i from 1 to n as
Equivalently,
Exercise
Let be the set of natural numbers divisible by 2, and the set of natural numbers divisible by 3, and the natural numbers divisible by 4.
Write the first five elements of .
This is a notational convenience, especially valuable when the number of sets is large.
However, we can even generalize the notation to permit so-to-speak "infinite unions".
Definition: union from 1 to
Let be any infinite indexed sequence of sets, from 1 to infinity. Then we define the union of for i from one to as
Exercise
For each i, define as the set of all strings of length i. What, then, is the set
Note that the index begins at 2, and therefore we have not technically defined exactly what this means.
Of course, we just mean the same basic idea as except that we do not include .
Of course we may naturally also extend the notion of intersection to an infinitary intersection.
Definition: big intersection
Let be any indexed sequence of sets, from index 1 to n. We define the union of for index i from 1 to n as
If be any indexed sequence of sets, from 1 to infinity. We define the union of for i from 1 to infinity as
Exercise
Show that the following identities hold for the infinitary operations, for any sequence of sets , and set B, with universe U.
A construction that we will use very often is to construct the set of all pairs, from two given sets.
First we need to be clear about what a pair is.
The "pair" of 1 and 'a' is written as (1,'a'). Mathematically, a pair is very similar to a list of length two. In this example, 1 is the left "coordinate" and 'a' is the right coordinate.
Unlike sets, for pairs order will matter. That is to say, .
Pairs allow for each coordinate to be equal. That is to say, (1,1) is a legitimate pair.
Now consider the sets and B = {'a','b'}. The set of all pairs, with left coordinates in A and right coordinates in B, is
Notice that, for every choice of element and every choice of element , the pair is present in .
Also notice that if A has m elements and if B has n elements, then has elements. This is surely from whence the name "set product" derives.
Suppose that the set C is . If we then write the product of all three sets then this is
Notice that this is made of pairs, for which the left coordinate is itself pairs from A and B; the right coordinate is from C.
Notice that this is not exactly the same thing as . This would result in pairs, which would have left coordinates in A and right coordinates would be pairs from B and C.
Although these are technically different, we will never be interested in this difference.
We will often write as a short-hand for , although you are also free to think of as the set of triples. For instance, you are free to write
Definition: set product
Let A and B be two sets. We define the set product of A and B by
For an indexed sequence of sets for index 1 to n, if we write then we mean to take the products "from left to right".
We use the notation to represent .
More generally, represents .
Exercise
List three elements from the set product if A is the set of all strings and B is the set of negative rational numbers.
Exercise
Let . Find and .
Hint: The former should have 4 elements, the latter 8 elements.