Documentation

CslibFrontier.Computability.Machines.ReadMachine.VirtualWord.Evaluator

Native repeated evaluation of a virtual input #

A Boolean-state consumer scans the whole virtual word twice, retaining its state across reads and across the pass boundary. The length is unbounded. Each outer address is translated to an original-tail address and the runtime accessor selects its prefix/suffix bit before resuming the consumer. Only the runtime header, its offset, a binary scan counter and one Boolean are stored. The virtual word is a specification, never a workspace object. Constants are independent of runtime cut, suffix and address. The supplied header's address field is ignored by the consumer.

This original implementation supports the QUERY-GENERATOR/EVALUATOR recomputation in the proof of Lemma 3.3, expanded ECCC TR13-047, printed page 6 [GNR+13]. Definitions 3.1–3.2 concern general logspace transducers; this module handles only a two-pass Boolean-state evaluator. Generic native predicate substitution, preparing the supplied header from a generator, regenerating answers, the resource-certified suffix loop and adaptive-to-tt conversion remain unproved here.

The declared virtual length; for valid cuts this is the reconstructed word's length.

The declared width uses space linear in the encoded data, without allocating the word.

Runtime accessor state, binary consumer position, and saved Boolean evaluator state.

  • runtime : Runtime.State

    State of the underlying runtime accessor.

  • pos : ℕ

    Binary consumer scan position across the two virtual-word passes.

  • acc : Bool

    Saved Boolean state of the consumer across reads and across the pass boundary.

theorem Turing.VirtualWord.Evaluator.State.ext {x y : State} (runtime : x.runtime = y.runtime) (pos : x.pos = y.pos) (acc : x.acc = y.acc) :
x = y
theorem Turing.VirtualWord.Evaluator.encState_acc_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).acc) encIn✝ MultiTapeTM.encBool S✝
theorem Turing.VirtualWord.Evaluator.encState_runtime_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).runtime) encIn✝ Runtime.encState S✝

Charge all retained data, including the suspended consumer state.

theorem Turing.VirtualWord.Evaluator.encState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Runtime.State} {T0 S0 x1 T1 S1 : γ → ℕ} {x2 : γ → Bool} {T2 S2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn Runtime.encState T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encNat T1 S1) (h2 : MultiTapeTM.ComputableInO x2 encIn MultiTapeTM.encBool T2 S2) :
MultiTapeTM.ComputableInO (fun (x : γ) => { runtime := x0 x, pos := x1 x, acc := x2 x }) encIn encState (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
theorem Turing.VirtualWord.Evaluator.encState_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Runtime.State} {x1 : γ → ℕ} {x2 : γ → Bool} (h0 : MultiTapeTM.ComputableInSpace x0 encIn Runtime.encState budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encNat budget) (h2 : MultiTapeTM.ComputableInSpace x2 encIn MultiTapeTM.encBool budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { runtime := x0 x, pos := x1 x, acc := x2 x }) encIn encState budget
theorem Turing.VirtualWord.Evaluator.encState_runtime_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
theorem Turing.VirtualWord.Evaluator.encState_acc_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
@[reducible, inline]

The tuple of the fields of encState.

theorem Turing.VirtualWord.Evaluator.encState_pos_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).pos) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.VirtualWord.Evaluator.encState_pos_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
theorem Turing.VirtualWord.Evaluator.encState_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Runtime.State} {x1 : γ → ℕ} {x2 : γ → Bool} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn Runtime.encState) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encNat) (h2 : MultiTapeTM.ComputableInPolyTime x2 encIn MultiTapeTM.encBool) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { runtime := x0 x, pos := x1 x, acc := x2 x }) encIn encState

Runtime data recovered from the retained small header.

The outer read address, reset at each pass boundary.

One translated read, using exactly the runtime accessor's selector.

A fixed consumer; its transition table is finite and independent of runtime parameters. The accessor's initialization read is retained, then every evaluation read resumes the saved Boolean state. A zero-width word halts immediately after initialization.

