research36 min studyLesson 974 in Mathematics

Turing machines and computable functions

Trace an explicit unary machine and distinguish total output procedures from partial searches.

On this page

What you’ll understand

  • Specify configurations, transition rules, and an input/output encoding.
  • Prove a concrete machine terminates with the intended output.
  • Distinguish partial computability, total computability, and the Church–Turing thesis.

A computation becomes a mathematical object once its states, storage, encoding, and local update rule are fixed. Turing machines provide one precise model with finite instructions and unbounded available tape. A particular run may halt or continue forever. We will trace a small machine completely, prove its termination for every valid input, and contrast it with a search that fails to produce an output on some inputs even though every individual search step is effective.

A finite program acts on an unbounded configuration space

Use a deterministic machine with a two-way infinite tape, a finite alphabet containing blank B and symbol 1, finitely many states, and one head. A nonhalting transition reads the current state and symbol, writes a symbol, moves left or right, and chooses a state. A configuration records the state, head position, and finite nonblank tape content. Our halt state has no outgoing rule. Other standard machine conventions can simulate this one and do not change which partial functions are computable.

Encode n by n consecutive ones starting at position zero, with the head at zero; zero is the blank tape. Output is the length of a contiguous block of ones in the halting configuration for the example below. This encoding must be stated before interpreting the machine as a numerical function. Merely counting states or watching one run does not determine what function a program computes on all inputs, nor whether every run halts.

δ(q,a)=(q1,b,D)⟹(q,a,head j)↦(q1,b,head j±1).\delta(q,a)=(q_1,b,D)\quad\Longrightarrow\quad(q,a,\text{head }j)\mapsto(q_1,b,\text{head }j\pm1).
Here D is a left or right move, and the complete tape contents are part of the configuration.↔ Scroll wide equations horizontally.

Halting determines the domain of a partial function

Fix an effective enumeration of machine descriptions and a standard computable encoding of inputs and outputs. The notation phi sub e denotes the partial function computed by description e. Its value is defined exactly when the run halts with a valid output under the adopted convention. A function is total computable when one machine returns its value on every input. A partial computable function may diverge outside its domain; divergence is absence of an output, not an additional numerical value.

Unbounded minimization illustrates the difference. To find the least y whose square equals x, test y=0,1,2 and continue. It halts with three at input nine, but never halts at input two. A total algorithm deciding whether x is a square can instead stop once the square exceeds x and return a negative answer. The first procedure's intended output is a root, while the second decides a property; these are different specifications with different termination obligations.

φe:N⇀N,dom⁡(φe)={x:φe(x)↓}.\varphi_e:\mathbb N\rightharpoonup\mathbb N,\qquad\operatorname{dom}(\varphi_e)=\{x:\varphi_e(x)\downarrow\}.
The arrow permits an undefined value when the computation does not halt.↔ Scroll wide equations horizontally.

Simulation theorems are different from the general thesis

One can mathematically prove equivalence between specific models, such as Turing machines, partial recursive functions, and suitable register machines, by explicit simulations in both directions. The Church–Turing thesis identifies the informal notion of an effective procedure with these formal notions. Because the informal side is not independently formalized, this identification is a thesis supported by many simulations, not the same kind of theorem as a simulation between two fully specified models.

Computability also differs from practical efficiency. A terminating program can take a vast number of steps or use enormous encodings, while an undecidable task has no correct total algorithm at all under the specification. Our unary machine has an exact linear step count, which supplies a genuine termination proof. Later diagonal arguments will concern arbitrary programs with unbounded configurations; a finite-state residue orbit cannot stand in for that whole class.

t(n)=n+3for the append-three machine below,φ(n)=n+3 for every n∈N.t(n)=n+3\quad\text{for the append-three machine below},\qquad\varphi(n)=n+3\text{ for every }n\in\mathbb N.
The step count is measured under the explicitly stated unary input and transition conventions.↔ Scroll wide equations horizontally.

Append three unary symbols in exactly n+3 transitions

Use states q,r,s,h, with h halting. Set δ(q,1)=(q,1,R)\delta(q,1)=(q,1,R), δ(q,B)=(r,1,R)\delta(q,B)=(r,1,R), δ(r,B)=(s,1,R)\delta(r,B)=(s,1,R), and δ(s,B)=(h,1,L)\delta(s,B)=(h,1,L). Trace input two and prove the result for every unary input.

  1. Initially positions zero and one contain 1, and the head is at zero in state q. Two q-transitions scan these symbols without changing them, leaving the head at position two, the first blank.

  2. The next three transitions write ones at positions two, three, and four. The successive states become r,s,h, and the final left move leaves the head at position three. The tape now contains five consecutive ones and the machine halts after five transitions.

  3. For input n, q performs exactly n scans before reaching the first blank. The following two right moves reach fresh blanks, so the r and s rules apply. Three symbols are appended and h is entered, proving output n+3 and termination after n+3 transitions, including input zero.

12⟼15,1n⟼1n+3,t(2)=5.1^2\longmapsto1^5,\qquad1^n\longmapsto1^{n+3},\qquad t(2)=5.
The last write and move enter h; head placement does not alter the declared output-length convention.↔ Scroll wide equations horizontally.
The result

The machine computes a total unary function n↦n+3. Its proof uses the whole transition specification and an arbitrary n, not just the successful input-two trace.

Explore the model

Interactive lab

Interactive lab · root-finding

Approximation termination differs from exact root search

Pause and Reset, set target c to 2 and upper bound U to 2, then take four Steps. Predict bracket [1.375,1.5], midpoint 1.4375, and error bound 0.0625. For a fresh run Reset and set both c to 2.25 and U to 3; one Step finds midpoint 1.5 exactly and collapses the bracket. This quadratic bisection is capped at fifty refinements and is not the unbounded integer-root search or an arbitrary Turing machine. Control changes retain time.

Approximation termination differs from exact root searchBisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. Current readings: Midpoint after 0 refinements: 1.5; Bracket error bound: 1.5; Computed residual · x² − c: 0.25. All parameters are adjustable with the labeled controls below.Bisection on x squared minus 2: bracket from 0 to 3 after 0 refinements.00.751.52.253−2.360.192.745.297.84x · bracket stays nonnegativef(x) = x² − cn = 0 · [ 0, 3 ]
Quadratic / midpointCurrent bracketPositive root
Midpoint after 0 refinements
1.5
Bracket error bound
1.5
Computed residual · x² − c
0.25
t = 0 s

Bisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forAn explicit approximation tolerance can give a stopping condition even when exact equality is never reached.

Check your understanding

The procedure that tests y=0,1,2,… until y²=x computes what?

Try it yourself

Give the exact transition count and final head position for the append-three machine on input four. Then describe a total square decider and explain its termination on input seven.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

There are n scans and three writes. A square decider may stop with false as soon as y² exceeds its nonnegative input.

Compare with the solution

The machine makes seven transitions, writes a block of seven ones at positions zero through six, and finishes at position five after the final left move. For a square decider, test successive y and return true on equality, false on the first strict excess. At input seven, squares 0,1,4 are below seven and nine exceeds it, so y=3 gives false. Since squares eventually exceed every fixed input, this modified procedure halts on every natural input.

Take it with you

  • A numerical computation needs explicit input, output, and transition conventions.
  • Total computability requires halting on every input; partial computability permits divergence.
  • Formal model equivalence is provable, while the Church–Turing identification also involves an informal notion.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.