Finite State Machines 3 95-771 Data Structures and Algorithms for Information Processing 1.

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

CS 345: Chapter 9 Algorithmic Universality and Its Robustness
Variants of Turing machines
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
Cook’s Theorem The Foundation of NP-Completeness.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Variants.
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
P, NP, PS, and NPS By Muhannad Harrim. Class P P is the complexity class containing decision problems which can be solved by a Deterministic Turing machine.
CS5371 Theory of Computation Lecture 11: Computability Theory II (TM Variants, Church-Turing Thesis)
Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Courtesy Costas Busch - RPI1 Turing Machines. Courtesy Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
Costas Busch - RPI1 Turing Machines. Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
Chapter 9 Turing Machine (TMs).
Finite State Machines Data Structures and Algorithms for Information Processing 1.
CSE202: Introduction to Formal Languages and Automata Theory Chapter 9 The Turing Machine These class notes are based on material from our textbook, An.
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Part 1 – Pages COMPUTABILITY THEORY.
1 Turing Machines Reading: Chapter 8. 2 Turing Machines are… Very powerful (abstract) machines that could simulate any modern day computer (although very,
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
Lecture 16b Turing Machines Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE 355 Foundations.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 8.4 Extensions to the Basic TM Extended TM’s to be studied: Multitape Turing machine Nondeterministic Turing machine The above extensions make no increase.
Chapter 9 Turing Machines What would happen if we change the stack in Pushdown Automata into some other storage device? Truing Machines, which maintains.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Chapters 11 and 12 Decision Problems and Undecidability.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
Turing’s Thesis Costas Busch - LSU.
CSE202: Introduction to Formal Languages and Automata Theory
8. Introduction to Turing Machines
Busch Complexity Lectures: Turing Machines
Linear Bounded Automata LBAs
Turing Machines.
Pushdown Automata.
Turing Machines 2nd 2017 Lecture 9.
Turing Machines Acceptors; Enumerators
Chapter 9 TURING MACHINES.
COSC 3340: Introduction to Theory of Computation
Jaya Krishna, M.Tech, Assistant Professor
Decidable Languages Costas Busch - LSU.
8. Introduction to Turing Machines
CS21 Decidability and Tractability
Formal Languages, Automata and Models of Computation
Decidability and Tractability
Instructor: Aaron Roth
Hopcroft, Motawi, Ullman, Chap 8
Turing Machines Everything is an Integer
Presentation transcript:

Finite State Machines Data Structures and Algorithms for Information Processing 1

Notes taken with modifications from “Introduction to Automata Theory, Languages, and Computation” by John Hopcroft and Jeffrey Ullman, Data Structures and Algorithms for Information Processing

Deterministic Finite-State Automata (review) A DFSA can be formally defined as A = (Q, , , q 0, F): – Q, a finite set of states – , a finite alphabet of input symbols – q 0  Q, an initial start state – F  Q, a set of final states –  (delta): Q x   Q, a transition function Data Structures and Algorithms for Information Processing

Pushdown Automata(review) A pushdown automaton can be formally defined M = (Q, , , ,q 0,F): – Q, a finite set of states – , the alphabet of input symbols – , the alphabet of stack symbols – , Q x  x   Q x  – q 0, the initial state – F, the set of final states Data Structures and Algorithms for Information Processing

Turing Machines The basic model of a Turing machine has a finite control, an input tape that is divided into cells, and a tape head that scans one cell of the tape at a time. The tape has a leftmost cell but is infinite to the right. Each cell of the tape may hold exactly one of a finite number of tape symbols. Initially, the n leftmost cells, for some finite n >= 0, hold the input, which is a string of symbols chosen from a subset of the tape symbols called the input symbols. The remaining infinity of cells each hold the blank, which is a special symbol that is not an input symbol Data Structures and Algorithms for Information Processing

A Turing machine can be formally defined as M = (Q, , , ,q 0,B,F):, Where – Q, a finite set of states – , is the finite set of allowable tape symbols – B, a symbol of , is the blank – , a subset of  not including B, is the set of input symbols –  : Q x   Q x  x {L, R} (  may, however, be undefined for some arguments) – q 0 in Q is the initial state – F  Q is the set of final states Data Structures and Algorithms for Information Processing

Turing Machine Example The design of a Turing Machine M to decide the language L = {0 n 1 n, n >= 1}. This language is decidable. Initially, the tape of M contains 0 n 1 n followed by an infinity of blanks. Repeatedly, M replaces the leftmost 0 by X, moves right to the leftmost 1, replacing it by Y, moves left to find the rightmost X, then moves one cell right to the leftmost 0 and repeats the cycle. If, however, when searching for a 1, M finds a blank instead, then M halts without accepting. If, after changing a 1 to a Y, M finds no more 0’s, then M checks that no more 1’s remain, accepting if there are none Data Structures and Algorithms for Information Processing

Let Q = { q 0, q 1, q 2, q 3, q 4 },  = {0,1},  = {0,1,X,Y,B} and F = {q 4 }  is defined with the following table: INPUT SYMBOL STATE01XYB q0 (q1,X,R)--(q3,Y,R)- q1(q1,0,R)(q2,Y,L)-(q1,Y,R)- q2(q2,0,L)-(q0,X,R)(q2,Y,L)- q3---(q3,Y,R)(q4,B,R) q As an exercise, draw a state diagram of this machine and trace its execution through 0011, and Data Structures and Algorithms for Information Processing

The Turing Machine as a computer of integer functions In addition to being a language acceptor, the Turing machine may be viewed as a computer of functions from integers to integers. The traditional approach is to represent integers in unary; the integer i >= 0 is represented by the string 0 i. If a function has more than one argument then the arguments may be placed on the tape separated by 1’s Data Structures and Algorithms for Information Processing

For example, proper subtraction m – n is defined to be m – n for m >= n, and zero for m < n. The TM M = ( {q0,q1,...,q6}, {0,1}, {0,1,B}, , q0, B, {} ) defined below, if started with 0 m 10 n on its tape, halts with 0 m-n on its tape. M repeatedly replaces its leading 0 by blank, then searches right for a 1 followed by a 0 and changes the 0 to a 1. Next, M moves left until it encounters a blank and then repeats the cycle. The repetition ends if -Searching right for a 0, M encounters a blank. Then, the n 0’s in 0 m 10 n have all been changed to 1’s, and n+1 of the m 0’s have been changed to B. M replaces the n+1 1’s by a 0 and n B’s, leaving m-n 0’s on its tape. -Beginning the cycle, M cannot find a 0 to change to a blank, because the first m 0’s already have been changed. Then n >= m, so m – n = 0. M replaces all remaning 1’s and 0’s by B Data Structures and Algorithms for Information Processing

The function  is described below.  (q0,0) = (q1,B,R) Begin. Replace the leading 0 by B.  (q1,0) = (q1,0,R) Search right looking for the first 1.  (q1,1) = (q2,1,R)  (q2,1) = (q2,1,R) Search right past 1’s until encountering a 0. Change that 0 to 1.  (q2,0) = (q3,1,L)  (q3,0) = (q3,0,L) Move left to a blank. Enter state q0 to repeat the cycle.  (q3,1) = (q3,1,L)  (q3,B) = (q0,B,R) If in state q2 a B is encountered before a 0, we have situation i described above. Enter state q4 and move left, changing all 1’s to B’s until encountering a B. This B is changed back to a 0, state q6 is entered and M halts.  (q2,B) = (q4,B,L)  (q4,1) = (q4,B,L)  (q4,0) = (q4,0,L)  (q4,B) = (q6,0,R) If in state q0 a 1 is encountered instead of a 0, the first block of 0’s has been exhausted, as in situation (ii) above. M enters state q5 to erase the rest of the tape, then enters q6 and halts.  (q0,1) = (q5,B,R)  (q5,0) = (q5,B,R)  (q5,1) = (q5,B,R)  (q5,B) = (q6,B,R). As an exercise, trace the execution of this machine using an input tape with the symbols Data Structures and Algorithms for Information Processing

Modifications To The Basic Machine It can be shown that the following modifications do not improve on the computing power of the basic Turing machine shown above: – Two-way infinite tape – Multi-tape Turing machine with k tape heads and k tapes – Multidimensional, Multi-headed, RAM, etc., etc.,… – Nondeterministic Turing machine – Let’s look at a Nondeterministic Turing Machine… Data Structures and Algorithms for Information Processing

Nondeterministic Turing Machine (NTM) The transition function has the form:  : Q x   Ρ(Q x  x {L, R}) So, the domain is an ordered pair, e.g., (q 0,1). Q x  x {L, R} looks like { (q 0,1,R),(q 0,0,R),(q 0,1,L),…}. Ρ(Q x  x {L, R}) is the power set. Ρ(Q x  x {L, R}) looks like { {}, {(q 0,1,R)}, {(q 0,1,R),(q 0,0,R)},…} So, if we see a 1 while in q 0 we might have to perform several activities… Data Structures and Algorithms for Information Processing 13

Computing using a NTM A tree corresponds to the different possibilities. If some branch leads to an accept state, the machine accepts. If all branches lead to a reject state, the machine rejects. Solve subset sum in linear time with NTM: Set A = {a,b,c} and sum = x. Is there a subset of A summing to x? Suppose A = {1,2}, x = 3. / \ for each element e of A 1 no 1 take paths with and without e / \ /\ accept if the subset sums to x 2 no 2 2 no 2 accept reject reject reject Data Structures and Algorithms for Information Processing 14

Church-Turing Hypothesis Notes taken from “The Turing Omnibus”, A.K. Dewdney Try as one might, there seems to be no way to define a mechanism of any type that computes more than a Turing machine is capable of computing. Note: On the previous slide we answered an NP- Complete problem in linear time with a non- deterministic algorithm. Quiz? Why does this not violate the Church-Turing Hypothesis? With respect to computability, non-determinism does not add power Data Structures and Algorithms for Information Processing

The Halting Problem Notes taken from “Algorithmics The Sprit of Computing” by D. Harel Consider the following algorithm A: while(x != 1) x = x – 2; stop Assuming that its legal input consists of the positive integers,It is obvious that A halts precisely for odd inputs. This problem can be expressed as a language recognition problem. How? Now, consider Algorithm B: while (x != 1) { if (x % 2 == 0) x = x / 2; else x = 3 * x + 1; } No one has been able to offer a proof that B always terminates. This is an open question in number theory. This too may be expressed as a language recognition problem. The halting problem is “undecidable”, meaning that there is no algorithm that will tell, in a finite amount of time, whether a given arbitrary program R, will terminate on a data input X or not Data Structures and Algorithms for Information Processing

Data Structures and Algorithms for Information Processing But let’s build such a device anyway…

Build a new program S that uses Q in the following way. S first makes a copy of its input. It then passes both copies (one as a program and another as its input) to Q. Q makes its decision as before and gives its result back to S. S halts if Q reports that Q’s input would loop forever. S itself loops forever if Q reports that Q’s input terminates Data Structures and Algorithms for Information Processing And let’s use it as a subroutine…

Data Structures and Algorithms for Information Processing How much effort would It require for you to write S? Assuming, of course, that Q is part of the Java API?

Data Structures and Algorithms for Information Processing OK, so far so good. Now, pass S in to S as input.

The existence of S leads to a logical contradiction. If S terminates when reading itself as input then Q reports this fact and S starts looping and never terminates. If S loops forever when reading itself as input then Q reports this to be the case and S terminates. The construction of S seems to be reasonable in many respects. It makes a copy of its input. It calls a function called Q. It gets a result back and uses that result to decide whether or not to loop (a bit strange but easy to program). So, the problem must be with Q. Its existence implies a contradiction. So, Q does not exist. The halting problem is undecidable Data Structures and Algorithms for Information Processing

Recursive and Recursively Enumerable notes from Wikipedia A formal language is recursive if there exists a Turing machine which halts for every given input and always either accepts or rejects candidate strings. This is also called a decidable language. A recursively enumerable language requires that some Turing machine halts and accepts when presented with a string in the language. It may either halt and reject or loop forever when presented with a string not in the language. A machine can recognize the language. The set of halting program integer pairs is in R.E. but is not recursive. We can’t decide it but we can recognize it. All recursive (decidable) languages are recursively enumerable Data Sttures and Algorithms for Information Processing 22

Recursive and Recursively Enumerable The set of halting program integer pairs is in R.E. but is not recursive. Are there any languages that are not recursively enumerable? Yes. Let L be { w = (program p, integer i) | p loops forever on i}. L is not recursively enumerable. We can’t even recognize L. The set of languages is bigger than the set of Turing machines Data Sttures and Algorithms for Information Processing 23

Data Structures and Algorithms for Information Processing 24 Some Results First Computing Model Finite Automata Pushdown Automata Linear Bounded Automata Turing Machines Language ClassRegular Languages Context-Free Languages Context- Sensitive Languages Recursively Enumerable Languages Non- determinism Makes no difference Makes a difference No one knowsMakes no difference 24