Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech...

134
Computational Models Inroduction to the Theory of Computing http://www.cs.tau.ac.il/bchor/CM05/compute.html Instructor: Prof. Benny Chor (benny@cs.tau.ac.il) Teaching Assistant: Dr. Gad Kimmel ([email protected]) Tel-Aviv University Fall Semester, 2004-2005 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.1

Transcript of Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech...

Page 1: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computational ModelsInroduction to the

Theory of Computinghttp://www.cs.tau.ac.il/∼bchor/CM05/compute.html

Instructor: Prof. Benny Chor ([email protected])

Teaching Assistant: Dr. Gad Kimmel ([email protected])

Tel-Aviv University

Fall Semester, 2004-2005

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.1

Page 2: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 3: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 4: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Late submition will not be accepted.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 5: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Late submition will not be accepted.

Only parts of the assignments will be graded.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 6: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Late submition will not be accepted.

Only parts of the assignments will be graded.

Solving assignments is crucial for exam.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 7: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Late submition will not be accepted.

Only parts of the assignments will be graded.

Solving assignments is crucial for exam.

Midterm exam (20-25% of grade).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 8: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Late submition will not be accepted.

Only parts of the assignments will be graded.

Solving assignments is crucial for exam.

Midterm exam (20-25% of grade).

Final exam (60-70% of grade).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 9: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTriviaCourse Requirements:

6 problem sets (10-15% of grade, best5-out-of-6).

Readable, concise, correct answers expected.

Late submition will not be accepted.

Only parts of the assignments will be graded.

Solving assignments is crucial for exam.

Midterm exam (20-25% of grade).

Final exam (60-70% of grade).

Second final (Moed B) in March.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2

Page 10: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTrivia IIPrerequisites:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3

Page 11: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTrivia IIPrerequisites:

Extended introduction to computer science(aka Scheme course).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3

Page 12: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTrivia IIPrerequisites:

Extended introduction to computer science(aka Scheme course).Students from other disciplines with somemathematical background are encouraged tocontact the instructor.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3

Page 13: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTrivia IIPrerequisites:

Extended introduction to computer science(aka Scheme course).Students from other disciplines with somemathematical background are encouraged tocontact the instructor.

Textbook (extensively used, highlyrecommended):

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3

Page 14: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

AdministraTrivia IIPrerequisites:

Extended introduction to computer science(aka Scheme course).Students from other disciplines with somemathematical background are encouraged tocontact the instructor.

Textbook (extensively used, highlyrecommended):

Michael Sipser, Introduction to the theory ofcomputation.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3

Page 15: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science Issues

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 16: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 17: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?Are computers omnipotent?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 18: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?Are computers omnipotent?What are the fundemental capabilities andlimitations of computers?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 19: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?Are computers omnipotent?What are the fundemental capabilities andlimitations of computers?

Pragmatic Reasons

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 20: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?Are computers omnipotent?What are the fundemental capabilities andlimitations of computers?

Pragmatic ReasonsAvoid intractable or impossible problems.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 21: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?Are computers omnipotent?What are the fundemental capabilities andlimitations of computers?

Pragmatic ReasonsAvoid intractable or impossible problems.Apply efficient algorithms when possible.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 22: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Why Study Theory?

Basic Computer Science IssuesWhat is a computation?Are computers omnipotent?What are the fundemental capabilities andlimitations of computers?

Pragmatic ReasonsAvoid intractable or impossible problems.Apply efficient algorithms when possible.Learn to tell the difference.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4

Page 23: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 24: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 25: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Complexity Theory: What makes some problemscomputationally hard and others easy?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 26: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Complexity Theory: What makes some problemscomputationally hard and others easy?

Coping with intractability:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 27: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Complexity Theory: What makes some problemscomputationally hard and others easy?

Coping with intractability:Approximation.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 28: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Complexity Theory: What makes some problemscomputationally hard and others easy?

Coping with intractability:Approximation.Randomization.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 29: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Complexity Theory: What makes some problemscomputationally hard and others easy?

Coping with intractability:Approximation.Randomization.Fixed parameter algorithms.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 30: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Course Topics

Automata Theory: What is a computer?

Computability Theory: What can computers do?

Complexity Theory: What makes some problemscomputationally hard and others easy?

Coping with intractability:Approximation.Randomization.Fixed parameter algorithms.Heuristics.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5

