cpsc 121 models of computation
play

CPSC 121: Models of Computation Instructor: Bob Woodham - PowerPoint PPT Presentation

CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2009/2010, Section 203 CPSC 121: Models of Computation Menu April 7, 2010 Topics: Set


  1. CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2009/2010, Section 203 CPSC 121: Models of Computation

  2. Menu April 7, 2010 Topics: Set Theory (concluded) Pre-class reading: Today: Epp 5.3 Next: Epp 7.1, 7.2 (definitions) Reminders: Assignment 4 due Friday, April 9, 17:00 Lab 10 this week (pre-lab worth marks, post-lab survey) On-line teaching evaluation (until 11:00pm April 17) Final exam Thursday, Apr 29, noon, OSBO A READ the WebCT Vista course announcements board www: http://www.ugrad.cs.ubc.ca/~cs121/ WebCT Vista: http://www.vista.ubc.ca CPSC 121: Models of Computation

  3. Example 1: We use set builder notation and logical equivalences to Prove: A ∩ B = A ∪ B (De Morgan law for sets) Proof 1: A ∩ B { x | x / ∈ A ∩ B } = definition of complement { x | x ∈ A ∩ B } ∈ = definition of / { x | x ∈ A ∧ x ∈ B } = definition of intersection { x | x ∈ A ∨ x ∈ B } = De Morgan (logical equivalence) { x | x ∈ A ∨ x ∈ B } = definition of complement { x | x ∈ ( A ∪ B ) } = definition of union A ∪ B = QED CPSC 121: Models of Computation

  4. Example 1 (cont’d): Here’s another way to prove A ∩ B = A ∪ B ↔ X ⊆ Y ∧ Y ⊆ X Recall: X = Y Proof 2: Step 1: Prove A ∩ B ⊆ A ∪ B Pick an arbitrary x ∈ A ∩ B ∈ A ∩ B then x / x ∈ A ∧ x ∈ B this implies definition of intersection x / ∈ A ∨ x / ∈ B De Morgan x ∈ A ∨ x ∈ B definition complement x ∈ A ∪ B definition union CPSC 121: Models of Computation

  5. Example 1 (cont’d): Step 2: Prove A ∪ B ⊆ A ∩ B We use the same argument from Step 1 in reverse QED CPSC 121: Models of Computation

  6. Example 2: Prove: A ⊕ B = ( A − B ) ∪ ( B − A ) Proof: A ⊕ B = ( A ∪ B ) ∩ ( A ∩ B ) alternative definition of ⊕ = ( A ∪ B ) ∩ ( A ∪ B ) De Morgan = [( A ∪ B ) ∩ A ] ∪ [( A ∪ B ) ∩ B ] distributive law = [ A ∩ ( A ∪ B )] ∪ [ B ∩ ( A ∪ B )] commutative law (twice) = [( A ∩ A ) ∪ ( A ∩ B )] ∪ [( B ∩ A ) ∪ ( B ∩ B )] distributive law (twice) = ( ∅ ∪ ( A ∩ B )) ∪ (( B ∩ A ) ∪ ∅ ) complement law (twice) = ( A ∩ B ) ∪ ( B ∩ A ) identity law (twice) = ( A ∩ B ) ∪ ( B ∩ A ) commutative law (3 × ) = ( A − B ) ∪ ( B − A ) definition set difference QED CPSC 121: Models of Computation

  7. Example 3: Prove or disprove A − B = B − A Clearly this is false. How do we prove it false? Recall: There are implied universal quantifiers on A and B Thus, a single counterexample serves to disprove the proposition A − B = B − A Let A = { 1 , 2 } , B = { 2 , 3 } and U = { 1 , 2 , 3 } Then A − B = { 1 } and B − A = { 3 } and A − B � = B − A QED CPSC 121: Models of Computation

  8. N-Tuples An ordered collection of n elements, a 1 , a 2 , a 3 , . . . , a n , is represented by an ordered n-tuple written as ( a 1 , a 2 , a 3 , . . . , a n ) Two n-tuples are equal if and only if each corresponding pair of elements are equal Examples: ( a , 1 , ∅ ) = ( a , 1 , A ∩ A ) ( 1 , 2 , 3 ) � = ( 3 , 2 , 1 ) ( a , b , a ) � = ( a , b , b ) CPSC 121: Models of Computation

  9. 2-Tuples An ordered pair is an n-tuple with 2 elements Often we refer to an ordered pair simply as a “pair” when ordering is understood from the context CPSC 121: Models of Computation

  10. Cartesian Product Let A and B be sets The Cartesian product of A and B , denoted A × B , is A × B = { ( a , b ) | a ∈ A ∧ b ∈ B } Example: √ Let A = { T , F } and B = { π, 17 , 3 } . Then √ √ A × B = { ( T , π ) , ( T , 17 ) , ( T , 3 ) , ( F , π ) , ( F , 17 ) , ( F , 3 ) } CPSC 121: Models of Computation

  11. Cartesian Product (cont’d) Let A and B be finite sets. Then | A × B | = | A | × | B | That is, the cardinality of the Cartesian product of two sets is equal to the product of the cardinalities of the two sets CPSC 121: Models of Computation

  12. Cartesian Product (cont’d) Why is this called the Cartesian product? Let X = { 1 , 2 , 3 } and Y = { 1 , 2 } . We can think of the elements of X and Y as defining the abscissa and ordinate values respectively of a Cartesian coordinate plot Y 2 1 1 2 3 X CPSC 121: Models of Computation

  13. Cartesian Product (cont’d) We can extend the definition to more than two sets The Cartesian product of sets A 1 , A 2 , . . . , A n , denoted A 1 × A 2 × . . . × A n , is A 1 × A 2 × . . . × A n = { ( a 1 , a 2 , . . . , a n ) | a i ∈ A i , i = 1 , 2 , . . . , n } If the A i , i = 1 , 2 , . . . , n are finite then | A 1 × A 2 × . . . × A n | = | A 1 | × | A 2 | × . . . × | A n | which can be proved by induction CPSC 121: Models of Computation

Recommend


More recommend