theoremunit_square_residue_card_le (q : ℕ) [NeZero q] (a : (ZMod q)ˣ) :
((Finset.univ : Finset (ZMod q)).filter
(fun x =>IsUnit x ∧ x ^ 2 = (a : ZMod q))).card ≤2 ^ (q.primeFactors.card + 1) :=by
proof · 14
lines
letF:= {x : ZMod q // IsUnit x ∧ x ^ 2 = (a : ZMod q)}
letf : F→ {x : (ZMod q)ˣ // x ^ 2 = a} :=fun x =>
⟨x.property.1.unit, by
apply Units.ext
simpa only [Units.val_pow_eq_pow_val, IsUnit.unit_spec] using x.property.2⟩
havehinj : Function.Injective f :=by
intro x y h
apply Subtype.ext
have hv := congrArg (funz : {x : (ZMod q)ˣ // x ^ 2 = a} => (z.val : ZMod q)) h
simpa only [f, IsUnit.unit_spec] using hv
have hc :=Fintype.card_le_of_injective f hinj
have hb := unit_square_fiber_card_le q a
rw [Nat.card_eq_fintype_card] at hb
exact (show _ ≤Fintype.card Ffromby simp [F, Fintype.card_subtype]).trans (hc.trans hb)