Plain polynomial-time signed integer division and modular reduction #
Plain Turing.MultiTapeTM.ComputableInPolyTime certificates, exact-division identities, and
sign-magnitude code-length bounds for signed binary integer division and remainder over
Turing.MultiTapeTM.encIntBin:
- truncated-toward-zero division and remainder (
Int.tdiv,Int.tmod); - Euclidean division and nonnegative remainder (
Int.ediv,Int.emod, and the/and%operators onℤ); - power-of-two modular reduction
Int.modPowTwo x ℓ = x % 2 ^ ℓwithℓin unaryTuring.MultiTapeTM.encUnary, used to recover integer counts modulo2 ^ ℓin Appendix B.3 of [OAI26c].
All certificates are total (at divisor 0, a / 0 = 0, a.tdiv 0 = 0, a % 0 = a, and
a.tmod 0 = a) and build on the binary natural division and modular reduction primitives of
PolyTime/Nat/BinaryDiv and PolyTime/Int/BinaryDiv without constructing new Turing machines.
Main definitions #
Int.modPowTwo: least nonnegative residuex % (2 : ℤ) ^ ℓmodulo2 ^ ℓ.
Main results #
Int.ediv_mul_left_exact,Int.ediv_mul_right_exact: exact Euclidean division of integer multiples(d * q).ediv d = qand(q * d).ediv d = qford ≠ 0.Int.modPowTwo_eq_of_dvd_sub: unique recovery ofz ∈ [0, 2 ^ ℓ)from anyxwith2 ^ ℓ ∣ x - z.Int.size_natAbs_tdiv_le,Int.size_natAbs_ediv_le,Int.size_natAbs_emod_le_of_ne_zero,Int.size_natAbs_modPowTwo_le,Turing.MultiTapeTM.length_encIntBin_tdiv_le,Turing.MultiTapeTM.length_encIntBin_ediv_le,Turing.MultiTapeTM.length_encIntBin_emod_le_of_ne_zero,Turing.MultiTapeTM.length_encIntBin_emod_le_max,Turing.MultiTapeTM.length_encIntBin_modPowTwo_le: binary magnitude andencIntBincode-length bounds.Turing.MultiTapeTM.ComputableInPolyTime.intBin_tdiv,.intBin_tmod,.intBin_ediv,.intBin_emod,.intBin_div,.intBin_mod,.intBin_modPowTwo: plain polynomial-time certificates and@[fun_prop]composition rules (.intBin_tdiv',.intBin_tmod',.intBin_ediv',.intBin_emod',.intBin_div',.intBin_mod',.intBin_modPowTwo').
References #
Exact division and power-of-two modular reduction #
Least nonnegative residue of x modulo 2 ^ ℓ, i.e., x - 2 ^ ℓ * ⌊x / 2 ^ ℓ⌋.
Instances For
Sign-magnitude reductions and magnitude bounds #
Sign-magnitude encIntBin code-length bounds #
Plain polynomial-time certificates #
Truncated-toward-zero division of computed binary integers.
Truncated-toward-zero remainder of computed binary integers.
Euclidean division (Int.ediv) of computed binary integers.
Euclidean division (/) of computed binary integers.
Euclidean remainder (Int.emod) of computed binary integers.
Euclidean remainder (%) of computed binary integers.
Reduction Int.modPowTwo p.1 p.2 = p.1 % 2 ^ p.2 of a binary integer modulo 2 ^ ℓ (with
ℓ in unary) is computable in polynomial time.
Reduction Int.modPowTwo (value a) (exponent a) of a computed binary integer modulo a
computed unary power of two.