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 2008/2009, Section 203 CPSC 121: Models of Computation Menu March 20, 2009 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 2008/2009, Section 203

CPSC 121: Models of Computation

slide-2
SLIDE 2

Menu March 20, 2009

Topics: Set Theory (cont’d) Reading: Today: Epp 5.1 Next: Epp 5.2–5.3 Epp 7.1 Reminders: Look for Assignment 4 Final exam Friday, April 17, 7:00pm, SRC A READ the WebCT Vista course announcements board

CPSC 121: Models of Computation

slide-3
SLIDE 3

News Item: Enrollment/Prospects for CPSC Majors

The March 17, 2009, article, “Computer Science Majors Increase at Most Significant Rate Since Dot Com Boom,” is available at http://www.cra.org/govaffairs/blog/ archives/000729.html “Total enrollment by majors and pre-majors in computer science is up 6.2 percent per department over last year. If

  • nly majors are considered, the increase is 8.1 percent”

“The average number of new students per department majoring in computer science is up 9.5 percent over last year” “According to the United States Department of Labor, computer science graduates on average earn 13 percent more than the average college graduate” “According to the Bureau of Labor Statistics, future job prospects for computer science graduates are higher than for any other science or engineering field”

CPSC 121: Models of Computation

slide-4
SLIDE 4

Lecture 27: Re-cap

Describing sets with braces and set builder notation Propositions related to set membership: x ∈ A, y / ∈ B Empty set denoted by { } or by ∅ Set equality: two sets are equal if and only if they have the same elements Universal set, U A is a subset of B if ∀x ∈ U, x ∈ A → x ∈ B Cardinality of a set Venn diagram

CPSC 121: Models of Computation

slide-5
SLIDE 5

Example 1: Set Equality

Consider the sets Q = {x2 | x ∈ Z+} P = {x | ∃n ∈ Z+, x =

n

  • i=1

(2i − 1)} Does P = Q?

CPSC 121: Models of Computation

slide-6
SLIDE 6

Example 1: Set Equality

Consider the sets Q = {x2 | x ∈ Z+} P = {x | ∃n ∈ Z+, x =

n

  • i=1

(2i − 1)} Does P = Q? Question: How do we prove equality of sets?

CPSC 121: Models of Computation

slide-7
SLIDE 7

Example 1: Set Equality

Consider the sets Q = {x2 | x ∈ Z+} P = {x | ∃n ∈ Z+, x =

n

  • i=1

(2i − 1)} Does P = Q? Question: How do we prove equality of sets? Answer: We use the following theorem

CPSC 121: Models of Computation

slide-8
SLIDE 8

Theorem: Set Equality

Theorem: Let A and B be sets contained in a universal set, U A = B ↔ (A ⊆ B) ∧ (B ⊆ A) That is, we can prove set equality by showing that each set is a subset of the other

CPSC 121: Models of Computation

slide-9
SLIDE 9

Theorem: Set Equality (cont’d)

Proof: To prove the biconditional is a tautology, we have to prove two implications are true

1

A = B → (A ⊆ B) ∧ (B ⊆ A)

2

(A ⊆ B) ∧ (B ⊆ A) → A = B

CPSC 121: Models of Computation

slide-10
SLIDE 10

Theorem: Set Equality (cont’d)

First, we show A = B → (A ⊆ B) ∧ (B ⊆ A) We use a direct proof. Assume, for arbitrary sets A, B, that A = B Prove: A ⊆ B Pick an arbitrary x ∈ A. Then x ∈ B since A = B. Thus, ∀x, x ∈ A → x ∈ B and A ⊆ B, as required Prove: B ⊆ A We use the identical argument, with the roles of A and B interchanged, to prove B ⊆ A, as required

CPSC 121: Models of Computation

slide-11
SLIDE 11

Theorem: Set Equality (cont’d)

Second, we show ∀A ⊆ U, ∀B ⊆ U, (A ⊆ B) ∧ (B ⊆ A) → A = B Our proof is by contradition Assume ∀A, ∀B, (A ⊆ B) ∧ (B ⊆ A) → A = B ≡ ∃A, ∃B, (A ⊆ B) ∧ (B ⊆ A) ∧ A = B Let A and B be sets such that (A ⊆ B) ∧ (B ⊆ A) ∧ A = B

