Prerequisite: Logic and Proof TechniquesPropositions, connectives, predicates and quantifiers with the rules for negating them, and the three basic proof techniques (direct, contrapositive, contradiction).Logic and Proof Techniques →. Set operations are the language of logic written with sets.
Sets and elements
A set is a collection of distinct objects, called elements, written between braces: A={1,2,3}. We write 2∈A and 5∈/A. In a set order does not matter ({1,2,3}={3,1,2}) and repetitions do not matter ({1,1,2}={1,2}). The empty set ∅ has no elements. Sets are denoted by capital letters, elements by lower-case ones.
Three ways to describe a set.
- Listing: A={1,2,3}; for infinite sets with dots when the rule is clear, N={0,1,2,3,…}.
- By a predicate: A={x∈N:1≤x<4}={1,2,3}, "the x in N such that 1≤x<4". Equivalent predicates give the same set: {x∈R:x2≤4}=[−2,2]. Mind the ambient set: {x∈N:x2≤4}={0,1,2}.
- Graphically (Venn diagrams): useful to guess relations, not to prove them.
The cardinality ∣A∣ of a finite set is its number of elements: ∣{1,2,3}∣=3, ∣∅∣=0.
Subsets, equality, power set
Definition (subset). B⊆A if every element of B is an element of A: ∀b∈B:b∈A.
{1,3}⊆{1,2,3}, while {1,5}⊆{1,2,3} because 5∈/{1,2,3} (one counterexample disproves a "for all"). For every A, both ∅⊆A (the condition on ∅ is true since there are no elements to check) and A⊆A hold. Strict inclusion B⊂A: B⊆A and some element of A is not in B.
Definition (equality). A=B if A⊆B and B⊆A.
This gives the method to prove that two sets are equal: prove the two inclusions separately.
Definition (power set). P(A) is the set of all subsets of A; its elements are sets.
P({a,b})={∅,{a},{b},{a,b}} (4 elements). For A={1,2,3} the subsets have 0,1,2,3 elements in number 1+3+3+1=8=23.
Proposition. ∣A∣=n⟹∣P(A)∣=2n.
Intuitively, for each of the n elements one decides "in" or "out": 2⋅2⋯2=2n choices (the rigorous proof is by induction, see Induction, Sums and the Binomial TheoremThe principle of induction with its proof, summation notation and its properties, Gauss and geometric sums, factorials, binomial coefficients, Pascal's triangle and Newton's binomial theorem.Induction, Sums and the Binomial Theorem →).
∈ versus ⊆. ∈ links an element to a set, ⊆ links a set to a set.
| Expression |
Valid? |
Why |
| a∈A |
yes |
a is an element of A |
| {a}⊆A |
yes |
the set {a} has the single element a∈A |
| a⊆A |
no |
a is not a set |
| {a}∈A |
no |
elements of A are objects like a |
| {a}∈P(A) |
yes |
elements of P(A) are the subsets of A |
| a∈P(A) |
no |
a is not a subset of A |
| ∅∈P(A) and ∅⊆P(A) |
yes, both |
∅ is a subset of A, and is a subset of every set |
- Disjoint sum. If X∩Y=∅ then ∣X∪Y∣=∣X∣+∣Y∣ (common elements would be counted twice).
- One-to-one correspondence. If f:X→Y is well defined, injective (different elements have different images) and surjective (every element of Y is an image), it is a bijection and ∣X∣=∣Y∣. A quick way to show it is to exhibit the inverse rule from Y to X.
Let E=∅. E is finite if ∣E∣=n for some n∈N, infinite otherwise. Analytic characterization:
E is infinite ⟺ E can be put in bijection with a proper subset of itself.
N is infinite: n↦2n is a bijection between N and the even numbers {0,2,4,…}⊊N (inverse m↦2m). [0,1) is infinite: x↦2x maps it bijectively onto [0,21)⊊[0,1) (inverse y↦2y). Infinite does not mean unbounded: [0,1) is infinite but bounded.
Operations between sets
Fix a universe X=∅ containing all sets considered (in Analysis usually X=R); it is needed to speak about "what is not in A".
- Union: A∪B={x∈X:x∈A or x∈B} (logic: ∨). {1,2,3}∪{3,4}={1,2,3,4}.
- Intersection: A∩B={x∈X:x∈A and x∈B} (logic: ∧). {1,2,3}∩{3,4}={3}. If A∩B=∅ the sets are disjoint.
- Difference: A∖B={x∈X:x∈A, x∈/B}. Not symmetric: {1,2,3}∖{3,4}={1,2} but {3,4}∖{1,2,3}={4}. Also [0,3]∖[1,2]=[0,1)∪(2,3].
- Complement: Bc=X∖B={x∈X:x∈/B} (logic: not). In R, [0,1]c=(−∞,0)∪(1,+∞); the complement depends on the universe ({0,1,2}c is {3,4,…} in N but contains negatives in Z).
Properties. Both ∪ and ∩ are idempotent (A∪A=A), commutative and associative. Distributive laws:
A∪(B∩C)=(A∪B)∩(A∪C)A∩(B∪C)=(A∩B)∪(A∩C)
Check with A={1}, B={1,2}, C={2,3}: B∩C={2} so A∪(B∩C)={1,2}; A∪B={1,2}, A∪C={1,2,3}, intersection {1,2}. Complement: A∪Ac=X, A∩Ac=∅, ∅c=X, Xc=∅.
Law (De Morgan). (A∪B)c=Ac∩Bc and (A∩B)c=Ac∪Bc.
Example in R: A=[0,2], B=[1,3] give (A∪B)c=(−∞,0)∪(3,+∞)=Ac∩Bc. In words: not being in the union means not being in A and not in B; not being in the intersection means not being in A or not in B. They extend to N sets: (⋃i=1NAi)c=⋂i=1NAic and (⋂i=1NAi)c=⋃i=1NAic. They are useful when the complement is easier to compute: Ac∪Bc is just (A∩B)c.
Sets and logic
For A={x:p(x)}, B={x:q(x)}:
| Sets |
Predicate |
| A∪B |
p(x)∨q(x) |
| A∩B |
p(x)∧q(x) |
| Ac |
¬p(x) |
| A∖B |
p(x)∧¬q(x) |
| A⊆B |
p(x)⇒q(x) for all x |
| A=B |
p(x)⇔q(x) for all x |
Since the sets in De Morgan's laws are equal, the predicates are equivalent: this gives the logical De Morgan laws of Logic and Proof TechniquesPropositions, connectives, predicates and quantifiers with the rules for negating them, and the three basic proof techniques (direct, contrapositive, contradiction).Logic and Proof Techniques →. In exercises: "or" means unite the solution sets; "and" (a system) means intersect them.
Cartesian product
A×B={(a,b):a∈A, b∈B}
the set of ordered pairs. For A={1,2}, B={1,2,3}: A×B={(1,1),(1,2),(1,3),(2,1),(2,2),(2,3)}, with 2⋅3=6 elements (∣A×B∣=∣A∣∣B∣). In a pair order matters, (1,2)=(2,1) (unlike {1,2}={2,1}), so in general A×B=B×A. For more sets, An=A×⋯×A (n-tuples).
R corresponds one-to-one to the points of a line, R2={(x,y)} to the points of the Cartesian plane, R3 to space. This is why functions are "drawn": the graph of a function is a subset of R2.
Common mistakes
- Confusing ∪ and ∩ ("or" widens, "and" narrows; always A∩B⊆A⊆A∪B).
- Writing (A∪B)c=Ac∪Bc: the complement swaps ∪ and ∩.
- Forgetting the universe in a complement.
- Writing {1,2} for an ordered pair.
Versione ripasso
Sets. Order and repetitions do not matter. Described by listing, by a predicate ({x∈N:x2≤4}={0,1,2} but {x∈R:x2≤4}=[−2,2]), or by Venn diagrams. ∣A∣ = number of elements.
Subset: B⊆A if ∀b∈B:b∈A. Always ∅⊆A and A⊆A. Equality: A=B iff A⊆B and B⊆A (prove two inclusions).
Power set P(A) = all subsets. ∣A∣=n⟹∣P(A)∣=2n ("in or out" for each element). P({a,b})={∅,{a},{b},{a,b}}. ∈ relates element to set, ⊆ set to set: a∈A, {a}⊆A, {a}∈P(A); but a⊆A and {a}∈A are wrong.
Counting. Disjoint: ∣X∪Y∣=∣X∣+∣Y∣. A bijection (well defined, injective, surjective; or exhibit the inverse) gives ∣X∣=∣Y∣. E is infinite iff it is in bijection with a proper subset: n↦2n for N, x↦2x for [0,1). Infinite does not mean unbounded.
Operations (universe X, usually R):
- A∪B: in A or B (∨). A∩B: in both (∧); disjoint if empty.
- A∖B: in A, not in B (not symmetric). [0,3]∖[1,2]=[0,1)∪(2,3].
- Bc=X∖B (depends on X).
- Distributive: A∪(B∩C)=(A∪B)∩(A∪C), A∩(B∪C)=(A∩B)∪(A∩C).
- A∪Ac=X, A∩Ac=∅.
De Morgan: (A∪B)c=Ac∩Bc, (A∩B)c=Ac∪Bc (also for N sets). Example: A=[0,2], B=[1,3]: (A∪B)c=(−∞,0)∪(3,+∞).
Sets and logic: ∪↔∨, ∩↔∧, complement ↔¬, ⊆↔⇒, =↔⇔; see Logic and Proof TechniquesPropositions, connectives, predicates and quantifiers with the rules for negating them, and the three basic proof techniques (direct, contrapositive, contradiction).Logic and Proof Techniques →. In exercises "or" = unite solutions, "and" = intersect.
Cartesian product: A×B={(a,b)}, ordered pairs, ∣A×B∣=∣A∣∣B∣, (a,b)=(b,a). R2 is the plane, R3 space.
Mistakes: ∪ vs ∩; De Morgan without swapping; no universe in a complement; pair confused with set.