Theoretical Computer Science (Bridging Course) Turing Machines

Similar documents
3515ICT Theory of Computation Turing Machines

Turing Machines: An Introduction

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Automata and Computability. Solutions to Exercises

Chapter 7 Uncomputability

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

Computability Theory

24 Uses of Turing Machines

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Theoretical Computer Science (Bridging Course) Complexity

Turing Machines, Part I

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Theory of Computation Chapter 2: Turing Machines

Introduction to Turing Machines

1 Definition of a Turing machine

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Computational Models Lecture 8, Spring 2009

Complexity Classes P and NP

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Notes on Complexity Theory Last updated: August, Lecture 1

Algebraic Computation Models. Algebraic Computation Models

Chapter 1. Computation theory

Regular Expressions and Automata using Haskell

CAs and Turing Machines. The Basis for Universal Computation

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

The Halting Problem is Undecidable

Lecture 2: Universality

Welcome to... Problem Analysis and Complexity Theory , 3 VU

Reading 13 : Finite State Automata and Regular Expressions

6.080/6.089 GITCS Feb 12, Lecture 3

Universality in the theory of algorithms and computer science

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Introduction to Logic in Computer Science: Autumn 2006

Quantum and Non-deterministic computers facing NP-completeness

Universal Turing Machine: A Model for all Computational Problems

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Models of Sequential Computation

Introduction to Automata Theory. Reading: Chapter 1

Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Finite Automata. Reading: Chapter 2

Regular Languages and Finite State Machines

The Classes P and NP

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Simulation-Based Security with Inexhaustible Interactive Turing Machines

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

C H A P T E R Regular Expressions regular expression

Notes on NP Completeness

How To Compare A Markov Algorithm To A Turing Machine

NP-Completeness and Cook s Theorem

Finite Automata and Regular Languages

FINITE STATE AND TURING MACHINES

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

Computer Science Theory. From the course description:

4.6 The Primitive Recursive Functions

Finite Automata. Reading: Chapter 2

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN

MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

Regular Languages and Finite Automata

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

How To Understand The Theory Of Computer Science

Outline 2. 1 Turing Machines. 2 Coding and Universality. 3 The Busy Beaver Problem. 4 Wolfram Prize. 5 Church-Turing Thesis.

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Factoring & Primality

Lecture summary for Theory of Computation

Informatique Fondamentale IMA S8

SECTION 10-2 Mathematical Induction

CS 301 Course Information

Automata on Infinite Words and Trees

Intrusion Detection via Static Analysis

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Prime Numbers. Difficulties in Factoring a Number: from the Perspective of Computation. Computation Theory. Turing Machine 電 腦 安 全

Model 2.4 Faculty member + student

Genetic programming with regular expressions

THEORY of COMPUTATION

Fast nondeterministic recognition of context-free languages using two queues

6.852: Distributed Algorithms Fall, Class 2

Two-dimensional Languages

The P versus NP Solution

Turing Machines and Understanding Computational Complexity

Hypercomputation: computing more than the Turing machine

Graph Theory Origin and Seven Bridges of Königsberg -Rhishikesh

Hilberts Entscheidungsproblem, the 10th Problem and Turing Machines

Automata and Formal Languages

Compiler Construction

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Introduction to NP-Completeness Written and copyright c by Jie Wang 1

Complexity of Algorithms

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

SOLVING NARROW-INTERVAL LINEAR EQUATION SYSTEMS IS NP-HARD PATRICK THOR KAHL. Department of Computer Science

Transcription:

Theoretical Computer Science (Bridging Course) Turing Machines Gian Diego Tipaldi

Topics Covered Turing machines Variants of Turing machines Multi-tape Non-deterministic Definition of algorithm The Church-Turing Thesis

Finite State Automata Can be simplified as follow state control a a b b input State control for states and transitions Tape to store the input string

Pushdown Automata Introduce a stack component state control stack a a b a a b b input Symbols can be read and written there

Turing Machine (TM) Introduce an infinite tape state control a a b b input Symbols can be read and written there Move left and right on the tape Machine accepts, rejects, or loops

Turing Machine (TM) Let s design one for the language F = w#w w 0,1 } How will it work? Remember: It has the string on the tape It can go left and right It can write symbols on the tape

Turing Machine (TM) F = w#w w 0,1 } The machine does this: Scan to check there is only one # Zig-zag across # and read symbols If do not match reject If they match write the symbol x If all symbols left to # matche, accept

