Introduction to Turing Machines

Similar documents
Turing Machines: An Introduction

3515ICT Theory of Computation Turing Machines

CS 3719 (Theory of Computation and Algorithms) Lecture 4

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

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

Turing Machines, Part I

Computability Theory

Notes on Complexity Theory Last updated: August, Lecture 1

1 Definition of a Turing machine

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

Introduction to Automata Theory. Reading: Chapter 1

Automata and Computability. Solutions to Exercises

Computational Models Lecture 8, Spring 2009

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Reading 13 : Finite State Automata and Regular Expressions

The Halting Problem is Undecidable

24 Uses of Turing Machines

CAs and Turing Machines. The Basis for Universal Computation

Lecture 2: Universality

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Regular Languages and Finite Automata

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

6.2 Permutations continued

Chapter 7 Uncomputability

Theory of Computation Chapter 2: Turing Machines

Regular Languages and Finite State Machines

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

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Deterministic Finite Automata

NUMBER SYSTEMS. William Stallings

NP-Completeness and Cook s Theorem

Universal Turing Machine: A Model for all Computational Problems

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

8 Divisibility and prime numbers

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Regular Expressions and Automata using Haskell

Lecture 36: Turing Machines [Fa 14]

Oracle Turing machines faced with the verification problem

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Handout #1: Mathematical Reasoning

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

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

The Little Man Computer

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Introduction to Theory of Computation

Row Echelon Form and Reduced Row Echelon Form

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

26 Integers: Multiplication, Division, and Order

Complexity of Algorithms

Automata and Formal Languages

Formal Grammars and Languages

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Universality in the theory of algorithms and computer science

Fundamentele Informatica II

Basic Proof Techniques

Finite Automata. Reading: Chapter 2

Models of Sequential Computation

4.6 The Primitive Recursive Functions

Near Optimal Solutions

Turing Machines, Busy Beavers, and Big Questions about Computing

The last three chapters introduced three major proof techniques: direct,

SECTION 10-2 Mathematical Induction

Overview of E0222: Automata and Computability

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

How To Understand The Theory Of Computer Science

Turing Machines and Understanding Computational Complexity

C H A P T E R Regular Expressions regular expression

CHAPTER 5 Round-off errors

Today s Topics. Primes & Greatest Common Divisors

MATH10040 Chapter 2: Prime and relatively prime numbers

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

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

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

The P versus NP Solution

Course Manual Automata & Complexity 2015

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

6.080/6.089 GITCS Feb 12, Lecture 3

Practice with Proofs

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

Representing Reversible Cellular Automata with Reversible Block Cellular Automata

THEORY of COMPUTATION

Basic Set Theory. 1. Motivation. Fido Sue. Fred Aristotle Bob. LX Semantics I September 11, 2008

Mathematical Induction

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Chapter 1. Computation theory

THE SEARCH FOR NATURAL DEFINABILITY IN THE TURING DEGREES

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

1. (First passage/hitting times/gambler s ruin problem:) Suppose that X has a discrete state space and let i be a fixed state. Let

Stanford Math Circle: Sunday, May 9, 2010 Square-Triangular Numbers, Pell s Equation, and Continued Fractions

Computation Beyond Turing Machines

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

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

8 Primes and Modular Arithmetic

Compiler Construction

Finite Automata and Regular Languages

