Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.LogSpace.Tabulation

Streaming a list of values at successive indices #

Polynomially many values of a function on unary parameters can be tabulated using a binary index. Each round emits its output directly to the write-only output tape. The fixed parameters fit in logarithmic space when encoded in binary. Recomputing the symbols of their unary forms lets the emitter accept the ordinary unary encodings, even for tuples of parameters in nested tables.

Main definitions #

Main results #

Binary-to-unary conversion can emit its entire output with workspace linear in the number of binary input digits.

theorem Turing.MultiTapeTM.ComputableInLogSpace.toUnary_of_polyBounded {α : Type} {enc : α ↪ List Bool} {f : α → ℕ} (hf : ComputableInLogSpace f enc encNat) (hb : PolyBounded (fun (a : α) => (enc a).length) f) :

A binary natural with polynomially bounded value can be emitted in unary within logarithmic workspace on the original input.

theorem Turing.MultiTapeTM.ComputableInLogSpace.flatMap_range {α σ : Type} {encIn : α ↪ List Bool} {enc : σ ↪ List Bool} {params : α → σ} {count : α → ℕ} {emit : σ × ℕ → List Bool} {t : σ × ℕ → ℕ} {c : ℕ} (hp : ComputableInSpace params encIn enc fun (a : α) => (encIn a).length.log2) (hr : ComputableInLogSpace count encIn encUnary) (he : ComputableInTimeAndSpace emit (encPair enc encNat) encBits t fun (p : σ × ℕ) => c * (((encPair enc encNat) p).length + 1)) :
ComputableInLogSpace (fun (a : α) => List.flatMap (fun (i : ℕ) => emit (params a, i)) (List.range (count a))) encIn encBits

Tabulate a binary-indexed emitter in logspace. The parameter carried between emissions fits in logarithmic space, and each round may write a word longer than its own workspace. The count is supplied in unary by a logspace computation.

Encodings made from unary natural numbers and framed pairs. Each leaf can be retained on a work tape in binary while processing a table indexed by the tuple.

theorem Turing.MultiTapeTM.ComputableInLogSpace.map_range {α β : Type} {e : α ↪ List Bool} {enc : β ↪ List Bool} (parameters : UnaryTupleEncoding e) {r : α → ℕ} {f : α × ℕ → β} (hr : ComputableInLogSpace r e encUnary) (hf : ComputableInLogSpace f (encPair e encUnary) enc) :
ComputableInLogSpace (fun (a : α) => List.map (fun (i : ℕ) => f (a, i)) (List.range (r a))) e (encList enc)

Tabulate a logspace computation on a fixed tuple of unary parameters paired with each of the first r a indices. The number of entries is itself supplied in unary in logspace.