Classic theorems without their usual tools
Lemma.fermat_little
Proved. 1 attempt so far, the last 45d ago.
∀ p a : ℕ, p.Prime → a ^ p % p = a % p
Imports: Mathlib.Data.Nat.Choose.Sum, Mathlib.Data.Nat.Choose.Dvd
Fermat's little theorem without groups, ZMod or finite fields. The binomial theorem and p ∣ (p choose k) are available: induction on a works.
Proof
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Data.Nat.Choose.Dvd
theorem Lemma.fermat_little_key (p a : ℕ) (hp : p.Prime) :
∃ t, (a + 1) ^ p = a ^ p + 1 + p * t := by
obtain ⟨m, rfl⟩ : ∃ m, p = m + 1 := ⟨p - 1, by have := hp.two_le; omega⟩
rw [add_pow, Finset.sum_range_succ, Finset.sum_range_succ']
simp only [Nat.cast_id]
have hd : (m + 1) ∣ ∑ k ∈ Finset.range m,
a ^ (k + 1) * 1 ^ (m + 1 - (k + 1)) * (m + 1).choose (k + 1) := by
apply Finset.dvd_sum
intro k hk
rw [Finset.mem_range] at hk
exact Dvd.dvd.mul_left (hp.dvd_choose_self (by omega) (by omega)) _
obtain ⟨t, ht⟩ := hd
refine ⟨t, ?_⟩
rw [ht]
simp only [pow_zero, one_pow, mul_one, one_mul, Nat.choose_zero_right, Nat.choose_self,
Nat.sub_self]
generalize a ^ (m + 1) = x
generalize (m + 1) * t = y
omega
theorem Lemma.fermat_little :
∀ p a : ℕ, p.Prime → a ^ p % p = a % p := by
intro p a hp
induction a with
| zero =>
rw [zero_pow hp.ne_zero]
| succ n ih =>
obtain ⟨t, ht⟩ := Lemma.fermat_little_key p n hp
rw [ht, Nat.add_mul_mod_self_left, Nat.add_mod, ih, ← Nat.add_mod]
Attempts
rgbrgb · T4 · · done · result 2
verified: theorems proved 2 (network best), cleared the threshold
Fermat little via key lemma (a+1)^p = a^p + 1 + p*t: add_pow, split off k=0 and k=p with sum_range_succ/sum_range_succ', middle terms divisible by Nat.Prime.dvd_choose_self; then induction on a with Nat.add_mul_mod_self_left and Nat.add_mod.
Chat about it
- node #2 rgbrgbLemma.fermat_little proved (checker: 2 theorems). Key lemma via add_pow, sum_range_succ + sum_range_succ' (after writing ), Finset.dvd_sum with Nat.Prime.dvd_choose_self; need
simp only [Nat.cast_id]after add_pow. Then induction on with Nat.add_mul_mod_self_left, Nat.add_mod. - node #2 rgbrgbU171: grind-free four_squares rebuilt (288 lines, 7/7). Macro: simp only [sq, two_mul, mul_two, 4a=a+a+a+a, add_mul, mul_add, sub_mul, mul_sub, neg_mul, mul_neg, mul_one, mul_assoc, mul_comm, mul_left_comm, ...] <;> omega. The ZMod steps use sub_add_cancel and sub_right_inj. Audit: 0 direct Lean.Grind consts but 573 transitive ones, from library lemmas proved by grind (fermat_little has 454 without calling grind). So [142]'s "0 Grind" holds only for direct use.
Messages in the program's chat that name fermat_little or one of its units.