COMP-330 Theory of Computation - McGill...

58
COMP-330 Theory of Computation Fall 2017 -- Prof. Claude Crépeau Lec. 16 : Turing Machines

Transcript of COMP-330 Theory of Computation - McGill...

Page 1: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

COMP-330 Theory of Computation

Fall 2017 -- Prof. Claude Crépeau Lec. 16 :

Turing Machines

Page 2: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

COMP 330 Fall 2017: Lectures Schedule

14. MIDTERM15-16. Deterministic CFLs16-17. Turing Machines and Church-Turing Thesis17. Models of computation Basic computability theory18. Reducibility, undecidability and Rice’s theorem19. Undecidable problems about CFGs20. Post Correspondence Problem21. Validity of FOL is RE / Gödel’s and Tarski’s thms22. Universality / The recursion theorem 23. Degrees of undecidability24. Introduction to complexity25. Introduction to Quantum Computing/Complexity26. Review of course material

1-2. Introduction 1.5. Some basic mathematics2-3. Deterministic finite automata +Closure properties,4. Nondeterministic finite automata5. Minimization 6. Determinization+Kleene’s theorem7. Regular Expressions+GNFA8. The pumping lemma9. Myhill-Nerode theorem10. Context-Free Grammar11. PushDown automata12 .CFG - PDA equivalence13. CFG Pumping lemma and applications

Page 3: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

All languages

Decidable Languages

Context-freeLanguages

RegularLanguages

Languages we can describe

NON-Regular Languagesvia Pumping Lemma

NON-RegularLanguages

via Reductions

Computability Theory

Page 4: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

All languages

Decidable Languages

Context-freeLanguages

Languages we can describe

NON-CFLsvia Pumping Lemma

NON-CFLsvia Reductions

RegularLanguages

Computability Theory

Page 5: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

All languages

Decidable Languages

Context-freeLanguages

Languages .we can

describe

NON-decidablevia Diagonalization

NON-decidablevia Reductions

RegularLanguages

Computability Theory

Page 6: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Turing MACHINES

Alan Turing

Page 7: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

M1

Page 8: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

q1

M1

10010101

Page 9: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

q2

1

M1M1

10010101

Page 10: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

M1

10010101

q3

0

M1

Page 11: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

q2

1

M1M1

10110101read and write!moves Right and Left!

Page 12: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

M1

10110101

q3

0

M1

Page 13: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Turing Machines

Page 14: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Example

Page 15: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.
Page 16: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

StatesInput AlphabetTape AlphabetTransition functionStart stateAccept stateReject state

Definition of TMq1

q2 q3

a,b,c

q1 q2

b→c,Da,b,c,A,B,C,_

Page 17: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

StatesInput AlphabetTape AlphabetTransition functionStart stateAccept stateReject state

Definition of TMq1

q2 q3

a,b,c

q1 q2

b→c,Da,b,c,A,B,C,_

q1 q2

b→c,D

inputsymbol

outputsymbol

L or Rheadmove

Page 18: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

StatesInput AlphabetTape AlphabetTransition functionStart stateAccept stateReject state

Definition of TMq1

q2 q3

a,b,c

q1 q2

b→c,D

q1

qacc

a,b,c,A,B,C,_

qrej

Page 19: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM definition

Page 20: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.
Page 21: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Configuration

Page 22: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Computation

Page 23: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

For all a,b,c∈𝜞, u,v∈𝜞*, qi,qi∈Q

Config. ua qi bv yields config. u qj acv if δ(qi,b) = qj,c,L

Config. ua qi bv yields config. uac qj v if δ(qi,b) = qj,c,R

Special cases: Config. qi bv yields qj cv if δ(qi,b) = qj,c,LConfig. qi bv yields c qj v if δ(qi,b) = qj,c,R

TM definition

Page 24: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Computation

Start configuration: q0 w (w = input string)

Accepting configuration: state = qaccept

Rejecting configuration: state = qreject

Page 25: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Computation

Turing Machine M accepts input w if there exists configurations C0, C1,..., Cm such that

C0 is a start configuration

Ci yields Ci+1 for 0≤i<m

Cm is an accepting configuration.

The collection of strings that M accepts is the language of M or the language recognized by M, denoted L(M).

Page 26: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Computation

A TM decides a language if it recognizes it and halts (reaches an accepting or rejecting states) on all input strings.

Page 27: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Computation

A TM decides a language if it recognizes it and halts (reaches an accepting or rejecting states) on all input strings.

1Often named Recursively-Enumerable in the literature.2Often named Recursive in the literature.

Page 28: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Examples

Page 29: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Examples

Page 30: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Computation

Page 31: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.
Page 32: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Examples

Page 33: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

∑ \ { x , _ }

∑ \ { # , _ }

Page 34: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Examples

Page 35: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Examples

Page 36: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

TM Examples

Page 37: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

More Turing MACHINES

Multitape Turing Machines

Non-Deterministic Turing Machines

Enumerator Turing Machines

Everything else...

Page 38: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Multitape TM

Page 39: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Multitape TM

Page 40: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Multitape TM

Page 41: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Multitape TM

Page 42: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Non-deterministic TM

Page 43: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Non-deterministic TM

Page 44: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Non-deterministic TM

Page 45: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Enumerator TM

Page 46: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Enumerator TM

Page 47: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Enumerator TM

Page 48: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Enumerator TM

Page 49: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Enumerator TM

Page 50: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Lambda-calculus

Recursive Functions

Programming languages:

FORTRAN, PASCAL, C, JAVA,...

LISP, SCHEME,...

Everything Else

Alonzo Church

J. Barkley Rosser

Stephen Kleene

Page 51: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Lambda-calculus

Recursive Functions

Programming languages:

FORTRAN, PASCAL, C, JAVA,...

LISP, SCHEME,...

Everything Else

Alonzo Church

J. Barkley Rosser

Stephen Kleene

Page 52: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Lambda-calculus

Recursive Functions

Programming languages:

FORTRAN, PASCAL, C, JAVA,...

LISP, SCHEME,...

Everything Else

Alonzo Church

J. Barkley Rosser

Stephen Kleene

Page 53: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Church-Turing Thesis

Alonzo Church Alan Turing

Page 54: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Church-Turing Thesis

Page 55: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Speaking on 8 August 1900, at the Paris 2nd International Congress of Mathematicians, at La Sorbonne, German mathematician David Hilbert presented ten problems in mathematics.

The problems were all unsolved at the time, and several of them turned out to be very influential for 20th century mathematics.

Paris, 1900

David Hilbert

Page 56: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Hilbert’s 10th problem

Let P be a polynomial in several variables: P(x,y,z)=24x2y3+17x+5y+25

Is there a set of integers for x,y,z such that P(x,y,z)=0 ?

This problem is undecidable...but is Turing-Recognizable...

Needed a formal model ofcomputing to prove impossibility. Yuri Matiyasevich

Page 57: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

Single variable Poly

Page 58: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-16.pdf · 2017-11-07 · Turing Machines. COMP 330 Fall 2017: Lectures Schedule 14.

COMP-330 Theory of Computation

Fall 2017 -- Prof. Claude Crépeau Lec. 16 :

Turing Machines &Church-Turing Thesis