Transcription:

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 1/2 Introduction to Turing Machines SITE : http://www.sir.blois.univ-tours.fr/ mirian/

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 2/2 Problems that computers cannot solve Problem: What a program does? Not knowing when, if ever, something will occur is the ultimate cause of our inability to tell what a program does

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 3/2 Programs that print Hello,Word (1) Kernighan and Ritchie s hello-world program main() { printf("hello, world"); }

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 4/2 Programs that print Hello,Word (2) Femat s last theorem expressed as a hello-world program main() { int n, total, x, y, z; scanf("%", &n); total = 3; while (1) { for (x = 1; x <= total -2; x++) for (y = 1; y <= total -1 ; y++) { z = total - x -y; if (exp(x, n) + exp (y, n) == exp(z, n)) printf ("hello, word"); } total ++ } }

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 5/2 Programs that print Hello,Word (3) The program (Fermat) takes an input n and looks for positive integer solutions to equation x n + y n = z n If the program finds a solution, it prints hello, world If it never finds integer x, y, z to satisfy the equation, then it continues searching forever, and never prints hello, world If the value of n is 2, then it will find combinations of integers and thus: For input n = 2 the program prints hello, world For any integer n > 2, the program will never find a triple of positive integers to satisfy x n + y n = z n (300 years to prove!)

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 6/2 Our hello-world problem Determine whether a given C program, with a given input, prints hello, world as the first 12 characters that it prints Is it possible to have a program that proves the correction of programs? Any of the problems that mathematicians have not been able to resolve can be turned into a question of the form Does this program, with this input, print hello, world? Is it possible to have a program that could examine any program P and input I for P, and tell whether P, run with I as its input, would print hello, world?

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 7/2 The Hypothetical "Hello World" Tester I P Hello-word tester H Yes No Assume there is a program (H) that takes as input A program P Input I and tells whether P within input I prints hello, world (Output is either Yes or No) If a problem has an algorithm like H, that always tells correctly whether an instance of the problem has answer Yes or No, then the problem is said to be decidable. Otherwise, the problem is undecidable. GOAL: To prove that H does not exist (proof by contradiction).

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 8/2 The Hypothetical "Hello World" Tester I P Hello-word tester H1 Yes hello, word Assume H exists. First modification: H1 prints hello, world exactly when H would print No

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 9/2 The Hypothetical "Hello World" Tester P Hello-word tester H2 Yes hello, word We want to restrict H1 so it: Takes only input P, not P and I. Asks what P would do if its inputs were its own code, i.e., what would H1 do on inputs P as program and P as input I as well? Second modification: H2 first reads the entire input P and stores it in an array A. H2 then simulates H1 but whenever H1 would read input from P or I, H2 reads from the stored copy in A.

Whichever output we suppose H2 makes, we can argue that it makes the other output. A PARADOX!!!! Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 10/2 How can we prove that H2 cannot exist? H2 Hello-word tester H2 Yes hello, word What H2 does when given itself as input? H2, given any program P as input: Makes output Yes if P prints hello, world when given itself as input. Prints hello, world if P (given itself as input) does not print hello, world. Suppose that H2 makes the output Yes: Then the H2 in the box is saying about its input H2 that H2 (given itself as input) prints hello, world as its first output. But we just supposed that the first output H2 makes in this situation is Yes! Thus it appears that the output of the box above is hello, world. But if H2 (given itself as input) prints hello, world, then the output of the box must be Yes

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 11/2 Undecidable Problems and Reduction A problem that cannot be solved by computer is called undecidable A problem is the question of deciding whether a given string is a member of some particular language. How to prove that a given problem is undecidable? Once we have one problem that we know is undecidable, we no longer have to prove the existence of a paradoxical situation. It is sufficient to show that if we could solve the new problem, then we could use that solution to solve a problem we already know is undecidable This strategy is called reduction

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 12/2 Reduction of P 1 to P 2 w x P 1 Instance Construct P 2 DECIDE YES Instance Undecidable Let P 1 be an undecidable problem (we know that) Let P 2 be a new problem that we would like to prove is undecidable as well We invent a construction that converts instances of P 1 into instances of P 2, i.e.: any string in the language P 1 is converted into a string un the language P 2 and and any string that is not in the language of P 1 is converted into a string that is not in the language of P 2. NO

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 13/2 Reduction of P 1 to P 2 Once we have this construction, we can solve P 1 as follows: Given an instance of P 1, i.e., given a string w that may or may not be in the language P, apply the construction algorithm to produce a string x. Test whether x is in P 2, and give the same answer about w and P 1. If w P 1, then x P 2 ; so the algorithm says YES If w P 1, then x P 2 ; so the algorithm says NO Since we assumed that NO algorithm to decide the membership of a string in P 1 exists, we have a proof BY CONTRADICTION, that the hypothetical decision algorithm for P 2 does not exist P 2 is undecidable What are you doing? We prove that: If P 2 is decidable then P 1 is decidable This is the same as to prove the contrapositive of the above statement: If P 1 is undecidable then P 2 is undecidable

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 14/2 Propose of the theory of undecidable problems To provide guidance to programmers about what they might or might not be able to accomplish through programming Pragmatic impact: Intractable problems: Decidable problems. Require large amount of time to solve them. Contrary to undecidable problems, which are usually rarely attempted in practice, the intractable problems are faced everyday. Yield to small modifications in the requirements or to heuristc solutions. We need tools that allow us to prove everyday questions undecidable or intractable We need to rebuild our theory of undecidability, based not on C programs, but based on a very simple model of computer called Turing Machine

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 15/2 The Turing Machine Informally... TM is essentially a finite automaton that has a single tape of infinite length on which it may read and write data. Advantage of TM over programs as representation of what can be computed: TM is sufficiently simple that we can represent its configuration precisely, using a simple notation much like ID s of a PDA. History 1936: Alan Turing proposed the TM as a model of any possible computation. This model is computer-like, rather than program-like, even though true electronic or electromechanical computers were several years in the future. All the serious proposals for a model of computation have the same power; i.e., they compute the same functions and recognize the same languages.

