CS 154 Formal Languages and Computability April 7 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.

Slides:



Advertisements
Similar presentations
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
Advertisements

Variants of Turing machines
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
CS 461 – Oct. 21 Begin chapter 3 We need a better (more encompassing) model of computation. Ex. { 1 n 2 n 3 n } couldn’t be accepted by PDA. –How could.
Turing Machines New capabilities: –infinite tape –can read OR write to tape –read/write head can move left and right q0q0 input tape.
Homework 8 Solutions #1 True or False a) Regular languages are recursive b) Context free languages are recursively enumerable (r.e.) c) Recursive languages.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?
CS 310 – Fall 2006 Pacific University CS310 Turing Machines Section 3.1 November 6, 2006.
Lecture 5 Turing Machines
Courtesy Costas Busch - RPI1 Turing Machines. Courtesy Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Computation Theory Introduction to Turing Machine.
Turing Machines.
Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov.
Costas Busch - RPI1 Turing Machines. Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Chapter 9 Turing Machine (TMs).
1 Turing Machines. 2 A Turing Machine Tape Read-Write head Control Unit.
Turing Machines Chapter Plan Turing Machines(TMs) – Alan Turing Church-Turing Thesis – Definitions Computation Configuration Recognizable vs. Decidable.
Ding-Zhu Du Office: ECSS 3-611, M 3:15-4:30 Lecture: ECSS 2.311, MW 12:30-1:45.
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 Turing Machines There are languages that are not context-free. What can we say about the most powerful automata and the limits of computation?. Alan.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Part 1 – Pages COMPUTABILITY THEORY.
CSE 311 Foundations of Computing I Lecture 26 Computability: Turing machines, Undecidability of the Halting Problem Spring
Computer Science 101 Theory of Computing. Computer Science is... The study of algorithms, with respect to –their formal properties –their linguistic realizations.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich
Theory of computing, part 4. 1Introduction 2Theoretical background Biochemistry/molecular biology 3Theoretical background computer science 4History of.
1 Turing machines Chapter 4, Smith and Kimber. A Turing machine is an abstraction of a human “computer”. Consists of - control, in the form of states -
CS 3240: Languages and Computation
Turing Machines Lecture 26 Naveen Z Quazilbash. Overview Introduction Turing Machine Notation Turing Machine Formal Notation Transition Function Instantaneous.
CS 154 Formal Languages and Computability February 4 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
1 IDT Open Seminar ALAN TURING AND HIS LEGACY 100 Years Turing celebration Gordana Dodig Crnkovic, Computer Science and Network Department Mälardalen University.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
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 ? ?
CS 154 Formal Languages and Computability April 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability March 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability April 19 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 3240 – Chapter 9.  Turing Machines  From Alan Turing, 1936  Turns out to be the LAST machine  The only machine you'll ever need  The Church-Turing.
CS 154 Formal Languages and Computability April 28 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
1 Computing Functions with Turing Machines. 2 A function Domain Result Region has:
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. The next level of Machine… PDAs improved on FSAs by adding memory. We make the memory more flexible to do more complicated tasks.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Universal Turing Machine
CS 154 Formal Languages and Computability April 5 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CSE202: Introduction to Formal Languages and Automata Theory
Busch Complexity Lectures: Turing Machines
COSC 3340: Introduction to Theory of Computation
Pumping Lemma Revisited
COSC 3340: Introduction to Theory of Computation
Turing Machines 2nd 2017 Lecture 9.
Turing Machines Acceptors; Enumerators
Chapter 9 TURING MACHINES.
Turing Machines (TM) Deterministic Turing Machine (DTM)
Computing Functions with Turing Machines
COSC 3340: Introduction to Theory of Computation
Formal Definitions for Turing Machines
Presentation transcript:

CS 154 Formal Languages and Computability April 7 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Another Heroic-Tragic Figure  Joseph John Rochefort, American cryptanalyst during World War II.  Helped break the Japanese naval code.  Enabled a major U.S. victory in the Battle of Midway. Destroyed much of the Japanese navy.  An exemplar of what can happen to you if you go around your immediate superiors, even if you’re very right. 2

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Models of Computation 3 MachineMemoryLanguageApplications Finite automatonMachine states onlyRegularText searching, text editors Pushdown automatonStates + stackContext-freeProgramming language compilers Turing machineStates + infinite tapeType 0Computers

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine  A Turing Machine (TM) is a model of a real-world computer.  A TM has the same abilities and the same inabilities of any computer.  Turing Thesis: Any computational process, such as those carried out by present-day computers, can be done on a Turing machine. AKA Church-Turing Thesis Church’s lambda notation and Turing’s machines are equivalent. 4

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine, cont’d  Each tape cell holds one input symbol. Blanks precede and follow the input string.  On each step: The read/write head can overwrite the current symbol. Then the read/write head can move one cell left or right, or stay. 5 ourses/2002/fall/cs30/Lectures/we ek08/Computation.html

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Definition  Turing Machine where: Q is the set of internal states Σ is the input alphabet Γ is the tape alphabet δ is the transition function is the special blank symbol is the initial state is the set of final states 6 I use Δ for the blank symbol instead of the book’s square for ease of typing.

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Transition Function  The transition function has two arguments: the current state the current tape symbol being read  Results: a new state a new tape symbol that replaces the current one a head move to the left ( L ), right ( R ), or stay ( S ). 7 The textbook doesn’t include S.

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Example #1  A TM that accepts the language L = {a n b n : n ≥ 1}  Pseudocode: 1. If the current input symbol (CIS) = a then write Δ, else REJECT. 2. Move head right until CIS = Δ. 3. Move head left. 4. If CIS = b then write Δ, else REJECT. 5. Move head left until CIS = Δ. 6. Move head right. 7. If CIS = Δ then ACCEPT, else go to step 1. 8

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Example #1, cont’d 9 q 0 : Replace the leftmost a with a blank q 1 : Skip right to a blank q 2 : Replace the rightmost b with a blank q 3 : Skip left to a blank q 4 : ACCEPT 1.If CIS = a then write Δ, else REJECT. 2.Move head right until CIS = Δ. 3.Move head left. 4.If CIS = b then write Δ, else REJECT. 5.Move head left until CIS = Δ. 6.Move head right. 7.If CIS = Δ then ACCEPT, else go to step 1. Demo G11.2

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Example #2  An alternate TM that accepts the same language L = {a n b n : n ≥ 1} Example 9.7 of the textbook.  Pseudocode: Replace the leftmost a by an x. Move head right until the leftmost b, replace by a y. Move head left until the leftmost a. Repeat until a ’s and b ’s are simultaneously exhausted, then ACCEPT. Else REJECT. 10

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Example #2, cont’d 11 Replace the leftmost a by an x. Move head right until the leftmost b, replace by a y. Move head left until the leftmost a. Repeat until a ’s and b ’s are simultaneously exhausted, then ACCEPT. Else REJECT. Demo Jexample9.7.jff q 0 : Replace the leftmost a with an x q 1 : Skip right to the leftmost b and replace the b with a y q 2 : Skip left to an x and go right one cell q 3 : Skip y ’s to the right until a blank, then ACCEPT q 4 : Else REJECT

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Instantaneous Descriptions  We can also use instantaneous descriptions. For input aabb : 12 q 0 aabb xq 1 abb xaq 1 bb xq 2 ayb q 2 xayb xq o ayb xxq 1 yb xxyq 1 b xxq 2 yy xq 2 xyy xxq 0 y y xxyq 3 y xxyyq 3 xxyyΔq 4 Δ

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Instantaneous Descriptions, cont’d  Because we can write 13 q 0 aabb * xxyyΔq 4 Δ q 0 aabb xq 1 abb xaq 1 bb xq 2 ayb q 2 xayb xq o ayb xxq 1 yb xxyq 1 b xxq 2 yy xq 2 xyy xxq 0 y y xxyq 3 y xxyyq 3 xxyyΔq 4 Δ

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machine Example #3  What does this TM do?  Not all TMs will halt! Stuck in an infinite loop. 14

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machines as Language Acceptors  A string w is accepted by a TM if w is written on the tape with blanks before and after The TM reads w, enters a final state, and halts.  The string w is rejected by the TM if The TM halts in a nonfinal state. The TM fails to halt.  Let be a TM.  Then the language L(M) consists of all strings over Σ that are accepted by M. 15

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing Machines as Transducers  Because TMs are models for all computers, we must also consider TMs that produce output. i.e., transducers  Input for a TM’s computation are the nonblank symbols on the tape at the initial time.  Output is whatever is on the tape at the conclusion of the computation. 16

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Turing-Computable Functions  Suppose M is a transducer TM that is given input w and produces output f(w).  f is a function such that for some final state q final of M. For input string w, TM M produces output string f(w) and halts in a final state.  A function f over domain D is Turing-computable if there is a TM such that for all strings. 17 q 0 w *

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Is Addition Turing-Computable?  Given two positive integers x and y, design a TM that computes x + y.  Represent the quantities x and y by strings of x 1 ’s and y 1 ’s, respectively, (unary notation) and separate the two strings with a 0. Example: Represent as  Program the TM to move the 0 to the right end of the string. Example: = 5, or

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Is Addition Turing-Computable? cont’d 19 Demo: Jexample9.9.jff

Computer Science Dept. Spring 2016: April 7 CS 154: Formal Languages and Computability © R. Mak Assignment #6 Create and program Turing machines to: 1. Accept the language L 1 = {a n b m a n+m : n ≥ 0, m ≥ 1} 2. Accept the language L 2 = {w : n a (w) = n b (w)} 3. Compute the function f(x) = x mod 3 where x is a positive integer. 4. Shift an entire input string consisting of 0 ’s and 1 ’s one cell to the right. 10 points extra credit if you can program a TM to do this right shift without ever moving the read/write head to the left. 20