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 #
Turing.MultiTapeTM.ComputableInSpace.bindWith: a function of the input and a stored intermediate value, within the sum of the budgets.
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.