Skip to content

[Merged by Bors] - feat(Algebra/Polynomial/Sturm): sturm sequences - #43954

Closed
tomaz1502 wants to merge 7 commits into
leanprover-community:masterfrom
tomaz1502:sturmSeq
Closed

tomaz1502 wants to merge 7 commits into
leanprover-community:masterfrom
tomaz1502:sturmSeq

Conversation

@tomaz1502

@tomaz1502 tomaz1502 commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

This PR defines Polynomial.sturmSeq p q, the Sturm sequence (signed remainder sequence) of two
polynomials over a field: the list [p, q, -(p % q), …] of successive negated remainders, ending at
the last nonzero one. It also proves its basic API:

  • sturmSeq_cons, sturmSeq_zero, sturmSeq_zero_right, sturmSeq_eq_nil_iff: unfolding and
    degenerate cases;
  • mem_sturmSeq_self, head?_sturmSeq, zero_notMem_sturmSeq: membership facts;
  • dvd_of_mem_sturmSeq: every common divisor of p and q divides every entry;
  • sturmSeq_mul_left: sturmSeq (r * p) (r * q) = (sturmSeq p q).map (r * ·) for r ≠ 0.

It also adds Polynomial.neg_mod and Polynomial.mul_mod_mul_left to FieldDivision.lean, used
in the proof of sturmSeq_mul_left.

This is the second PR of a series formalizing the Sturm–Tarski theorem, following #43783
(List.signVariations). The development is a port of Wenda Li's Isabelle/AFP entry. The remaining
parts (local sign of a polynomial to the right of a point, the Cauchy index, and the theorem
itself) will follow in separate PRs. See also #43512.

The definition and the original proofs were written by hand. Claude Code (Fable 5.1) was used to
simplify part of the proofs and to review the code.

Co-authored-by: Pedro Saccomani [email protected]
Co-authored-by: Sarah Azevedo Pereira [email protected]

@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 Sep 18, 2026
@github-actions

Copy link
Copy Markdown

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 Zulip and join the Lean community.
Thank you again for joining our community.

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

PR summary b263a5953a

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Algebra.Polynomial.Sturm.Sequence (new file) 1457

Declarations diff (regex)

+ dvd_of_mem_sturmSeq
+ head?_sturmSeq
+ mem_sturmSeq_self
+ mul_mod_mul_left
+ ne_zero_of_mem_sturmSeq
+ neg_mod
+ sturmSeq
+ sturmSeq_cons
+ sturmSeq_eq_nil_iff
+ sturmSeq_mul_left
+ sturmSeq_zero_left
+ sturmSeq_zero_right
+ zero_notMem_sturmSeq

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit b263a59).

  • +15 new declarations
  • −0 removed declarations
+Polynomial.dvd_of_mem_sturmSeq
+Polynomial.head?_sturmSeq
+Polynomial.mem_sturmSeq_self
+Polynomial.mul_mod_mul_left
+Polynomial.ne_zero_of_mem_sturmSeq
+Polynomial.neg_mod
+Polynomial.sturmSeq
+Polynomial.sturmSeq.eq_def
+Polynomial.sturmSeq.induct
+Polynomial.sturmSeq_cons
+Polynomial.sturmSeq_eq_nil_iff
+Polynomial.sturmSeq_mul_left
+Polynomial.sturmSeq_zero_left
+Polynomial.sturmSeq_zero_right
+Polynomial.zero_notMem_sturmSeq

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type (weak)
exposed public sections 5077 1

Current commit b263a5953a
Reference commit 94ef6b8954

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

✅ PR Title Formatted Correctly

The title of this PR has been updated to match our commit style conventions.
Thank you!

@tomaz1502 tomaz1502 changed the title feat(Algebra/Polynomial/Sturm): Sturm sequences feat(Algebra/Polynomial/Sturm): sturm sequences Sep 18, 2026

@kim-em kim-em left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Claude says: Thanks, this is a clean and well-documented PR. A few small suggestions inline; all proposed code has been compiled against this branch.

@SnirBroshi SnirBroshi Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you anticipating creating more files in this new directory in further PRs, or could this just be Polynomial/Sturm.lean or Polynomial/SturmSequence.lean?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the first of a sequence of PRs to add the Sturm-Tarski theorem. My plan is to add the other relevant concepts for the proof in this folder.

@kim-em

kim-em commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

bors merge

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Sep 22, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 22, 2026
This PR defines `Polynomial.sturmSeq p q`, the Sturm sequence (signed remainder sequence) of two
polynomials over a field: the list `[p, q, -(p % q), …]` of successive negated remainders, ending at
the last nonzero one. It also proves its basic API:

* `sturmSeq_cons`, `sturmSeq_zero`, `sturmSeq_zero_right`, `sturmSeq_eq_nil_iff`: unfolding and
  degenerate cases;
