1 / 10

Turing machines

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

nitsa
Download Presentation

Turing machines

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. Turing machine Finite set of States Q with initial state Finite Input/out alphabet S withspecial symbols < (left marker), _ (blank) Accepting, or halting states H Transition relation ((Q-H) x S) -> (Q x (S 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 control > tape < a b a a - - head

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

  4. Example 1Turing 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,->)) s: see lh, move right ((q,<),(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. Example 2Turing machine What does this machine do? S= {s0,s1,s2,s3,s4, h}, H={h}, initial s0, S ={a,b} ((s0,<),(s1,->)) ((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. Example 3Turing 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 • Memorise character • Erase character • Go right to first blank, right again, while not blank, go right • Write character • Go left to blank, replace blank by character, go right Go back to < > (1,_) (1,->) (_,->) (_,1) (_,1) (1,<-) (1,->) (1,->) (1,->) (_,<-) (1,<-) (Assume alphabet {1}) (<,->)

  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 S={1} then the string 11 represents 2, if S={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. 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 |- C2 configuration C1=(q,uav) yields C2=(p,u’bv’) iff u=u’, v=v’, d(q,a) = (x,b) or v=bv’, ua=u’, d(q,a) = (x,->) etc. C0 |-* Cn iff C0 |- C1…|- Cn A computation of length n.

  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:S*->S* if for every w e Dom(f), M halts with M(w) =f(w) and for every w e Dom(f), M does not halt. Defn A function f with Dom(f) C S* is called PartialTuringComputable iff there exists a TM that computes it. Defn A PartialTuringComputable function f is called TuringComputable iff Dom(f) = S* . Defn A language is called Turingcomputable, or decidable if its characteristic function is Turing computable. Defn A language is semidecidable if its characteristic function is only partial Turing computable.

  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 w1 …wn encodes input x1 to xn, then the input tape is w1_ w2 _ …_ wn 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????

More Related