Enumerating a prime field by natural representatives #
The enumeration bridge needs only a nonzero modulus. Fintype.sum_extend_by_zero supplies
restriction to a finite subset.
These identities separate finite-field enumeration from the bit-cost certificates of its computational realizations.
theorem ZMod.sum_range_natCast {n : ℕ} [NeZero n] {M : Type u_1} [AddCommMonoid M] (h : ZMod n → M) :
Summing over least natural representatives enumerates a nonzero residue ring once.
theorem ZMod.sum_range_natCast_mem {n : ℕ} [NeZero n] {M : Type u_1} [AddCommMonoid M] (s : Finset (ZMod n)) (h : ZMod n → M) :
Restricting the enumeration by membership gives a sum over the chosen finite subset.
Natural representative tests count a finite subset exactly. In particular this applies to
primitiveRoots (p - 1) (ZMod p), with cardinality bounds supplied by GeneratorProducts.