Residues modulo two and modulo powers of two #
A residue modulo two is 0 or 1, so its canonical representative ZMod.val is the indicator
of being nonzero. This is the identity behind the counting arguments that read a ℕ-valued
weight off a ZMod 2-valued vector: summing the representatives of the coordinates counts the
nonzero ones.
In ℤ/2^n the element 2 is nilpotent, so in ℤ/2^{k+1} the units are exactly the odd
elements: an even element plus a unit is a unit, and an even element is never a unit.
Main results #
ZMod.val_eq_ite_mod_two:a.val = if a ≠ 0 then 1 else 0fora : ZMod 2.ZMod.isNilpotent_two:2is nilpotent inℤ/2^n.ZMod.isUnit_two_mul_add:2c + uis a unit inℤ/2^{k+1}whenuis.ZMod.not_isUnit_two_mul:2cis not a unit inℤ/2^{k+1}.ZMod.eq_two_mul_or_eq_two_mul_add_one: every element ofℤ/2^{k+1}is even or odd.
2 is nilpotent modulo a power of two: 2 ^ n = 0 in ℤ/2^n.