ECS 120 Lesson 15 Turing Machines, Pt. 1

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

CS21 Decidability and Tractability

CSCC63 Worksheet Turing Machines

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

CS4026 Formal Models of Computation

Part I: Definitions and Properties

Chapter 3: The Church-Turing Thesis

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

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

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

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

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

Turing Machines Part II

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

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

Fundamentals of Computer Science

Computability and Complexity

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

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

Undecidable Problems and Reducibility

The Church-Turing Thesis

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Automata Theory - Quiz II (Solutions)

1 Unrestricted Computation

Most General computer?

Homework Assignment 6 Answers

ECS 120 Lesson 20 The Post Correspondence Problem

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

CSE 105 THEORY OF COMPUTATION

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

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

Chapter Two: Finite Automata

Chapter 8. Turing Machine (TMs)

Nondeterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Two Way Deterministic Finite Automata

Theory of Computation Turing Machine and Pushdown Automata

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

Pushdown Automata. Chapter 12

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

Introduction to Turing Machines

Theory of Computation

Lecture notes on Turing machines

Turing Machines. Nicholas Geis. February 5, 2015

Variants of Turing Machine (intro)

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Turing Machines. Chapter 17

Formal Definition of Computation. August 28, 2013

The Power of One-State Turing Machines

Lecture 13: Turing Machine

Computation Histories

Equivalent Variations of Turing Machines

CISC4090: Theory of Computation

CS 525 Proof of Theorems 3.13 and 3.15

Finite Automata. Mahesh Viswanathan

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

Introduction to Turing Machines. Reading: Chapters 8 & 9

Finite Automata. Finite Automata

CSE 105 Theory of Computation

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

Computability Theory. CS215, Lecture 6,

Formal Definition of a Finite Automaton. August 26, 2013

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

CSE 105 THEORY OF COMPUTATION

Introduction to Theory of Computing

CSci 311, Models of Computation Chapter 9 Turing Machines

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.


CSE 105 THEORY OF COMPUTATION

Theory of computation: initial remarks (Chapter 11)

Languages, regular languages, finite automata

ECS 120 Lesson 23 The Class P

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

Automata Theory CS S-12 Turing Machine Modifications

Introduction to Languages and Computation

Designing 1-tape Deterministic Turing Machines

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

COMPARATIVE ANALYSIS ON TURING MACHINE AND QUANTUM TURING MACHINE

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Lecture 17: Language Recognition

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

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CpSc 421 Homework 9 Solution

The tape of M. Figure 3: Simulation of a Turing machine with doubly infinite tape

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

Automata and Languages

Chapter 7 Turing Machines

The Turing machine model of computation

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

X-machines - a computational model framework.

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

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

Transcription:

