Zulip Chat Archive
Stream: mathlib4
Topic: Can restrictScalars be a coercion?
Martin Winter (Jan 07 2026 at 15:45):
In a recent PR we implemented coercion from a submodule to a pointed cone, which is just restriction to the non-negative scalars. Is there a reason to not have the general restrictScalars as a coercion like this:
instance {p : Submodule R M} : CoeDep (Submodule R M) p (Submodule S M) := ⟨restrictScalars S p⟩
I know from my own code that a lot of statements would become much shorter.
We could then also put @[coe] on restrictScalars for readability.
Eric Wieser (Jan 07 2026 at 16:59):
Why do you need CoeDep here?
Eric Wieser (Jan 07 2026 at 16:59):
Martin Winter said:
We could then also put
@[coe]onrestrictScalarsfor readability.
This is a bad idea, since the goal view then shows p.restrictScalars S as ↑S p
Martin Winter (Jan 07 2026 at 17:01):
Eric Wieser said:
Why do you need
CoeDephere?
The honest answer is: because I could not make it work with any other Coe variant. It always complains that it cannot find a synthesization order.
Martin Winter (Jan 07 2026 at 17:03):
Eric Wieser said:
Martin Winter said:
We could then also put
@[coe]onrestrictScalarsfor readability.This is a bad idea, since the goal view then shows
p.restrictScalars Sas↑S p
This is already the case for LinearMap.restrictScalars and I always found this to be more readable than the alternative.
Kevin Buzzard (Jan 07 2026 at 20:32):
Yes I noticed this "weirdness" with LinearMap.restrictScalars recently and after having considered reporting it as an issue I decided it might actually be more helpful to just to leave it as it is and get used to it :-) It's weird but helpful notation :-)
Last updated: Feb 28 2026 at 14:05 UTC