welcome to cs103! - stanford university · pdf filewelcome to cs103! many handouts! course...

204
Welcome to CS103! Handouts Course Information Syllabus Today: Course Overview Introduction to Set Theory The Limits of Computation Problem Set 0 will be posted later today

Upload: dinhtu

Post on 29-Mar-2018

226 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Welcome to CS103!

● Handouts● Course Information● Syllabus

● Today:● Course Overview● Introduction to Set Theory● The Limits of Computation● Problem Set 0 will be posted later today

Page 2: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Are there “laws of physics”in computer science?

Page 3: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Key Questions in CS103

● What problems can you solve with a computer?● Computability Theory

● Why are some problems harder to solve than others?● Complexity Theory

● How can we be certain in our answers to these questions?● Discrete Mathematics

Page 4: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

InstructorsCynthia Lee ([email protected])

Head TAGuy Amdur ([email protected])

TAsChioma Agu

Diego HernandezDana MurphyHugo ValdiviaLaetitia Shao

Sudarshan Seshadri

Page 5: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

https://cs103.stanford.edu

Course Website

Page 6: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Prerequisite / Corequisite

CS106BThis is a new pre/corequisite this year.

We’ve added in some programming assignments and will be referencing

some concepts from CS106B/X throughout the quarter.

This is a new pre/corequisite this year. We’ve added in some programming assignments and will be referencing

some concepts from CS106B/X throughout the quarter.

There aren't any math prerequisites for this course – high-school algebra should be

enough!

There aren't any math prerequisites for this course – high-school algebra should be

enough!

Page 7: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Problem Set 0

● Your first assignment, Problem Set 0, goes out today. Its’ due Friday at 2:30PM.● There’s no actual coding involved. This is just

to ensure that you get your coding environment set up and know how to submit your work.

Page 8: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Recommended Reading

Page 9: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Online Course Notes

Page 10: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Grading

Page 11: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Problem SetsMidtermsFinal ExamParticipation

Grading

Ten Problem Sets

Problem sets (other than PS0) may be

done individually or in pairs.

Ten Problem Sets

Problem sets (other than PS0) may be

done individually or in pairs.

Page 12: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Problem SetsMidtermsFinal ExamParticipation

Grading

Midterm I

Monday, April 307:00PM – 10:00PM

Midterm I

Monday, April 307:00PM – 10:00PM

Midterm II

Monday, May 217:00PM – 10:00PM

Midterm II

Monday, May 217:00PM – 10:00PM

Page 13: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Problem SetsMidtermsFinal ExamParticipation

Grading

Midterm Score

²/₃ · Higher + ¹/₃ · Lower

Midterm Score

²/₃ · Higher + ¹/₃ · Lower

Page 14: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Problem SetsMidtermsFinal ExamParticipation

Grading

Final Exam

Friday, June 83:30PM – 6:30PM

Final Exam

Friday, June 83:30PM – 6:30PM

Page 15: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Problem SetsMidtermsFinal ExamParticipation

Grading

Lecture Participation

Optional—otherwise this 4% splits between midterm and final.

Lecture Participation

Optional—otherwise this 4% splits between midterm and final.

Page 16: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

CS103A

● CS103A is an optional, one-unit add-on course to CS103.

● It provides extra review and practice with the material from CS103 and covers general problem-solving techniques useful in discrete math.

● Similar in spirit to Math 51A, Physics 41A, or Chem 31AC.

● Runs on Tuesdays from 3:00 – 5:00PM in 380-380X, with some time left over at the end for one-on-one questions.

Page 17: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

We've got a big journey ahead of us.

Let's get started!

Page 18: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Introduction to Set Theory

Page 19: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

“The chemical elements”“Cute animals”

“Cool people”

“US coins”

“All the computers on theStanford network”

“CS103 students”

Page 20: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

A set is an unordered collection of distinct objects, which may be anything (including

other sets).

Page 21: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

