Upload
magdalen-oconnor
View
214
Download
0
Embed Size (px)
Citation preview
What is a set?
• A set is a collection of zero or more objects– These objects are called elements
• No duplicates
• Order does not matter
Examples
• {2,3,5,7,11}
• {(1,1), (2,2), (3,3)}
• {Apple, Orange, Banana, Peach}
• {Apple, Dell, IBM}
• {Heads, Tails}
• {Win, Lose, Tie}
• {}
Order does not matter
• {3,4} = {4,3}
• {1,2,3,4,5} = {2,3,4,5,1}
• {1,4,2,5,3} = {1,3,5,2,4}
• {Apple, Dell, IBM} = {Dell, Apple, IBM}
Element-of Notation
• “x S” means that x is an element of the set S.
• 1 {1,2,3}
• 2 {1,2,3}
• 3 {1,2,3}
Not-an-element-of Notation
• “x S” means that x is not an element of the set S.
• 0 {1,2,3}
• 4 {1,2,3}
• 17 {1,2,3}
Empty Set
• {} contains no elements at all
• {} = the set of 70-year-old Math C067 students
• {} = the set of 25-year-old U.S. Presidents is another symbol for the empty set
Set Descriptors
• The set consisting of all objects with some particular property can be denoted– {x : x has that particular property }
• {x : x is a positive integer less than 4} = {1,2,3}
• If it is understood that x is an integer we can write {x : 1 x < 4} = {1,2,3}
Examples with Letters
• Let U = {A,B,…,Z}• Let V = {x : x is a vowel} = {A,E,I,O,U}• Let C = {x : x is not a vowel} =
{B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F} • Let P = {g : g is a passing grade} = {A,B,C,D}
Intersection
• The intersection of two sets A and B consists of all objects that belong to both A and B
• A B = {x : x A and x B}
• S {} = {} (true for every set S)
• S U = S (true for every set S)
Intersection Examples
• Let V = {x : x is a vowel} = {A,E,I,O,U}• Let C = {x : x is not a vowel} =
{B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F} • Let P = {g : g is a passing grade} = {A,B,C,D}• P V = {A}
Intersection Examples
• Let V = {x : x is a vowel} = {A,E,I,O,U}• Let C = {x : x is not a vowel} =
{B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F} • Let P = {g : g is a passing grade} = {A,B,C,D}• C P = {B,C,D}
Intersection Examples
• Let V = {x : x is a vowel} = {A,E,I,O,U}• Let C = {x : x is not a vowel} =
{B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F} • Let P = {g : g is a passing grade} = {A,B,C,D}• G P = {A,B,C,D} = P
Union
• The union of two sets A and B consists of all objects that belong to one or both sets A and B
• A B = {x : x A or x B}
• S {} = S (true for every set S)
• S U = U (true for every set S)
Union Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• P V = {A,B,C,D,E,I,O,U}
Union Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• G P = {A,B,C,D,F}
Union Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• V C = U
Disjointness Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• V and C are disjoint
Subsets
• A is a subset of B (written A B) • Every element of A is an element of B • A B = A • A B = B
Subset Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• P G
Subset Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• V U
Subset Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• {} V
Complement
• The complement of a set S consists of everything (in the universal set) that does not belong to S
• It is denoted Sc
• Sc = {x : x S}
• Uc = {}, {}c = U
• (Sc)c = S
Complementation Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• V = Cc
Complementation Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• C = Vc
Proof of DeMorgan’s 2nd Law
• DeMorgan’s 1st Law says(A B)c = Ac Bc
• Apply DeMorgan’s 1st Law to Ac and Bc
(Ac Bc)c = (Ac)c (Bc)c
(Ac Bc)c = A B
• Complement both sides of the equation:((Ac Bc)c)
c = (A B)c
Ac Bc = (A B)c
Cardinality Examples
• |{2,3,5,7,11}| = 5
• |{(1,1), (2,2), (3,3)}| = 3
• |{Apple, Orange, Banana, Peach}| = 4
• |{Apple, Dell, IBM}| = 3
• |{Heads, Tails}| = 2
• |{Win, Lose, Tie}| = 3
• |{}| = 0
Cardinality Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• |U| = 26
Cardinality Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• |V| = 5
Cardinality Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• |C| = 26-|V| = 26-5 = 21
Cardinality Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• |G| = 5
Cardinality Examples
• Let U = {A,B,…,Z}
• Let V = {x : x is a vowel} = {A,E,I,O,U}
• Let C = {x : x is not a vowel} = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}
• Let G = {g : g is a grade} = {A,B,C,D,F}
• Let P = {g : g is a passing grade} = {A,B,C,D}
• |P| = 4
Cardinality of Union
• |A B| =? |A| + |B|
• Let V = {A,E,I,O,U} 5
• Let P = {A,B,C,D} +4
• V P = {A,B,C,D,E,I,O,U} 8
Cardinality of Union
• |A B| =? |A| + |B|
• Let V = {A,E,I,O,U} 5
• Let P = {A,B,C,D} +4
• V P = {A,B,C,D,E,I,O,U} 8
Cardinality of Union
• |A B| = |A| + |B| |A B|
• Let V = {A,E,I,O,U} 5
• Let P = {A,B,C,D} +4
• V P = {A} 1• V P = {A,B,C,D,E,I,O,U} =8
Cardinality of Disjoint Union
• If A and B are disjoint sets then|A B| = |A| + |B|
• Why?• Because A B = {},• |A B| = |A| + |B| |A B|
= |A| + |B| |{}| = |A| + |B| 0 = |A| + |B|
Example
• If A and B are disjoint sets then
|A B| = |A| + |B|
• Let H = {H,P} 2
• Let I = {I,B,M} +3
• H I = {}
• H I = {H,P,I,B,M} =5
Difference of Two Sets
• The difference of two sets A and B consists of everything that belongs to A but does not belong to B.
• It is denoted A B• It is also denoted A \ B
• A B = A Bc
Examples of Set Difference
• Let V = {A,E,I,O,U}
• Let P = {A,B,C,D}
• V P = {E,I,O,U}
• P V = {B,C,D}
Cardinality of a Set Difference
• A = (AB) (AB)
• Because AB and AB are disjoint
|A| = |AB| + |AB|
• Rearranging,
|A| |AB| = |AB|
• so |AB| = |A| |AB|
|V P| = |V| |V P|
• Let V = {A,E,I,O,U} 5
• Let P = {A,B,C,D}
• V P = P V ={A} 1• V P = {E,I,O,U} =4
• P V = {B,C,D}
|P V| = |P| |P V|
• Let V = {A,E,I,O,U}
• Let P = {A,B,C,D} 4
• V P = P V ={A} 1• V P = {E,I,O,U}
• P V = {B,C,D} =3
(Cartesian) Product of Two Sets
• A B = {(a,b) : a A and b B}
• Let A = {egg roll, soup}
• Let B = {lo mein, chow mein, egg fu yung}
• A B =
{(egg roll,lo mein), (egg roll, chow mein),
(egg roll,egg fu yung), (soup,lo mein),
(soup,chow mein), (soup,egg fu yung)}
Cardinality of A B
• |A B| = |A| |B|(the raised dot means multiply)
• Let A = {egg roll, soup}
• Let B = {lo mein, chow mein, egg fu yung}
• |A B| = |A| |B| = 2 3 = 6
Another Example
• Let A = {1,2,3,4}
• Let B = {a,b,c}
• A B = {(1,a), (2,a), (3,a), (4,a), (1,b), (2,b),
(3,b), (4,b), (1,c), (2,c), (3,c), (4,c)}
= {(1,a), (2,a), (3,a), (4,a),
(1,b), (2,b), (3,b), (4,b),
(1,c), (2,c), (3,c), (4,c)}
• 43 rectangle contains 43 points
Longer Products
• A B C = (A B) C = A (B C)
= {(a,b,c) : a A and b B and c C}
• |A B C| = |A| |B| |C|
• A2 = A A
• A3 = A A A, etc.
• |Ak|= |A|k
Examples
• Let A = {Heads,Tails}
• A2 = {(Heads,Heads), (Heads,Tails)
(Tails,Heads), (Tails, Tails)}
• A3 = {(Heads,Heads,Heads),(Heads,Heads,Tails),
(Heads,Tails,Heads),(Heads,Tails,Tails),
(Tails,Heads,Heads),(Tails,Heads,Tails),
(Tails,Tails,Heads),(Tails,Tails,Tails)}
Examples
• Let A = {Heads,Tails}
• |A| = 2
• |A2| = |A|2 = 22 = 4
• |A3| = |A|3 = 23 = 8
• |A4| = |A|4 = 24 = 16
Application 1
• Yong’s Chinese restaurant offers 3 entrees– lo mein, chow mein, and egg fu yung
• each of which can be prepared with– chicken, beef, pork, shrimp, or no meat
• Yong’s menu includes 2 desserts:– ice cream or lychee nuts
Application 1 (continued)
• Let M = {chicken,beef,pork,shrimp,plain}• Let E = {lo mein, chow mein, egg fu yung}• A dinner order without dessert can be
represented as an ordered pair (m,e) where m M and e E. The set of all such dinner orders is
M E = {(m,e) : m M and e E}The number of possible dinner orders is
|M E| = |M| |E| = 5 3 = 15.
Application 1 (continued)
• Let M = {chicken,beef,pork,shrimp,plain}• Let E = {lo mein, chow mein, egg fu yung}• Let D = {ice cream, lychee nuts}• A dinner order including dessert can be
represented as an ordered triple (m,e,d) where m M, e E, and d D. The set of all such dinner orders is M E D = {(m,e,d) : m M and e E and d E}|M E D | = |M| |E| |D| = 5 3 2 = 30
Application 2
• The set of possible outcomes for a single coin flip is {H,T}, where H stands for heads and T stands for tails.
• We represent the results of several coin flips as an ordered tuple.
• The set of possible outcomes when one coin is flipped 10 times or when 10 distinguishable coins are flipped is {H,T}10.
• The number of possible outcomes is |{H,T}10| = |{H,T}|10 = 210 = 1024