Documentation

CslibFrontier.Computability.Machines.ReadMachine.VirtualWord.Runtime

Uniform runtime virtual-word access #

A single query machine reads a framed binary data header followed by the original read-only word. It stores only the header, a binary cursor and finite flags, then reads one original bit. The original word is never copied into workspace. Both counters in the header are binary. access_inSpace supplies a single native program with constants shared across all data. access_inOriginalLogSpace measures its workspace against the original word length under the explicit parameter-size conditions in Admissible. Outside that domain, access remains total with the general header-size bound; a cut past the input uses the declared suffix offset. This is an original implementation lemma supporting, rather than proving, Lemma 3.3 of [GNR+13].

Runtime parameters followed by the unchanged original word.

  • data : Data

    Runtime prefix cut, stored suffix, and target address.

  • original : List Bool

    Unchanged original read-only word.

theorem Turing.VirtualWord.Runtime.Input.ext {x y : Input} (data : x.data = y.data) (original : x.original = y.original) :
x = y

Retained header prefix (in reverse order) and current physical input cursor.

  • header : List Bool

    Header bits retained so far, in reverse order.

  • cursor : ℕ

    Position just after the header once initialization has finished.

theorem Turing.VirtualWord.Runtime.Scan.ext {x y : Scan} (header : x.header = y.header) (cursor : x.cursor = y.cursor) :
x = y

Reversed header and cursor, followed by payload/ready flags and a fetched bit.

  • payload : Bool

    Whether the next header symbol is payload rather than a frame marker.

  • ready : Bool

    Whether initialization has reached the end of the framed header.

  • bit : Option Bool

    The original-input bit, with a false default on a missing address.

theorem Turing.VirtualWord.Runtime.State.ext {x y : State} (header : x.header = y.header) (cursor : x.cursor = y.cursor) (payload : x.payload = y.payload) (ready : x.ready = y.ready) (bit : x.bit = y.bit) :
x = y
theorem Turing.VirtualWord.Runtime.encInput_data_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Input} :
MultiTapeTM.ComputableInPolyTime g✝ encIn✝ encInput → MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).data) encIn✝ encData
theorem Turing.VirtualWord.Runtime.encInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Data} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn encData T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encBits T1 S1) :
MultiTapeTM.ComputableInO (fun (x : γ) => { data := x0 x, original := x1 x }) encIn encInput (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Turing.VirtualWord.Runtime.encInput_data_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Input} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).data) encIn✝ encData S✝

A framed small header, then the literal original word.

@[reducible, inline]

The tuple of the fields of encInput.

theorem Turing.VirtualWord.Runtime.encInput_original_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Input} :
theorem Turing.VirtualWord.Runtime.encInput_original_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Input} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).original) encIn✝ MultiTapeTM.encBits S✝
theorem Turing.VirtualWord.Runtime.encInput_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Data} {x1 : γ → List Bool} (h0 : MultiTapeTM.ComputableInSpace x0 encIn encData budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encBits budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { data := x0 x, original := x1 x }) encIn encInput budget
theorem Turing.VirtualWord.Runtime.encInput_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Data} {x1 : γ → List Bool} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn encData) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encBits) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { data := x0 x, original := x1 x }) encIn encInput

Total decoding of the binary cut, literal suffix and binary address.

Decoding the supplied header recovers every runtime parameter.

theorem Turing.VirtualWord.Runtime.encScan_cursor_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Scan} :
theorem Turing.VirtualWord.Runtime.encScan_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn MultiTapeTM.encBits T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encNat T1 S1) :
MultiTapeTM.ComputableInO (fun (x : γ) => { header := x0 x, cursor := x1 x }) encIn encScan (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Turing.VirtualWord.Runtime.encScan_header_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Scan} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encScan S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).header) encIn✝ MultiTapeTM.encBits S✝
theorem Turing.VirtualWord.Runtime.encScan_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List Bool} {x1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInSpace x0 encIn MultiTapeTM.encBits budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encNat budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { header := x0 x, cursor := x1 x }) encIn encScan budget
@[reducible, inline]

The tuple of the fields of encScan.

theorem Turing.VirtualWord.Runtime.encScan_cursor_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Scan} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encScan S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).cursor) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.VirtualWord.Runtime.encScan_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {x1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn MultiTapeTM.encBits) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encNat) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { header := x0 x, cursor := x1 x }) encIn encScan

Encoding of the retained reversed header and binary cursor.

theorem Turing.VirtualWord.Runtime.encScan_header_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Scan} :
theorem Turing.VirtualWord.Runtime.encState_ready_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).ready) encIn✝ MultiTapeTM.encBool S✝
theorem Turing.VirtualWord.Runtime.encState_payload_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).payload) encIn✝ MultiTapeTM.encBool S✝
theorem Turing.VirtualWord.Runtime.encState_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Scan} {x1 x2 : γ → Bool} {x3 : γ → Option Bool} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn encScan) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encBool) (h2 : MultiTapeTM.ComputableInPolyTime x2 encIn MultiTapeTM.encBool) (h3 : MultiTapeTM.ComputableInPolyTime x3 encIn (MultiTapeTM.encOption MultiTapeTM.encBool)) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { toScan := x0 x, payload := x1 x, ready := x2 x, bit := x3 x }) encIn encState
theorem Turing.VirtualWord.Runtime.encState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Scan} {T0 S0 : γ → ℕ} {x1 : γ → Bool} {T1 S1 : γ → ℕ} {x2 : γ → Bool} {T2 S2 : γ → ℕ} {x3 : γ → Option Bool} {T3 S3 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn encScan T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encBool T1 S1) (h2 : MultiTapeTM.ComputableInO x2 encIn MultiTapeTM.encBool T2 S2) (h3 : MultiTapeTM.ComputableInO x3 encIn (MultiTapeTM.encOption MultiTapeTM.encBool) T3 S3) :
MultiTapeTM.ComputableInO (fun (x : γ) => { toScan := x0 x, payload := x1 x, ready := x2 x, bit := x3 x }) encIn encState (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))
theorem Turing.VirtualWord.Runtime.encState_payload_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
theorem Turing.VirtualWord.Runtime.encState_bit_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).bit) encIn✝ (MultiTapeTM.encOption MultiTapeTM.encBool) S✝
theorem Turing.VirtualWord.Runtime.encState_toScan_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).toScan) encIn✝ encScan S✝

