1
Turing Machines
Computation and programming
Computation with Turing Machines
- Computing functions with TMs
– The result of the function applied to an input string x, will be left on the tape when the machine halts.
- Note: it doesn’t matter if the machine halts in a final
state.
– Functions with multiple arguments can be placed on the input tape with arguments separated by some character.
Computation with Turing Machines
- Turing’s original use of his machine was to
calculate integer valued functions.
– Integers were represented in unary as blocks of a single symbol. – Example
- 000000 would represent 6
- 0000 would represent 4
– In our text
- 0s are used as the unary symbol
- 1s are used to separate arguments
Computation with Turing Machines
- Computing functions with TMs
– Formally,
- Let M = (Q, Σ, Γ , δ, q0, B, F) be a TM and let f be a
partial function on Σ*. We say T computes f if for every x ∈ Σ* where f is defined:
– q0x a* pf(x)
- And for every other x, T fails to halt on input x.
Computation with Turing Machines
- Computing functions with TMs
– Formally (with multiple arguments)
- Let M = (Q, Σ, Γ , δ, q0, B, F) be a TM and let f be a
partial function on (Σ*) k. We say T computes f if for every (x1, x2. …, xk) where f is defined:
– q0x1 1x2… 1xk a* pf(x1, x2. …, xk)
- And for every other k-tuple, T fails to halt on input
x.
Computation with Turing Machines
- Example
– Proper subtraction:
- m – n = max (m-n, 0)
- Use 0 as unary symbol
- M will start with 0m10n
- M will halt with 0(m-n) on it’s tape