Metamath Proof Explorer


Theorem znrrg

Description: The regular elements of Z/nZ are exactly the units. (This theorem fails for N = 0 , where all nonzero integers are regular, but only +- 1 are units.) (Contributed by Mario Carneiro, 18-Apr-2016)

Ref Expression
Hypotheses znchr.y Y = /N
znunit.u U = Unit Y
znrrg.e E = RLReg Y
Assertion znrrg N E = U

Proof

Step Hyp Ref Expression
1 znchr.y Y = /N
2 znunit.u U = Unit Y
3 znrrg.e E = RLReg Y
4 nnnn0 N N 0
5 eqid Base Y = Base Y
6 eqid ℤRHom Y = ℤRHom Y
7 1 5 6 znzrhfo N 0 ℤRHom Y : onto Base Y
8 4 7 syl N ℤRHom Y : onto Base Y
9 3 5 rrgss E Base Y
10 9 sseli x E x Base Y
11 foelrn ℤRHom Y : onto Base Y x Base Y n x = ℤRHom Y n
12 8 10 11 syl2an N x E n x = ℤRHom Y n
13 12 ex N x E n x = ℤRHom Y n
14 nncn N N
15 14 ad2antrr N n ℤRHom Y n E N
16 simplr N n ℤRHom Y n E n
17 nnz N N
18 17 ad2antrr N n ℤRHom Y n E N
19 nnne0 N N 0
20 19 ad2antrr N n ℤRHom Y n E N 0
21 simpr n = 0 N = 0 N = 0
22 21 necon3ai N 0 ¬ n = 0 N = 0
23 20 22 syl N n ℤRHom Y n E ¬ n = 0 N = 0
24 gcdn0cl n N ¬ n = 0 N = 0 n gcd N
25 16 18 23 24 syl21anc N n ℤRHom Y n E n gcd N
26 25 nncnd N n ℤRHom Y n E n gcd N
27 25 nnne0d N n ℤRHom Y n E n gcd N 0
28 15 26 27 divcan2d N n ℤRHom Y n E n gcd N N n gcd N = N
29 gcddvds n N n gcd N n n gcd N N
30 16 18 29 syl2anc N n ℤRHom Y n E n gcd N n n gcd N N
31 30 simpld N n ℤRHom Y n E n gcd N n
32 25 nnzd N n ℤRHom Y n E n gcd N
33 30 simprd N n ℤRHom Y n E n gcd N N
34 simpll N n ℤRHom Y n E N
35 nndivdvds N n gcd N n gcd N N N n gcd N
36 34 25 35 syl2anc N n ℤRHom Y n E n gcd N N N n gcd N
37 33 36 mpbid N n ℤRHom Y n E N n gcd N
38 37 nnzd N n ℤRHom Y n E N n gcd N
39 dvdsmulc n gcd N n N n gcd N n gcd N n n gcd N N n gcd N n N n gcd N
40 32 16 38 39 syl3anc N n ℤRHom Y n E n gcd N n n gcd N N n gcd N n N n gcd N
41 31 40 mpd N n ℤRHom Y n E n gcd N N n gcd N n N n gcd N
42 28 41 eqbrtrrd N n ℤRHom Y n E N n N n gcd N
43 simpr N n ℤRHom Y n E ℤRHom Y n E
44 4 ad2antrr N n ℤRHom Y n E N 0
45 44 7 syl N n ℤRHom Y n E ℤRHom Y : onto Base Y
46 fof ℤRHom Y : onto Base Y ℤRHom Y : Base Y
47 45 46 syl N n ℤRHom Y n E ℤRHom Y : Base Y
48 47 38 ffvelrnd N n ℤRHom Y n E ℤRHom Y N n gcd N Base Y
49 eqid Y = Y
50 eqid 0 Y = 0 Y
51 3 5 49 50 rrgeq0i ℤRHom Y n E ℤRHom Y N n gcd N Base Y ℤRHom Y n Y ℤRHom Y N n gcd N = 0 Y ℤRHom Y N n gcd N = 0 Y
52 43 48 51 syl2anc N n ℤRHom Y n E ℤRHom Y n Y ℤRHom Y N n gcd N = 0 Y ℤRHom Y N n gcd N = 0 Y
53 1 zncrng N 0 Y CRing
54 4 53 syl N Y CRing
55 crngring Y CRing Y Ring
56 54 55 syl N Y Ring
57 56 ad2antrr N n ℤRHom Y n E Y Ring
58 6 zrhrhm Y Ring ℤRHom Y ring RingHom Y
59 57 58 syl N n ℤRHom Y n E ℤRHom Y ring RingHom Y
60 zringbas = Base ring
61 zringmulr × = ring
62 60 61 49 rhmmul ℤRHom Y ring RingHom Y n N n gcd N ℤRHom Y n N n gcd N = ℤRHom Y n Y ℤRHom Y N n gcd N
63 59 16 38 62 syl3anc N n ℤRHom Y n E ℤRHom Y n N n gcd N = ℤRHom Y n Y ℤRHom Y N n gcd N
64 63 eqeq1d N n ℤRHom Y n E ℤRHom Y n N n gcd N = 0 Y ℤRHom Y n Y ℤRHom Y N n gcd N = 0 Y
65 16 38 zmulcld N n ℤRHom Y n E n N n gcd N
66 1 6 50 zndvds0 N 0 n N n gcd N ℤRHom Y n N n gcd N = 0 Y N n N n gcd N
67 44 65 66 syl2anc N n ℤRHom Y n E ℤRHom Y n N n gcd N = 0 Y N n N n gcd N
68 64 67 bitr3d N n ℤRHom Y n E ℤRHom Y n Y ℤRHom Y N n gcd N = 0 Y N n N n gcd N
69 1 6 50 zndvds0 N 0 N n gcd N ℤRHom Y N n gcd N = 0 Y N N n gcd N
70 44 38 69 syl2anc N n ℤRHom Y n E ℤRHom Y N n gcd N = 0 Y N N n gcd N
71 52 68 70 3imtr3d N n ℤRHom Y n E N n N n gcd N N N n gcd N
72 42 71 mpd N n ℤRHom Y n E N N n gcd N
73 15 26 27 divcan1d N n ℤRHom Y n E N n gcd N n gcd N = N
74 37 nncnd N n ℤRHom Y n E N n gcd N
75 74 mulid1d N n ℤRHom Y n E N n gcd N 1 = N n gcd N
76 72 73 75 3brtr4d N n ℤRHom Y n E N n gcd N n gcd N N n gcd N 1
77 1zzd N n ℤRHom Y n E 1
78 37 nnne0d N n ℤRHom Y n E N n gcd N 0
79 dvdscmulr n gcd N 1 N n gcd N N n gcd N 0 N n gcd N n gcd N N n gcd N 1 n gcd N 1
80 32 77 38 78 79 syl112anc N n ℤRHom Y n E N n gcd N n gcd N N n gcd N 1 n gcd N 1
81 76 80 mpbid N n ℤRHom Y n E n gcd N 1
82 16 18 gcdcld N n ℤRHom Y n E n gcd N 0
83 dvds1 n gcd N 0 n gcd N 1 n gcd N = 1
84 82 83 syl N n ℤRHom Y n E n gcd N 1 n gcd N = 1
85 81 84 mpbid N n ℤRHom Y n E n gcd N = 1
86 1 2 6 znunit N 0 n ℤRHom Y n U n gcd N = 1
87 44 16 86 syl2anc N n ℤRHom Y n E ℤRHom Y n U n gcd N = 1
88 85 87 mpbird N n ℤRHom Y n E ℤRHom Y n U
89 88 ex N n ℤRHom Y n E ℤRHom Y n U
90 eleq1 x = ℤRHom Y n x E ℤRHom Y n E
91 eleq1 x = ℤRHom Y n x U ℤRHom Y n U
92 90 91 imbi12d x = ℤRHom Y n x E x U ℤRHom Y n E ℤRHom Y n U
93 89 92 syl5ibrcom N n x = ℤRHom Y n x E x U
94 93 rexlimdva N n x = ℤRHom Y n x E x U
95 94 com23 N x E n x = ℤRHom Y n x U
96 13 95 mpdd N x E x U
97 96 ssrdv N E U
98 3 2 unitrrg Y Ring U E
99 56 98 syl N U E
100 97 99 eqssd N E = U