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

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

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

Decidable and undecidable languages

1 Unrestricted Computation

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

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

Chapter 3: The Church-Turing Thesis

CSE 105 THEORY OF COMPUTATION

CSCE 551 Final Exam, Spring 2004 Answer Key

Introduction to Turing Machines

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Advanced topic: Space complexity

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

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

Reducability. Sipser, pages

Introduction to Turing Machines. Reading: Chapters 8 & 9

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

CSCC63 Worksheet Turing Machines

V Honors Theory of Computation

CS4026 Formal Models of Computation

CS21 Decidability and Tractability

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

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

Turing Machines Part III

Automata Theory CS S-12 Turing Machine Modifications

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

Further discussion of Turing machines

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

Homework 5 Solution CSCI 2670 October 6, c) New text q 1 1##1 xq 3 ##1 x#q 5 #1 q reject. Old text. ~q 3 ##1 ~#q 5 #1

1 Showing Recognizability

Homework Assignment 6 Answers

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

Lecture 12: Mapping Reductions

Part I: Definitions and Properties

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

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

CSCI3390-Assignment 2 Solutions

TURING MAHINES

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

Theory of Computation (IX) Yijia Chen Fudan University

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

Computability Theory

CSE 105 THEORY OF COMPUTATION

Turing Machines Part II

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

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

Exam Computability and Complexity

Computability and Complexity

Theory of Computation

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

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

Turing Machines Part II

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

Computability Theory. CS215, Lecture 6,

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

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

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

CS20a: Turing Machines (Oct 29, 2002)

ECS 120 Lesson 15 Turing Machines, Pt. 1

Turing Machines Part One

CSE 105 THEORY OF COMPUTATION

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Decidability (What, stuff is unsolvable?)

Turing Machines. Lecture 8

Decidable Languages - relationship with other classes.

The Church-Turing Thesis

Complexity Theory Part I

Turing Machines. Nicholas Geis. February 5, 2015

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

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

Fundamentals of Computer Science

Equivalent Variations of Turing Machines

UNIT-VIII COMPUTABILITY THEORY

Turing Machine Variants

CA320 - Computability & Complexity

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

Midterm II : Formal Languages, Automata, and Computability

Decidability (intro.)

Turing Machines Part II

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

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

CS20a: Turing Machines (Oct 29, 2002)

CSCE 551 Final Exam, April 28, 2016 Answer Key

Rumination on the Formal Definition of DPDA

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Variants of Turing Machine (intro)

Intro to Theory of Computation

CSci 311, Models of Computation Chapter 9 Turing Machines

Most General computer?

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

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

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Foundations of

Theory of Computation

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

CSC236 Week 11. Larry Zhang

Decidability and Undecidability

Transcription:

The Chinese University of Hong Kong Fall 2011 CSCI 3130: Formal languages and automata theory Turing Machines Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130

Turing Machines control head a b b input blanks Can both read from and write to the tape Head can move both left and right Tape is infinite Has two special states accept and reject

