Turing machine. Turing Machine Model. Turing Machines. 1. Turing Machines. Wolfgang Schreiner 2. Recognizing Languages

Similar documents
Turing Machines. Wolfgang Schreiner

Limits of Computability

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

Most General computer?

Computability Theory. CS215, Lecture 6,

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Decidability (What, stuff is unsolvable?)

CS20a: Turing Machines (Oct 29, 2002)

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS20a: Turing Machines (Oct 29, 2002)

Turing machines and linear bounded automata

Introduction to Turing Machines. Reading: Chapters 8 & 9

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Chapter 6: Turing Machines

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

Decidability: Church-Turing Thesis

Part I: Definitions and Properties

Turing Machines Part II

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Chapter 8. Turing Machine (TMs)

Introduction to Turing Machines

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

Further discussion of Turing machines

V Honors Theory of Computation

1 Showing Recognizability

Turing machines and linear bounded automata

CSCE 551: Chin-Tser Huang. University of South Carolina

Turing Machines (TM) The Turing machine is the ultimate model of computation.

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Lecture 13: Turing Machine

CS21 Decidability and Tractability

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Computable Functions

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

Turing machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage?

Chapter 7 Turing Machines

Turing Machines. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

DM17. Beregnelighed. Jacob Aae Mikkelsen

Turing Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA

CPSC 421: Tutorial #1

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models

Turing Machines. Lecture 8

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

Turing Machines. Chapter 17

Decidability. William Chan

Turing machines and linear bounded automata

Busch Complexity Lectures: Turing s Thesis. Costas Busch - LSU 1

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CSE 105 THEORY OF COMPUTATION

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

Section 14.1 Computability then else

The Church-Turing Thesis

SE 3310b Theoretical Foundations of Software Engineering. Turing Machines. Aleksander Essex

CSci 311, Models of Computation Chapter 9 Turing Machines

ACS2: Decidability Decidability

Turing Machine Recap

The Turing machine model of computation

Decidability and Undecidability

TURING MAHINES

Chapter 3: The Church-Turing Thesis

CSCE 551 Final Exam, Spring 2004 Answer Key

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Homework 8. a b b a b a b. two-way, read/write

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

COMPARATIVE ANALYSIS ON TURING MACHINE AND QUANTUM TURING MACHINE

There are two main techniques for showing that problems are undecidable: diagonalization and reduction

Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem

Decidability (intro.)

Chapter 2 Algorithms and Computation

Equivalent Variations of Turing Machines

highlights proof by contradiction what about the real numbers?

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Turing Machines Part III

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

Theory of Computing Tamás Herendi

Theory of Computation (IX) Yijia Chen Fudan University

Variants of Turing Machine (intro)

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSCI3390-Assignment 2 Solutions

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

CSE 105 THEORY OF COMPUTATION

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Lecture 14: Recursive Languages

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Transcription:

Turing achines Wolfgang Schreiner Wolfgang.Schreiner@risc.jku.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.jku.at 1. Turing achines Wolfgang Schreiner http://www.risc.jku.at 1/28 Wolfgang Schreiner http://www.risc.jku.at 2/28 Turing achine odel Turing achines Turing machine tape sequence accepted The machine is always in one of a finite set of states. The machine starts its execution in a fixed start state. An infinite tape holds at its beginning the input word. Tape is read and written and arbitrarily moved by the machine. The machine proceeds in a sequence of state transitions. achine reads symbol, overwrites it, and moves tape head left or right. The symbol read and the current state determine the symbol written, the move direction, and the next state. If the machine cant make ather transition, it terminates. The machine signals whether it is in an accepting state. If the machine terminates in an accepting state, the word is accepted. Wolfgang Schreiner http://www.risc.jku.at 3/28 Turing achine = (Q,Γ,,Σ,δ,q,F ): The state set Q, a fine set of states. A tape alphabet Γ, a finite set of tape symbols. The blank symbol Γ. An input alphabet Σ Γ\{}. The (partial) transition function δ : Q Γ p Q Γ { L, R }, δ(q,x) = (q,x, L / R )... reads in state q symbol x, goes to state q, writes symbol x, and moves the tape head left/right. The start state q Q A set of accepting states (final states) F Q. The crucial difference to an automaton is the infinite tape that can be arbitrarily moved and written. Wolfgang Schreiner http://www.risc.jku.at 4/28

