cs 173: discrete structures
TRANSCRIPT
![Page 2: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/2.jpg)
2
Agenda
• Sets (sections 2.1, 2.2)
![Page 3: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/3.jpg)
3
Set Theory
Sets you should know:
Notation you should know:
![Page 4: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/4.jpg)
4
Set Theory - Definitions and notation
A set is an unordered collection of elements.
Some examples:
{1, 2, 3} is the set containing “1” and “2” and “3.”{1, 1, 2, 3, 3} = {1, 2, 3} since repetition is irrelevant.{1, 2, 3} = {3, 2, 1} since sets are unordered.{1, 2, 3, …} is a way we denote an infinite set (in this case,
the natural numbers).∅ = {} is the empty set, or the set containing no elements.
Note: ∅ ≠ {∅}
![Page 5: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/5.jpg)
5
Set Theory - Definitions and notation
x ∈ S means “x is an element of set S.”x ∉ S means “x is not an element of set S.”
A ⊆ B means “A is a subset of B.”
Venn Diagram
or, “B contains A.”or, “every element of A is also in B.”or, ∀x ((x ∈ A) → (x ∈ B)).
A
B
![Page 6: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/6.jpg)
6
Set Theory - Definitions and notation
A ⊆ B means “A is a subset of B.”A ⊇ B means “A is a superset of B.”
A = B if and only if A and B have exactly the sameelements.
iff, A ⊆ B and B ⊆ Aiff, A ⊆ B and A ⊇ Biff, ∀x ((x ∈ A) ↔ (x ∈ B)).
So to show equality of sets A and B, show:• A ⊆ B• B ⊆ A
![Page 7: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/7.jpg)
7
Set Theory - Definitions and notationA ⊂ B means “A is a proper subset of B.”
– A ⊆ B, and A ≠ B.– ∀x ((x ∈ A) → (x ∈ B)) ∧ ¬∀x ((x ∈ B) → (x ∈ A))– ∀x ((x ∈ A) → (x ∈ B)) ∧ ∃x ¬(¬(x ∈ B) v (x ∈ A))– ∀x ((x ∈ A) → (x ∈ B)) ∧ ∃x ((x ∈ B) ∧ ¬(x ∈ A))– ∀x ((x ∈ A) → (x ∈ B)) ∧ ∃x ((x ∈ B) ∧ (x ∉ A))
A
B
![Page 8: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/8.jpg)
8
Set Theory - Definitions and notationQuick examples:• {1,2,3} ⊆ {1,2,3,4,5}• {1,2,3} ⊂ {1,2,3,4,5}
Is ∅ ⊆ {1,2,3}?
Yes! ∀x (x ∈ ∅) → (x ∈ {1,2,3})holds, because (x ∈ ∅) is false.
Is ∅ ∈ {1,2,3}? No!Is ∅ ⊆ {∅,1,2,3}? Yes!
Is ∅ ∈ {∅,1,2,3}? Yes!
Vacuously
![Page 9: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/9.jpg)
9
Set Theory - Definitions and notationQuiz time:
Is {x} ⊆ {x}?
Is {x} ∈ {x,{x}}?
Is {x} ⊆ {x,{x}}?
Is {x} ∈ {x}?
Yes
Yes
Yes
No
![Page 10: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/10.jpg)
10
Set Theory - Ways to define sets• Explicitly: {John, Paul, George, Ringo}• Implicitly: {1,2,3,…}, or {2,3,5,7,11,13,17,…}• Set builder: { x : x is prime }, { x | x is odd }. In
general { x : P(x) is true }, where P(x) is somedescription of the set.
Ex. Let D(x,y) denote “x is divisible by y.”Give another name for
{ x : ∀y ((y > 1) ∧ (y < x)) → ¬D(x,y) }.
Can we use any predicate P to define a setS = { x : P(x) }?
: and | are read“such that” or
“where”
Primes
![Page 11: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/11.jpg)
11
Set Theory - Russell’s ParadoxCan we use any predicate P to define a set
S = { x : P(x) }?
Define S = { x : x is a set where x ∉ x }
Then, if S ∈ S, then by defn of S, S ∉ S. So S must not bein S, right?
ARRRGH!But, if S ∉ S, then by defn of S, S ∈ S.
No!
There is a town with a barber who shaves all the people (andonly the people) who don’t shave themselves.
Who shaves thebarber?
![Page 12: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/12.jpg)
12
Set Theory - Cardinality
If S is finite, then the cardinality of S, |S|, is thenumber of distinct elements in S.
If S = {1,2,3}, |S| = 3.If S = {3,3,3,3,3},
If S = ∅,
If S = { ∅, {∅}, {∅,{∅}} },
|S| = 1.
|S| = 0.|S| = 3.
If S = {0,1,2,3,…}, |S| is infinite. (more on this later)
![Page 13: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/13.jpg)
13
Set Theory - Power setsIf S is a set, then the power set of S is
2S = { x : x ⊆ S }.
If S = {a},
aka P(S)
If S = {a,b},If S = ∅,
If S = {∅,{∅}},
We say, “P(S) isthe set of allsubsets of S.”2S = {∅, {a}}.
2S = {∅, {∅}, {{∅}}, {∅,{∅}}}.
Fact: if S is finite, |2S| = 2|S|. (if |S| = n, |2S| = 2n)
![Page 14: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/14.jpg)
14
Set Theory - Cartesian ProductThe Cartesian Product of two sets A and B is:
A x B = { <a,b> : a ∈ A ∧ b ∈ B}
If A = {Charlie, Lucy, Linus}, andB = {Brown, VanPelt}, then
A,B finite → |AxB| = ?
A1 x A2 x … x An = {<a1, a2,…, an>: a1 ∈ A1, a2 ∈ A2, …,an ∈ An}
A x B = {<Charlie, Brown>, <Lucy, Brown>,<Linus, Brown>, <Charlie, VanPelt>,<Lucy, VanPelt>, <Linus, VanPelt>}
We’ll use thesespecial sets
soon!
![Page 15: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/15.jpg)
15
Set Theory - Cartesian ProductThe Cartesian Product of two sets A and B is:
A x B = { <a,b> : a ∈ A ∧ b ∈ B}
A,B finite → |AxB| = ?
![Page 16: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/16.jpg)
16
Set Theory - OperatorsThe union of two sets A and B is:
A ∪ B = { x : x ∈ A v x ∈ B}
If A = {Charlie, Lucy, Linus}, andB = {Lucy, Desi}, then
A ∪ B = {Charlie, Lucy, Linus, Desi}
AB
![Page 17: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/17.jpg)
17
Set Theory - OperatorsThe intersection of two sets A and B is:
A ∩ B = { x : x ∈ A ∧ x ∈ B}
If A = {Charlie, Lucy, Linus}, andB = {Lucy, Desi}, then
A ∩ B = {Lucy}
AB
![Page 18: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/18.jpg)
18
Set Theory - OperatorsThe intersection of two sets A and B is:
A ∩ B = { x : x ∈ A ∧ x ∈ B}
If A = {x : x is a US president}, andB = {x : x is deceased}, then
A ∩ B = {x : x is a deceased US president}
AB
![Page 19: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/19.jpg)
19
Set Theory - OperatorsThe intersection of two sets A and B is:
A ∩ B = { x : x ∈ A ∧ x ∈ B}
If A = {x : x is a US president}, andB = {x : x is in this room}, then
A ∩ B = {x : x is a US president in this room} = ∅
ABSets whose
intersection isempty are called
disjoint sets
![Page 20: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/20.jpg)
20
Set Theory - OperatorsThe complement of a set A is:
A = { x : x ∉ A}
If A = {x : x is bored}, then
A = {x : x is not bored}
A
= ∅
∅= Uand
U = ∅
U
![Page 21: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/21.jpg)
21
Set Theory - OperatorsThe set difference, A - B, is:
AU
B
A - B = { x : x ∈ A ∧ x ∉ B }
A - B = A ∩ B
![Page 22: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/22.jpg)
22
Set Theory - OperatorsThe symmetric difference, A ⊕ B, is:
A ⊕ B = { x : (x ∈ A ∧ x ∉ B) v (x ∈ B ∧ x ∉ A)}
= (A - B) U (B - A)like
“exclusiveor”
AU
B
![Page 23: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/23.jpg)
23
Set Theory - Operators
A ⊕ B = { x : (x ∈ A ∧ x ∉ B) v (x ∈ B ∧ x ∉ A)}
= (A - B) U (B - A)
Proof:
{ x : (x ∈ A ∧ x ∉ B) v (x ∈ B ∧ x ∉ A)}= { x : (x ∈ A - B) v (x ∈ B - A)}
= { x : x ∈ ((A - B) U (B - A))}
= (A - B) U (B - A)
![Page 24: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/24.jpg)
24
Set Theory - Famous Identities
• Page 124• Mostly like HS algebra.• Don’t memorize…understand them
![Page 25: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/25.jpg)
25
Set Theory - Famous Identities
• Identity
• Domination
• Idempotent
A ∩ U = AA U ∅ = A
A U U = UA ∩ ∅ = A
A U A = AA ∩ A = A
(Lazy)
![Page 26: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/26.jpg)
26
Set Theory - Famous Identities
• Excluded Middle
• Uniqueness
• Double complement
A U A = U
A ∩ A = ∅
A = A
![Page 27: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/27.jpg)
27
Set Theory - Famous Identities
• Commutativity
• Associativity
• Distributivity
A U B =
(A U B) U C =
A ∩ B =B U AB ∩ A
(A ∩ B) ∩ C =A U (B U C)A ∩ (B ∩ C)
A U (B ∩ C) =
A ∩ (B U C) =
(A U B) ∩ (A U C)
(A ∩ B) U (A ∩ C)
![Page 28: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/28.jpg)
28
Set Theory - Famous Identities
• DeMorgan’s I
• DeMorgan’s II
p q
(A U B) = A ∩ B
(A ∩ B) = A U B
![Page 29: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/29.jpg)
29
Set Theory - 4 Ways to prove identities
• Show that A ⊆ B and that A ⊇ B.
• Use a membership table.
• Use previously proven identities.
• Use logical equivalences to prove equivalent setdefinitions.
New & important
Like truth tables
Like ≡
Not hard, a little tedious
![Page 30: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/30.jpg)
30
Set Theory - 4 Ways to prove identities
Prove that using a membershiptable.
0 : x is not in the specified set1 : otherwise
(A U B) = A ∩ B
1000
A U B
1000
A ∩ B
1010
B
0100111010011011
A U BABA
Haven’t we seenthis before?
![Page 31: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/31.jpg)
31
CS 173 Set Theory - 4 Ways to prove identities
Prove that using identities.(A U B) = A ∩ B
(A U B) = A U B
= A ∩ B
= A ∩ B
![Page 32: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/32.jpg)
32
CS 173 Set Theory - 4 Ways to prove identities
Prove that using logicallyequivalent set definitions.
(A U B) = A ∩ B
(A U B) = {x : ¬(x ∈ A v x ∈ B)}
= {x : ¬(x ∈ A) ∧ ¬(x ∈ B)}
= A ∩ B
= {x : (x ∈ A) ∧ (x ∈ B)}
![Page 33: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/33.jpg)
33
Set Theory - 4 Ways to prove identities
Prove that
1. (⊆) (x ∈ A U B) →2. (⊇) (x ∈ A ∩ B) →
(A U B) = A ∩ B
![Page 34: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/34.jpg)
34
Set Theory - A proof for us to do together.
X ∩ (Y - Z) = (X ∩ Y) - (X ∩ Z). True or False?Prove your response.
= (X ∩ Y) ∩ (X’ U Z’)
= (X ∩ Y ∩ X’) U (X ∩ Y ∩ Z’)
= ∅ U (X ∩ Y ∩ Z’)
= (X ∩ Y ∩ Z’)
(X ∩ Y) - (X ∩ Z) = (X ∩ Y) ∩ (X ∩ Z)’
![Page 35: CS 173: Discrete Structures](https://reader031.vdocument.in/reader031/viewer/2022020622/61ec5a4c9ef0152e40279430/html5/thumbnails/35.jpg)
35
Suppose to the contrary, that A ∩ B ≠ ∅, and that x ∈ A ∩ B.
Set Theory - A proof for us to do together.
Pv that if (A - B) U (B - A) = (A U B) then ______
Then x cannot be in A-B and x cannot be in B-A.
Do you see the contradiction yet?
But x is in A U B since (A ∩ B) ⊆ (A U B).
A ∩ B = ∅
Thus, A ∩ B = ∅.
a) A U B = ∅b) A = Bc) A ∩ B = ∅d) A-B = B-A = ∅
Then x is not in (A - B) U (B - A).DeMorgan’s!!
Trying to pv p --> qAssume p and not q, and find
a contradiction.Our contradiction was that
sets weren’t equal.