Interpretation of machine codes #
Code.toTM interprets a well-formed machine code as an operational multi-input Turing
machine (MIPRE.TM.MultiInput.Deterministic) over the alphabet Fin alphabetSize and
state set Fin stateCount: the transition function looks up the dense table at the
canonical position (Code.actionAt) and converts the raw entry into a transition output
(Code.interpretAction), with every range fact supplied by well-formedness through the
Code.actionAt_* lemmas. Code.toTM_tr records that this is definitional.
The machine code is the primary object and toTM its interpretation — never the other
way around. Everything here is executable: no Fintype.elems, no choice, no
noncomputable (planning/tm-infrastructure.md, decision D5 and Milestone B).
Bit-level input/output: coded machines read and write the reserved symbols 0/1
(Code.bitEmbedding, Code.bitInputs); every symbol they emit is one of the two bit
symbols (Code.outputSymbol_isBit), so decoding outputs as bit strings
(Code.decodeBitOutput) is total and faithful
(Code.decodeBitOutput_map_bitEmbedding).
The alphabet of a coded machine.
Equations
- c.Symbol = Fin c.alphabetSize
Instances For
The state set of a coded machine.
Equations
- c.State = Fin c.stateCount
Instances For
The two reserved I/O symbols of a coded machine: false ↦ 0, true ↦ 1 (the
alphabet has size at least two by well-formedness).
Instances For
Interpret one table entry as a transition output, given the well-formedness facts
for that entry: input moves and work actions are read off positionally, written symbols
and successor states are cast into Fin using their range facts, and the output bit is
embedded as a reserved I/O symbol.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The operational machine denoted by a code: start in the coded start state, and transition by looking up the dense table at the canonical position.
Equations
Instances For
The emitted symbol of a coded transition, at the level of raw data.
The successor state of a coded transition, at the level of raw data.
Every symbol a coded machine emits is one of the two reserved bit symbols.
Decode a machine-alphabet string as a bit string: symbol 1 is true, every other
symbol is false. On outputs of coded machines this is faithful, because only the two
bit symbols are ever emitted (Code.outputSymbol_isBit).
Equations
- c.decodeBitOutput l = List.map (fun (s : c.Symbol) => ↑s == 1) l