Only the small header and binary cursor are charged.

theorem Turing.VirtualWord.Runtime.encState_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Scan} {x1 x2 : γ → Bool} {x3 : γ → Option Bool} (h0 : MultiTapeTM.ComputableInSpace x0 encIn encScan budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encBool budget) (h2 : MultiTapeTM.ComputableInSpace x2 encIn MultiTapeTM.encBool budget) (h3 : MultiTapeTM.ComputableInSpace x3 encIn (MultiTapeTM.encOption MultiTapeTM.encBool) budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { toScan := x0 x, payload := x1 x, ready := x2 x, bit := x3 x }) encIn encState budget
theorem Turing.VirtualWord.Runtime.encState_ready_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
@[reducible, inline]

The tuple of the fields of encState.

theorem Turing.VirtualWord.Runtime.encState_mk_deg :
MultiTapeTM.ComputableInDegree (fun (p : Scan × Bool × Bool × Option Bool) => { toScan := p.1, payload := p.2.1, ready := p.2.2.1, bit := p.2.2.2 }) encStateFields encState 1 1
theorem Turing.VirtualWord.Runtime.encState_bit_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
theorem Turing.VirtualWord.Runtime.encState_toScan_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInPolyTime g✝ encIn✝ encState → MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).toScan) encIn✝ encScan

Initialize by scanning the framed small header, then fetch one original-input bit. A missing frame marker ends initialization; a missing payload is decoded as false.

theorem Turing.VirtualWord.Runtime.run_marker (h x : List Bool) {k : ℕ} (hk : k ≤ h.length) :
machine.run (MultiTapeTM.frame h ++ x) (2 * k) = { header := (List.take k h).reverse, cursor := 2 * k, payload := false, ready := false, bit := none }

At each frame marker only the already scanned header prefix is stored.

theorem Turing.VirtualWord.Runtime.run_payload (h x : List Bool) {k : ℕ} (hk : k < h.length) :
machine.run (MultiTapeTM.frame h ++ x) (2 * k + 1) = { header := (List.take k h).reverse, cursor := 2 * k + 1, payload := true, ready := false, bit := none }

Between marker and payload the retained header has not grown.

theorem Turing.VirtualWord.Runtime.run_initialized (h x : List Bool) :
machine.run (MultiTapeTM.frame h ++ x) (2 * h.length + 1) = { header := h.reverse, cursor := 2 * h.length + 1, payload := false, ready := true, bit := none }

Initialization finishes with exactly the supplied header and the original-word offset.

theorem Turing.VirtualWord.Runtime.run_halted (d : Data) (x : List Bool) :
machine.run (encInput { data := d, original := x }) (2 * (encData d).length + 2) = { header := (encData d).reverse, cursor := 2 * (encData d).length + 1, payload := false, ready := true, bit := some (x.getD d.address false) }

One further step reads the original input at the runtime address.

theorem Turing.VirtualWord.Runtime.output (d : Data) (x : List Bool) :
machine.output (encInput { data := d, original := x }) (2 * (encData d).length + 2) = [answer d (x.getD d.address false)]

Every runtime parameter is an input to this one fixed machine, rather than part of its code.

Header decoding has native space linear in the actual header, even for noncanonical bits.

Decoding the reversed retained header is linear in the encoded runtime state.

The runtime address is added to the original-word offset only after initialization.

The final answer uses the existing native selector certificate.

The fixed runtime machine first halts after loading the header and making one input query.

Every live and halted state retains at most the supplied header and its binary scan offset.

Finite flags contribute at most eleven bits beyond the header and binary cursor.

State size is uniformly linear in the actual header plus a logarithmic input counter.

The total runtime operation. When the cut exceeds the original length it still uses the specified cut as the suffix offset; no padded or reconstructed word is allocated.

One compiled native program handles all runtime cuts, suffixes and addresses, with shared constants. The bound explicitly charges arbitrary header sizes, including invalid parameters.

Admissible parameter sizes are measured against the original word, before its header.

The entire encoded input has a small header; its length cannot hide a large workspace allowance. This also covers original lengths zero and one.

Physical runtime states occupy logarithmic space in the original word length.

The compiled program has logarithmic workspace in the original word length, uniformly across all admissible runtime parameters. The framed input is explicit, not a large encoding chosen to inflate the logarithmic bound.

theorem Turing.VirtualWord.Runtime.output_word (cut i : ℕ) (suffix x : List Bool) (hc : cut ≤ x.length) :
machine.output (encInput { data := { cut := cut, suffix := suffix, address := i }, original := x }) (2 * (encData { cut := cut, suffix := suffix, address := i }).length + 2) = [(word x cut suffix).getD i false]

For a valid cut the runtime output is exactly the virtual-word bit, including its default.