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

cpsc 121 models of computation
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 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

slide-3
SLIDE 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

slide-4
SLIDE 4

Example 1 (cont’d):

Here’s another way to prove A ∩ B = A ∪ B Recall: X = Y ↔ X ⊆ Y ∧ Y ⊆ X Proof 2: Step 1: Prove A ∩ B ⊆ A ∪ B Pick an arbitrary x ∈ A ∩ B then x / ∈ A ∩ B this implies x ∈ A ∧ x ∈ B 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

slide-5
SLIDE 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

slide-6
SLIDE 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

slide-7
SLIDE 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

slide-8
SLIDE 8

N-Tuples

An ordered collection of n elements, a1, a2, a3, . . . , an, is represented by an ordered n-tuple written as (a1, a2, a3, . . . , an) 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

slide-9
SLIDE 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

  • rdering is understood from the context

CPSC 121: Models of Computation

slide-10
SLIDE 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

slide-11
SLIDE 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

slide-12
SLIDE 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

  • f X and Y as defining the abscissa and ordinate values

respectively of a Cartesian coordinate plot

X Y

1 2 3 1 2 CPSC 121: Models of Computation

slide-13
SLIDE 13

Cartesian Product (cont’d)

We can extend the definition to more than two sets The Cartesian product of sets A1, A2, . . . , An, denoted A1 × A2 × . . . × An, is A1 × A2 × . . . × An = {(a1, a2, . . . , an) | ai ∈ Ai, i = 1, 2, . . . , n} If the Ai, i = 1, 2, . . . , n are finite then |A1 × A2 × . . . × An| = |A1| × |A2| × . . . × |An| which can be proved by induction

CPSC 121: Models of Computation