Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Similar documents
Variants of Turing Machines

Theory of Languages and Automata

ECS 120 Lesson 16 Turing Machines, Pt. 2

Introduction to Computers & Programming

CISC 4090 Theory of Computation

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

Outline. Language Hierarchy

CS21 Decidability and Tractability

Equivalence of NTMs and TMs

pp Variants of Turing Machines (Sec. 3.2)

CSE 105 THEORY OF COMPUTATION

CT32 COMPUTER NETWORKS DEC 2015

Theory of Computation p.1/?? Theory of Computation p.2/?? A Turing machine can do everything that any computing

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Enumerations and Turing Machines

Turing Machines, continued

Actually talking about Turing machines this time

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Computer Sciences Department

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

A Characterization of the Chomsky Hierarchy by String Turing Machines

Theory of Computation, Homework 3 Sample Solution

CS402 - Theory of Automata Glossary By

Turing Machine Languages

Theory of Programming Languages COMP360

Computability and Complexity

Chapter 14: Pushdown Automata

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.


Decidable Problems. We examine the problems for which there is an algorithm.

Turing Machine as Transducer. Turing Machines. Computation with Turing Machines. Computation with Turing Machines. Computation with Turing Machines

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Recursively Enumerable Languages, Turing Machines, and Decidability

Multiple Choice Questions


(Refer Slide Time: 0:19)

Lec-5-HW-1, TM basics

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

COMP 382: Reasoning about algorithms

UNIT I PART A PART B

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

Lecture 18: Turing Machines

Context Free Languages and Pushdown Automata

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Theory of Computations Spring 2016 Practice Final Exam Solutions

1 Parsing (25 pts, 5 each)

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

Limited Automata and Unary Languages

The Big Picture. Chapter 3

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

Final Course Review. Reading: Chapters 1-9

CS 125 Section #4 RAMs and TMs 9/27/16

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

Theory of Computations Spring 2016 Practice Final

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

CSCI 3130: Formal Languages and Automata Theory Lecture 16 The Chinese University of Hong Kong, Fall 2010

lec3:nondeterministic finite state automata

Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

Decision Properties for Context-free Languages

Final Exam 1, CS154. April 21, 2010

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

CSE 105 THEORY OF COMPUTATION

Theory Bridge Exam Example Questions Version of June 6, 2008

Does this program exist? Limits of computability. Does this program exist? A helper function. For example, if the string program is

Languages and Models of Computation

Log-Space. A log-space Turing Machine is comprised of two tapes: the input tape of size n which is cannot be written on, and the work tape of size.

More on Polynomial Time and Space

05. Turing Machines and Spacetime. I. Turing Machines and Classical Computability.

More Simulations. CS154 Chris Pollett Apr 25, 2007.

CS 44 Exam #2 February 14, 2001

Specifying Syntax COMP360

III. Supplementary Materials

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

Theory of Computation

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

To illustrate what is intended the following are three write ups by students. Diagonalization

CSC-461 Exam #2 April 16, 2014

Verification in Loosely Synchronous Queue-Connected Discrete Timed Automata

Chapter 4 Turing Machines

1.0 Languages, Expressions, Automata

Formal languages and computation models

Languages and Compilers

Formal Grammars and Abstract Machines. Sahar Al Seesi

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

Material from Recitation 1

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

Final Exam 2, CS154. April 25, 2010

A Note on the Succinctness of Descriptions of Deterministic Languages

Transcription:

Turing Machines Transducers: A transducer is a finite state machine (FST) whose output is a string and not just accept or reject. Each transition of an FST is labeled with two symbols, one designating the input symbol and the other designating the output symbol. The two symbols are written with a slash,/, separating them. When an FST computes on an input string w, it takes the input symbols w 1, w n one by one and, starting at the start state, follows the transitions by matching the input labels with the sequence of symbols w1,..wn. Every time it goes along a transition, it outputs the corresponding output symbol. 0/0 1/0 2/1 1/1 2/1 q1f q2 0/0 For example, on input 22112011 (1111000) Formal Definition of the finite state transducer: A transducer finite state machine is a 5-tuple (Q,, Γ,δ, q0) where: Q is a finite non empty set of states is the input alphabet Γ is the output alphabet q0 is the start state, an element of Q δ is the state transition function: δ: Q x Q x Γ Turing Machines

A Turing machine is like a pushdown automaton. Both have a finite-state machine as a central component; both have additional storage. But where a pushdown automaton uses a stack for storage, a Turing machine uses a tape, which is considered to be infinite in both directions. The tape consists of a series of squares, each of which can hold a single symbol. The tape head, or read-write head, can read a symbol from the tape, write a symbol to the tape, and move one square in either direction. Turing machines can be deterministic or nondeterministic. We will consider only deterministic machines. Unlike the other automata we have discussed, a Turing machine does not read "input." Instead, there may be (and usually are) symbols on the tape before the Turing machine begins; the Turing machine might read some, all, or none of these symbols. The initial tape may, if desired, be thought of as "input." The following list summarizes the differences between FSA and Turing machines: A Turing machine can both write on the tape and read from it. A read-write head can move both to the left and to the right the tape is infinite The special states for rejecting and accepting take effect immediately. Let us introduce a Turing machine M1 for recognizing the language B= { w#w w {0,1}* We want M1 to accept if its input is a member of B or reject otherwise. An input is a member of B if it consists of two identical strings separated by a # symbol. The input is too long to remember it all, but the machine is allowed to move back and forth over the input and make marks on it. Strategy: Read each symbol on the two sides of the # and determine whether they match. Place marks on the tape to keep track of which places they correspond. M1 will take multiple passes over the input string with the read/write head. On each pass it matches one of characters on each side of the # symbol, To keep track of which symbols have been checked already, M1 crosses off each symbol as it is examined. If it crosses off all the symbols, that means that everything matched successfully and M1 goes into an accept state. If it discovers a mismatch, it enters the reject state. Formal Definition of Turing Machines

A Turing machine M is a 7-tuple (Q,,,, q 0, #, F) where Q is a set of states, is a finite set of symbols, the input alphabet, is a finite set of symbols, the tape alphabet, is the partial transition function, # is a symbol called blank, q 0 Q is the initial state, F Q is a set of final states. M= (Q,, Γ, δ, q0, B, F), whose components have the following meaning: Q: The finite set of states of the machine : The finite set of input symbols Γ: The complete set of tape symbols; δ: the transition function. The arguments of δ(q, X) are a state q and a tape symbol X. The value of δ(q, X), if it is defined, is a triple (p, Y, D) where: 1. p is the next state in Q 2. Y is the symbol, in Γ, written in the cell being scanned, replacing whatever symbol was there. 3. D is the direction, either L or R, standing for left or right, respectively and telling us the direction in which the head moves. q0: The start state a member of Q, in which the machine is found initially B: The blank symbol. This symbol is in Γ but not in F: The set of final or accepting states; a subset of Q. Because the Turing machine has to be able to find its input, and to know when it has processed all of that input, we require: The tape is initially blank (every symbol is #) except possibly for a finite, contiguous sequence of symbols. If there are initially nonblank symbols on the tape, the tape head is initially positioned on one of them.

There is a distinction between (the input alphabet) and (the tape alphabet). The "input" (the nonblank symbols on the tape) does not contain # or blank. However the complete set of tape symbols includes # or blanks. Usually is a subset of Transition Function, Instantaneous Descriptions, and Moves The transition function for Turing machines is given by : Q Q {L, R} This means: When the machine is in a given state (q Q) and reads a given symbol (t ) from the tape, it replaces the symbol on the tape with some other symbol (t ), goes to some other state (q Q), and moves the tape head one square left (L) or right (R). An instantaneous description or configuration of a Turing machine requires (1) the state the Turing machine is in, (2) the contents of the tape, and (3) the position of the tape head on the tape. This can be summarized in a string of the form x i...x j q m x k...x l where the x's are the symbols on the tape, q m is the current state, and the tape head is on the square containing x k (the symbol immediately following q m ). A move of a Turing machine can therefore be represented as a pair of instantaneous descriptions, separated by the symbol " ". For example, if (q 5, b) = (q 8, c, R) then a possible move might be abbabq 5 babb abbabcq 8 abb Programming a Turing Machine Just as the productions are the "heart" of a grammar, in that most of the other components can be figured out by looking at the productions, the transitions are the heart of a Turing machine. These transitions are often given as a table or list of 5-tuples, where each tuple has the form (current state, symbol read, symbol written, direction, next state) Creating such a list is often spoken of as "programming" a Turing machine. A Turing machine is often defined to start with the read head positioned over the first (leftmost) input symbol. This isn't really necessary, because if the Turing machine starts anywhere on the nonblank portion of the tape, it's simple to get to the first input symbol.

For the input alphabet = {a, b}, the following program fragment positions the head on the leftmost symbol and moves right to q 1 : (q0, a, a, L, q0) (q0, b, b, L, q0) (q0, #, #, R, q1) If we start a Turing machine on an input, three outcomes are possible: 1. The machine may accept, 2. The machine may reject or 3. The machine may loop. By loop we mean that the machine does not halt. A Turing machine halts when it no longer has any available moves. If a Turing Machine (TM) halts in a final state, it accepts its input; otherwise, it rejects its input. If a Turing machine halts, the sequence of configurations leading to the halt state is called a computation. Failed computations: ATuring machine accepts its input if it halts in a final state. There are two ways this could fail to happen: 1. The Turing machine could halt in a nonfinal state, or 2. The Turing machine could never stop (in which case we say it is in an infinite loop. ) A function f is Turing computable if there exist a Turing machine that can perform it. Describe a Turing machine (TM) M that decides A={0 2n n>=0}. Example of strings: 0, 00, 0000, 000000 Current State Symbol Read Symbol written direction next state q1 ^ ^ R q reject q1 x x R q reject q1 0 ^ R q2 q2 x x R q2 q2 0 x R q3 q2 ^ ^ R q accept q3 x x R q3 q3 ^ ^ L q5 q3 0 0 R q4 q4 0 x R q3 q4 x x R q4

q4 ^ ^ R q reject q5 0 0 L q5 q5 x x L q5 q5 ^ ^ R q2 find its computation on input 0000 q 1 0000; ^q 2 000; ^xq 3 00; ^x0q 4 0; ^x0xq 3^; ^x0q 5 x^; ^xq 5 0x^; ^q 5 x0x^,. Define a Turing machine that recognizes strings of the form {0 n 1 n n>=1} Initially it is given a finite sequence of 0 s and 1 s on its tape, preceded and followed by an infinite number of blanks. How would this machine proceed? Starting at the left end of the input, it changes a 0 into an x. It moves to the right over whatever 0 s and y s it sees until it comes to a 1. It changes the 1 to a y It moves left over 0 s and y s until it finds an x. At this point it looks for a 0 immediately to the right, and if it finds one, changes it into an x and repeat the process, changing a matching 1 to y. M= ({q0,q1,q2,q3,q4},{0,1},{0,1,x,y,^}, δ, q0,^,{q4}) As M performs its computation, the portion of the tape, that the head has visited will always be a sequence of symbols described by the regular expression x*0*y*1*. - Write the function δ. - Check that it accepts 0011 - Check that it rejects 0010 Transition diagrams for Turing Machines: The same as for PDA a TM can be represented with a diagram. A transition diagram consists of: - set of nodes corresponding to the states of the TM. - An arc from state q to state p is labeled by one or more items of the form X/YD, where X and Y are tape symbols, and D is a direction, either L or R. That is, whenever δ(q,x)=(p,y,d), we find the label X/YD on the arc from q to p. - The start and final states representations follow the same conventions as for other kinds of transition diagrams.

Represent the transition diagram for the TM that accepts {0 n 1 n } Languages and Turing Machines Definition: A Turing Machine T = (Q,,,, q 0, #, F) accepts a language L(M), where : L(M) = {w + : q 0 w x i q f x j for some q f F, x i, x j *} The set of languages that we can accept using a Turing machine is often called recursively enumerable languages or RE languages. A language is Turing-recognizable if some Turing machine recognizes it. Turing Machines and Halting: Acceptance by halting: We say that a TM halts if it enters a state q, scanning a tape symbol x and there is no move in this situation; i.e.; the transition function is undefined. In general, we assume that a TM always halts when it is in an accepting state. Languages with TM that eventually halt whether they accept or not are called recursive. TM that always halt, regardless of whether or not they accept, are good model of an algorithm. That is if an algorithm to solve a given problem exists, then we say the problem is decidable. A language is Turing-decidable or decidable if some Turing decides it. machine Variants of Turing Machines: -Storage in the State: We can use the control not only to represent the state of the machine but also a finite amount of data. In that sense, a state is represented as pairs with two components: a) a control portion q i that remembers what the TM is doing. b) a data portion, which remembers what symbol has been seen.

-Multiple Tracks: We can think of the tape of a Turing machine as composed of several tracks. Each track can hold one symbol and the tape alphabet of the TM consists of tuples, with one component for each track. A common use of multiple tracks is to treat one track as holding the data and a second track as holding a mark. We can check off each symbol as we use it or we can keep track of a small number of positions. Example: Design a TM that recognizes the non-context free language: L wcw = {wcw w is in (0+1) + } The TM is defined as: M= (Q,, Γ, δ,[q1,^],[^,^],{[q9,^]}) where: Q: The set of states is {q0, q1,, q9} x {0,1, ^}, that is, pairs consisting of a control state qi and a data component: 0, 1, and ^ (for blank). Γ: The set of tape symbols is {^, *} x {0,1, c, ^}. The first component, or track, can be either blank or checked represented by the symbols ^ and *, respectively. We use the * to check off symbols of the first and second groups of 0 s and 1 s, eventually confirming that the string to the left of the center marker c is the same as the string to its right. The second component of the tape symbol is the tape symbol itself. -Multitape Turing Machines: A multitape Turing machine is like an ordinary Turing machine with several tapes. Each tape has its own head for reading and writing. Initially the input appears on tape 1, and the others start out blank. The transition function is changed to allow for reading, writing and moving the heads on some or all of the tapes simultaneously..formally, the transition function is: δ: Q x Γ k Q x Γ k x {L, R, S} k where k is the number of tapes. The expression δ(q i,a 1,.a k )= (q j, b 1,..,b k, L, R,..,L) means that, if the machine is in state q i and the heads 1 through k are reading symbols a 1,.a k ; the machine goes to state q j, writes symbols b 1,..,b k and directs each head to move left or right or to stay stationary, as specified. Theorem: Every language accepted by a multitape TM is recursively enumerable. Theorem: Every multitape Turing machine has an equivalent single-tape Turing machine. Proof: We have to convert a multitape TM M to an equivalent single-tape TM S.

Say that M has k tapes, then S simulates the effect of k tapes by storing their information on its single tape. It uses the new symbol # as a delimiter to separate the contents of the different tapes. In addition, S must keep track of the locations of the heads. It does so by writing a tape symbol with a dot above it to mark where the head on that tape would be. The dotted symbols are simply new symbols that have been added to the tape alphabet. M 0 1 0 1 ^ a a a ^ b a ^ S # 0 1 0 1 # a a a # b a # ^.. Representing three tapes with one Non deterministic Turing machines: A nondeterministic TM is defined such as at any point in a computation the machine may proceed according to several possibilities. The transition function of a nondeterministic TM has the form: δ:q x Γ P(Q x Γ x {L, R}). The computation of a non-deterministic TM is a tree whose branches correspond to different possibilities for the machine. -If some branch of the computation leads to the accept state, the machine accepts its input. Theorem: Every nondeterministic Turing Machine has an equivalent deterministic Turing Machine. Corollary:

A language is Turing-recognizable if and only if some nondeterministic Turing machine recognizes it. Decider: We call a nondetermistic Turing machine a decider of all branches halt on all inputs. Corollary: A language is decidable if and only if some nondeterministic Turing machine decides it. Enumerators: An enumerator is a TM with an attached printer. The TM can use that printer as an output device. Every time the TM wants to add a string to the list, it sends the string to the printer. The language enumerated by E is the collection of all the strings that it eventually prints out. E may generate the strings of the language in any order with possible repetitions. Theorem: A language is Turing recognizable if and only if some enumerator enumerates it. Equivalence with other models Many models of general purpose computation have been proposed. All these models share the essential feature of TM- namely unrestricted access to unlimited memorydistinguishing them from weaker models such as FSA and PDA. All models with that feature are equivalent in power. Turing Machines and Computers: Computers and Turing Machines accept exactly the same languages- the recursively enumerable languages. 1. A computer can simulate a Turing machine 2. A Turing machine can simulate a computer, and can do so in an amount of time that is at most polynomial in the number of steps taken by the computer. Simulating a computer by a Turing Machine: This is done by assuming that the computer storage consists of an indefinitely long sequence of words, each with an address that is an integer. We assume that the program of the computer is stored in some of the memory. We assume that each instruction involves a finite number of words and that each instruction changes the value of at most one word. This can be simulated using a Turing machine consisting of multiple tapes. The first tape represents the entire memory of the computer. The second tape is the instruction counter etc.. Simulating a Turing machine by a computer:

In order to simulate the infinite memory of a Turing machine, we assume that our computer has an infinite number of disks that are swapped one a disk become full. Furthermore, we assume that the data on the tape can be simulated by disks arranged in two stacks. One stack holds the data in the TM located significantly to the left and the other holds the data, located significantly to the right. When the head moves sufficiently far to the left or right so as it reaches cells not represented by the disk currently mounted in the computer, it issues a swap message.