Repository navigation
Fermat's little theorem and the freshman's dream, for every prime - #1502
Merged
Merged
Conversation
Under a quantifier that establishes p prime, p divides d where writing each power (u + v)^p in d as u^p + v^p leaves nothing: what the binomial theorem adds are multiples of binomial(p, k) with 0 < k < p, and the rule asks the quantifiers for that first (add_pow_char, resting on Nat.Prime.dvd_choose_self). A congruence reads the same rule. A congruence modulo a symbol, or an equation of residues, over a row of whole numbers holds where it holds at one member and the difference of its sides changes by a multiple of the modulus from each member to the next (Int.inductionOn'). For a^p = a (mod p) that change is (a + 1)^p - a^p - 1, which the binomial theorem reads. Sullivan and Mackey's Prob 8.9.25 and 8.9.26. Part of #1409. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1409.
This decides Sullivan and Mackey's Prob 8.9.25 and 8.9.26 for every prime, derived from #1500's
p divides binomial(p, k)as the book derives them:forall p in PP : forall a, b in ZZ : (a + b)^p = a^p + b^p (mod p)Trueforall p in PP : forall a in ZZ : a^p = a (mod p)Trueforall p in PP : forall a in ZZ : a^p mod p = a mod pTrueThe freshman's dream
With
pprime in scope,p divides dholds where replacing each power(u + v)^pindbyu^p + v^pleaves nothing, or only multiples ofp. The binomial theorem addsbinomial(p, k) u^k v^(p - k)for0 < k < p, and #1500's rule sayspdivides each of those.The rule asks the quantifiers
forall k in ZZ : (0 < k and k < p) implies p divides binomial(p, k)before it answers, and records that as the step it rests on. It requires three things:dis a polynomial with whole coefficients, in quantities that are whole by the facts in scope;dis ap-th power of such a polynomial, so the congruence carries through products;u^p - v^p, since(-v)^pis-v^pmodulo every prime, 2 included.Congruentfreads the same rule.Fermat's little theorem
This is a new route for
forall x in S : f = g (mod m), orf mod m = g mod m, overZZ,ZZ*orZZ+, wheremis a symbol that doesn't mentionx. WriteDforf - g.mdividesDat every member, the statement holds.mdividesD(x + 1) - D(x)at every member. ThenDhas one residue modulomall along the row, up from that member and down from it, so the statement holds at every member.For Fermat, the step is
(a + 1)^p - (a + 1) - (a^p - a), which the freshman's dream reads. The base is at 1, since0^pis only0 provided p > 0.Proof recording
The lemmas are
add_pow_char(Mathlib/Algebra/CharP/Lemmas.lean),Int.inductionOn'andInt.modEq_iff_dvd : a ≡ b [ZMOD n] ↔ n ∣ b - a.What else changes
A body is now renamed and decided with the facts in scope wherever it contains a divisibility, a congruence or an equation of residues by a modulus that isn't a number. In #1500 that happened only for
p divides binomial(p, k). Statements with a numeric modulus are untouched.Each of these fails as it should: over
ZZ+instead of the primes, witha + 1on the right, or with+ 1added to the dream.(a + b)^p = a^p + b^p (mod p)on its own stays unevaluated after the quantified statement is decided.Measured
Both were measured on this tree before the rebase onto #1500's merge, and the tree is unchanged by it.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura