Part I: Definitions and Properties

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

1 Showing Recognizability

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

ECS 120 Lesson 15 Turing Machines, Pt. 1

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

Computable Functions

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

Computability Theory. CS215, Lecture 6,

Computability and Complexity

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Automata Theory CS S-12 Turing Machine Modifications

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

Most General computer?

CS21 Decidability and Tractability

Variants of Turing Machine (intro)

CS20a: Turing Machines (Oct 29, 2002)

CpSc 421 Final Exam December 15, 2006

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

Chapter 7 Turing Machines

Computation Histories

Decidability: Church-Turing Thesis

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

Turing Machine Variants

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

CS481F01 Prelim 2 Solutions

CSCC63 Worksheet Turing Machines

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

MA/CSSE 474 Theory of Computation

Turing s Thesis. Fall Costas Busch - RPI!1

16.1 Countability. CS125 Lecture 16 Fall 2014

Theory of Computation Turing Machine and Pushdown Automata

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

CP405 Theory of Computation

CSE 105 THEORY OF COMPUTATION

DM17. Beregnelighed. Jacob Aae Mikkelsen

X-machines - a computational model framework.

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

1 Definition of a Turing machine

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

CS 21 Decidability and Tractability Winter Solution Set 3

Chapter 8. Turing Machine (TMs)

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

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

CPSC 421: Tutorial #1

TURING MAHINES

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

CS4026 Formal Models of Computation

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Turing Machines Part II

SCHEME FOR INTERNAL ASSESSMENT TEST 3

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

Chapter 3: The Church-Turing Thesis

ACS2: Decidability Decidability

Turing Machines. Chapter 17

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

Homework Assignment 6 Answers

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

Introduction to Turing Machines

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

Introduction to Languages and Computation

CSE 105 THEORY OF COMPUTATION

Undecidable Problems and Reducibility

Foundations of

Automata and Computability. Solutions to Exercises

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

Finite Automata. Finite Automata

Non-emptiness Testing for TMs

CSE 105 THEORY OF COMPUTATION

Automata and Computability. Solutions to Exercises

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

Decidability. William Chan

Finite Automata. Mahesh Viswanathan

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

CS20a: Turing Machines (Oct 29, 2002)

1 Unrestricted Computation

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

CS481F01 Solutions 6 PDAS

A Universal Turing Machine

Reducability. Sipser, pages

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

Automata Theory - Quiz II (Solutions)

The Power of One-State Turing Machines

Pushdown Automata. Chapter 12

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

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

Further discussion of Turing machines

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

MTAT Complexity Theory October 13th-14th, 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, diagonalization, the halting problem, reducibility

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

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

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

Computational Models Lecture 8 1

Introduction to Computers & Programming

The Church-Turing Thesis

Languages, regular languages, finite automata

Theory of Computation

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

Transcription:

Turing Machines

Part I: Definitions and Properties

Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States Q -- δ :Q Σ Q = Transition Functions Analog Machine Hard Wired, No Code Read Only, State is Memory

Push-Down Automata Push Down Automata (PDA) Finite State Automata with a Stack Can Write on the Stack -- More Memory in Stack -- Stack can be used for Counting Accept Halts in an Accepting State AND Stack is Empty PDA more Powerful than FSA Non-Deterministic (Analog?) Machine

Turing Machine Informal Definition Control Unit -- States Doubly infinite tape -- input -- output -- memory Tape reader Initial state (See Picture)

Turing Machine Machine with states -- finite automata Tape -- mostly blank Tape head -- on leftmost nonblank symbol

Turing Machine Formal Definition M = {Q, Σ, H, δ, s 0 } Q = set of states s 0 = initial state H = halting states Q Σ = tape alphabet δ :(Q H ) Σ Q Σ {R, L} -- go to new state -- write new symbol on tape -- replace old symbol -- move tape head to left or right -- list of 5-tuples -- (s, x; s, x, L / R)

Turing Machine Machine Move Change symbol under tape head Move tape head Change state Analog Machine? Hardware and Software Turing Machine = Computer (Hardware) 5-tuples = Program (Software) Functions M maps the input x to the output y and then halts. M is a partial function because M might not halt.

Diagrams of Turing Machines Diagrams States = Circles Arrows = Transition Functions -- From Current State to Next State Labels on Arrows = x / y /(L or R) -- Read x -- Write y -- Move Left or Right

Configurations of Turing Machines (q,w L,x, w R ) (q,w L x w R ) -- q = current state -- x = current symbol on tape -- w L = string of non blank symbols to the left of x -- w R = string of non blank symbols to the right of x

What a Turing Machine Can Do Halt -- Accept or Reject Loop -- Cycle Diverge -- Never Halt or Cycle

` Languages and Turing Machines Decidable Languages M Halts in Accept State x L M Halts in Reject State x L Semi Decidable Languages M Always Halts in Accept State x L M Might Loop or Diverge for x L

Decidable Languages L = {a n b n c n } -- Not Context Free L = {wc w w {a,b} } -- Not Context Free

Power of Turing Machine Lemma: L = {a n b n c n } can be recognized by a Turing Machine (L is not context free -- pumping theorem) Proof: If Tape Empty, Halt and Accept Otherwise, Replace first a with 1 Move Right to first b and Replace with 2 -- If no b or if c encountered first, Halt and Reject Move Right to first c and Replace with 3 -- If no c or if a encountered first, Halt and Reject Continue until all a s converted to 1 s If no b s or c s remain, Halt and Accept Otherwise, Halt and Reject

Functions and Turing Machines Turing Machines as Functions Input = Initial String (Non Blanks) on Tape -- x X = Domain Output = Final String on Tape when Machine Halts -- y Y = Range Function -- M : X Y -- M(x) = y Computable (Recursive) Functions -- Functions that can be Computed by Some Turing Machine

Examples Language Recognition x Σ = Domain = Strings Output: Range = {TRUE, FALSE} M recognizes L if and only if -- M Halts and Writes TRUE on the Tape when x L -- M Halts and Writes FALSE on the Tape when x L Functions on Natural Numbers Encode Natural Numbers as Binary (or Decimal) Strings -- Input and Output are Binary (Decimal) Strings Example: Adding 1 to a Binary Number -- Carrying Function

Part II: Equivalent Machines

Equivalent Machines for Simplifying Proofs 1. Multiple Tapes 2. Nondeterminism 3. One Way Tape 4. Two Stacks 5. One Queue

Multiple Tape Turing Machine Description Input on Tape 1 -- All Other Tapes Start Blank ª Output on Tape 1 -- Contents of All Other Tapes Ignored Move all Tape Heads Simultaneously -- Left, Right, or Stay in Same Location Halt

Simulating Multiple Tapes with One Tape Tape Alphabet Introduce New Tape Symbols to Represent with a Single Symbol -- Contents of Each Position on Each Tape -- Location of Each Tape Head -- 0, 1 Number of Tapes One New Symbol for Each Element of (Σ {0,1}) Program Replace Original Tape Symbols by New Tape Symbols Locate and Store (in State) Symbols at Current Head Locations Change Symbols to Simulate Each Head Move Replace New Tape Symbols by Corresponding Original Tape Symbols Halt

Nondeterministic Machines Non Deterministic Finite State Automata Simultaneous Transitions to Many Possible Different States No More Powerful than Deterministic Finite State Automata Non Deterministic Push Down Automata Simultaneous Transitions to Many Possible Different States and Stacks More Powerful than Deterministic Push Down Automata

Nondeterministic Turing Machine Simultaneous Transitions Many Possible Different States Multiple Possible Head Directions Writing Many Possible Different Symbols on Current Tape Location Accept or Reject Accept if at Least One Computation Accepts Reject if ALL Computations Reject

Non-Determinism and Languages Decidable (M Decides L) Finite Number of Paths for Each String Each Path Halts M Accepts w On at Least 1 Path w L Semi-Decidable (M Semi-Decides L) M Accepts w on at Least 1 Path w L M Need Not Halt for w L

Non-Determinism and Functions M Compute F For Each w in Domain F -- Every Path Halts -- Final String is the Same F(w) for Every Path

Simulating Nondeterminism Depth First Search No Why? Breadth First Search Yes Why?

Simulating 1 Two Way Tape with 3 One Way Tapes Tapes Tape #1 = Characters to the Right of Initial Position Tape #2 = Characters Introduced to the Left of Initial Position Tape #3 = Number of Operations in Unary (All 1 s) Simulation Initialize Tape #1 to Initial Characters; Tape #2, Tape 3 Blank Simulate All Moves to Right of Initial Position on Tape #1 Simulate All Moves to Left of Initial Position on Tape # 2 Update Number of Operations on Tape #3 Shift All Characters on Tape #1 to Right by #1 s on Tape #3 Move Characters from Tape #2 to Tape #1

Turing Machines and Push Down Automata Theorems 1. Every Push Down Automaton can be Simulated with a Turing Machine. 2. Every Turing Machine can be Simulated by a Push Down Automaton with 2 Stacks. 3. Turing Machines are more powerful than Push Down Automata with 1 Stack.

Theorem 1 Every Push Down Automaton can be Simulated by a Non-Deterministic Turing Machine with 2 Tapes Simulation Tape #1 = Characters in String -- Read Only -- Move Only to Right Tape #2 = Characters on Stack -- Left to Right on Tape Bottom to Top of Stack -- Head at Right End of Tape #2 (Top of Stack) -- Pop -- Scan Left Replacing Symbols by Blanks -- Push -- Scan Right Replacing Blanks by Symbols

Theorem 2 Every Turing Machine can be Simulated by a Push Down Automaton with 2 Stacks Simulation Stack #1 = Characters to Left of Head and Under Reading Head -- Left to Right Bottom to Top Stack #2 = Characters to Right of Reading Head -- Left to Right Top to Bottom Move Left Move Right Pop Stack #1 Pop Stack #2 Push Stack #2 Push Stack #1

Theorem 3 Turing Machines are more Powerful than Push Down Automaton with 1 Stack. Proof Turing Machines can Recognize the Language L = {a n b n c n }.

Turing Machine with Queue Description Finite State Automata with a Queue Push Down Automata with Queue in Place of Stack Simulating a Turing Machine Queue: Treat as a Loop -- Turing Tape = Queues in Reverse Order (First In First Out) Move Right = Move Head of Queue to Tail of Queue -- If Blank, Insert New Symbol to Tail of Queue Move Left = Move All but the First Symbol from the Head to the Tail -- If Blank, Insert an Additional Symbol onto Tail and Move All Other Symbols From Front to Back of Queue

Simulating a Digital Computer with a Turing Machine Seven Tapes Tape #1 = Memory = Program + Data Tape #2 = Program Counter = Index into Memory in Tape #1 Tape #3 = Address Register Tape #4 = Accumulator Tape #5 = Operation Code of Current Instruction Tape #6 = Input File Tape #7 = Output File

Part III: Universal Turing Machines

Encoding Turing Machines States Number the States in Any Order Code the Numbers in Binary -- Accepting State = y-binary -- Rejecting State = n-binary -- Other States = q-binary Symbols Number the Symbols in Any Order Code the Numbers in Binary Assign a-binary to Each Symbol

Godel Numbering for Special Symbols Symbol Godel Number q 0000 y 0001 n 0010 a 0011 L 0100 R 0101 ( 0110 ) 0111, 1000

Encoding Turing Machines (continued) Transition Functions (State, Input Character, New State, Output Character, Move) (q-binary, a-binary, q-binary, a-binary, L or R) Turing Machine List of Transition Functions Godel Number = Binary Number Corresponding to List of Transition Functions

Universal Turing Machine Input Encoding of Any Turing Machine M -- Also could input just the Number encoding M in Lexicographic Order Encoding of Input Tape for M 3 Tapes Tape #1 = Tape of Input for M Tape #2 = Encoding of (Transition Functions) for M Tape #3 = Current State of M

Universal Turing Machine (continued) Simulation Find Current State of M -- Tape #3 Find Current Character -- Tape #1 Find Appropriate Transition Function for State and Character -- Tape #2 Apply Transition Function -- Update Tape #1 and Tape #3 Continue Until in Halting State Conclusion Universal Turing Machine with input <M, w> reports same result as Turing Machine M on Input w

Universal Turing Machine as Digital Computer Machine Move Change symbol under tape head -- Tape #1 Move tape head -- Tape #1 Change state -- Tape #3 Hardware Universal Turing Machine Software Transition Functions = Program Data = Input String

Number of Turing Machines How Many Turing Machines? Turing Machine Finite List of 5-tuples -- δ :Q Σ Q Σ {R, L} -- (q, x; q, x, L / R) Number of finite lists of 5-tuples in countable -- # Turing machines with 1 state is countable -- # TM with 1 state = # 5-tuples = 2 Σ 2 -- # Turing machines with n states is countable -- # TM with n states = # 5-tuples = 2n 2 Σ 2 Countable union of countable sets is countable Number of Turing machines is countable

Non Computable Functions Existence of Non Computable Functions -- Counting Argument There are only countably many Turing machines -- Turing machines can be listed in Lexicographic order There are uncountably many functions { f : N {0, 1} } P(N) Existence of Non Computable Functions -- Diagonalization Argument List the Turing Machines List all Possible Input Strings Set F(w i ) = 0 if M i (w i ) =1 =1 if M i (w i ) = 0 F not in List Exist Non-Computable Functions