Documentation

CslibFrontier.Computability.Machines.ReadMachine.VirtualWord.Simulation

Resuming arbitrary query machines on virtual inputs #

The outer machine's encoded state is retained across each translated read. The runtime header and cursor are loaded once and then preserved. Optional reads distinguish an absent symbol from some false, including past the virtual end. Emission and final-output continuations are those of the outer machine, without restricting its state type or transition graph.

Main definitions #

Main results #

This original construction addresses the generic consumer gap in the recomputation argument for Lemma 3.3, expanded ECCC TR13-047, printed page 6 [GNR+13]. It does not prepare headers, regenerate answer words, implement suffix iteration or adaptive-to-tt conversion, or prove Lemma 3.3.

Saved runtime header/cursor and unrestricted outer state.

  • runtime : Runtime.State

    State of the underlying runtime header/bit accessor.

  • outer : σ

    State of the simulated outer query machine.

theorem Turing.VirtualWord.Simulation.State.ext {σ : Type} {x y : State σ} (runtime : x.runtime = y.runtime) (outer : x.outer = y.outer) :
x = y
def Turing.VirtualWord.Simulation.instDecidableEqState.decEq {σ✝ : Type} [DecidableEq σ✝] (x✝ x✝¹ : State σ✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
theorem Turing.VirtualWord.Simulation.encState_mk_deg {σ : Type} (enc : σ ↪ List Bool) :
MultiTapeTM.ComputableInDegree (fun (p : Runtime.State × σ) => { runtime := p.1, outer := p.2 }) (encStateFields enc) (encState enc) 1 1

Both the header and the entire outer encoding are charged.

theorem Turing.VirtualWord.Simulation.encState_mk_inO {σ : Type} (enc : σ ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Runtime.State} {T0 S0 : γ → ℕ} {x1 : γ → σ} {T1 S1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn Runtime.encState T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn enc T1 S1) :
MultiTapeTM.ComputableInO (fun (x : γ) => { runtime := x0 x, outer := x1 x }) encIn (encState enc) (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Turing.VirtualWord.Simulation.encState_runtime_polyTime {σ : Type} (enc : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State σ} :
MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encState enc) → MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).runtime) encIn✝ Runtime.encState
theorem Turing.VirtualWord.Simulation.encState_outer_inO {σ : Type} (enc : σ ↪ List Bool) :
MultiTapeTM.ComputableInO State.outer (encState enc) enc (fun (a : State σ) => ((encState enc) a).length) fun (a : State σ) => ((encState enc) a).length
theorem Turing.VirtualWord.Simulation.encState_mk_budget {σ : Type} (enc : σ ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Runtime.State} {x1 : γ → σ} (h0 : MultiTapeTM.ComputableInSpace x0 encIn Runtime.encState budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn enc budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { runtime := x0 x, outer := x1 x }) encIn (encState enc) budget
theorem Turing.VirtualWord.Simulation.encState_runtime_budget {σ : Type} (enc : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State σ} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ (encState enc) S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).runtime) encIn✝ Runtime.encState S✝
@[reducible, inline]

The tuple of the fields of encState.

theorem Turing.VirtualWord.Simulation.encState_outer_budget {σ : Type} (enc : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State σ} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ (encState enc) S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).outer) encIn✝ enc S✝
theorem Turing.VirtualWord.Simulation.encState_mk_polyTime {σ : Type} (enc : σ ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Runtime.State} {x1 : γ → σ} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn Runtime.encState) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn enc) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { runtime := x0 x, outer := x1 x }) encIn (encState enc)
theorem Turing.VirtualWord.Simulation.encState_outer_polyTime {σ : Type} (enc : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State σ} :
MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encState enc) → MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).outer) encIn✝ enc

Parameters retained by the initialized runtime accessor.

Restore the outer machine's optional input symbol from one physical tail read.

One fixed simulator loads the runtime header, then resumes the outer machine.

