turing machines
play

Turing Machines 4.1 covers algorithms for decidable problems about - PowerPoint PPT Presentation

Reading Assignment: Sipser Chapter 3.1, 4.2 Turing Machines 4.1 covers algorithms for decidable problems about DFA, NFA, RegExp, CFG, and PDAs, e.g. slides 17 & 18 below. Ive talked about most of this in class at one point or another,


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

  2. All other transitions go to q reject 5 6 By definition, no transitions out of q acc, q rej ; L is Turing recognizable if ∃ TM M s.t. L = L(M) M halts if (and only if) it reaches either L is Turing decidable if, furthermore, M halts on all inputs M loops if it never halts (“loop” might suggest “simple”, but non- halting computations may of course be arbitrarily complex) A key distinction! M accepts if it reaches q acc, M rejects by halting in q rej or by looping The language recognized by M: L(M) = { w ∈ Σ * | M accepts w } 7 8

  3. Example: Multi-tape Turing Machines Church-Turing Thesis 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 (e.g., DFA’s) or too powerful (e.g., a computer with a “solve-the-halting-problem” instruction). 9 10 Nondeterministic Turing Machines δ : Q ! "# P ( Q ! " ! { L , R }) q0 Rej Rej Rej Rej Rej Rej . ... Rej Rej . . . . . Accept 11 12

  4. Nondeterministic Turing Machines Simulating an NTM δ : Q ! "# P ( Q ! " ! { L , R }) q0 Key issue: avoid getting lost on ∞ path Accept if any q0 path leads to Key Idea: breadth -first search q accept ; reject Rej Rej otherwise, Rej Rej Rej Rej Rej (i.e., all halting Rej Rej Rej . ... Rej Rej . paths lead to . . . Rej Rej . q reject ) Accept 3211... . ... Rej Rej . . . 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” A DFA = { <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> = ( (A 0 , A 1 , ...),(a 0 , a 1 , ...), (A 0 → a 0 A 1 , A 0 → a 1 , A 1 → a 2 A 1 a 1 , ...), A 0 ) DFA D = (Q, Σ , δ , q 0 , F); <D> = (...) TM M = (Q, Σ , Γ , δ , q 0 , q a , q r ); <M> = (...) ... 15 16

  5. Some Decidable Languages EMPTY DFA = {<D> | D is a DFA and L(D) = ∅ } pf: is there no path from start state to any final state? The following are decidable: EQ DFA = { <A,B> | A & B are DFAs s.t. L(A)= L(B) } A DFA = { <D,w> | D is a DFA & w ∈ L(D) } pf: equal iff L(A) ⊕ L(B) = ∅ , and x ⊕ y = (x ∩ y c ) ∪ (x c ∩ y), and regular sets are closed under ∪ , ∩ , complement pf: simulate D on w A NFA = { <N,w> | N is an NFA & w ∈ L(N) } A CFG = { <G,w> | ... } pf: convert N to a DFA, then use previous as a subroutine pf: see book A REX = { <R,w> | R is a regular expr & w ∈ L(R) } EMPTY CFG = { <G> | ... } pf: convert R to an NFA, then use previous as a subroutine pf: see book 17 18 EQ CFG = { <A,B> | A & B are CFGs s.t. L(A) = L(B) } This is NOT decidable 19 20

  6. The Acceptance Problem for TMs A TM = { <M,w> | M is a TM & w ∈ L(M) } Theorem: A TM 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://en.wikipedia.org/wiki/ENIAC 21 22 The Set of Languages in Σ * “Most” languages are neither Turing recognizable nor Turing decidable is Uncountable Proof idea: Suppose they were w 1 w 2 w 3 w 4 w 5 w 6 “ ⟨ ⟩ ” maps TMs into Σ * , a countable set, so the set of 1 L 1 0 0 0 0 0 0 List them in order TMs, and hence of Turing recognizable languages is also L 2 1 1 1 1 1 1 countable; Turing decidable is a subset of Turing Define L so that L 3 0 1 0 1 0 1 ... w i ∈ L ⇔ w i ∉ L i recognizable, so also countable. But by the previous L 4 0 1 0 0 0 0 result, the set of all languages is un countable. L 5 1 1 1 0 0 0 Then L is not in the list L 6 1 1 1 1 0 1 . . . Contradiction ... L 1 0 1 1 1 0 ... 23 24

  7. A specific non-Turing- recognizable language Theorem: The class of Turing recognizable languages is Let M i be the TM encoded w 1 w 2 w 3 w 4 w 5 w 6 not closed under complementation. by w i , i.e. ⟨ M i ⟩ = w i 1 <M 1 > 0 0 0 0 0 0 Proof: <M 2 > 1 1 1 1 1 1 (M i = some default machine, if w i <M 3 > 0 1 0 1 0 1 The complement of D, is Turing recognizable: is an illegal code.) ... <M 4 > 0 1 0 0 0 0 i, j entry =1 ⇔ M i accepts w j On input w i , run <M i > on w i (= <M i >); accept if it <M 5 > 1 1 1 0 0 0 does. E.g. use a universal TM on input <M i ,<M i >> <M 6 > 0 1 0 0 0 1 L D ={ w i | i,i entry = 0} . . . ... Then L D is not recognized by E.g., in previous example, D c might be L(M 6 ) any TM L D 1 0 1 1 1 0 ... 25 26 The Acceptance Problem for TMs Theorem: The class of Turing decidable languages is A TM = { <M,w> | M is a TM & w ∈ L(M) } closed under complementation. Theorem: A TM is Turing recognizable Proof Idea: 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. � Flip q accept , q reject , (just like we did with DFAs) U is called a Universal Turing Machine (Ancestor of the stored-program computer) Note that U is a recognizer, not a decider. 27 28

  8. A specific non-Turing- Note: The above TM D, if A TM is Undecidable it existed, would recognize recognizable language exactly the language L D defined in this A TM = { <M,w> | M is a TM & w ∈ L(M) } diagonalization proof Let M i be the TM (which we already know is w 1 w 2 w 3 w 4 w 5 w 6 encoded by w i , i.e. Suppose it’s decidable, say by TM H. Build a new TM D: 1 <M 1 > 0 0 0 0 0 0 <M i > = w i not recognizable) “on input <M> (a TM), run H on <M,<M>>; when it <M 2 > 1 1 1 1 1 1 (M i = some default machine, if <M 3 > 0 1 0 1 0 1 halts, halt & do the opposite, i.e. accept if H rejects ... w i is an illegal code.) and vice versa” <M 4 > 0 1 0 0 0 0 <M 5 > 1 1 1 0 0 0 i, j entry tells whether D accepts <M> iff H rejects <M,<M>> (by construction) <M 6 > 0 1 0 0 0 1 M i accepts w j iff M rejects <M> (H recognizes A TM ) . . . ... Then L D is not recognized D accepts <D> iff D rejects <D> (special case) by any TM L D 1 0 1 1 1 0 ... Contradiction! 29 30 ⊂ Decidable = Rec ∩ co-Rec Decidable Recognizable ≠ L decidable iff both L & L c are recognizable co- recognizable Pf: ( $ ) on any given input, recognizable co- dovetail (run in parallel) a recognizable recognizable recognizer for L with one for L D L D L c ; one or the other must halt decidable & accept, so you can halt & accept/reject appropriately. decidable ( % ): from above, decidable languages are closed under complement (flip acc/rej) 31 32

  9. The Halting Problem Programs vs TMs HALT TM = { <M,w> | TM M halts on input w } 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 Theorem: The halting problem is undecidable Some things are perhaps easier with programs. Proof: Others get harder (e.g., “Universal TM” is a Java interpreter written M,w in Java; “configurations” etc. are much messier) Suppose TM R decides HALT TM . S: R: Yes TMs are convenient to use here since they strike a good balance Halt? Consider S: between simplicity and versatility Simulate M on w On input <M,w>, run R on it. If it rejects, Hopefully you can mentally translate between the two; decidability/ rej acc halt & reject; if it accepts, run M on w; undecidability of various properties of programs are obviously rej acc accept/reject as it does. more directly relevant. Then S decides A TM , which is impossible. R can’t exist. 33 34 Many Undecidable Programs vs TMs Problems Fix Σ = printable ASCII About Turing Machines Programming language with ints, strings & function calls HALT TM EQ TM EMPTY TM REGULAR TM ... “Computable function” = always returns something About programs “Decider” = computable function always returning 0 / 1 Ditto! And : array-out-of-bounds, unreachability, loop “Acceptor” = accept if return 1; reject if ≠ 1 or loop termination, assertion-checking, correctness, ... About Other Things A Prog = {<P ,w> | program P returns 1 on input w } EMPTY LBA ALL CFG EQ CFG PCP DiophantineEqns ... HALT Prog = {<P ,w> | prog P returns something on w } ... 35 36

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend