Documentation

CslibFrontier.Computability.Machines.ReadMachine.VirtualWord

Reading a fixed prefix and a stored suffix #

The original word is read-only input. Only a binary prefix length, a stored suffix and a binary address enter the accessor state. machine emits one bit and halts: it reads the original input at prefix addresses and indexes the stored suffix otherwise. All five query-machine components have native charged space certificates linear in this small state, independently of the length of the original word. word is a semantic specification and is never computed into workspace. The false default agrees with Turing.ReadMachine.

This is the virtual-input access operation needed in the proof of Lemma 3.3 of [GNR+13], expanded ECCC TR13-047, printed page 6. The paper's fixed prefix ends before its ceiling-logarithmic suffix. Initialization, query and answer regeneration, suffix iteration and adaptive-to-tt conversion are separate obligations.

def Turing.VirtualWord.word (x : List Bool) (cut : ℕ) (suffix : List Bool) :

The specified word; this list is not stored by the accessor.

The only stored data: prefix length, stored suffix, and requested address.

  • cut : ℕ

    Length of the prefix read from the original input word.

  • suffix : List Bool

    Stored suffix bits following the prefix.

  • address : ℕ

    Requested virtual-word bit address.

theorem Turing.VirtualWord.Data.ext {x y : Data} (cut : x.cut = y.cut) (suffix : x.suffix = y.suffix) (address : x.address = y.address) :
x = y

State of the single-bit accessor: stored request data and a halting flag.

  • data : Data

    Stored prefix cut, suffix, and target address.

  • halted : Bool

    Whether the single original-input read has already taken place.

theorem Turing.VirtualWord.State.ext {x y : State} (data : x.data = y.data) (halted : x.halted = y.halted) :
x = y
theorem Turing.VirtualWord.encData_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ℕ} {x1 : γ → List Bool} {x2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn MultiTapeTM.encNat) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encBits) (h2 : MultiTapeTM.ComputableInPolyTime x2 encIn MultiTapeTM.encNat) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { cut := x0 x, suffix := x1 x, address := x2 x }) encIn encData
theorem Turing.VirtualWord.encData_suffix_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Data} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encData S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).suffix) encIn✝ MultiTapeTM.encBits S✝
theorem Turing.VirtualWord.encData_cut_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Data} :
theorem Turing.VirtualWord.encData_address_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Data} :
theorem Turing.VirtualWord.encData_mk_deg :
MultiTapeTM.ComputableInDegree (fun (p : ℕ × List Bool × ℕ) => { cut := p.1, suffix := p.2.1, address := p.2.2 }) encDataFields encData 1 1
theorem Turing.VirtualWord.encData_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 x2 T2 S2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn MultiTapeTM.encNat T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encBits T1 S1) (h2 : MultiTapeTM.ComputableInO x2 encIn MultiTapeTM.encNat T2 S2) :
MultiTapeTM.ComputableInO (fun (x : γ) => { cut := x0 x, suffix := x1 x, address := x2 x }) encIn encData (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)

Binary counters and the literal stored suffix.

theorem Turing.VirtualWord.encData_address_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Data} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encData S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).address) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.VirtualWord.encData_suffix_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Data} :
@[reducible, inline]

The tuple of the fields of encData.

theorem Turing.VirtualWord.encData_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → List Bool} {x2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInSpace x0 encIn MultiTapeTM.encNat budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encBits budget) (h2 : MultiTapeTM.ComputableInSpace x2 encIn MultiTapeTM.encNat budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { cut := x0 x, suffix := x1 x, address := x2 x }) encIn encData budget
theorem Turing.VirtualWord.encData_cut_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Data} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encData S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).cut) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.VirtualWord.encState_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Data} {x1 : γ → Bool} (h0 : MultiTapeTM.ComputableInSpace x0 encIn encData budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encBool budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { data := x0 x, halted := x1 x }) encIn encState budget
theorem Turing.VirtualWord.encState_data_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).data) encIn✝ encData S✝
theorem Turing.VirtualWord.encState_data_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInPolyTime g✝ encIn✝ encState → MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).data) encIn✝ encData