* `mem_sturmSeq_self`, `head?_sturmSeq`, `zero_notMem_sturmSeq`: membership facts;
* `dvd_of_mem_sturmSeq`: every common divisor of `p` and `q` divides every entry;
* `sturmSeq_mul_left`: `sturmSeq (r * p) (r * q) = (sturmSeq p q).map (r * ·)` for `r ≠ 0`.

It also adds `Polynomial.neg_mod` and `Polynomial.mul_mod_mul_left` to `FieldDivision.lean`, used
in the proof of `sturmSeq_mul_left`.

This is the second PR of a series formalizing the Sturm–Tarski theorem, following #43783 
(`List.signVariations`). The development is a port of Wenda Li's Isabelle/AFP entry. The remaining
parts (local sign of a polynomial to the right of a point, the Cauchy index, and the theorem
itself) will follow in separate PRs. See also #43512.

The definition and the original proofs were written by hand. Claude Code (Fable 5.1) was used to
simplify part of the proofs and to review the code.

Co-authored-by: Pedro Saccomani <[email protected]>
Co-authored-by: Sarah Azevedo Pereira <[email protected]>
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Sep 22, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat(Algebra/Polynomial/Sturm): sturm sequences [Merged by Bors] - feat(Algebra/Polynomial/Sturm): sturm sequences Sep 22, 2026
@mathlib-bors mathlib-bors Bot closed this Sep 22, 2026
grunweg pushed a commit to grunweg/mathlib4 that referenced this pull request Sep 22, 2026
…#43954)

This PR defines `Polynomial.sturmSeq p q`, the Sturm sequence (signed remainder sequence) of two
polynomials over a field: the list `[p, q, -(p % q), …]` of successive negated remainders, ending at
the last nonzero one. It also proves its basic API:

* `sturmSeq_cons`, `sturmSeq_zero`, `sturmSeq_zero_right`, `sturmSeq_eq_nil_iff`: unfolding and
  degenerate cases;
* `mem_sturmSeq_self`, `head?_sturmSeq`, `zero_notMem_sturmSeq`: membership facts;
* `dvd_of_mem_sturmSeq`: every common divisor of `p` and `q` divides every entry;
* `sturmSeq_mul_left`: `sturmSeq (r * p) (r * q) = (sturmSeq p q).map (r * ·)` for `r ≠ 0`.

It also adds `Polynomial.neg_mod` and `Polynomial.mul_mod_mul_left` to `FieldDivision.lean`, used
in the proof of `sturmSeq_mul_left`.

This is the second PR of a series formalizing the Sturm–Tarski theorem, following leanprover-community#43783 
(`List.signVariations`). The development is a port of Wenda Li's Isabelle/AFP entry. The remaining
parts (local sign of a polynomial to the right of a point, the Cauchy index, and the theorem
itself) will follow in separate PRs. See also leanprover-community#43512.

The definition and the original proofs were written by hand. Claude Code (Fable 5.1) was used to
simplify part of the proofs and to review the code.

Co-authored-by: Pedro Saccomani <[email protected]>
Co-authored-by: Sarah Azevedo Pereira <[email protected]>
mathlib-bors Bot pushed a commit that referenced this pull request Oct 15, 2026
…e right of a point (#44248)

This PR defines `Polynomial.signRight x p : SignType`, the sign that a real polynomial `p` takes
on a sufficiently small interval `(x, x + ε)`, as the limit of `sign (p.eval y)` as `y → x` from the right, and
develops its basic API:

* `eventually_sign_eq_signRight`, `signRight_eq_iff`: the defining property and its uniqueness;
* `signRight_eq_zero_iff`: `signRight x p = 0` iff `p = 0`;
* `signRight_mul`, `signRight_neg`, `signRight_C`: `signRight x` is multiplicative, commutes with
  negation and agrees with `SignType.sign` on constants;
* `signRight_of_eval_ne_zero`, `signRight_of_eval_eq_zero`: the computation rule
  `signRight x p = sign (p.eval x)` if `p.eval x ≠ 0`, and `signRight x p = signRight x (derivative p)`
  otherwise (via the mean value theorem).

This is the local invariant behind Sturm's theorem: it determines the direction in which the sign
of a Sturm sequence changes across a root, and it will be used to define the Cauchy index in the
next PR of the series.

This is the third PR of a series formalising the Sturm–Tarski theorem, following #43783
(`List.signVariations`) and #43954 (`Polynomial.sturmSeq`). Everything is stated over `ℝ`; the
statements hold over any real closed field, and the implementation notes record what is needed to
generalise them.

Co-authored-by: Pedro Saccomani <[email protected]>
Co-authored-by: Sarah Pereira <[email protected]>
Co-authored-by: Kim Morrison <[email protected]>
Co-authored-by: Oliver Nash <[email protected]>
Co-authored-by: Oliver Nash <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants