CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.

Slides:



Advertisements
Similar presentations
Lecture 3 Universal TM. Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction,
Advertisements

Lecture 16 Deterministic Turing Machine (DTM) Finite Control tape head.
Variants of Turing machines
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
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.
Programming the TM qa  (,q) (,q) q1q1 0q1q1 R q1q1 1q1q1 R q1q1  h  Qa  (,q) (,q) q1q1 0q2q2  q1q1 1q3q3  q1q1  h  q2q2 0q4q4 R q2q2 1q4q4.
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
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).
Lecture 18 Various TMs. Allow the head not move Theorem. If the head is allowed to stay at the cell in each move, then every function computed by the.
AUTOMATA THEORY VIII.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Turing Machines A more powerful computation model than a PDA ?
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
TM Design Universal TM MA/CSSE 474 Theory of Computation.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
MA/CSSE 474 Theory of Computation Enumerability Reduction.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
1 More About Turing Machines “Programming Tricks” Restrictions Extensions Closure Properties.
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,
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
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.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable 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 ? ?
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Unrestricted Grammars
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Lecture 7: Turning Machines 虞台文 大同大學資工所 智慧型多媒體研究室.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
Universal Turing Machine
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
Chapter 5 Recursive and recursively enumerable functions Phrase-structure grammars.
Chapters 11 and 12 Decision Problems and Undecidability.
Turing Machines.
Turing Machines Chapter 17.
(Universal Turing Machine)
Turing Machines 2nd 2017 Lecture 9.
CSE 105 theory of computation
Turing Machines Acceptors; Enumerators
COSC 3340: Introduction to Theory of Computation
Turing Machines Chapter 17.
Decidable Languages Costas Busch - LSU.
CS21 Decidability and Tractability
MA/CSSE 474 Theory of Computation
Decidability and Tractability
CSE 105 theory of computation
Variants of Turing machines
Theory of Computation Lecture 23: Turing Machines III
CSE 105 theory of computation
Presentation transcript:

CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American

Chapter Three Turing Machines

The Language Hierarchy of FA and PA is not RL nor CFL. But L is very simple and can be accepted by a simple program CF Languages Regular Languages

Turing Machines (TM) Δ a b a a … Read/write head Finite control Tape (input and working) Actions: Depending on its current symbol and current state, Enter another state Either - write a symbol - move read/write head one square right or left.

Formal Definition A Turing machine is a quintuple: M = (K, , , S, H), where  K is a finite set of states   is an alphabet, containing the blank symbol |_| and the left end symbol Δ, but not containing the symbols  and   s  K is the initial state.  H  K is the set of halting states.  , the transition function, is a function from (K – H) X  to K X (  U { ,  } ) such that: (a)  q  K – H, if  (q, Δ) = (p, b), then b =  (b)  q  K – H and a  , if  (q, a) = (p, b) then b  Δ Explain  (q, a) = (p, b).

Examples Consider M = (K, , , s, {h} ), where  - What does this does? - Show examples.

Examples Consider M = (K, , , s, {h} ), where - What does this machine do? - Show examples.

Configurations Definition. Given M = (K, , , s, H), a configuration of M is a member of  K X  * X (  * (  - {Ц} ) U {e} ) Content of a configuration:  current state  read/write head position  all symbols to the left of the r/w head  all symbols to the right of the r/w head (may be empty)

Configuration Examples Find a configuration for the following snap shot of the TM Δ a a b a _ _ …

Configuration Examples Find a configuration for the following snap shot of the TM Δ _ _ _ _ a _ …

Configuration Examples Find a configuration for the following snap shot of the TM Δ _ a _ _ _ _ …

A Simple Notation of Configurations (q,  a a b a)  the current state is q  the current string is  aaba  the current symbol is the second a The underline indicates the current symbol, or The r/w head position Want more examples?

The Yield Relation Let TM M = (K, , , s, H). Consider two configurations  (q1,  1 a1 u1) and  (q2,  2 a2 u2) where a1, a2,  , then (q1,  1 a1 u1) |  (q2,  2 a2 u2) if and only if, for some b   U { ,  },  (q1, a1) = (q2, b) and either  b  ,  1 =  2, u1 = u2, a2 = b,  b = ,  1 =  2 a2, and either u2 = a1 u1 if a1  Ц or u1  e or u2 = e, if a = Ц and u1 = e  b = ,  2 = w1 a1, and either u1 = a1 u2, or  u1 = u2 = e, and a2 = Ц

Cases of Yield Relation Let , u   *, where u does not end with a Ц, and let a, b  . Case 1:  (q1, a) = (q2, b)  Example: (q1,  a u) |  (q2,  b u) Case 2:  (q1, a) = (q2,  )  Example  (q1,  bau) |  (q2,  bau)

Cases of Yield Relation Case 3:  (q1, a) = (q2,  )  Example:  (q1,  abu) |  (q2,  abu)  (q1,  a) |  (q2,  aЦ)

The Closure of Yield Relation Let |  * the reflexive transitive closure of |  |  describes one step of computation of TM M |  * describes a sequence of zero or a finite number steps of computation of TM M In other words, a computation by M is a sequence of configurations for some such that   the length of the computation is n or we write

Example Δ table is given below (, Δaaaa) |   Finish the above computation.

Basic TM Machines Symbol-writing machines:  a   U { ,  } – {Δ} is defined as follows:  if a  , then writes a and then halts  if a  { ,  }, then moves r/w head according to the direction of a and then halt.

Better Notations a =, for a  , a-writing machine  Write an a R =, right-moving machine,  move one square right L =, left-moving machine  move one square left.

Combining Rules a b Semantics: Start at the initial state of M1; operate as M1 would operate until M1 would halt; then if the current symbol is a, start M2; otherwise if the current symbol is b, start M3.

TM Construction Examples Examples 1 R R a b Δ |_| RR a, b, Δ, |_|

TM Construction Examples Example 2 L R |_| R L

TM Construction Examples Example 3 L R Џ R Џ L Џ Џ

The Copying Machine C If C starts with input w, which contains only nonblank symbols but possibly empty and is put on an otherwise blank tape with one blank square to its left, and the head is put on the blank square to the left of w, then the machine C will eventually stop with w Ц w on an otherwise blank tape. We say that C transforms  Ц ω Ц into Ц ω Ц ω Ц

The Left-Shift Machine S transforms  Ц w Ц to w Ц, where w is a nonblank string Џ L a R R L a ≠ Џ ЏЏ Џ Џ

The a-Erasing Machine This machines erase the a’s in its input tape RЏ a

Computing with TM’s Input representation of a TM M = (K, , , s, H) Given   (  - {Ц, Δ })*, the input representation is Δ Ц  The initial configuration is (s, ΔЦ  )

Definitions Let M = (K, , , s, H), H = {y, n}  Accepting configurations: Any halting configuration with the halting state y.  Rejecting configurations: Any halting configuration with the halting state n.  M accepts  if (s,  Ц  ) yields an accepting configuration  M rejects  if (s,  Ц  ) yields a rejecting configuration

Definitions  Let  =  - { , Ц} be the input alphabet. Given a language over , M decides L if the following is true:     *, M accepts w if and only if   L.  A language L   * is recursive if and only if there is a TM M that decides L

Examples The language is recursive  Recall that L is not regular nor CF. Construct a TM to accept Џ n R d R y Џ ab b, d d L Џ c a, dd b, c c, Џ a, Џ

Recursive Functions TM’s as computing device Definition: Let M = (K, , , s, H),  0 =  - { , Ц}, let    *. Suppose that M halts on input , and that  (s, ΔЦ  ) |  (h,  Цy) for some y   *. Then y is called the output of M on input , and is denoted as M(  ). M(  ) is defined if and only if M halts on .  In other words, (s,  Ц  ) |  (h,  Цy) for some h  H and y   *. 0 0

Recursive Functions TM’s as computing device Let be a function. A TM M computes f if and only if  A function is recursive if and only if there is a TM computing f.

Examples The doubling function d :  *  * such that   w  , d(  ) =  d is recursive  The following TM computes d  C S First make a copy of w to get w_w from _w, and then shift the copy to form _ww

Computing Numeric Functions Coding natural numbers Any natural numbers can be represented as strings in  {0} U {1, 2, …, 9} {0,1, 2, 3, …9}* or as strings  in {0} U {1} {0, 1}*

Definition. Let M = (K, , δ, s, H) be a TM such that 0, 1, ;  , and let f be any function We say that M computes f if  is recursive if there is a TM computing f.

Example The successor function is recursive. The following TM computes the function: R L Џ 1 1 S R 0 0 Џ 1

Recursively Enumerable Languages Note: A TM can be viewed as one of the three:  Acceptor  Computer  Generator Definition. Let M = (K, , , s, H) be a TM, let  0 =  - { , Ц} be an alphabet, and let L  be a language. We say that M semidecides L if for any string   the following is true:    L if and only if M halts on input .

Recursively Enumerable Languages A language L is r.e. if and only if there is a TM which semidecides L. When M does not halt on input , we write  M (  ) = L is r.e. if and only if    , M (  ) =     L.

Examples L = {   {a, b}* :  contains at least one a } is r.e. The following TM M semidecides L: R a

Recursive vs. R.E. Languages Theorem. If a language is recursive, then it is r.e. Theorem. If a language is recursive, then so is its complement. Theorem: A language L is recursive if L and L are both r.e. Proofs? (Prove in class)

Extensions of TM Multiple tapes … … …

Definition of Multiple Tape TM Definition. Let be an integer. A k-tape TM M is (K, , , s, H), where  K is the set of states   is the set of input symbols  s  K is the initial state  H  K is the set of final states.   transition function, Explain

Configurations of Multiple Tape TM Definition. Let M=(K, , , s, H) be a k-tape TM. A configuration of M is a member of Explain

The Yield Relation of k-Tape TM Define the yield relation Define the reflexive transitive closure of the yield relation Accepting configurations? Rejecting? Copmputing? R.e.?

Computing with a k-Tape TM A k-tape TM can be used to compute a function or decide or semidecide a language. Convention:  The first tape is the input and output tape  The other tapes are just working tapes. K-tape TM’s are relatively easier to construct in some cases than single-tape TM’s

Example Ex. Design a 2-tape TM to make a copy of the input:  Idea of construction  Copy ω to the second tape  Cope the content of the second tape to the first tape

Single Tape vs. Multiple Tapes Theorem. Let M=(K, , , s, H) be a k-tape TM for some. Then there is a standard single tape TM M’=(K’,  ’,  ’, s’, H’) with   ’ such that the following holds: 

Proof. Use 2k-tracks on a single-tape to simulate k-tape computation:  Each of the k-tapes can be simulated by two tracks:  One track for the content  The other track for the head position Example Δ a _ b a _ _ Δ b b b _ _ _ Δ b b b _ _ _ Δ a _ b a _ _ Δ_

Corollary Corollary. Any function that is computed or language that is decided or semidecided by a k-tape TM is also computed, decided, or semidecided, respectively by a standard single-tape TM.

Other Extensions of TM’s Two-way infinite tape TM’s Multiple heads TM’s Two-dimensional tape TM’s Random Access TM’s Many other models … All models have the same computational power  That is, for any two models, one model can do something, so does the other; and vice versa.

Nondeterministic TM (NTM) Allow more than one choice for next move Definition. An NTM M=(K,∑,Δ,s,H), where  K,∑,s and H are the same as for standard TM’s  Δ is a transition relation: Explain Can you see nondeterministism from Δ?

Configurations and Yield Relation of NTM Both can defined in a way similar to these of standard TM’s Can one define configurations? Can one define yield relation? The reflexive transitive closure of yield relation describes computation of the NTM The difference:  Each configuration may yield (or derive) several configurations at each step! Nondeterministic computation

Computation of an NTM Definition. Let M=(K,∑,Δ,s,H) be an NTM. M accepts if  Remark.  An NTM accepts an input ω even though it may have nonhalting computation on ω  As long as at least one computation of the NTM halts, then we say it accepts ω.

Tree-like Computation of NTM ……………… ………………………………

Semidecidability Let M=(K,∑,Δ,s,H) be an NTM. Let be a language. M semidecides L, if  Think about what will happen if

Decidability Let M=(K,∑,Δ,s,H) be an NTM. Let be a language. M decides L, if the following two conditions hold for all  There is a natural number N, depending on M and ω, such that all possible computations of M on ω end in no more N steps (either halt or no further computations can be performed).  At least one particular computation halts in no more than N steps (hence, this computation accepts ω).

Computing Functions M computes a function  if the following two conditions hold for all  There is a natural number N, depending on M and ω, such that all possible computations of M on ω end in no more N steps (either halt or no further computations can be performed).  At least one particular computation halts with configuration in no more than N steps Hence, this computation computes f(ω)=u.

NTM vs. DTM Theorem. If there is an NTM M semidecides, or decides a languages, or computes a function, then there is a standard deterministic TM (DTM) semideciding, deciding the same language, or computing the same function. Proof. Use multiple-tape DTM to simulate the DTM.

Grammars: Unrestricted Grammars Definition. A grammar is a quadruple Where  is an alphabet  is the set of terminals  is the set of non-terminals  S is the start symbol  is the set of production rules Note. Examine R to tell the difference between an unrestricted grammar and a CF grammar.

Derivations Let be a grammar. Let iff  Let denote the reflexive transitive closure of describes one step of derivation describes zero or a finite number steps of derivation

Strings and Languages Let be a grammar. A string is generated by G if The language generated by G is 

Examples Design a grammar to generate the language  Here is the grammar: Try a few examples.

R.E. Languages vs. Unrestricted Grammar Theorem A language is generated by an unrestricted grammar iff it is r.e. Proof Ideas.  Suppose L is generated by a grammar Design a TM M to simulate the derivation of G such that M semidecides L. This part is easy to do  Suppose a TM M =(K,∑,δ,s,{h}) semidecides L. Construct a grammar to generate L.

The If-Part Proof of Theorem M semidecides L, that is, for any  Rewrite this we have  Design L to simulate M backwards, that is, 

The If-Part Proof of Theorem How to design L? Have you noticed the backward computation of M simulated by G?

Computing Functions by Grammars Definition. Let be a grammar, and let be a function. We say that G computes f if, for all the following is true:   A function is called grammatically computable iff there is a grammar G that computes it.

Theorem Theorem A function is recursive iff it is grammatically computable. Proof. Simulate a TM by grammar, and vice versa.

Numerical Functions: Definitions Basic Functions  k-ary zero function  The j-th k-ary identity function  Successor function

Composition Let be -ary functions. Define

Recursive Definition Let be -ary functions. Let h be a -ary function. Define

Primitive Recursive Functions All basic functions Plus All functions obtained from basic functions by any number of successive applications of composition and recursive definition

Minimalization Let be -ary function. For some Define

μ-Recursive Functions A function is μ-recursive if  it is primitive recursive, or  can be obtained from basic functions by any number of successive applications of composition, recursive definition, and minimalization on minimalizable functions These always with m’s satisfy the minimalization condition

Theorem Theorem A function is μ-recursive iff it is recursive. Proof.  (Only-if part) Show all basic functions are TM- computable, and all functions derived from basic functions using composition, recursive definition, and minimalizable minimalization are all TM- computable.  (If-part) Show μ-recursive functions can simulate computation of TM.