Casts of natural-number expressions to ZMod #
Programs that work on natural numbers subtract a residue b modulo q as q - b % q, which
avoids truncated subtraction below zero. This module shows that the cast of q - b % q to
ZMod q is -b, and that the cast of q - 1 is -1.
Main results #
ZMod.natCast_sub_mod_eq_neg:((q - b % q : ℕ) : ZMod q) = -bforq ≠ 0.ZMod.natCast_self_sub_one:((q - 1 : ℕ) : ZMod q) = -1forq ≠ 0.