building upon #3714, this (almost) implements the second half of #3302. The main effect is that we now get a better error message when `rfl` fails. For ```lean example : n+1+m = n + (1+m) := by rfl ``` instead of the wall of text ``` The rfl tactic failed. Possible reasons: - The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). - The arguments of the relation are not equal. Try using the reflexivity lemma for your relation explicitly, e.g. `exact Eq.refl _` or `exact HEq.rfl` etc. n m : Nat ⊢ n + 1 + m = n + (1 + m) ``` we now get ``` error: tactic 'rfl' failed, the left-hand side n + 1 + m is not definitionally equal to the right-hand side n + (1 + m) n m : Nat ⊢ n + 1 + m = n + (1 + m) ``` Unfortunately, because of very subtle differences in semantics (which transparency setting is used when reducing the goal and whether the “implicit lambda” feature applies) I could not make this simply the only `rfl` implementation. So `rfl` remains a macro and is still expanded to `eq_refl` (difference transparency setting) and `exact Iff.rfl` and `exact HEq.rfl` (implicit lambda) to not break existing code. This can be revised later, so this still closes: #3302. A user might still be puzzled *why* to terms are not defeq. Explaining that better (“reduced to… and reduces to… etc.”) would also be great, but that’s not specific to `rfl`, so better left for some other time.
39 lines
1.1 KiB
Text
39 lines
1.1 KiB
Text
runTacticMustCatchExceptions.lean:2:25-2:28: error: tactic 'rfl' failed, the left-hand side
|
|
1
|
|
is not definitionally equal to the right-hand side
|
|
a + b
|
|
a b : Nat
|
|
⊢ 1 ≤ a + b
|
|
runTacticMustCatchExceptions.lean:3:25-3:28: error: tactic 'rfl' failed, the left-hand side
|
|
a + b
|
|
is not definitionally equal to the right-hand side
|
|
b
|
|
a b : Nat
|
|
this : 1 ≤ a + b
|
|
⊢ a + b ≤ b
|
|
runTacticMustCatchExceptions.lean:4:25-4:28: error: tactic 'rfl' failed, the left-hand side
|
|
b
|
|
is not definitionally equal to the right-hand side
|
|
2
|
|
a b : Nat
|
|
this✝ : 1 ≤ a + b
|
|
this : a + b ≤ b
|
|
⊢ b ≤ 2
|
|
runTacticMustCatchExceptions.lean:9:18-9:21: error: tactic 'rfl' failed, the left-hand side
|
|
1
|
|
is not definitionally equal to the right-hand side
|
|
a + b
|
|
a b : Nat
|
|
⊢ 1 ≤ a + b
|
|
runTacticMustCatchExceptions.lean:10:14-10:17: error: tactic 'rfl' failed, the left-hand side
|
|
a + b
|
|
is not definitionally equal to the right-hand side
|
|
b
|
|
a b : Nat
|
|
⊢ a + b ≤ b
|
|
runTacticMustCatchExceptions.lean:11:14-11:17: error: tactic 'rfl' failed, the left-hand side
|
|
b
|
|
is not definitionally equal to the right-hand side
|
|
2
|
|
a b : Nat
|
|
⊢ b ≤ 2
|