Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.BlockComputation.QueryReplay

Query-machine replay inside a local tape window #

The query machine stores three blocks per work tape, binary head positions and a remaining-step counter. The original input is read only through the query-machine input channel. Both native input boundaries read blank and input movement uses the existing clamping arithmetic.

A halted simulated machine keeps its data fixed while the replay counter continues to zero. Only the three-valued output track is retained; no accumulated output word is stored or emitted. Initialization receives the input length explicitly; computing that length and decoding a caller's block labels are charged by the caller.

Main results #

Decode the existing ternary cell code; malformed codes read blank.

Finite local storage. Tape families are fixed-size tuples, not finite lookup tables over whole windows. Every runtime work cell and every head position is explicitly encoded.

  • inputLength : ℕ

    Length of the original read-only input.

  • width : ℕ

    Runtime block width.

  • remaining : ℕ

    Ticks still to replay.

  • inputPos : ℕ

    Native padded input position, including both blank boundaries.

  • control : Option Q

    Current simulated control, or halted.

  • heads : Fin k → ℕ

    Local work-head positions.

  • cells : Fin k → List ℕ

    Explicit local windows using ternary symbol codes.

  • Finite summary of emitted output.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Config.ext {k : ℕ} {Q : Type} {x y : Config k Q} (inputLength : x.inputLength = y.inputLength) (width : x.width = y.width) (remaining : x.remaining = y.remaining) (inputPos : x.inputPos = y.inputPos) (control : x.control = y.control) (heads : x.heads = y.heads) (cells : x.cells = y.cells) (track : x.track = y.track) :
x = y

Signed movement on the natural coordinates of a finite window. Valid replay heads do not attempt a left move at zero before their remaining-step counter reaches zero.

The symbol currently under each local work head.

Apply a native action to the fixed local windows. Writes outside a malformed short list do not allocate a long gap.

