Metamath Proof Explorer


Theorem powm2modprm

Description: If an integer minus 1 is divisible by a prime number, then the integer to the power of the prime number minus 2 is 1 modulo the prime number. (Contributed by Alexander van der Vekens, 30-Aug-2018)

Ref Expression
Assertion powm2modprm PAPA1AP2modP=1

Proof

Step Hyp Ref Expression
1 simpll PAPA1P
2 simpr PAA
3 2 adantr PAPA1A
4 m1dvdsndvds PAPA1¬PA
5 4 imp PAPA1¬PA
6 eqid AP2modP=AP2modP
7 6 modprminv PA¬PAAP2modP1P1AAP2modPmodP=1
8 simpr AP2modP1P1AAP2modPmodP=1AAP2modPmodP=1
9 8 eqcomd AP2modP1P1AAP2modPmodP=11=AAP2modPmodP
10 7 9 syl PA¬PA1=AAP2modPmodP
11 1 3 5 10 syl3anc PAPA11=AAP2modPmodP
12 modprm1div PAAmodP=1PA1
13 12 biimpar PAPA1AmodP=1
14 13 oveq1d PAPA1AmodPAP2modP=1AP2modP
15 14 oveq1d PAPA1AmodPAP2modPmodP=1AP2modPmodP
16 zre AA
17 16 ad2antlr PAPA1A
18 prmm2nn0 PP20
19 18 anim1ci PAAP20
20 19 adantr PAPA1AP20
21 zexpcl AP20AP2
22 20 21 syl PAPA1AP2
23 prmnn PP
24 23 adantr PAP
25 24 adantr PAPA1P
26 22 25 zmodcld PAPA1AP2modP0
27 26 nn0zd PAPA1AP2modP
28 23 nnrpd PP+
29 28 adantr PAP+
30 29 adantr PAPA1P+
31 modmulmod AAP2modPP+AmodPAP2modPmodP=AAP2modPmodP
32 17 27 30 31 syl3anc PAPA1AmodPAP2modPmodP=AAP2modPmodP
33 19 21 syl PAAP2
34 33 24 zmodcld PAAP2modP0
35 34 nn0cnd PAAP2modP
36 35 mullidd PA1AP2modP=AP2modP
37 36 oveq1d PA1AP2modPmodP=AP2modPmodP
38 37 adantr PAPA11AP2modPmodP=AP2modPmodP
39 reexpcl AP20AP2
40 16 18 39 syl2anr PAAP2
41 40 29 jca PAAP2P+
42 41 adantr PAPA1AP2P+
43 modabs2 AP2P+AP2modPmodP=AP2modP
44 42 43 syl PAPA1AP2modPmodP=AP2modP
45 38 44 eqtrd PAPA11AP2modPmodP=AP2modP
46 15 32 45 3eqtr3d PAPA1AAP2modPmodP=AP2modP
47 11 46 eqtr2d PAPA1AP2modP=1
48 47 ex PAPA1AP2modP=1