A set is an unordered collection of distinct objects, which may be anything (including

other sets).

, , ,

Page 22: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

A set is an unordered collection of distinct objects, which may be anything (including

other sets).

, , ,

Set notation: Curly braces with commas separating out the

elements

Set notation: Curly braces with commas separating out the

elements

Page 23: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Two sets are equal when they have exactly the same contents, ignoring order.

, , ,

Page 24: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Two sets are equal when they have exactly the same contents, ignoring order.

, , ,

, , ,

Page 25: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Two sets are equal when they have exactly the same contents, ignoring order.

, , ,

, , ,

These are the same

set!

These are the same

set!

Page 26: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Sets cannot contain the same object twice. Repeated elements are ignored.

Page 27: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Sets cannot contain the same object twice. Repeated elements are ignored.

,

Page 28: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Sets cannot contain the same object twice. Repeated elements are ignored.

,

, , , , ,

Page 29: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Sets cannot contain the same object twice. Repeated elements are ignored.

,

, , , , ,

These are the same set!

These are the same set!

Page 30: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

ØWe use this symbol to denote the empty set.

The empty set contains no elements.

=

Page 31: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online
Page 32: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Are these objects equal to one another?

1 1≟

This is a number.

This is a number.

This is a set. It contains a number.

This is a set. It contains a number.

Page 33: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Are these objects equal to one another?

1 1≠

This is a number.

This is a number.

This is a set. It contains a number.

This is a set. It contains a number.

Page 34: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Are these objects equal to one another?

Ø Ø≟

This set contains nothing at all.

This set contains nothing at all.

This set has one element, which

happens to be the empty set.

This set has one element, which

happens to be the empty set.

Page 35: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Are these objects equal to one another?

Ø Ø≠

This set contains nothing at all.

This set contains nothing at all.

This set has one element, which

happens to be the empty set.

This set has one element, which

happens to be the empty set.

Page 36: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Membership

Page 37: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Membership

, , ,

Page 38: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Membership

, , ,

Is in this set?

Page 39: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Membership

, , ,

Is in this set?

Page 40: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Membership

, , ,

Is in this set?

Page 41: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Membership

, , ,

Is in this set?

Page 42: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Set Membership

● Given a set S and an object x, we write

x ∈ S

if x is contained in S, and

x ∉ S

otherwise.● If x ∈ S, we say that x is an element of S.● Given any object x and any set S, either

x ∈ S or x ∉ S.

Page 43: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Sets

● Some sets contain infinitely many elements!● The set ℕ = { 0, 1, 2, 3, …} is the set of all the

natural numbers.● Some mathematicians don't include zero; in this

class, assume that 0 is a natural number.● The set ℤ = { …, -2, -1, 0, 1, 2, … } is the set of

all the integers.● Z is from German “Zahlen.”

● The set ℝ is the set of all real numbers.● e ∈ ℝ, π ∈ ℝ, 4 ∈ ℝ, etc.

Page 44: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Describing Complex Sets

● Here are some English descriptions of infinite sets:

“The set of all even numbers.”

“The set of all real numbers less than 137.”

“The set of all negative integers.”● To describe complex sets like these

mathematically, we'll use set-builder notation.

Page 45: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

Even Natural Numbers

Page 46: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

Even Natural Numbers

Page 47: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

The set of all n

Even Natural Numbers

Page 48: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

The set of all n

Even Natural Numbers

where

Page 49: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

The set of all n

n is a natural number

Even Natural Numbers

where

Page 50: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

The set of all n

n is a natural number

and n is even

Even Natural Numbers

where

Page 51: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ n | n ∈ ℕ and n is even }

The set of all n

n is a natural number

and n is even

Even Natural Numbers

where

{ 0, 2, 4, 6, 8, 10, 12, 14, 16, … }

Page 52: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Set Builder Notation

● A set may be specified in set-builder notation:

{ x | some property x satisfies }● For example:

{ r | r ∈ ℝ and r < 137 }

{ n | n is an even natural number }

{ S | S is a set of US currency }

{ a | a is cute animal }

{ r ∈ ℝ | r < 137 }

{ n ∈ ℕ | n is odd }

Page 53: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Combining Sets

Page 54: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 55: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 56: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

A

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 57: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 58: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 59: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 60: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

A ∪ B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Union

{ 1, 2, 3, 4, 5 }

Page 61: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 62: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

A ∩ B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Intersection

{ 3 }

Page 63: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 64: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

A – B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Difference

{ 1, 2 }

Page 65: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

A \ B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Difference

{ 1, 2 }

Page 66: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

Page 67: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

A B

A Δ B

1

2

4

5

3

A = { 1, 2, 3 }B = { 3, 4, 5 }

SymmetricDifference

{ 1, 2, 4, 5 }

Page 68: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams

Page 69: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Venn Diagrams for Three Sets

Page 70: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Power Sets

Page 71: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets

● A set S is called a subset of a set T (denoted S ⊆ T) if all elements of S are also elements of T.

● Examples:● { 1, 2, 3 } ⊆ { 1, 2, 3, 4 }● { b, c } ⊆ { a, b, c, d }● { H, He, Li } ⊆ { H, He, Li }● ℕ ⊆ ℤ (every natural number is an integer)● ℤ ⊆ ℝ (every integer is a real number)

Page 72: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Page 73: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∈ S

Page 74: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∈ S

Page 75: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∈ S2

Page 76: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∈ S{2}

Page 77: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Page 78: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

⊆ S{ , }2

Page 79: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

⊆ S{ , }2

Page 80: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∉ S{ , }2

Page 81: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∉ S{ , }2

Page 82: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∈ S{ }2

Page 83: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

∈ S{ }2

Page 84: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

⊆ S{ }2

Page 85: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

⊆ S{ }2

Page 86: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

⊆ S{ }2

Page 87: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

2

Subsets and Elements

{2}

2

Set S

⊆ S

Page 88: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

2

Subsets and Elements

{2}

2

Set S

⊆ S(Since 2 isn't a

set.)