Notation for the TM Finite control B B...... B B... X 1 X 2 X i X n Finite control: can be in any of a finite set of states Tape: divided into cells; each cell can hold one of a finite number of symbols. Initially the input (a finite-length string) is placed on the tape All other tape cells initially hold a special symbol: blank Blank is tape symbol (not an input symbol) Tape head: always positioned at one of the tape cell. Initially, the tape head is at the leftmost cell that holds the input. Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 16/2

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 17/2 A move of the TM A move of the TM is a function of the state of the finite control and the tape symbol scanned. In one move the TM will 1. Change state 2. Write a tape symbol in the cell scanned. 3. Move the tape head left or right

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 18/2 TM: Formal notation M = (Q,Σ,Γ, δ, q 0, B, F) Q: The finite set of states of the finite control Σ: The finite set of input symbols Γ: The complete set of tape symbols; Σ is always a subset of Γ δ: The transition function The arguments of δ(q, X) are: a state q and a tape symbol X. The value of δ(q, X), if it is defined, is (p, Y, D) where: p is the next state, in Q Y is the symbol, in Γ, written in the cell being scanned, replacing whatever symbol was there. D is a direction (either L or R), telling us the direction in which the head moves. q 0 : The start state (q 0 Q) in which the finite control is found initially. B: blank symbol (B Γ but B Σ). F : the set of final or accepting states (F Q).

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 19/2 Instantaneous Descriptions for TM We use the instantaneous description to describe the configuration. An ID is represented by the string: where: X 1 X 2...X i 1 qx i X i+1...x n 1. q is the state of the TM. 2. The tape head is scanning the ith symbol from the left. 3. X 1 X 2...X n is the portion of the tape between the leftmost and the rightmost nonblank

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 20/2 Moves (1) Let M = (Q,Σ,Γ, δ, q 0, B, F). We use the notation M (or ) to represent moves of a TM M from one configuration to another. M is used as usual. The next move is leftward: If δ(q, X i ) = (p, Y, L) then: Exceptions: X 1 X 2... X i 1 q X i X i+1... X n M X 1 X 2... X i 2 p X i 1 Y X i+1... X n 1. If i = 1, then M moves to the blank to the left of X 1 qx 1 X 2... X n M p B Y X 2... X n 2. If i = n and Y = B, then the symbol B written over X n joins the infinite sequence of trailing blanks and does not appear in the next ID. X 1... X n 1 qx n M X 1 X 2... X n 2 p X n 1

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 21/2 Moves (2) The next move is rightward: If δ(q, X i ) = (p, Y, L) then: Exceptions: X 1 X 2... X i 1 q X i X i+1... X n M X 1 X 2... X i 2 X i 1 Y p X i+1... X n 1. If i = n then the i + 1st cell holds a blank, and that cell was not part of the previous ID. X 1... X n 1 q X n M X 1 X 2... X n 1 Y p B 2. If i = 1 and Y = B, then the symbol B written over X 1 joins the infinite sequence of trailing blanks and does not appear in the next ID. q X 1 X 2... X n M p X 2... X n

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 22/2 A TM for the language {0 n 1 n n 1} M = ({q 0, q 1, q 2, q 3, q 4 }, {0,1}, {0,1, X, Y, B}, δ, q 0, B, {q 4 }) State Symbol 0 1 X Y B q 0 (q 1, X, R) - - (q 3, Y, R) - q 1 (q 1,0, R) (q 2, Y, L) - (q 1, Y, R) - q 2 (q 2,0, L) - (q 0, X, R) (q 2, Y, L) - q 3 - - - (q 3, Y, R) (q 4, B, R) q 4 - - - - -

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 23/2 Transition diagram for TM Y/Y 0/0 q 0 q 1 q 2 0/X 1/Y Y/Y 0/0 Y/Y X/X q 3 B/B q 4 Y/Y q 0 0011 Xq 1 011 X0q 1 11 Xq 2 0Y 1 q 2 X0Y 1 Xq 0 0Y 1 XXq 1 Y 1 XXY q 1 1 XXq 2 Y Y Xq 2 XY Y XXq 0 Y Y XXY q 3 Y XXY Y q 3 B XXY Y Bq 4 B

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 24/2 The language of a TM Let M = (Q,Σ,Γ,δ,q 0,B,F) be a TM. Then L(M) is the set of strings w Σ such that q 0 w α p β for some state p F and any tape string α and β.

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 25/2 The language of a TM The set of languages we can accept using a TM is often called the recursively enumerable languages or RE languages. There is another notion of acceptance that is commonly used for TM: acceptance by halting. We say a TM halts if it enters a state q scanning a tape symbol X, and there is no move in this situation, i.e., δ(q, X) is undefined. We can always assume that a TM halts if it accepts Unfortunately, it is not always possible to require that a TM halts even if it does not accept Recursive languages: Languages for which TM do halt, regardless of whether or not they accept TM that always halt, regardless of whether or not they accept, are good model of an algorithm If an algorithm to solve a given problem exists, then we say the problem is decidable.

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 26/2 Alan Turing, the father of modern computer science. - Biography June 23, 1912 - June 7, 1954: English mathematician, logician, and cryptographer With the Turing test, Turing made a significant and characteristically provocative contribution to the debate regarding artificial intelligence: whether it will ever be possible to say that a machine is conscious and can think. He provided an influential formalisation of the concept of the algorithm and computation with the Turing machine, formulating the now widely accepted "Turing" version of the Church-Turing thesis: any practical computing model has either the equivalent or a subset of the capabilities of a Turing machine. During World War II, Turing worked at Britain s code breaking centre, and was for a time head of the section responsible for German Naval cryptanalysis. He devised a number of techniques for breaking German ciphers, including the method of the bombe, an electromechanical machine which could find settings for the Enigma machine. After the war, he worked at the National Physical Laboratory, creating one ofthe first designs for a stored-program computer, although it was never actually built. In 1947 he moved to the University of Manchester to work, largely on software, on the Manchester Mark I then emerging as one of the world s earliest true computers. In 1952, Turing was convicted of "acts of gross indecency" after admitting to a sexual relationship with a man in Manchester. He was placed on probation and required to undergo hormone therapy. Turing died after eating an apple laced with cyanide in 1954, sixteen days short of his 42nd birthday. His death is regarded by most as an act of suicide.

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 27/2

Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 28/2