Metamath Proof Explorer


Theorem znfermltl

Description: Fermat's little theorem in Z/nZ . (Contributed by Thierry Arnoux, 24-Jul-2024)

Ref Expression
Hypotheses znfermltl.z Z = /P
znfermltl.b B = Base Z
znfermltl.p × ˙ = mulGrp Z
Assertion znfermltl P A B P × ˙ A = A

Proof

Step Hyp Ref Expression
1 znfermltl.z Z = /P
2 znfermltl.b B = Base Z
3 znfermltl.p × ˙ = mulGrp Z
4 prmnn P P
5 4 nnnn0d P P 0
6 5 ad3antrrr P A B a A = ℤRHom Z a P 0
7 simplr P A B a A = ℤRHom Z a a
8 eqid mulGrp fld 𝑠 = mulGrp fld 𝑠
9 zsscn
10 eqid mulGrp fld = mulGrp fld
11 cnfldbas = Base fld
12 10 11 mgpbas = Base mulGrp fld
13 9 12 sseqtri Base mulGrp fld
14 eqid mulGrp fld = mulGrp fld
15 eqid inv g mulGrp fld = inv g mulGrp fld
16 cnring fld Ring
17 10 ringmgp fld Ring mulGrp fld Mnd
18 16 17 ax-mp mulGrp fld Mnd
19 cnfld1 1 = 1 fld
20 10 19 ringidval 1 = 0 mulGrp fld
21 1z 1
22 20 21 eqeltrri 0 mulGrp fld
23 eqid 0 mulGrp fld = 0 mulGrp fld
24 8 12 23 ress0g mulGrp fld Mnd 0 mulGrp fld 0 mulGrp fld = 0 mulGrp fld 𝑠
25 18 22 9 24 mp3an 0 mulGrp fld = 0 mulGrp fld 𝑠
26 8 13 14 15 25 ressmulgnn0 P 0 a P mulGrp fld 𝑠 a = P mulGrp fld a
27 6 7 26 syl2anc P A B a A = ℤRHom Z a P mulGrp fld 𝑠 a = P mulGrp fld a
28 7 zcnd P A B a A = ℤRHom Z a a
29 cnfldexp a P 0 P mulGrp fld a = a P
30 28 6 29 syl2anc P A B a A = ℤRHom Z a P mulGrp fld a = a P
31 27 30 eqtrd P A B a A = ℤRHom Z a P mulGrp fld 𝑠 a = a P
32 31 fveq2d P A B a A = ℤRHom Z a ℤRHom Z P mulGrp fld 𝑠 a = ℤRHom Z a P
33 nnnn0 P P 0
34 1 zncrng P 0 Z CRing
35 34 crngringd P 0 Z Ring
36 eqid ℤRHom Z = ℤRHom Z
37 36 zrhrhm Z Ring ℤRHom Z ring RingHom Z
38 35 37 syl P 0 ℤRHom Z ring RingHom Z
39 zringmpg mulGrp fld 𝑠 = mulGrp ring
40 eqid mulGrp Z = mulGrp Z
41 39 40 rhmmhm ℤRHom Z ring RingHom Z ℤRHom Z mulGrp fld 𝑠 MndHom mulGrp Z
42 4 33 38 41 4syl P ℤRHom Z mulGrp fld 𝑠 MndHom mulGrp Z
43 42 ad3antrrr P A B a A = ℤRHom Z a ℤRHom Z mulGrp fld 𝑠 MndHom mulGrp Z
44 8 12 ressbas2 = Base mulGrp fld 𝑠
45 9 44 ax-mp = Base mulGrp fld 𝑠
46 eqid mulGrp fld 𝑠 = mulGrp fld 𝑠
47 45 46 3 mhmmulg ℤRHom Z mulGrp fld 𝑠 MndHom mulGrp Z P 0 a ℤRHom Z P mulGrp fld 𝑠 a = P × ˙ ℤRHom Z a
48 43 6 7 47 syl3anc P A B a A = ℤRHom Z a ℤRHom Z P mulGrp fld 𝑠 a = P × ˙ ℤRHom Z a
49 simpr P a a
50 4 adantr P a P
51 50 nnnn0d P a P 0
52 zexpcl a P 0 a P
53 49 51 52 syl2anc P a a P
54 eqid - ring = - ring
55 54 zringsubgval a P a a P a = a P - ring a
56 53 49 55 syl2anc P a a P a = a P - ring a
57 56 fveq2d P a ℤRHom Z a P a = ℤRHom Z a P - ring a
58 53 zred P a a P
59 zre a a
60 59 adantl P a a
61 50 nnrpd P a P +
62 fermltl P a a P mod P = a mod P
63 eqidd P a a mod P = a mod P
64 58 60 60 60 61 62 63 modsub12d P a a P a mod P = a a mod P
65 zcn a a
66 65 subidd a a a = 0
67 66 adantl P a a a = 0
68 67 oveq1d P a a a mod P = 0 mod P
69 0mod P + 0 mod P = 0
70 61 69 syl P a 0 mod P = 0
71 64 68 70 3eqtrd P a a P a mod P = 0
72 53 49 zsubcld P a a P a
73 dvdsval3 P a P a P a P a a P a mod P = 0
74 50 72 73 syl2anc P a P a P a a P a mod P = 0
75 71 74 mpbird P a P a P a
76 eqid 0 Z = 0 Z
77 1 36 76 zndvds0 P 0 a P a ℤRHom Z a P a = 0 Z P a P a
78 51 72 77 syl2anc P a ℤRHom Z a P a = 0 Z P a P a
79 75 78 mpbird P a ℤRHom Z a P a = 0 Z
80 rhmghm ℤRHom Z ring RingHom Z ℤRHom Z ring GrpHom Z
81 51 38 80 3syl P a ℤRHom Z ring GrpHom Z
82 zringbas = Base ring
83 eqid - Z = - Z
84 82 54 83 ghmsub ℤRHom Z ring GrpHom Z a P a ℤRHom Z a P - ring a = ℤRHom Z a P - Z ℤRHom Z a
85 81 53 49 84 syl3anc P a ℤRHom Z a P - ring a = ℤRHom Z a P - Z ℤRHom Z a
86 57 79 85 3eqtr3rd P a ℤRHom Z a P - Z ℤRHom Z a = 0 Z
87 4 33 35 3syl P Z Ring
88 87 ringgrpd P Z Grp
89 88 adantr P a Z Grp
90 eqid Base Z = Base Z
91 82 90 rhmf ℤRHom Z ring RingHom Z ℤRHom Z : Base Z
92 51 38 91 3syl P a ℤRHom Z : Base Z
93 92 53 ffvelrnd P a ℤRHom Z a P Base Z
94 92 49 ffvelrnd P a ℤRHom Z a Base Z
95 90 76 83 grpsubeq0 Z Grp ℤRHom Z a P Base Z ℤRHom Z a Base Z ℤRHom Z a P - Z ℤRHom Z a = 0 Z ℤRHom Z a P = ℤRHom Z a
96 89 93 94 95 syl3anc P a ℤRHom Z a P - Z ℤRHom Z a = 0 Z ℤRHom Z a P = ℤRHom Z a
97 86 96 mpbid P a ℤRHom Z a P = ℤRHom Z a
98 97 ad4ant13 P A B a A = ℤRHom Z a ℤRHom Z a P = ℤRHom Z a
99 32 48 98 3eqtr3d P A B a A = ℤRHom Z a P × ˙ ℤRHom Z a = ℤRHom Z a
100 oveq2 A = ℤRHom Z a P × ˙ A = P × ˙ ℤRHom Z a
101 100 adantl P A B a A = ℤRHom Z a P × ˙ A = P × ˙ ℤRHom Z a
102 simpr P A B a A = ℤRHom Z a A = ℤRHom Z a
103 99 101 102 3eqtr4d P A B a A = ℤRHom Z a P × ˙ A = A
104 1 2 36 znzrhfo P 0 ℤRHom Z : onto B
105 4 33 104 3syl P ℤRHom Z : onto B
106 foelrn ℤRHom Z : onto B A B a A = ℤRHom Z a
107 105 106 sylan P A B a A = ℤRHom Z a
108 103 107 r19.29a P A B P × ˙ A = A