Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.LogSpace.QueryMachine.CallBounds

Space bounds at every clock of calls and call loops #

A space bound for a query machine must hold at every physical clock, including the clocks spent inside a callee, not only at call boundaries. This file proves such bounds once for the two shapes that machines built from Turing.QueryMachine.withCalls repeat: one state-returning call, and a counter loop of bounded runs that may stop early. The lemmas are distilled from Christian Reitwiessner's per-machine proofs of these bounds for block-computation searches, gate vectors, the packed interpolation loop and the packed tree-evaluation controller.

Main results #

theorem Turing.QueryMachine.withCalls_runFrom_call_encoding_le {σ τ : Type} (M : QueryMachine σ) (N : QueryMachine τ) (request : σ → Option τ) (resume : σ → τ → σ) (w : List Bool) (encS : σ ↪ List Bool) (encT : τ ↪ List Bool) {s : σ} {start : τ} {T C D : ℕ} (hs : M.halted s = false) (hrequest : request s = some start) (hpre : ∀ i < T, N.halted (N.runFrom w start i) = false) (hhalt : N.halted (N.runFrom w start T) = true) (hcaller : (encS s).length ≤ C) (hresume : (encS (resume s (N.runFrom w start T))).length ≤ C) (hcallee : ∀ i ≤ T, (encT (N.runFrom w start i)).length ≤ D) (t : ℕ) (ht : t ≤ T + 2) :
((encWithCalls encS encT) ((M.withCalls N request resume).runFrom w (Sum.inl s) t)).length ≤ 2 * C + D + 2

One state-returning call is encoded in 2 * C + D + 2 bits at every clock from its request through its return, when the requesting and resumed callers fit C bits and every callee state up to the callee's first halt fits D bits.

theorem Turing.QueryMachine.runFrom_add_encoding_le {σ : Type} {M : QueryMachine σ} {w : List Bool} (enc : σ ↪ List Bool) {B T U : ℕ} (s : σ) (hT : ∀ t ≤ T, (enc (M.runFrom w s t)).length ≤ B) (hU : ∀ t ≤ U, (enc (M.runFrom w (M.runFrom w s T) t)).length ≤ B) (t : ℕ) :
t ≤ T + U → (enc (M.runFrom w s t)).length ≤ B

Concatenate two encoded-state bounds at their actual shared run boundary.

theorem Turing.QueryMachine.exists_runFrom_search_encoding_le {σ : Type} {M : QueryMachine σ} {w : List Bool} {α : Type u_1} (enc : σ ↪ List Bool) {B : ℕ} (c : ℕ → σ) (hit : ℕ → Option α) (found : ℕ → α → σ) {lo hi : ℕ} (hle : lo ≤ hi) (hlo : (enc (c lo)).length ≤ B) (hnone : ∀ (j : ℕ), lo ≤ j → j < hi → hit j = none → ∃ (T : ℕ), M.runFrom w (c j) T = c (j + 1) ∧ ∀ t ≤ T, (enc (M.runFrom w (c j) t)).length ≤ B) (hsome : ∀ (j : ℕ) (a : α), lo ≤ j → j < hi → hit j = some a → ∃ (T : ℕ), M.runFrom w (c j) T = found j a ∧ ∀ t ≤ T, (enc (M.runFrom w (c j) t)).length ≤ B) :
∃ (T : ℕ), ((M.runFrom w (c lo) T = c hi ∧ ∀ (j : ℕ), lo ≤ j → j < hi → hit j = none) ∨ ∃ (j : ℕ) (a : α), lo ≤ j ∧ j < hi ∧ hit j = some a ∧ M.runFrom w (c lo) T = found j a) ∧ ∀ t ≤ T, (enc (M.runFrom w (c lo) t)).length ≤ B

A counter loop from lo towards hi is one run whose every clock is encoded in B bits. Each step from c j is a run encoded in B bits that either advances to c (j + 1), when hit j = none, or stops at found j a, when hit j = some a. The loop reaches c hi with no hit in between, or stops at the first hit.

theorem Turing.QueryMachine.exists_runFrom_chain_encoding_le {σ : Type} {M : QueryMachine σ} {w : List Bool} (enc : σ ↪ List Bool) {B : ℕ} (c : ℕ → σ) (n : ℕ) (h0 : (enc (c 0)).length ≤ B) (hstep : ∀ j < n, ∃ (T : ℕ), M.runFrom w (c j) T = c (j + 1) ∧ ∀ t ≤ T, (enc (M.runFrom w (c j) t)).length ≤ B) :
∃ (T : ℕ), M.runFrom w (c 0) T = c n ∧ ∀ t ≤ T, (enc (M.runFrom w (c 0) t)).length ≤ B

A loop of runs from c j to c (j + 1) for j < n, each encoded in B bits at every clock, is one run from c 0 to c n encoded in B bits at every clock.