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

Similar documents
CSCC63 Worksheet Turing Machines

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

Turing Machines. Fall The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory

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

Part I: Definitions and Properties

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

CSE 105 THEORY OF COMPUTATION

ECS 120 Lesson 15 Turing Machines, Pt. 1

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

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

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

Computability Theory. CS215, Lecture 6,

CS21 Decidability and Tractability

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

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

Turing Machines Part II

Homework Assignment 6 Answers

Computability and Complexity

Introduction to Turing Machines. Reading: Chapters 8 & 9

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

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

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

CSCI3390-Assignment 2 Solutions

Turing Machines Part III

CpSc 421 Final Exam December 15, 2006

IV. Turing Machine. Yuxi Fu. BASICS, Shanghai Jiao Tong University

Chapter 3: The Church-Turing Thesis

CS4026 Formal Models of Computation

Before We Start. Turing Machines. Languages. Now our picture looks like. Theory Hall of Fame. The Turing Machine. Any questions? The $64,000 Question

Theory of Computation

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

Designing 1-tape Deterministic Turing Machines

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

Notes for Comp 497 (Comp 454) Week 12 4/19/05. Today we look at some variations on machines we have already seen. Chapter 21

Most General computer?

CPSC 421: Tutorial #1

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

Turing Machines. Nicholas Geis. February 5, 2015

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Decidable and undecidable languages

Further discussion of Turing machines

The Church-Turing Thesis

Lecture notes on Turing machines

1 Showing Recognizability

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

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

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

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Turing machines and computable functions

Automata Theory CS S-12 Turing Machine Modifications

Turing Machines, diagonalization, the halting problem, reducibility

Equivalent Variations of Turing Machines

Turing Machines Part II

V Honors Theory of Computation

CISC4090: Theory of Computation

Turing Machine Variants

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Lecture 12: Mapping Reductions

Chapter 7 Turing Machines

Lecture 14: Recursive Languages

CS20a: Turing Machines (Oct 29, 2002)

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

Reducability. Sipser, pages

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

CSE 105 THEORY OF COMPUTATION

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

Space Complexity. The space complexity of a program is how much memory it uses.

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

CS20a: Turing Machines (Oct 29, 2002)

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

Turing Machine Recap

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

CS 525 Proof of Theorems 3.13 and 3.15

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

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

Universal Turing Machine. Lecture 20

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

Turing Machines. Lecture 8

Fundamentals of Computer Science

Theory of Computation (IX) Yijia Chen Fudan University

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

CS 21 Decidability and Tractability Winter Solution Set 3

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

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

Computation Histories

Theory of Computer Science

Turing Machines Part Two

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

CSE 105 THEORY OF COMPUTATION

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Lecture 13: Turing Machine

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

Foundations of

Automata Theory - Quiz II (Solutions)

Formal Definition of Computation. August 28, 2013

Chapter 8. Turing Machine (TMs)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

The Power of One-State Turing Machines

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

Turing Machine variants

Transcription:

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

A Turing Machine A Turing Machine (TM) has three components: An infinite tape divided into cells. Each cell contains one symbol. A head that accesses one cell at a time, and which can both read from and write on the tape, and can move both left and right. A memory that is in one of a fixed finite number of states. Goddard 11: 2

The TM s Tape We assume a two-way infinite tape that stretches to infinity in both directions. denotes an empty or blank cell. The input starts on the tape surrounded by with the head at left-most symbol. (If input is ε, then tape is empty and head points to empty cell.) control 0 0 1 Goddard 11: 3

The Program The program of a TM is a transition function; depending on symbol under the head and state, the TM: writes a symbol, moves left or right or stays in place, and updates its state. The language of TM is set of strings it accepts. Like the PDA, once a TM enters an accept state it stops, and it terminates abnormally if there is no transition. Goddard 11: 4

The Diagram The TM is represented as a diagram, like for FA, except that each arrow is labeled with a triple: oldsymbol newsymbol movedir, where movedir is one of L (move left one cell), R (move right one cell), and S (stay in place). For example, triple 01L means if reading a 0, then write a 1 and move the head left. Goddard 11: 5

Example TM: Strings Containing 101 Here is a simple TM that mimics an FA for the language of all binary strings that contain the substring 101. 00R 11R 11R 00R 11R a b c h a 00R Goddard 11: 6

