Presentation is loading. Please wait.

Presentation is loading. Please wait.

Turing Machines Acceptors; Enumerators

Similar presentations


Presentation on theme: "Turing Machines Acceptors; Enumerators"— Presentation transcript:

1 Turing Machines Acceptors; Enumerators
Chapter 4 Turing Machines Acceptors; Enumerators

2 Turing Machines Q: a finite set of states, and a halt state h ∉ Q
initially input  Σ* Turing Machines tape: σ # L ← → R read/write head Q: a finite set of states, and a halt state h ∉ Q s: the start state ∈ Q Σ: the tape alphabet, and a blank symbol # ∉ Σ δ: the transition function The head begins at the left end and crashes if it moves off the edge. δ : Q × (Σ ∪ {#}) → (Q ∪ {h}) × (Σ ∪ {#} ∪ {L, R}) It accepts by halting with a blank tape (infinite computations possible). finite control h halt state 9/22/2018 Theory of Computation: Chapter 4

3 Theory of Computation: Chapter 4
Simple Example h #, # q₀ Q = {q₀, q₁} Σ = {a} (erases all its input) δ(q₀, a) = (q₁, #) − erase a δ(q₀, #) = (h, #) − halt at end δ(q₁, a) = (q₀, a) − not used δ(q₁, #) = (q₀, R) − move right a, # #, R a, a q₁ δ(q, σ) σ = a σ = # q = q₀ (q₁, #) (h, #) q = q₁ (q₀, a) (q₀, R) 9/22/2018 Theory of Computation: Chapter 4

4 Instantaneous descriptions
q α σ β # … α ∈ (Σ ∪ {#})* σ ∈ (Σ ∪ {#}) β ∈ (Σ ∪ {#})*Σ + ε (no unnecessary blanks) Before: After: Unless: LEFT MOVE δ(q, σ) = (q′, L) α = α′a σ β q q′ α′ a σ β If σ = # and β = ε then: # WRITING δ(q, σ) = (q′, σ′) α σ β q q′ σ′ RIGHT MOVE δ(q, σ) = (q′, R) α σ bβ' = β q q′ ασ b β' If β = ε then: # assumes head is not leftmost 9/22/2018 Theory of Computation: Chapter 4