(Since 2 isn't a set.)

Page 89: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

● We say that S ∈ T if, among the elements of T, one of them is exactly the object S.

● We say that S ⊆ T if S is a set and every element of S is also an element of T. (S has to be a set for the statement S ⊆ T to be meaningful.)

● Although these concepts are similar, they are not the same! Not all elements of a set are subsets of that set and vice-versa.

● We have a resource on the course website, the Guide to Elements and Subsets, that explores this in more depth.

Page 90: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

What About the Empty Set?

● A set S is called a subset of a set T (denoted S ⊆ T) if all elements of S are also elements of T.

● Are there any sets S where Ø ⊆ S?● Equivalently, is there a set S where the

following statement is true?

“All elements of Ø arealso elements of S”

● Yes! In fact, this statement is true for every choice of S!

Page 91: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Vacuous Truth

● A statement of the form

“All objects of type Pare also of type Q”

is called vacuously true if there are no objects of type P.

● Vacuously true statements are true by definition. This is a convention used throughout mathematics.

● Some examples:● All unicorns are pink.● All unicorns are blue.● Every element of Ø is also an element of S.

Page 92: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Vacuous Truth

Can’t find an element of the set for which the statement fails if the set has no elements.

Page 93: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Page 94: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Ø ⊆ S

Page 95: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Ø ⊆ S

Page 96: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Ø ∉ S

Page 97: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Subsets and Elements

{2}

2

Set S

Ø ∉ S

Page 98: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

,,,,

,S =

℘(S) =

The notation (℘ S) denotes the power set of S (the set of all subsets of S).

Formally, (℘ S) = { T | T ⊆ S }

The notation (℘ S) denotes the power set of S (the set of all subsets of S).

Formally, (℘ S) = { T | T ⊆ S }

Ø

Page 99: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

What is (Ø)?℘

Answer: {Ø}

Remember that Ø ≠ {Ø}!

Page 100: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Cardinality

Page 101: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Cardinality

Page 102: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Cardinality

● The cardinality of a set is the number of elements it contains.

● If S is a set, we denote its cardinality by writing |S|.

● Examples:● |{a, b, c, d, e}| = 5● |{{a, b}, {c, d, e, f, g}, {h}}| = 3● |{1, 2, 3, 3, 3, 3, 3}| = 3● |{ n ∈ ℕ | n < 137}| = 137

Page 103: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

The Cardinality of ℕ

● What is |ℕ|?● There are infinitely many natural numbers.● |ℕ| can't be a natural number, since it's

infinitely large.● We need to introduce a new term.● Definition: |ℕ| = ℵ0

● Pronounced “Aleph-Zero” or “Aleph-Null”

Page 104: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

The Cardinality of ℕ

● What is |ℕ|?● There are infinitely many natural numbers.● |ℕ| can't be a natural number, since it's

infinitely large.● We need to introduce a new term.● Let's define ₀ℵ = |ℕ|.

● ₀ ℵ is pronounced “aleph-zero,” “aleph-nought,” or “aleph-null.”

Page 105: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Consider the set

S = { n | n ∈ ℕ and n is even }

What is |S|?

Page 106: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

How Big Are These Sets?

, , ,

, ,,

Page 107: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

How Big Are These Sets?

, , ,

, ,,

Page 108: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Comparing Cardinalities

● By definition, two sets have the same size if there is a way to pair their elements off without leaving any elements uncovered.

● The intuition:

, , ,

, ,,

Page 109: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

,

Comparing Cardinalities

● By definition, two sets have the same size if there is a way to pair their elements off without leaving any elements uncovered.

● The intuition:

, , ,

,,Everything has been

paired up, and this one is all alone.

Everything has been paired up, and this one

is all alone.

Page 110: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

0 2 4 6 8 ...

S = { n | n ∈ ℕ and n is even }

S

Two sets have the same size if there is a way to pair their

elements off without leaving any elements uncovered

Two sets have the same size if there is a way to pair their

elements off without leaving any elements uncovered

Page 111: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

0 2 4 6 8 ...

S = { n | n ∈ ℕ and n is even }

S

Two sets have the same size if there is a way to pair their

elements off without leaving any elements uncovered

Two sets have the same size if there is a way to pair their

elements off without leaving any elements uncovered

Page 112: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

0 2 4 6 8 ...

S = { n | n ∈ ℕ and n is even }

S

Page 113: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

0 2 4 6 8 10 12 14 16 ...

n ↔ 2n

S = { n | n ∈ ℕ and n is even }

|S| = |ℕ| = ₀ℵ

S

Page 114: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1 0 1 2 3 4 ...

Page 115: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1

0 1 2 3 4 ...

Page 116: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1

ℤ 0 1 2 3 4 5 6 7 8 ...

Page 117: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1

ℤ 0 1 2 3 4 5 6 7 8 ...

Two sets have the same size if there is a way to pair their

elements off without leaving any elements uncovered

Two sets have the same size if there is a way to pair their

elements off without leaving any elements uncovered

Page 118: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1 0 1 2 3 4 ...

Page 119: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1 0 1 2 3 4 ...

Page 120: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1

ℤ 0 1 2 3 4 ...

Page 121: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1

ℤ 0 1 2 3 4 ...

Page 122: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

... -3 -2 -1

ℤ 0 1 2 3 4 ...

Pair nonnegative integers with even natural numbers. n ↔ -(n + 1) / 2 (if n is odd)

Page 123: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

-3-2-1

ℤ 0 1 2 3 4 ...-4

Pair nonnegative integers with even natural numbers. n ↔ -(n + 1) / 2 (if n is odd)

Page 124: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

-3-2-1

ℤ 0 1 2 3 4 ...-4

Pair nonnegative integers with even natural numbers. n ↔ -(n + 1) / 2 (if n is odd)

Page 125: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

-3-2-1

ℤ 0 1 2 3 4 ...-4

Pair nonnegative integers with even natural numbers.Pair negative integers with odd natural numbers.

Page 126: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

0 1 2 3 4 5 6 7 8 ...

-3-2-1

ℤ 0 1 2 3 4 ...-4

Pair nonnegative integers with even natural numbers.Pair negative integers with odd natural numbers.

|ℕ| = |ℤ| = ℵ0

Page 127: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Important Question:

Do all infinite sets havethe same cardinality?

Page 128: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

,,,,

,S =

℘(S) = Ø|S| < | (S)|℘

Page 129: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

,S =

℘(S) =

,

, ,

Ø

, , ,

, , , ,

, , ,

|S| < | (S)|℘

Page 130: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

S = {a, b, c, d}

℘(S) = {Ø,

{a}, {b}, {c}, {d},{a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d}

{a, b, c}, {a, b, d}, {a, c, d}, {b, c, d},{a, b, c, d}

}

|S| < | (℘ S)|

Page 131: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

If |S| is infinite, what is therelation between |S| and | (℘ S)|?

Does |S| = | (℘ S)|?

Page 132: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

If |S| = | (℘ S)|, we can pair up the elements of S and the elements of (℘ S) without

leaving anything out.

What might this correspondence look like?

Page 133: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

If |S| = | (℘ S)|, we can pair up the elements of S and the elements of (℘ S) without

leaving anything out.

What might this correspondence look like?

Page 134: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

If |S| = | (℘ S)|, we can pair up the elements of S and the subsets of S without

leaving anything out.

What might this correspondence look like?

Page 135: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

If |S| = | (℘ S)|, we can pair up the elements of S and the subsets of S without

leaving anything out.

Page 136: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

If |S| = | (℘ S)|, we can pair up the elements of S and the subsets of S without

leaving anything out.

What would that look like?

Page 137: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

x0

x2

x3

x4

x5

x1

...

Page 138: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

x0

x2

x3

x4

x5

x1

Page 139: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 140: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ x0, x2, x4, ...}

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Y Y YN N N …

