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. Pre-Class Learning Goals Quiz 10 Feedback  By the start of class, you should be able to:  Generally:  Define the terms domain, co-domain, range, image, and pre-  Issues: image  Use appropriate function syntax to relate these terms (e.g., f : A → B indicates that f is a function mapping domain A to co-domain B).  Determine whether f : A → B is a function given a definition for f as an equation or arrow diagram. Unit 10: Sets 25 Unit 10: Sets 26 In-Class Learning Goals Outline  By the end of this unit, you should be able to:  What’s the Use of Sets (history & DFAs)  Define the power set and cartesian product operations in  Cardinality (size) terms of predicate logic and set membership/subset relations.  Power set (and an induction proof)  Execute the power set, cartesian product, and cardinality operations on sets expressed through any of the notations  Cartesian products (and application to DFAs) discussed so far.  Apply your proof skills to proofs involving sets.  Set proofs.  Relate DFAs to sets. Unit 10: Sets Unit 10: Sets 27 28 7

  8. Russell's Paradox Historical Notes on Sets  At the beginning of the 20 th century Bertrand Russell  Mathematicians formalized set theory to create a discovered inconsistencies with the "naïve" set theory. foundation for all of mathematics. Essentially all  Russell focused on some special type of sets. mathematical constructs can be defined in terms of  Let S be the set of all sets that contain themselves: sets. S = { x | x ϵ x }.  Hence sets are a powerful means of formalizing new ideas. Does S contain itself?  But we have to be careful how we use them! A. Yes, definitely. B. No, certainly not. C. Maybe (either way is fine). D. Cannot prove or disprove it. E. None of the above.  So, no problem here. Unit 10: Sets 29 Unit 10: Sets 30 Russell's Paradox (cont') Sets and Functions are Very Useful  Let R be the set of all sets that do not contain  Despite this, sets (and functions) are incredibly useful. themselves. That is  E.g. We can definite valid DFAs formally: Same question, R = { x | ~x ϵ x }. different form: a DFA is a 5-tuple (I, S, s0, F, N) where  Does R contain itself?  I is a finite set of characters (input alphabet). “Imagine a barber that A. Yes, definitely.  S is a finite set of states. shaves every man in  s0 ∈ S is the initial state. B. No, certainly not. town who does not shave himself. Does  F ⊆ S is the set of accepting states. C. Maybe (either way is fine). the barber shave D. Cannot prove or disprove it.  N: S x I → S is the transition function. himself?” E. None of the above.  Set theory has been restricted in a way that disallow this kind of sets. Unit 10: Sets Unit 10: Sets 31 32 8

Recommend


More recommend