Example L 1 = {w#w: w {a, b}*} Strategy: Read and remember the first symbol Cross it off (x) Read the first symbol past # If they don t match, reject If they do, cross it off abbaa#abbaa xbbaa#abbaa xbbaa#abbaa xbbaa#xbbaa

Example L 1 = {w#w: w {a, b}*} Strategy: Look for the first uncrossed symbol Cross it off (x) Read the first uncrossed symbol past # If they match, cross it off, else reject At the end, there should be only xs and #s xbbaa#xbbaa xxbaa#xbbaa xxbaa#xbbaa xxbaa#xxbaa xxxxx#xxxxx If not, reject; otherwise, accept.

How Turing Machines operate current state a/bl q 1 q 2 a b a Replace a with b, and move head left new state a/bl q 1 q 2 a b b

Formal Definition A Turing Machine is (Q, Σ, Γ, δ, q 0, q acc, q rej ): Q is a finite set of states; Σ is the input alphabet not containing the blank symbol Γ is the tape alphabet (Σ Γ) including q 0 in Q is the start state; q acc, q rej in Q are the accepting and rejecting state δ is the transition function δ: (Q {q acc, q rej }) Γ Q Γ {L, R} Turing Machines are deterministic

Configurations A configuration consists of the current state, the head position, and tape contents configuration q 1 a b a abq 1 a q 1 a/br q acc q acc a b b abbq acc

Configurations We say configuration C yields C if the TM can go from C to C in one step abq 1 a yields abbq acc The start configuration of the TM on input w is q 0 w An accepting configuration is one that contains q acc ; A rejecting configuration is one that contains q rej

The language of a Turing Machine We say M accepts x if there exists a sequence of configurations C 0, C 1,..., C k where C 0 is starting C i yields C i+1 C k is accepting The language recognized by M is the set of all strings that M accepts

Looping Something strange can happen in a Turing Machine: / R q 0 q acc q rej Σ = {0, 1} input: ε This machine never halts Inputs can be divided into three types q acc q rej accept reject loop

Halting We say M halts on x if there exists a sequence of configurations C 0, C 1,..., C k where C 0 is starting C i yields C i+1 C k is accepting or rejecting A TM M is a decider if it halts on every input Language L is decidable if it is recognized by a TM that halts on every input

Programming Turing Machines Description of Turing Machine: L 1 = {w#w: w {a, b}*} 1 2 3 4 5 6 7 8 Until you reach # and see a left-x Read and remember entry Write x Move right past # and past all xs If this entry is different, reject Otherwise Write x Move left past # and to right of first x If you see only xs followed by, accept xbbaa#xbbaa xxbaa#xbbaa xxbaa#xbbaa xxbaa#xxbaa xxbaa#xxbaa

Programming Turing Machines a/ar b/br x/xr L 1 = {w#w: w {a, b}*} q a1 x/xr #/#R 4 q a2 a/al b/bl x/xl a/al b/bl q 0 #/#R 1 q 1 / R 8 q acc q 2 #/#L 7 q 3 q rej everything else q b1 #/#R 4 q b2 a/ar b/br x/xr x/xr

Programming Turing Machines q 0 #/#R 1 a/ar b/br q a1 x/xr q 1 q b1 a/ar b/br #/#R / R 8 #/#R 4 4 x/xr q a2 q acc q b2 x/xr x/xr a/al b/bl x/xl q 2 #/#L 7 a/al b/bl q 3 input: aab#aab configurations: q 0 aab#aab xq a1 ab#aab xaq a1 b#aab xabq a1 #aab xab#q a2 aab xabq 2 #xab xaq 3 b#xab xq 3 ab#xab q 3 xab#xab xq 0 ab#xab

Programming Turing Machines L 2 = {a i b j c k : i j = k and i, j, k > 0 } High-level description of TM: For every a: Cross off the same number of bs and cs Uncross the crossed bs (but not the cs) Cross off this a If all as and cs are crossed off, accept. Σ = {a, b, c} Γ = {a, b, c, a, b, c, } aabbcccc aabbcccc aabbcccc aabbcccc aabbcccc aabbcccc aabbcccc aabbcccc

Programming Turing Machines L 2 = {a i b j c k : i j = k and i, j, k > 0 } Low-level description of TM: Scan input from left to right to check it looks like aa*bb*cc* Move the head to the first symbol of the tape For every a: how do we know? Cross off the same number of bs and cs Restore the crossed of bs (but not the cs) Cross off this a If all as and cs are crossed off, accept. how to do this?

Programming Turing Machines Implementation details: Move the head to the first symbol of the tape Put a special marker on top of first a Cross off the same number of bs and cs: Replace b by b Move right until you see a c Replace c by c Move left just past the last b If any bs are left, repeat Σ = {a, b, c} Γ = {a, b, c, a, b, c, a, a, } aabbcccc aabbcccc aaqbbcccc aabqbcccc aabbqcccc aabqbcccc aabbqcccc aabbcqccc aabbqcccc

Programming Turing Machines L 3 = {#x 1 #x 2...#x l : x i {0, 1}* and x i x j for each i j} High-level description of TM: #01#0011#1 On input w, For every pair of blocks x i and x j in w, Compare the blocks x i and x j If they are the same, reject. Otherwise, accept.

Programming Turing Machines L 3 = {#x 1 #x 2...#x l : x i {0, 1}* and x i x j for each i j} Low-level description: 0. If input is ε, or has exactly one #, accept. #01#0011#1 1. 2. Place a mark on the leftmost # (i.e. replace # by #) and move right Place another mark on next unmarked # (If there are no more #, accept) #01#0011#1 #01#0011#1

Programming Turing Machines L 3 = {#x 1 #x 2...#x l : x i {0, 1}* and x i x j for each i j} 3. current state: Compare the two strings to the right of marked #. If there are same, reject #01#0011#1 #01#0011#1 4. Move the right # to the right If not possible, move the left # to the next # and put the right # on the next If not possible, accept #01#0011#1 5. Repeat Step 3 #01#0011#1

Programming Turing Machines L 3 = {#x 1 #x 2...#x l : x i {0, 1}* and x i x j for each i j} 3. Compare the two strings to the right of marked #. If there are same, reject 4. Move the right # to the right If not possible, move the left # to the next # and put the right # on the next If not possible, accept #01#0011#1 #01#0011#1 accept

How to describe Turing Machines? Unlike for DFAs, NFAs, PDAs, we rarely give complete state diagrams of Turing Machines Usually we give a high-level description: A recipe about the workings of the Turing Machine Just like in earlier chapters, practice makes perfect!

Programming Turing Machines L 4 = { G : G is a connected undirected graph} Q: How do we feed a graph into a Turing Machine? A: We represent it by a string, e.g. 1 2 3 4 (1,2,3,4)((1,4),(2,3),(3,4)(4,2)) Convention for describing graphs: (nodes)(edges) no node must repeat edges are pairs (node 1,node 2 )

Programming Turing Machines L 4 = { G : G is a connected undirected graph} On input G, 0. Verify that G is the description of a graph (no vertex repeats; edges only go between nodes) 1. Mark the first node of G 2. Repeat until no new nodes are marked: For each node, mark it if it is attached to an already marked node x 1 2 x 3 4 x x 3. If all nodes are marked accept, otherwise reject.

Programming Turing Machines L 4 = { G : G is a connected undirected graph} (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) 1 2 3 4 (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) (1,2,3,4)((1,4)(2,3)(3,4)(4,2)) etc.

The Church-Turing Thesis All arguments [for the CT Thesis] which can be given are bound to be, fundamentally, appeals to intuition, and for this reason rather unsatisfactory mathematically. The arguments which I shall use are of three kinds: 1. A direct appeal to intuition 2. A proof of the equivalence of two definitions (In case the new definition has greater intuitive appeal) 3. Giving examples of large classes of numbers which are computable. 1936: On Computable Numbers, with an Application to the Entscheidungsproblem Section 9. The extent of the computable numbers