Zulip Chat Archive

Stream: lean4

Topic: simpa? should output information even if failing


Yaël Dillies (Feb 18 2025 at 15:32):

Consider the following MWE:

-- `Foo`, `Bar`, `Baz` are propeq but non-defeq propositions
def Foo : Prop := True
def Bar : Prop := True  True
def Baz : Prop := (True  True)  True

-- Some bad pair of simp lemmas
@[simp] theorem foo_iff_bar : Foo  Bar := by simp [Foo, Bar]
@[simp] theorem foo_iff_baz : Foo  Baz := by simp [Foo, Baz]

-- `simpa?` won't let me know :(
example (h : Foo) : Baz := by simpa? using h
/-
type mismatch, term
  h
after simplification has type
  Bar : Prop
but is expected to have type
  Baz : Prop
-/

Yaël Dillies (Feb 18 2025 at 15:34):

This kind of situation, where a simpa doesn't work because I should disable some lemma in the simpa call, is really annoying to debug because simpa? fails instead of telling me what lemmas it tried to use.

Yaël Dillies (Feb 18 2025 at 15:35):

The only general way to debug this is to do

example (h : Foo) : Baz := by
  have := h
  simp? at this 

which is a painful code transformation to perform

Yaël Dillies (Feb 18 2025 at 15:35):

Could simpa? output information about which lemmas it used even when it is failing?

Yaël Dillies (Feb 19 2025 at 11:08):

I've opened a RFC: lean4#7145


Last updated: May 02 2025 at 03:31 UTC