# mathlib3documentation

number_theory.legendre_symbol.gauss_eisenstein_lemmas

# Lemmas of Gauss and Eisenstein #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

This file contains the Lemmas of Gauss and Eisenstein on the Legendre symbol. The main results are zmod.gauss_lemma and zmod.eisenstein_lemma.

theorem zmod.Ico_map_val_min_abs_nat_abs_eq_Ico_map_id (p : ) [hp : fact (nat.prime p)] (a : zmod p) (hap : a 0) :
multiset.map (λ (x : ), (a * x).val_min_abs.nat_abs) (p / 2).succ).val = multiset.map (λ (a : ), a) (p / 2).succ).val

The image of the map sending a non zero natural number x ≤ p / 2 to the absolute value of the element of interger in the interval (-p/2, p/2] congruent to a * x mod p is the set of non zero natural numbers x such that x ≤ p / 2

theorem zmod.gauss_lemma_aux (p : ) [hp : fact (nat.prime p)] [fact (p % 2 = 1)] {a : } (hap : a 0) :
a ^ (p / 2) = (-1) ^ (finset.filter (λ (x : ), p / 2 < (a * x).val) (p / 2).succ)).card
theorem zmod.gauss_lemma {p : } [fact (nat.prime p)] {a : } (hp : p 2) (ha0 : a 0) :
a = (-1) ^ (finset.filter (λ (x : ), p / 2 < (a * x).val) (p / 2).succ)).card

Gauss' lemma. The legendre symbol can be computed by considering the number of naturals less than p/2 such that (a * x) % p > p / 2

theorem zmod.eisenstein_lemma_aux (p : ) [fact (nat.prime p)] [fact (p % 2 = 1)] {a : } (ha2 : a % 2 = 1) (hap : a 0) :
(finset.filter (λ (x : ), p / 2 < (a * x).val) (p / 2).succ)).card (p / 2).succ).sum (λ (x : ), x * a / p) [MOD 2]
theorem zmod.div_eq_filter_card {a b c : } (hb0 : 0 < b) (hc : a / b c) :
a / b = (finset.filter (λ (x : ), x * b a) c.succ)).card
theorem zmod.sum_mul_div_add_sum_mul_div_eq_mul (p q : ) [hp : fact (nat.prime p)] (hq0 : q 0) :
(p / 2).succ).sum (λ (a : ), a * q / p) + (q / 2).succ).sum (λ (a : ), a * p / q) = p / 2 * (q / 2)

Each of the sums in this lemma is the cardinality of the set integer points in each of the two triangles formed by the diagonal of the rectangle (0, p/2) × (0, q/2). Adding them gives the number of points in the rectangle.

theorem zmod.eisenstein_lemma {p : } [fact (nat.prime p)] (hp : p 2) {a : } (ha1 : a % 2 = 1) (ha0 : a 0) :
= (-1) ^ (p / 2).succ).sum (λ (x : ), x * a / p)