TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.

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

Introduction to Computability Theory
Variants of Turing machines
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Module 15 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
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.
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
Courtesy Costas Busch - RPI1 Turing Machines. Courtesy Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
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 ? ?
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 ? ?
Turing Machines A more powerful computation model than a PDA ?
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Birthday Gift from Dad …. … Most Powerful Computer.
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
TM Design Universal TM MA/CSSE 474 Theory of Computation.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
Turing Machines. Intro to Turing Machines A Turing Machine (TM) has finite-state control (like PDA), and an infinite read-write tape. The tape serves.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Part 1 – Pages COMPUTABILITY THEORY.
The Church-Turing Thesis Chapter 3 Giorgi Japaridze Theory of Computability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich
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 -
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
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.
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,
THE CONVENTIONS 2 simple rules: Rule # 1: Rule # 2: RR “move to the right until you find  “ Note: first check. Then move (think of a “while”) “Never.
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 ? ?
Unrestricted Grammars
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
Theory of Computation Automata Theory Dr. Ayman Srour.
MA/CSSE 474 Theory of Computation Universal Turing Machine Church-Turing Thesis (Winter 2016, these slides were also used for Day 33)
Universal Turing Machine
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
TM Macro Language MA/CSSE 474 Theory of Computation.
MA/CSSE 474 Decision Problems Languages, Machines, Computation
Turing Machines Chapter 17.
(Universal Turing Machine)
CSE 105 theory of computation
Computing with Turing Machines
COSC 3340: Introduction to Theory of Computation
Turing Machines 2nd 2017 Lecture 9.
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
Turing Machines Chapter 17.
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Computation FSM Intro.
MA/CSSE 474 Theory of Computation
CSE 105 theory of computation
Variants of Turing machines
MA/CSSE 474 Theory of Computation
CSE 105 theory of computation
Presentation transcript:

TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation

Your Questions? Previous class days' material Reading Assignments HW 12 problems Anything else I have included some slides online that we will not have time to do in class, but may be helpful to you anyway.

Recap: Turing Machines At each step, the machine must: ● choose its next state, ● write on the current square, and ● move left or right.

A Formal Definition A (deterministic) Turing machine M is (K, , , , s, H): ● K is a finite set of states; ●  is the input alphabet, which does not contain  ; ●  is the tape alphabet, which must contain  and have  as a subset. ● s  K is the initial state; ● H  K is the set of halting states; ●  is the transition function: (K - H)   to K    { ,  } non-halting  tape  state  tape  direction to move state char char (R or L)

An Example M takes as input a string in the language: { a i b j, 0  j  i}, and adds b ’s as required to make the number of b ’s equal the number of a ’s. The input to M will look like this: The output should be:

The Details K = {1, 2, 3, 4, 5, 6},  = { a, b },  = { a, b, , $, #}, s = 1,H = {6},  =

Notes on Programming The machine has a strong procedural feel, with one phase coming after another. There are common idioms, such as "scan left until you find a blank" There are some common ways to scan back and forth marking things off. Often there is a final phase to fix up the output. Even a very simple machine is a nuisance to write.

Halting ● A DFSM M, on input w, is guaranteed to halt in |w| steps. ● A PDA M, on input w, is not guaranteed to halt. To see why, consider again M = But there exists an algorithm to construct an equivalent PDA M that is guaranteed to halt. A TM M, on input w, is not guaranteed to halt. And there is no algorithm to construct an equivalent TM that is guaranteed to halt.

Formalizing the Operation A configuration of a Turing machine M = (K, , , s, H) is an element of: K  ((  - {  })  *)  {  }    (  * (  - {  }))  {  } state up current after to current square current square square

Example Configurations (1)(q, ab, b, b )written more simply as (q, abbb ) (2)(q, , , abbb ) written more simply as (q,  abbb ) Initial configuration is (s,  w). b

Yields (q 1, w 1 ) |- M (q 2, w 2 ) iff (q 2, w 2 ) is derivable, via , in one step. For any TM M, let |- M * be the reflexive, transitive closure of |- M. Configuration C 1 yields configuration C 2 if: C 1 |- M * C 2. A path through M is a sequence of configurations C 0, C 1, …, C n for some n  0 such that C 0 is the initial configuration and: C 0 |- M C 1 |- M C 2 |- M … |- M C n. A computation by M is a path that halts. If a computation is of length n (has n steps), we write: C 0 |- M n C n

Exercise If n and m are non-negative integers, monus(n, m) is defined to be n – m if n > m, and 0 if n ≤ m. Draw the diagram for a TM M whose input is 1 n ;1 m and whose output is 1 monus(n, m). When M halts, the read/write head should be positioned on the blank before the first 1.

(Hidden, not used 2014)Exercise A TM to recognize { ww R : w  {a, b}* }. If the input string is in the language, the machine should halt with y as its current tape symbol If not, it should halt with n as its current tape symbol. The final symbols on the rest of the tape may be anything.

Hidden: Exercise A TM to recognize ww R, where w  {a, b}* (beginning of a solution) New tape symbols: A, B: (1,  )  (2, ,   ) (2,  )  (3, ,   ) 3 is a halting state (2, a)  (4,  A,   ) (4, a)  (4,  a,   ) (4, b)  (4,  b,   ) (4,  )  (5, ,   ) (4, A)  (5, A,  )

TMs are complicated … and low-level! We need higher-level "abbreviations". –Macros –Subroutines

A Macro language for Turing Machines (1) Define some basic machines ● Symbol writing machines For each x  , define M x, written as just x, to be a machine that writes x. Read-write head ends up in original position. ● Head moving machines R:for each x  ,  (s, x) = (h, x,  ) L:for each x  ,  (s, x) = (h, x,  ) ● Machines that simply halt: h, which simply halts (don't care whether it accepts). n, which halts and rejects. y, which halts and accepts. You need to learn this simple language. I will use it and I expect you to use it on HW and tests.

Next we need to describe how to: ● Check the tape and branch based on what character we see, and ● Combine the basic machines to form larger ones. To do this, we need two forms: ● M 1 M 2 Checking Inputs and Combining Machines

Turing Machines Macros Cont'd Example: >M 1 a M 2 b M 3 ● Start in the start state of M 1. ● Compute until M 1 reaches a halt state. ● Examine the tape and take the appropriate transition. ● Start in the start state of the next machine, etc. ● Halt if any component reaches a halt state and has no place to go. ● If any component fails to halt, then the entire machine may fail to halt.

a M 1 M 2 becomesM 1 a, b M 2 b M 1 all elems of  M 2 becomesM 1 M 2 or M 1 M 2 Variables M 1 all elems of  M 2 becomesM 1 x   a M 2 except a and x takes on the value of the current square M 1 a, b M 2 becomesM 1 x  a, b M 2 and x takes on the value of the current square M 1 x = y M 2 if x = y then take the transition e.g., > x    Rx if the current square is not blank, go right and copy it. More macros

Blank/Non-blank Search Machines Find the first blank square to the right of the current square. Find the first blank square to the left of the current square. Find the first nonblank square to the right of the current square. Find the first nonblank square to the left of the current square RR LL RR LL

More Search Machines L a Find the first occurrence of a to the left of the current square. R a, b Find the first occurrence of a or b to the right of the current square. L a, b a M 1 Find the first occurrence of a or b to the left of the current square, b then go to M 1 if the detected character is a ; go to M 2 if the M 2 detected character is b. L x  a, b Find the first occurrence of a or b to the left of the current square and set x to the value found. L x  a, b RxFind the first occurrence of a or b to the left of the current square, set x to the value found, move one square to the right, and write x ( a or b ).

An Example Input:  w w  {1}* Output:  w 3 Example:  111 

What does this machine do?

Exercise Initial input on the tape is a non-negative integer written in binary, most significant bit first (100 represents 6). Design a TM that replaces the binary representation of n by the binary representation of n+1.

Two Useful Kinds of TMs 1.Recognize a language 2.Compute a function

Turing Machines as Language Recognizers Let M = (K, , , , s, {y, n}). ● M accepts a string w iff (s,  w) |- M * (y, w) for some string w. ● M rejects a string w iff (s,  w) |- M * (n, w) for some string w. M decides a language L   * iff: For any string w   * it is true that: if w  L then M accepts w, and if w  L then M rejects w. A language L is decidable iff there is a Turing machine M that decides it. In this case, we will say that L is in D.

A Deciding Example A n B n C n = { a n b n c n : n  0} Example:  aabbcc  Example:  aaccb 

Semideciding a Language Let  M be the input alphabet to a TM M. Let L   M *. M semidecides L iff, for any string w   M *: ● w  L  M accepts w ● w  L  M does not accept w. M may either: reject or fail to halt. A language L is semidecidable iff there is a Turing machine that semidecides it. We define the set SD to be the set of all semidecidable languages.

Example of Semideciding Let L = b * a ( a  b )* We can build M to semidecide L: 1. Loop 1.1 Move one square to the right. If the character under the read head is an a, halt and accept. In our macro language, M is:

Example of Semideciding L = b * a ( a  b )*. We can also decide L: Loop: 1.1 Move one square to the right. 1.2 If the character under the read/write head is an a, halt and accept. 1.3 If it is , halt and reject. In our macro language, M is:

Computing Functions Let M = (K, , , , s, {h}). Define M(w) = z iff (s,  w) |- M * (h,  z). Let    be M’s output alphabet. Let f be any function from  * to  *. M computes f iff, for all w   *: ● If w is an input on which f is defined: M(w) = f(w). ● Otherwise M(w) does not halt. A function f is recursive or computable iff there is a Turing machine M that computes it and that always halts.

Example of Computing a Function Let  = { a, b }. Let f(w) = ww. Input:  w  Output:  ww  Define the copy machine C:  w    w  w  Also use the S  machine:  u  w    uw  Then the machine to compute f is just >C S  L 

Example of Computing a Function Let  = { a, b }. Let f(w) = ww. Input:  w  Output:  ww  Define the copy machine C:  w    w  w  Then use the the S  machine:  u  w    uw  Then the machine to compute f is just >C S  L  We skip the details in class; you can look at them later.

Computing Numeric Functions For any positive integer k, value k (n) returns the nonnegative integer that is encoded, base k, by the string n. For example: ● value 2 ( 101 ) = 5. ● value 8 ( 101 ) = 65. TM M computes a function f from ℕ m to ℕ iff, for some k: value k (M(n 1 ;n 2 ;…n m )) = f(value k (n 1 ), … value k (n m )).

Computing Numeric Functions Example: succ(n) = n + 1 We will represent n in binary. So n  0  1 { 0, 1 }* Input:  n  Output:  n+1   1111  Output:  

Why Are We Working with Our Hands Tied Behind Our Backs? Turing machinesAre more powerful than any of the other formalisms we have studied so far. Turing machinesAre a lot harder to work with than all the real computers we have available.  Why bother? The very simplicity that makes it hard to program Turing machines makes it possible to reason formally about what they can do. If we can, once, show that anything a real computer can do can be done (albeit clumsily) on a Turing machine, then we have a way to reason about what real computers can do.