Formal Definition One can define a TM as a 7-tuple (Q, Σ, Γ, q 0, h a, h r, δ) where: Q is set of states. Σ is input alphabet. Γ is tape alphabet (more than Σ). q 0 is start state, h a the unique halt-and-accept state, and h r the (seldom drawn) unique haltand-reject state. δ is the transition function Q Γ Q Γ {L, R, S}. Goddard 11: 7

Example TM: 0 n 1 n For a TM that accepts { 0 n 1 n }, pair off the 0 s and 1 s repeatedly erase first 0 and last 1 until ε reached. In pseudocode: (1) If HeadSymbol=0, then Write( ) else Reject. (2) Move head right until HeadSymbol=. (3) Move head left. (4) If HeadSymbol=1, then Write( ) else Reject. (5) Move head left until HeadSymbol=. (6) Move head right. (7) If HeadSymbol=, then Accept. (8) Goto (1). Goddard 11: 8

Example Diagram: 0 n 1 n 00R, 11R A 0 R B S L R h a D 1 L C 00L, 11L Here is what happens on input 00111... Goddard 11: 9

A 0 0 1 1 1 B 0 1 1 1. C 0 1 1 1 D 0 1 1 A. 0 1 1. C 1 1. A 1 Reject Goddard 11: 10

TMs might not halt Here is a particularly unhelpful TM. It does not halt. abr, bbr bal L R Goddard 11: 11

Example TM: Balanced Brackets For a TM for balanced brackets, one idea is to find the innermost matching pair of brackets, erase them, and repeat the process. Goddard 11: 12

Example TM: Balanced Brackets For a TM for balanced brackets, one idea is to find the innermost matching pair of brackets, erase them, and repeat the process. We use x to indicate an erased bracket. ((R, xxr )xl A B xxl (xr L xxl C S h a Goddard 11: 13

Example TM: Palindromes For even-length palindromes, we match first and last symbols and erase; then repeat. If reach ε without mismatch, then string was palindrome. Goddard 11: 14

Example TM: Even-length Palindromes 00R, 11R L B 0 C 0 0 R 0 L S A 1 R R 1 L D 00L, 11L h a L B 1 C 1 00R, 11R Goddard 11: 15

Informal TM We often present TM as pseudocode or English. Example: A TM that recognizes { w#w : w Σ }. Goddard 11: 16

Informal TM Example: A TM that recognizes { w#w : w Σ }. The TM crosses off first entry and remembers it. It then marches right until first entry after the hash mark. It checks that that is correct and crosses that off. The TM returns to leftmost uncrossed entry and repeats the process, ignoring the crossed-out symbols. The TM accepts if it manages to cross out all the symbols without encountering a problem. Goddard 11: 17

TM Subroutines At this stage it looks like a TM is a simple computer perhaps with a limited instruction set. However, we will see that it can perform complex tasks. One aid to this is to design TM subroutines: basic tasks that are useful. Goddard 11: 18

Example Subroutine Example. A subroutine that shifts the entire input string one cell to the right. Goddard 11: 19

Example Subroutine Example. A subroutine that shifts the entire input string one cell to the right. An inefficient TM could move right-most symbol over, then next one, and so on. That is, it moves to end of string, remembering the last symbol seen as it goes. When it reaches the right-hand end, it writes down the remembered symbol, then backs up and erases the symbol. Then repeats... Goddard 11: 20

TM for Shifting Right 00R 0 L, 1 L 00R q 2 q 1 0L q 4 S 11R 11R 00R 1L h a q 3 11R Goddard 11: 21

TMs That Do Not Halt A TM does not necessarily halt. (And if not, it is not necessarily stuck in a loop.) And, we might not know beforehand whether it will halt. Consider, for example, a TM that tries to find a counterexample to Goldbach s conjecture that every even number at least 4 is sum of two primes. The TM tries every value of even n in increasing order. For each n, it checks whether there is i such that both i and n i are prime. If not, it stops. Otherwise it continues forever. So we have built a TM that we humans don t know whether halts. Goddard 11: 22

Practice Draw the diagram for a TM that accepts the language {0 n 1 n 2 n }. Goddard 11: 23

Solution to Practice 00R, xxr 0 R 1xR 11R, yyr xxr R 2yL xxr yyr S h a 00L 11L xxl yyl Goddard 11: 24

Summary A Turing Machine (TM) is like an FA, but it has an infinite tape. The input starts on the tape surrounded by blank cells denoted. The program of a TM is represented as a diagram: depending on the symbol under the head and the state, the machine writes a symbol, moves left or right or stays in place, and/or changes state. Once a TM enters the accept state it stops. Goddard 11: 25