Machine descriptions for the universal Turing machine #
A TMDesc describes a single-work-tape deterministic Turing machine as
finite data: a state bit-width w (states are numbers below 2^w), start
and halt states, and a transition table (List DescEntry, first match wins).
Encoding #
A description is laid out as a string over the writable alphabet
Γw = {0, 1, □}, with □ acting as a field/entry separator:
qstart(w bits) □ qhalt(w bits) □ entry₀ □ entry₁ □ ⋯ □ entryₘ □ □
Each entry is 2w + 16 bit-symbols with no internal separators (field widths
are determined by w): key q(w) si(2) sw(2) so(2), action
q'(w) ww(2) wo(2) di(2) dw(2) dOut(2). The state width w is defined by
the length of the leading qstart field. The table ends at the first empty
segment (□□), so trailing junk is ignored — every description has
infinitely many encodings (decodeDesc_encodeDesc_append), which the
hierarchy-theorem diagonalization relies on.
The binary encoding encodeDesc : TMDesc → List Bool maps each Γw symbol
to 2 bits via Γw.encode; decodeDesc : List Bool → TMDesc is total
(unparseable segments are skipped, missing fields default), so every binary
string denotes some machine.
Main definitions #
DescAct,DescEntry,TMDesc— machine descriptionsTMDesc.lookup— first-match transition lookup with default actionTMDesc.syms/encodeDesc— canonical encodingparseSyms/decodeDesc— total decodingTMDesc.WF— well-formedness (all state fields below2^w)
Main results #
decodeDesc_encodeDesc— roundtrip on well-formed descriptionsdecodeDesc_encodeDesc_append— roundtrip ignores trailing junk
The action part of a transition-table entry: next state, writes for the
work and output tapes, and directions for the input, work, and output
heads (matching the component order of TM.δ).
- q' : ℕ
The next state (as a number below
2^w). - ww : Γw
The symbol written to the work tape.
- wo : Γw
The symbol written to the output tape.
- di : Dir3
The input-head direction.
- dw : Dir3
The work-head direction.
- dOut : Dir3
The output-head direction.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
One transition-table row for a single-work-tape machine: the key (state and the three symbols under the input/work/output heads) together with the action to take.
- q : ℕ
The state this row fires in.
- si : Γ
The symbol under the input head.
- sw : Γ
The symbol under the work head.
- so : Γ
The symbol under the output head.
- act : DescAct
The action to take when the key matches.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
A description of a single-work-tape deterministic TM: state bit-width
w (states are numbers below 2^w), start and halt states, and a
transition table with first-match-wins semantics (TMDesc.lookup).
- w : ℕ
The state bit-width: states are numbers below
2^w. - qstart : ℕ
The start state.
- qhalt : ℕ
The halt state.
The transition table, first match wins.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Identity write-back: the Γw symbol that leaves a read symbol unchanged
when written. ▷ maps to □, which is harmless: ▷ occurs only at
cell 0, where writes are structural no-ops.
Equations
Instances For
The default action taken when no table entry matches: go to the halt state, write back what was read, and keep all heads in place.
Equations
- One or more equations did not get rendered due to their size.
Instances For
First-match transition lookup; missing keys take the default action.
Equations
Instances For
A description is well-formed when every state field is below 2^w, so
the fixed-width binary encoding is faithful.
Instances For
A bit as a desc-tape symbol.
Equations
Instances For
A bit string as desc-tape symbols.
Equations
Instances For
The desc-tape symbols of one table entry (given state width w):
q(w) si(2) sw(2) so(2) q'(w) ww(2) wo(2) di(2) dw(2) dOut(2),
2w + 16 symbols with no separators.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The desc-tape symbols of a description:
qstart(w) □ qhalt(w) □ entry₀ □ ⋯ □ entryₘ □ □.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The canonical binary encoding of a description: each desc-tape symbol
becomes 2 bits via Γw.encode.
Equations
Instances For
Total 2-bit-group decoding: 00 → 0, 01 → 1, and both remaining
patterns (10, 11) map to the separator □. Left inverse of
Γw.encode on the three encodable patterns.
Equations
Instances For
Group a bit string into consecutive pairs and decode each; a trailing odd bit is dropped.
Equations
- Complexity.groupPairs (b₀ :: b₁ :: rest) = Complexity.symOfPair b₀ b₁ :: Complexity.groupPairs rest
- Complexity.groupPairs x✝ = []
Instances For
Decoding pairs is a left inverse of symbol-wise binary encoding.
groupPairs distributes over appending at an even boundary.
Every symbol-wise binary encoding has even length.
The bit denoted by a desc-tape symbol, if any.
Equations
Instances For
Split off the first field: the symbols before the first □, and the
rest after it. An empty first field means the input started with a
separator (or was empty).
Equations
- Complexity.takeField [] = ([], [])
- Complexity.takeField (Complexity.Γw.blank :: rest) = ([], rest)
- Complexity.takeField (s :: rest) = (s :: (Complexity.takeField rest).1, (Complexity.takeField rest).2)
Instances For
The number denoted by a field (its bit symbols, read big-endian).
Equations
Instances For
Total read-symbol decoder (left inverse of Γ.encode).
Equations
Instances For
Total write-symbol decoder; 11 decodes to □.
Equations
Instances For
Total direction decoder; 11 decodes to stay.
Equations
Instances For
Parse one table entry from a (blank-free) segment: reject if shorter
than 2w + 16, otherwise decode the fixed-width fields sequentially
from the prefix and ignore any excess.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parse the table: segments are separated by □; parseable segments
become entries, unparseable (too short) segments are skipped, and the
first empty segment (a □□ or end of input) terminates the table.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.parseEntries w [] = []
- Complexity.parseEntries w (Complexity.Γw.blank :: rest) = []
Instances For
Decode a desc-tape symbol string into a description. The state width is
the length of the leading qstart field; a qhalt field of any other
length denotes the out-of-range sentinel 2^w (a machine that never
halts), matching the universal machine's symbol-wise comparison.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Total decoding of a binary string into a machine description.
Equations
Instances For
One-step unfolding of the table parse on a segment-headed input.
Parsing the encoded table recovers it, ignoring anything after the terminating empty segment.
Roundtrip with padding: decoding an encoded well-formed description recovers it exactly, no matter what junk follows the encoding. This gives every description infinitely many encodings — the padding fact the hierarchy-theorem diagonalization relies on.
Roundtrip: decoding an encoded well-formed description recovers it.