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 simpl2 P A ¬ P A S 0 P 1 P A S 1 A
6 elfzelz S 0 P 1 S
7 6 ad2antrl P A ¬ P A S 0 P 1 P A S 1 S
8 5 7 zmulcld P A ¬ P A S 0 P 1 P A S 1 A S
9 1z 1
10 zsubcl A S 1 A S 1
11 8 9 10 sylancl P A ¬ P A S 0 P 1 P A S 1 A S 1
12 1 prmdiv P A ¬ P A R 1 P 1 P A R 1
13 12 adantr P A ¬ P A S 0 P 1 P A S 1 R 1 P 1 P A R 1
14 13 simpld P A ¬ P A S 0 P 1 P A S 1 R 1 P 1
15 elfzelz R 1 P 1 R
16 14 15 syl P A ¬ P A S 0 P 1 P A S 1 R
17 5 16 zmulcld P A ¬ P A S 0 P 1 P A S 1 A R
18 zsubcl A R 1 A R 1
19 17 9 18 sylancl P A ¬ P A S 0 P 1 P A S 1 A R 1
20 simprr P A ¬ P A S 0 P 1 P A S 1 P A S 1
21 13 simprd P A ¬ P A S 0 P 1 P A S 1 P A R 1
22 4 11 19 20 21 dvds2subd P A ¬ P A S 0 P 1 P A S 1 P A S - 1 - A R 1
23 8 zcnd P A ¬ P A S 0 P 1 P A S 1 A S
24 17 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 5 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 16 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 5 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 7 16 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 5 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 7 16 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 7 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 5 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 12 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