A configuration should tell us everything we need to know to resume a TM computation from some arbitrary point ... wherever the machine was in its computation when we took a lunch break, perhaps. Hopefully it's clear that what would need to be remembered is the machine's state, what's on the tape, and where the tape head is pointing. This leads us to the following definition:
A configuration of a Turing Machine M = (Q,Σ,Γ,δ,s) is a 4-tuple (q,u,x,v) ∈ (Q ∪ {h}) x (Γ ∪ {□})* x (Γ ∪ {□}) x (Γ ∪ {□})* where
- q is the current state,
- u is the string of all characters to the left of the tape head,
- x is the symbol in the cell pointed to by the tape head, and
- v is the string of all symbols to the right of the tape head up to and including the symbol in the last non-blank cell (note that v is the empty string if every cell to the right of the tape head is blank).
So, if we consider the machine
... we can write down the computation of the machine on input abb as the following sequence of configurations:
(q0,λ,a,bb) ⇒ (q1,a,b,b) ⇒ (q0,ab,b,λ) ⇒ (q1,abb,□,λ) ⇒ (h,abb,□,λ)
For Turing Machine M = (Q,Σ,Γ,δ,s) configuration (q,u,x,v) yields (q',u',x',v') in one step if, letting δ(q,x) = (p,y,d):Oh yeah, q can't be h, the halt state!
(q',u',x',v') = {
(p,u,y,v) if d = S (p,uy,v1,v2...vk) if d = R and v = v1v2...vk (p,uy,□,λ) if d = R and v = λ (p,u1...um-1,um,yv) if d = L and u = u1u2...um, where m > 0
Notice that we have to take care not to allow a left move when the tape head is in the first cell. Now we are able to say precisely which sequence of configurations are encountered when a particular Turing machine is given a particular string as input.
Definition: A Turing machine M = (Q,Σ,Γ,δ,s) decides the language L ⊆ Σ* if for any string w ∈ Σ* there is a finite sequence of configurations C1,C2,...,Cm such that eitherwhere x ≠ □ if w ∈ L and x = □ otherwise.
- w = λ and (s,λ,□,λ) = C1 ⇒ C2 ⇒ ... ⇒ Cm = (h,u,x,v), or
- w = w1w2...wk, where the wi's are in Σ, and (s,λ,w1,w2...wk) = C1 ⇒ C2 ⇒ ... ⇒ Cm = (h,u,x,v)
Notice that this definition requires that the machine actually halts for any input string in Σ*. So a Turing Machine that decides a language always gives an answer, yes or no, in finite time. The situation isn't so pretty with semi-deciding, of course.
Definition: A Turing machine M = (Q,Σ,Γ,δ,s) semi-decides the language L ⊆ Σ* if for any string w ∈ Σ* there is a finite sequence of configurations C1,C2,...,Cm such that eitherif and only if w ∈ L. In other words, for input not in L the computation never reaches the halt state. For input in L, the computation halts.
- w = λ and (s,λ,□,λ) = C1 ⇒ C2 ⇒ ... ⇒ Cm = (h,u,x,v), or
- w = w1w2...wk, where the wi's are in Σ, and (s,λ,w1,w2...wk) = C1 ⇒ C2 ⇒ ... ⇒ Cm = (h,u,x,v)