Word operations and pairing in logarithmic space #
The word operations underlying the encodings of pairs, options and lists — framing, reading and
dropping the first frame, prepending true, dropping or keeping the first symbol, testing for
emptiness, mapping a Boolean function over a bit word, and folding a finite-state transition
function over an encoded word — are computed by finite-state transducers, without work tapes
(Turing.MultiTapeTM.Transducer.computableInLogSpace). They are therefore computable in
logarithmic space, as are the projections of pairs.
Concatenating or pairing two logspace functions of the same input runs both machines one after the
other; the work space is the sum of the two
(Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace.append). Case distinctions run the condition
test and then the selected branch (Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace.ite).
Together with word concatenation, these give logspace operations on options, lists, bit words, and
unary numbers, as well as bounded-count batch evaluation (map_range_const, map_range_of_le,
mapToBits_range_const, mapToBits_range_of_le).
Main results #
Turing.MultiTapeTM.ComputableInLogSpace.of_frame,.of_unframe,.of_dropFrame,.of_cons_true,.of_tail,.of_drop,.of_take_one,.of_isEmpty,.of_foldl_bool: word operations.Turing.MultiTapeTM.ComputableInLogSpace.restrict,.ite_subtype,.ite,.of_isEmpty_ite: restriction and case distinctions.Turing.MultiTapeTM.ComputableInLogSpace.append,Turing.MultiTapeTM.ComputableInLogSpace.fst,Turing.MultiTapeTM.ComputableInLogSpace.snd,Turing.MultiTapeTM.ComputableInLogSpace.pair: concatenation and pairing.Turing.MultiTapeTM.ComputableInLogSpace.optionSome,.optionGetD: option operations.Turing.MultiTapeTM.ComputableInLogSpace.listSingleton,.listCons,.listAppend,.listHeadD,.listLength: framed-list operations.Turing.MultiTapeTM.ComputableInLogSpace.bitsAppend,.bitsHeadD,.bitsMap,.bitsFoldl,.bitsAll,.bitsAny: bit-word operations.Turing.MultiTapeTM.ComputableInLogSpace.unaryAdd,.unaryMulConst,.unaryLeConst,.unaryBoundedMap: unary-number operations.Turing.MultiTapeTM.ComputableInLogSpace.map_range_const,.map_range_of_le,.mapToBits_range_const,.mapToBits_range_of_le: bounded-count batch evaluation.Turing.MultiTapeTM.ComputableInLogSpace.fst',.snd',.bool_and,.bool_or,.ite_decide: projections of a computed pair, Boolean connectives and case distinctions on decidable propositions, in the form used byfun_prop, with which the closure rules and word operations above are registered.
References #
A function computable in logarithmic space on all inputs is computable in logarithmic space on
the inputs satisfying p, by the same machine.
Case distinctions in logarithmic space, with each branch certified on the inputs where it is taken.
Case distinction: if c, f and g are computable in logarithmic space on a common
input, so is fun a => if c a then f a else g a.
A function with a fixed value d on the input encoded by the empty word, and computable in
logarithmic space on the other inputs.
Word concatenation: if f₁ and f₂ are computable in logarithmic space on a common input
and encOut (g a) = enc₁ (f₁ a) ++ enc₂ (f₂ a) for all a, then g is computable in logarithmic
space.
Pairing: the values of two logspace functions of the same input, framed first value followed by the second, are computed in logarithmic space.
Options, framed lists, bit words, and unary numbers #
Wrapping a value in some in logarithmic space.
Unwrapping an option with a default value d in logarithmic space.
Forming a singleton framed list in logarithmic space.
Prepending a computed element to a computed framed list in logarithmic space.
Concatenating two framed lists computed in logarithmic space from a common input.
Reading the head of a framed list with a default value d in logarithmic space.
Concatenating two bit words computed in logarithmic space from a common input.
Reading the head of a bit word with a default value d in logarithmic space.
Mapping a Boolean function over a bit word is computable in logarithmic space.
Folding a finite-state transition function over an encoded word and projecting the final state to a Boolean is computable in logarithmic space.
Folding a binary Boolean operation over a bit word is computable in logarithmic space.
Testing whether all bits of a word satisfy p is computable in logarithmic space.
Testing whether any bit of a word satisfies p is computable in logarithmic space.
Adding two unary-encoded natural numbers computed in logarithmic space from a common input.
Multiplying a unary-encoded natural number by a fixed constant k in logarithmic space.
Testing whether a unary-encoded natural number is at most a fixed constant k.
Evaluating any function g : ℕ → β on a unary input clamped at a fixed constant M is
computable in logarithmic space.
Bounded-count batch evaluation #
Evaluating a logspace family f : α × ℕ → β at the first k indices 0, …, k - 1, for a
fixed constant k, is computable in logarithmic space.
Evaluating a logspace family f : α × ℕ → β at indices 0, …, r a - 1, where r : α → ℕ is
computable in logarithmic space and bounded by a constant k, is computable in logarithmic
space.
Evaluating a logspace Boolean family f : α × ℕ → Bool at the first k indices
0, …, k - 1, for a fixed constant k, is computable in logarithmic space.
Evaluating a logspace Boolean family f : α × ℕ → Bool at indices 0, …, r a - 1, where
r : α → ℕ is computable in logarithmic space and bounded by a constant k, is computable in
logarithmic space.
Automation #
The closure rules for pairing, projections and case distinctions, and the word operations, are
registered with fun_prop. Projections are stated for a computed pair, so the pair certificate
fixes the encodings of the components.
The first component of a computed pair, in the form used by fun_prop.
The second component of a computed pair, in the form used by fun_prop.
The conjunction of two computed Booleans.
The disjunction of two computed Booleans.
A case distinction on a decidable proposition whose truth value is computed.