Skip to content

feat(ComputablePolynomial): division with remainder and SparsePoly ≃ₐ Polynomial - #41344

Open
mkaratarakis wants to merge 6 commits into
leanprover-community:masterfrom
mkaratarakis:sparsepoly-6-divrem
Open

mkaratarakis wants to merge 6 commits into
leanprover-community:masterfrom
mkaratarakis:sparsepoly-6-divrem

Conversation

@mkaratarakis

@mkaratarakis mkaratarakis commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

divRem (long division by leading-term cancellation, with degree_sub_leading_term_lt justifying termination), its specification divRem_spec (a = b * q + r), and toPolyEquiv : SparsePoly R ≃ₐ[R] Polynomial R packaging the semantics as an R-algebra equivalence. The proofs in this PR were done with the help of Claude code.

@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 summary 41c211f3ce

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Tactic 6
Mathlib.Tactic.ComputablePolynomial.Basic (new file) 1159
Mathlib.Tactic.ComputablePolynomial.OfList (new file) 1160
Mathlib.Tactic.ComputablePolynomial.Ring (new file) 1161
Mathlib.Tactic.ComputablePolynomial.Degree (new file) 1162
Mathlib.Tactic.ComputablePolynomial.Content (new file) 1165
Mathlib.Tactic.ComputablePolynomial.DivRem (new file) 1166

Declarations diff (regex)

+ C
+ CHom
+ IsExactDiv
+ SparsePoly
+ X
+ addCore
+ addCore_degLt
+ addCore_sorted
+ coeff
+ coeffCore
+ coeffCore_eq_toPolyCore_coeff
+ coeff_smul
+ coeff_toPoly
+ coeff_toPolyCore_eq_zero_of_forall_lt
+ coeff_toPolyCore_head
+ coeff_toPolyCore_of_degLt
+ content
+ content_dvd_coeff_final
+ dedupList
+ dedupList_degLt
+ dedupList_sorted
+ degLt
+ degLt_of_sorted_cons
+ deg_pseudo_rem_a
+ deg_pseudo_rem_b
+ degree
+ degree_eq_head
+ degree_eq_natDegree_toPoly
+ degree_eq_poly_degree
+ degree_mul
+ degree_sub_leading_term_lt
+ divRem
+ divRem_eq
+ divRem_spec
+ foldl_gcd_dvd_acc
+ foldl_gcd_dvd_mem
+ gcd
+ gcdPrim
+ instance : Add (SparsePoly R)
+ instance : Algebra R (SparsePoly R)
+ instance : CommRing (SparsePoly R)
+ instance : DecidableEq (SparsePoly R) := fun a b =>
+ instance : IsExactDiv ℤ
+ 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)
+ instance [Div R] : Div (SparsePoly R)
+ instance {R} [CommGroupWithZero R] : IsExactDiv R
+ natDegree_toPolyCore_lt
+ ofList
+ ofPoly_X
+ ofSortedList
+ ofSortedList_of_nonzero
+ primitivePart
+ toPoly
+ toPolyCore
+ toPolyCore_addCore
+ toPolyCore_append
+ toPolyCore_dedupList
+ toPolyCore_filter_nonzero
+ toPolyCore_injective_of_sorted
+ toPolyCore_map_smul
+ toPolyCore_mergeSort
+ toPolyCore_mul_x
+ toPolyCore_mul_y
+ toPolyCore_perm
+ toPolyEquiv
+ toPoly_C
+ toPoly_X
+ toPoly_add
+ toPoly_injective
+ toPoly_mul
+ toPoly_neg
+ toPoly_ofList
+ toPoly_ofPoly
+ toPoly_one
+ toPoly_pow
+ toPoly_pseudo_rem_a
+ toPoly_pseudo_rem_b
+ toPoly_smul
+ toPoly_smul_X_pow
+ toPoly_smul_X_pow_mul
+ 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 41c211f).

  • +116 new declarations
  • −0 removed declarations
