Documentation

CslibFrontier.Foundations.NumberTheory.FiniteField.Enumeration

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) :
∑ g ∈ Finset.range n, h ↑g = ∑ γ : ZMod n, h γ

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) :
(∑ g ∈ Finset.range n, if ↑g ∈ s then h ↑g else 0) = ∑ γ ∈ s, h γ

Restricting the enumeration by membership gives a sum over the chosen finite subset.

theorem ZMod.count_range_natCast_mem {n : ℕ} [NeZero n] (s : Finset (ZMod n)) :
(∑ g ∈ Finset.range n, if ↑g ∈ s then 1 else 0) = s.card

Natural representative tests count a finite subset exactly. In particular this applies to primitiveRoots (p - 1) (ZMod p), with cardinality bounds supplied by GeneratorProducts.