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 P A P A 1 A P 2 mod P = 1

Proof

Step Hyp Ref Expression
1 simpll P A P A 1 P
2 simpr P A A
3 2 adantr P A P A 1 A
4 m1dvdsndvds P A P A 1 ¬ P A
5 4 imp P A P A 1 ¬ P A
6 eqid A P 2 mod P = A P 2 mod P
7 6 modprminv P A ¬ P A A P 2 mod P 1 P 1 A A P 2 mod P mod P = 1
8 simpr A P 2 mod P 1 P 1 A A P 2 mod P mod P = 1 A A P 2 mod P mod P = 1
9 8 eqcomd A P 2 mod P 1 P 1 A A P 2 mod P mod P = 1 1 = A A P 2 mod P mod P
10 7 9 syl P A ¬ P A 1 = A A P 2 mod P mod P
11 1 3 5 10 syl3anc P A P A 1 1 = A A P 2 mod P mod P
12 modprm1div P A A mod P = 1 P A 1
13 12 biimpar P A P A 1 A mod P = 1
14 13 oveq1d P A P A 1 A mod P A P 2 mod P = 1 A P 2 mod P
15 14 oveq1d P A P A 1 A mod P A P 2 mod P mod P = 1 A P 2 mod P mod P
16 zre A A
17 16 ad2antlr P A P A 1 A
18 prmm2nn0 P P 2 0
19 18 anim1ci P A A P 2 0
20 19 adantr P A P A 1 A P 2 0
21 zexpcl A P 2 0 A P 2
22 20 21 syl P A P A 1 A P 2
23 prmnn P P
24 23 adantr P A P
25 24 adantr P A P A 1 P
26 22 25 zmodcld P A P A 1 A P 2 mod P 0
27 26 nn0zd P A P A 1 A P 2 mod P
28 23 nnrpd P P +
29 28 adantr P A P +
30 29 adantr P A P A 1 P +
31 modmulmod A A P 2 mod P P + A mod P A P 2 mod P mod P = A A P 2 mod P mod P
32 17 27 30 31 syl3anc P A P A 1 A mod P A P 2 mod P mod P = A A P 2 mod P mod P
33 19 21 syl P A A P 2
34 33 24 zmodcld P A A P 2 mod P 0
35 34 nn0cnd P A A P 2 mod P
36 35 mulid2d P A 1 A P 2 mod P = A P 2 mod P
37 36 oveq1d P A 1 A P 2 mod P mod P = A P 2 mod P mod P
38 37 adantr P A P A 1 1 A P 2 mod P mod P = A P 2 mod P mod P
39 reexpcl A P 2 0 A P 2
40 16 18 39 syl2anr P A A P 2
41 40 29 jca P A A P 2 P +
42 41 adantr P A P A 1 A P 2 P +
43 modabs2 A P 2 P + A P 2 mod P mod P = A P 2 mod P
44 42 43 syl P A P A 1 A P 2 mod P mod P = A P 2 mod P
45 38 44 eqtrd P A P A 1 1 A P 2 mod P mod P = A P 2 mod P
46 15 32 45 3eqtr3d P A P A 1 A A P 2 mod P mod P = A P 2 mod P
47 11 46 eqtr2d P A P A 1 A P 2 mod P = 1
48 47 ex P A P A 1 A P 2 mod P = 1