Polynomial-time iteration with invariants #
The loop count is computed in unary, so its value is polynomially bounded in the encoded input.
The caller certifies the step and bounds the encoded intermediate states. The captured-parameter
rules are the plain rules of Turing.MultiTapeTM.ComputableInPolyTime (in
Internal.PolyTimeLoops) with tidied conclusions. The specification interface is adapted from
IsPolyTime.iterate_spec in the cslib crypto branch.
Main results #
Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterate: iteration with a size bound.Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterateWith: the same bound with captured data.Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterate_spec: a loop invariant gives both polynomial-time computation and the final postcondition.Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterateWith_spec: capture a computed parameter while retaining a uniform joint certificate for the step.Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterate_of_bounded_growth: constant additive state growth discharges intermediate-size obligations.Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterateWith_of_bounded_growth: captured loops with a polynomial per-step growth bound depending on the original input.Turing.MultiTapeTM.ComputableTidilyInPolyTime.iterateWithInput_of_bounded_growth: the same growth contract with the original input captured directly, for certificate inference.
References #
Adapted from Computability/Probabilistic/Iteration.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8.
Capture a computed parameter while bounding every intermediate loop state.
A unary loop count and polynomially bounded intermediate states give a polynomial-time loop.
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.