Zulip Chat Archive

Stream: general

Topic: Is simp only a sequence of intelligent rewrites?


Assar Lannerborn (Jul 26 2025 at 03:27):

Hi i am relatively new to lean. I encountered some proof using the tactic simp only [someprop]. Testing my understanding of simp and rw tactic, i thought i could just replace with rw [someprop], but the rw completely fails, "did not find instance of the pattern in the target expression". According to the documentation it states "The simplifier mindlessly rewrites until it can rewrite no more." I am probably missing something obvious but i can't figure it out.

Assar Lannerborn (Jul 26 2025 at 03:30):

the exact example is

example (h : s  t) : s  u  t  u := by
  rw [subset_def, inter_def, inter_def]
  rw [subset_def] at h
  simp only [mem_setOf]
  rintro x xs, xu
  exact h _ xs, xu

Weiyi Wang (Jul 26 2025 at 03:46):

(I had to guess a few declarations

import Mathlib
variable (s t : Set )
open Set
example (h : s  t) : s  u  t  u := by
  rw [subset_def, inter_def, inter_def]
  rw [subset_def] at h
  -- goal: ∀ x ∈ {a | a ∈ s ∧ a ∈ u}, x ∈ {a | a ∈ t ∧ a ∈ u}
  simp only [mem_setOf]
  rintro x xs, xu
  exact h _ xs, xu

)
This is the case where rw doesn't work because the expression being rewritten contains a binder (x), but simp can still do it

Weiyi Wang (Jul 26 2025 at 03:48):

https://leanprover-community.github.io/extras/pitfalls.html#rewriting-under-binders

Assar Lannerborn (Jul 26 2025 at 03:52):

ahh forgot to include the imports. I see so it's a unintended limitation it seems. Thanks for help and that resource :)

Etienne Marion (Jul 26 2025 at 08:39):

Note there is also simp_rw whose only purpose is to rewrite more efficiently than rw, in particular under binders (with the downside that it does not defer side conditions).


Last updated: Dec 20 2025 at 21:32 UTC