Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.BlockComputation.QueryReplayGateCorrect

Correctness of the native local gate subroutine #

The subroutine queries the original input and emits the existing Boolean label of the native leaving view precisely when all movement labels hold. The fixed template supplies no free input-dependent initial data: initialization and run time are explicit in the statements.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Gate.runFrom_eq {k s : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (e : Q ≃ Fin s) (w : List Bool) (context : Context k) (q : Config k Q) (t : ℕ) :
(machine M e).runFrom w (context, q) t = (context, (QueryReplay.machine M).runFrom w q t)

Retaining scheduling context preserves each physical replay transition exactly.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Gate.halted_runFrom_load {k s : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (e : Q ≃ Fin s) (w : List Bool) (N b positive negative : ℕ) (expected : Option (Fin k) → SignType) (raw : RawResult k Q) :
(machine M e).halted ((machine M e).runFrom w ((positive, negative, expected), Load.load (N, b, (positive, negative), raw)) b) = true

A local call stops at its requested runtime width, even if native control halted earlier.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Gate.live_runFrom_load {k s : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (e : Q ≃ Fin s) (w : List Bool) (N b positive negative : ℕ) (expected : Option (Fin k) → SignType) (raw : RawResult k Q) {t : ℕ} (ht : t < b) :
(machine M e).halted ((machine M e).runFrom w ((positive, negative, expected), Load.load (N, b, (positive, negative), raw)) t) = false

Before the requested duration, the local call remains live. Together with the stopping lemma this supplies the exact first-halt contract for state-returning query calls.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Gate.finish_runFrom_load {k s : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (e : Q ≃ Fin s) (w : List Bool) (b positive negative : ℕ) [NeZero b] (expected : Option (Fin k) → SignType) (raw : RawResult k Q) (hcanonical : Load.CanonicalWindows b raw) (J : Option (Fin k) → ℤ) (hinput : J none = ↑positive - ↑negative) :
have view := RawResult.toView b raw; have c := MultiTapeTM.runFrom (embedCfg b J view.1 view.2) b; (machine M e).finish ((machine M e).runFrom w ((positive, negative, expected), Load.load (w.length, b, (positive, negative), raw)) b) = List.ofFn (Encoding.encode e (if ∀ (head : Option (Fin k)), Cfg.blockIndex b c head = J head + ↑(expected head) then some (Cfg.blockControl b c, Cfg.windowContents b J c) else none))

Finishing a loaded replay emits exactly the encoded leaving view on successful all-head motion validation, and the exact FAIL code otherwise. Retained context and windows are explicit.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Gate.length_runFrom_load_le {k s : ℕ} {Q : Type} [Finite Q] (M : MultiTapeTM k Bool Q) (e : Q ≃ Fin s) (w : List Bool) (b positive negative : ℕ) [NeZero b] (expected : Option (Fin k) → SignType) (raw : RawResult k Q) (hcanonical : Load.CanonicalWindows b raw) (J : Option (Fin k) → ℤ) (hinput : J none = ↑positive - ↑negative) (t : ℕ) :
(encState ((machine M e).runFrom w ((positive, negative, expected), Load.load (w.length, b, (positive, negative), raw)) t)).length ≤ 2 * (encContext (positive, negative, expected)).length + 1 + 1024 * (k + 1) * (b + w.length.log2 + Nat.card (Option Q) + Nat.card MultiTapeNTM.ChoiceTable.OutputTrack + 1)

Every physical subroutine clock charges retained context plus the actual replay state.