CPSC 121: Models of Computation

slide-12
SLIDE 12

Theorem: Set Equality (cont’d)

Given that A = B, without loss of generality, let x ∈ A and x / ∈ B ASIDE: If this is not possible then exchange labelling of sets A and B By assumption, A ⊆ B. Thus, x ∈ A → x ∈ B Thus, x ∈ B ∧ x / ∈ B, a contradiction Therefore, we conclude ∀A, ∀B, (A ⊆ B) ∧ (B ⊆ A) → A = B as required QED

CPSC 121: Models of Computation

slide-13
SLIDE 13

Power Set

Let S = {q, x, z} Construct the set of all subsets of S {{q, x, z}, {q, x}, {q, z}, {x, z}, {q}, {x}, {z}, ∅} The set of all subsets of a given set, S, is called the power set

  • f S and is denoted by P(S)

ASIDE: A is a proper subset of B, denoted A ⊂ B, if A is a subset of B but A = B. The power set, P(S), includes all subsets of S, not just the proper subsets

CPSC 121: Models of Computation

slide-14
SLIDE 14

Questions about Power Set

Question: What is the power set of the empty set, P(∅)?

CPSC 121: Models of Computation

slide-15
SLIDE 15

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅}

CPSC 121: Models of Computation

slide-16
SLIDE 16

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))?

CPSC 121: Models of Computation

slide-17
SLIDE 17

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))? Answer: P(P(∅)) = P({∅}) = {∅, {∅}}

CPSC 121: Models of Computation

slide-18
SLIDE 18

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))? Answer: P(P(∅)) = P({∅}) = {∅, {∅}} Question: What is P(P(P(∅)))?

CPSC 121: Models of Computation

slide-19
SLIDE 19

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))? Answer: P(P(∅)) = P({∅}) = {∅, {∅}} Question: What is P(P(P(∅)))? Answer: P(P(P(∅))) = P({∅, {∅}}) = {∅, {∅}, {{∅}}, {∅, {∅}}}

CPSC 121: Models of Computation

slide-20
SLIDE 20

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))? Answer: P(P(∅)) = P({∅}) = {∅, {∅}} Question: What is P(P(P(∅)))? Answer: P(P(P(∅))) = P({∅, {∅}}) = {∅, {∅}, {{∅}}, {∅, {∅}}} Question: For a set of cardinality n, what is the cardinality of its power set?

CPSC 121: Models of Computation

slide-21
SLIDE 21

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))? Answer: P(P(∅)) = P({∅}) = {∅, {∅}} Question: What is P(P(P(∅)))? Answer: P(P(P(∅))) = P({∅, {∅}}) = {∅, {∅}, {{∅}}, {∅, {∅}}} Question: For a set of cardinality n, what is the cardinality of its power set? Answer: For each of the n elements, we have 2 independent choices: put it in the subset or don’t put it in the subset. Therefore, the total number of choices is 2 × 2 × . . . × 2 (n times) = 2n

CPSC 121: Models of Computation

slide-22
SLIDE 22

Questions about Power Set

Question: What is the power set of the empty set, P(∅)? Answer: {∅} Question: What is P(P(∅))? Answer: P(P(∅)) = P({∅}) = {∅, {∅}} Question: What is P(P(P(∅)))? Answer: P(P(P(∅))) = P({∅, {∅}}) = {∅, {∅}, {{∅}}, {∅, {∅}}} Question: For a set of cardinality n, what is the cardinality of its power set? Answer: For each of the n elements, we have 2 independent choices: put it in the subset or don’t put it in the subset. Therefore, the total number of choices is 2 × 2 × . . . × 2 (n times) = 2n

CPSC 121: Models of Computation

slide-23
SLIDE 23

Theorem: Cardinality of Power Set

Theorem: Let S be a finite set |P(S)| = 2|S| Proof (by induction): To follow (later)

CPSC 121: Models of Computation