Example Turing achine Simulator = (Q,Γ,,Σ,δ,q,F ) Q = {q,q 1,q 2,q 3,q 4 } Γ = {,,1,X,Y } Σ = {,1} F = {q 4 } q Y,Y q 1 q 3 Y X 1 http://math.hws.edu/eck/js/turing-machine/t.html,y q 2 q 4 δ 1 X Y q (q 1,X,R) (q 3,Y,R) q 1 (q 1,,R) (q 2,Y,L) (q 1,Y,R) q 2 (q 2,,L) (q,x,r) (q 2,Y,L) q 3 (q 4,,R) (q 3,Y,R) q 4 achine accepts every word of form n 1 n (replacing it by X n Y n ). Wolfgang Schreiner http://www.risc.jku.at 5/28 Wolfgang Schreiner http://www.risc.jku.at 6/28 Generalized Turing achines Infinite tape in both directions. Can be simulated by a machine whose tape is infinite in one direction. ultiple tapes. Can be simulated by a machine with a single tape. Nondeterministic transitions. We can simulate a ndeterministic by a deterministic. Let r be the maximum number of choices that can make. operates with 3 tapes. Tape 1 holds the input (tape is only read). writes to tape 2 all finite sequences of numbers 1,...,r. First all sequences of length 1, then all of length 2, etc. After writing sequence s 1 s 2...s n to tape 2, simulates on tape 3. copies the input to tape 3 and performs at most n transitions. In transition i, attempts to perform choice s i. If choice i is t possible or terminates after n transitions in a n-accepting state, continues with next sequence. If terminates in accepting state, accepts the input. Every generalized Turing machine can be simulated by the core form. Wolfgang Schreiner http://www.risc.jku.at 7/28 1. Turing achines Wolfgang Schreiner http://www.risc.jku.at 8/28

Turing achine Configurations Configuration a 1...a k q a k+1...a m : q: the current state of. a k+1 : the symbol currently under the tape head. a 1...a k : the portion of the tape left to the tape head. a k+2...a m : the portion right to the head (followed by...). ove relation: a 1...a k q a k+1...a m b 1...b l p b l+1...b m If is a situation described by the left configuration, it can make a transition to the situation described by the right configuration. a i = b i for all i k + 1 and one of the following: l = k + 1 and δ(q,a k+1 ) = (p,b l,r), l = k 1 and δ(q,a k+1 ) = (p,b l+2,l). Extended move relation: c 1 c 2 can make in an arbitrary number of moves a transition from the situation described by configuration c 1 to the one described by c 2. c 1 c 2 : c 1 = c 2 c 1 i+1 c 2 : c : c 1 i c c c 2 c 1 c 2 : i N : c 1 i c 2 Wolfgang Schreiner http://www.risc.jku.at 9/28 The Language of a Turing achine The language L() of Turing machine = (Q,Γ,,Σ,δ,q,F ): The set of all inputs that drive from its initial configuration to a configuration with an accepting state such that from this configuration further move is possible: L() := { w Σ a,b Γ,q Q : q w a q b q F a,b Γ,q Q : a q b a q b L is a recursively enumerable language: There exists a Turing machine such that L = L(). L is a recursive language: There exists a Turing machine such that L = L() and terminates for every possible input. Every recursive language is recursively enumerable; as we will see, the converse does t hold. Wolfgang Schreiner http://www.risc.jku.at 1/28 } Recursiv. Enumerable/Recursive Languages Theorem: L is recursive, if and only if both L and its complement L are recursively enumerable. Proof : Let L be a recursive. Since by definition L is recursively enumerable, it remains to be shown that also L is recursively enumerable. Since L is recursive, there exists a Turing machine such that halts for every input w: if w L, then accepts w; if w L, then does t accept w. With the help of, we can construct the following with L( ) = L: function (w): case (w) of : return : return end case Wolfgang Schreiner http://www.risc.jku.at 11/28 w Recursiv. Enumerable/Recursive Languages Proof : Let L be such that both L and L are recursively enumerable. We show that L is recursive. Since L is r.e., there exists such that L = L() and halts for w L with (w) =. Since L is r.e., there exists with L = L() and halts for w L with (w) =. We can thus construct with L( ) = L that always halts: function (w): parallel begin if (w) = then return loop forever end begin if (w) = then return loop forever end end parallel Wolfgang Schreiner http://www.risc.jku.at 12/28 w

