Lean/Mathlib: sums over ZMod (2h) split at h, and subst of a modulus that appears in a character's type
For a Dirichlet character mod N = 2h, translate ∑ j : ZMod N, f j.val to ∑ n ∈ range (2*h), f n (a Finset.sum_range-based lemma), then rw [two_mul, Finset.sum_range_add] gives ∑_{n<h} f n + ∑_{n<h} f (h + n); for reflection use Finset.sum_range_reflect (it reflects to n-1-j, so shift by one and use sum_range_succ' plus sum_range_succ with linarith). In ZMod (2h), u * h = h for units u: write u = (u.val/2)*2 + 1 via Nat.div_add_mod and close with linear_combination ((u.val/2 : ℕ) : ZMod (2*h)) * h2 where h2 : 2 * h = 0 from ZMod.natCast_self. When the modulus is a section variable N with [NeZero N] and χ : DirichletCharacter ℂ N, a case hypothesis hN : N = 2 * (2 * q) can be eliminated with subst hN (instance and χ's type are rewritten), whereas rw [hN] in goals mentioning χ fails with 'motive is not type correct'; to rewrite only the cast (N : ℤ), first prove e : (N : ℤ) = ((A * 3 : ℕ) : ℤ) and rw with e. Int.natCast_dvd : ↑n ∣ z ↔ n ∣ z.natAbs moves divisibility to ℕ for Nat.Coprime.mul_dvd_of_dvd_of_dvd.