Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.InSpace.StoredBind

Storing an intermediate value #

Turing.MultiTapeTM.ComputableInSpace.bindWith computes fun a => g (h a, a) by storing the value h a and running g on it and the input, where g is in the context form of Turing.MultiTapeTM.ComputableInSpace.loopWith. The budgets add: the space of h, the space of g beyond its stored argument, and the logarithm of the length of the input. Composition by recomputation (Turing.MultiTapeTM.ComputableInSpace.comp_space) instead multiplies the bound by a constant of both machines, and needs a budget of g on the value of h alone.

The rule is a loop of two rounds: the registers are the stored value and the optional result, the first round fills in the result and the second stops.

Main results #

theorem Turing.MultiTapeTM.ComputableInSpace.bindWith {α β γ : Type} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {encC : γ ↪ List Bool} {h : α → β} {g : β × α → γ} {Sh Sg : α → ℕ} (hh : ComputableInSpace h encA encB Sh) (hg : ComputableInSpace g (encPair encB encA) encC fun (p : β × α) => (encB p.1).length + Sg p.2) :
ComputableInSpace (fun (a : α) => g (h a, a)) encA encC fun (a : α) => Sh a + Sg a + (encA a).length.log2

Storing an intermediate value. If h is computable within Sh, and g takes the stored value of h and the input within the length of that value plus Sg, then fun a => g (h a, a) is computable within Sh + Sg + log₂ n on inputs of length n. The value h a is stored, not recomputed, so the constant does not depend on how g reads it.