Metamath Proof Explorer


Theorem wilthimp

Description: The forward implication of Wilson's theorem wilth (see wilthlem3 ), expressed using the modulo operation: For any prime p we have ( p - 1 ) ! == - 1 (mod p ), see theorem 5.24 in ApostolNT p. 116. (Contributed by AV, 21-Jul-2021)

Ref Expression
Assertion wilthimp ⊢ P ∈ ℙ → P − 1 ! mod P = -1 mod P

Proof

Step Hyp Ref Expression
1 wilth ⊢ P ∈ ℙ ↔ P ∈ ℤ ≥ 2 ∧ P ∥ P − 1 ! + 1
2 eluz2nn ⊢ P ∈ ℤ ≥ 2 → P ∈ ℕ
3 nnm1nn0 ⊢ P ∈ ℕ → P − 1 ∈ ℕ 0
4 2 3 syl ⊢ P ∈ ℤ ≥ 2 → P − 1 ∈ ℕ 0
5 4 faccld ⊢ P ∈ ℤ ≥ 2 → P − 1 ! ∈ ℕ
6 5 nnzd ⊢ P ∈ ℤ ≥ 2 → P − 1 ! ∈ ℤ
7 6 peano2zd ⊢ P ∈ ℤ ≥ 2 → P − 1 ! + 1 ∈ ℤ
8 dvdsval3 ⊢ P ∈ ℕ ∧ P − 1 ! + 1 ∈ ℤ → P ∥ P − 1 ! + 1 ↔ P − 1 ! + 1 mod P = 0
9 2 7 8 syl2anc ⊢ P ∈ ℤ ≥ 2 → P ∥ P − 1 ! + 1 ↔ P − 1 ! + 1 mod P = 0
10 9 biimpar ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P ∥ P − 1 ! + 1
11 5 nncnd ⊢ P ∈ ℤ ≥ 2 → P − 1 ! ∈ ℂ
12 1cnd ⊢ P ∈ ℤ ≥ 2 → 1 ∈ ℂ
13 11 12 jca ⊢ P ∈ ℤ ≥ 2 → P − 1 ! ∈ ℂ ∧ 1 ∈ ℂ
14 13 adantr ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P − 1 ! ∈ ℂ ∧ 1 ∈ ℂ
15 subneg ⊢ P − 1 ! ∈ ℂ ∧ 1 ∈ ℂ → P − 1 ! − -1 = P − 1 ! + 1
16 14 15 syl ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P − 1 ! − -1 = P − 1 ! + 1
17 10 16 breqtrrd ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P ∥ P − 1 ! − -1
18 neg1z ⊢ − 1 ∈ ℤ
19 18 a1i ⊢ P ∈ ℤ ≥ 2 → − 1 ∈ ℤ
20 2 6 19 3jca ⊢ P ∈ ℤ ≥ 2 → P ∈ ℕ ∧ P − 1 ! ∈ ℤ ∧ − 1 ∈ ℤ
21 20 adantr ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P ∈ ℕ ∧ P − 1 ! ∈ ℤ ∧ − 1 ∈ ℤ
22 moddvds ⊢ P ∈ ℕ ∧ P − 1 ! ∈ ℤ ∧ − 1 ∈ ℤ → P − 1 ! mod P = -1 mod P ↔ P ∥ P − 1 ! − -1
23 21 22 syl ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P − 1 ! mod P = -1 mod P ↔ P ∥ P − 1 ! − -1
24 17 23 mpbird ⊢ P ∈ ℤ ≥ 2 ∧ P − 1 ! + 1 mod P = 0 → P − 1 ! mod P = -1 mod P
25 24 ex ⊢ P ∈ ℤ ≥ 2 → P − 1 ! + 1 mod P = 0 → P − 1 ! mod P = -1 mod P
26 9 25 sylbid ⊢ P ∈ ℤ ≥ 2 → P ∥ P − 1 ! + 1 → P − 1 ! mod P = -1 mod P
27 26 imp ⊢ P ∈ ℤ ≥ 2 ∧ P ∥ P − 1 ! + 1 → P − 1 ! mod P = -1 mod P
28 1 27 sylbi ⊢ P ∈ ℙ → P − 1 ! mod P = -1 mod P