Division and remainder of unary counters #
A quotient/remainder loop scans the unary dividend and captures the divisor. One invariant proves its arithmetic specification and the linear bound on encoded intermediate states, including divisor zero. The fixed-divisor interface follows by composition.
Main results #
Turing.MultiTapeTM.ComputableTidilyInPolyTime.unary_divMod: compute quotient and remainder.Turing.MultiTapeTM.ComputableTidilyInPolyTime.unary_div,.unary_mod: project either result.Turing.MultiTapeTM.ComputableTidilyInPolyTime.unary_div_const: division by a fixed natural.Turing.MultiTapeTM.ComputableInPolyTime.unary_div',.unary_mod': composition rules forfun_propon plain certificates.
References #
The machine realization uses the invariant-based loop calculus in PolyTime.Iteration.
Compute both quotient and remainder with a runtime unary divisor. Division by zero returns
(0, dividend), matching Lean's conventions. All intermediate counters have linear size.
Division by a fixed natural is a special case of runtime unary division.
Divide two computed unary naturals with the same full input context.
Take the remainder of two computed unary naturals with the same full input context.
Compute both quotient and remainder with a runtime unary divisor. Division by zero returns
(0, dividend), matching Lean's conventions. All intermediate counters have linear size.
Division by a fixed natural is a special case of runtime unary division.