Closure of Recursive Languages Let L,L 1,L 2 be recursive languages. Then also the complement L, the union L 1 L 2, the intersection L 1 L 2 are recursive languages. Proof by construction of the corresponding Turing machines. 1. Turing achines Wolfgang Schreiner http://www.risc.jku.at 13/28 Wolfgang Schreiner http://www.risc.jku.at 14/28 Enumerators Recognizing versus Generating Languages Turing machine = (Q,Γ,, /,δ,q,f ) with special symbol # Γ. is an enumerator, if has an additional output tape on which moves its tape head only to the right, and writes only symbols different from. The generated language Gen() of enumerator is the set of all words that eventually writes on its output tape. The end of each word is marked by a trailing #. may run forever and thus Gen() may be infinite. Theorem: L is recursively enumerable, if and only if there exists some enumerator such that L = Gen(). Proof : Let L be recursively enumerable, i.e., L = L( ) for some. We construct enumerator such that L = Gen(). procedure : loop produce next (m,n) on working tape if (w m ) = in at most n steps then write w m to output tape end loop end procedure (,),(1,),(1,1),(2,),... (m,n) w m n write w m w m Wolfgang Schreiner http://www.risc.jku.at 15/28 Wolfgang Schreiner http://www.risc.jku.at 16/28

Recognizing versus Generating Languages Proof : Let L be such that L = Gen() for some enumerator. We show that there exists some Turing machine such that L = L( ). 1. Turing achines function (w): while is t terminated do writes next word w if w = w then return end while return w w on tape? Recognizing is possible, if and only if generating is possible. Wolfgang Schreiner http://www.risc.jku.at 17/28 Wolfgang Schreiner http://www.risc.jku.at 18/28 Functions Functions Take binary relation f A B. f : A B: f is a total function from A to B. For every a A, there is exactly one b B such that (a,b) f. f : A p B: f is a partial function from A to B. For every a A, there is at most one b B such that (a,b) f. Auxiliary tions: domain(f ) := {a b : (a,b) f } range(f ) := {b a : (a,b) f } f (a) := such b : (a,b) f Every total function f : A B is a partial function f : A p B; every partial function f : A p B is a total function f : domain(f ) B. Wolfgang Schreiner http://www.risc.jku.at 19/28 Let f : Σ p Γ where Σ Γ. f is a function over words in some alphabets. f is Turing computable, if there exists a Turing machine such that for input w (i.e. initial tape content w...), terminates in an accepting state, if and only if w domain(f ); for input w, terminates in an accepting state with output w (i.e. final tape content w...), if and only if w = f (w). Not every function f : Σ p Γ is Turing computable: The set of all Turing machines is countably infinite: all machines can be ordered in a single list (in the alphabetic order of their definitions). The set of all functions Σ p Γ is more than countably infinite (Cantor s diagonalization argument). Consequently, there are more functions than Turing machines. computes f, if terminates for arguments in the domain of f with output f (a) and does t terminate for arguments outside the domain. Wolfgang Schreiner http://www.risc.jku.at 2/28

