Metamath Proof Explorer


Theorem gausslemma2d

Description: Gauss' Lemma (see also theorem 9.6 in ApostolNT p. 182) for integer 2 : Let p be an odd prime. Let S={2,4,6,...,(p-1)}. Let n denote the number of elements of S whose least positive residue modulo p is greater than p/2. Then ( 2 | p ) = (-1)^n. (Contributed by AV, 14-Jul-2021)

Ref Expression
Hypotheses gausslemma2d.p φ P 2
gausslemma2d.h H = P 1 2
gausslemma2d.r R = x 1 H if x 2 < P 2 x 2 P x 2
gausslemma2d.m M = P 4
gausslemma2d.n N = H M
Assertion gausslemma2d φ 2 / L P = 1 N

Proof

Step Hyp Ref Expression
1 gausslemma2d.p φ P 2
2 gausslemma2d.h H = P 1 2
3 gausslemma2d.r R = x 1 H if x 2 < P 2 x 2 P x 2
4 gausslemma2d.m M = P 4
5 gausslemma2d.n N = H M
6 1 2 3 4 5 gausslemma2dlem7 φ 1 N 2 H mod P = 1
7 eldifi P 2 P
8 prmnn P P
9 8 nnred P P
10 prmgt1 P 1 < P
11 9 10 jca P P 1 < P
12 1 7 11 3syl φ P 1 < P
13 1mod P 1 < P 1 mod P = 1
14 12 13 syl φ 1 mod P = 1
15 14 eqcomd φ 1 = 1 mod P
16 15 eqeq2d φ 1 N 2 H mod P = 1 1 N 2 H mod P = 1 mod P
17 neg1z 1
18 1 4 2 5 gausslemma2dlem0h φ N 0
19 zexpcl 1 N 0 1 N
20 17 18 19 sylancr φ 1 N
21 2nn 2
22 21 a1i φ 2
23 1 2 gausslemma2dlem0b φ H
24 23 nnnn0d φ H 0
25 22 24 nnexpcld φ 2 H
26 25 nnzd φ 2 H
27 20 26 zmulcld φ 1 N 2 H
28 27 zred φ 1 N 2 H
29 1red φ 1
30 28 29 jca φ 1 N 2 H 1
31 30 adantr φ 1 N 2 H mod P = 1 mod P 1 N 2 H 1
32 1 gausslemma2dlem0a φ P
33 32 nnrpd φ P +
34 20 33 jca φ 1 N P +
35 34 adantr φ 1 N 2 H mod P = 1 mod P 1 N P +
36 simpr φ 1 N 2 H mod P = 1 mod P 1 N 2 H mod P = 1 mod P
37 modmul1 1 N 2 H 1 1 N P + 1 N 2 H mod P = 1 mod P 1 N 2 H 1 N mod P = 1 1 N mod P
38 31 35 36 37 syl3anc φ 1 N 2 H mod P = 1 mod P 1 N 2 H 1 N mod P = 1 1 N mod P
39 38 ex φ 1 N 2 H mod P = 1 mod P 1 N 2 H 1 N mod P = 1 1 N mod P
40 20 zcnd φ 1 N
41 25 nncnd φ 2 H
42 40 41 40 mul32d φ 1 N 2 H 1 N = 1 N 1 N 2 H
43 18 nn0cnd φ N
44 43 2timesd φ 2 N = N + N
45 44 eqcomd φ N + N = 2 N
46 45 oveq2d φ 1 N + N = 1 2 N
47 neg1cn 1
48 47 a1i φ 1
49 48 18 18 expaddd φ 1 N + N = 1 N 1 N
50 18 nn0zd φ N
51 m1expeven N 1 2 N = 1
52 50 51 syl φ 1 2 N = 1
53 46 49 52 3eqtr3d φ 1 N 1 N = 1
54 53 oveq1d φ 1 N 1 N 2 H = 1 2 H
55 41 mulid2d φ 1 2 H = 2 H
56 42 54 55 3eqtrd φ 1 N 2 H 1 N = 2 H
57 56 oveq1d φ 1 N 2 H 1 N mod P = 2 H mod P
58 40 mulid2d φ 1 1 N = 1 N
59 58 oveq1d φ 1 1 N mod P = 1 N mod P
60 57 59 eqeq12d φ 1 N 2 H 1 N mod P = 1 1 N mod P 2 H mod P = 1 N mod P
61 2 oveq2i 2 H = 2 P 1 2
62 61 oveq1i 2 H mod P = 2 P 1 2 mod P
63 62 eqeq1i 2 H mod P = 1 N mod P 2 P 1 2 mod P = 1 N mod P
64 2z 2
65 lgsvalmod 2 P 2 2 / L P mod P = 2 P 1 2 mod P
66 64 1 65 sylancr φ 2 / L P mod P = 2 P 1 2 mod P
67 66 eqcomd φ 2 P 1 2 mod P = 2 / L P mod P
68 67 eqeq1d φ 2 P 1 2 mod P = 1 N mod P 2 / L P mod P = 1 N mod P
69 1 4 2 5 gausslemma2dlem0i φ 2 / L P mod P = 1 N mod P 2 / L P = 1 N
70 68 69 sylbid φ 2 P 1 2 mod P = 1 N mod P 2 / L P = 1 N
71 63 70 syl5bi φ 2 H mod P = 1 N mod P 2 / L P = 1 N
72 60 71 sylbid φ 1 N 2 H 1 N mod P = 1 1 N mod P 2 / L P = 1 N
73 39 72 syld φ 1 N 2 H mod P = 1 mod P 2 / L P = 1 N
74 16 73 sylbid φ 1 N 2 H mod P = 1 2 / L P = 1 N
75 6 74 mpd φ 2 / L P = 1 N