Skip to content

feat(ComputablePolynomial): add SparsePoly.ofList and injectivity of toPoly - #41340

Open
mkaratarakis wants to merge 2 commits into
leanprover-community:masterfrom
mkaratarakis:sparsepoly-2-oflist
Open

mkaratarakis wants to merge 2 commits into
leanprover-community:masterfrom
mkaratarakis:sparsepoly-2-oflist

Conversation

@mkaratarakis

@mkaratarakis mkaratarakis commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Builds a canonical SparsePoly R from an arbitrary (exponent, coefficient) list by sorting and merging (ofList), defines the sparse variable X, and proves the key toPoly_injective: the canonical-form invariant makes the semantics map injective. Also toPoly_add, toPoly_zero, toPoly_C, toPoly_X.

The proofs in this PR were done with the help of Claude code.

@github-actions

github-actions Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

PR summary 1c0bb6fbbc

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Tactic 2
Mathlib.Tactic.ComputablePolynomial.Basic (new file) 1159
Mathlib.Tactic.ComputablePolynomial.OfList (new file) 1160

Declarations diff (regex)

+ C
+ SparsePoly
+ X
+ addCore
+ addCore_degLt
+ addCore_sorted
+ coeff_toPolyCore_head
+ coeff_toPolyCore_of_degLt
+ dedupList
+ dedupList_degLt
+ dedupList_sorted
+ degLt
+ degLt_of_sorted_cons
+ instance : Add (SparsePoly R)
+ instance : Mul (SparsePoly R)
+ instance : Neg (SparsePoly R)
+ instance : One (SparsePoly R)
+ instance : Zero (SparsePoly R)
+ instance [CommRing R] [Lean.ToFormat R] : Lean.ToFormat (SparsePoly R)
+ ofList
+ ofSortedList
+ ofSortedList_of_nonzero
+ toPoly
+ toPolyCore
+ toPolyCore_addCore
+ toPolyCore_filter_nonzero
+ toPolyCore_injective_of_sorted
+ toPoly_C
+ toPoly_X
+ toPoly_add
+ toPoly_injective
+ toPoly_zero

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 1c0bb6f).

  • +52 new declarations
  • −0 removed declarations
+SparsePoly
+SparsePoly.C
+SparsePoly.X
+SparsePoly.addCore
+SparsePoly.addCore.eq_def
+SparsePoly.addCore_degLt
+SparsePoly.addCore_sorted
+SparsePoly.casesOn
+SparsePoly.coeff_toPolyCore_head
+SparsePoly.coeff_toPolyCore_of_degLt
+SparsePoly.coeffs
+SparsePoly.ctorIdx
+SparsePoly.dedupList
+SparsePoly.dedupList.eq_def
+SparsePoly.dedupList_degLt
+SparsePoly.dedupList_sorted
+SparsePoly.degLt
+SparsePoly.degLt_of_sorted_cons
+SparsePoly.ext
+SparsePoly.ext_iff
+SparsePoly.instAdd
+SparsePoly.instMul
+SparsePoly.instNeg
+SparsePoly.instOne
+SparsePoly.instToFormat
+SparsePoly.instZero
+SparsePoly.mk
+SparsePoly.mk.congr_simp
+SparsePoly.mk.inj
+SparsePoly.mk.injEq
+SparsePoly.mk.noConfusion
+SparsePoly.mk.sizeOf_spec
+SparsePoly.noConfusion
+SparsePoly.noConfusionType
+SparsePoly.nonzero
+SparsePoly.ofList
+SparsePoly.ofSortedList
+SparsePoly.ofSortedList_of_nonzero
+SparsePoly.rec
+SparsePoly.recOn
+SparsePoly.sorted
+SparsePoly.toPoly
+SparsePoly.toPolyCore
+SparsePoly.toPolyCore.eq_def
+SparsePoly.toPolyCore_addCore
+SparsePoly.toPolyCore_filter_nonzero
+SparsePoly.toPolyCore_injective_of_sorted
+SparsePoly.toPoly_C
+SparsePoly.toPoly_X
+SparsePoly.toPoly_add
+SparsePoly.toPoly_injective
+SparsePoly.toPoly_zero

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (2.00, 0.00)
Current number Change Type (weak)
5002 2 exposed public sections

Current commit 1c0bb6fbbc
Reference commit c093ecaf22

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.sh 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-meta Tactics, attributes or user commands label Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 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!

@mkaratarakis
mkaratarakis force-pushed the sparsepoly-2-oflist branch from 33e8de7 to 1c0bb6f Compare July 4, 2026 07:30
@mkaratarakis mkaratarakis changed the title feat(Tactic/ComputablePolynomial): SparsePoly.ofList and injectivity of toPoly feat(Tactic/ComputablePolynomial): add SparsePoly.ofList and injectivity of toPoly Jul 4, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jul 4, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

@mkaratarakis mkaratarakis changed the title feat(Tactic/ComputablePolynomial): add SparsePoly.ofList and injectivity of toPoly feat(ComputablePolynomial): add SparsePoly.ofList and injectivity of toPoly Aug 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant