=========================================================================== CSC 363 Lecture Summary for Week 2 Winter 2008 =========================================================================== Definitions: - Recall a language L is simply a subset of S* (set of all strings over alphabet S). - L is "Turing-recognizable" (recognizable/semi-decidable/recursively enumerable) if there is some TM M such that L = L(M), i.e., if there is some TM M such that for all strings w (- S*, M accepts w when w (- L and M rejects or loops on w when w !(- L. - L is "Turing-decidable" (decidable/recursive) if there is some TM M that halts on every input such that L = L(M). Such a TM is called a "decider". Previous examples show { 0^{2^n} | n >= 0 } and { w#w | w (- {0,1}* } are decidable. We will see many other examples. -------- Variants -------- How do we know TMs are the "right" model? Consider different decisions we made when defining TMs and how they affect the outcome. Compare different models by the languages they recognize: models that can recognize the same class of languages are equivalent. Example: Finite-State Automata (FSA) are NOT equivalent to TMs (they are strictly weaker), because every language recognized by a FSA is regular and can be recognized by a TM, but TMs can recognize non-regular languages, such as { w#w | w (- {0,1}* } or { 0^n 1^n : n (- N }. Turing machines with "stay put" head movement: - Allow head to stay on same square during a transition. Formally, d : Q-{q_A,q_R} x T -> Q x T x {L,R,S}. - Equivalent to TM: simulate stay put move by moving right to "extra" state then left to correct state (need more than one extra state). - Details: Let M = (Q,S,T,q_1,q_A,q_R,d) be a regular TM. Then M' = M = (Q,S,T,q_1,q_A,q_R,d) is also a stay-put TM (one that just happens to never use a stay-put transition) whose behaviour is identical to that of M on every input string. In other words, regular TMs are just special cases of stay-put TMs. Now, let M = (Q,S,T,q_1,q_A,q_R,d) be a stay-put TM, where Q = {q_1,...,q_n}. Let M' by the regular TM defined as follows. S' = S, T' = T (i.e., same input and tape alphabets as M) Q' = Q U {q'_1,...,q'_n} (i.e., create a copy of each state of M) initial state = q_1 (same as for M) accepting state = q_A (same as for M) rejecting state = q_R (same as for M) d' is defined as follows: - for all q_i,q_j (- Q, a,b (- T such that d(q_i,a) = (q_j,b,L) or d(q_i,a) = (q_j,b,R), set d'(q,a) = d(q,a) (i.e., all transitions that move left or right stay the same); - for all q_i,q_j (- Q, a,b (- T such that d(q_i,a) = (q_j,b,S), set d'(q_i,a) = (q'_j,b,R) (i.e., all transitions that stay put become transitions that move right to one of the new states); - for all q'_j (- Q', a (- T, set d'(q'_j,a) = (q_j,a,L) (i.e., each new state simply moves one square left and back to the corresponding original states). On every input w (- S*, the behavious of M' is the same as that of M: - the initial configuration of M (q_1 w) remains the same in M' - each of the following transitions of M remains the same in M': u q_i av -> ub q_j v uc q_i av -> u q_j cbv q_i av -> q_j bv when d(q_i,a) = (q_j,b,L) - each transition of M where the head stays put u q_i av -> u q_j bv becomes the following transitions in M' u q_i av -> ub q'_j v -> u q_j bv Hence, M' accepts/rejects/loops exactly when M accepts/rejects/loops. Turing machines with doubly infinite tape: - Similar to regular TMs except no leftmost square. Tape initially all blank except for input, and head starts on first symbol of input. - Equivalent to regular TM: (main idea only) . Doubly-infinite tape TMs can simulate regular TMs: use a few extra states at start of computation to write a special symbol to the left of input; then, during computation, remain in same state and move right whenever special symbol is read. . Regular TMs can simulate doubly-infinite tape TMs: start by placing special symbol on leftmost square (shift input one square right) and on first blank to the right of input; during computation, whenever "left edge" symbol is read, shift entire tape content one square right (insert blank), then return to leftmost blank square to continue computation; whn "right edge" symbol is read, simply move it one square to the right (insert blank) then go back to newly inserted blank square and continue. . Formal details: see separate notes on website, as an extended example. - Note that both directions are necessary (even if one is easier). Multi-tape Turing machines: - Allow more than 1 tape, each with independent head. Initially, all tapes blank except tape 1 that contains input. In one step, current state and symbols read on all tapes determine next state, symbols written and head movements for all tapes. Formally, d : Q-{q_A,q_R} x T^k -> Q x T^k x {L,R}^k. Note: Different from k independent machines running concurrently! - Equivalent to TM: keep track of contents of k tapes separated by special symbol, as well as head positions by using additional symbols (duplicates of tape alphabet), and use additional states to remember k symbols to read/write (since k is fixed). Simulating one step of multi-tape machine requires single-tape machine to scan over its entire tape twice: once to read k tapes, once to update k tapes. Other direction is trivial since 1 tape is just a special case of k tapes. - Details: Theorem 3.13 on p.149.