Turing Machines. Reading Assignment: Sipser Chapter 3.1, 4.2

Similar documents
Reading Assignment: Sipser Chapter 3.1, 4.2

Initial Reading Assignment: Sipser Chapter 3 CSE 431. Larry Ruzzo, Spring

CSE 105 THEORY OF COMPUTATION

CSE 105 Theory of Computation

CSE 105 THEORY OF COMPUTATION

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

Decidability and Undecidability

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

1 Showing Recognizability

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

Turing Machines Part III

CSE 105 Theory of Computation

Computational Models Lecture 8 1

Computational Models Lecture 8 1

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

Lecture Notes: The Halting Problem; Reductions

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSCE 551: Chin-Tser Huang. University of South Carolina

Computational Models Lecture 8 1

ACS2: Decidability Decidability

CSE 105 THEORY OF COMPUTATION

Reducability. Sipser, pages

CPSC 421: Tutorial #1

Intro to Theory of Computation

Undecidable Problems and Reducibility

CSCE 551: Chin-Tser Huang. University of South Carolina

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

CSE 105 THEORY OF COMPUTATION

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

V Honors Theory of Computation

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

Intro to Theory of Computation

CSE 105 THEORY OF COMPUTATION

Decidability (intro.)

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Introduction to Turing Machines. Reading: Chapters 8 & 9

Further discussion of Turing machines

Turing Machines. Lecture 8

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Decidability (What, stuff is unsolvable?)

Decidability: Church-Turing Thesis

Decidable and undecidable languages

Theory of Computation (IX) Yijia Chen Fudan University

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CSE 105 THEORY OF COMPUTATION

CS154, Lecture 10: Rice s Theorem, Oracle Machines

TURING MAHINES

Reductions in Computability Theory

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CSE 105 THEORY OF COMPUTATION

Introduction to Languages and Computation

A Note on Turing Machine Design

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 10 Nancy Lynch

CS20a: Turing Machines (Oct 29, 2002)

CSE 105 THEORY OF COMPUTATION

Lecture 12: Mapping Reductions

Finish K-Complexity, Start Time Complexity

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

Problems, and How Computer Scientists Solve Them Manas Thakur

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Decidability. Overview. Preliminaries to Halting Problem. Decidable Problems of Regular Languages. Decidable Problems of Context-Free Languages

CS5371 Theory of Computation. Lecture 15: Computability VI (Post s Problem, Reducibility)

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Decidable Languages - relationship with other classes.

Computability and Complexity

Turing Machine Recap

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Lecture 13: Foundations of Math and Kolmogorov Complexity

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

CpSc 421 Homework 9 Solution

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

15-251: Great Theoretical Ideas in Computer Science Fall 2016 Lecture 6 September 15, Turing & the Uncomputable

Turing Machine Variants

Theory of Computation

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

Turing Machines Part Three

Theory of Computation

CSCI3390-Lecture 6: An Undecidable Problem

CS 361 Meeting 26 11/10/17

16.1 Countability. CS125 Lecture 16 Fall 2014

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

Most General computer?

Computational Models Lecture 9, Spring 2009

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

CSE 311: Foundations of Computing. Lecture 26: More on Limits of FSMs, Cardinality

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

MTAT Introduction to Theoretical Computer Science

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Turing Machines Part II

Lecture 16: Time Complexity and P vs NP

Turing Machines Part II

Non-emptiness Testing for TMs

CSE 105 THEORY OF COMPUTATION

UNIT-VIII COMPUTABILITY THEORY

Exam Computability and Complexity

Transcription:

Reading Assignment: Sipser Chapter 31, 42 Turing Machines 41 covers algorithms for decidable problems about DFA, NFA, RegExp, CFG, and PDAs, eg slides 17 & 18 below I ve talked about most of this in class at one point or another, but skimming 41 would probably be a good review 1 2 3 4

All other transitions go to qreject 5 6 By definition, no transitions out of qacc, qrej; M halts if (and only if) it reaches either M loops if it never halts ( loop might suggest simple, but nonhalting computations may of course be arbitrarily complex) M accepts if it reaches qacc, M rejects by halting in qrej or by looping The language recognized by M: L(M) = { w Σ* M accepts w } L is Turing recognizable if TM M st L = L(M) L is Turing decidable if, furthermore, M halts on all inputs A key distinction! 7 8