Page 31: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 32: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.Related to controllers and hardware design.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 33: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.Related to controllers and hardware design.Useful in text processing and finding patternsin strings.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 34: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.Related to controllers and hardware design.Useful in text processing and finding patternsin strings.Probabilistic (Markov) versions useful inmodeling various natural phenomena (e.g.speech recognition).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 35: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.Related to controllers and hardware design.Useful in text processing and finding patternsin strings.Probabilistic (Markov) versions useful inmodeling various natural phenomena (e.g.speech recognition).

Push down automata.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 36: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.Related to controllers and hardware design.Useful in text processing and finding patternsin strings.Probabilistic (Markov) versions useful inmodeling various natural phenomena (e.g.speech recognition).

Push down automata.Titely related to a family of languages knownas context free languages.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 37: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Automata Theory - Simple Models

Finite automata.Related to controllers and hardware design.Useful in text processing and finding patternsin strings.Probabilistic (Markov) versions useful inmodeling various natural phenomena (e.g.speech recognition).

Push down automata.Titely related to a family of languages knownas context free languages.Play important role in compilers, design ofprogramming languages, and studies ofnatural languages.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6

Page 38: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computability Theory

In the first half of the 20th century, mathematicianssuch as Kurt Göedel, Alan Turing, and AlonzoChurch discovered that some fundemental problemscannot be solved by computers.

Proof verication of statements can be automated.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.7

Page 39: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computability Theory

In the first half of the 20th century, mathematicianssuch as Kurt Göedel, Alan Turing, and AlonzoChurch discovered that some fundemental problemscannot be solved by computers.

Proof verication of statements can be automated.

It is natural to expect that determining validitycan also be done by a computer.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.7

Page 40: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computability Theory

In the first half of the 20th century, mathematicianssuch as Kurt Göedel, Alan Turing, and AlonzoChurch discovered that some fundemental problemscannot be solved by computers.

Proof verication of statements can be automated.

It is natural to expect that determining validitycan also be done by a computer.

Theorem: A computer cannot determine ifmathematical statement true or false.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.7

Page 41: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computability Theory

In the first half of the 20th century, mathematicianssuch as Kurt Göedel, Alan Turing, and AlonzoChurch discovered that some fundemental problemscannot be solved by computers.

Proof verication of statements can be automated.

It is natural to expect that determining validitycan also be done by a computer.

Theorem: A computer cannot determine ifmathematical statement true or false.

Results needed theoretical models for computers.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.7

Page 42: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computability Theory

In the first half of the 20th century, mathematicianssuch as Kurt Göedel, Alan Turing, and AlonzoChurch discovered that some fundemental problemscannot be solved by computers.

Proof verication of statements can be automated.

It is natural to expect that determining validitycan also be done by a computer.

Theorem: A computer cannot determine ifmathematical statement true or false.

Results needed theoretical models for computers.

These theoretical models helped lead to theconstruction of real computers.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.7

Page 43: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Computability Theory

a simplicial complexSlides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8

Page 44: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Paths and Loops

a path is a sequence of vertices connected byedges

a loop is a path that ends and ends at the samevertex

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.9

Page 45: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Paths and Loops can be Deformed

(v0, v1) ⇔ (v0, v2, v1)

(v0, v0) ⇔ (v0)

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.10

Page 46: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Contractibility

contractible

notcontractible

No algorithm can determine whether an arbitraryloop in an arbitrary finite complex is contractible.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.11

Page 47: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Some Other Undecidable ProblemsDoes a program run forever?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12

Page 48: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Some Other Undecidable ProblemsDoes a program run forever?

Is a program correct?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12

Page 49: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Some Other Undecidable ProblemsDoes a program run forever?

Is a program correct?

Are two programs equivalent?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12

Page 50: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Some Other Undecidable ProblemsDoes a program run forever?

Is a program correct?

Are two programs equivalent?

Is a program optimal?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12

Page 51: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Some Other Undecidable ProblemsDoes a program run forever?

Is a program correct?

Are two programs equivalent?

Is a program optimal?

Does an equation with one or more variables andinteger coefficients (5x + 15y = 12) have aninteger solution (Hilbert’s 10th problem).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12

Page 52: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Some Other Undecidable ProblemsDoes a program run forever?

Is a program correct?

Are two programs equivalent?

Is a program optimal?

Does an equation with one or more variables andinteger coefficients (5x + 15y = 12) have aninteger solution (Hilbert’s 10th problem).

Is a finitely-presented group trivial?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12

Page 53: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 54: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parameters

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 55: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 56: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedure

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 57: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipe

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 58: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipea computer program

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 59: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipea computer programa mathematical object

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 60: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipea computer programa mathematical object

We want the most efficient algorithms

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 61: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipea computer programa mathematical object

We want the most efficient algorithmsfastest (usually)

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 62: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipea computer programa mathematical object