Page 141: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ x0, x3, x4, ...}…

{ x4, ... }

{ x1, x4, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Y Y Y NN N

Page 142: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 143: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 144: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 145: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 146: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y NN …N YN

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 147: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y Y Y Y Y …

Y NN …N YN

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 148: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ x0, x2, x4, ... }

{ x0, x3, x4, ... }

{ x4, ... }

{ x1, x4, ... }

{ 0, 2, 4, ... }

{ 0, 2, 4, ... }

{ “b”, “ab”, ... }

{ x0, x1, x2, x3, x4, x5, ... }

...

{ x0, x5, ... }

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y Y Y Y Y …

Y NN …N YN

… … … … … … …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 149: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }Y NYN N …N YN

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 150: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }Y NYN N …N YN

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 151: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Y NN N N

YN NN

Y Y Y NN N …

Y NN N N N …

Y N …

N N NNN …

Y Y Y Y Y Y …

… … … … … …

…Y N N N N Y

…...

Y …

x0, x5, …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Y Y YN N N

Page 152: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … …

…Y N N N N Y

…...

{ 0, 2, 4, ... }{ “b”, “ab”, ... }Y NYN Y …N YN

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 153: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … …

…Y N N N N Y

…...

{ 0, 2, 4, ... }{ “b”, “ab”, ... }Y NYN Y …N YN

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 154: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … …

…Y N N N N Y

…...

{ 0, 2, 4, ... }{ “b”, “ab”, ... }Y NYN Y …N YN

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 155: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y Y Y Y Y …

… … … … … …

…Y N N N N Y

…...

Flip all Y's to N's and vice-versa to

get a new set