5 L = {w  {a, b, c}* : |w|a = |w|b = |w|c}
δ X a b c blank (#) q∅ q∅, L q{a, b, c}, R (restart) q{a} q{a}, R q∅, X h, a (missing an “a”) q{b} q{b}, R h, b (missing a “b”) q{c} q{c}, R h, c (missing a “c”) q{a, b} q{a, b}, R q{b}, X q{a}, X h, c (extra “c”) q{b, c} q{b, c}, R q{c}, X h, a (extra “a”) q{a, c} q{a, c}, R h, b (extra “b”) q{a, b, c} q{a, b, c}, R q{b, c}, X q{a, c}, X q{a, b}, X h, # (accept) Idea: leftmost cell is blank; qs is looking for any symbol in s to X out. Accepts when tape contains only X’s and #’s (in halt state). Head ends up on blank square to the right of the input. 9/22/2018 Theory of Computation: Chapter 4

6 Acceptors A read-only input tape; assume read head always moves right
Let Σ = input alphabet A read/write work tape; no restrictions on head movement Let Γ = work tape alphabet δ : Q × Σ × Γ → (Q ∪ {h}) × (Σ ∪ {L, R}) 9/22/2018 Theory of Computation: Chapter 4

7 Enumerators A read/write work tape; no restrictions on head movement
Let Γ = work tape alphabet A write-only output tape; assume output head always moves right Let Σ = output alphabet, and # ∈ Σ be a separator on the output tape δ : Q × Γ → (Q ∪ {h}) × (Γ ∪ {L, R}) × (Σ ∪ {ε}) must be deterministic 9/22/2018 Theory of Computation: Chapter 4

8 Theory of Computation: Chapter 4
q₁ L = {0ⁿ1ⁿ : n ≥ 0} q₀ writing zeros _ X ……… writing ones Let _ be the blank on work tape Let # be the separator on output tape writes separator after head returns to left square scans right over X’s while writing 0’s on output scans left over X’s while writing 1’s on output _, R : # X, R : 0 δ _ X q₀ q₁, R, # q₀, L, 1 q₁ q₀, X, 0 q₁, R, 0 X, L : 1 q₀ q₁ H&U 7.8 _, X : 0 adds additional X on end of work tape 9/22/2018 Theory of Computation: Chapter 4

9 Non-deterministic Turing Machines
Δ ⊆ (Q × Σ) × ((Q ∪ {h}) × (Σ ∪ {L, R})) Definition: A nondeterministic Turing machine (NTM) M accepts a string w iff there is some possible choice of moves that causes M to accept on input w (e.g. halting with an empty tape.) Let LM = {w : M accepts w}. Does it matter how we define termination for NTMs? Theorem: Every language accepted by an NTM is accepted by a DTM. 9/22/2018 Theory of Computation: Chapter 4

10 Theory of Computation: Chapter 4
Proof Let M be an NTM. We design a three tape DTM M' to simulate M. Idea: There are only finitely many choices for the next move of M. Holds the input w (so it doesn’t get erased) Enumerates all finite sequences of moves in length-increasing order A work tape to simulate the behavior of M, based on tape (2) After each finite sequence of moves is enumerated, copy (1) to (3) and simulate M on (3) using the deterministic choices on (2). If the simulation accepts then M′ halts. If not, M′ writes out the next sequence of moves to try on (2), and continue as before. 9/22/2018 Theory of Computation: Chapter 4

11 Termination and closure
A machine must halt and answer yes in order to accept, but it might not always terminate. How does an NTM terminate? Does it matter? Call a language recursively enumerable if it is accepted by some TM, and call it recursive if it is accepted by an always terminating TM. Both classes are closed under the positive Boolean operations, union (concurrent) and intersection (sequential). What about complement? Theorem: If a language and its complement are recursively enumerable, then both are recursive. Proof: Alternate execution between the two machines (zig-zag). Discuss intersection and union, along with the subtlety of the halt state: does it have out-degree zero or does it have a self-loop? 9/22/2018 Theory of Computation: Chapter 4

12 Decidability and Generability
Definitions: A language is decidable if it is accepted by a machine M that halts on all inputs. A language is generatable if it is printed by a machine M in length- increasing order, without duplicates. These two notions are equivalent! 9/22/2018 Theory of Computation: Chapter 4

13 Generatable ⇒ Decidable
Generator M output in order Proof: Suppose M generates L. Let M' run M, storing its output on a work tape. After each string enumerated by M, compare it with the input w. If they match, accept. Otherwise, reject when output from M exceeds |w|. Note: How do we know that the output from M will eventually exceed |w|? run again M W.O. … w′ … |w′| > n ? n yes reject size no w = w′ ? input w R.O. yes accept no 9/22/2018 Theory of Computation: Chapter 4

14 Decidable ⇒ Generatable
Decider accept reject input M Proof: Suppose M decides L. Construct M' by running M on all inputs enumerated in lexicographic order, printing on acceptance. Note: Why do strings come out in length-increasing without duplicates? generate next string print w w M no yes 9/22/2018 Theory of Computation: Chapter 4

15 Acceptability and Enumerability
Definitions: A language is acceptable if it is accepted by a (input) Turing machine. A language is enumerable if it is printed by an (output) Turing machine. These two notions are equivalent! 9/22/2018 Theory of Computation: Chapter 4

16 Enumerable ⇒ Acceptable
enumerator start M output Proof: Suppose M enumerates L. Construct M' to run M, comparing each output with its input. If they match, halt and accept. If not, continue. run M print one # w # yes accept Input w = no 9/22/2018 Theory of Computation: Chapter 4

17 Acceptable ⇒ Enumerable
acceptor input M yes Proof: Suppose M accepts L. Can’t construct a machine to enumerate L by running M on all strings and printing on acceptance. (Why?) Instead, enumerate all pairs consisting of a string and time bound (w, k) diagonally in lexicographic order, and run M on input w for only k steps. Observe: if accepted, w will print infinitely often. enumerate (w, k) run for k steps on input w M if accept, then print 9/22/2018 Theory of Computation: Chapter 4


Download ppt "Turing Machines Acceptors; Enumerators"

Similar presentations


Ads by Google