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

Similar documents
CS21 Decidability and Tractability

Chapter 3: The Church-Turing Thesis

CSCC63 Worksheet Turing Machines

ECS 120 Lesson 15 Turing Machines, Pt. 1

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

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

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

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

Turing Machines Part II

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

The Turing machine model of computation

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

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

Computational Models - Lecture 6

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

CpSc 421 Homework 9 Solution

CS4026 Formal Models of Computation

Computational complexity

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

The Church-Turing Thesis

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

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

CS20a: Turing Machines (Oct 29, 2002)

Theory of Computation Turing Machine and Pushdown Automata

TURING MAHINES

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

Most General computer?

Introduction to Turing Machines

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

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

Nondeterministic Finite Automata

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

Turing Machines. Lecture 8

Lecture 12: Mapping Reductions

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Homework Assignment 6 Answers

Turing Machines. COMP2600 Formal Methods for Software Engineering. Katya Lebedeva. Australian National University Semester 2, 2014

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

Introduction to Turing Machines. Reading: Chapters 8 & 9

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

1 Unrestricted Computation

Languages, regular languages, finite automata

Fundamentals of Computer Science

Undecidable Problems and Reducibility

Computability Theory

Reducability. Sipser, pages

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

Computability and Complexity

Part I: Definitions and Properties

Lecture 14: Recursive Languages

Lecture 13: Turing Machine

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

CSE 105 Theory of Computation

DM17. Beregnelighed. Jacob Aae Mikkelsen

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

CSE 105 THEORY OF COMPUTATION

Decidability (intro.)

Chapter Five: Nondeterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

Further discussion of 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 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

Automata Theory - Quiz II (Solutions)

Midterm II : Formal Languages, Automata, and Computability

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

CSE 105 THEORY OF COMPUTATION

Chapter 5. Finite Automata

Turing machines and linear bounded automata

Chapter 7 Turing Machines

Chapter 8. Turing Machine (TMs)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Models Lecture 8 1

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

ACS2: Decidability Decidability

Foundations of

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

Decidability (What, stuff is unsolvable?)

The Power of One-State Turing Machines

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

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

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

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

Finite Automata. Mahesh Viswanathan

Two Way Deterministic Finite Automata

Computational Models Lecture 8 1

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

A non-turing-recognizable language

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Computation Histories

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

Turing Machines. Nicholas Geis. February 5, 2015

Equivalent Variations of Turing Machines

Theory of Computation Lecture 1. Dr. Nahla Belal

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

1 Showing Recognizability

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Transcription:

COMS11700 Turing machines Department of Computer Science, University of Bristol Bristol, UK 21 March 2014 COMS11700: Turing machines Slide 1/15

Introduction We have seen two models of computation: finite automata and pushdown automata. We now discuss a model which is much more powerful: the Turing machine. COMS11700: Turing machines Slide 2/15

Introduction We have seen two models of computation: finite automata and pushdown automata. We now discuss a model which is much more powerful: the Turing machine. A Turing machine is like a finite automaton, with three major differences: It can write to its tape; It can move both left and right; The tape is infinite in one direction. Control a b b a a... Initially, the input is provided on the left-hand end of the tape, and followed by an infinite sequence of blank spaces ( ). COMS11700: Turing machines Slide 2/15

Example q 0 a b b a a... COMS11700: Turing machines Slide 3/15

Example q 1 c b b a a... COMS11700: Turing machines Slide 3/15

Example q 1 c a b a a... COMS11700: Turing machines Slide 3/15

Example q 3 c a b a a... COMS11700: Turing machines Slide 3/15

Example q 2 c a b a a... COMS11700: Turing machines Slide 3/15

Example q 2 c a b a a... COMS11700: Turing machines Slide 3/15

Example q 2 c a b a a... COMS11700: Turing machines Slide 3/15

Example q 2 c a b a a... COMS11700: Turing machines Slide 3/15

Example q 1 c a b a a c... COMS11700: Turing machines Slide 3/15