+SparsePoly
+SparsePoly.C
+SparsePoly.CHom
+SparsePoly.IsExactDiv
+SparsePoly.IsExactDiv.casesOn
+SparsePoly.IsExactDiv.mk
+SparsePoly.IsExactDiv.mul_div_cancel
+SparsePoly.IsExactDiv.rec
+SparsePoly.IsExactDiv.recOn
+SparsePoly.X
+SparsePoly.addCore
+SparsePoly.addCore.eq_def
+SparsePoly.addCore_degLt
+SparsePoly.addCore_sorted
+SparsePoly.casesOn
+SparsePoly.coeff
+SparsePoly.coeffCore
+SparsePoly.coeffCore.eq_def
+SparsePoly.coeffCore_eq_toPolyCore_coeff
+SparsePoly.coeff_smul
+SparsePoly.coeff_toPoly
+SparsePoly.coeff_toPolyCore_eq_zero_of_forall_lt
+SparsePoly.coeff_toPolyCore_head
+SparsePoly.coeff_toPolyCore_of_degLt
+SparsePoly.coeffs
+SparsePoly.content
+SparsePoly.content_dvd_coeff_final
+SparsePoly.ctorIdx
+SparsePoly.dedupList
+SparsePoly.dedupList.eq_def
+SparsePoly.dedupList_degLt
+SparsePoly.dedupList_sorted
+SparsePoly.degLt
+SparsePoly.degLt_of_sorted_cons
+SparsePoly.deg_pseudo_rem_a
+SparsePoly.deg_pseudo_rem_b
+SparsePoly.degree
+SparsePoly.degree_eq_head
+SparsePoly.degree_eq_natDegree_toPoly
+SparsePoly.degree_eq_poly_degree
+SparsePoly.degree_mul
+SparsePoly.degree_sub_leading_term_lt
+SparsePoly.divRem
+SparsePoly.divRem.eq_def
+SparsePoly.divRem.induct
+SparsePoly.divRem.match_3.congr_eq_1
+SparsePoly.divRem.match_3.congr_eq_2
+SparsePoly.divRem_eq
+SparsePoly.divRem_spec
+SparsePoly.ext
+SparsePoly.ext_iff
+SparsePoly.foldl_gcd_dvd_acc
+SparsePoly.foldl_gcd_dvd_mem
+SparsePoly.gcd
+SparsePoly.gcdPrim
+SparsePoly.gcdPrim.eq_def
+SparsePoly.instAdd
+SparsePoly.instAlgebra
+SparsePoly.instCommRing
+SparsePoly.instDecidableEq
+SparsePoly.instDiv
+SparsePoly.instIsExactDiv
+SparsePoly.instIsExactDivInt
+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.natDegree_toPolyCore_lt
+SparsePoly.noConfusion
+SparsePoly.noConfusionType
+SparsePoly.nonzero
+SparsePoly.ofList
+SparsePoly.ofPoly_X
+SparsePoly.ofSortedList
+SparsePoly.ofSortedList_of_nonzero
+SparsePoly.primitivePart
+SparsePoly.rec
+SparsePoly.recOn
+SparsePoly.sorted
+SparsePoly.toPoly
+SparsePoly.toPolyCore
+SparsePoly.toPolyCore.eq_def
+SparsePoly.toPolyCore_addCore
+SparsePoly.toPolyCore_append
+SparsePoly.toPolyCore_dedupList
+SparsePoly.toPolyCore_filter_nonzero
+SparsePoly.toPolyCore_injective_of_sorted
+SparsePoly.toPolyCore_map_smul
+SparsePoly.toPolyCore_mergeSort
+SparsePoly.toPolyCore_mul_x
+SparsePoly.toPolyCore_mul_y
+SparsePoly.toPolyCore_perm
+SparsePoly.toPolyEquiv
+SparsePoly.toPoly_C
+SparsePoly.toPoly_X
+SparsePoly.toPoly_add
+SparsePoly.toPoly_injective
+SparsePoly.toPoly_mul
+SparsePoly.toPoly_neg
+SparsePoly.toPoly_ofList
+SparsePoly.toPoly_ofPoly
+SparsePoly.toPoly_one
+SparsePoly.toPoly_pow
+SparsePoly.toPoly_pseudo_rem_a
+SparsePoly.toPoly_pseudo_rem_b
+SparsePoly.toPoly_smul
+SparsePoly.toPoly_smul_X_pow
+SparsePoly.toPoly_smul_X_pow_mul
+SparsePoly.toPoly_zero

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (6.00, 0.00)
Current number Change Type (weak)
5006 6 exposed public sections

Current commit 41c211f3ce
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).

@mkaratarakis
mkaratarakis force-pushed the sparsepoly-6-divrem branch from 3573f09 to 41c211f Compare July 4, 2026 07:30
@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

This PR/issue depends on:

@mkaratarakis mkaratarakis changed the title feat(Tactic/ComputablePolynomial): division with remainder and SparsePoly ≃ₐ Polynomial feat(ComputablePolynomial): division with remainder and SparsePoly ≃ₐ Polynomial 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