Turing Machine properties There are many ways to skin a cat Turing Machines And many ways to define a TM The book’s “Standard Turing Machines” Tape unbounded on both sides Deterministic (at most 1 move / configuration) TM Variants and the Universal TM Tape acts as both input and output The books looks at a number of “alternate” (and equivalent) definitions. Alternate TM definitions Alternate TM definitions Off-line TM Turing Machines with a “STAY” Option TM with 2 tapes Allows the tape head to stay where it is Read-only input tape δ : Q x Γ → Q x Γ x {R, L, S } Read-write tape Basic TM defined in JFLAP Input file + memory TM with semi-infinite tape Non-deterministic TM Tape is bounded on the left Machine has a choice of moves Any attempt to go beyond this boundary will result in halt and reject. δ : Q x Γ → 2 Q x Γ x {R, L} More on this next week. Alternate TM definitions Alternate TM definitions Multi-taped TMs All of the alternate definitions are equivalent to the standard TM Have multiple tapes With a multiple tape heads that is read/ I.e Given an alternate TM that accepts L, writing a different position on each tape at one can construct a standard TM that any one given time. accepts the same language. δ : Q x Γ n → Q x Γ n x {R, L} n where n is #of tapes 1
Turing Machine Variants Turing Machine Variants Multitape TM Move of a multitape TM Will depend upon: The state of the machine The symbol being read on all of the tape heads Result: Each of the tape heads will write a new symbol on the tape Each of the tape heads will move left, right, or stationery Tape heads can move independently. Multitape TM Multitape TM Example {ww R | w is a string in {a,b} * } Even length palandromes 2-tapes Step 1: Copy contents of tape 1 to tape 2 Step 2: position head of tape 1 at beginning of tape and head of tape 2 at end Step 3: Compare strings character by character Questions? Universal Turing Machine Universal Turing Machine Universal Turing Machine Encoding scheme A TM M u that takes as input, an encoded version We need a way to encode a TM so that it can be of another TM M and an input w to M’. provided as input to T u M u will simulate the processing w on M’ Define sets: If M halts on input w, M u will halt Q = {q 1 , q 2 , … } = set of all possible states that may appear in any TM If M rejects on input w,M u will reject. S = {a 1 , a 2 , a 3 , …} = set of all possible tapes symbols that can be written on any TM. M u is a general purpose TM So for any TM M is a program run on the general purpose TM Q ⊆ Q and Γ ⊆ S 2
Universal Turing Machine Universal Turing Machine Assumptions Encoding scheme Associate states, symbols, and directions with q 1 will always be the start state binary numbers: There will only be 1 final state States: It will be q 2 s(q i ) → 1 i Symbols The machine always halts in q 2 s(a i ) → 1 i Directions: s(L) → 1 s(R) → 11 Universal Turing Machine Universal Turing Machine Encoding scheme Encoding Encoding transitions: Encoding for a TM Encode each state, symbol, direction Encode each of it’s moves Separate by 0 Separate by 0’s The transition δ (p,a) = (q, b, D) can be e(T) = e(m 1 )0e(m 2 )0…0e(m k )0 encoded as: s(p)0s(a)0s(q)0s(b)0s(D) Universal Turing Machine Universal Turing Machine The input to M u will be Encoding Scheme an encoded TM and Finally, the description of the TM and the encoding of the string to run on the TM will a string w to run on that TM be separated by a blank We encode x by individually encoding the Input to M u characters of x (separated by 1’s) e(M) e(x) x = z 1 z 2 …z n e(x) = s(z 1 )0s(z 2 )0…0s(z n )0 3
Universal Turing Machine Universal Turing Machine Encoding example Encoding example States States q 1 – state 1 q 1 – state 1 q 2 – state 2 q 2 – state 2 q 3 – state 3 q 4 – state 4 q 3 – state 3 Symbols q 4 – state 4 B – symbol 1 Symbols a – symbol 2 1 0 1 0 111 0 1 0 11 B – symbol 1 b – symbol 3 Directions a – symbol 2 s(L) → 1 b – symbol 3 s(R) → 11 Universal Turing Machine Universal Turing Machine Encoding scheme The set of all TMs is countably infinite The actual scheme isn’t really important (in We can define a one-to-one and onto fact, there are many) function between the set of TMs and the set of natural numbers { 0, 1, 2, …} What is important is that we can encode a TM and it’s input as a binary string. Uncountably infinite sets are larger than countably infinite sets This encoding defines a unique “serial number” to each TM Universal Turing Machine Universal Turing Machine How it works How it works On a single move, ... 3 tape TM The symbol on each tape is read Tape 1 – Working tape ... The symbol on each Tape 2 – Input and output tape tape is written Tape 3 – encoded form of the state that ... machine being simulated is in The tape head for Read head(s) each tape is moved independently Note that a 3 tape TM is equivalent to a State “basic” TM. Machine (program) 4
Universal Turing Machine Universal Turing Machine How it works How it works When we start e(T) e(x) is on tape 1 Step 3: Now simulation begins Step 1: Move e(x) from tape 1 to tape 2 “read” and replace character on tape 2 and delete from tape 1 “read” state on tape 3 Tape 2: e(x) “find” a transition in the encoded machine on Step 2: Copy encoded initial state of T to tape 1. tape 3 Replace destination state onto tape 3 Tape 3: s(q 1 ) Replace character on tape 2. Move head on tape 2 appropriately Universal Turing Machine Universal Turing Machine Reality check: What have we done? How will the machine finish? Defined: The TM being simulated has nowhere to go. M u will never find a suitable transition A means to encode a TM as a binary string The TM being simulated goes into an infinite loop Defines it’s “serial number” Set of all TMs is infinitely countable M u will continually simulate these moves A Universal TM (M u ) that takes as input: The TM being simulated halts An encoded TM, M M u will halt with halt state on it’s 3 rd tape An encoded input string, w M u will copy the contents of Tape 2 to Tape 1 That will simulate the running of w on M Questions? Next time (Monday): Languages and TMs Godel, Escher, Bach! Next class: Exam 2 5
Recommend
More recommend