noncomputable def Turing.MultiTapePTM.BlockComputation.QueryReplay.tick {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (s : Config k Q) (symbol : Option Bool) :
Config k Q

One replay tick. Even after the simulated machine halts, the duration counter decreases.

A silent state-returning query subroutine. Callers supply an initialized state via runFrom.

@[simp]
@[simp]
theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.tick_width {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (s : Config k Q) (symbol : Option Bool) :
(tick M s symbol).width = s.width
theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.length_cells_tick {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (s : Config k Q) (symbol : Option Bool) (h : Fin k) :
((tick M s symbol).cells h).length = (s.cells h).length

Each local tape keeps exactly its original number of cells.

structure Turing.MultiTapePTM.BlockComputation.QueryReplay.Represents {k : ℕ} {Q : Type} {w : List Bool} (s : Config k Q) (c : Cfg k Bool Q w) (base : Fin k → ℤ) :

A local window agrees with the native configuration on every stored cell. Absolute tape origins belong to this proof relation, not to the runtime tape data.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Represents.applyAction {k : ℕ} {Q : Type} {w : List Bool} {s : Config k Q} {c : Cfg k Bool Q w} {base : Fin k → ℤ} (hs : Represents s c base) (a : Action k Bool Q) (hin : ∀ (h : Fin k), s.heads h < (s.cells h).length) (hpos : ∀ (h : Fin k), 0 < s.heads h) :

Applying the same action preserves every stored cell and the output track.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Represents.withRemaining {k : ℕ} {Q : Type} {w : List Bool} {s : Config k Q} {c : Cfg k Bool Q w} {base : Fin k → ℤ} (hs : Represents s c base) (remaining : ℕ) :
Represents { inputLength := s.inputLength, width := s.width, remaining := remaining, inputPos := s.inputPos, control := s.control, heads := s.heads, cells := s.cells, track := s.track } c base

The duration counter does not change the represented native data.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Represents.tick {k : ℕ} {Q : Type} {w : List Bool} {s : Config k Q} {c : Cfg k Bool Q w} {base : Fin k → ℤ} (M : MultiTapeTM k Bool Q) (hs : Represents s c base) (hin : ∀ (h : Fin k), s.heads h < (s.cells h).length) (hpos : ∀ (h : Fin k), 0 < s.heads h) :

A tick simulates one native step whenever all current work heads are in the stored window.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.step_eq_tick {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (w : List Bool) (s : Config k Q) (hrem : 0 < s.remaining) :
(machine M).step w s = tick M s w[s.inputPos - 1]?

A live duration counter takes one local replay tick.

The counter uses exactly the requested duration, including halted simulated prefixes.

Replay never changes the block width.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.length_cells_runFrom {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (w : List Bool) (s : Config k Q) (t : ℕ) (h : Fin k) :
(((machine M).runFrom w s t).cells h).length = (s.cells h).length

Replay never allocates cells beyond its supplied fixed windows.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.runFrom_represents {k : ℕ} {Q : Type} {w : List Bool} (M : MultiTapeTM k Bool Q) {s : Config k Q} {c : Cfg k Bool Q w} {base : Fin k → ℤ} (hs : Represents s c base) (hrem : s.remaining = s.width) (hlen : ∀ (h : Fin k), (s.cells h).length = 3 * s.width) (hheads : ∀ (h : Fin k), s.width ≤ s.heads h ∧ s.heads h < 2 * s.width) {t : ℕ} (ht : t ≤ s.width) :

Replaying a block preserves the native state, heads, stored windows and output track at all clocked prefixes. The initial heads are in the middle block, leaving room for width moves.

def Turing.MultiTapePTM.BlockComputation.QueryReplay.loadView {k : ℕ} {Q : Type} (inputLength width : ℕ) (J : Option (Fin k) → ℤ) (v : View k Q width) :
Config k Q

Initialize the local replay from decoded block data. The input length is an explicit argument, and every work cell is stored using the existing ternary symbol code. Native loading and its semantic correspondence are provided by QueryReplayLoad and QueryReplayLoadCorrect.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.loadView_represents {k : ℕ} {Q : Type} {w : List Bool} (width : ℕ) (J : Option (Fin k) → ℤ) (v : View k Q width) :
Represents (loadView w.length width J v) (embedCfg width J v.1 v.2) fun (h : Fin k) => ↑width * (J (some h) - 1)

Decoded local data represents precisely the existing embedded native configuration.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.runFrom_loadView_represents {k : ℕ} {Q : Type} {w : List Bool} (M : MultiTapeTM k Bool Q) (width : ℕ) [NeZero width] (J : Option (Fin k) → ℤ) (v : View k Q width) {t : ℕ} (ht : t ≤ width) :
Represents ((machine M).runFrom w (loadView w.length width J v) t) (MultiTapeTM.runFrom (embedCfg width J v.1 v.2) t) fun (h : Fin k) => ↑width * (J (some h) - 1)

The actual query subroutine realizes the native block replay on the original input, without storing that word in its state.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.halted_runFrom_loadView {k : ℕ} {Q : Type} {w : List Bool} (M : MultiTapeTM k Bool Q) (width : ℕ) (J : Option (Fin k) → ℤ) (v : View k Q width) :
(machine M).halted ((machine M).runFrom w (loadView w.length width J v) width) = true

A requested replay is halted at exactly its width, even if the native machine halts sooner.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.live_runFrom_loadView {k : ℕ} {Q : Type} {w : List Bool} (M : MultiTapeTM k Bool Q) (width : ℕ) (J : Option (Fin k) → ℤ) (v : View k Q width) {t : ℕ} (ht : t < width) :
(machine M).halted ((machine M).runFrom w (loadView w.length width J v) t) = false

Every proper prefix remains live, even if the simulated machine has already halted.

def Turing.MultiTapePTM.BlockComputation.QueryReplay.result {k : ℕ} {Q : Type} (width : ℕ) (s : Config k Q) :
View k Q width

Decode the final local data back to a leaving view. Absolute work origins are multiples of width, so they do not affect the head residues.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.Represents.result_eq {k : ℕ} {Q : Type} {w : List Bool} {s : Config k Q} {c : Cfg k Bool Q w} (width : ℕ) [NeZero width] (J : Option (Fin k) → ℤ) (hs : Represents s c fun (h : Fin k) => ↑width * (J (some h) - 1)) (hlen : ∀ (h : Fin k), (s.cells h).length = 3 * width) :

A represented replay returns the native control and the contents of the original windows.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.result_runFrom_loadView {k : ℕ} {Q : Type} {w : List Bool} (M : MultiTapeTM k Bool Q) (width : ℕ) [NeZero width] (J : Option (Fin k) → ℤ) (v : View k Q width) :
result width ((machine M).runFrom w (loadView w.length width J v) width) = (Cfg.blockControl width (MultiTapeTM.runFrom (embedCfg width J v.1 v.2) width), Cfg.windowContents width J (MultiTapeTM.runFrom (embedCfg width J v.1 v.2) width))

The state-returning query subroutine computes exactly the native leaving view of the block.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.cells_lt_three_tick {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (s : Config k Q) (symbol : Option Bool) (hcells : ∀ (h : Fin k), ∀ a ∈ s.cells h, a < 3) (h : Fin k) (a : ℕ) :
a ∈ (tick M s symbol).cells h → a < 3

Every new work-cell code remains one of the three canonical symbols.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.cells_lt_three_runFrom {k : ℕ} {Q : Type} (M : MultiTapeTM k Bool Q) (w : List Bool) (s : Config k Q) (hcells : ∀ (h : Fin k), ∀ a ∈ s.cells h, a < 3) (t : ℕ) (h : Fin k) (a : ℕ) :
a ∈ ((machine M).runFrom w s t).cells h → a < 3

Replay preserves canonical ternary cell codes at every clocked prefix.

theorem Turing.MultiTapePTM.BlockComputation.QueryReplay.cells_lt_three_loadView {k : ℕ} {Q : Type} {w : List Bool} (width : ℕ) (J : Option (Fin k) → ℤ) (v : View k Q width) (h : Fin k) (a : ℕ) :
a ∈ (loadView w.length width J v).cells h → a < 3

The view loader writes only the existing blank/false/true codes.