Implement monomial ordering functions: MonomialOrder.degree, leadingMonomial, leadingCoeff
Summary
Implement computable versions of monomial ordering functions for CMvPolynomial. These functions allow determining the "leading" term of a polynomial according to a monomial order, which is essential for Gröbner basis computations and polynomial division algorithms.
Context
Part of Phase 1: Foundation Completion (API completeness) as outlined in ROADMAP.md line 49. The MonomialOrder class already exists with a compare method; these functions build on top of it.
What to Implement
-
MonomialOrder.degree {n : ℕ} [MonomialOrder n] (m : CMvMonomial n) : ℕ
- Returns the degree of a monomial according to the ordering
- The exact meaning depends on the specific monomial order (e.g., total degree for graded orders, weighted degree, etc.)
- Location:
CompPoly/Multivariate/CMvPolynomial.lean line 162
-
leadingMonomial {n : ℕ} {R : Type} [Zero R] [MonomialOrder n] (p : CMvPolynomial n R) : Option (CMvMonomial n)
- Returns the leading monomial of a polynomial according to the monomial order
- Returns
none for the zero polynomial
- Location:
CompPoly/Multivariate/CMvPolynomial.lean line 169
-
leadingCoeff {n : ℕ} {R : Type} [Zero R] [MonomialOrder n] (p : CMvPolynomial n R) : R
- Returns the coefficient of the leading monomial
- Returns
0 for the zero polynomial
- Location:
CompPoly/Multivariate/CMvPolynomial.lean line 177
Dependencies
MonomialOrder class (already exists with compare method)
CMvPolynomial structure and monomial access
CMvMonomial.totalDegree (may be useful for graded orders)
Lawful.monomials (to iterate over monomials)
Implementation Notes
leadingMonomial should iterate through all monomials in the polynomial and find the maximum according to MonomialOrder.compare
leadingCoeff can be implemented by finding the leading monomial and then extracting its coefficient
MonomialOrder.degree may need to be defined per-order-type (lex, grlex, etc.) or as a general method
- Consider edge cases: zero polynomial, single monomial, etc.
Mathlib References
MvPolynomial.leadingMonomial - Similar concept in Mathlib
MvPolynomial.leadingCoeff - Similar concept in Mathlib
- Monomial ordering theory in
Mathlib.RingTheory.MvPolynomial.Monad
Success Criteria
Tags
phase-1
api-completeness
multivariate-polynomials
monomial-ordering
Implement monomial ordering functions:
MonomialOrder.degree,leadingMonomial,leadingCoeffSummary
Implement computable versions of monomial ordering functions for
CMvPolynomial. These functions allow determining the "leading" term of a polynomial according to a monomial order, which is essential for Gröbner basis computations and polynomial division algorithms.Context
Part of Phase 1: Foundation Completion (API completeness) as outlined in
ROADMAP.mdline 49. TheMonomialOrderclass already exists with acomparemethod; these functions build on top of it.What to Implement
MonomialOrder.degree {n : ℕ} [MonomialOrder n] (m : CMvMonomial n) : ℕCompPoly/Multivariate/CMvPolynomial.leanline 162leadingMonomial {n : ℕ} {R : Type} [Zero R] [MonomialOrder n] (p : CMvPolynomial n R) : Option (CMvMonomial n)nonefor the zero polynomialCompPoly/Multivariate/CMvPolynomial.leanline 169leadingCoeff {n : ℕ} {R : Type} [Zero R] [MonomialOrder n] (p : CMvPolynomial n R) : R0for the zero polynomialCompPoly/Multivariate/CMvPolynomial.leanline 177Dependencies
MonomialOrderclass (already exists withcomparemethod)CMvPolynomialstructure and monomial accessCMvMonomial.totalDegree(may be useful for graded orders)Lawful.monomials(to iterate over monomials)Implementation Notes
leadingMonomialshould iterate through all monomials in the polynomial and find the maximum according toMonomialOrder.compareleadingCoeffcan be implemented by finding the leading monomial and then extracting its coefficientMonomialOrder.degreemay need to be defined per-order-type (lex, grlex, etc.) or as a general methodMathlib References
MvPolynomial.leadingMonomial- Similar concept in MathlibMvPolynomial.leadingCoeff- Similar concept in MathlibMathlib.RingTheory.MvPolynomial.MonadSuccess Criteria
MonomialOrder.degreeis implemented and typechecksleadingMonomialcorrectly identifies the maximum monomial according to the orderleadingCoeffcorrectly extracts the coefficient of the leading monomialleadingCoeff p = coeff (leadingMonomial p) p)Tags
phase-1api-completenessmultivariate-polynomialsmonomial-ordering