Zulip Chat Archive

Stream: general

Topic: simp normal form for double casts


Scott Morrison (Mar 20 2021 at 08:16):

Can someone remind me what the preferred simp normal form should be in this example?

Say I have a s : subalgebra R A. Is ((s : subsemiring A) : set A) better, or (s : set A) directly?

(Currently mathlib seems to like the former in some places, and I'm wondering if it should be changed.)

Scott Morrison (Mar 20 2021 at 08:21):

Actually this is terrible. There's a diamond, because we can also do ((s : submodule R A) : set A).

Scott Morrison (Mar 20 2021 at 08:24):

ugh

Scott Morrison (Mar 20 2021 at 08:24):

And of course coe_coe unpacks the direct coercion...

Johan Commelin (Mar 20 2021 at 08:35):

I would think that the direct coercion is SNF

Scott Morrison (Mar 20 2021 at 08:47):

Except that coe_coe is marked as a simp lemma.

Scott Morrison (Mar 20 2021 at 08:48):

/-- Add an instance to "undo" coercion transitivity into a chain of coercions, because
   most simp lemmas are stated with respect to simple coercions and will not match when
   part of a chain. -/
@[simp] theorem coe_coe {α β γ} [has_coe α β] [has_coe_t β γ]
  (a : α) : (a : γ) = (a : β) := rfl

Scott Morrison (Mar 20 2021 at 08:48):

So I guess we're meant to cope with these diamonds... I seem to have done so in my local situation.

Johan Commelin (Mar 20 2021 at 08:49):

Yeah, I see why coe_coe should be simp

Johan Commelin (Mar 20 2021 at 08:49):

But I'm not sure what the principled approach to dealing with these diamonds is

Eric Wieser (Mar 20 2021 at 09:02):

I'm adding a direct coercion from subalgebra to set in #6768

Eric Wieser (Mar 20 2021 at 09:04):

Which is consistent with how all the other subobjects work

Scott Morrison (Mar 20 2021 at 09:05):

Ah, cool, thanks!

Eric Wieser (Mar 20 2021 at 09:08):

We deal with diamonds in the same way with bundled homs

Eric Wieser (Mar 21 2021 at 16:06):

Split to #6800, that PR grew too much


Last updated: Dec 20 2023 at 11:08 UTC