Zulip Chat Archive

Stream: mathlib4

Topic: Tracing simp that timeouts


Yury G. Kudryashov (Feb 14 2023 at 17:56):

I have a simp that timeouts with "maximum recursion depth has been reached". How do I debug/trace which lemmas does it apply? @Mario Carneiro @Gabriel Ebner ?

Yury G. Kudryashov (Feb 14 2023 at 17:59):

I tried some random set_option trace.Compiler.simp.* true, didn't work.

Yury G. Kudryashov (Feb 14 2023 at 19:03):

I'm talking about !4#2270

Yury G. Kudryashov (Feb 14 2023 at 19:03):

Probably, I introduced a simp cycle somewhere (why we don't see it elsewhere?)

Reid Barton (Feb 14 2023 at 19:04):

I think you want one or both of these instead

set_option trace.Meta.Tactic.simp true
set_option trace.Meta.Tactic.simp.rewrite true

Yury G. Kudryashov (Feb 14 2023 at 19:06):

Thanks! I found a cycle. Not sure if I have time to break it now.

Yury G. Kudryashov (Feb 14 2023 at 19:09):

The cycle is between MulHom.coe_mk and MulHom.toFun_eq_coe. It appears when it is applied to a MulHom which is reducibly equal to MulHom.mk _ _.

Yury G. Kudryashov (Feb 14 2023 at 19:09):

(in this case, it is MulEquiv.toMulHom _)

Yury G. Kudryashov (Feb 14 2023 at 19:15):

Why does MulHom.coe_mk simplify (e.toMulHom : _ → _) to e.toMulHom.toFun, not to e.toEquiv.toFun?

Yury G. Kudryashov (Feb 14 2023 at 19:16):

MulEquiv.toMulHom is defined as

@[reducible] def MulEquiv.toMulHom.{u_1, u_2} : {M : Type u_1} 
  {N : Type u_2}  [inst : Mul M]  [inst_1 : Mul N]  M ≃* N  M →ₙ* N :=
fun M N [Mul M] [Mul N] self =>
  { toFun := self.toEquiv.toFun,
    map_mul' :=
      (_ :  (x y : M), Equiv.toFun self.toEquiv (x * y) = Equiv.toFun self.toEquiv x * Equiv.toFun self.toEquiv y) }

Yury G. Kudryashov (Feb 14 2023 at 19:16):

And MulHom.coe_mk:

@[to_additive (attr := simp)]
theorem MulHom.coe_mk [Mul M] [Mul N] (f : M  N) (hmul) : (MulHom.mk f hmul : M  N) = f := rfl
#align mul_hom.coe_mk MulHom.coe_mk
#align add_hom.coe_mk AddHom.coe_mk

Yury G. Kudryashov (Feb 14 2023 at 19:27):

@Reid Barton @Mario Carneiro @Gabriel Ebner :up:


Last updated: Dec 20 2023 at 11:08 UTC