Skip to content

feat(Data/Nat/Fib): formalize Lamé's theorem#37584

Open
kennethgoodman wants to merge 1 commit intoleanprover-community:masterfrom
kennethgoodman:lame-theorem
Open

feat(Data/Nat/Fib): formalize Lamé's theorem#37584
kennethgoodman wants to merge 1 commit intoleanprover-community:masterfrom
kennethgoodman:lame-theorem

Conversation

@kennethgoodman
Copy link
Copy Markdown

Summary

Formalize Lamé's theorem (1844), the founding result of computational complexity theory.

Lamé's Theorem: If the Euclidean algorithm on inputs (a, b) with b ≤ a takes n + 1 division steps, then b ≥ fib(n + 1) and a ≥ 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 that b + a % b ≤ a when b ≤ a and 0 < 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 since a ≥ b + a % b (because a / b ≥ 1), the Fibonacci recurrence fib(n+3) = fib(n+2) + fib(n+1) matches the structure of the algorithm.

References

  • Gabriel Lamé, Note sur la limite du nombre des divisions dans la recherche du plus grand commun diviseur entre deux nombres entiers, Comptes rendus de l'Académie des sciences, 1844.

  • builds cleanly (lake build Mathlib.Data.Nat.Fib.Lame)
  • no sorry
  • lines ≤ 100 characters, no trailing whitespace
  • autoImplicit false
  • docstrings on all public declarations

🤖 Generated with Claude Code

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>
@github-actions github-actions bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

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 awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

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.

@github-actions github-actions bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant