lean4-htt/tests/lean/run/dsimp_instances.lean
Leonardo de Moura 1695b940b1
feat: do not simp instances (#12244)
This PR ensures `simp` does not "simplify" instances by default. The old
behavior can be retrieved by using `simp +instances`. This PR is similar
to #12195, but for `dsimp`.
The backward compatibility flag for `dsimp` also deactivates this new
feature.

```
set_option backward.dsimp.instances true
```

Applying `simp` (and `dsimp`) to instances creates non-standard
instances, and this creates all sorts of problems in Mathlib.

---------

Co-authored-by: Henrik Böving <hargonix@gmail.com>
Co-authored-by: Sebastian Graf <sgraf1337@gmail.com>
Co-authored-by: Kim Morrison <kim@tqft.net>
2026-02-05 04:53:46 +00:00

62 lines
1.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean
set_option warn.sorry false
def f [Add α] (a : α) := a + a
abbrev id' (a : α) := a
abbrev addNat : Add Nat := ⟨Nat.add⟩
set_option pp.explicit true
/--
trace: a b : Nat
⊢ @Eq Nat (@f Nat (@id' (Add Nat) addNat) a) b
---
trace: a b : Nat
⊢ @Eq Nat (@f Nat addNat a) b
-/
#guard_msgs in
example : @f _ (id' addNat) a = id b := by
dsimp [id']
trace_state -- `id'` was not unfolded because it is part of an instance
dsimp +instances [id']
trace_state
sorry
/--
trace: a b : Nat
⊢ @Eq Nat (@f Nat addNat a) b
-/
#guard_msgs in
set_option backward.dsimp.instances true in
example : @f _ (id' addNat) a = id b := by
dsimp [id']
trace_state
sorry
set_option linter.unusedSimpArgs false
/--
trace: a b : Nat
⊢ @Eq Nat (@f Nat (@id' (Add Nat) addNat) a) b
---
trace: a b : Nat
⊢ @Eq Nat (@f Nat addNat a) b
-/
#guard_msgs in
example : @f _ (id' addNat) a = id b := by
simp [id']
trace_state -- `id'` was not unfolded because it is part of an instance
simp +instances [id']
trace_state
sorry
/--
trace: a b : Nat
⊢ @Eq Nat (@f Nat addNat a) b
-/
#guard_msgs in
set_option backward.dsimp.instances true in
example : @f _ (id' addNat) a = id b := by
simp [id']
trace_state
sorry