Salta al contenuto
Note per Studenti Sets and Set Operations Report

Sets and Set Operations

In questa pagina 7

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}A = \{1, 2, 3\}. We write 2∈A2 \in A and 5∉A5 \notin A. In a set order does not matter ({1,2,3}={3,1,2}\{1,2,3\} = \{3,1,2\}) and repetitions do not matter ({1,1,2}={1,2}\{1,1,2\} = \{1,2\}). The empty set ∅\emptyset has no elements. Sets are denoted by capital letters, elements by lower-case ones.

Three ways to describe a set.

  1. Listing: A={1,2,3}A = \{1,2,3\}; for infinite sets with dots when the rule is clear, N={0,1,2,3,… }\mathbb{N} = \{0,1,2,3,\dots\}.
  2. By a predicate: A={x∈N:1≤x<4}={1,2,3}A = \{x \in \mathbb{N} : 1 \le x < 4\} = \{1,2,3\}, "the xx in N\mathbb{N} such that 1≤x<41 \le x < 4". Equivalent predicates give the same set: {x∈R:x2≤4}=[−2,2]\{x \in \mathbb{R} : x^2 \le 4\} = [-2,2]. Mind the ambient set: {x∈N:x2≤4}={0,1,2}\{x \in \mathbb{N} : x^2 \le 4\} = \{0,1,2\}.
  3. Graphically (Venn diagrams): useful to guess relations, not to prove them.

The cardinality ∣A∣|A| of a finite set is its number of elements: ∣{1,2,3}∣=3|\{1,2,3\}| = 3, ∣∅∣=0|\emptyset| = 0.

Subsets, equality, power set

Definition (subset). B⊆AB \subseteq A if every element of BB is an element of AA: ∀b∈B:b∈A\forall b \in B : b \in A.

{1,3}⊆{1,2,3}\{1,3\} \subseteq \{1,2,3\}, while {1,5}⊈{1,2,3}\{1,5\} \not\subseteq \{1,2,3\} because 5∉{1,2,3}5 \notin \{1,2,3\} (one counterexample disproves a "for all"). For every AA, both ∅⊆A\emptyset \subseteq A (the condition on ∅\emptyset is true since there are no elements to check) and A⊆AA \subseteq A hold. Strict inclusion B⊂AB \subset A: B⊆AB \subseteq A and some element of AA is not in BB.

Definition (equality). A=BA = B if A⊆BA \subseteq B and B⊆AB \subseteq A.

This gives the method to prove that two sets are equal: prove the two inclusions separately.

Definition (power set). P(A)\mathcal{P}(A) is the set of all subsets of AA; its elements are sets.

P({a,b})={∅,{a},{b},{a,b}}\mathcal{P}(\{a,b\}) = \{\emptyset, \{a\}, \{b\}, \{a,b\}\} (44 elements). For A={1,2,3}A = \{1,2,3\} the subsets have 0,1,2,30,1,2,3 elements in number 1+3+3+1=8=231+3+3+1 = 8 = 2^3.

Proposition. ∣A∣=n  ⟹  ∣P(A)∣=2n|A| = n \implies |\mathcal{P}(A)| = 2^n.

Intuitively, for each of the nn elements one decides "in" or "out": 2⋅2⋯2=2n2 \cdot 2 \cdots 2 = 2^n 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 →).

∈\in versus ⊆\subseteq. ∈\in links an element to a set, ⊆\subseteq links a set to a set.

Expression Valid? Why
a∈Aa \in A yes aa is an element of AA
{a}⊆A\{a\} \subseteq A yes the set {a}\{a\} has the single element a∈Aa \in A
a⊆Aa \subseteq A no aa is not a set
{a}∈A\{a\} \in A no elements of AA are objects like aa
{a}∈P(A)\{a\} \in \mathcal{P}(A) yes elements of P(A)\mathcal{P}(A) are the subsets of AA
a∈P(A)a \in \mathcal{P}(A) no aa is not a subset of AA
∅∈P(A)\emptyset \in \mathcal{P}(A) and ∅⊆P(A)\emptyset \subseteq \mathcal{P}(A) yes, both ∅\emptyset is a subset of AA, and is a subset of every set

