Metamath Proof Explorer


Theorem znunit

Description: The units of Z/nZ are the integers coprime to the base. (Contributed by Mario Carneiro, 18-Apr-2016)

Ref Expression
Hypotheses znchr.y Y = /N
znunit.u U = Unit Y
znunit.l L = ℤRHom Y
Assertion znunit N 0 A L A U A gcd N = 1

Proof

Step Hyp Ref Expression
1 znchr.y Y = /N
2 znunit.u U = Unit Y
3 znunit.l L = ℤRHom Y
4 1 zncrng N 0 Y CRing
5 4 adantr N 0 A Y CRing
6 eqid 1 Y = 1 Y
7 eqid r Y = r Y
8 2 6 7 crngunit Y CRing L A U L A r Y 1 Y
9 5 8 syl N 0 A L A U L A r Y 1 Y
10 eqid Base Y = Base Y
11 1 10 3 znzrhfo N 0 L : onto Base Y
12 11 adantr N 0 A L : onto Base Y
13 fof L : onto Base Y L : Base Y
14 12 13 syl N 0 A L : Base Y
15 ffvelrn L : Base Y A L A Base Y
16 14 15 sylancom N 0 A L A Base Y
17 eqid Y = Y
18 10 7 17 dvdsr2 L A Base Y L A r Y 1 Y x Base Y x Y L A = 1 Y
19 16 18 syl N 0 A L A r Y 1 Y x Base Y x Y L A = 1 Y
20 forn L : onto Base Y ran L = Base Y
21 12 20 syl N 0 A ran L = Base Y
22 21 rexeqdv N 0 A x ran L x Y L A = 1 Y x Base Y x Y L A = 1 Y
23 ffn L : Base Y L Fn
24 oveq1 x = L n x Y L A = L n Y L A
25 24 eqeq1d x = L n x Y L A = 1 Y L n Y L A = 1 Y
26 25 rexrn L Fn x ran L x Y L A = 1 Y n L n Y L A = 1 Y
27 14 23 26 3syl N 0 A x ran L x Y L A = 1 Y n L n Y L A = 1 Y
28 22 27 bitr3d N 0 A x Base Y x Y L A = 1 Y n L n Y L A = 1 Y
29 crngring Y CRing Y Ring
30 5 29 syl N 0 A Y Ring
31 3 zrhrhm Y Ring L ring RingHom Y
32 30 31 syl N 0 A L ring RingHom Y
33 32 adantr N 0 A n L ring RingHom Y
34 simpr N 0 A n n
35 simplr N 0 A n A
36 zringbas = Base ring
37 zringmulr × = ring
38 36 37 17 rhmmul L ring RingHom Y n A L n A = L n Y L A
39 33 34 35 38 syl3anc N 0 A n L n A = L n Y L A
40 30 adantr N 0 A n Y Ring
41 3 6 zrh1 Y Ring L 1 = 1 Y
42 40 41 syl N 0 A n L 1 = 1 Y
43 39 42 eqeq12d N 0 A n L n A = L 1 L n Y L A = 1 Y
44 simpll N 0 A n N 0
45 34 35 zmulcld N 0 A n n A
46 1zzd N 0 A n 1
47 1 3 zndvds N 0 n A 1 L n A = L 1 N n A 1
48 44 45 46 47 syl3anc N 0 A n L n A = L 1 N n A 1
49 43 48 bitr3d N 0 A n L n Y L A = 1 Y N n A 1
50 49 rexbidva N 0 A n L n Y L A = 1 Y n N n A 1
51 simplr N 0 A n N n A 1 A
52 nn0z N 0 N
53 52 ad2antrr N 0 A n N n A 1 N
54 gcddvds A N A gcd N A A gcd N N
55 51 53 54 syl2anc N 0 A n N n A 1 A gcd N A A gcd N N
56 55 simpld N 0 A n N n A 1 A gcd N A
57 51 53 gcdcld N 0 A n N n A 1 A gcd N 0
58 57 nn0zd N 0 A n N n A 1 A gcd N
59 34 adantrr N 0 A n N n A 1 n
60 dvdsmultr2 A gcd N n A A gcd N A A gcd N n A
61 58 59 51 60 syl3anc N 0 A n N n A 1 A gcd N A A gcd N n A
62 56 61 mpd N 0 A n N n A 1 A gcd N n A
63 45 adantrr N 0 A n N n A 1 n A
64 1zzd N 0 A n N n A 1 1
65 peano2zm n A n A 1
66 63 65 syl N 0 A n N n A 1 n A 1
67 55 simprd N 0 A n N n A 1 A gcd N N
68 simprr N 0 A n N n A 1 N n A 1
69 58 53 66 67 68 dvdstrd N 0 A n N n A 1 A gcd N n A 1
70 dvdssub2 A gcd N n A 1 A gcd N n A 1 A gcd N n A A gcd N 1
71 58 63 64 69 70 syl31anc N 0 A n N n A 1 A gcd N n A A gcd N 1
72 62 71 mpbid N 0 A n N n A 1 A gcd N 1
73 dvds1 A gcd N 0 A gcd N 1 A gcd N = 1
74 57 73 syl N 0 A n N n A 1 A gcd N 1 A gcd N = 1
75 72 74 mpbid N 0 A n N n A 1 A gcd N = 1
76 75 rexlimdvaa N 0 A n N n A 1 A gcd N = 1
77 simpr N 0 A A
78 52 adantr N 0 A N
79 bezout A N n m A gcd N = A n + N m
80 77 78 79 syl2anc N 0 A n m A gcd N = A n + N m
81 eqeq1 A gcd N = 1 A gcd N = A n + N m 1 = A n + N m
82 81 2rexbidv A gcd N = 1 n m A gcd N = A n + N m n m 1 = A n + N m
83 80 82 syl5ibcom N 0 A A gcd N = 1 n m 1 = A n + N m
84 52 ad3antrrr N 0 A n m N
85 dvdsmul1 N m N N m
86 84 85 sylancom N 0 A n m N N m
87 zmulcl N m N m
88 84 87 sylancom N 0 A n m N m
89 dvdsnegb N N m N N m N N m
90 84 88 89 syl2anc N 0 A n m N N m N N m
91 86 90 mpbid N 0 A n m N N m
92 35 adantr N 0 A n m A
93 92 zcnd N 0 A n m A
94 zcn n n
95 94 ad2antlr N 0 A n m n
96 93 95 mulcomd N 0 A n m A n = n A
97 96 oveq1d N 0 A n m A n + N m = n A + N m
98 95 93 mulcld N 0 A n m n A
99 88 zcnd N 0 A n m N m
100 98 99 subnegd N 0 A n m n A N m = n A + N m
101 97 100 eqtr4d N 0 A n m A n + N m = n A N m
102 101 oveq2d N 0 A n m n A A n + N m = n A n A N m
103 99 negcld N 0 A n m N m
104 98 103 nncand N 0 A n m n A n A N m = N m
105 102 104 eqtrd N 0 A n m n A A n + N m = N m
106 91 105 breqtrrd N 0 A n m N n A A n + N m
107 oveq2 1 = A n + N m n A 1 = n A A n + N m
108 107 breq2d 1 = A n + N m N n A 1 N n A A n + N m
109 106 108 syl5ibrcom N 0 A n m 1 = A n + N m N n A 1
110 109 rexlimdva N 0 A n m 1 = A n + N m N n A 1
111 110 reximdva N 0 A n m 1 = A n + N m n N n A 1
112 83 111 syld N 0 A A gcd N = 1 n N n A 1
113 76 112 impbid N 0 A n N n A 1 A gcd N = 1
114 28 50 113 3bitrd N 0 A x Base Y x Y L A = 1 Y A gcd N = 1
115 9 19 114 3bitrd N 0 A L A U A gcd N = 1