Presentation is loading. Please wait.

Presentation is loading. Please wait.

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 -

Similar presentations


Presentation on theme: "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 -"— Presentation transcript:

1 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 - a tape, which is infinite - a tape head, which can be moved left and right - output, which is written to the tape - a tape head A TM is just a souped up FSM!

2 2 Turing machine Finite set of States Q with initial state Finite Input/out alphabet  with  special symbols < (left marker), _ (blank) Accepting, or halting states H Transition relation ((Q-H) x  ) -> (Q x (  U  \  ) A transition describes the “rules” of the TM. transition ((s,a),(q,b)) in state s, read symbol a from tape, then move to state q and replace a with b states read a write b (at same tape position) transition ((s,a),(q,->)) in state s, read symbol a from tape, then move the head right one position transition ((s,a),(q,<-)) in state s, read symbol a from tape, then move the head left one position > < a b a a - - head tape control

3 3 Turing machine Finite set of States Q with initial state Finite Input/out alphabet  with special symbols < (left marker), _ (blank) Accepting, or halting states H Transition relation  :: ((Q-H) x  ) -> (Q x  U  ) Conditions on the transition relation:  is total for all non halting states and symbols but for all a, for all halting states h,  (h,a) is not defined. Note 1: From the type of , we can see that no new left marker is ever produced. Note 2: Some definitions of Turing machines allow  to be partial, in which case a TM may halt and fail. > < a b a a - - head tape control

4 4 Example 1 Turing machine What does this machine do? S= {s,q,h}, H={h}, initial s ((s,_) (h,_ )) s: see _, halt ((s,a),(q,_)) s: see a, erase and move to state q ((q,_),(s,->)) q: see a _, move tape right and move to state s ((s, )) s: see lh, move right ((q, )) q: see lh, move right ((q,a),(h,a)) q: see a, halt It just erases the input string! Work through an example, e.g. input <aaa_ _

5 5 Example 2 Turing machine What does this machine do? S= {s0,s1,s2,s3,s4, h}, H={h}, initial s0,  ={a,b} ((s0, )) ((s1,a) (s2,a )) ((s1,b),(s2,b)) ((s2,a) (s3,-> )) ((s2,b),(s3,->)) ((s3,a) (s4,_ )) ((s3,b),(s4,_)) ((s3,_),(h,<-)) ((s4,_) (s3,-> ) Graphical representation: (_,->) (a,a) (a,->) (a,_) (b,b) (b,->) (b,_) It computes the head of a list! Note: you could remove state s1 – or keep it and add ((s1,_),(h,<-))

6 6 Example 3 Turing machine Design a machine to make a copy of the input, with a blank between the original input and the copy. E.g. if the input is w, then the output (i.e. the contents of the tape) is w_w. < a b c - to < a b c - a b c - Design: Loop until blank 1.Memorise character 2.Erase character 3.Go right to first blank, right again, while not blank, go right 4.Write character 5.Go left to blank, replace blank by character, go right Go back to < > (1,_) (1,->)(_,1)(_,->) (_,<-) (1,<-) (1,->) (1,<-) (_,1) (1,->) ( ) (Assume alphabet {1})

7 7 Encodings and language recognition How does a TM recognise a language? By halting with a tape which contains only a 0 (False) or a 1 (True). (Characteristic function) Strings can be unary or binary (or any) encodings of Nat. E.g. if  ={1} then the string 11 represents 2, if  ={0,1} then the string 11 represents 3. For example, if we take the TM from example 3, and modify it to remove the blank between the two strings, Then when the input is in unary, this TM computes the function (*2). We now formalise this. Nb. example 3 was something we couldn’t do with PDAs!

8 8 Some definitions Defn A TM configuration consists of the current state the symbol currently at the head position on the tape the string on the tape to the left of the head the string on the tape to the right of the head (to rightmost nonblank) If the state is a halting state, we say that the configuration is halting. Convenient notation is (q,uav) string to left current symbol string to right Defn C1 |- C2configuration C1=(q,uav) yields C2=(p,u’bv’) iff u=u’, v=v’,  (q,a) = (x,b) or v=bv’, ua=u’, d(q,a) = (x,->) etc. C0 |-* Cniff C0 |- C1…|- Cn A computation of length n.

9 9 Some definitions Defn If a TM M starting with initial configuration (s,<w) and head at first character of w halts in final configuration (h,<u), i.e. (s,<w) |-* (h,u), then we say that M(w)=u and call M(w) the output of M, on input w. Defn A TM M computes the function f:  *->  * if for every w  Dom(f), M halts with M(w) =f(w) and for every w  Dom(f), M does not halt. Defn A function f with Dom(f) C  * is called Partial Turing Computable iff there exists a TM that computes it. Defn A Partial Turing Computable function f is called Turing Computable iff Dom(f) =  *. Defn A language is called Turing computable, or decidable if its characteristic function is Turing computable. Defn A language is semidecidable if its characteristic function is only partial Turing computable.

10 10 Turing Computability What is the significance of these definitions? Essentially Partial computable => the machine may not halt, it may loop (procedure) Computable => the machine always halts (algorithm) Note: TMs can compute functions of multiple arguments by separating all the inputs by blanks. e.g. if w 1 …w n encodes input x1 to xn, then the input tape is w 1 _ w 2 _ …_ w n So TMs can compute functions from Nat x Nat x.. Nat -> Nat. How powerful are TMs? Or put another way, Question: the £20M one are all functions Turing computable????


Download ppt "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 -"

Similar presentations


Ads by Google