Alan Turing (1912-1954) 1936: Invented the Turing machine and the concept of computability. 1939-1945: Worked at Bletchley Park on cracking the Enigma cryptosystem and others. 1946-1954: Work on practical computers, AI, mathematical biology,... 1952: Convicted of indecency. Died of cyanide poisoning in 1954. 2014: Received a royal pardon. Pic: Wikipedia/Bletchley Park COMS11700: Turing machines Slide 4/15

Turing machines Turing machines have two special states: an accept state and a reject state. COMS11700: Turing machines Slide 5/15

Turing machines Turing machines have two special states: an accept state and a reject state. If the machine enters the accept or reject state, it halts (stops). COMS11700: Turing machines Slide 5/15

Turing machines Turing machines have two special states: an accept state and a reject state. If the machine enters the accept or reject state, it halts (stops). If it doesn t ever enter either of these states, it never halts (i.e. it runs forever). COMS11700: Turing machines Slide 5/15

Turing machines Turing machines have two special states: an accept state and a reject state. If the machine enters the accept or reject state, it halts (stops). If it doesn t ever enter either of these states, it never halts (i.e. it runs forever). The language L(M) recognised by a Turing machine M is the set {x M halts in the accept state on input x} COMS11700: Turing machines Slide 5/15

Turing machines Turing machines have two special states: an accept state and a reject state. If the machine enters the accept or reject state, it halts (stops). If it doesn t ever enter either of these states, it never halts (i.e. it runs forever). The language L(M) recognised by a Turing machine M is the set {x M halts in the accept state on input x} For some language L, if there exists a Turing machine M such that L = L(M), we say that L is Turing-recognisable. (These languages are also sometimes called recursively enumerable.) COMS11700: Turing machines Slide 5/15

Describing Turing machines We can describe a Turing machine by its state diagram. As with DFAs and PDAs, we have a graph whose vertices are labelled by states of the machine, and whose edges are labelled by possible transitions. a b, R q 1 q 2 COMS11700: Turing machines Slide 6/15

Describing Turing machines We can describe a Turing machine by its state diagram. As with DFAs and PDAs, we have a graph whose vertices are labelled by states of the machine, and whose edges are labelled by possible transitions. A label of the form a b, R q 1 q 2 a b, R means that on reading tape symbol a, the machine writes b to the tape and then moves right. COMS11700: Turing machines Slide 6/15

Describing Turing machines We can describe a Turing machine by its state diagram. As with DFAs and PDAs, we have a graph whose vertices are labelled by states of the machine, and whose edges are labelled by possible transitions. A label of the form a b, R q 1 q 2 a b, R means that on reading tape symbol a, the machine writes b to the tape and then moves right. Another example: a label a, b L means that on reading either tape symbol a or b, the machine doesn t write anything to the tape and then moves left. COMS11700: Turing machines Slide 6/15

