Direct plain folds with reachable-prefix bounds #
Derived from the machine-level plain fold of the credited #869 supplier. The accumulator is bounded only on reachable prefixes; no bound on arbitrary unreachable states is assumed. The rules use the canonical direct core and its independent polynomial-growth algebra.
A unary-output certificate bounds the actual numeric value by a polynomial in input size.
A polynomial bound on the encoded accumulators of reachable prefixes suffices for a uniform polynomial-time fold. The list and callback encodings are preserved.
A captured parameter is computed uniformly, retained through every step, and bounded separately from the accumulator. Only reachable prefix states need the supplied bound.
A computed captured parameter and a unary loop count give a uniform loop when every reachable iterate has polynomially bounded encoded size.
A unary count and a bound only on the reachable states suffice for polynomial-time iteration, with the original state encoding.
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.
Iteration may capture a computed parameter. The joint step certificate must be uniform in that parameter; the invariant and size bound concern the original input. The bound need not be computable and may use properties of the input beyond its encoded length.
One invariant proves both the resource bound and the final loop postcondition.
A captured loop may add a polynomial amount of storage per iteration, measured against the original input. A bound depending only on the current state would not justify this rule.
An iteration step may capture its original input. Paired growth obligations let automation select a common polynomial bound. The uniform joint step certificate charges the captured input on every iteration; the growth bound need not itself be computable.
A loop with constant additive state growth has polynomially bounded intermediate states.