Church-Turing Thesis Example: Multi-tape Turing Machines TM s formally capture the intuitive notion of algorithmically solvable Not provable, since intuitive is necessarily fuzzy But, give support for it by showing that (a) other intuitively appealing (but formally defined) models are precisely equivalent, and (b) models that are provably different are unappealing, either because they are too weak (eg, DFA s) or too powerful (eg, a computer with a solve-the-halting-problem instruction) 9 10 Nondeterministic Turing Machines δ: Q! "# P (Q! "! {L,R}) q 0 Accept 11 12

q 0 Nondeterministic Turing Machines δ: Q! "# P (Q! "! {L,R}) Simulating an NTM Accept if any path leads to qaccept; reject otherwise, (ie, all halting paths lead to qreject ) Key issue: avoid getting lost on path Key Idea: breadth-first search q 0 Accept 3211 tree arity Q x Γ x {L,R} (3 in example) Accept 13 14 Encoding things Decidability Recall: L decidable means there is a TM recognizing L that always halts Σ =? Example: The acceptance problem for DFAs ADFA = { <D,w> D is a DFA & w L(D) } CFG G = (V, Σ, R, S) ; <G> = ((S,A,B,),(a,b,), (S aa, S b, A cab, ),S) or <G> = ((A0, A1, ),(a0, a1, ), (A0 a0 A1, A0 a1, A1 a2 A1 a1, ), A0) DFA D = (Q, Σ, δ, q0, F); <D> = () TM M = (Q, Σ, Γ, δ, q0, qa, qr); <M> = () 15 16

Some Decidable Languages The following are decidable: ADFA = { <D,w> D is a DFA & w L(D) } pf: simulate D on w ANFA = { <N,w> N is an NFA & w L(N) } pf: convert N to a DFA, then use previous as a subroutine AREX = { <R,w> R is a regular expr & w L(R) } pf: convert R to an NFA, then use previous as a subroutine EMPTYDFA = {<D> D is a DFA and L(D) = } pf: is there no path from start state to any final state? EQDFA = { <A,B> A & B are DFAs st L(A)= L(B) } pf: equal iff L(A) L(B) =, and x y = (x y c ) (x c y), and regular sets are closed under,, complement ACFG = { <G,w> } pf: see book EMPTYCFG = { <G> } pf: see book 17 18 EQCFG = { <A,B> A & B are CFGs st L(A) = L(B) } This is NOT decidable 19 20

The Acceptance Problem for TMs ATM = { <M,w> M is a TM & w L(M) } Theorem: ATM is Turing recognizable Pf: It is recognized by a TM U that, on input <M,w>, simulates M on w step by step U accepts iff M does U is called a Universal Turing Machine (Ancestor of the stored-program computer) Note that U is a recognizer, not a decider Programming ENIAC, circa 1947 http://enwikipediaorg/wiki/eniac 21 22 The Set of Languages in Σ * is Uncountable Suppose they were List them in order Define L so that wi L wi Li Then L is not in the list Contradiction L1 L2 L3 L4 L5 L6 w1 w2 w3 w4 w5 w6 10 0 0 0 0 0 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 0 1 L 1 0 1 1 1 0 Most languages are neither Turing recognizable nor Turing decidable Proof idea: maps TMs into Σ *, a countable set, so the set of TMs, and hence of Turing recognizable languages is also countable; Turing decidable is a subset of Turing recognizable, so also countable But by the previous result, the set of all languages is uncountable 23 24