The state encoding charges the stored suffix, but never the original prefix.

theorem Turing.VirtualWord.encState_halted_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → State} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).halted) encIn✝ MultiTapeTM.encBool S✝
theorem Turing.VirtualWord.encState_halted_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → State} :
@[reducible, inline]

The tuple of the fields of encState.

theorem Turing.VirtualWord.encState_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Data} {x1 : γ → Bool} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn encData) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encBool) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { data := x0 x, halted := x1 x }) encIn encState
theorem Turing.VirtualWord.encState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Data} {T0 S0 : γ → ℕ} {x1 : γ → Bool} {T1 S1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn encData T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encBool T1 S1) :
MultiTapeTM.ComputableInO (fun (x : γ) => { data := x0 x, halted := x1 x }) encIn encState (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

Select the original input bit or a bit of the stored suffix, defaulting to false.

One native input read suffices. The read is ignored at suffix addresses.

theorem Turing.VirtualWord.length_word (x : List Bool) (cut : ℕ) (suffix : List Bool) (h : cut ≤ x.length) :
(word x cut suffix).length = cut + suffix.length

Exact length, including an empty prefix or suffix.

theorem Turing.VirtualWord.answer_eq_getD (x : List Bool) (cut : ℕ) (suffix : List Bool) (i : ℕ) (h : cut ≤ x.length) :
answer { cut := cut, suffix := suffix, address := i } (x.getD i false) = (word x cut suffix).getD i false

Prefix, boundary, suffix and past-the-end reads all agree with the specified word.

The actual native run emits exactly the requested bit and then halts.

theorem Turing.VirtualWord.run_one (d : Data) (x : List Bool) :
(machine d).run x 1 = { data := d, halted := true }

Only the halting bit changes; the stored suffix is never enlarged.

The selector is natively computable in charged space linear in the stored data and bit.

theorem Turing.VirtualWord.length_encState (cut i : ℕ) (suffix : List Bool) (halt : Bool) :
(encState { data := { cut := cut, suffix := suffix, address := i }, halted := halt }).length = 4 * (MultiTapeTM.encNat cut).length + 4 * suffix.length + 2 * (MultiTapeTM.encNat i).length + 6

Explicit storage bound: two binary counters, the suffix, and a halting bit.

For each fixed stored data d, the answer bit answer d (x.getD d.address false) is computable from x within work space c * ((encState ⟨d, false⟩).length + Nat.log2 x.length + 1), where the machine, the time bound and the constant c may all depend on d. The original input is not part of the charged workspace. This theorem supplies actual multi-tape machines, using the query-machine compiler, rather than assuming an access certificate. One machine and one constant for all data, read from the input tape, are given by Turing.VirtualWord.Runtime.access_inSpace.

theorem Turing.VirtualWord.length_encState_le_log {n cut i : ℕ} {suffix : List Bool} (halt : Bool) (hc : cut ≤ n) (hi : i ≤ n) (hs : suffix.length ≤ Nat.clog 2 n) :
(encState { data := { cut := cut, suffix := suffix, address := i }, halted := halt }).length ≤ 16 * (n.log2 + 1)

A ceiling-logarithmic suffix and addresses at most the input length give an explicit logarithmic state bound, including lengths zero and one.

theorem Turing.VirtualWord.access_inLogSpace (d : Data) (P : List Bool → Prop) (hcut : ∀ (x : List Bool), P x → d.cut ≤ x.length) (hindex : ∀ (x : List Bool), P x → d.address ≤ x.length) (hsuffix : ∀ (x : List Bool), P x → d.suffix.length ≤ Nat.clog 2 x.length) :

A concrete logspace certificate on any input domain satisfying the stored-data bounds. The domain hypotheses restrict data sizes, not correctness or an assumed resource certificate.