Well-formed machine codes #
RawCode.WellFormed pins down when a raw description denotes a machine: alphabet of size
at least two (symbols 0/1 are the I/O bits), a nonempty state set containing the start
state, a dense transition table of exactly the canonical size
stateCount * (alphabetSize + 1) ^ (i + workTapeCount) (Turing.transitionIndex), and
per-entry arity and range constraints.
The predicate comes with an executable checker RawCode.wellFormedB and the equivalence
RawCode.wellFormedB_iff (decision D3 of planning/tm-infrastructure.md); through it,
WellFormed is decidable, so concrete literals can be certified by decide. The
Milestone C parser will run the same checker.
Code i bundles a raw code with its well-formedness proof; by proof irrelevance it is
just as first-order as RawCode i (Code.ext, DecidableEq). Code.actionAt is the
canonical table lookup, and the Code.actionAt_* lemmas expose the well-formedness facts
about the entry it returns — every later consumer of table entries (the interpretation of
Milestone B, the serialization of Milestone C, the universal machine of Milestones E–G)
goes through this single, dependency-free access point.
The well-formedness predicate #
Executable check that a successor state, if any, is below the state count.
Equations
- Turing.nextStateCheckB Q none = true
- Turing.nextStateCheckB Q (some q) = decide (q < Q)
Instances For
A raw code denotes a machine: the alphabet has at least the two I/O symbols, there is at least one state, the start state is in range, the transition table has exactly the canonical dense size, and every entry has the right arities and only in-range symbols and successor states.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The executable well-formedness checker; RawCode.wellFormedB_iff proves it decides
RawCode.WellFormed. The Milestone C parser accepts exactly the descriptions passing this
check.
The table loops run over toList with List.all (not Array.all) deliberately:
List.all is structurally recursive, so the kernel can evaluate this checker and
concrete literals can be certified by decide; Array.all does not kernel-reduce on
this toolchain.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The executable checker decides well-formedness.
Equations
Named accessors for the conjuncts #
The type of well-formed codes #
A well-formed machine code: a raw description together with its well-formedness
proof. By proof irrelevance, Code i is as first-order as RawCode i itself.
- raw : RawCode i
The underlying raw description.
- wf : self.raw.WellFormed
The well-formedness certificate.
Instances For
Equations
- Turing.instDecidableEqCode c₁ c₂ = decidable_of_iff (c₁.raw = c₂.raw) ⋯
The number of work tapes of a coded machine.
Equations
Instances For
The alphabet size of a coded machine (at least 2).
Equations
- c.alphabetSize = c.raw.alphabetSize
Instances For
The number of states of a coded machine (at least 1).
Equations
- c.stateCount = c.raw.stateCount
Instances For
The start state of a coded machine (in range by well-formedness).
Equations
- c.startState = c.raw.startState
Instances For
The canonical table lookup: the entry of the dense transition table at the normative
position transitionIndex q as bs. All later consumers of table entries go through this
single access point.