cpsc 121 models of computation part 1
play

CPSC 121: Models of Computation PART 1 REVIEW OF TEXT READING Unit - PowerPoint PPT Presentation

CPSC 121: Models of Computation PART 1 REVIEW OF TEXT READING Unit 11: Sets These pages correspond to text reading and are not covered in the lectures. Based on slides by Patrice Belleville and Steve Wolfman Unit 10: Sets 2 Sets Quantifier


  1. CPSC 121: Models of Computation PART 1 REVIEW OF TEXT READING Unit 11: Sets These pages correspond to text reading and are not covered in the lectures. Based on slides by Patrice Belleville and Steve Wolfman Unit 10: Sets 2 Sets Quantifier Example A set is a collection of elements: Someone in this class is left-handed (where C is the set  the set of students in this class of people in this class and L(p) means p is left-  the set of lowercase letters in English handed):  x  C, L(x)  the set of natural numbers (N)  the set of all left-handed students in this class An element is either in the set ( x  S ) or not ( x  S ). Is there a set of everything ? Unit 10: Sets 3 Unit 10: Sets 4 1

  2. What is a Set? Describing Sets (1/4) Some sets… A set is an unordered collection of objects. A = {1, 3, 9} B = {1, 3, 9, 27, snow} The objects in a set are called members. C = {1, 1, 3, 3, 9, 9} ( a  S indicates a is a member of S ; D = {A, B} a  S indicates a is not a member of S ) D' = { {1, 3, 9}, {1, 3, 9, 27, snow} } E = { } A set contains its members. Unit 10: Sets 5 Unit 10: Sets 6 Describing Sets (2/4) Describing Sets (3/4) Some sets… Some sets, using set builder notation: A = {x  N |  y  N , x = 5 y } A = {1, 5, 25, 125, …} B = {2 i - 1 | i is a prime} B = {…, -2, - 1, 0, 1, 2, …} C = {n  Z | 0 < n  100} C = {1, 2, 3, …, 98, 99, 100} (The set of powers of 5, the set of integers, and the set of integers between 1 and 100.) To read, start with “the set of all”. Read “ | ” as “such that”. A : “ the set of all natural numbers x such that x is a power of 5 ” B : “ the set of all numbers of the form 2 i -1 such that i is a prime” C : “ the set of all integers n such that 0 < n  100 ” “…” is an ellipsis Unit 10: Sets 7 Unit 10: Sets 8 2

  3. Describing Sets (4/4) Describing Sets (4/4) Graphical depiction of sets: Venn diagrams. Graphical depiction of sets: Venn diagrams. Draw the set of all five-letter things. Draw the set of all five-letter things. All red things? All red, five-letter things? All red things? All red, five-letter things? U U U is the Texas Texas snows snows universal seven seven set of happiness happiness everything. books books   fire truck fire truck heart heart Unit 10: Sets 9 Unit 10: Sets 10 Containment Containment A set A is a subset of a set B iff A set A is a subset of a set B iff  x  U , x  A  x  B .  x  U , x  A  x  B . We write A is a subset of B as A  B. We write A is a subset of B as A  B. If A  B , can B have elements that are not elements of If A  B , can B have elements that are not elements of A ? Yes, but A can’t have elements that are not A ? elements of B. Unit 10: Sets 11 Unit 10: Sets 12 3

  4. Membership and Containment Membership and Containment A = {1, {2}} A = {1, {2}} Is 1  A ? Is 2  A ? Is 1  A ? Yes Is 2  A ? No Is {1}  A ? Is {2}  A ? Is {1}  A ? Yes Is {2}  A ? No Is 1  A ? Is 2  A ? Is 1  A ? Is 2  A ? Is {1}  A ? Is {2}  A ? Not meaningful since Not meaningful since 1 is not a set. 2 is not a set. Is {1}  A ? No Is {2}  A ? Yes Unit 10: Sets 13 Unit 10: Sets 14 Thought Question Set Equality What if A  B and B  A ? Sets A and B are equal ( denoted A = B ) if and only if  x  U , x  A  x  B . Can we prove that that’s equivalent to A  B and B  A ? Unit 10: Sets 15 Unit 10: Sets 16 4

  5. Set Equality Set Union Sets A and B are equal — denoted A = B — if and only if  x The union of A and B — denoted A  B — is  U , x  A  x  B . {x  U | x  A  x  B} . A  B is the blue region... Can we prove that that’s equivalent to A  B and B  A ? U Yes, using a standard predicate logic proof in which we note that p  q is logically equivalent to p  q  p  q. A B Unit 10: Sets 17 Unit 10: Sets 18 Set Intersection Set Difference The intersection of A and B — denoted A  B — is The difference of A and B — denoted A - B — is {x  U | x  A  x  B} . {x  U | x  A  x  B} . A  B is the dark blue region... A – B is the pure blue region. U U U A B A B Unit 10: Sets 19 Unit 10: Sets 20 5

  6. Set Complement Set Operation Equivalencies Many logical equivalences have analogous set operation The complement of A — denoted A — is identities. Here are a few… read more in the text! {x  U | x  A} . A  B = B  A Commutative Law A is everything but the blue region. (A  B)  C = (A  C)  (B  C) Distributive Law U U (A  B) = A  B DeMorgan’s Law A  U = A U as identity for  A ... Can we express this as a set difference? Unit 10: Sets 21 Unit 10: Sets 22 Pre-Class Learning Goals  By the start of class, you should be able to:  Define the set operations union, intersection, complement PART 2 and difference, and the logical operations subset and set equality in terms of predicate logic and set membership. IN CLASS PAGES  Translate between sets represented explicitly (possibly using ellipses, e.g., { 4, 6, 8, … }) and using "set builder" notation (e.g., { x in Z + | x 2 > 10 and x is even }).  Execute set operations on sets expressed explicitly, using set builder notation, or a combination of these.  Interpret the empty set symbol  , including the fact that the empty set has no members and that it is a subset of any set. Unit 10: Sets Unit 10: Sets 23 24 6

  7. Quiz 10 Feedback In-Class Learning Goals  Generally:  By the end of this unit, you should be able to:  Define the power set and cartesian product operations in  Issues: terms of predicate logic and set membership/subset relations.  Execute the power set, cartesian product, and cardinality operations on sets expressed through any of the notations discussed so far.  Apply your proof skills to proofs involving sets.  Relate DFAs to sets. Unit 10: Sets 25 Unit 10: Sets 26 Outline Historical Notes on Sets  Mathematicians formalized set theory to create a  What’s the Use of Sets (history & DFAs) foundation for all of mathematics. Essentially all  Cardinality (size) mathematical constructs can be defined in terms of sets.  Power set (and an induction proof)  Hence sets are a powerful means of formalizing new ideas.  Cartesian products  But we have to be careful how we use them!  Set proofs. Unit 10: Sets Unit 10: Sets 27 28 7

  8. Russell's Paradox Russell's Paradox (cont')  At the beginning of the 20 th century Bertrand Russell  Let R be the set of all sets that do not contain discovered inconsistencies with the "naïve" set theory. themselves. That is Same question,  Russell focused on some special type of sets. R = { x | ~x ϵ x }. different form:  Let S be the set of all sets that contain themselves:  Does R contain itself? “Imagine a barber that S = { x | x ϵ x }. A. Yes, definitely. shaves every man in B. No, certainly not. town who does not Does S contain itself? shave himself. Does C. Maybe (either way is fine). A. Yes, definitely. the barber shave D. Cannot prove or disprove it. B. No, certainly not. himself?” E. None of the above. C. Maybe (either way is fine). D. Cannot prove or disprove it. E. None of the above.  Set theory has been restricted in a way that disallow  So, no problem here. this kind of sets. Unit 10: Sets 29 Unit 10: Sets 30 Sets and Functions are Very Useful Set Cardinality  Despite this, sets (and functions) are incredibly useful.  Cardinality: the number of elements of a set S, denoted by |S|.  E.g. We can definite valid DFAs formally:  What is the cardinality of the following set: a DFA is a 5-tuple (I, S, s0, F, N) where  I is a finite set of characters (input alphabet). { 1, 2, 3, { a, b, c }, snow, rain } ?  S is a finite set of states. A. 3  s0 ∈ S is the initial state.  F ⊆ S is the set of accepting states. B. 6  N: S x I → S is the transition function. C. 8 D. Some other integer E. The cardinality of the set is undefined. Unit 10: Sets Unit 10: Sets 31 32 8

  9. Cardinality Exercises Worked Cardinality Exercises Given the definitions: Given the definitions: A = {1, 2, 3} A = {1, 2, 3} B = {2, 4, 6, 8} B = {2, 4, 6, 8} What are: What are: |A| = _________ |A – B| = _________ |A| = 3________ |A – B| = 2________ |B| = _________ |B – A| = _________ |B| = 4________ |B – A| = 3________ |A  B| = _________ |A  B| = 6________ |{{}}| = _________ |{{}}| = 1________ |A  B| = _________ |{  }| |A  B| = 1________ |{  }| = _________ = 1________ |{{  }}| = _________ |{{  }}| = 1________ a. 0 b. 1 c. 2 d. 3 e. None of these Unit 10: Sets 33 Unit 10: Sets 34 Outline Power Sets  The power set of a set S, denoted P (S), is the set  What’s the Use of Sets (history & DFAs) whose elements are all subsets of S.  Cardinality (size)  Given the definitions A = { a, b, f }, B = { b, c },  Power set (and an induction proof) which of the following are correct:  Cartesian products A. P (B) = { {b}, {c}, {b, c} }  Set proofs. B. P (A - B) = {  , {a}, {f}, {a, f} } C. |P (A  B)| = 1 D. |P (A  B)| = 4 E. None of the above Unit 10: Sets Unit 10: Sets 35 36 9

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend