170 likes | 833 Views
Formal Definition. Definition . A Turing machine is a 5-tuple (S, , , s, H), where:. S is a set of states is an alphabet It must contain and . It cannot contain or s S is the initial state H S is the set of halting states. Formal Definition (II).
E N D
Formal Definition Definition. A Turing machine is a 5-tuple (S, , , s, H), where: • S is a set of states • is an alphabet It must contain and . It cannot contain or • s S is the initial state • H S is the set of halting states
Formal Definition (II) • is a collection of transitions defined by the function: • maps ((S-H) ) into (S ( (, })) • such that: • For any q S – H, then for some p S • 1.1 (q, ) = (p,), or • 1.2 (q, ) = (p, ) • There cannot be any p, q S and α – {} such that (p, α) = (q, ) Very simple definition but very useful precisely because of its simplicity!
a a a • S = {s,q,h} • ={a, , } H = {h} (S, , , s, H) The “Eraser” TM Construct a Turing machine that receives as input a substring of a’s and replace each a for a blank space,
((s, ),(q,)) What does this Turing machine do? Another Example • = { ((s, ),(s,)), ((s,a),(q, )), ((q, ),(s, )), ((s, ),(h, )), ((q,a),(q,a)), ((q, ), (q, a)) }
? ? ? ? ? ? ? ? 1 0 ? ? ? ? ? ? The Turing Machine M0 The Turing Machines M1 and M0 The Turing Machine M1
? ? ? ? ? ? 1 0 0 1 ? ? ? ? ? ? The Turing Machine Mx
q: state, w: word (q,w) q: state, w: word : stack (q,w,) Configuration for Previous Machines Machine Configuration Explanation Finite automata Pushdown automata
(q,h,LS,RS) • The current state, q • The symbol pointed by the head, h • The string left of the head, LS • The string right of the head, RS Configuration for Turing Machines Configuration:
Configuration for Turing Machines (2) Instead of writing: (q,h,LS,RS), we write: (q,LShRS) If q H, then (q,LShRS) is called a halting configuration Examples: - Initial configuration with 3 a’s for the eraser TM: (s,eaaa) - Final configuration starting with (s,eaaa): (s,) - Final configuration of M1with (s,aab): (s,1ab)
C yields C’, written C * C’: There is a sequence of configurations: C C0 C1 … C’ Computation in Turing Machines A configuration C1 = (q1,LS1h1RS1) yields a configuration C2 = (q2,LS2h2RS2) in one step, written C1 C2, if: • There is a transition ((q1, h1),(q2,A)) in • C2 is obtained after applying ((q, h1),(q2,A)) to C1 (there are 3 cases for A: a in ∑, , or )
Example of Computation (s,eaaa) yields (h,e) written (s,eaaa) * (h,e)
Example of Computation (2) Consider the following Turing machine: ((s, ),(h, )) ((s,a),(q,b)) ((s,b),(q,a)) ((q,a),(s,)) ((q,b),(s,)) ((q, ),(q, )) ((s, ),(s,)) ((q, ),(s,)) - Trace the machine when starting with configuration (s,abbabba) - Describe what this machine does
1 ? ? ? 0 ? ? ? Another Turing Machine The (ab)* Turing Machine: a b a b a b a a
Homework • Please provide a secret nickname so we can post your grades on the course’s web site • 4.1 a), b) • 4.2 • Construct a Turing machine that “reads” the character in the current cell and copies it into the contiguous cell immediately to the right of the current one (if the character in the current cell is , the machine does not terminate). For example if the starting configuration is: (s, abaa), then the halting configuration is: (h, abba), where h is a halting state • Construct the Turing machine that recognizes (ab)* (See Slide # 13)