We want the most efficient algorithmsfastest (usually)most economical with memory (sometimes)

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 63: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Complexity Theory

Key notion: tractable vs. intractable problems.

A problem is a general computational question:description of parametersdescription of solution

An algorithm is a step-by-step procedurea recipea computer programa mathematical object

We want the most efficient algorithmsfastest (usually)most economical with memory (sometimes)expressed as a function of problem size

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13

Page 64: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Example: Traveling Salesman Problem

Parameters:

set of cities

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.14

Page 65: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Example: Traveling Salesman Problem

Parameters:

set of cities

set of inter-city distancesSlides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.14

Page 66: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Example: Traveling Salesman Problem

Solution:

want the shortest tour through the cities

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.15

Page 67: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Example: Traveling Salesman Problem

Solution:

want the shortest tour through the cities

example: a, b, d, c, a has length 27.Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.15

Page 68: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 69: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 70: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 71: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Use an encoding of the problem

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 72: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Use an encoding of the problemalphabet of symbols

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 73: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Use an encoding of the problemalphabet of symbolsstrings: a/b/c/d//10/5/9//6/9//3.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 74: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Use an encoding of the problemalphabet of symbolsstrings: a/b/c/d//10/5/9//6/9//3.

Measures

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 75: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Use an encoding of the problemalphabet of symbolsstrings: a/b/c/d//10/5/9//6/9//3.

MeasuresProblem Size: length of encoding (here: 23ascii characters).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 76: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Problem SizeWhat is an appropriate measure of problem size?

m nodes?m(m + 1)/2 distances?

Use an encoding of the problemalphabet of symbolsstrings: a/b/c/d//10/5/9//6/9//3.

MeasuresProblem Size: length of encoding (here: 23ascii characters).Time Complexity: how long an algorithmruns, as function of problem size?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16

Page 77: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Time Complexity - What is tractable?

We say that a function f(n) is O(g(n)) if there isa constant c such that for large enough n,|f(n)| ≤ c · |g(n)|.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.17

Page 78: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Time Complexity - What is tractable?

We say that a function f(n) is O(g(n)) if there isa constant c such that for large enough n,|f(n)| ≤ c · |g(n)|.A polynomial-time algorithm is one whose timecomplexity is O(p(n)) for some polynomial p(n),where n denotes the length of the input.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.17

Page 79: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Time Complexity - What is tractable?

We say that a function f(n) is O(g(n)) if there isa constant c such that for large enough n,|f(n)| ≤ c · |g(n)|.A polynomial-time algorithm is one whose timecomplexity is O(p(n)) for some polynomial p(n),where n denotes the length of the input.

An exponential-time algorithm is one whose timecomplexity cannot be bounded by a polynomial(e.g., nlog n).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.17

Page 80: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Tractability – Basic distinction:

Polynomial time = tractable.

Exponential time = intractable.

10 20 30 40 50 60

n .00001 .00002 .00003 .00004 .00005 .00006

second second second second second second

n2 .00001 .00004 .00009 .00016 .00025 .00036

second second second second second second

n3 .00001 .00008 .027 .064 .125 .216

second second second second second second

n5 .1 3.2 24.3 1.7 5.2 13.0

second seconds seconds minute minutes minutes

2n .001 1.0 17.9 12.7 35.7 366

second second minutes days years centuries

3n .059 58 6.5 3855 2 · 108 1.3 · 1013second minutes years centuries centuries centuries

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.18

Page 81: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Effect of Speed-Ups

Let’s wait for faster hardware! Consider maximumproblem size you can solve in an hour.

present 100 times faster 1000 times faster

n N1 100N1 1000N1n2 N2 10N2 31.6N2n3 N3 4.64N3 10N3n5 N4 2.5N4 3.98N42n N5 N5 + 6.64 N5 + 9.97

3n N6 N6 + 4.19 N6 + 6.29

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.19

Page 82: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

NP-Completeness

Your boss says:

“Get me an efficient traveling-salesmanalgorithm, or else...”

What are you going to do?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.20

Page 83: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Yes Ma’am, expect it this afternoon!”

Problem is

All known algorithms (essentially) check allpossible paths.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.21

Page 84: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Yes Ma’am, expect it this afternoon!”

Problem is

All known algorithms (essentially) check allpossible paths.

Exhaustive checking is exponential.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.21

Page 85: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Yes Ma’am, expect it this afternoon!”

Problem is

All known algorithms (essentially) check allpossible paths.

Exhaustive checking is exponential.

Good luck!

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.21

Page 86: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Hah! I will prove that no such algorithm is possible”