theorem Turing.VirtualWord.Simulation.run_initializing {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) {t : ℕ} (ht : t ≤ 2 * (encData p.data).length + 2) :
(machine M).run (Runtime.encInput p) t = { runtime := Runtime.machine.run (Runtime.encInput p) t, outer := M.init }

Loading never changes the suspended outer state.

theorem Turing.VirtualWord.Simulation.read_loaded {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (s : σ) :
(machine M).read (Runtime.encInput p) { runtime := Evaluator.loaded p, outer := s } = p.original[M.query s]?

The loaded simulator queries precisely the unchanged original-input tail.

theorem Turing.VirtualWord.Simulation.symbol_loaded {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (s : σ) :
symbol M { runtime := Evaluator.loaded p, outer := s } p.original[M.query s]? = M.read (word p.original p.data.cut p.data.suffix) s

The translated symbol is the exact optional read, including the virtual end.

theorem Turing.VirtualWord.Simulation.step_loaded {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (s : σ) :
(machine M).step (Runtime.encInput p) { runtime := Evaluator.loaded p, outer := s } = { runtime := Evaluator.loaded p, outer := M.step (word p.original p.data.cut p.data.suffix) s }

A resumed step preserves the header/cursor and exactly advances the arbitrary outer state.

theorem Turing.VirtualWord.Simulation.resume {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (s : σ) (k : ℕ) :
((machine M).step (Runtime.encInput p))^[k] { runtime := Evaluator.loaded p, outer := s } = { runtime := Evaluator.loaded p, outer := (M.step (word p.original p.data.cut p.data.suffix))^[k] s }

Any number of resumed steps, from any saved state, preserves the loaded runtime data.

theorem Turing.VirtualWord.Simulation.run_loaded {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (k : ℕ) :
(machine M).run (Runtime.encInput p) (2 * (encData p.data).length + 2 + k) = { runtime := Evaluator.loaded p, outer := M.run (word p.original p.data.cut p.data.suffix) k }

After initialization the outer run is simulated step for step, even after halting.

theorem Turing.VirtualWord.Simulation.emit_loaded {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (s : σ) :
(machine M).emit ({ runtime := Evaluator.loaded p, outer := s }, (machine M).read (Runtime.encInput p) { runtime := Evaluator.loaded p, outer := s }) = M.emit (s, M.read (word p.original p.data.cut p.data.suffix) s)

Emission resumes the unrestricted outer output continuation with the exact symbol.

Saved outer state adds to the charged header and binary cursor, without a virtual word.

theorem Turing.VirtualWord.Simulation.length_resume_le {σ : Type} (M : QueryMachine σ) (enc : σ ↪ List Bool) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (s : σ) (k B : ℕ) (hB : (enc ((M.step (word p.original p.data.cut p.data.suffix))^[k] s)).length ≤ B) :
((encState enc) (((machine M).step (Runtime.encInput p))^[k] { runtime := Evaluator.loaded p, outer := s })).length ≤ 32 * ((encData p.data).length + (Runtime.encInput p).length.log2 + 1) + 1 + B

A bound on outer states transfers to resumed physical states additively.

Decoding the retained header uses native space linear in the charged state.

The virtual width is computed without allocating the virtual input.

The optional-read adapter has a native certificate from the outer query certificate alone.

theorem Turing.VirtualWord.Simulation.components_inSpace {σ : Type} (M : QueryMachine σ) (enc : σ ↪ List Bool) (hq : MultiTapeTM.ComputableInSpace M.query enc MultiTapeTM.encNat fun (s : σ) => (enc s).length) (hn : MultiTapeTM.ComputableInSpace M.next (QueryMachine.encStateRead enc) enc fun (p : σ × Option Bool) => ((QueryMachine.encStateRead enc) p).length) (he : MultiTapeTM.ComputableInSpace M.emit (QueryMachine.encStateRead enc) MultiTapeTM.encBits fun (p : σ × Option Bool) => ((QueryMachine.encStateRead enc) p).length) (hh : MultiTapeTM.ComputableInSpace M.halted enc MultiTapeTM.encBool fun (s : σ) => (enc s).length) (hf : MultiTapeTM.ComputableInSpace M.finish enc MultiTapeTM.encBits fun (s : σ) => (enc s).length) :

Native certificates for every simulator component; all outer continuations are arbitrary. Only ordinary native outer component certificates are premises, never substitution certificates.

theorem Turing.VirtualWord.Simulation.first_halt {σ : Type} (M : QueryMachine σ) (p : Runtime.Input) (hc : p.data.cut ≤ p.original.length) (T : ℕ) (hh : M.halted (M.run (word p.original p.data.cut p.data.suffix) T) = true) (hpre : ∀ t < T, M.halted (M.run (word p.original p.data.cut p.data.suffix) t) = false) :

Exact first halt transfers from the outer machine, with only the fixed header-loading delay.

The simulator's output is precisely the outer output, including all emissions and finish.

@[reducible, inline]

Valid cuts give the ordinary prefix/suffix word, with no padded-gap convention.

@[reducible, inline]

Explicit framed runtime input, retaining the original word as its read-only tail.

theorem Turing.VirtualWord.Simulation.length_run_le {σ : Type} (M : QueryMachine σ) (enc : σ ↪ List Bool) (p : Input) (T B : ℕ) (hB : ∀ k ≤ T, (enc (M.run (word (↑p).original (↑p).data.cut (↑p).data.suffix) k)).length ≤ B) {t : ℕ} (ht : t ≤ 2 * (encData (↑p).data).length + 2 + T) :
((encState enc) ((machine M).run (encInput p) t)).length ≤ 32 * ((encData (↑p).data).length + (encInput p).length.log2 + 1) + 1 + B

All states up to an outer clock satisfy an additive header/position/outer-state bound.

theorem Turing.VirtualWord.Simulation.computableInSpace {σ : Type} (M : QueryMachine σ) (enc : σ ↪ List Bool) (hq : MultiTapeTM.ComputableInSpace M.query enc MultiTapeTM.encNat fun (s : σ) => (enc s).length) (hn : MultiTapeTM.ComputableInSpace M.next (QueryMachine.encStateRead enc) enc fun (p : σ × Option Bool) => ((QueryMachine.encStateRead enc) p).length) (he : MultiTapeTM.ComputableInSpace M.emit (QueryMachine.encStateRead enc) MultiTapeTM.encBits fun (p : σ × Option Bool) => ((QueryMachine.encStateRead enc) p).length) (hh : MultiTapeTM.ComputableInSpace M.halted enc MultiTapeTM.encBool fun (s : σ) => (enc s).length) (hf : MultiTapeTM.ComputableInSpace M.finish enc MultiTapeTM.encBits fun (s : σ) => (enc s).length) {β : Type} (encOut : β ↪ List Bool) (f : Input → β) (T B : Input → ℕ) (hhalt : ∀ (p : Input), M.halted (M.run (word (↑p).original (↑p).data.cut (↑p).data.suffix) (T p)) = true) (hpre : ∀ (p : Input), ∀ k < T p, M.halted (M.run (word (↑p).original (↑p).data.cut (↑p).data.suffix) k) = false) (hout : ∀ (p : Input), encOut (f p) = M.output (word (↑p).original (↑p).data.cut (↑p).data.suffix) (T p)) (hB : ∀ (p : Input), ∀ k ≤ T p, (enc (M.run (word (↑p).original (↑p).data.cut (↑p).data.suffix) k)).length ≤ B p) :
∃ (time : Input → ℕ) (c : ℕ), MultiTapeTM.ComputableInTimeAndSpace f encInput encOut time fun (p : Input) => c * (B p + (encData (↑p).data).length + (encInput p).length.log2 + 1)

Generic native virtual-input substitution for a certified query transducer. Constants are shared across all runtime headers and original inputs. The only semantic premises are the outer machine's own termination/output and saved-state bound; no oracle or substitution is assumed.