Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Int.BinaryDiv

Polynomial-time reduction of signed binary integers #

Reduce a signed binary integer modulo a binary natural and return the nonnegative residue. The construction first computes r = z.natAbs % q. For a negative integer it returns (q - r) % q; otherwise it returns r. This reuses binary natural division, subtraction and the sign-magnitude interface, without enumerating the modulus or constructing a new machine.

The certificate is total: at modulus zero the result is z.toNat, matching Lean's integer remainder convention followed by truncation at zero.

Main results #

References #

The proof uses Lean's Int.emod_natAbs_of_nonneg and Int.emod_natAbs_of_neg and the native arithmetic certificates in PolyTime/Int/Binary and PolyTime/Nat/BinaryDiv.

Reduce a signed binary integer modulo a binary natural. At modulus zero the result is the integer truncated at zero; no positive-modulus hypothesis is required.

theorem Turing.MultiTapeTM.ComputableInPolyTime.intBin_emodNat' {α : Type} {input : α ↪ List Bool} {value : α → ℤ} {modulus : α → ℕ} (hvalue : ComputableInPolyTime value input encIntBin) (hmodulus : ComputableInPolyTime modulus input encNat) :
ComputableInPolyTime (fun (a : α) => (value a % ↑(modulus a)).toNat) input encNat

Reduce computed signed integers by computed binary natural moduli, fixing the intermediate encodings for proof search.