Chapter 8. Turing Machine (TMs)

Similar documents
CS 410/610, MTH 410/610 Theoretical Foundations of Computing

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

1 Unrestricted Computation

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

Chapter 3: The Church-Turing Thesis

UNRESTRICTED GRAMMARS

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

Busch Complexity Lectures: Turing Machines. Prof. Busch - LSU 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Part I: Definitions and Properties

Most General computer?

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

Theory of Computation - Module 4

CSCC63 Worksheet Turing Machines

Computability Theory. CS215, Lecture 6,

CS4026 Formal Models of Computation

Automata Theory (2A) Young Won Lim 5/31/18

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

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

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

CS21 Decidability and Tractability

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

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

Theory of Computation Turing Machine and Pushdown Automata

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

Theory of Computation

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

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

Turing Machines Part II

Introduction to Turing Machines

ECS 120 Lesson 15 Turing Machines, Pt. 1

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

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

Chapter 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

Lecture 14: Recursive Languages

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

The Church-Turing Thesis

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

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

Chapter 6: Turing Machines

Finite Automata. Finite Automata

Turing Machines. Chapter 17

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Turing machines and linear bounded automata

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

Turing Machine properties. Turing Machines. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions

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

The Turing Machine. CSE 211 (Theory of Computation) The Turing Machine continued. Turing Machines

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

Computability and Complexity

Chapter 7 Turing Machines

Chapter 6. Properties of Regular Languages

Variants of Turing Machine (intro)

Variations of the Turing Machine

TURING MAHINES

Theory of Computation

CS 525 Proof of Theorems 3.13 and 3.15

Chapter 5. Finite Automata

Introduction to Turing Machines. Reading: Chapters 8 & 9

7.2 Turing Machines as Language Acceptors 7.3 Turing Machines that Compute Partial Functions

Automata Theory - Quiz II (Solutions)

SCHEME FOR INTERNAL ASSESSMENT TEST 3

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

CSE 460: Computabilty and Formal Languages Turing Machine (TM) S. Pramanik

A Universal Turing Machine

Turing machines and linear bounded automata

Further discussion of Turing machines

CPSC 421: Tutorial #1

Turing Machines. Lecture 8

1 Showing Recognizability

TAKE-HOME: OUT 02/21 NOON, DUE 02/25 NOON

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

Equivalent Variations of Turing Machines

Introduction to Formal Languages, Automata and Computability p.1/42

CSci 311, Models of Computation Chapter 9 Turing Machines

Lecture 12: Mapping Reductions

CSCE 551 Final Exam, Spring 2004 Answer Key

Turing Machines. Wolfgang Schreiner

DM17. Beregnelighed. Jacob Aae Mikkelsen

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

Computability THEORY OF COMPUTATION

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

A Lower Bound for Boolean Satisfiability on Turing Machines

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

CS154 Final Examination

Chap. 4 Computability

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Homework. Turing Machines. Announcements. Plan for today. Now our picture looks like. Languages

CSE 105 THEORY OF COMPUTATION

Turing s Thesis. Fall Costas Busch - RPI!1

Turing Machines Part III

Turing Machine Extensions, and Enumerators

Automata and Computability. Solutions to Exercises

Turing Machines Part II

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Decidability: Church-Turing Thesis

Foundations of

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

The Unsolvability of the Halting Problem. Chapter 19

Transcription:

Chapter 8 Turing Machine (TMs)

Turing Machines (TMs) Accepts the languages that can be generated by unrestricted (phrase-structured) grammars No computational machine (i.e., computational language recognition system) is more powerful than the class of TMs due to the language processing power, i.e., the generative power of grammars, its unlimited memory, and time of computations Proposed by Alan Turing in 1936 as a result of studying algorithmic processes by means of a computational model TMs are similar to FSAs since they both consist of i) a control mechanism, and ii) an input tape In addition, TMs can i) move their tape head back and forth, and ii) write on, as well as read from, their tapes. 2

Turing Machines Defn. 8.1.1 A TM is a quintuple M = (Q,,,, q 0 ), where Q is a finite set of states is a finite set called the tape alphabet which contains B, a special symbol that represents a blank - { B }, is the input alphabet : Q Q { L, R }, a transition function, which is a partial function q 0 Q, is the start state 3

Machine Operations: Turing Machines Write operation - replaces a symbol on the tape with another (not necessarily distant) symbol Move operation - moves the tape head one cell to the right (left, respectively) and then shift to a new (or current) state Halt operation - halts when the TM encounters a < state, input symbol > pair for which no transition is defined 4

Turing Machines Machine Operations. TMs are designed to perform computations on strings from the input alphabet Example 8.1.2. A TM produces a copy of input string over { a, b } with input BuB and terminates with tape BuBuB, where u (a b)* b/b R a/a b/b R a/a X/X R Y/Y R a/x R q 2 q 3 B/a L > q 0 X/a L Y/b L B/B L q 1 q 7 b/y R q 5 a/a R b/b R q 6 a/a R b/b R B/b L q 4 a/a L b/b L B/B L 5

