Zulip Chat Archive

Stream: mathlib4

Topic: Default `OfScientific` instance


Heather Macbeth (Mar 08 2023 at 09:20):

I'd like to make Rat the default OfScientific instance in mathlib, overriding Float which is the default instance in core. So something like 1.7 without a type annotation would be interpreted as Rat.

@Gabriel Ebner told me that this should be an easy change, just put a line somewhere making that the default instance and perhaps giving it a higher priority than the Float one in core, so that it takes precedence. But what is the right place in mathlib to put this?

Thomas Murrills (Mar 08 2023 at 20:20):

Maybe Mathlib.Init.Data.Rat.Basic? (Data.Rat.Basic is where the Rat instance for OfScientific is in std4, and Mathlib.Init.Data.Rat.Basic already imports Std.Data.Rat.Basic, as you'd expect)

Yaël Dillies (Mar 08 2023 at 22:09):

That's a leftover file from Lean 3's architecture, though. Not sure we want to mess with that.

Thomas Murrills (Mar 09 2023 at 01:58):

Oh, I thought that it was named “Init” because it’s imported by every Mathlib file, sort of like a prelude. Does Mathlib have anything prelude-like?

Yaël Dillies (Mar 09 2023 at 09:25):

Std is prelude-like to mathlib4, but that doesn't really help here, no.

Scott Morrison (Mar 09 2023 at 09:49):

How about Mathlib.Data.Rat.Init? That is where we set up the notation for ℚ, and it is the earliest place where have Std.Data.Rat imported.


Last updated: Dec 20 2023 at 11:08 UTC