Metamath Proof Explorer


Theorem reumodprminv

Description: For any prime number and for any positive integer less than this prime number, there is a unique modular inverse of this positive integer. (Contributed by Alexander van der Vekens, 12-May-2018)

Ref Expression
Assertion reumodprminv P N 1 ..^ P ∃! i 1 P 1 N i mod P = 1

Proof

Step Hyp Ref Expression
1 simpl P N 1 ..^ P P
2 elfzoelz N 1 ..^ P N
3 2 adantl P N 1 ..^ P N
4 prmnn P P
5 prmz P P
6 fzoval P 1 ..^ P = 1 P 1
7 5 6 syl P 1 ..^ P = 1 P 1
8 7 eleq2d P N 1 ..^ P N 1 P 1
9 8 biimpa P N 1 ..^ P N 1 P 1
10 fzm1ndvds P N 1 P 1 ¬ P N
11 4 9 10 syl2an2r P N 1 ..^ P ¬ P N
12 eqid N P 2 mod P = N P 2 mod P
13 12 modprminv P N ¬ P N N P 2 mod P 1 P 1 N N P 2 mod P mod P = 1
14 13 simpld P N ¬ P N N P 2 mod P 1 P 1
15 13 simprd P N ¬ P N N N P 2 mod P mod P = 1
16 1eluzge0 1 0
17 fzss1 1 0 1 P 1 0 P 1
18 16 17 mp1i P 1 P 1 0 P 1
19 18 sseld P s 1 P 1 s 0 P 1
20 19 3ad2ant1 P N ¬ P N s 1 P 1 s 0 P 1
21 20 imdistani P N ¬ P N s 1 P 1 P N ¬ P N s 0 P 1
22 12 modprminveq P N ¬ P N s 0 P 1 N s mod P = 1 s = N P 2 mod P
23 22 biimpa P N ¬ P N s 0 P 1 N s mod P = 1 s = N P 2 mod P
24 23 eqcomd P N ¬ P N s 0 P 1 N s mod P = 1 N P 2 mod P = s
25 24 expr P N ¬ P N s 0 P 1 N s mod P = 1 N P 2 mod P = s
26 21 25 syl P N ¬ P N s 1 P 1 N s mod P = 1 N P 2 mod P = s
27 26 ralrimiva P N ¬ P N s 1 P 1 N s mod P = 1 N P 2 mod P = s
28 14 15 27 jca32 P N ¬ P N N P 2 mod P 1 P 1 N N P 2 mod P mod P = 1 s 1 P 1 N s mod P = 1 N P 2 mod P = s
29 1 3 11 28 syl3anc P N 1 ..^ P N P 2 mod P 1 P 1 N N P 2 mod P mod P = 1 s 1 P 1 N s mod P = 1 N P 2 mod P = s
30 oveq2 i = N P 2 mod P N i = N N P 2 mod P
31 30 oveq1d i = N P 2 mod P N i mod P = N N P 2 mod P mod P
32 31 eqeq1d i = N P 2 mod P N i mod P = 1 N N P 2 mod P mod P = 1
33 eqeq1 i = N P 2 mod P i = s N P 2 mod P = s
34 33 imbi2d i = N P 2 mod P N s mod P = 1 i = s N s mod P = 1 N P 2 mod P = s
35 34 ralbidv i = N P 2 mod P s 1 P 1 N s mod P = 1 i = s s 1 P 1 N s mod P = 1 N P 2 mod P = s
36 32 35 anbi12d i = N P 2 mod P N i mod P = 1 s 1 P 1 N s mod P = 1 i = s N N P 2 mod P mod P = 1 s 1 P 1 N s mod P = 1 N P 2 mod P = s
37 36 rspcev N P 2 mod P 1 P 1 N N P 2 mod P mod P = 1 s 1 P 1 N s mod P = 1 N P 2 mod P = s i 1 P 1 N i mod P = 1 s 1 P 1 N s mod P = 1 i = s
38 29 37 syl P N 1 ..^ P i 1 P 1 N i mod P = 1 s 1 P 1 N s mod P = 1 i = s
39 oveq2 i = s N i = N s
40 39 oveq1d i = s N i mod P = N s mod P
41 40 eqeq1d i = s N i mod P = 1 N s mod P = 1
42 41 reu8 ∃! i 1 P 1 N i mod P = 1 i 1 P 1 N i mod P = 1 s 1 P 1 N s mod P = 1 i = s
43 38 42 sylibr P N 1 ..^ P ∃! i 1 P 1 N i mod P = 1