Metamath Proof Explorer


Theorem prmdiveq

Description: The modular inverse of A mod P is unique. (Contributed by Mario Carneiro, 24-Jan-2015)

Ref Expression
Hypothesis prmdiv.1 R = A P 2 mod P
Assertion prmdiveq P A ¬ P A S 0 P 1 P A S 1 S = R

Proof

Step Hyp Ref Expression
1 prmdiv.1 R = A P 2 mod P
2 simpl1 P A ¬ P A S 0 P 1 P A S 1 P
3 prmz P P
4 2 3 syl P A ¬ P A S 0 P 1 P A S 1 P
5 simprr P A ¬ P A S 0 P 1 P A S 1 P A S 1
6 1 prmdiv P A ¬ P A R 1 P 1 P A R 1
7 6 adantr P A ¬ P A S 0 P 1 P A S 1 R 1 P 1 P A R 1
8 7 simprd P A ¬ P A S 0 P 1 P A S 1 P A R 1
9 simpl2 P A ¬ P A S 0 P 1 P A S 1 A
10 elfzelz S 0 P 1 S
11 10 ad2antrl P A ¬ P A S 0 P 1 P A S 1 S
12 9 11 zmulcld P A ¬ P A S 0 P 1 P A S 1 A S
13 1z 1
14 zsubcl A S 1 A S 1
15 12 13 14 sylancl P A ¬ P A S 0 P 1 P A S 1 A S 1
16 7 simpld P A ¬ P A S 0 P 1 P A S 1 R 1 P 1
17 elfzelz R 1 P 1 R
18 16 17 syl P A ¬ P A S 0 P 1 P A S 1 R
19 9 18 zmulcld P A ¬ P A S 0 P 1 P A S 1 A R
20 zsubcl A R 1 A R 1
21 19 13 20 sylancl P A ¬ P A S 0 P 1 P A S 1 A R 1
22 4 5 8 15 21 dvds2subd P A ¬ P A S 0 P 1 P A S 1 P A S - 1 - A R 1
23 12 zcnd P A ¬ P A S 0 P 1 P A S 1 A S
24 19 zcnd P A ¬ P A S 0 P 1 P A S 1 A R
25 1cnd P A ¬ P A S 0 P 1 P A S 1 1
26 23 24 25 nnncan2d P A ¬ P A S 0 P 1 P A S 1 A S - 1 - A R 1 = A S A R
27 9 zcnd P A ¬ P A S 0 P 1 P A S 1 A
28 elfznn0 S 0 P 1 S 0
29 28 ad2antrl P A ¬ P A S 0 P 1 P A S 1 S 0
30 29 nn0red P A ¬ P A S 0 P 1 P A S 1 S
31 30 recnd P A ¬ P A S 0 P 1 P A S 1 S
32 18 zcnd P A ¬ P A S 0 P 1 P A S 1 R
33 27 31 32 subdid P A ¬ P A S 0 P 1 P A S 1 A S R = A S A R
34 26 33 eqtr4d P A ¬ P A S 0 P 1 P A S 1 A S - 1 - A R 1 = A S R
35 22 34 breqtrd P A ¬ P A S 0 P 1 P A S 1 P A S R
36 simpl3 P A ¬ P A S 0 P 1 P A S 1 ¬ P A
37 coprm P A ¬ P A P gcd A = 1
38 2 9 37 syl2anc P A ¬ P A S 0 P 1 P A S 1 ¬ P A P gcd A = 1
39 36 38 mpbid P A ¬ P A S 0 P 1 P A S 1 P gcd A = 1
40 11 18 zsubcld P A ¬ P A S 0 P 1 P A S 1 S R
41 coprmdvds P A S R P A S R P gcd A = 1 P S R
42 4 9 40 41 syl3anc P A ¬ P A S 0 P 1 P A S 1 P A S R P gcd A = 1 P S R
43 35 39 42 mp2and P A ¬ P A S 0 P 1 P A S 1 P S R
44 prmnn P P
45 2 44 syl P A ¬ P A S 0 P 1 P A S 1 P
46 moddvds P S R S mod P = R mod P P S R
47 45 11 18 46 syl3anc P A ¬ P A S 0 P 1 P A S 1 S mod P = R mod P P S R
48 43 47 mpbird P A ¬ P A S 0 P 1 P A S 1 S mod P = R mod P
49 45 nnrpd P A ¬ P A S 0 P 1 P A S 1 P +
50 elfzle1 S 0 P 1 0 S
51 50 ad2antrl P A ¬ P A S 0 P 1 P A S 1 0 S
52 elfzle2 S 0 P 1 S P 1
53 52 ad2antrl P A ¬ P A S 0 P 1 P A S 1 S P 1
54 zltlem1 S P S < P S P 1
55 11 4 54 syl2anc P A ¬ P A S 0 P 1 P A S 1 S < P S P 1
56 53 55 mpbird P A ¬ P A S 0 P 1 P A S 1 S < P
57 modid S P + 0 S S < P S mod P = S
58 30 49 51 56 57 syl22anc P A ¬ P A S 0 P 1 P A S 1 S mod P = S
59 prmuz2 P P 2
60 uznn0sub P 2 P 2 0
61 2 59 60 3syl P A ¬ P A S 0 P 1 P A S 1 P 2 0
62 zexpcl A P 2 0 A P 2
63 9 61 62 syl2anc P A ¬ P A S 0 P 1 P A S 1 A P 2
64 63 zred P A ¬ P A S 0 P 1 P A S 1 A P 2
65 modabs2 A P 2 P + A P 2 mod P mod P = A P 2 mod P
66 64 49 65 syl2anc P A ¬ P A S 0 P 1 P A S 1 A P 2 mod P mod P = A P 2 mod P
67 1 oveq1i R mod P = A P 2 mod P mod P
68 66 67 1 3eqtr4g P A ¬ P A S 0 P 1 P A S 1 R mod P = R
69 48 58 68 3eqtr3d P A ¬ P A S 0 P 1 P A S 1 S = R
70 69 ex P A ¬ P A S 0 P 1 P A S 1 S = R
71 fz1ssfz0 1 P 1 0 P 1
72 71 sseli R 1 P 1 R 0 P 1
73 eleq1 S = R S 0 P 1 R 0 P 1
74 72 73 syl5ibr S = R R 1 P 1 S 0 P 1
75 oveq2 S = R A S = A R
76 75 oveq1d S = R A S 1 = A R 1
77 76 breq2d S = R P A S 1 P A R 1
78 77 biimprd S = R P A R 1 P A S 1
79 74 78 anim12d S = R R 1 P 1 P A R 1 S 0 P 1 P A S 1
80 6 79 syl5com P A ¬ P A S = R S 0 P 1 P A S 1
81 70 80 impbid P A ¬ P A S 0 P 1 P A S 1 S = R