Reference evaluation, defined by successive reads rather than constructing the word.

The finite evaluator's result after two complete passes.

The initialized accessor is held fixed while the consumer runs.

theorem Turing.VirtualWord.Evaluator.run_initializing (δ : Bool × Bool → Bool) (p : Runtime.Input) {t : ℕ} (ht : t ≤ 2 * (encData p.data).length + 2) :
(machine δ).run (Runtime.encInput p) t = { runtime := Runtime.machine.run (Runtime.encInput p) t, pos := 0, acc := false }

Initialization has exactly the accessor's states, with a constant suspended consumer.

theorem Turing.VirtualWord.Evaluator.read_loaded (δ : Bool × Bool → Bool) (p : Runtime.Input) (k : ℕ) (a : Bool) :
(machine δ).read (Runtime.encInput p) { runtime := loaded p, pos := k, acc := a } = p.original[k % width p.data]?

Every consumer read is redirected to the original read-only tail.

theorem Turing.VirtualWord.Evaluator.run_scanning (δ : Bool × Bool → Bool) (p : Runtime.Input) {k : ℕ} (hk : k ≤ 2 * width p.data) :
(machine δ).run (Runtime.encInput p) (2 * (encData p.data).length + 2 + k) = { runtime := loaded p, pos := k, acc := value δ p k }

The unbounded read-loop invariant: exactly one finite transition per virtual bit.

Exact first halt, including the empty virtual word.

The actual machine emits the evaluator result, without accumulating a virtual input.

theorem Turing.VirtualWord.Evaluator.value_word (δ : Bool × Bool → Bool) (cut : ℕ) (suffix x : List Bool) (hc : cut ≤ x.length) (k : ℕ) :
value δ { data := { cut := cut, suffix := suffix, address := 0 }, original := x } (k + 1) = δ (value δ { data := { cut := cut, suffix := suffix, address := 0 }, original := x } k, (word x cut suffix).getD (k % (word x cut suffix).length) false)

For valid cuts the consumer transition reads exactly the reconstructed virtual word. The modulo counter scans each address once per pass when the word is nonempty.

Header decoding is native in the charged consumer state.

The virtual length is computed from binary cut and the stored suffix only.

The outer scan address is binary, even for unbounded virtual lengths.

Explicit encoding cost: saved accessor state, binary loop counter and one bit.

All live states fit a uniform budget; oversized cuts cost binary bits, not unary storage.

One actual native evaluator handles all runtime inputs with shared constants.

Physical consumer states are logarithmic in the original word, with honest header bounds.

The native certificate measures workspace against the original length, uniformly over runtime parameters. Only size admissibility is assumed, never a final transfer certificate.

theorem Turing.VirtualWord.Evaluator.value_eq_fold (δ : Bool × Bool → Bool) (cut : ℕ) (suffix x : List Bool) (hc : cut ≤ x.length) (k : ℕ) :
value δ { data := { cut := cut, suffix := suffix, address := 0 }, original := x } k = List.foldl (fun (a b : Bool) => δ (a, b)) false (List.map (fun (j : ℕ) => (word x cut suffix).getD (j % (word x cut suffix).length) false) (List.range k))

The semantic specification is an ordinary finite-state fold of the actual virtual reads. This list describes output semantics only; the native machine stores just one Boolean.

theorem Turing.VirtualWord.Evaluator.evaluate_word (δ : Bool × Bool → Bool) (cut : ℕ) (suffix x : List Bool) (hc : cut ≤ x.length) :
evaluate δ { data := { cut := cut, suffix := suffix, address := 0 }, original := x } = List.foldl (fun (a b : Bool) => δ (a, b)) false (word x cut suffix ++ word x cut suffix)

Conventional semantics: the native result is the finite-state fold of two copies of the virtual word. These copies occur only in the specification, never in the machine's state.