Download presentation
Presentation is loading. Please wait.
Published byJosephine Daniels Modified over 9 years ago
1
Nathan Brunelle Department of Computer Science University of Virginia www.cs.virginia.edu/~njb2b/theory Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death
2
Spring Break Extra Credit Assignment Read Chapter 3 of Sipser. One sentence in there is the most bogus sentence in the entire book. Correctly guessing which sentence is bogus earns extra credit.
3
Turing Machine Infinite tape: Γ* Tape head: read current square on tape, write into current square, move one square left or right FSM:like PDA, except: transitions also include direction (left/right) final accepting and rejecting states … FSM
4
Turing Machine Acceptance … FSM δ *: Γ* Q Γ * Γ* Q Γ * A string w is in the language of Turing Machine T if δ*(ε, q 0, w) = (u, q accept, v) A string w is not in the language of Turing Machine T if δ*(ε, q 0, w) = (u, q reject, v) Does this cover all possibilities? u v
5
Machine Termination DFAs, DPDAs: Consume one input symbol each step Must terminate NFAs: Equivalent to DFA: must terminate Turing Machine: Can move left and right: no “progress” guarantee
6
Infinite Loops Some Turing machines have infinite loops: While(true){ TwiddleThumbs(); } Is this good or bad? Yes.
7
Infinite Loops Programs we want to halt: Programs we want to run forever: Your 2150 Homework
8
Turing Machine Outcomes 1.Running TM M on input w eventually leads to q accept. Result: Accept 2.Running TM M on input w eventually leads to q reject. Result: Reject 3.Running TM M on input w runs forever (never terminates). Result: Reject
9
Recognizing vs. Deciding Turing-recognizable: A language L is “Turing-recognizable” if there exists a TM M such that for all strings w: If w L eventually M enters q accept If w L either M enters q reject or M never terminates Turing-decidable: A language L is “decidable” if there exists a TM M such that for all strings w: If w L, M enters q accept. If w L, M enters q reject.
10
Turing -Recognizable vs. -Decidable Def: A language is Turing-decidable iff it is exactly the set of strings accepted by some always-halting TM. w Σ * = abaaabbabbaaaaababaabbbaababbbabbbaaaa… M(w) √ √ √ √ … L(M) ={ a,aa,aaa,aaaa…} w→ Input √ Accept & halt Reject & halt Never runs forever Note: M must always halt on every input.
11
Turing -Recognizable vs. -Decidable Def: A language is Turing-recognizable iff it is exactly the set of strings accepted by some Turing machine. w Σ * = abaaabbabbaaaaababaabbbaababbbabbbaaaa… M(w) √ √∞ ∞√∞∞ ∞ √ … L(M) ={ a,aa,aaa,aaaa…} ≡ w→ Input √ Accept & halt Reject & halt ∞ Run forever Note: M can run forever on an input, which is implicitly a reject (since it is not an accept).
12
Famous Deciders “I'm the decider, and I decide what is best.” “A wrong decision is better than indecision.”
13
Famous Deciders
14
Recognizable Languages Revised Hierarchy Decidable Languages Regular Languages CFLs finite Languages Deterministic CFLs
15
Here we have some helpful modifications to Turing Machines Does not change language class Helpful for describing machines Turing Machine “Enhancements”
16
Larger alphabet: old: Σ={0,1} new: Σ’ ={a,b,c,d} Idea: Encode larger alphabet using smaller one. Encoding example: a=00, b=01, c=10, d=11 Turing Machine “Enhancements” badca old: δ b 01 new: δ' 0100111000
17
Double-sided infinite tape: Turing Machine “Enhancements” Idea: Fold into a normal single-sided infinite tape 001 101 1 101001 1 001 101 1 old: δ L/R new: δ' L/RR/L
18
b Multiple heads: Turing Machine “Enhancements” Idea: Mark heads locations on tape and simulate Modified δ ' processes each “virtual” head independently: Each move of δ is simulated by a long scan & update δ ' updates & marks all “virtual” head positions bbbaaa ba bbbaaabab baB B A A bB BAb
19
Multiple tapes: Turing Machine “Enhancements” Idea: Interlace multiple tapes into a single tape 10110 010 1 1 11100 1 0 10110 010 1 1 11100 1 0 Modified δ ' processes each “virtual” tape independently: Each move of δ is simulated by a long scan & update δ ' updates R/W head positions on all “virtual tapes”
20
Two-dimensional tape: Turing Machine “Enhancements” Idea: Flatten 2-D tape into a 1-D tape 1011011010010111 0 Modified 1-D δ ' simulates the original 2-D δ: Left/right δ moves: δ ' moves horizontally Up/down δ moves: δ ' jumps between tape sections $$$1011011010010111 0 This is how compilers implement 2D arrays!
21
Non-determinism: Turing Machine “Enhancements” Idea: Parallel-simulate non-deterministic threads Modified deterministic δ ' simulates the original ND δ: Each ND move by δ spawns another independent “thread” All current threads are simulated “in parallel” 111101 $$ $ 11001 1101101101101 1 1100111 111101
22
Turing Machine “Enhancements” Theorem: Combinations of “enhancements” do not increase the power of Turing machines. Combinations: Idea: “Enhancements” are independent (and commutative with respect to preserving the language recognized). 9.14513 Wol!dr Heoll Παωνλτ 3 ND
23
Theorem: The decidable langs are closed under complement. Modify the machine to exchange the accept state for reject state. Closure Properties of Decidable Languages A string w is in the language of Turing Machine T if δ*(ε, q 0, w) = (u,, v) A string w is not in the language of Turing Machine T if δ*(ε, q 0, w) = (u,, v) q accept q reject
24
Theorem: The decidable languages are closed under union. 1.Copy input 2.Run machine 1 on copy of input (never cross $) 1.If accept then move into accept state 3.Erase everything to right of $ 4.Run machine 2 Closure Properties of Decidable Languages abba$abba input copy M1 M2
25
Theorem: The decidable languages are closed under . 1.Copy input 2.Run machine 1 on copy of input (never cross $) 1.If reject then move into reject state 3.Erase everything to right of $ 4.Run machine 2 Closure Properties of Decidable Languages abba$abba input copy M1 M2
26
Theorem: The decidable langs are closed under concatenation. Use a 3-tape machine: Tape 1: save input remember factor attempts Tape 2: tape for Machine 1 Tape 3: tape for Machine 2 Closure Properties of Decidable Languages abba$0 indexinput a abba 1 bba
27
Closure Properties of Decidable Languages Theorem: The decidable langs are closed under Kleene star. Similar to concatenation, but now we also try all possible numbers of concatenations. Tape 1: abba$0$ index input Number of concatenations
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.