feat(Data/Nat/Fib): formalize Lamé's theorem#37584
feat(Data/Nat/Fib): formalize Lamé's theorem#37584kennethgoodman wants to merge 1 commit intoleanprover-community:masterfrom
Conversation
Lamé's theorem (1844) bounds the number of division steps in the Euclidean algorithm using the Fibonacci sequence: if the algorithm takes n+1 steps on (a, b) with b ≤ a, then b ≥ fib(n+1) and a ≥ fib(n+2). This is the founding result of computational complexity theory. ## New definitions - `Nat.euclidSteps`: counts division steps in the Euclidean algorithm on natural numbers. ## New theorems - `Nat.fib_le_of_euclidSteps`: Fibonacci lower bound on inputs given a step count. - `Nat.euclidSteps_le_of_lt_fib`: step count upper bound given a Fibonacci bound on the smaller input. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
Summary
Formalize Lamé's theorem (1844), the founding result of computational complexity theory.
Lamé's Theorem: If the Euclidean algorithm on inputs
(a, b)withb ≤ atakesn + 1division steps, thenb ≥ fib(n + 1)anda ≥ fib(n + 2).New definitions
Nat.euclidSteps: counts the number of division steps in the Euclidean algorithm on natural number inputs.New theorems
Nat.fib_le_of_euclidSteps: the main Lamé bound — Fibonacci lower bound on inputs given a step count.Nat.euclidSteps_le_of_lt_fib: the contrapositive — step count upper bound given a Fibonacci bound on the smaller input.Nat.add_mod_le: helper lemma thatb + a % b ≤ awhenb ≤ aand0 < b.Proof strategy
Induction on
n, tracking both elements of the pair. The key insight is that each Euclidean step replaces(a, b)with(b, a % b), and sincea ≥ b + a % b(becausea / b ≥ 1), the Fibonacci recurrencefib(n+3) = fib(n+2) + fib(n+1)matches the structure of the algorithm.References
lake build Mathlib.Data.Nat.Fib.Lame)sorryautoImplicit false🤖 Generated with Claude Code