Zulip Chat Archive

Stream: mathlib4

Topic: making `op` irreducible


Matthew Ballard (May 02 2024 at 16:29):

Taking the new diagnostics tool for a ride and this was the biggest offender in the file with the worst regressions with 4.8.

Matthew Ballard (May 02 2024 at 16:41):

The canonical map α → αᵒᵖ.

Sounds kinda evil

Eric Wieser (May 02 2024 at 17:30):

Just to be clear, this is docs#Opposite.op, from category theory?

Eric Wieser (May 02 2024 at 17:31):

(Should we namespace the definition in CategoryTheory?)

Markus Himmel (May 02 2024 at 17:41):

Matthew Ballard said:

Sounds kinda evil

Why is it evil? How else would you go from an object X : C to the corresponding object in the opposite category?

Matthew Ballard (May 02 2024 at 17:48):

However I did it, I wouldn't tell Lean

Adam Topaz (May 02 2024 at 17:59):

Markus Himmel said:

Why is it evil?

It's evil because an object is not an object of C but rather an object in some unspecified category equivalent to C. (sorry...)

Joël Riou (May 02 2024 at 18:01):

Anyway, it is completely unreasonable to make Opposite.op irreducible.

Matthew Ballard (May 02 2024 at 18:03):

In terms of impractical?

Joël Riou (May 02 2024 at 18:04):

Yes.

Adam Topaz (May 02 2024 at 18:04):

I'm not sure it's completely unreasonable, but if we do make it irreducible we would have to be very careful in developing the initial API.

Matthew Ballard (May 02 2024 at 18:05):

I am attempting the experiment now with the new attribute [local semireducible] and trying to quarantine those with irreducible

Adam Topaz (May 02 2024 at 18:05):

It's already a structure, right? Is the main issue with eta-reduction?

Matthew Ballard (May 02 2024 at 18:05):

Opposite is a structure. op is a def

Adam Topaz (May 02 2024 at 18:06):

docs#Opposite.op

Adam Topaz (May 02 2024 at 18:06):

Why aren't we doing:

structure Opposite := op :: unop : α

Joël Riou (May 02 2024 at 18:07):

It this does what I think it does, I would be ok with this.

Matthew Ballard (May 02 2024 at 18:10):

Joël Riou said:

It this does what I think it does, I would be ok with this.

Sorry, I cannot parse "this". Are you referring to Adam's suggestion to use the constructor directly?

Joël Riou (May 02 2024 at 18:11):

Matthew Ballard said:

Joël Riou said:

It this does what I think it does, I would be ok with this.

Sorry, I cannot parse "this". Are you referring to Adam's suggestion to use the constructor directly?

Yes!

Matthew Ballard (May 02 2024 at 18:11):

That does seem more principled

Joël Riou (May 02 2024 at 18:12):

Isn't it mostly like making op reducible?

Matthew Ballard (May 02 2024 at 18:13):

Structure eta?

Eric Wieser (May 02 2024 at 18:19):

Adam Topaz said:

Why aren't we doing:

structure Opposite := op :: unop : α

Independent of the performance discussion in this thread, we should certainly do this

Matthew Ballard (May 03 2024 at 19:57):

Let's see what happens... #12636

Matthew Ballard (May 03 2024 at 19:58):

I got caught in DTH in one proof and didn't have the energy to fight my way out

Matthew Ballard (May 03 2024 at 19:59):

I had to no_index a couple of instances because the discrimination tree was applying structure eta to get the keys making Lean miss the instance

Matthew Ballard (May 03 2024 at 20:03):

AlgebraicGeometry.GammaSpecAdjunction gets sped up by about 10% but is still incredibly slow compared to before v4.8

Markus Himmel (Jul 07 2024 at 11:15):

Matthew Ballard said:

Let's see what happens... #12636

An unfortunate consequence of this change is that instead of op X the pretty printer now prints { unop := X } everywhere. In lean4#4675 I'm proposing a new attribute @[pp_no_structure_instances] that we can apply to Opposite to fix this.

Yaël Dillies (Jul 07 2024 at 11:56):

I've offered a different solution which would solve other problems along the way, namely to decouple the default constructor from the \<> notation and instead couple it to mk.

Markus Himmel (Jul 07 2024 at 12:04):

Ah, thanks for reminding me about that discussion (for reference: this one). That seems like a much larger change to me, and from the discussion so far it also seems not clear whether the issue I'm referring to would be affected by your suggested change at all, since it's about the delaborator producing { field := value } notation rather than \<> notation. So it seems to me that there is value in getting this tiny change to the delaborator merged while your suggestion makes its way through the RFC process.


Last updated: May 02 2025 at 03:31 UTC