Compare commits

...

1 Commits

Author SHA1 Message Date
Joachim Breitner
04c3d318c2 fix: suggest (rfl) not id rfl in linter 2026-04-08 08:05:45 +00:00
3 changed files with 9 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ theorem gcd_def (x y : Nat) : gcd x y = if x = 0 then y else gcd (y % x) x := by
cases n with
| zero => simp
| succ n =>
-- `simp [gcd_succ]` produces an invalid term unless `gcd_succ` is proved with `id rfl` instead
-- `simp [gcd_succ]` produces an invalid term unless `gcd_succ` is proved with `(rfl)` instead
rw [gcd_succ]
exact gcd_zero_left _
instance : Std.LawfulIdentity gcd 0 where

View File

@@ -382,10 +382,10 @@ private def mkSimpTheoremCore (origin : Origin) (e : Expr) (levelParams : Array
forallTelescopeReducing type fun _ type => do
let checkDefEq (lhs rhs : Expr) := do
unless ( withTransparency .instances <| isDefEq lhs rhs) do
logWarning m!"`{origin.key}` is a `rfl` simp theorem, but its left-hand side{indentExpr lhs}\n\
logWarning m!"`{origin.key}` is a `[defeq]` simp theorem, but its left-hand side{indentExpr lhs}\n\
is not definitionally equal to the right-hand side{indentExpr rhs}\n\
at `.instances` transparency. Possible solutions:\n\
1- use `id rfl` as the proof\n\
1- use `(rfl)` as the proof\n\
2- mark constants occurring in the lhs and rhs as `[implicit_reducible]`"
match_expr type with
| Eq _ lhs rhs => checkDefEq lhs rhs

View File

@@ -5,19 +5,19 @@ def myId (n : Nat) : Nat := n
-- LHS `myId n` and RHS `n` are only defeq if `myId` is unfolded (requires default transparency)
/--
warning: `myId_eq` is a `rfl` simp theorem, but its left-hand side
warning: `myId_eq` is a `[defeq]` simp theorem, but its left-hand side
myId n
is not definitionally equal to the right-hand side
n
at `.instances` transparency. Possible solutions:
1- use `id rfl` as the proof
1- use `(rfl)` as the proof
2- mark constants occurring in the lhs and rhs as `[implicit_reducible]`
-/
#guard_msgs in
@[simp] theorem myId_eq (n : Nat) : myId n = n := rfl
#guard_msgs in
@[simp] theorem myId_eq' (n : Nat) : myId n = n := id rfl
@[simp] theorem myId_eq' (n : Nat) : myId n = n := (rfl)
attribute [implicit_reducible] myId
@@ -32,16 +32,16 @@ attribute [implicit_reducible] myId
@[simp] theorem myId2_eq (n : Nat) : myId2 n = n := rfl
/--
warning: `add_zero` is a `rfl` simp theorem, but its left-hand side
warning: `add_zero` is a `[defeq]` simp theorem, but its left-hand side
n + 0
is not definitionally equal to the right-hand side
n
at `.instances` transparency. Possible solutions:
1- use `id rfl` as the proof
1- use `(rfl)` as the proof
2- mark constants occurring in the lhs and rhs as `[implicit_reducible]`
-/
#guard_msgs in
@[simp] theorem add_zero (n : Nat) : n + 0 = n := rfl
#guard_msgs in
@[simp] theorem add_zero' (n : Nat) : n + 0 = n := id rfl
@[simp] theorem add_zero' (n : Nat) : n + 0 = n := (rfl)