Turing
function, q0 ∈ Q is the initial state, BinΓ − Σ is the blank symbol, and F ⊆ Q is the set of final states. Instantaneous description (ID) X1 X2 . . . Xi−1 qXi. . . Xn of a TM. A move of a TM is denoted ; a sequence of zero or more moves is denoted ∗ . Turing machines to recognise languages accept by entering a final state (and halting); Turing machines to perform computation may simply halt when the computation is complete. Example of a TM to recognise palindromes (M, Ex. 16.2, Fig. 16.4). Machine structure: while true { if a { change a to B & move Rwhile a or b move R move L if B halt // odd-length palindrome if a { while a or b move L move R } } else if b { ... similarly ... } else { break } } if B halt // even-length palindrome Test on inputs abba, abbba, abaa. Example of a TM to recognise Lww = { ww | w ∈ {a, b}∗ } (M, Ex. 16.3, Fig. 16.5). Machine structure: // Stage 1: Check length is even, change as / bs to As / Bs while a or b { changea to A or b to B & move R while a or b move R move L change a to A or b to B & move L while a or b move L if A or B move R } // Stage 2: Change As and Bs in first half to as and bs if Blank halt if A or B move L while A or B change to a or b & move L if Blank move R // Stage 3: Compare first and second halves 2
while true { if a { change a to A & move R while a or b or Blank move R change Ato Blank & move L // fail if B while a or b or Blank move L if A or B move R } else if b { ... similarly ... } } if Blank halt Test on inputs aba, abaa, abab. The language L(M ) accepted by a TM M is the set of strings w in Σ∗ such that q0 w some state q in F and any tape strings α and β. αqβ for
The set of languages accepted by TMs is called the set of computably enumerable languages. The setof languages accepted by TMs that always halt is called the set of computable languages. Significance of this distinction. Example of a TM to perform integer subtraction (Ex. 8.4, Fig. 8.12). The initial tape is 0m 10n . (Who knows why they reversed the normal roles of 0s and 1s?) The TM halts with 0m−n on its tape. Machine structure: while 0 { // ID is q0ˆ(m-k)11ˆk0(n-k) change 0 to B & move R...
Regístrate para leer el documento completo.