Upcoming SlideShare
×

# MELJUN CORTES Discrete Mathematics SETS

1,207 views

Published on

MELJUN CORTES Discrete Mathematics SETS

2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,207
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
30
0
Likes
2
Embeds 0
No embeds

No notes for slide
• We will see this basic counting principle again when we talk about combinatorics.
• NOT (x in A -&gt; x in B) = NOT (x not in A or x in B) (defn. of implies) = x in A AND x not in B (DeMorgan’s law).
• Note that set difference and complement do not relate to each other like arithmetic difference and negative. In arithmetic, we know that a-b = -(b-a). But in sets, A-B is not generally the same as the complement of B-A.
• A membership table is like a truth table.
• So, for example, on a 64-bit processor, using just a single machine-language instruction you can calculate the union or intersection of two sets out of a universe of discourse having up to 64 elements. This leads to an extremely fast way of doing complicated calculations on small sets. It is not a good method for large, sparsely populated sets, because searching the bit string to find which bits are “1” can take a long time.
• ### MELJUN CORTES Discrete Mathematics SETS

1. 1. DISCRETE MATHEMATICS SETSMELJUN CORTES Discrete Mathematics 1
2. 2. Start §2.2: The Union Operator  For sets A, B, their∪ nion A∪B is the set containing all elements that are either in A, or (“∨”) in B (or, of course, in both).  Formally, ∀A,B: A∪B = {x | x∈A ∨ x∈B}.  Note that A∪B is a superset of both A and B (in fact, it is the smallest such superset): ∀A, B: (A∪B ⊇ A) ∧ (A∪B ⊇ B) Discrete Mathematics 2
3. 3. Union Examples  {a,b,c}∪{2,3}= {a,b,c,2,3}  {2,3,5}∪{3,5,7} = {2,3,5,3,5,7} ={2,3,5,7} Think “The United States of America includes every person who worked in any U.S. state last year.” (This is how the IRS sees it...) Discrete Mathematics 3
4. 4. The Intersection Operator  For sets A, B, their intersection A∩B is the set containing all elements that are simultaneously in A and (“∧”) in B.  Formally, ∀A,B: A∩B={x | x∈A ∧ x∈B}.  Note that A∩B is a subset of both A and B (in fact it is the largest such subset): ∀A, B: (A∩B ⊆ A) ∧ (A∩B ⊆ B) Discrete Mathematics 4
5. 5. Intersection Examples  {a,b,c}∩{2,3} ∅ = ___ {4}  {2,4,6}∩{3,4,5} = ______ Think “The intersection of University Ave. and W 13th St. is just that part of the road surface that lies on both streets.” Discrete Mathematics 5
6. 6. Disjointedness  Two sets A, B are called Help, I’ve been disjoint (i.e., unjoined) disjointed! if their intersection is empty. (A∩B=∅)  Example: the set of even integers is disjoint with the set of odd integers. Discrete Mathematics 6
7. 7. Inclusion-Exclusion Principle  How many elements are in A∪B? |A∪B| = |A| + |B| − |A∩B|  Example: How many students are on our class email list? Consider set E = I ∪ M, I = {s | s turned in an information sheet} M = {s | s sent the TAs their email address}  Some students did both! |E| = |I∪M| = |I| + |M| − |I∩M| Discrete Mathematics 7
8. 8. Set Difference  For sets A, B, the difference of A and B, written A−B, is the set of all elements that are in A but not B. Formally: A − B :≡ {x | x∈A ∧ x∉B} = {x | ¬(x∈A → x∈B) }  Also called: The complement of B with respect to A. Discrete Mathematics 8
9. 9. Set Difference Examples  {1,2,3,4,5,6} − {2,3,5,7,9,11} = {1,4,6} ___________  Z − N = {… , −1, 0, 1, 2, … } − {0, 1, … } = {x | x is an integer but not a nat. #} = {x | x is a negative integer}  Result = {… , −3, −2, −1} Discrete Mathematics 9
10. 10. Set Difference - Venn Diagram  A−B is what’s left after B “takes a bite out of A” Chomp! Set A−B Set A Set B Discrete Mathematics 10
11. 11. Set Complements  The universe of discourse can itself be considered a set, call it U.  When the context clearly defines U, we say that for any set A⊆U, the complement of A, written A , is the complement of A w.r.t. U, i.e., it is U−A.  E.g., If U=N, {3,5} = {0,1,2,4,6,7,...} Discrete Mathematics 11
12. 12. More on Set Complements  An equivalent definition, when U is clear: A = {x | x ∉ A} A A U Discrete Mathematics 12
13. 13. Set Identities  Identity: A∪∅ = A = A∩U  Domination: A∪U = U, A∩∅ = ∅  Idempotent: A∪A = A = A∩A  Double complement: ( A ) = A  Commutative: A∪B = B∪A, A∩B = B∩A  Associative: A∪(B∪C)=(A∪B)∪C , A∩(B∩C)=(A∩B)∩C Discrete Mathematics 13
14. 14. DeMorgan’s Law for Sets  Exactly analogous to (and provable from) DeMorgan’s Law for propositions. A∪ B = A ∩ B A∩ B = A ∪ B Discrete Mathematics 14
15. 15. Proving Set Identities  To prove statements about sets, of the form E1 = E2 (where the Es are set expressions), here are three useful techniques: 1. Prove E1 ⊆ E2 and E2 ⊆ E1 separately. 2. Use set builder notation & logical equivalences. 3. Use a membership table. Discrete Mathematics 15
16. 16. Method 1: Mutual subsets Example: Show A∩(B∪C)=(A∩B)∪(A∩C).  Part 1: Show A∩(B∪C)⊆(A∩B)∪(A∩C).  Assume x∈A∩(B∪C), & show x∈(A∩B)∪(A∩C).  We know that x∈A, and either x∈B or x∈C.  Case 1: x∈B. Then x∈A∩B, so x∈(A∩B)∪(A∩C).  Case 2: x∈C. Then x∈A∩C , so x∈(A∩B)∪(A∩C).  Therefore, x∈(A∩B)∪(A∩C).  Therefore, A∩(B∪C)⊆(A∩B)∪(A∩C).  Part 2: Show (A∩B)∪(A∩C) ⊆ A∩(B∪C). … Discrete Mathematics 16
17. 17. Method 3: Membership Tables  Just like truth tables for propositional logic.  Columns for different set expressions.  Rows for all combinations of memberships in constituent sets.  Use “1” to indicate membership in the derived set, “0” for non-membership.  Prove equivalence with identical columns. Discrete Mathematics 17
18. 18. Membership Table Example Prove (A∪B)−B = A−B. A B A∪ (A∪− A− B B) B B 0 0 0 0 0 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 Discrete Mathematics 18
19. 19. Membership Table Exercise Prove (A∪B)−C = (A−C)∪(B−C). A B C A ∪ (A ∪ ) − A − B B C C B−C (A− )∪B− ) C ( C 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Discrete Mathematics 19
20. 20. Review of §2.1-2.2  Sets S, T, U… Special sets N, Z, R.  Set notations {a,b,...}, {x|P(x)}…  Relations x∈S, S⊆T, S⊇T, S=T, S⊂T, S⊃T.  Operations |S|, P(S), ×, ∪, ∩, S −,  Set equality proof techniques:  Mutual subsets.  Derivation using logical equivalences. Discrete Mathematics 20
21. 21. Generalized Unions & Intersections  Since union & intersection are commutative and associative, we can extend them from operating on ordered pairs of sets (A,B) to operating on sequences of sets (A1,…,An), or even on unordered sets of sets, X={A | P(A)}. Discrete Mathematics 21
22. 22. Generalized Union  Binary union operator: A∪B  n-ary union: A∪A2∪…∪An :≡ ((…((A1∪ A2) ∪…)∪ An) (grouping & order is irrelevant) n  “Big U” notation:  Ai i =1  Or for infinite sets of sets: A A∈ X Discrete Mathematics 22
23. 23. Generalized Intersection  Binary intersection operator: A∩B  n-ary intersection: A1∩A2∩…∩An≡((…((A1∩A2)∩…)∩An) (grouping & order is irrelevant) n  “Big Arch” notation:  Ai i =1  Or for infinite sets of sets: A A∈ X Discrete Mathematics 23
24. 24. Representations A frequent theme of this course will be methods of representing one discrete structure using another discrete structure of a different type.  E.g., one can represent natural numbers as  Sets: 0:≡∅, 1:≡{0}, 2:≡{0,1}, 3:≡{0,1,2}, …  Bit strings: 0:≡0, 1:≡1, 2:≡10, 3:≡11, 4:≡100, … Discrete Mathematics 24
25. 25. Representing Sets with Bit Strings  For an enumerable u.d. U with ordering x1, x2, …, represent a finite set S⊆U as the finite bit string B=b1b2…bn where ∀i: xi∈S ↔ (i<n ∧ bi=1). e.g. U=N, S={2,3,5,7,11}, B=001101010001.  In this representation, the set operators “∪”, “∩”, “” are implemented directly by bitwise OR, AND, NOT! Discrete Mathematics 25