Problem is, proving intractability is very hard.

Many important problems have

no known tractable algorithms

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22

Page 87: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Hah! I will prove that no such algorithm is possible”

Problem is, proving intractability is very hard.

Many important problems have

no known tractable algorithms

no known proof of intractability.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22

Page 88: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“I can’t find an efficient algorithm.I guess I’m just a pathetic loser. ”

Bad for job security.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.23

Page 89: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“The problem is NP-complete. I can’t findan efficient algorithm, but neither can anyof these famous people . . . ”

Advantage is:

The problem is “just as hard” as other problemssmart people can’t solve efficiently.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.24

Page 90: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“The problem is NP-complete. I can’t findan efficient algorithm, but neither can anyof these famous people . . . ”

Advantage is:

The problem is “just as hard” as other problemssmart people can’t solve efficiently.

So it would do your boss no good to fire you andhire a Technion/Hebrew Univ./MIT graduate.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.24

Page 91: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Would you settle for a pretty good, but not the best,algorithm?”

Intractability isn’t everything.

Find an approximate solution (is a solution within10% of optimum good enough, ma’am?).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.25

Page 92: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Would you settle for a pretty good, but not the best,algorithm?”

Intractability isn’t everything.

Find an approximate solution (is a solution within10% of optimum good enough, ma’am?).

Use randomization.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.25

Page 93: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Would you settle for a pretty good, but not the best,algorithm?”

Intractability isn’t everything.

Find an approximate solution (is a solution within10% of optimum good enough, ma’am?).

Use randomization.

Fixed parameter algorithms may be applicable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.25

Page 94: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Would you settle for a pretty good, but not the best,algorithm?”

Intractability isn’t everything.

Find an approximate solution (is a solution within10% of optimum good enough, ma’am?).

Use randomization.

Fixed parameter algorithms may be applicable.

Heuristics can also help.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.25

Page 95: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Response

“Would you settle for a pretty good, but not the best,algorithm?”

Intractability isn’t everything.

Find an approximate solution (is a solution within10% of optimum good enough, ma’am?).

Use randomization.

Fixed parameter algorithms may be applicable.

Heuristics can also help.

Approximation, randomization, etc. are amongthe hottest areas in complexity theory andalgorithmic research today.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.25

Page 96: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Next Subject

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.26

Page 97: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

A Very Short Math Review• Graphs• Strings and languages• Mathematical proofs• Mathematical notations (sets, sequences, . . . )

å Functions and predicates

√= done in recitation.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.27

Page 98: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Graphs

1

2

3

4

5

1

234

G = (V,E), where

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28

Page 99: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Graphs

1

2

3

4

5

1

234

G = (V,E), where

V is set of nodes or vertices, and

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28

Page 100: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Graphs

1

2

3

4

5

1

234

G = (V,E), where

V is set of nodes or vertices, and

E is set of edges

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28

Page 101: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Graphs

1

2

3

4

5

1

234

G = (V,E), where

V is set of nodes or vertices, and

E is set of edges

degree of a vertex is number of edges

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28

Page 102: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Graphs

2

3

5

1

4 subgraph

graph treeroot

2

3

5

1

4

cycle14

23

path

leaves

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.29

Page 103: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Directed Graphs

2

3

5

1

4

6

scissors

rockpaper

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.30

Page 104: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Directed Graph and its Adjacency Matrix

0 1 0 0 0 0

1 0 1 0 0 0

0 0 0 1 0 0

0 0 0 0 1 0

1 0 0 0 0 1

0 0 0 0 0 0

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.31

Page 105: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 106: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 107: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 108: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

the empty string ε

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 109: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

the empty string ε

reverse: abcd reversed is dcba.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 110: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

the empty string ε

reverse: abcd reversed is dcba.

substring: xyz in xyzzy.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 111: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

the empty string ε

reverse: abcd reversed is dcba.

substring: xyz in xyzzy.

concatenation of xyz and zy is xyzzy.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 112: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

the empty string ε

reverse: abcd reversed is dcba.

substring: xyz in xyzzy.

concatenation of xyz and zy is xyzzy.

xk is x · · · x, k times.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 113: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Strings and Languages

an alphabet is a finite set of symbols

a string over an alphabet is a finite sequence ofsymbols from that alphabet.

the length of a string is the number of symbols

the empty string ε

reverse: abcd reversed is dcba.

substring: xyz in xyzzy.

concatenation of xyz and zy is xyzzy.

xk is x · · · x, k times.

a language L is a set of strings.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32

Page 114: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

ProofsWe will use the following basic kinds of proofs.

by construction

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33