Counting tools; finite and infinite sets

  1. Disjoint sum. If X∩Y=∅X \cap Y = \emptyset then ∣X∪Y∣=∣X∣+∣Y∣|X \cup Y| = |X| + |Y| (common elements would be counted twice).
  2. One-to-one correspondence. If f:X→Yf : X \to Y is well defined, injective (different elements have different images) and surjective (every element of YY is an image), it is a bijection and ∣X∣=∣Y∣|X| = |Y|. A quick way to show it is to exhibit the inverse rule from YY to XX.

Let E≠∅E \ne \emptyset. EE is finite if ∣E∣=n|E| = n for some n∈Nn \in \mathbb{N}, infinite otherwise. Analytic characterization:

EE is infinite   ⟺  \iff EE can be put in bijection with a proper subset of itself.

N\mathbb{N} is infinite: n↦2nn \mapsto 2n is a bijection between N\mathbb{N} and the even numbers {0,2,4,… }⊊N\{0,2,4,\dots\} \subsetneq \mathbb{N} (inverse m↦m2m \mapsto \frac m2). [0,1)[0,1) is infinite: x↦x2x \mapsto \frac x2 maps it bijectively onto [0,12)⊊[0,1)[0,\frac12) \subsetneq [0,1) (inverse y↦2yy \mapsto 2y). Infinite does not mean unbounded: [0,1)[0,1) is infinite but bounded.

Operations between sets

Fix a universe X≠∅X \ne \emptyset containing all sets considered (in Analysis usually X=RX = \mathbb{R}); it is needed to speak about "what is not in AA".

  • Union: A∪B={x∈X:x∈A or x∈B}A \cup B = \{x \in X : x \in A \text{ or } x \in B\} (logic: ∨\vee). {1,2,3}∪{3,4}={1,2,3,4}\{1,2,3\} \cup \{3,4\} = \{1,2,3,4\}.
  • Intersection: A∩B={x∈X:x∈A and x∈B}A \cap B = \{x \in X : x \in A \text{ and } x \in B\} (logic: ∧\wedge). {1,2,3}∩{3,4}={3}\{1,2,3\} \cap \{3,4\} = \{3\}. If A∩B=∅A \cap B = \emptyset the sets are disjoint.
  • Difference: A∖B={x∈X:x∈A, x∉B}A \setminus B = \{x \in X : x \in A,\ x \notin B\}. Not symmetric: {1,2,3}∖{3,4}={1,2}\{1,2,3\} \setminus \{3,4\} = \{1,2\} but {3,4}∖{1,2,3}={4}\{3,4\} \setminus \{1,2,3\} = \{4\}. Also [0,3]∖[1,2]=[0,1)∪(2,3][0,3] \setminus [1,2] = [0,1) \cup (2,3].
  • Complement: Bc=X∖B={x∈X:x∉B}B^c = X \setminus B = \{x \in X : x \notin B\} (logic: not). In R\mathbb{R}, [0,1]c=(−∞,0)∪(1,+∞)[0,1]^c = (-\infty,0) \cup (1,+\infty); the complement depends on the universe ({0,1,2}c\{0,1,2\}^c is {3,4,… }\{3,4,\dots\} in N\mathbb{N} but contains negatives in Z\mathbb{Z}).