Transitions of TMs: TMs uq i vb m xq j yb denotes that xq j yb is obtained from uq i vb by a single transition of M * uq i vb m xq j yb denotes that xq j yb is obtained from uq i vb by zero or more transitions of M. TMs as Language Acceptors TMs can be designed to accept languages besides computing functions, and accepting a string does not require the entire input string to be read. Defn. 8.2.1 Let M = (Q,,,, q 0, F) be a TM. A string u * is accepted by final state if the computation of M with input u halts in a final state. A computation that terminates abnormally rejects the input regardless of the state in which the machine halts. The language of M, L(M), is the set of all string accepted by M. A language accepted by a TM is called a recursively enumerable language. 6

Transitions of TMs Example 8.2.2. A TM that accepts the language { a i b i c i i 0 } is > q 0 q 1 Y/Y R q 5 Y/Y R Z/Z R a/x R X/X R a/a R Y/Y R q 2 b/y R q 6 b/b R Z/Z R q 3 q 4 c/z L Z/Z L b/b L Y/Y L a/a L 7

TMs Acceptance by Halting An input string S is accepted by TM M if the computation with S causes M to halt. M rejects S when M terminates abnormally or M never halts with S. A TM of which its acceptance is defined by halting (normally) is defined by the quintuple (Q,,,, q 0 ). Theorem 8.3.2 The following statements are equivalent: i) The language L is accepted by a TM that accepts by final state ii) The language L is accepted by a TM that accepts by halting Example 8.3.1 A TM that accepts (a b)*aa(a b)* by halting. b/b R > q 0 a/a R a/a R q 1 q 2 q 3 b/b R q e 8

Transitions of TMs Design a TM that computes the proper-subtraction function, i.e., m n = max(m - n, 0) such that m n is m - n, if m > n, and 0, if m n. The TM will start with a tape consisting 0 m 10 n surrounded by blanks, i.e., B0 m 10 n B. The machine halts with its result on its tape, surrounded by blanks. 9

8.7 Nondeterministic TMs (NTMs) Provide more than one applicable transition for some current state/input symbol pair, i.e., > 1 non- deterministic choice Formal Definition: A NTM M = (Q,,,, q 0 ) or M = (Q,,,, q 0, F), where Q,,,, q 0, and F are as defined in any DTMs and : Q 2Q {L, R} Example 8.7.1 A NTM that accepts strings containing a c, which is either preceded or followed by ab a/a R b/b R c/c R > q 0 q 1 c/c R q 2 a/a R q 3 b/b R q 4 c/c L q 5 b/b L q 6 a/a L q 7 10

8.7 Nondeterministic TMs (NTMs) Acceptance in NTMs can be defined by final state or by halting alone, similar to the DTMs Every NTM can be transformed into an equivalent DTM that accepts by halting, which is chosen because it reduces the number of computations from 3 to 2 The language accepted by NTMs are precisely those accepted by DTMs The converted can be done by using multiple (3-) tapes Multiple computations for a single input string are sequentially generated and examined A maximum number of transitions can be defined for any combination of <state, input symbol> 11

8.7 Nondeterministic TMs (NTMs) Example. Transforming the NTM in Example 8.7.1 into its DTM a/a R b/b R c/c R > q 0 q 1 c/c R q 2 a/a R q 3 b/b R q 4 c/c L q 5 b/b L q 6 a/a L q 7 12

Transitions of TMs Design a TM that takes as input a number N and adds 1 to it in binary. The tape initially contains a $ followed by N in binary. The tape head is initially scanning the $ in the initial state q 0. The TM should halt with N+1, in binary, on the tape, scanning the leftmost symbol of N+1 in the final state q f with $ removed. For instance, q 0 $10011 yields q f 10100, and q 0 $11111 yields q f 100000. 13

A K-tape TM 8.6 Multitape TMs consists of k tapes and k independent tape heads reads k tapes simultaneously, but has only one state is configured by the current tape symbol being pointed to by each tape head and the current state, e.g., Tape 3 Tape 2 Tape 1 q i A transition in a multitape TM may change the current state, (over)write a symbol on each tape, and independently reposition each of the tape heads 14

8.6 Multitape TMs A transition of a k-tape TM is defined as (q i, x 1, x 2,, x k ) = [q j ; y 1, d 1 ; y 2, d 2 ; ; y k, d k ] where q i, q j Q, x n, y n, and d n { L, R, S }, 1 n k. Initialize configuration: The input string is placed on tape 1, whereas all the other tapes are assumed to be blank to begin with. The tape heads scan the leftmost position of each tape. Any tape head attempts to move to the left of the leftmost position terminates the computation abnormally. A language accepted by a TM is a recursively enumerable language. A language that is accepted by a TM that halts for all input strings is said to be recursive. 15