Flip all Y's to N's and vice-versa to

get a new set

N Y Y Y N ...Y

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Y NN N YN

Y Y YN N N

Page 156: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Y …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y Y Y Y Y …

… … … … … … …...

Flip all Y's to N's and vice-versa to

get a new set

Flip all Y's to N's and vice-versa to

get a new set

N Y Y Y N ...Yx2, x3, x4, ...x1,

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Y NN N YN

Y YN N N

Page 157: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 158: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 159: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 160: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 161: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 162: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 163: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 164: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y Y N ...

...

Y NYN N …N YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 165: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

...

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 166: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

...

{ 0, 2, 4, ... }Y Y YN N N …

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y Y NNNN …

Y Y Y Y Y Y …

… … … … … … …

Y N N N Y YN Y Y Y N N ...

...

Y NYN N …N

Y

YN

Which row in the table is paired with this set?

Which row in the table is paired with this set?

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 167: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

NN N YN

Y Y YN N N …

...

Y Y Y NN N …

Y NN N N N …

Y Y NN NN …

Y …

Y Y Y Y Y Y …

… … … … … … …

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 168: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 169: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 170: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…N Y N N N Y

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 171: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 172: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 173: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 174: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 175: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 176: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 177: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 178: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

{ 0, 2, 4, ... }

...

N N NN N Y …

Y Y Y YY Y …

Y NN Y N Y …

N Y NY NY …

Y Y NNNN …

Y N N N N Y …

… … … … … … …

{ 0, 2, 4, ... }{ “b”, “ab”, ... }N NYN N …Y YY

…Y N Y Y Y N

x0

x2

x3

x4

x5

x1

x0 x1 x2 x3 x4 x5 ...

Page 179: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

The Diagonalization Proof

● No matter how we pair up elements of S and subsets of S, the complemented diagonal won't appear in the table.

● In row n, the nth element must be wrong.● No matter how we pair up elements of S and

subsets of S, there is always at least one subset left over.

● This result is Cantor's theorem: Every set is strictly smaller than its power set:

If S is a set, then |S| < | (℘ S)|.

Page 180: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Infinite Cardinalities

● By Cantor's Theorem:

|ℕ| < | (ℕ)|℘

| (ℕ)| < | ( (ℕ))|℘ ℘℘

| ( (ℕ))| < | ( ( (ℕ)))|℘℘ ℘℘℘

| ( ( (ℕ)))| < | ( ( ( (ℕ))))|℘℘℘ ℘℘℘℘

… ● Not all infinite sets have the same size!

● There is no biggest infinity!

● There are infinitely many infinities!

Page 181: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

What does this have to dowith computation?

Page 182: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

“The set of all computer programs”

“The set of all problems to solve”

Page 183: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

● A string is a sequence of characters.● We're going to prove the following results:

● There are at most as many programs as there are strings.

● There are at least as many problems as there are sets of strings.

● This leads to some incredible results – we'll see why in a minute!

Page 184: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

A string is a sequence of characters.

We're going to prove the following results:● There are at most as many programs as there

are strings.

There are at least as many problems as there are sets of strings.

This leads to some incredible results – we'll see why in a minute!

Page 185: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Strings and Programs

● The source code of a computer program is just a (long, structured, well-commented) string of text.

● All programs are strings, but not all strings are necessarily programs.

All possibleprograms

All possiblestrings

|Programs| ≤ |Strings|

Page 186: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

● A string is a sequence of characters.● We're going to prove the following results:

● There are at most as many programs as there are strings.

● There are at least as many problems as there are sets of strings.

● This leads to some incredible results – we'll see why in a minute!

Page 187: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

● A string is a sequence of characters.● We're going to prove the following results:

● There are at most as many programs as there are strings. ✓

● There are at least as many problems as there are sets of strings.

● This leads to some incredible results – we'll see why in a minute!

Page 188: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

A string is a sequence of characters.