Properties. Both ∪\cup and ∩\cap are idempotent (A∪A=AA \cup A = A), commutative and associative. Distributive laws: A∪(B∩C)=(A∪B)∩(A∪C)A∩(B∪C)=(A∩B)∪(A∩C)A \cup (B \cap C) = (A \cup B) \cap (A \cup C) \qquad A \cap (B \cup C) = (A \cap B) \cup (A \cap C) Check with A={1}A = \{1\}, B={1,2}B = \{1,2\}, C={2,3}C = \{2,3\}: B∩C={2}B \cap C = \{2\} so A∪(B∩C)={1,2}A \cup (B \cap C) = \{1,2\}; A∪B={1,2}A \cup B = \{1,2\}, A∪C={1,2,3}A \cup C = \{1,2,3\}, intersection {1,2}\{1,2\}. Complement: A∪Ac=XA \cup A^c = X, A∩Ac=∅A \cap A^c = \emptyset, ∅c=X\emptyset^c = X, Xc=∅X^c = \emptyset.

Law (De Morgan). (A∪B)c=Ac∩Bc(A \cup B)^c = A^c \cap B^c and (A∩B)c=Ac∪Bc(A \cap B)^c = A^c \cup B^c.

Example in R\mathbb{R}: A=[0,2]A = [0,2], B=[1,3]B = [1,3] give (A∪B)c=(−∞,0)∪(3,+∞)=Ac∩Bc(A \cup B)^c = (-\infty,0) \cup (3,+\infty) = A^c \cap B^c. In words: not being in the union means not being in AA and not in BB; not being in the intersection means not being in AA or not in BB. They extend to NN sets: (⋃i=1NAi)c=⋂i=1NAic\big(\bigcup_{i=1}^N A_i\big)^c = \bigcap_{i=1}^N A_i^c and (⋂i=1NAi)c=⋃i=1NAic\big(\bigcap_{i=1}^N A_i\big)^c = \bigcup_{i=1}^N A_i^c. They are useful when the complement is easier to compute: Ac∪BcA^c \cup B^c is just (A∩B)c(A \cap B)^c.

Sets and logic

For A={x:p(x)}A = \{x : p(x)\}, B={x:q(x)}B = \{x : q(x)\}:

Sets Predicate
A∪BA \cup B p(x)∨q(x)p(x) \vee q(x)
A∩BA \cap B p(x)∧q(x)p(x) \wedge q(x)
AcA^c ¬p(x)\neg p(x)
A∖BA \setminus B p(x)∧¬q(x)p(x) \wedge \neg q(x)
A⊆BA \subseteq B p(x)⇒q(x)p(x) \Rightarrow q(x) for all xx
A=BA = B p(x)⇔q(x)p(x) \Leftrightarrow q(x) for all xx

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}A \times B = \{(a,b) : a \in A,\ b \in B\} the set of ordered pairs. For A={1,2}A = \{1,2\}, B={1,2,3}B = \{1,2,3\}: A×B={(1,1),(1,2),(1,3),(2,1),(2,2),(2,3)}A \times B = \{(1,1),(1,2),(1,3),(2,1),(2,2),(2,3)\}, with 2⋅3=62 \cdot 3 = 6 elements (∣A×B∣=∣A∣ ∣B∣|A \times B| = |A|\,|B|). In a pair order matters, (1,2)≠(2,1)(1,2) \ne (2,1) (unlike {1,2}={2,1}\{1,2\} = \{2,1\}), so in general A×B≠B×AA \times B \ne B \times A. For more sets, An=A×⋯×AA^n = A \times \dots \times A (nn-tuples).

R\mathbb{R} corresponds one-to-one to the points of a line, R2={(x,y)}\mathbb{R}^2 = \{(x,y)\} to the points of the Cartesian plane, R3\mathbb{R}^3 to space. This is why functions are "drawn": the graph of a function is a subset of R2\mathbb{R}^2.

