The `conv` tactic tries to close “trivial” goals after itself. As of now, it uses `try rfl`, which means it can close goals that are only trivial after reducing with default transparency. This is suboptimal * this can require a fair amount of unfolding, and possibly slow down the proof a lot. And the user cannot even prevent it. * it does not match what `rw` does, and a user might expect the two to behave the same. So this PR changes it to `with_reducible rfl`, matching `rw`’s behavior. I considered `with_reducible eq_refl` to only solve trivial goals that involve equality, but not other relations (e.g. `Perm xs xs`), but a discussion on mathlib pointed out that it’s expected and desirable to solve more general reflexive goals: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Closing.20after.20.60rw.60.2C.20.60conv.60.3A.20.60eq_refl.60.20instead.20of.20.60rfl.60/near/429851605
20 lines
496 B
Text
20 lines
496 B
Text
class Trait (X : Type) where
|
|
R : Type
|
|
|
|
class One (R : Type) where
|
|
one : R
|
|
|
|
attribute [reducible] Trait.R
|
|
|
|
def add_one {X} [Trait X] [One (Trait.R X)] [HAdd X (Trait.R X) X] (x : X) : X := x + (One.one : (Trait.R X))
|
|
|
|
@[reducible] instance : Trait Int := ⟨Nat⟩
|
|
instance : One Nat := ⟨1⟩
|
|
instance : HAdd Int Nat Int := ⟨λ x y => x + y⟩
|
|
|
|
def add_one_to_one (x : Int) (h : x = 1) : add_one (x : Int) = (2 : Int) := by
|
|
conv =>
|
|
pattern add_one _
|
|
trace_state
|
|
rw [h]
|
|
rfl
|