Example Example (Contd) We show that natural number subtraction is Turing computable. Subtraction on N: = (Q,Γ,,Σ,δ,q,F ) Q = {q,...,q 6 } Σ = {},Γ = {,1,},F = {q 6 } q m n := Unary representation of n N: { m n if m n else... }{{} n times Input shall lead to output. 2 1 = 1. L( ) Idea: replace every pair of in m and n by. Wolfgang Schreiner http://www.risc.jku.at 21/28 δ 1 q (q 1,,R) (q 5,,R) (q 5,,R) q 1 (q 1,,R) (q 2,1,R) (q 2,1,R) q 2 (q 3,1,L) (q 2,1,R) (q 4,,L) q 3 (q 3,,L) (q 3,1,L) (q,,r) q 4 (q 4,,L) (q 4,,L) (q 6,,R) q 5 (q 5,,R) (q 5,,R) (q 6,,R) q 6 q 1 q 2 1, 1 q 3,1 q 4 q 5,1 In q, the leading is replaced by. In q 1, searches for the next and replaces it by a 1. In q 2, searches for the next and replaces it by 1, then moves left. In q 3, searches for previous, moves right and starts from begin. In q 4, has found a instead of and replaces all previous 1 by. In q 5, n is (has become) ; the rest of the tape is erased. In q 6, the computation successfully terminates. Wolfgang Schreiner http://www.risc.jku.at 22/28,1 1, q 6 Example (Contd) Turing Computability 2 1 = 1: q q 1 q 1 1q 2 q 3 11 q 3 11 q 3 11 q 11 q 1 11 1q 2 1 11q 2 1q 4 1 q 4 1 q 4 q 6 1 2 = : q q 1 1q 2 q 3 11 q 3 11 q 11 q 5 1 q 5 q 5 q 6. For m > n, leading blanks still have to be removed. Theorem: f : Σ p Γ is Turing computable, if and only if L f := {(a,b) Σ Γ a domain(f ) b = f (a)} is recursively enumerable. Proof : Since f : Σ p Γ is Turing computable, there exists a Turing machine which computes f. To show that L f is r.e., we construct with L( ) = L f : function (a,b): b (a) if b = b then return else return (a,b) b a b = Wolfgang Schreiner http://www.risc.jku.at 23/28 Wolfgang Schreiner http://www.risc.jku.at 24/28

Turing Computability Proof : Since L f is recursively enumerable, there exists an enumerator with Gen() = L f. We construct the following Turing machine which computes f : 1. Turing achines function (a): while is t terminated do writes (a,b ) to tape if a = a then return b end while loop forever a (a,.) on tape? (a, b) b Computing is possible, if and only if recognizing is possible. Wolfgang Schreiner http://www.risc.jku.at 25/28 Wolfgang Schreiner http://www.risc.jku.at 26/28 Algorithms The Church-Turing Thesis Computer science is based on algorithms. Compute as follows the greatest common divisor of two natural numbers m,n that are t both : 1. If m =, the result is n. 2. If n =, the result is m. 3. If m > n, subtract n from m and continue with step 1. 4. Otherwise subtract m from n and continue with step 1. Euklid( m, n, r) m n? ja ja m > n? nein m m n ja r n m =? n n m r m nein nein Euklid( m, n, r): while m n do if m > n then m m n else n n m if m = then r n else r m end Euklid. What is an algorithm and what is computable by an algorithm? Church-Turing Thesis: Every problem that is solvable by an algorithm (in an intuitive sense) is solvable by a Turing machine. Thus the set of intuitively computable functions is identical with the set of Turing computable functions. Replaces fuzzy tion algorithm by precise tion Turing machine. Unprovable thesis, exactly because the tion algorithm is fuzzy. Substantially validated, because many different computational models have more computational power than Turing machines. Random access machines, loop programs, recursive functions, goto programs, λ-calculus, rewriting systems, grammars,... Turing machines represent the most powerful computational model kwn, but there are many other equally powerful ( Turing complete ) models. Wolfgang Schreiner http://www.risc.jku.at 27/28 Wolfgang Schreiner http://www.risc.jku.at 28/28