Page 115: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

ProofsWe will use the following basic kinds of proofs.

by construction

by contradiction

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33

Page 116: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

ProofsWe will use the following basic kinds of proofs.

by construction

by contradiction

by induction

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33

Page 117: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

ProofsWe will use the following basic kinds of proofs.

by construction

by contradiction

by induction

by reduction

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33

Page 118: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

ProofsWe will use the following basic kinds of proofs.

by construction

by contradiction

by induction

by reduction

we will often mix them.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33

Page 119: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Construction

A graph is k-regular if every node has degree k.

Theorem: For every even n > 2, there exists a3-regular graph with n nodes.

1

2

3

4

5

0

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.34

Page 120: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Construction

1

2

3

4

5

0

Proof: Construct G = (V,E), whereV = {0, 1, . . . , n − 1} and

E = {{i, i + 1} | for 0 ≤ i ≤ n − 2} ∪ {n − 1, 0}∪ {{i, i + n/2} | for 0 ≤ i ≤ n/2 − 1} .

Note: A picture is helpful, but it is not a proof!

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.35

Page 121: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Contradiction

Theorem:√

2 is irrational.

Proof: Suppose not. Then√

2 = mn , where m and n

are relatively prime.

n√

2 = m

2n2 = m2

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.36

Page 122: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Contradiction (cont.)

So m2 is even, and so is m = 2k.

2n2 = (2k)2

= 4k2

n2 = 2k2

Thus n2 is even, and so is n.

Therefore both m and n are even, and not relativelyprime!

Reductio ad absurdam.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.37

Page 123: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Induction

Prove properties of elements of an infinite set.N = {1, 2, 3, . . .}

To prove that ℘ holds for each element, show:

base step: show that ℘(1) is true.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.38

Page 124: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Induction

Prove properties of elements of an infinite set.N = {1, 2, 3, . . .}

To prove that ℘ holds for each element, show:

base step: show that ℘(1) is true.

induction step: show that if ℘(i) is true (theinduction hypothesis), then so is ℘(i + 1).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.38

Page 125: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example

Theorem: All cows are the same color.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39

Page 126: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example

Theorem: All cows are the same color.Base step: A single-cow set is definitely the samecolor.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39

Page 127: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example

Theorem: All cows are the same color.Base step: A single-cow set is definitely the samecolor.Induction Step: Assume all sets of i cows are thesame color. Divide the set {1, . . . , i + 1} intoU = {1, . . . , i}, and V = {2, . . . , i + 1}.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39

Page 128: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example

Theorem: All cows are the same color.Base step: A single-cow set is definitely the samecolor.Induction Step: Assume all sets of i cows are thesame color. Divide the set {1, . . . , i + 1} intoU = {1, . . . , i}, and V = {2, . . . , i + 1}.

All cows in U are the same color by the inductionhypothesis.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39

Page 129: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example

Theorem: All cows are the same color.Base step: A single-cow set is definitely the samecolor.Induction Step: Assume all sets of i cows are thesame color. Divide the set {1, . . . , i + 1} intoU = {1, . . . , i}, and V = {2, . . . , i + 1}.

All cows in U are the same color by the inductionhypothesis.All cows in V are the same color by the inductionhypothesis.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39

Page 130: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example

Theorem: All cows are the same color.Base step: A single-cow set is definitely the samecolor.Induction Step: Assume all sets of i cows are thesame color. Divide the set {1, . . . , i + 1} intoU = {1, . . . , i}, and V = {2, . . . , i + 1}.

All cows in U are the same color by the inductionhypothesis.All cows in V are the same color by the inductionhypothesis.All cows in U ∩ V are the same color by the inductionhypothesis.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39

Page 131: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example (cont.)

Ergo, all cows are the same color.

Quod Erat Demonstrandum (QED).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.40

Page 132: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Induction Example (cont.)

Ergo, all cows are the same color.

Quod Erat Demonstrandum (QED).

(cows’ images courtesy of www.crawforddirect.com/ cows.htm)Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.40

Page 133: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Reduction

We can sometime solve problem A by reducing it toproblem B, whose solution we already know.

Example: Maximal matching in bipartite graphs:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.41

Page 134: Computational Models Inroduction to the Theory of …bchor/CM05/Compute1_Intro.pdfspeech recognition). Push down automata. Titely related to a family of languages known as context

Proof by Reduction

Reducing bipartite matching to MAX FLOW:

Reduction: Put capacity 1 on each edge.Maximum flow corresponds to maximum matching.So if we have an algorithm that produces max flow,we can easily derive a maximum bipartite matchingfrom it.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.42