Zulip Chat Archive

Stream: mathlib4

Topic: dsimp in instances


Yury G. Kudryashov (May 31 2023 at 19:51):

git grep -nH -A1 '^instance' | grep -B1 dsimp shows that many instances use dsimp mydef; infer_instance pattern. It inserts id in the resulting instance. Am I right that this is a bad idea for instances with data? Or this changed in Lean 4?

Yury G. Kudryashov (May 31 2023 at 19:52):

Another bunch of instances use unfold for the same purpose.

Eric Wieser (May 31 2023 at 21:27):

Doesn't inferInstanceAs insert a wrapper function too?

Eric Wieser (May 31 2023 at 21:27):

I think we tried to avoid this pre-emptively in Lean 3 because at best it was just one more trivial thing to unfold

Yury G. Kudryashov (May 31 2023 at 21:28):

No, in some cases Lean 3 failed to unfold id.

Yury G. Kudryashov (May 31 2023 at 21:29):

We migrated from pi_instance to manual instances because of that.

Yury G. Kudryashov (May 31 2023 at 21:29):

inferInstanceAs is an abbrev, id is @[inline]

Yury G. Kudryashov (May 31 2023 at 21:30):

As far as I understand, abbrevs are reducible.

Yury G. Kudryashov (Jun 01 2023 at 04:20):

@Mario Carneiro Should we get rid of those dsimps?

Mario Carneiro (Jun 01 2023 at 04:22):

instances are usually unfolded at default reducibility, so it shouldn't matter

Yury G. Kudryashov (Jun 01 2023 at 05:47):

Did it change from Lean 3 to Lean 4? I remember that we had lots of @[reducible] non-instances in mathlib3.


Last updated: Dec 20 2023 at 11:08 UTC