Metamath Proof Explorer


Theorem eulerth

Description: Euler's theorem, a generalization of Fermat's little theorem. If A and N are coprime, then A ^ phi ( N ) == 1 (mod N ). This is Metamath 100 proof #10. Also called Euler-Fermat theorem, see theorem 5.17 in ApostolNT p. 113. (Contributed by Mario Carneiro, 28-Feb-2014)

Ref Expression
Assertion eulerth N A A gcd N = 1 A ϕ N mod N = 1 mod N

Proof

Step Hyp Ref Expression
1 phicl N ϕ N
2 1 nnnn0d N ϕ N 0
3 hashfz1 ϕ N 0 1 ϕ N = ϕ N
4 2 3 syl N 1 ϕ N = ϕ N
5 dfphi2 N ϕ N = k 0 ..^ N | k gcd N = 1
6 4 5 eqtrd N 1 ϕ N = k 0 ..^ N | k gcd N = 1
7 6 3ad2ant1 N A A gcd N = 1 1 ϕ N = k 0 ..^ N | k gcd N = 1
8 fzfi 1 ϕ N Fin
9 fzofi 0 ..^ N Fin
10 ssrab2 k 0 ..^ N | k gcd N = 1 0 ..^ N
11 ssfi 0 ..^ N Fin k 0 ..^ N | k gcd N = 1 0 ..^ N k 0 ..^ N | k gcd N = 1 Fin
12 9 10 11 mp2an k 0 ..^ N | k gcd N = 1 Fin
13 hashen 1 ϕ N Fin k 0 ..^ N | k gcd N = 1 Fin 1 ϕ N = k 0 ..^ N | k gcd N = 1 1 ϕ N k 0 ..^ N | k gcd N = 1
14 8 12 13 mp2an 1 ϕ N = k 0 ..^ N | k gcd N = 1 1 ϕ N k 0 ..^ N | k gcd N = 1
15 7 14 sylib N A A gcd N = 1 1 ϕ N k 0 ..^ N | k gcd N = 1
16 bren 1 ϕ N k 0 ..^ N | k gcd N = 1 f f : 1 ϕ N 1-1 onto k 0 ..^ N | k gcd N = 1
17 15 16 sylib N A A gcd N = 1 f f : 1 ϕ N 1-1 onto k 0 ..^ N | k gcd N = 1
18 simpl N A A gcd N = 1 f : 1 ϕ N 1-1 onto k 0 ..^ N | k gcd N = 1 N A A gcd N = 1
19 oveq1 k = y k gcd N = y gcd N
20 19 eqeq1d k = y k gcd N = 1 y gcd N = 1
21 20 cbvrabv k 0 ..^ N | k gcd N = 1 = y 0 ..^ N | y gcd N = 1
22 eqid 1 ϕ N = 1 ϕ N
23 simpr N A A gcd N = 1 f : 1 ϕ N 1-1 onto k 0 ..^ N | k gcd N = 1 f : 1 ϕ N 1-1 onto k 0 ..^ N | k gcd N = 1
24 fveq2 k = x f k = f x
25 24 oveq2d k = x A f k = A f x
26 25 oveq1d k = x A f k mod N = A f x mod N
27 26 cbvmptv k 1 ϕ N A f k mod N = x 1 ϕ N A f x mod N
28 18 21 22 23 27 eulerthlem2 N A A gcd N = 1 f : 1 ϕ N 1-1 onto k 0 ..^ N | k gcd N = 1 A ϕ N mod N = 1 mod N
29 17 28 exlimddv N A A gcd N = 1 A ϕ N mod N = 1 mod N