Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.BlockComputation.Encoding

Fixed-width binary block-computation values #

An outer bit distinguishes FAIL from a valid leaving view. The payload stores the finite control state by a binary rank, each of the k+1 head residues in b.size bits, the output track in two bits, and every cell of the three work-tape windows in two bits. Window cells use canonical row-major blocks: tape, window port, residue, then cell bit. No rank of the whole view or unary encoding of window contents is used.

The supplied equivalence enumerates only the fixed machine's finite control states. The width is 1 + (s+1).size + (k+1)*b.size + 2 + 6*k*b. The positive block-width assumption is essential: ZMod 0 is infinite. Unused state/cell/track words decode to a halted state, blank cell or other output track respectively; a false outer bit always decodes to FAIL.

These are explicit semantic codecs, not native runtime codec certificates.

Main results #

Width of the three two-bit-cell windows on every work tape.

Width of the payload before the outer FAIL tag.

Width of one optionally failing block-computation value.

def Turing.MultiTapePTM.BlockComputation.Encoding.stateIndex {s : ℕ} {State : Type} (e : State ≃ Fin s) :
Option State ≃ Fin (s + 1)

Only the optional finite control state is numbered, independently of the windows.

def Turing.MultiTapePTM.BlockComputation.Encoding.encodeState {s : ℕ} {State : Type} (e : State ≃ Fin s) (state : Option State) :

Fixed-width binary code of the optional control state.

def Turing.MultiTapePTM.BlockComputation.Encoding.decodeState {s : ℕ} {State : Type} (e : State ≃ Fin s) (bits : Cslib.BitString (s + 1).size) :
Option State

An unused state rank represents the halted control state.

@[simp]
theorem Turing.MultiTapePTM.BlockComputation.Encoding.decodeState_encodeState {s : ℕ} {State : Type} (e : State ≃ Fin s) (state : Option State) :
decodeState e (encodeState e state) = state

The binary value of a head residue, padded to the runtime block-width bit length.

Read the binary value and reduce modulo the positive block width.

Residues in canonical Option (Fin k) order, with the input head included.

Read the fixed-width residues of all work heads and the input head.

Two bits separate blank, written zero and written one. The fourth word is unused.

Decode a cell tag, treating both words with a false first bit as blank.

The source output track has three cases: empty, exactly [true], and other.

Decode the output summary, assigning the unused word to other.

The explicit row-major two-bit encoding of all three windows on all work tapes.

Read all window cells in the same tape/port/residue order as the encoder.

def Turing.MultiTapePTM.BlockComputation.Encoding.encodePayload {k s b : ℕ} {State : Type} [NeZero b] (e : State ≃ Fin s) (view : View k State b) :

Encode the control record and all window cells with fixed field boundaries.

def Turing.MultiTapePTM.BlockComputation.Encoding.decodePayload {k s b : ℕ} {State : Type} [NeZero b] (e : State ≃ Fin s) (bits : Cslib.BitString (payloadBits k s b)) :
View k State b

Read the control fields and window cells at their fixed field boundaries.

@[simp]
theorem Turing.MultiTapePTM.BlockComputation.Encoding.decodePayload_encodePayload {k s b : ℕ} {State : Type} [NeZero b] (e : State ≃ Fin s) (view : View k State b) :
decodePayload e (encodePayload e view) = view
def Turing.MultiTapePTM.BlockComputation.Encoding.encode {k s b : ℕ} {State : Type} [NeZero b] (e : State ≃ Fin s) :
Option (View k State b) → Cslib.BitString (width k s b)

A false tag is FAIL; a true tag is followed by the explicit payload.

def Turing.MultiTapePTM.BlockComputation.Encoding.decode {k s b : ℕ} {State : Type} [NeZero b] (e : State ≃ Fin s) (bits : Cslib.BitString (width k s b)) :
Option (View k State b)

Read the outer FAIL bit before decoding a valid-view payload.

@[simp]
theorem Turing.MultiTapePTM.BlockComputation.Encoding.decode_encode {k s b : ℕ} {State : Type} [NeZero b] (e : State ≃ Fin s) (value : Option (View k State b)) :
decode e (encode e value) = value

Every genuine view, including FAIL, round-trips without identifying blank and written zero.

The explicit codec is injective; no enumeration of all possible views is involved.

theorem Turing.MultiTapePTM.BlockComputation.Encoding.width_eq (k s b : ℕ) :
width k s b = 1 + (s + 1).size + (k + 1) * b.size + 2 + 6 * k * b

The exact width charges all head residues, every cell, output track and FAIL.

theorem Turing.MultiTapePTM.BlockComputation.Encoding.width_le (k s b : ℕ) :
width k s b ≤ (7 * k + 1) * b + (s + 1).size + 3

For fixed control and work-tape counts the full payload is linear in the block width.