Metamath Proof Explorer


Theorem fermltl

Description: Fermat's little theorem. When P is prime, A ^ P == A (mod P ) for any A , see theorem 5.19 in ApostolNT p. 114. (Contributed by Mario Carneiro, 28-Feb-2014) (Proof shortened by AV, 19-Mar-2022)

Ref Expression
Assertion fermltl P A A P mod P = A mod P

Proof

Step Hyp Ref Expression
1 prmnn P P
2 dvdsmodexp P P P A A P mod P = A mod P
3 2 3exp P P P A A P mod P = A mod P
4 1 1 3 sylc P P A A P mod P = A mod P
5 4 adantr P A P A A P mod P = A mod P
6 coprm P A ¬ P A P gcd A = 1
7 prmz P P
8 gcdcom P A P gcd A = A gcd P
9 7 8 sylan P A P gcd A = A gcd P
10 9 eqeq1d P A P gcd A = 1 A gcd P = 1
11 6 10 bitrd P A ¬ P A A gcd P = 1
12 simp2 P A A gcd P = 1 A
13 1 3ad2ant1 P A A gcd P = 1 P
14 13 phicld P A A gcd P = 1 ϕ P
15 14 nnnn0d P A A gcd P = 1 ϕ P 0
16 zexpcl A ϕ P 0 A ϕ P
17 12 15 16 syl2anc P A A gcd P = 1 A ϕ P
18 17 zred P A A gcd P = 1 A ϕ P
19 1red P A A gcd P = 1 1
20 13 nnrpd P A A gcd P = 1 P +
21 eulerth P A A gcd P = 1 A ϕ P mod P = 1 mod P
22 1 21 syl3an1 P A A gcd P = 1 A ϕ P mod P = 1 mod P
23 modmul1 A ϕ P 1 A P + A ϕ P mod P = 1 mod P A ϕ P A mod P = 1 A mod P
24 18 19 12 20 22 23 syl221anc P A A gcd P = 1 A ϕ P A mod P = 1 A mod P
25 phiprm P ϕ P = P 1
26 25 3ad2ant1 P A A gcd P = 1 ϕ P = P 1
27 26 oveq2d P A A gcd P = 1 A ϕ P = A P 1
28 27 oveq1d P A A gcd P = 1 A ϕ P A = A P 1 A
29 12 zcnd P A A gcd P = 1 A
30 expm1t A P A P = A P 1 A
31 29 13 30 syl2anc P A A gcd P = 1 A P = A P 1 A
32 28 31 eqtr4d P A A gcd P = 1 A ϕ P A = A P
33 32 oveq1d P A A gcd P = 1 A ϕ P A mod P = A P mod P
34 29 mulid2d P A A gcd P = 1 1 A = A
35 34 oveq1d P A A gcd P = 1 1 A mod P = A mod P
36 24 33 35 3eqtr3d P A A gcd P = 1 A P mod P = A mod P
37 36 3expia P A A gcd P = 1 A P mod P = A mod P
38 11 37 sylbid P A ¬ P A A P mod P = A mod P
39 5 38 pm2.61d P A A P mod P = A mod P