CS20a: Turing Machines (Oct 29, 2002)

Similar documents
CS20a: Turing Machines (Oct 29, 2002)

CSE 105 THEORY OF COMPUTATION

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

Introduction to Turing Machines. Reading: Chapters 8 & 9

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

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

1 Showing Recognizability

Most General computer?

CSE 105 THEORY OF COMPUTATION

Turing Machines. Lecture 8

CSE 105 THEORY OF COMPUTATION

Decidability (What, stuff is unsolvable?)

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

Theory of Computation Turing Machine and Pushdown Automata

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSE 105 THEORY OF COMPUTATION

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Computability Theory

Lecture 13: Turing Machine

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

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

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

ACS2: Decidability Decidability

Turing Machines Part II

CS21 Decidability and Tractability

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

Turing Machines. Wolfgang Schreiner

Homework Assignment 6 Answers

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

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

Intro to Theory of Computation

Computational Models Lecture 8 1

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

Decidability (intro.)

TURING MAHINES

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

Introduction to Turing Machines

Turing Machines Part III

Turing Machine Recap

Computational Models Lecture 8 1

Computable Functions

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

Computational Models Lecture 8 1

Universal Turing Machine. Lecture 20

Decidability and Undecidability

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

CSCC63 Worksheet Turing Machines

CSE 105 THEORY OF COMPUTATION

Theory of Computation (IX) Yijia Chen Fudan University

CS481F01 Solutions 8

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

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

CS154, Lecture 10: Rice s Theorem, Oracle Machines

CSE 105 THEORY OF COMPUTATION

Reducability. Sipser, pages

CSE 105 THEORY OF COMPUTATION

Decidability: Church-Turing Thesis

16.1 Countability. CS125 Lecture 16 Fall 2014

Decidable Languages - relationship with other classes.

CpSc 421 Final Exam December 15, 2006

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

V Honors Theory of Computation

Properties of Context-Free Languages. Closure Properties Decision Properties

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

Turing Machines, diagonalization, the halting problem, reducibility

CpSc 421 Homework 9 Solution

Turing Machines Part II

Automata Theory CS S-12 Turing Machine Modifications

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

Turing Machines and the Church-Turing Thesis

Computability and Complexity

The Unsolvability of the Halting Problem. Chapter 19

CPSC 421: Tutorial #1

Homework 8. a b b a b a b. two-way, read/write

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

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Equivalent Variations of Turing Machines

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

Turing Machine Variants

CP405 Theory of Computation

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

MA/CSSE 474 Theory of Computation

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

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

Undecidable Problems and Reducibility

Limits of Computability

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

1 Unrestricted Computation

Decidability. Overview. Preliminaries to Halting Problem. Decidable Problems of Regular Languages. Decidable Problems of Context-Free Languages

Section 14.1 Computability then else

Turing Machine Extensions, and Enumerators

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

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

The Church-Turing Thesis

Transcription:

CS20a: Turing Machines (Oct 29, 2002) So far: DFA = regular languages PDA = context-free languages Today: Computability 1

Handicapped machines DFA limitations Tape head moves only one direction 2-way DFA has equivalent power Tape is read-only Tape length is a constant PDA limitations Tape head moves only one direction 2-way PDA has a little more power (can accept { ww w in Sigma* }, which is not context free) Tape is read-only, but stack is writable Stack has only LIFO (last-in, first-out) access Tape length is constant, but stack is not bounded What about: Writable, 2-way tape? Random-access stack? 2

Computability Computible Equivalence of DFAs (we gave an algorithm) String membership in a regular language (gave an algorithm) Determining valid executions of a PDA (there is an algorithm) Uncomputible Equivalence of CFGs Emptiness of the complement of a CFL (emptiness of CFL is computible) Whether a C program ever terminates How to prove it? 3

Turing machines Infinite read-write tape Blanks 0 1 1 0 0 b b b Finite Control Tape head 1. In state q a. read a symbol c b. print a new symbol c' c. move the tape head one position left or right d. goto state delta(q, c) 2. Accept iff the TM ever enters a final state 4

Turing machine formal definition A Turing Machine is a 7-tuple M = (Q, Σ, Γ,δ,s,b,F) Q is a finite set of states, Γ is a finite set of tape symbols, b Γ is the blank symbol, Σ Γ {b} is the set of input symbols, δ : Q Γ Q Γ {L, R} is a partial transition function, s Q is the start state, F Q is the set of final states 5

Nontermination A TM that does not terminate M = (Q, Σ, Γ,δ,s,b, F) Q ={q 0,q 1 } Σ ={a} Γ ={a, b} δ(q 0,a)= (q 0,a,R) s = q 0 F ={} 6

Nontermination execution 0 1 1 0 0 b b b q0 a 1 1 0 0 b b b q0 a a a a a b b b q0 a a a a a a b b q0 7

Termination A partial function U V is a function that may not be defined for every argument u U A TM that accepts Σ Q ={q 0 } Γ = Σ {b} δ(q 0,c) is arbitrary (possibly not defined) s = q 0 F ={q 0 } 8

Termination execution 0 1 1 0 0 b b b q0 in F 9

Instantaneous descriptions Aninstantaneous description ID (σ )isα 1 qα 2,where q is the current state of the TM, α 1 α 2 Γ if the contents of the tape (to the last non-blank symbol) The current symbol is the first symbol of α 2 10

