Sets
Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 11 1/ 21Sets Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester - - PowerPoint PPT Presentation
Sets Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester - - PowerPoint PPT Presentation
Sets Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 11 1/ 21 Sets Definitions Defining Sets Set Operations The Inclusion-Exclusion Principle Cartesian Products The Power Set Lecture 11 2/ 21 Some Common Sets
Some Common Sets
Loose definition: A set is a collection of objects (called members or elements) I This loose general definition can lead to paradoxes (e.g., Russell’s Paradox) I To stay out of trouble, we will work with a small number of well-understood sets Basic Sets I N = {0, 1, 2, 3, . . .}: The set of natural numbers I Z = {. . . , 3, 2, 1, 0, 1, 2, 3, . . .}: The set of integers I Q: The set of rational numbers, e.g., ratios of integers such as 2 3 , 3 1 , 17 4 I R: The set of real numbers, i.e., decimal numbers with possibly infinite strings- f digits after the decimal point
Subsets
Definitions for Subsets I x 2 A: The element x is a member of the set A I A ✓ B: A is a subset of B, i.e., every element in A is also in B I A = B: Set A and B contain exactly the same elements I ;: The empty set, i.e., the set that contains no elements I U: For any given discussion, all sets will be subsets of a larger set called the universal set or the universe Some Formal Definitions I A ✓ B: 8x 2 U, (x 2 A) ! (x 2 B) I A = B: A ✓ B and B ✓ A True or False? (If false, give a counterexample) I Z ✓ N I N ✓ Z I Q ✓ Z I Z ✓ Q I R ✓ Q I Q ✓ R Lecture 11 4/ 21 13 false L- 3)
}
True False Ira ) TrueDigression: √ 2 is Irrational
Theorem p 2 is irrational Proof by Contradiction:- 1. Suppose the theorem is false
- 2. Then we can write
- 3. So 2 = a2
- 4. Therefore a2 is even, which implies that a is even (see end of Lecture 7)
- 5. Therefore a = 2k for some integer k
- 6. So a2 = 4k2 = 2b2 and hence b2 = 2k2
- 7. Therefore b2 is even, so that b is even
- 8. Thus a and b are both even
- 9. This contradicts the assumption that a and b are relatively prime
- 10. Since assuming that the theorem is false leads to a contradiction, the theorem
More Examples
- 1. {1, 2, 3, 4, 5} = {4, 2, 3, 1, 5} = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5}
- 2. {2, 4} ✓ {1, 2, 3, 4, 5} is true
- 3. {1, 2, 3, 4, 5} ✓ {2, 4} is false
- 4. ; ✓ {1, 2, 3, 4, 5} is true
- 5. {John, Sue, Chen, Shankar} is a set containing 4 names
- 6. {(1, 3), (2, 5), (3, 7)} is a set of ordered pairs
- 7. {{3, 4}, {5, 6, 7}} is a set of sets
- nly unique
Set-Builder Notation
Even natural numbers I {x : x 2 N and x is even} or I {x 2 N : x is even} or I {x 2 N : x = 2k for some k 2 N} (a property description) I {2k : k 2 N} (a form description) Intervals I {x 2 R : 2.1 x 2.6} or [2.1, 2.6] I {x 2 R : 2.1 < x < 2.6} or (2.1, 2.6) I {x 2 R : 2.1 < x 2.6} or (2.1, 2.6] I {x 2 R : 2.1 x < 2.6} or [2.1, 2.6) I {x 2 N : 3 x < 6} or [3, 6) = {3, 4, 5} Other examples: give an alternate description I {n 2 N : n has exactly two positive divisors} I {x 2 R : x2 + 1 = 0} Lecture 11 7/ 21 ° closed interval- pen
.
closed intervals Form description¢
Sa . b : a , bane prime }Examples of Form Notation
- 1. The set of integers that are multiples of 3: {3k : k 2 Z}
- 2. The set of perfect square integers: {m2 : m 2 N} or {m2 : m 2 Z}
- 3. The set of natural numbers that end in a 1: {10k + 1 : k 2 N}
- 4. The set Q: { a
- O
- v
Operations on Sets
Operations on Sets A and B- 1. Intersection A \ B: A \ B = {x 2 U : x 2 A and x 2 B}
- 2. Union A [ B: A [ B = {x 2 U : x 2 A or x 2 B}
- 3. Difference A B: A B = {x 2 U : x 2 A and x 62 B}
- 4. Complement A0: A0 = {x 2 U : x 62 A} or A0 = U A
BHT for Sets
Theorem For sets A, B, and C, the empty set ;, and the universal set U, the following properties hold: (a) Commutative A \ B = B \ A A [ B = B [ A (b) Associative (A \ B) \ C = A \ (B \ C) (A [ B) [ C = A [ (B [ C) (c) Distributive A \ (B [ C) = (A \ B) [ (A \ C) A [ (B \ C) = (A [ B) \ (A [ C) (d) Identity A \ U = A A [ ; = A (e) Negation A [ A0 = U A \ A0 = ; (f) Double negative (A0)0 = A (g) Idempotent A \ A = A A [ A = A (h) DeMorgan’s laws (A \ B)0 = A0 [ B0 (A [ B)0 = A0 \ B0 (i) Universal bound A [ U = U A \ ; = ; (j) Absorption A \ (A [ B) = A A [ (A \ B) = A (k) Complements U0 = ; ;0 = U (l) Compl. & neg. A B = A \ B0 Lecture 11 10/ 21 closeRelation
to
logic
U → v- f
Duality principle
: u → n ¢ s u n → u u →- f
Verification via Venn Diagrams
Example: U = {1, 2, . . . , 15, 16}, A = {1, 2, 5, 7, 9, 11, 13, 15}, B = {2, 3, 5, 7, 11, 13}, C = {1, 4, 9, 16} Example: Show that A \ (B [ C) = (A \ B) [ (A \ C) A B C U A B C U A B C U A B C U A B C U Lecture 11 11/ 21 1 2 4 6 5 7 8 9 10 11 12 13 14 15 16 3 A B C U Also: A \ (B [ C) ✓ B [ CElementwise Proofs 1
Example 1: Prove that A ∩ B ⊆ A- 1. Let x ∈ A ∩ B
- 2. Then x ∈ A and x ∈ B
- 3. In particular, x ∈ A
- 4. So (x ∈ A ∩ B) → (x ∈ A), and hence A ∩ B ⊆ A
Definition
tlxeu :@
e A) → HEB)Elementwise Proofs 2
Example 2: Prove that A ∩ (B ∪ C) ⊆ (A ∩ B) ∪ (A ∩ C)- 1. Let x ∈ A ∩ (B ∪ C)
- 2. Then x ∈ A and x ∈ B ∪ C
- 3. Case 1: x ∈ B
- 4. Case 2: x ∈ C
- 5. In either case, x ∈ A ∩ (B ∪ C) implies that
get
B)YAK))
IElementwise Proofs 3
Example 3: Prove that A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) I By above result, it suffices to show that (A ∩ B) ∪ (A ∩ C) ⊆ A ∩ (B ∪ C) Lecture 11 14/ 21Let
x a CAN B) U@
not
- i. show
that
NEA and case I :X a An B . then xe A exo B hence HEA Case 2 : exe Anc . Then xeA and C ' hence HEA so in both cases . XEA ' a . Show that XO BVC case I : xe An B , hence XEB > Xe BUC Laser : Xo Arc , hence X GC 3- X EA
Elementwise Proofs 4
Example 4: Prove that (A ⊆ B) ∧ (B ⊆ C) → (A ⊆ C)- 1. Let x ∈ A
- 2. Then x ∈ B since A ⊆ B
- 3. Hence x ∈ C since B ⊆ C
- 4. So (x ∈ A) → (x ∈ C), and hence A ⊆ C
The Inclusion-Exclusion Principle
Definition n(A) = the number of elements in the set A Example I A = {2k : k 2 Z+ and k 15} and B = {3k : k 2 Z+ and k 10} I n(A) = n(B) = I A \ B = I n(A \ B) = I A [ B = I n(A [ B) = Theorem (The Inclusion-Exclusion Principle) Let sets A, B, and C be given. Then I n(A [ B) = n(A) + n(B) n(A \ B) I n(A[B[C) = n(A)+n(B)+n(C)n(A\B)n(A\C)n(B\C)+n(A\B\C) n(A) + n(B) + n(C) = n1 + n2 + n3 + 2n4 + 2n5 + 2n6 + 3n7 Lecture 11 16/ 21 2 4 6 8 9 10 12 16 3 A B U 15 21 27 18 24 30 14 20 22 26 28 A B C U F 3 } 2,416,410,13143^936,9 ) I since Any- 163
- I
Cartesian Products
Ordered pairs: Definition The Cartesian product A ⇥ B of sets A and B is defined as {(a, b) : a 2 A and b 2 B}. When both coordinates are taken from the same set A, we write A2 instead of A ⇥ A. Example: For second graph, the set of plotted points are {(x, y) 2 R2 : y = 3x 1} Example: Succinctly describe the sequence a1 = 2, a2 = 4, a3 = 8, . . . using ordered pairs (1, 2), (2, 4), (3, 8), etc.: Example: Describe all possible (sandwich, drink) orders where sandwiches are of type 1, 2, or 3 and drinks are A, B, C, or D: Example: Describe all possible pairs (type of A, type of B) of people you might encounter on the island of Liars and Truthtellers: Lecture 11 17/ 21 scn.sn ) : nettI
Gbh ,3)xSA,B,4D3 49,13A } .- ( 417USD
:{
Liar , Truth teller }t=E4TlxE4T3Size of Cartesian Products
Example: A = {2, 4, 6, 8} and B = {1, 2, 3, 4, 5} A ⇥ B Elements of A Elements of B ! # 1 2 3 4 5 2 (2,1) (2,2) (2,3) (2,4) (2,5) 4 (4,1) (4,2) (4,3) (4,4) (4,5) 6 (6,1) (6,2) (6,3) (6,4) (6,5) 8 (8,1) (8,2) (8,3) (8,4) (8,5) B ⇥ A Elements of B Elements of A ! # 2 4 6 8 1 (1,2) (1,4) (1,6) (1,8) 2 (2,2) (2,4) (2,6) (2,8) 3 (3,2) (3,4) (3,6) (3,8) 4 (4,2) (4,4) (4,6) (4,8) 5 (5,2) (5,4) (5,6) (5,8) Theorem For all finite sets A and B, n(A ⇥ B) = n(A) · n(B). Lecture 11 18/ 21 n lAxB)=nlBxA )Cartesian Products Gone Wild!
Definition For any integer n 3, the structure (x1, x2, . . . , xn) is called an n-tuple. Definition Given sets S1, S2, . . . , Sn, the Cartesian product S1 ⇥ S2 ⇥ · · · ⇥ Sn is the set of all n-tuples (x1, x2, . . . , xn) such that x1 2 S1, x2 2 S2, . . . , xn 2 Sn. When S1, . . . , Sn are all equal to the same set S, we write Sn = S ⇥ S ⇥ · · · ⇥ S | {z } n terms . Theorem A For any finite sets S1, S2, . . . , Sk, n(S1 ⇥ S2 ⇥ · · · ⇥ Sk) = n(S1) · n(S2) · · · · n(Sk) Lecture 11 19/ 21ex
:
⇒Examples: Cartesian Products and Sets of Sets
Example 1: Truth-table values for p, q, r, s: Example 2: 12 ⇥ 12 multiplication table, e.g., (2, 3, 6), (5, 1, 5), and so on: Example 3: List 4 elements of I {T, F}3: I S = {s 2 {0, 1}5 : s consists of three 0’s and two 1’s in some order} I {1, 2, 3, 4, 5} ⇥ {x, y, z} ⇥ {A, B, C, D}: Example 4: Sets of sets I Is {1, 2} ✓ {{1, 2}, {1, 3, 4}}? I Is {1, 2} 2 {{1, 2}, {1, 3, 4}}? I What is n- {{1, 2}, {3, 4}, {1, 3, 4}}
- ?
5=17,03
IT,f34=
5×5×5×5=24
5=514,12){ La
,b,4els1xfs3xlN
: ax 5- c) ka,b,axD :@ Des } 'I
first
.tk/T,f3e:lIIf).CT.f,f),lF,fDco,o,o,lil.Ct9QQDu,x.s),L5,7D)
NO ! e. 9. lisnelanelementotheroght- hand
4435123,9%43
" " 4The Power Set
Definition The power set of A is P(A) = {S : S ✓ A}. Example: For A = {1, 2, 3, 4}, list the elements of P(A) in an orderly manner P({1}) ; {1} P({1, 2}) ; {1} {2} {1, 2} P({1, 2, 3}) ; {1} {2} {1, 2} {3} {1, 3} {2, 3} {1, 2, 3} P({1, 2, 3, 4}) ; {1} {2} {1, 2} {3} {1, 3} {2, 3} {1, 2, 3} {4} {1, 4} {2, 4} {1, 2, 4} {3, 4} {1, 3, 4} {2, 3, 4} {1, 2, 3, 4} Some questions: I How large is P(A)? I If B = {2, 4, 6, 8}, how large is P(B)? I If C = {1, 2, 3, 4, 5}, how large is P(C)? Theorem B For any finite set A, if k = n(A), then n(P(A)) = 2k. Lecture 11 21/ 21 16 16 32