8.6 Multitape TMs Example 8.6.2 The set { a k k is a perfect square } is a recursively enumerable language (and is also a recursive language). (i) Tape 3 - k Tape 2 k 2 Tape 1 - input a a a a a q 0 Tape 3-1 X Tape 2 1 2 X Tape 1 - input a a a a a Tape 1 holds the input string, a string of a s Tape 2 holds a string of X s whose length is a perfect square Tape 3 holds a string of X s whose length is S, where S is the string on Tape 2 Step 1: Since the input is not a null string, initialize tapes 2 and 3 with an X, and all the tape head move to Position 1 (ii) Tape 3-1 Tape 2 1 2 Tape 1 - input q 2 X X a a a a a q 2 Step 2: Move the heads of tapes 1 and 2 to the right, since they have scanned a nonblank square Accept: if both read a blank Reject: if tape head 1 reads a blank and tape head 2 reads an X 16

8.6 Multitape TMs Example 8.6.2 (Continued). Step 3: Reconfiguration for comparison (iii) X X Tape 3-2 Tape 2 2 2 Tape 1 - input X a a a a a q 1 (iv) X X Tape 3-2 Tape 2 2 2 Tape 1 - input X X X X X X X a a a a a with the next perfect square by - adding an X on tape 2 to yield k 2 +1 X s - appending two copies of the string on tape 3 to the end of the string on tape 2 to yield (k+1) 2 X s - adding an X on tape 3 to yield (k + 1) X s on tape 3 - moving all the tape heads to Position 1 Step 4: Repeat Steps 2 through 3. q 2 (v) Tape 3-3 Tape 2 3 2 X X X X X X X X X X X X Another iteration of Step 2 halts and rejects the input. Tape 1 - input a a a a a q 2 17

8.6 Multitape TMs Example 8.6.2 (Continued). The transition function of the TM that accepts { a k k is a perfect square }: [,, ] > q 0 q 1 [a/a S, B/X S, B/X S] q 2 [a/a R, X/X R, X/X S] [B/B S, B/B S, X/X S] q 3 [,, ] q 4 [a/a S, B/X R, X/X S] [a/a S, B/X R, X/X R] [a/a S, B/X R, X/X S] [a/a L, B/B L, B/X L] q 5 q 6 [a/a L, X/X L, X/X L], [a/a L, X/X L, B/B S], [a/a L, B/B S, B/B S], [B/B S, X/X L, B/B S] 18

8.6 Multitape TMs Example 8.6.2 (Continued). The transition function of the TM that accepts { a k k is a perfect square }: [Step 1] (q 0, B, B, B) = [q 1 ; B, R; B, R; B, R] (initialize the tape) (q 1, a, B, B) = [q 2 ; a, S; X, S; X, S] (q 1 is a final state) [Step 2] (q 2, a, X, X) = [q 2 ; a, R; X, R; X, S] (compare strings on tapes 1 and 2) (q 2, B, B, X) = [q 3 ; B, S; B, S; X, S] (accept; q 3 is a final state) (q 2, a, B, X) = [q 4 ; a, S; X, R; X, S] (add an X to tape 2 and re-compute) [Step 3] (q 4, a, B, X) = [q 5 ; a, S; X, R; X, S] (rewrite tapes 2 and 3) (q 5, a, B, X) = [q 4 ; a, S; X, R; X, R] (add two X s to tape 2 for each X on tape 3 to generate (k+1) 2 ) (q 4, a, B, B) = [q 6 ; a, L; B, L; X, L] (add an X s to tape 2 to yield k+1) [Step 4] (q 6, a, X, X) = [q 6 ; a, L; X, L; X, L] (reposition tape heads) (q 6, a, X, B) = [q 6 ; a, L; X, L; B, S] (tape 3 at 1 st cell, but not tapes 1 & 2) (q 6, a, B, B) = [q 6 ; a, L; B, S; B, S] (tape 2 & 3 at 1 st cell, but not tape 1) (q 6, B, X, B) = [q 6 ; B, S; X, L; B, S] (tape 1 & 3 at 1 st cell, but not tape 2) (q 6, B, B, B) = [q 2 ; B, R; B, R; B, R] (repeat comparison cycle) 19

8.6 Multitape TMs A multitape TM can be represented by a state transition diagram. Example 8.6.3 A 2-tape TM that accepts { uu u { a, b }* }. Computation: 1) Make a copy of the input S (on tape 1) to tape 2; tape heads: right of S. 2) Move both tape heads one step to the left. 3) Move the head of tape 1 two squares for each square move of tape 2. 4) Reject the input S if the TM halts in q 3. (i.e. S is odd.) 5) Compare the 1st half with the 2nd half of S in q 4 6) Accept S in q 5 (1) [x/x R, B/x R] [, ] > q 0 q 1 (2) [B/B L, B/B L] (5) [, y/y R] q 2 (3) [x/x L, y/y L] [x/x L, y/y S] (3) (4) q 3 x {a, b} y {a, b, B} (6) [y/y R, ] q 4 q 5 [x/x R, x/x R] (5) 20

8.6 Multitape TMs Theorem 8.6.1 A language L is accepted by a multitape TM iff it is accepted by a standard TM. Proof. By simulating a multitape TM using a single tape with multitrackstm. 21