Transitions Define a left transition a 1...a i 1 q a i,...,a n L a 1,...,a i 2 pc a i...a n Define a right transition a 1...a i 1 q a i,...,a n R a 1,...,a i 1 cp a i+1...a n A transition is either L or R 11

Executions An execution is either: A finite sequence σ 1 σ 2 σ n An infinite sequence σ 1 σ 2 where σ i σ i+1 12

Acceptance condition Let x Σ,andM = (Q, Σ, Γ,δ,q 0,b,F) M accepts x iff q 0 x α 1 pα 2 p F α 1 α 2 Γ 13

Definitions The languages accepted by TM are called recursively enumerable (r.e.) Recursion is related to recursion in programs, Enumerable means there is some TM that can enumerate the strings in the language (we'll see why) A language is recursive if it is accepted by some TM that halts on all inputs WLOG, we'll usually assume that TM halt if they enter a final state 14

Multi-tape machines Σ 3 0 0 1 0 b b b b 1 1 1 0 0 1 b b 0 1 0 b 0 b b b Finite Control

Making space To make space on the tape Remember a symbol, and replace it with a $ Move all the way to the right Move left, copying symbols one position to the right When reaching $, write the original symbol to the right Replace $ with a blank 16

Unary addition To add 0 m $0 n 0 n+m $ (in unary): Find $ Replace with 0, and move right to first blank Back up one space, and write $ 17

Copying To copy 0 n $ 0 n $0 n Move to first 0 Replace with X Move to first blank and replace with 0 Move back to X, move right, and repeat On reaching $, convert all Xs to0s 18

Unary multiplication To multiply 0 m $0 n 0 mn Place a $ at right end of tape Move to first 0, and replace with Y Move past first $ Invoke copy Move back to Y and repeat 19

Multi-head, multi-tape machines 0 0 1 0 b b b b 1 1 1 0 0 1 b b 0 1 0 b 0 b b b # # # For each move: delta(<i, ci>,..., <j, cj>) = <i+d,ci'>,..., <j+d, cj'> Scan right: collect <i, ci>,..., <j, cj> Scan left: write <i+d,ci'>,..., <j+d, cj'> Finite Control 20

RAM machines (standard processors) A RAM has: A finite number of random-access registers R1,, Rn A program counter PC A program I1,, In Example program (R1 factorial, R2 gets result, R0 is zero) fact: CMP R1,R0 JMP EQ,out MUL R2 R2*R1 DEC R1 JMP fact out: 21

A RAM #0$R1 #1$R2 #01$R3 #10$R4... PC #0 $CMP R1,R0 #01 $JMP EQ,110 #10 $MUL R2<-R2,R1 #11 $DEC R1 #101$JMP 0 Each move: 1. Use PC to find instruction For example: ADD Ri<-Rj,Rk 2. Find Ri,Rj,Rk 3. Perform arithmetic 4. Increment PC 5. Continue 22

Church s thesis The computable functions are the same as the partial recursive functions What is a computable function? Lots of models: l-calculus, mechanical devices, fluids and valves, DNA, quantum devices All of these seem to define the same set of functions (but some have better performance) 23

Definitions A problem is a yes-or-no question Are two CFGs equivalent? Does a TM halt on blank tape? An instance of a problem has specific arguments Does this TM halt on blank tape? An algorithm is a program that always halts (with the correct answer), so it is recursive A problem is decidable if it is recursive If not, it is undecidable Classically, every instance of a problem is decidable Not true constructively 24

Some properties The complement of a recursive set is recursive Given M that halts on all inputs, construct M that simulates M. If M halts and accepts, M halts and does not accept If M halts and does not accept, M halts and accepts The union/intersection of two recursive sets is recursive Simulate machine M1, then simulate machine M2 Union: accept if either accepts Intersection: accept if both accept If L and (Sigma* - L) are r.e., then L is recursive 25

Quiz 26

Writing down a Turing Machine Consider M = (Q, Σ, Γ,δ,s,b,F) Write it down as a sequence of symbols Kozen: write as 0 n #0 m #0 k #0 s #0 t #0 r #0 u #0 v # USe integer representations for states, symbols, etc. n = Q, m = Γ, k = Σ s, t, r are start, accept, reject states u and v are some translation of δ 27

Universal Turing Machines Next, build a universal Turing machine U that accepts L(U) {M#x x L(M)} U checks that M#x is a valid description Copy M to one tape, and x to another tape Use a scratch tape to represents current state, head position, etc. Simulate M: for each move: Figure out δ function from M Move the head, modify the tape x 28

Reals are uncountable Cantor s diagonalization argument 0 0. 7 3 5 9 2... 1 0. 3 7 7 1 8... 2 0. 0 0 1 0 0... 3 0. 9 7 9 8 4... 4 0. 8 1 5 2 5... 5 0. 6 6 6 0 0... 0. 8 8 2 0 6... 29

Another diagonalization argument Input string Machine ε 0 1 10 01 11... Mε x x x M0 x x x M1 x x x M01 x x x Place an x iff M halts on x M10... x x x 30

Halting problem Problem: determine entries in the matrix Find a recursive machine K, given M#x K halts and accepts if M accepts x K halts and rejects if M does not terminate Is there such a machine? Suppose so, then build a new machine N, that, given x, runs K on M x #x and: Accepts if K rejects Loops forever of K accepts If K exists, then N does too; let N = M y N#y halts and accepts if N#y does not halt N#y loops forever if N#y halts 31