ECS 120 Lesson 15 Turing Machines, Pt. 1 Oliver Kreylos Wednesday, May 2nd, 2001 Before we can start investigating the really interesting problems in theoretical computer science, we have to introduce yet another type of machine. As we have seen recently, neither finite automata nor pushdown automata are powerful enough to accept certain types of languages that have practical applications, like the language of syntactically correct C programs. We have found out, however, that pushdown automata are more powerful than finite automata, and that this increase in power is based in the availability of unlimited memory in form of a stack. To further increase the power of our computation models, we will remove the restriction of last-in, first-out access from pushdown automata. The resulting machine, that can access its memory in a random-access fashion, is called a Turing Machine. This machine type was first introduced by Alan Turing in 1936. 1 Turing Machines A Turing Machine is essentially still a finite state machine, but as opposed to the latter, it can write to the input tape (now called work tape, and it can move its read/write head arbitrarily over the work tape. Furthermore, the work tape does not only contain the word that is the machine s input, but it has an unlimited number of tape cells to the right. An illustration of a Turing Machine is shown in Figure 1. A Turing Machine computes by initially being presented with its input written on the work tape, from the leftmost position to the right. All work tape cells to the right of the end of the input tape are filled with a special blank symbol. Initially, the read/write head is positioned over the leftmost tape cell. The Turing Machine will then transition inside its state control, guided by 1

a 1 a 2 a 3 a 4 a n M accept reject Figure 1: A Turing Machine M consisting of state control, work tape and movable read/write head. the character located underneath the read/write head, called the current character. In each computation step, the machine writes a new character into the tape cell underneath the read/write head, and then moves the head either to the left or to the right. Unlike a finite automaton, a Turing Machine ends its computation by entering either the designated accept state or the reject state. If the machine never enters one of these states, computation will continue forever and it will never halt. To summarize, a Turing Machine differs from a finite automaton in the following ways: A Turing Machine can write to its input tape (work tape). The read/write head can be moved to the left and to the right. The work tape is unlimited to the right. The machine has two special accept and reject states which take immediate effect. The major difference between a Turing Machine and a pushdown automaton is that the former can access its work tape in a random-access fashion, whereas the latter can only access its stack in a last-in, first-out manner. 2

2 Examples on Turing Machine Computation To get a feel for how Turing Machines work, let us look at some languages that we know are not context-free, and see how we can recognize them using Turing Machines. 2.1 The Language L 1 := { 0 n 1 n 2 n n 0 } The idea for a Turing Machine to accept this language is to sweep the input from left to right, crossing of exactly one 0, one 1 and one 2 in each sweep. If after one of the sweeps only crossed-out characters remain, the word must initially have consisted of an equal number of zeros, ones and twos. We will give a high-level description of a Turing Machine that accepts language L 1 in the form of an algorithm. Initially, the input word w is written on the work tape, and all cells to the right of the input tape are filled with the blank symbol. The read/write head is positioned at the left end of the tape. The machine now proceeds as follows: 1. If the input word is the empty word, i. e., the current character is the blank symbol, go to the accept state. 2. If the current character is not a zero, go to the reject state. Otherwise, cross it out and move the read/write head to the right until something but a zero or a crossed-out character is encountered. 3. If the current character is not a one, go to the reject state. Otherwise, cross it out and move the read/write head to the right until something but a one or a crossed-out character is encountered. 4. If the current character is not a two, go to the reject state. Otherwise, cross it out and move the read/write head to the right until something but a two or a crossed-out character is encountered. 5. If the current character is not the blank symbol, go to the reject state. Otherwise, move the read/write head back to the left end of the tape. If all characters encountered on the way are crossed-out, move to the accept state. 6. Move the read/write head to the right until the first non-crossed-out character is encountered and repeat from step 2. 3

2.2 The Language L 2 := { 0 2n n 0 } This language seems a little more complicated to accept. After all, a Turing Machine is little more than a glorified finite state machine, and we already now that finite state machines cannot perform arithmetics. Thus, we have to find a different way to determine whether a string contains a power of two number of zeros than calculating the exponential directly. This other way lies in a recursive defition of all powers of two: Base Case If n = 1, then n is a power of two. Inductive Case If n is even, and n/2 is a power of two, then n is a power of two. This observation leads to the following idea: We sweep the input from left to right, and in each sweep we determine if the number of zeros seen was even or odd, or if it was exactly one. While sweeping, we cross out every other zero. If the number of zeros was one, we accept. If the number of zeros was odd, we reject. If the number was even, we have effectively divided the number by two by crossing out every other zero. We now move the read/write head back to the beginning and repeat. In the form of an algorithm, the Turing Machine to accept L 2 works as follows: 1. If the input word is the empty word, i. e., the current character is the blank symbol, go to the reject state. 2. If the current character is not a zero, reject. Otherwise, move the input head one to the right. 3. Scan to the right, until the first non-crossed-out character is encountered. If it is the blank symbol, accept. If it is neither the blank symbol nor a zero, reject. 4. Cross out the current character and scan to the right until the next non-crossed-out character is encountered. If it is the blank symbol, move the read/write head all the way to the left end of the tape and repeat from step 2. If it is neither the blank symbol nor a zero, reject. 5. Move the read/write head one to the right and scan to the right until the next non-crossed-out character is encountered. If it is anything but a zero, reject. Otherwise, repeat from step 4. 4

3 Formal Definition of Turing Machines Though the description of Turing Machines by algorithms, as shown in the above sections, is usually sufficient to understand how a Turing Machine works, it is not precise enough to allow us to reason about the behaviour of a specific Turing Machine. For this purpose we need a formal definition. A Turing Machine M is a 7-tuple M = (Q, Σ, Γ, δ, q 0, q accept, q reject ), where Q is a finite set of states, Σ is the input alphabet, where / Σ, Γ is the tape alphabet, where Γ and Σ Γ, δ: Q Γ Q Γ {L, R} is the transition function, q 0 Q is the start state, q accept Q is the accept state, and q reject Q is the reject state, where q accept q reject. 4 Turing Machines as State Diagrams As for finite automata, a Turing Machine s behaviour is determined by its transition function. To specify the transition function, we can draw a transition diagram similar to those for finite automata or pushdown automata. The machine s states will be drawn as nodes, and the transition function will be denoted by arrows going from state to state, labeled with the read input character, the character written to the tape, and the direction the tape head should move. Figure 2 shows how the arrows are labeled for different types of transitions. 5

(a) a b,r (b) a R (c) a b,r, b c,l (d) a,b R Figure 2: Notations and shorthands for transition diagrams of Turing Machines. (a) Label for a transition δ(q 1, a) = (q 2, b, R) (b) Label for a transition δ(q 1, a) = (q 2, a, R) (the character a is not changed) (c) Label for two transitions δ(q 1, a) = (q 2, b, R) and δ(q 1, b) = (q 2, c, L) (d) Label for two transitions δ(q 1, a) = (q 2, a, R) and δ(q 1, b) = (q 2, b, R) (the characters a and b are not changed). 6