120 likes | 223 Vues
Liberalizing the definition of a TM. To show that results on TMs apply to real-world computers, it's simplest to show that TMs can be defined more and more liberally without changing the set of accepted languages
E N D
Liberalizing the definition of a TM • To show that results on TMs apply to real-world computers, it's simplest to show that TMs can be defined more and more liberally • without changing the set of accepted languages • The approach is to simulate more liberally defined TMs by less liberally defined TMs • We go briefly over some sorts of liberalizations below
The “stay” option • Suppose TM moves weren’t required to move to the left or right on the tape • in this model d: Q x G → Q x G x {L, R, S} • A move d(q,a) = (p,b,S) would be simulated by moves d(q,a) = (p’,b,R) and d(p’,b) = (p,b,L) • there would be a new state p’ for each p in Q
Multitrack TMs • In a multitrack TM, the tape is divided “lengthwise” into several tracks, each of which may be updated independently • but there’s still only one read/write head • Multitrack TMs with track alphabets G1, G2, … Gn may be simulated by an ordinary TM with a tape alphabet G1 x G2 x …x Gn
Multitape TMs • Multitape TMs differ from multitrack TMs • their read-write heads can move independently • An n-tape TM can be simulated by a 2n-track TM, where each tape corresponds to a pair of tracks • one to hold its contents, and • another having only one nonblank symbol, to show the position of the simulated read-write head • cf. Figure 10.7, p. 258 of Linz
Applications of multitape TMs • To keep an immutable copy of the input string • To allow checking off of symbols. • for acceptance of a language like {wcw | w ε {a,b}+ } • To allow additional memory components • e.g., a stack to allow a TM to simulate a PDA • e.g., a state to allow one TM to simulate another
Subroutines and TMs • Subroutines would correspond to sets of states with limited interaction with the rest of the program. • Subroutines that are called from more than one place would simply be replicated.
Nondeterministic TMs • Allowing nondeterminism in TMs does not allow the acceptance of any new languages • since a nondeterministic TM M may be simulated by an ordinary deterministic TM Md. • Md would systematically explore all possible computations of M. • by a breadth-first search, or (cf. Linz, Sec. 10.3) keeping track of all legal current IDs • This may require exponentially more moves than M would use.
TMs and CFLs • We can now see that a TM may simulate a PDA • since TMs can simulate nondeterminism • and multitape machines where one tape simulates the PDA's stack. • Thus every CFL is r.e. • In fact, every CFL is recursive • since the CYK algorithm may be implemented as a TM
Defining a universal TM • Recall that a universal TM needs to • take (an encoding of) another TM M • as well as the input x for M • and accept or not depending on whether M accepts x • We can’t allow x to come from all possible alphabets • So we assume that M’s alphabet is {0,1} • we’ll also use 0 and 1 alone to encode M
Encoding moves for the universal TM • To encode a TM, we may number the states, tape symbols, and directions as follows • q1 is the start state; q2 is the (unique!) final state • a1 is the blank; a2 is 0; a3 is 1 • d1 is L; d2 is R • Then the move d(qm,an) = (qi,aj,dk) is encoded as 1m01n01i01j01k
Encoding TMs for the universal TM • An encoding for a TM consists of a sequence of codes for its moves, separated by 00’s • it’s ok that this encoding is not unique • The encoding of an input <M,w> to the universal TM Mu looks like g000w • where g is the encoding for M • Mu may now simulate M on w and • halt and accept, halt and reject, or compute forever, depending on what M does
Counting TMs • Every TM has a finite encoding as a bit string starting with 1 • If this encoding for M represents the integer i in binary, then we may say that M = Mi • So there are only countably many TMs • since they may be put into 1-1 correspondence with the nonnegative integers • This conclusion holds even though • some bit strings don’t represent TMs, and • TMs may have multiple encodings