Turing machines Imagine we want to test membership in the language L EQ = {w#w w {0, 1} }. x L EQ if it is made up of two equal bit-strings, separated by a # symbol. COMS11700: Turing machines Slide 7/15

Turing machines Imagine we want to test membership in the language L EQ = {w#w w {0, 1} }. x L EQ if it is made up of two equal bit-strings, separated by a # symbol. Idea for recognising this language 1. Our algorithm will scan forwards and backwards, testing each corresponding pair of bits either side of the # for equality in turn. 2. We can overwrite each bit with an x symbol after checking it so we don t check the same bits twice. COMS11700: Turing machines Slide 7/15

State diagram (Sipser, Figure 3.10) q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept q # L 6 q 7 1 x, R q 3 q 5 1 x, L COMS11700: Turing machines Slide 8/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 1 0 1 # 0 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 2 x 1 # 0 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 2 x 1 # 0 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 4 x 1 # 0 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 6 x 1 # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 7 x 1 # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 7 x 1 # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 1 x 1 # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 3 x x # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 5 x x # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 5 x x # x 1... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 6 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 6 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 7 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 1 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 8 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 8 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q 8 x x # x x... COMS11700: Turing machines Slide 9/15

Example: testing whether 01#01 L EQ q 2 q 4 0 x, R 0 x, L 0, 1, x L 0, 1 L q 1 q 8 R q accept # L q 6 q 7 1 x, R q 3 q 5 1 x, L q accept x x # x x... COMS11700: Turing machines Slide 9/15

Turing machines: formal definition Definition A Turing machine is described by a 7-tuple (Q, Σ, Γ, δ, q 0, q accept, q reject ), where: 1. Q is the set of states, 2. Σ is the input alphabet (which must not contain ), 3. Γ is the tape alphabet, where Γ and Σ Γ, 4. δ : Q Γ Q Γ {L, R} is the transition function, 5. q 0 Q is the start state, 6. q accept is the accept state, 7. q reject is the reject state, where q reject q accept. COMS11700: Turing machines Slide 10/15

Example The Turing machine we just saw is described by ({q 1,..., q 8, q accept, q reject }, {0, 1, #}, {0, 1, #, x, }, δ, q 1, q accept, q reject ) where the transition function δ is defined by the table 0 1 # x q 1 q 2, x, R q 3, x, R q 8, R q 2 q 2, R q 2, R q 4, R q 3 q 3, R q 3, R q 5, R q 4 q 6, x, L q 4, R q 5 q 6, x, L q 5, R q 6 q 6, L q 6, L q 7, L q 6, L q 7 q 7, L q 7, L q 1, R q 8 q 8, R q accept, R Blank entries in the table correspond to transitions where the machine rejects. COMS11700: Turing machines Slide 11/15

Turing machines: formal definition (2) The full description of what a Turing machine M is doing at any point in time is called its configuration. We write uqv for the configuration where: the tape to the left of the current position contains u; the tape to the right of the current position (and including the current position) contains v (followed by an infinite number of s); the machine is in state q. COMS11700: Turing machines Slide 12/15

Turing machines: formal definition (2) The full description of what a Turing machine M is doing at any point in time is called its configuration. We write uqv for the configuration where: the tape to the left of the current position contains u; the tape to the right of the current position (and including the current position) contains v (followed by an infinite number of s); the machine is in state q. For example, 01q 3 110 describes the following situation: q 3 0 1 1 1 0... COMS11700: Turing machines Slide 12/15

Turing machines: formal definition (3) Configuration C 1 yields C 2 if M can go from C 1 to C 2 in one step. So: uaqj bv yields uq k acv if δ(q j, b) = (q k, c, L); uaqj bv yields uacq k v if δ(q j, b) = (q k, c, R). COMS11700: Turing machines Slide 13/15

Turing machines: formal definition (3) Configuration C 1 yields C 2 if M can go from C 1 to C 2 in one step. So: uaqj bv yields uq k acv if δ(q j, b) = (q k, c, L); uaqj bv yields uacq k v if δ(q j, b) = (q k, c, R). If M is at the left-hand end of the tape, it cannot move any further to the left; but M can move arbitrarily far to the right (the tape is one-way infinite). COMS11700: Turing machines Slide 13/15

Turing machines: formal definition (3) Configuration C 1 yields C 2 if M can go from C 1 to C 2 in one step. So: uaqj bv yields uq k acv if δ(q j, b) = (q k, c, L); uaqj bv yields uacq k v if δ(q j, b) = (q k, c, R). If M is at the left-hand end of the tape, it cannot move any further to the left; but M can move arbitrarily far to the right (the tape is one-way infinite). M accepts input x if there is a sequence of configurations C 1,..., C k such that: 1. C 1 is the start configuration of M on input x; 2. For all 1 i k 1, C i yields C i+1 ; 3. C k is an accepting configuration (M is in state q accept). COMS11700: Turing machines Slide 13/15

Real-world implementations As well as being a mathematical tool, a Turing machine is a real machine that we can build... http://aturingmachine.com/index.php http://www.legoturingmachine.org COMS11700: Turing machines Slide 14/15

Summary and further reading A Turing machine is a generalisation of a finite automaton which has access to an infinite tape which it can read from and write to. Turing machines can perform complicated computations (although writing these down formally can be a painful process). Further reading: Sipser 3.1. COMS11700: Turing machines Slide 15/15