130 likes | 143 Views
Computing with Turing Machines. Section 4.2 Mon, Nov 29, 2004. Function Evaluators. A Turing Machine may be viewed as a function evaluator. Let 0 – { , }. Let w 0 * . The initial configuration is ( s , w ).
E N D
Computing with Turing Machines Section 4.2 Mon, Nov 29, 2004
Function Evaluators • A Turing Machine may be viewed as a function evaluator. • Let 0 – {, }. • Let w0*. • The initial configuration is (s, w). • When the Turing Machine halts, the configuration is (s, y), for some y 0*. • Then we write M(w) = y and say that Mcomputes a function f : 0*0* if M(w) = f(w) for all w0*.
Recursive Functions • A function is called recursive if it can be computed by a Turing Machine. • This is not the same as a recursive function in C++.
Examples • The TM INCR computes the function f(n) = n + 1. • The TM DECR computes the function f(n) = n – 1, if n > 0 and f(0) = 0. • Design a TM that computes the function f(n) = 2n. • Design a TM that computes the fucntion f(n) = 2n + 1. • Design a TM that computes the function f(w) = wwR.
Language Acceptors • A Turing Machine may be viewed as a language acceptor. • Let 0 – {, }. • Let w0*. • The initial configuration is (s, w). • H = {y, n}. • If the final state is y (“yes”), then the input is accepted. • If the final state is n (“no”), then the input is rejected.
Recursive Languages • Let L be a language. • A Turing Machine M decides L if it has the following property. • If w L, then M accepts w. • If wL, then M rejects w. • A language is decidable, or recursive, if there is a Turing Machine that decides it.
Example • Let 0 = {a, b, c}. • Let L = {anbncn | n 0}. • The Turing Machine in Programming Assignment #3 will decide this language.
Recursively Enumerable Languages • Let L 0* be a language. • A Turing Machine MsemidecidesL if • For every w0*, M halts on w if and only if wL. • A language is recursively enumerable if there is a Turing Machine that semidecides it.
Example • Let 0 = {a, b}. • Let L = {w* | w contains at least one a}. • The Turing Machine Ra will semidecide L.
Recursive and Recursively Enumerable Languages • Theorem: If L is recursive, then L is recursive enumerable. • Theorem: If L is recursive, then L′ is recursive. • Theorem: If L and L′ are recursively enumerable, then L is recursive.
Language Generators • A Turing Machine may be viewed as a language generator. • The initial configuration is (s, ). • The Turing Machine writes a sequence of words on the tape, separated by blanks. • The Turing Machine runs forever (if the language is infinite). • Each word in the language appears exactly once on the tape.
0 COPY INCR Example • Design a Turing Machine that generates the binary representations of the set of nonnegative integers.
0 COPY SUCC Example • Let = {0, 1}. • Design a TM SUCC to produce the lexicographical successor of the input string w *. • This is similar to INCR except that, e.g., the successor of 111 is 0000.