Zulip Chat Archive

Stream: mathlib4

Topic: Polynomial and PolynomialModule


Luna (Sep 10 2025 at 22:26):

Why are Polynomial and PolynomialModule two different definitions?

In mathlib, they are respectively defined like:

structure Polynomial (R : Type*) [Semiring R] where ofFinsupp ::
  toFinsupp : AddMonoidAlgebra R 

def PolynomialModule (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] :=  →₀ M

If you unfold AddMonoidAlgebra R ℕ it is just ℕ →₀ R. These two definition look like they contain the same type of data but with different instances. Should these definitions be merged? And would a PR be welcomed?

For context of why this came up, I'm working on Chapter 10 of MIL and want to show:

import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Eigenspace.Minpoly
import Mathlib.LinearAlgebra.Charpoly.Basic

open Polynomial Module LinearMap End

variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V]

example (P Q : K[X]) (h : IsCoprime P Q) (φ : End K V) :
    ker (aeval φ P)  ker (aeval φ Q) = ker (aeval φ (P*Q)) := by sorry

Ideally I'd like to show that these are equivalent using the theorem Polynomial.roots_mul (i.e. the kernel of these expressions occur when the image of φ equals the roots of the polynomial when evaluated on the elements of the module; so showing the kernels are equal is equivalent to showing the roots of PQP*Q are equal to the roots PP unioned with the roots of QQ). But the regular Polynomial K definition cannot be evaluated on the elements of a module.

Eric Wieser (Sep 10 2025 at 22:41):

There's some ongoing work refactoring AddMonoidAlgebra by @Yaël Dillies , which I think aims to replace the first one with Polynomial := AddMonoidAlgebra R ℕ (which is also what it used to be defined as!)

Yaël Dillies (Sep 11 2025 at 05:09):

Indeed. The current blocker is #29207, where I would like some help to debug an obscure error


Last updated: Dec 20 2025 at 21:32 UTC