Skip to content

feat(Algebra): add multivariate Laurent polynomials#37249

Open
yuma-mizuno wants to merge 9 commits intoleanprover-community:masterfrom
yuma-mizuno:mvlaurent
Open

feat(Algebra): add multivariate Laurent polynomials#37249
yuma-mizuno wants to merge 9 commits intoleanprover-community:masterfrom
yuma-mizuno:mvlaurent

Conversation

@yuma-mizuno
Copy link
Copy Markdown
Collaborator

@yuma-mizuno yuma-mizuno commented Mar 26, 2026


I used Codex to imitate the MvPolynomial API. Now it has been rewritten by hand to focus on its AddMonoidAlgebra features.
Proving UniqueFactorizationMonoid is my next plan.

Open in Gitpod

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

PR summary 28a77d90ec

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Algebra.MvLaurentPolynomial.Basic (new file) 1065

Declarations diff

+ X
+ X_eq_monomial
+ X_inj
+ X_injective
+ X_ne_zero
+ X_pow_eq_monomial
+ algebraMap_eq_toMvLaurent
+ algebraMvPolynomial
+ as_sum
+ basisAlgEquiv
+ basisAlgEquiv_apply
+ basisAlgEquiv_monomial
+ basisAlgEquiv_toMvLaurent
+ induction_on'
+ isUnit_monomial
+ monomial
+ monomial_add_single
+ monomial_eq_zero
+ monomial_left_inj
+ monomial_left_injective
+ monomial_mul
+ monomial_pow
+ monomial_single_add
+ monomial_zero
+ mul_eq_sum_monomial
+ one_eq_monomial
+ single_eq_monomial
+ smul_monomial
+ sum_monomial_eq
+ support_monomial
+ support_monomial_subset
+ support_sum_monomial_coeff
+ toMvLaurent
+ toMvLaurent_X
+ toMvLaurent_eq_zero
+ toMvLaurent_inj
+ toMvLaurent_injective
+ toMvLaurent_monomial
+ toMvLaurent_ne_zero

You can run this locally as follows
## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>

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

The doc-module for scripts/pr_summary/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./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-algebra Algebra (groups, rings, fields, etc) label Mar 26, 2026
@eric-wieser eric-wieser requested a review from YaelDillies March 27, 2026 01:09
I removed `sum_def` because its left-hand side directly uses the `Finsupp` expression.
Copy link
Copy Markdown
Contributor

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

Can you please reuse as many AddMonoidAlgebra primitives as possible? In particular, could you please avoid defining: coeff, support. monomial?

My hope is that you can work with mutlvariate polynomials without adding any API at all, but I can see that maybe you want MvLaurentPolynomial.C and MvLaurentPolynomial.X, the latter of which doesn't make sense over AddMonoidAlgebra.

variable {R : Type*} {S : Type*} {σ : Type*}

/-- Multivariate Laurent polynomials over `R` in variables indexed by `σ`. -/
abbrev MvLaurentPolynomial (σ : Type*) (R : Type*) [CommSemiring R] :=
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.

Suggested change
abbrev MvLaurentPolynomial (σ : Type*) (R : Type*) [CommSemiring R] :=
abbrev MvLaurentPolynomial (σ R : Type*) [CommSemiring R] :=

@YaelDillies YaelDillies added the awaiting-author A reviewer has asked the author a question or requested changes. label Mar 27, 2026
@yuma-mizuno
Copy link
Copy Markdown
Collaborator Author

yuma-mizuno commented Mar 27, 2026

My hope is that you can work with mutlvariate polynomials without adding any API at all, but I can see that maybe you want MvLaurentPolynomial.C and MvLaurentPolynomial.X, the latter of which doesn't make sense over AddMonoidAlgebra.

Indeed, what I actually want would be X and its related things. Can we develop the theory of Laurent polynomials as a part of AddMonoidAlgebra API by using the definitions like this?

def X {σ R M : Type*} [CommSemiring R] [AddCommGroup M] [Module ℤ M]
    (v : Basis σ ℤ M) (i : σ) :
    AddMonoidAlgebra R M :=
  AddMonoidAlgebra.single (v i) 1

@YaelDillies
Copy link
Copy Markdown
Contributor

Possibly, yes. In Toric, we need "multivariate polynomials without a canonical basis". @erdOne, @Kiolt, do you think what Yuma is suggesting above would be useful to us?

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

Labels

awaiting-author A reviewer has asked the author a question or requested changes. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants