Automata and Formal Languages - CM0081 Turing Machines Andrés Sicard-Ramírez EAFIT University Semester 2017-1
Turing Machines Alan Mathison Turing (1912 1954) Automata and Formal Languages - CM0081. Turing Machines 2/43
Turing Machines (TM) Unbounded tape divided into discrete squares which contain symbols from a finite alphabet Automata and Formal Languages - CM0081. Turing Machines 3/43
Turing Machines (TM) Unbounded tape divided into discrete squares which contain symbols from a finite alphabet Read/Write head Automata and Formal Languages - CM0081. Turing Machines 4/43
Turing Machines (TM) Unbounded tape divided into discrete squares which contain symbols from a finite alphabet Read/Write head Finite set of instructions (transition function) Automata and Formal Languages - CM0081. Turing Machines 5/43
Turing Machines (TM) Unbounded tape divided into discrete squares which contain symbols from a finite alphabet Read/Write head Finite set of instructions (transition function) Move of a TM (tape symbol under the head, current state): change state, rewrite the symbol and move the head one square Automata and Formal Languages - CM0081. Turing Machines 6/43
Turing Machines A Turing machine is a 7-tuple M = (Q, Σ, Γ, δ, q 0, B, F ) where Q: A finite set of states Σ: An alphabet of input symbols Γ: An alphabet of tape symbols (Σ Γ) δ Q Γ Q Γ D: A transition (partial) function where D = {L, R} is the set of moves q 0 Q: A start state B: The blank symbol (B Γ, B Σ) F Q: A set of final or accepting states Automata and Formal Languages - CM0081. Turing Machines 7/43
Transition Diagrams for Turing Machines Example start Y /Y 0/0 Y /Y 0/0 q 0 0/X 1/Y q 1 q 2 Y /Y X/X Y /Y B/B q 3 q 4 where Σ = {0, 1} and Γ = {0, 1, X, Y, B}. Automata and Formal Languages - CM0081. Turing Machines 8/43
Transition Tables for Turing Machines Example The machine of the previous example is given by M = ({q 0, q 1, q 2.q 3, q 4 }, {0, 1}, {0, 1, X, Y, B}, δ, q 0, B, {q 4 }) where δ is given by state 0 1 X Y B q 0 (q 1, X, R) (q 3, Y, R) q 1 (q 1, 0, R) (q 2, Y, L) (q 1, Y, R) q 2 (q 2, 0, L) (q 0, X, R) (q 2, Y, L) q 3 (q 3, Y, R) (q 4, B, R) q 4 Automata and Formal Languages - CM0081. Turing Machines 9/43
Quintuples for Turing Machines Example The machine of the previous example is given by M = ({q 0, q 1, q 2.q 3, q 4 }, {0, 1}, {0, 1, X, Y, B}, δ, q 0, B, {q 4 }), where δ is given by q 0, 0, X, R, q 1 q 0, Y, Y, R, q 3 q 1, 0, 0, R, q 1 q 1, 1, Y, L, q 2 q 1, Y, Y, R, q 1 q 2, 0, 0, L, q 2 q 2, X, X, R, q 0 q 2, Y, Y, L, q 2 q 3, Y, Y, R, q 3 q 3, B, B, R, q 4 Automata and Formal Languages - CM0081. Turing Machines 10/43
Instantaneous Descriptions for Turing Machines Definition (Instantaneous descriptions) An instantaneous description of a TM is a string where 1. q is the state of the TM, X 1 X 2 X i 1 qx i X i+1 X n 2. the head is scanning the i-th symbol from the left and 3. X 1 X 2 X n is the portion of the tape between the leftmost and rightmost non-blank. Automata and Formal Languages - CM0081. Turing Machines 11/43
Instantaneous Descriptions for Turing Machines Notation : Move of the TM M from an instantaneous descriptions to another. M M : Zero o more moves of the TM M. Automata and Formal Languages - CM0081. Turing Machines 12/43
Instantaneous Descriptions for Turing Machines Example 0 0 1 q 0 X 0 1 q 0 001 M Xq 1 01 M X0q 2 1 q 1 q 0 001 M X0q 2 1 X 0 1 q 2 Automata and Formal Languages - CM0081. Turing Machines 13/43
Recursively Enumerable Languages Definition (Language accepted by a TM) Let M = (Q, Σ, Γ, δ, q 0, B, F ) be a TM. The language accepted by M is L(M) = {w Σ q 0 w αpβ}, M where p F and α, β Γ. Automata and Formal Languages - CM0081. Turing Machines 14/43
Recursively Enumerable Languages Definition (Language accepted by a TM) Let M = (Q, Σ, Γ, δ, q 0, B, F ) be a TM. The language accepted by M is L(M) = {w Σ q 0 w αpβ}, M where p F and α, β Γ. Definition (Recursively enumerable language) A language L is recursively enumerable if exists a TM M such L = L(M). Automata and Formal Languages - CM0081. Turing Machines 15/43
Recursively Enumerable Languages Example Let M be the machine described by the previous diagram. Then L(M) = {0 n 1 n n 1}. See the simulation in the course website. Automata and Formal Languages - CM0081. Turing Machines 16/43
Recursive Languages Convention We assume that a TM halts if it accepts. Automata and Formal Languages - CM0081. Turing Machines 17/43
Recursive Languages Convention We assume that a TM halts if it accepts. What about if the TM does not accept? Automata and Formal Languages - CM0081. Turing Machines 18/43
Recursive Languages Convention We assume that a TM halts if it accepts. What about if the TM does not accept? Definition (Recursively enumerable (RE) language) A language L is RE if exists a TM M such that L = L(M). Definition (Recursive language) A language L is recursive if exists a TM M such that 1. L = L(M) and 2. M always halt (even if it does not accept) Automata and Formal Languages - CM0081. Turing Machines 19/43
Turing Machine Computable Functions Number-theoretical functions {f f N k N} Automata and Formal Languages - CM0081. Turing Machines 20/43
Turing Machine Computable Functions Number-theoretical functions {f f N k N} Codification n = 0 n = 0 0 n times (n 1, n 2,, n k ) = n 1 1 n 2 1 1 n k for n N for (n 1, n 2,, n k ) N k Automata and Formal Languages - CM0081. Turing Machines 21/43
Turing Machine Computable Functions Definition (Turing machine computable function) A function f N N is Turing machine computable iff exists a machine M = (Q, {0, 1}, Γ, δ, q 0, B) (there are not accepting states) such that for all n N: From the initial instantaneous description q 0 n the machine halts with f(n) on its tape, surrounded by blanks. Automata and Formal Languages - CM0081. Turing Machines 22/43
Turing Machine Computable Functions Definition (Turing machine computable function) A function f N N is Turing machine computable iff exists a machine M = (Q, {0, 1}, Γ, δ, q 0, B) (there are not accepting states) such that for all n N: From the initial instantaneous description q 0 n the machine halts with f(n) on its tape, surrounded by blanks. Remark: The definition extends to functions f N k N. Automata and Formal Languages - CM0081. Turing Machines 23/43
Turing Machine Computable Functions Example The proper subtraction function is Turing machine computable. m n m n = { Initial instantaneous description: q 0 0 m 10 n Final information on the tape: 0 m n if m n, 0 otherwise. See the simulation in the course homepage. Automata and Formal Languages - CM0081. Turing Machines 24/43
Equivalence between Function Computation and Language Recognition Example (Hopcroft, Motwani and Ullman [2007], Exercise 8.2.4) Define the graph of a function f N N to be the set of all strings of the form [ x, f(x)]. Automata and Formal Languages - CM0081. Turing Machines 25/43
Equivalence between Function Computation and Language Recognition Example (Hopcroft, Motwani and Ullman [2007], Exercise 8.2.4) Define the graph of a function f N N to be the set of all strings of the form [ x, f(x)]. A Turing machine is said to compute the function f N N if, started with x on its tape, it halts (in any state) with f(x) on its tape. Automata and Formal Languages - CM0081. Turing Machines 26/43
Equivalence between Function Computation and Language Recognition Example (Hopcroft, Motwani and Ullman [2007], Exercise 8.2.4) Define the graph of a function f N N to be the set of all strings of the form [ x, f(x)]. A Turing machine is said to compute the function f N N if, started with x on its tape, it halts (in any state) with f(x) on its tape. Answer the following, with informal, but clear constructions. Automata and Formal Languages - CM0081. Turing Machines 27/43
Equivalence between Function Computation and Language Recognition Example (cont.) 1. Show how, given a TM that computes f, you can construct a TM that accepts the graph of f as a language. Automata and Formal Languages - CM0081. Turing Machines 28/43
Equivalence between Function Computation and Language Recognition Example (cont.) 1. Show how, given a TM that computes f, you can construct a TM that accepts the graph of f as a language. 2. Show how, given a TM that accepts the graph of f, you can construct a TM that computes f. Automata and Formal Languages - CM0081. Turing Machines 29/43
Equivalence between Function Computation and Language Recognition Example (cont.) 1. Show how, given a TM that computes f, you can construct a TM that accepts the graph of f as a language. 2. Show how, given a TM that accepts the graph of f, you can construct a TM that computes f. 3. A function is said to partial if it may be undefined for some arguments. If we extend the ideas of this exercise to partial functions, then we do not require that the TM computing f halts if its input x is one of the natural numbers for which f(x) is not defined. Automata and Formal Languages - CM0081. Turing Machines 30/43
Equivalence between Function Computation and Language Recognition Example (cont.) 1. Show how, given a TM that computes f, you can construct a TM that accepts the graph of f as a language. 2. Show how, given a TM that accepts the graph of f, you can construct a TM that computes f. 3. A function is said to partial if it may be undefined for some arguments. If we extend the ideas of this exercise to partial functions, then we do not require that the TM computing f halts if its input x is one of the natural numbers for which f(x) is not defined. Do your constructions for parts (1) and (2) work if the function f is partial? If not, explain how you could modify the constructions to make it work. Automata and Formal Languages - CM0081. Turing Machines 31/43
Restrictions to the Turing Machines Automata and Formal Languages - CM0081. Turing Machines 32/43
Restrictions to the Turing Machines Restrictions Turing machines with semi-unbounded tapes Automata and Formal Languages - CM0081. Turing Machines 33/43
Restrictions to the Turing Machines Restrictions Turing machines with semi-unbounded tapes Multi-stack machines Automata and Formal Languages - CM0081. Turing Machines 34/43
Restrictions to the Turing Machines Restrictions Turing machines with semi-unbounded tapes Multi-stack machines Theorem The previous restrictions are equivalents to the Turing machines. Automata and Formal Languages - CM0081. Turing Machines 35/43
Extensions to the Turing Machines Automata and Formal Languages - CM0081. Turing Machines 36/43
Extensions to the Turing Machines Extensions Multi-tape Turing machines Automata and Formal Languages - CM0081. Turing Machines 37/43
Extensions to the Turing Machines Extensions Multi-tape Turing machines Mutil-dimensional tape Turing machines Automata and Formal Languages - CM0081. Turing Machines 38/43
Extensions to the Turing Machines Extensions Multi-tape Turing machines Mutil-dimensional tape Turing machines Multi-head Turing machines Automata and Formal Languages - CM0081. Turing Machines 39/43
Extensions to the Turing Machines Extensions Multi-tape Turing machines Mutil-dimensional tape Turing machines Multi-head Turing machines Non-deterministic Turing machines Automata and Formal Languages - CM0081. Turing Machines 40/43
Extensions to the Turing Machines Extensions Multi-tape Turing machines Mutil-dimensional tape Turing machines Multi-head Turing machines Non-deterministic Turing machines Subroutines Automata and Formal Languages - CM0081. Turing Machines 41/43
Extensions to the Turing Machines Extensions Multi-tape Turing machines Mutil-dimensional tape Turing machines Multi-head Turing machines Non-deterministic Turing machines Subroutines Theorem The previous extensions are equivalents to the Turing machines. Automata and Formal Languages - CM0081. Turing Machines 42/43
References Hopcroft, J. E., Motwani, R. and Ullman, J. D. (2007). Introduction to Automata theory, Languages, and Computation. 3rd ed. Pearson Education. Automata and Formal Languages - CM0081. Turing Machines 43/43