Common mistakes

  • Confusing ∪\cup and ∩\cap ("or" widens, "and" narrows; always A∩B⊆A⊆A∪BA \cap B \subseteq A \subseteq A \cup B).
  • Writing (A∪B)c=Ac∪Bc(A \cup B)^c = A^c \cup B^c: the complement swaps ∪\cup and ∩\cap.
  • Forgetting the universe in a complement.
  • Writing {1,2}\{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}\{x \in \mathbb{N} : x^2 \le 4\} = \{0,1,2\} but {x∈R:x2≤4}=[−2,2]\{x \in \mathbb{R} : x^2 \le 4\} = [-2,2]), or by Venn diagrams. ∣A∣|A| = number of elements.

Subset: B⊆AB \subseteq A if ∀b∈B:b∈A\forall b \in B : b \in A. Always ∅⊆A\emptyset \subseteq A and A⊆AA \subseteq A. Equality: A=BA = B iff A⊆BA \subseteq B and B⊆AB \subseteq A (prove two inclusions).

Power set P(A)\mathcal{P}(A) = all subsets. ∣A∣=n  ⟹  ∣P(A)∣=2n|A| = n \implies |\mathcal{P}(A)| = 2^n ("in or out" for each element). P({a,b})={∅,{a},{b},{a,b}}\mathcal{P}(\{a,b\}) = \{\emptyset,\{a\},\{b\},\{a,b\}\}. ∈\in relates element to set, ⊆\subseteq set to set: a∈Aa \in A, {a}⊆A\{a\} \subseteq A, {a}∈P(A)\{a\} \in \mathcal{P}(A); but a⊆Aa \subseteq A and {a}∈A\{a\} \in A are wrong.

Counting. Disjoint: ∣X∪Y∣=∣X∣+∣Y∣|X \cup Y| = |X| + |Y|. A bijection (well defined, injective, surjective; or exhibit the inverse) gives ∣X∣=∣Y∣|X| = |Y|. EE is infinite iff it is in bijection with a proper subset: n↦2nn \mapsto 2n for N\mathbb{N}, x↦x2x \mapsto \frac x2 for [0,1)[0,1). Infinite does not mean unbounded.

Operations (universe XX, usually R\mathbb{R}):

  • A∪BA \cup B: in AA or BB (∨\vee). A∩BA \cap B: in both (∧\wedge); disjoint if empty.
  • A∖BA \setminus B: in AA, not in BB (not symmetric). [0,3]∖[1,2]=[0,1)∪(2,3][0,3] \setminus [1,2] = [0,1) \cup (2,3].
  • Bc=X∖BB^c = X \setminus B (depends on XX).
  • Distributive: A∪(B∩C)=(A∪B)∩(A∪C)A \cup (B \cap C) = (A \cup B) \cap (A \cup C), A∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C) = (A \cap B) \cup (A \cap C).
  • A∪Ac=XA \cup A^c = X, A∩Ac=∅A \cap A^c = \emptyset.

De Morgan: (A∪B)c=Ac∩Bc(A \cup B)^c = A^c \cap B^c, (A∩B)c=Ac∪Bc(A \cap B)^c = A^c \cup B^c (also for NN sets). Example: A=[0,2]A = [0,2], B=[1,3]B = [1,3]: (A∪B)c=(−∞,0)∪(3,+∞)(A \cup B)^c = (-\infty,0) \cup (3,+\infty).

Sets and logic: ∪↔∨\cup \leftrightarrow \vee, ∩↔∧\cap \leftrightarrow \wedge, complement ↔¬\leftrightarrow \neg, ⊆↔⇒\subseteq \leftrightarrow \Rightarrow, =↔⇔= \leftrightarrow \Leftrightarrow; 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)}A \times B = \{(a,b)\}, ordered pairs, ∣A×B∣=∣A∣∣B∣|A \times B| = |A||B|, (a,b)≠(b,a)(a,b) \ne (b,a). R2\mathbb{R}^2 is the plane, R3\mathbb{R}^3 space.

Mistakes: ∪\cup vs ∩\cap; De Morgan without swapping; no universe in a complement; pair confused with set.

Teoria collegata