We're going to prove the following results:

There are at most as many programs as there are strings. ✓

● There are at least as many problems as there are sets of strings.

This leads to some incredible results – we'll see why in a minute!

Page 189: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Strings and Problems

● There is a connection between the number of sets of strings and the number of problems to solve.

● Let S be any set of strings. This set S gives rise to a problem to solve:

Given a string w, determine whether w ∈ S.

Page 190: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Strings and Problems

Given a string w, determine whether w ∈ S.

● Suppose that S is the set

S = { "a", "b", "c", …, "z" }● From this set S, we get this problem:

Given a string w, determine whetherw is a single lower-case English letter.

Page 191: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Strings and Problems

Given a string w, determine whether w ∈ S.

● Suppose that S is the set

S = { "0", "1", "2", …, "9", "10", "11", ... }● From this set S, we get this problem:

Given a string w, determine whetherw represents a natural number.

Page 192: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Strings and Problems

Given a string w, determine whether w ∈ S.

● Suppose that S is the set

S = { p | p is a legal Java program }● From this set S, we get this problem:

Given a string w, determine whetherw is a legal Java program.

Page 193: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Strings and Problems

● Every set of strings gives rise to a unique problem to solve.

● Other problems exist as well.

Problemsformed from

sets of strings

All possibleproblems

|Sets of Strings| ≤ |Problems|

Page 194: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

● A string is a sequence of characters.● We're going to prove the following results:

● There are at most as many programs as there are strings. ✓

● There are at least as many problems as there are sets of strings.

● This leads to some incredible results – we'll see why in a minute!

Page 195: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

● A string is a sequence of characters.● We're going to prove the following results:

● There are at most as many programs as there are strings. ✓

● There are at least as many problems as there are sets of strings. ✓

● This leads to some incredible results – we'll see why in a minute!

Page 196: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

A string is a sequence of characters.

We're going to prove the following results:

There are at most as many programs as there are strings. ✓

There are at least as many problems as there are sets of strings. ✓

● This leads to some incredible results – we'll see why in a minute!

Page 197: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going

A string is a sequence of characters.

We're going to prove the following results:

There are at most as many programs as there are strings. ✓

There are at least as many problems as there are sets of strings. ✓

● This leads to some incredible results – we'll see why in a minute! right now!

Page 198: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Every computer program is a string.

So, the number of programs is at most the number of strings.

From Cantor's Theorem, we know that there are more sets of strings than strings.

There are at least as many problemsas there are sets of strings.

|Programs| |Strings| |Sets of Strings| |Problems|≤ ≤<

Page 199: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

|Programs| < |Problems|

Every computer program is a string.

So, the number of programs is at most the number of strings.

From Cantor's Theorem, we know that there are more sets of strings than strings.

There are at least as many problemsas there are sets of strings.

Page 200: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

|Programs| < |Problems|

There are more problems tosolve than there are programs

to solve them.

Page 201: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

It Gets Worse

● Using more advanced set theory, we can show that there are infinitely more problems than solutions.

● In fact, if you pick a totally random problem, the probability that you can solve it is zero.

● More troubling fact: We've just shown that some problems are impossible to solve with computers, but we don't know which problems those are!

Page 202: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

We need to develop a more nuanced understanding of computation.

Page 203: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Where We're Going● What makes a problem impossible to solve

with computers?● Is there a deep reason why certain problems can't be

solved with computers, or is it completely arbitrary?● How do you know when you're looking at an

impossible problem?● Are these real-world problems, or are they highly

contrived?● How do we know that we're right?

● How can we back up our pictures with rigorous proofs?

● How do we build a mathematical framework for studying computation?

Page 204: Welcome to CS103! - Stanford University · PDF fileWelcome to CS103! Many Handouts! Course Information Syllabus Problem Set 0 (There’s some other ones that are only available online

Next Time

● Mathematical Proof● What is a mathematical proof?● How can we prove things with certainty?