Metamath Proof Explorer


Theorem lgsvalmod

Description: The Legendre symbol is equivalent to a ^ ( ( p - 1 ) / 2 ) , mod p . This theorem is also called "Euler's criterion", see theorem 9.2 in ApostolNT p. 180, or a representation of Euler's criterion using the Legendre symbol, see also lgsqr . (Contributed by Mario Carneiro, 4-Feb-2015)

Ref Expression
Assertion lgsvalmod A P 2 A / L P mod P = A P 1 2 mod P

Proof

Step Hyp Ref Expression
1 eldifi P 2 P
2 1 adantl A P 2 P
3 prmz P P
4 2 3 syl A P 2 P
5 lgscl A P A / L P
6 4 5 syldan A P 2 A / L P
7 6 zred A P 2 A / L P
8 peano2re A / L P A / L P + 1
9 7 8 syl A P 2 A / L P + 1
10 oddprm P 2 P 1 2
11 10 adantl A P 2 P 1 2
12 11 nnnn0d A P 2 P 1 2 0
13 zexpcl A P 1 2 0 A P 1 2
14 12 13 syldan A P 2 A P 1 2
15 14 zred A P 2 A P 1 2
16 peano2re A P 1 2 A P 1 2 + 1
17 15 16 syl A P 2 A P 1 2 + 1
18 neg1rr 1
19 18 a1i A P 2 1
20 prmnn P P
21 2 20 syl A P 2 P
22 21 nnrpd A P 2 P +
23 lgsval3 A P 2 A / L P = A P 1 2 + 1 mod P 1
24 23 eqcomd A P 2 A P 1 2 + 1 mod P 1 = A / L P
25 17 22 modcld A P 2 A P 1 2 + 1 mod P
26 25 recnd A P 2 A P 1 2 + 1 mod P
27 ax-1cn 1
28 27 a1i A P 2 1
29 7 recnd A P 2 A / L P
30 26 28 29 subadd2d A P 2 A P 1 2 + 1 mod P 1 = A / L P A / L P + 1 = A P 1 2 + 1 mod P
31 24 30 mpbid A P 2 A / L P + 1 = A P 1 2 + 1 mod P
32 31 oveq1d A P 2 A / L P + 1 mod P = A P 1 2 + 1 mod P mod P
33 modabs2 A P 1 2 + 1 P + A P 1 2 + 1 mod P mod P = A P 1 2 + 1 mod P
34 17 22 33 syl2anc A P 2 A P 1 2 + 1 mod P mod P = A P 1 2 + 1 mod P
35 32 34 eqtrd A P 2 A / L P + 1 mod P = A P 1 2 + 1 mod P
36 modadd1 A / L P + 1 A P 1 2 + 1 1 P + A / L P + 1 mod P = A P 1 2 + 1 mod P A / L P + 1 + -1 mod P = A P 1 2 + 1 + -1 mod P
37 9 17 19 22 35 36 syl221anc A P 2 A / L P + 1 + -1 mod P = A P 1 2 + 1 + -1 mod P
38 9 recnd A P 2 A / L P + 1
39 negsub A / L P + 1 1 A / L P + 1 + -1 = A / L P + 1 - 1
40 38 27 39 sylancl A P 2 A / L P + 1 + -1 = A / L P + 1 - 1
41 pncan A / L P 1 A / L P + 1 - 1 = A / L P
42 29 27 41 sylancl A P 2 A / L P + 1 - 1 = A / L P
43 40 42 eqtrd A P 2 A / L P + 1 + -1 = A / L P
44 43 oveq1d A P 2 A / L P + 1 + -1 mod P = A / L P mod P
45 17 recnd A P 2 A P 1 2 + 1
46 negsub A P 1 2 + 1 1 A P 1 2 + 1 + -1 = A P 1 2 + 1 - 1
47 45 27 46 sylancl A P 2 A P 1 2 + 1 + -1 = A P 1 2 + 1 - 1
48 15 recnd A P 2 A P 1 2
49 pncan A P 1 2 1 A P 1 2 + 1 - 1 = A P 1 2
50 48 27 49 sylancl A P 2 A P 1 2 + 1 - 1 = A P 1 2
51 47 50 eqtrd A P 2 A P 1 2 + 1 + -1 = A P 1 2
52 51 oveq1d A P 2 A P 1 2 + 1 + -1 mod P = A P 1 2 mod P
53 37 44 52 3eqtr3d A P 2 A / L P mod P = A P 1 2 mod P