Polynomial-time folds #
The polynomial-time counterparts of Christian Reitwiessner's degree-bounded fold rules. A
SizedListEncoding accounts for list lengths, elements and suffixes, leaving only a polynomial
bound on the intermediate accumulator. The step may carry a fixed parameter. The basic folds
come from the degree-bounded fold rules; the specification and growth contracts are the plain
contracts of Turing.MultiTapeTM.ComputableInPolyTime (in Internal.PolyTimeLoops) with tidied
conclusions.
Main definitions #
Turing.MultiTapeTM.encFoldStep: the encoding of the input of a fold step with a parameter.
Main results #
Turing.MultiTapeTM.ComputableTidilyInPolyTime.foldl': a fold with bounded accumulators.Turing.MultiTapeTM.ComputableTidilyInPolyTime.foldlWith: a fold with a fixed parameter.Turing.MultiTapeTM.ComputableTidilyInPolyTime.foldl_spec: one prefix invariant proves both polynomial-time computation and the final postcondition.Turing.MultiTapeTM.ComputableTidilyInPolyTime.foldlWith_spec: the same contract with a computed captured parameter.Turing.MultiTapeTM.ComputableTidilyInPolyTime.foldlWith_of_bounded_growth: input-dependent additive growth on the values occurring in the runtime list.Turing.MultiTapeTM.ComputableTidilyInPolyTime.foldlWithInput_of_bounded_growth: the same contract for a callback that captures the original input.
The specification interface is adapted from IsPolyTime.list_foldl_spec in the cslib
crypto branch.
The encoding of the input ((p, b), a) of a fold step with a fixed parameter: the pair of the
parameter p, framed, and the accumulator b, framed as a whole, then the element a.
Instances For
A left fold is polynomial-time when its step is polynomial-time and its intermediate accumulators have polynomially bounded encoded length.
A polynomial-time fold whose step also uses a fixed, polynomial-time computable parameter.
A prefix invariant supplies both the accumulator bound and the final postcondition for a fold with a captured parameter. The size bound may depend on the original input and need not be computable. The step certificate is uniform jointly in the parameter, accumulator and element.
A prefix invariant supplies both the accumulator bound and the final postcondition. The size bound may depend on the original input and need not be computable. The list and step must have uniform polynomial-time certificates.
A captured fold may add a polynomial amount of storage per element, measured against the original input. The growth bound covers every accumulator and each element in the runtime list; the joint step certificate still covers all parameters, accumulators and elements.
A fold callback may capture its original input. Growth is needed only on elements of the
runtime list, for every accumulator. Joint computation and encoding evidence lets automation
choose compatible list and callback certificates; paired growth obligations select a common
polynomial bound. The general foldlWith_of_bounded_growth contract takes separate premises.
Constant additive growth discharges the fold's intermediate-size obligation.