Basic functions within linear work space #
Arithmetic on binary naturals and operations on lists, computable within work space linear in the
lengths of their encoded arguments, for Turing.MultiTapeTM.ComputableInSpace. Combinators keep a
computation within a fixed space budget.
Main results #
Turing.MultiTapeTM.ComputableInSpace.natDivMod: the quotient and the remainder.Turing.MultiTapeTM.ComputableInSpace.natMul: multiplication.Turing.MultiTapeTM.ComputableInSpace.getD: the element of a list at an index.Turing.MultiTapeTM.ComputableInSpace.set: replacing the element at an index.Turing.MultiTapeTM.ComputableInSpace.budget_natAdd,Turing.MultiTapeTM.ComputableInSpace.budget_consand their siblings: arithmetic and list operations on values computed within a fixed budget stay within it.Turing.MultiTapeTM.ComputableInSpace.budget_optionSome,Turing.MultiTapeTM.ComputableInSpace.budget_optionGetD,Turing.MultiTapeTM.ComputableInSpace.budget_optionIsSome: building and reading options.Turing.MultiTapeTM.ComputableInSpace.dispatch: a case distinction on the element of a fixed list at a computed index.
Computing within a space budget #
Composition with a function computed in space linear in its argument: no side condition, as the argument is computed within the budget.
Iterating a step computed in linear space, a computed number of times, within a budget that covers the states.
Direct linear list and framing helpers #
Prepending an element to an encoded list in linear space.
Appending an element at the end of an encoded list in linear space.
Framing an encoded value in linear space.
Arithmetic #
Dispatching on the element of a fixed list at a computed index: if F x is computed in
linear space for every x, and the index is computed in linear space, then so is
F (l.getD (i a) d) a. A finite case distinction, as on the instruction at the current label of
a program.
Lists of naturals #
Replacing the element at an index, l.set i v from (l, i, v).
Building and measuring lists #
A list of copies, List.replicate n a from (n, a); its work space is that of the list.
Mapping with a parameter, within the space of the parameter, of the list, of the mapped list and of the largest application.
Operations within a fixed budget #
Adding an element in front of a list, within the budget.
Appending an element at the end of a list, within the budget.
The head of a list, within the budget.
The tail of a list, within the budget.
Whether a list is empty, within the budget.
The length of a list, within the budget.
The successor, within the budget.
The predecessor, within the budget.
The zero test, within the budget.
Equality of numbers, within the budget.
The sum, within the budget.
The product, within the budget.
The quotient, within the budget.
Truncated subtraction, within the budget.
The remainder, within the budget.
The strict comparison, within the budget.
A fixed natural power, within the budget.
The remainder modulo a positive constant, as an element of Fin w.
some of a value, within the budget.
The value of an option with a fixed default, within the budget.
Whether an option holds a value, within the budget.