Overview CS20a: Turing Machines (Oct 29, 2002) • So far: – DFA = regular languages – PDA = context-free languages • Today: – Computability U S T T I T E O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 1 F I L O L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Handicapped machines • DFA limitations – Tape head moves only one direction • 2-way DFA has equivalent power – Tape is read-only – Tape length is a constant • PDA limitations – Tape head moves only one direction • 2-way PDA has a little more power (can accept { ww | w in Sigma* }, which is not context free) – Tape is read-only, but stack is writable – Stack has only LIFO (last-in, first-out) access – Tape length is constant, but stack is not bounded • What about: – Writable, 2-way tape? – Random-access “stack?” T U T E T S I O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 2 F I O L L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Computability • Computible – Equivalence of DFAs (we gave an algorithm) – String membership in a regular language (gave an algorithm) – Determining valid executions of a PDA (there is an algorithm) • Uncomputible – Equivalence of CFGs – Emptiness of the complement of a CFL (emptiness of CFL is computible) – Whether a C program ever terminates – How to prove it? T U T E S T I O F I N T E A C I N H N Computation, Computers, and Programs Course Introduction R O O 3 F L I I L O A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences
Overview Turing machines Infinite read-write tape 1. In state q a. read a symbol c Blanks b. print a new symbol c' b b b 0 1 1 0 0 c. move the tape head one position left or right Tape head d. goto state delta(q, c) 2. Accept iff the TM ever enters Finite a final state Control U T S T I T E O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 4 I F O L L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Turing machine formal definition A Turing Machine is a 7-tuple M = (Q, Σ , Γ , δ, s, b, F) • Q is a finite set of states , • Γ is a finite set of tape symbols , • b ∈ Γ is the blank symbol, • Σ ⊆ Γ − { b } is the set of input symbols , • δ : Q × Γ → Q × Γ × { L, R } is a partial transition function , • s ∈ Q is the start state , • F ⊆ Q is the set of final states T U T E S T I O F N T A I E C I H N N Computation, Computers, and Programs Course Introduction R O O I 5 I F O L L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Nontermination A TM that does not terminate M = (Q, Σ , Γ , δ, s, b, F) • Q = { q 0 , q 1 } • Σ = { a } • Γ = { a, b } • δ(q 0 , a) = (q 0 , a, R) • s = q 0 • F = {} T U T E T S I O F I N T E A C I N H N Computation, Computers, and Programs Course Introduction O R O 6 F L I L I O A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences
Overview Nontermination execution 0 1 1 0 0 b b b q0 a 1 1 0 0 b b b q0 a a a a a b b b q0 a a a a a a b b q0 U T S T I T E O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 7 F I L O L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Termination A partial function U → V is a function that may not be defined for every argument u ∈ U • A TM that accepts Σ ∗ • Q = { q 0 } • Γ = Σ ∪ { b } • δ(q 0 , c) is arbitrary (possibly not defined) • s = q 0 • F = { q 0 } T U T E S T I O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 8 F I O L L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Termination execution 0 1 1 0 0 b b b q0 in F T U T E T S I O F I N T E A C I N H N Computation, Computers, and Programs Course Introduction O R O 9 F L I L I O A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences
Overview Instantaneous descriptions • An instantaneous description ID ( σ ) is α 1 qα 2 , where – q is the current state of the TM, – α 1 α 2 ∈ Γ ∗ if the contents of the tape (to the last non-blank symbol) – The current symbol is the first symbol of α 2 U S T T I T E O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 10 I F L O L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Transitions • Define a left transition a 1 . . . a i − 1 q a i , . . . , a n → L a 1 , . . . , a i − 2 pc a i . . . a n • Define a right transition a 1 . . . a i − 1 q a i , . . . , a n → R a 1 , . . . , a i − 1 cp a i + 1 . . . a n • A transition → is either → L or → R T U T E T S I O F N T I A E C I H N N Computation, Computers, and Programs Course Introduction R O O I 11 I F L O L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Executions • An execution is either: – A finite sequence σ 1 σ 2 · · · σ n – An infinite sequence σ 1 σ 2 · · · • where σ i → σ i + 1 T U T E S T I O F I N T E A C I N H N Computation, Computers, and Programs Course Introduction O R O 12 F L I L I O A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences
Overview Acceptance condition • Let x ∈ Σ ∗ , and M = (Q, Σ , Γ , δ, q 0 , b, F) • M accepts x iff – q 0 x → ∗ α 1 pα 2 – p ∈ F – α 1 α 2 ∈ Γ ∗ U S T I T T E O F N T A I E C I H N N Computation, Computers, and Programs Course Introduction R O O I 13 F I L O L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Definitions • The languages accepted by TM are called recur- sively enumerable (r.e.) – Recursion is related to recursion in programs, – Enumerable means there is some TM that can enumerate the strings in the language (we'll see why) • A language is recursive if it is accepted by some TM that halts on all inputs • WLOG, we'll usually assume that TM halt if they enter a final state T U T E S T I O F N T A I E C I H N N Computation, Computers, and Programs Course Introduction R O O I 14 F I O L L A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Multi-tape machines 0 0 1 0 b b b b Σ 3 b b 1 1 1 0 0 1 b b b b 0 1 0 0 Finite Control T U T E T S I O F I N E T A C I N H N Computation, Computers, and Programs Course Introduction O R O 15 F L I L I O A G http://www.cs.caltech.edu/courses/cs20/a/ October 29, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences
Recommend
More recommend