Metamath Proof Explorer


Theorem prmdivdiv

Description: The (modular) inverse of the inverse of a number is itself. (Contributed by Mario Carneiro, 24-Jan-2015)

Ref Expression
Hypothesis prmdiv.1 R = A P 2 mod P
Assertion prmdivdiv P A 1 P 1 A = R P 2 mod P

Proof

Step Hyp Ref Expression
1 prmdiv.1 R = A P 2 mod P
2 fz1ssfz0 1 P 1 0 P 1
3 simpr P A 1 P 1 A 1 P 1
4 2 3 sselid P A 1 P 1 A 0 P 1
5 simpl P A 1 P 1 P
6 elfznn A 1 P 1 A
7 6 adantl P A 1 P 1 A
8 7 nnzd P A 1 P 1 A
9 prmnn P P
10 fzm1ndvds P A 1 P 1 ¬ P A
11 9 10 sylan P A 1 P 1 ¬ P A
12 1 prmdiv P A ¬ P A R 1 P 1 P A R 1
13 5 8 11 12 syl3anc P A 1 P 1 R 1 P 1 P A R 1
14 13 simprd P A 1 P 1 P A R 1
15 7 nncnd P A 1 P 1 A
16 13 simpld P A 1 P 1 R 1 P 1
17 elfznn R 1 P 1 R
18 16 17 syl P A 1 P 1 R
19 18 nncnd P A 1 P 1 R
20 15 19 mulcomd P A 1 P 1 A R = R A
21 20 oveq1d P A 1 P 1 A R 1 = R A 1
22 14 21 breqtrd P A 1 P 1 P R A 1
23 16 elfzelzd P A 1 P 1 R
24 fzm1ndvds P R 1 P 1 ¬ P R
25 9 16 24 syl2an2r P A 1 P 1 ¬ P R
26 eqid R P 2 mod P = R P 2 mod P
27 26 prmdiveq P R ¬ P R A 0 P 1 P R A 1 A = R P 2 mod P
28 5 23 25 27 syl3anc P A 1 P 1 A 0 P 1 P R A 1 A = R P 2 mod P
29 4 22 28 mpbi2and P A 1 P 1 A = R P 2 mod P