Zulip Chat Archive
Stream: mathlib4
Topic: Polynomial eval function
Shreyas Srinivas (Feb 27 2026 at 23:30):
Why is the order of arguments for Polynomial.eval first x and then P, the polynomial?
Shreyas Srinivas (Feb 27 2026 at 23:31):
The signature borrowed from the docs is
def Polynomial.eval {R : Type u} [Semiring R] (x : R) (p : Polynomial R) : R
Shreyas Srinivas (Feb 27 2026 at 23:32):
Wouldn't
def Polynomial.eval {R : Type u} [Semiring R] (p : Polynomial R) (x : R) : R
allow us to write p.eval x?
Snir Broshi (Feb 27 2026 at 23:32):
The current def also allows that, unless your R is also a polynomial
Snir Broshi (Feb 27 2026 at 23:33):
I believe the reason for the order is that Polynomial.eval x is a RingHom from polynomials, but I don't remember where that RingHom is defined
Snir Broshi (Feb 27 2026 at 23:35):
Shreyas Srinivas (Feb 27 2026 at 23:35):
Oh that's interesting. That seems unlike the usual requirement for getting the dot notation
Snir Broshi (Feb 27 2026 at 23:35):
Dot notation uses the first parameter of that type, it doesn't have to be the first parameter overall
Snir Broshi (Feb 27 2026 at 23:35):
Otherwise the R : Type* would beat it
Shreyas Srinivas (Feb 27 2026 at 23:36):
Thanks. TIL
Edward van de Meent (Feb 28 2026 at 10:59):
Shreyas Srinivas said:
Wouldn't
def Polynomial.eval {R : Type u} [Semiring R] (p : Polynomial R) (x : R) : Rallow us to write
p.eval x?
Doesn't it still do so now?
Shreyas Srinivas (Feb 28 2026 at 11:00):
It does. This thread can be closed. I learnt something new
Last updated: Feb 28 2026 at 14:05 UTC