Turing Machine (TM) F = w#w w 0,1 } w 1 F = "011000#011000" 0 1 1 0 0 0 # 0 1 1 0 0 0 X 1 1 0 0 0 # 0 1 1 0 0 0 X 1 1 0 0 0 # X 1 1 0 0 0 X 1 1 0 0 0 # X 1 1 0 0 0 X X 1 0 0 0 # X 1 1 0 0 0 X X X X X X # X X X X X X

Formal Definition of a TM A Turing machine is a 7-tuple (Q, Σ, Γ, δ, q o, q accept, q reject ) Q is the set of states Σ is the input alphabet, without Γ is the tape alphabet and Γ, Σ Γ δ: Q Γ Q Γ {L, R} is the transition function q 0 Q is the initial state q accept, q reject Q are the final states

TM Configurations Describe the state of the machine Written as C = uq i v where: q i is the current state of the machine uv is the content of the tape The head stays at the first symbol of v

TM Transitions A configuration C 1 yields C 2 if the machine can go from C 1 to C 2 in 1 step uaq i bv yields uq j acv if δ q i, b = q j, c, L uaq i bv yields uacq j v if δ q i, b = q j, c, R Note: cannot go over the left border!

TM Acceptance The machine starts at q 0 w The machine accepts at q accept The machine rejects at q reject An input is accepted if there is C 1,, C k The machine starts at C 1 Each C i yields C i+1 C k is an accepting state

Computations and Deciders Three possible outcomes: It ends in an accept state It ends in a reject state It does not end (loops forever) Accept and reject are halting states Loops are not halting A Decider halts on every input

TMs and Languages The strings a TM M accepts define the language of M, L(M) A language is Turing recognizable (recursively enumerable) if some TM recognizes it A language is Turing decidable (recursive) if some TM decides it

TM Example TM M 2 recognizes the language consisting of all strings of zeros with their length being a power of 2. In other words, it decides the language A = 0 2n n 0}.

TM Example A = 0 2n n 0} 1.Sweep left to right accross the tape, crossing off every other 0 2.If the tape has a single 0, accept 3.If the tape has more than one 0 and the number of 0s is odd, reject 4.Return the head to the left 5.Go to stage 1

TM Example 0 L x L x R q 5 x R q 1 q 2 0,R 0 x,r q 3 R x R R 0 R 0 x,r q reject q accept q 4 x R R

Another TM Example F = w#w w 0,1 } 1.Check for #, if not reject 2.Zig-zag across and cross off same symbols. If not same, reject 3.If all left of # are crossed, check for non crossed symbols on the right side 4.If none, accept, otherwise reject

Another TM Example

Variants of Turing Machines Mostly equivalent to the original Example: consider movements as {L,R,S}, where S means stay still Equivalent to original, represent S as two transitions: first R, then L or vice versa

Multi-Tape Turing Machine Include multiple tapes and heads 0 0 1 1 M b a b a b Input on first tape, the others blank Transitions δ: Q Γ k Q Γ k L, R, S k

Equivalence Result Theorem 3.13: Every multitape Turing machine has an equivalent single-tape Turing machine.

Equivalence Result Theorem 3.13: Every multitape Turing machine has an equivalent single-tape Turing machine. 0 0 1 1 M b a b a b

Equivalence Result Theorem 3.13: Every multitape Turing machine has an equivalent single-tape Turing machine. 0 0 1 1 M b a b a b S # 0 0 1 1 # b a b # a b

Proof of Theorem 3.13 Consider a input w 1 w 2 w k Add dotted symbols for the head Put all the input on the single tape #w 1 w 2 w k # # # # Simulate a single move Scan from first # to last to get the heads Re-run to update the tape If head symbols go to the right # write a blank and shift the tape content

Equivalence Result Corollary 3.15: A language is Turing-recognizable if and only if some multi-tape Turing machine recognizes it Proof: Forward: an ordinary machine is a special case of a multi-tape Backward: see Theorem 3.13

Intermezzo: Programming Brainfuck : language simulating a TM Character Meaning > increment the data pointer (to point to the next cell to the right). R < decrement the data pointer (to point to the next cell to the left). L + increment (increase by one) the byte at the data pointer. - decrement (decrease by one) the byte at the data pointer.. output a character, the ASCII value of which being the byte at the data pointer., accept one byte of input, storing its value in the byte at the data pointer. [ ] if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command. if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command *. (http://en.wikipedia.org/wiki/brainfuck)

Non Deterministic TMs (NTMs) Transition function changed into δ: Q Γ P Q Γ L, R δ q, a = q 1, b 1, L,, q k, b k, R q 1 q 1 Same idea as for NFAs q 1 q 2 q 3 q 1 q 3 q 1 q 2 q 3 q 4 q 1 q 2 q 3 q 4 q 4 q 1 q 3 q 4 q 4

Equivalence of NTMs and TMs Theorem 3.16: Every nondeterministic Turing machine has an equivalent deterministic Turing machine. Idea: Three tapes: input, simulation, index Simulator to perform computation Index to trace the path in the tree

Equivalence of NTMs and TMs Theorem 3.16: Every nondeterministic Turing machine has an equivalent deterministic Turing machine. Idea: Three tapes: input, simulation, index Simulator to perform computation Index to trace the path in the tree

Proof of Theorem 3.16 1. Copy the input from tape 1 to 2 2. Use tape 2 to simulate N on one branch of computation a. Consult tape 3 to get the transition b. Abort if empty symbol, invalid or reject c. Accept if accept state 3. Replace the string on 3 with the lexicographically next one 4. Repeat from 1.

NTMs and Languages Corollary 3.18: A language is Turing-recognizable if and only if some nondeterministic Turing machine recognizes it. Corollary 3.19: A language is decidable if and only if some nondeterministic Turing machine decides it.

Enumerators Recursively enumerable languages Recognized by TMs Alternative model: Enumerator state control a a b b work tape

Enumerators Enumerate the strings Start with empty tape Output tape (printer) Print strings instead of accepting them Printing in any order Strings might be duplicated

Equivalence Result Theorem 3.21: A language is Turing-recognizable if and only if some enumerators enumerate it. Proof: Forward: e have an enumerator E. We can build a machine T that 1. Run E and compare every string 2. If it appears, accept

Equivalence Result Backward: We have a machine T. We can build an enumerator E as this: 1. Ignore the input 2. For each i = 1,2, 1. Run T for i steps on each input in Σ 2. If any computation accepts, print it. E eventually prints all string T accepts

Other Variants of TMs Many other variants of TMs exist All equivalent in power under reasonable assumptions Turing complete languages The class of algorithms described identical for all these languages. For a given task, one type of language may be more elegant or simple.

Definition of Algorithm Precise definition only in 20 th century Informal idea was already present Collection of instructions for a task Formal definition needed to be found

Anecdote: David Hilbert Famous mathematician Int. congress of Maths in 1900 Formulated 23 math problems The 10 th problem said: Devise an algorithm to test whether a polynomial has an integral root Algorithm = a process according to which it can be determined by a finite number of operations

Anecdote: David Hilbert Mathematicians believed it existed We know it is not possible A formal definition of algorithm was needed to prove it Alonso Church : λ-calculus Alan Turing: Turing machines Church Turing Thesis: Intuitive algorithm = TM algorithm

Formal Definition of Algorithm Let s rephrase Hilbert problem Consider the set D = p p is a polynomial with integer root} Hilbert problem asks if D is decidable Unfortunately it is not Fortunately is Turing recognizable

Formal Definition of Algorithm Consider a simpler problem D 1 = p p is a poly. over x with integer root} Build a TM that recognizes it 1. Input is a polynomial over x 2. Evaluate p with x=0,1,-1,2,-2, 3. If polynomial evaluates to 0, accept

Formal Definition of Algorithm Describe an algorithm equals to describe a Turing machine Three possibilities: Formal description (low level) Implementation description (mid level) English description (high level) We will describe machines in high level

Turing Machine Description Input is always a string Objects represented as strings Encoding is irrelevant (equivalence) TM Algorithm will be high level First line describe the input Indentations describe blocks

Example description A = { G G is a connected undirected graph} Remember the definition of connected?

Example description A = { G G is a connected undirected graph} Remember the definition of connected? Every node is reachable from every one 4 1 G = 3 2

Example description 4 1 G = <G> = (1,2,3,4) ((1,2),(2,3),(3,1),(1,4)) 3 2 M = On input <G>, the encoding of a graph G: 1. Select the first node of G and mark it. 2. Repeat the following stage until no new nodes are marked. 1. For each node in G, mark it if it is attached by an edge to a node that is already marked. 3. Scan all the nodes of G to determine whether they all are marked. If yes, accept; otherwise reject.

Summary Turing machines Variants of Turing machines Multi-tape Non-deterministic The definition of algorithm The Church-Turing Thesis