A specific non-turingrecognizable language Let Mi be the TM encoded by wi, ie Mi = wi (Mi = some default machine, if wi is an illegal code) i, j entry =1 Mi accepts wj LD ={ wi i,i entry = 0} Then LD is not recognized by any TM <M1> > <M2> <M3> <M4> <M5> <M6> w1 w2 w3 w4 w5 w6 10 0 0 0 0 0 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 1 LD 1 0 1 1 1 0 Theorem: The class of Turing recognizable languages is not closed under complementation Proof: The complement of D, is Turing recognizable: On input wi, run <Mi> on wi (= <Mi>); accept if it does Eg use a universal TM on input <Mi,<Mi>> Eg, in previous example, D c might be L(M6) 25 26 The Acceptance Problem for TMs Theorem: The class of Turing decidable languages is closed under complementation Proof Idea: Flip qaccept, qreject, (just like we did with DFAs) ATM = { <M,w> M is a TM & w L(M) } Theorem: ATM is Turing recognizable Pf: It is recognized by a TM U that, on input <M,w>, simulates M on w step by step U accepts iff M does U is called a Universal Turing Machine (Ancestor of the stored-program computer) Note that U is a recognizer, not a decider 27 28

ATM is Undecidable ATM = { <M,w> M is a TM & w L(M) } Suppose it s decidable, say by TM H Build a new TM D: on input <M> (a TM), run H on <M,<M>>; when it halts, halt & do the opposite, ie accept if H rejects and vice versa D accepts <M> iff H rejects <M,<M>> iff M rejects <M> D accepts <D> iff D rejects <D> Contradiction! (by construction) (H recognizes ATM) (special case) A specific non-turingrecognizable language Let Mi be the TM encoded by wi, ie <Mi> = wi Note: The above TM D, if it existed, would recognize exactly the language LD defined in this diagonalization proof (which we already know is not recognizable) (Mi = some default machine, if wi is an illegal code) i, j entry tells whether Mi accepts wj Then LD is not recognized by any TM <M1> <M2> > <M3> <M4> <M5> <M6> w1 w2 w3 w4 w5 w6 10 0 0 0 0 0 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 1 LD 1 0 1 1 1 0 29 30 Decidable Recognizable Decidable = Rec co-rec LD decidable recognizable LD L decidable iff both L & L c are recognizable Pf: ($) on any given input, dovetail (run in parallel) a recognizer for L with one for L c ; one or the other must halt & accept, so you can halt & accept/reject appropriately corecognizable corecognizable decidable recognizable (%): from above, decidable languages are closed under complement (flip acc/rej) 31 32

The Halting Problem HALTTM = { <M,w> TM M halts on input w } Theorem: The halting problem is undecidable Proof: Suppose TM R decides HALTTM Consider S: On input <M,w>, run R on it If it rejects, halt & reject; if it accepts, run M on w; accept/reject as it does M,w S: R: Yes Halt? Simulate M on w rej acc Then S decides ATM, which is impossible R can t exist rej acc Programs vs TMs Everything we ve done re TMs can be rephrased re programs From the Church-Turing thesis, we expect them to be equivalent, and it s not hard to prove that they are Some things are perhaps easier with programs Others get harder (eg, Universal TM is a Java interpreter written in Java; configurations etc are much messier) TMs are convenient to use here since they strike a good balance between simplicity and versatility Hopefully you can mentally translate between the two; decidability/ undecidability of various properties of programs are obviously more directly relevant 33 34 Programs vs TMs Fix Σ = printable ASCII Programming language with ints, strings & function calls Computable function = always returns something Decider = computable function always returning 0 / 1 Acceptor = accept if return 1; reject if 1 or loop AProg = {<P,w> program P returns 1 on input w } HALTProg = {<P,w> prog P returns something on w } Many Undecidable Problems About Turing Machines HALTTM EQTM EMPTYTM REGULARTM About programs Ditto! And: array-out-of-bounds, unreachability, loop termination, assertion-checking, correctness, About Other Things EMPTYLBA ALLCFG EQCFG PCP DiophantineEqns 35 36

Turing Machines Summary A simple model of mechanical computation Church-Turing Thesis All reasonable models are alike in capturing the intuitive notion of mechanically computable Decidable/Recognizable Key distinction: Does it halt Undecidability counting, diagonalization, reduction ATM = { <M,w> TM M accepts w } HALTTM = { <M,w> TM M halts on w } Want More? Check out CSE 431 Intro Computability & Complexity 37 38