Skip to content

Commit 47423df

Browse files
committed
debug option, not trace option
1 parent 2cc0737 commit 47423df

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/Init/Data/List/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ theorem getElem_length_sub_one_eq_getLast {l : List α} (h : l.length - 1 < l.le
834834
rw [← getLast_eq_getElem]
835835

836836
@[simp, grind] theorem getLast_cons_cons {a : α} {l : List α} :
837-
getLast (a :: b :: l) (by simp) = getLast (b :: l) (by simp) := by
837+
getLast (a :: b :: l) (by simp) = getLast (b :: l) (by simp) :=
838838
rfl
839839

840840
theorem getLast_cons {a : α} {l : List α} : ∀ (h : l ≠ nil),

src/Lean/Meta/Tactic/Simp.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ builtin_initialize registerTraceClass `Meta.Tactic.simp.unify (inherited := true
2828
builtin_initialize registerTraceClass `Meta.Tactic.simp.ground (inherited := true)
2929
builtin_initialize registerTraceClass `Meta.Tactic.simp.numSteps
3030
builtin_initialize registerTraceClass `Meta.Tactic.simp.heads
31-
builtin_initialize registerTraceClass `Meta.Tactic.simp.rflAttrMismatch
3231
builtin_initialize registerTraceClass `Debug.Meta.Tactic.simp
3332
builtin_initialize registerTraceClass `Debug.Meta.Tactic.simp.congr (inherited := true)
3433

src/Lean/Meta/Tactic/Simp/Rewrite.lean

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,20 @@ where
218218
else
219219
let candidates := candidates.insertionSort fun e₁ e₂ => e₁.1.priority > e₂.1.priority
220220
for (thm, numExtraArgs) in candidates do
221-
unless inErasedSet thm || (rflOnly && !thm.isRfl (← getEnv)) do
222-
if let some result ← tryTheoremWithExtraArgs? e thm numExtraArgs then
223-
trace[Debug.Meta.Tactic.simp] "rewrite result {e} => {result.expr}"
224-
return some result
225-
if !inErasedSet thm && rflOnly && !thm.isRfl (← getEnv) then
226-
let r ← withOptions (experimental.tactic.simp.useRflAttr.set · false) do
227-
isRflProof thm.proof
228-
if r then
229-
trace[Meta.Tactic.simp.rflAttrMismatch] "theorem {thm.proof} is no longer rfl"
221+
if inErasedSet thm then continue
222+
if rflOnly then
223+
let isRfl := thm.isRfl (← getEnv)
224+
if !isRfl then
225+
if debug.tactic.simp.checkRflAttr.get (← getOptions) &&
226+
experimental.tactic.simp.useRflAttr.get (← getOptions) then
227+
let isRflOld ← withOptions (experimental.tactic.simp.useRflAttr.set · false) do
228+
isRflProof thm.proof
229+
if isRflOld then
230+
logWarning "theorem {thm.proof} is no longer rfl"
231+
continue
232+
if let some result ← tryTheoremWithExtraArgs? e thm numExtraArgs then
233+
trace[Debug.Meta.Tactic.simp] "rewrite result {e} => {result.expr}"
234+
return some result
230235
return none
231236

232237
/--

src/Lean/Meta/Tactic/Simp/SimpTheorems.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ register_builtin_option experimental.tactic.simp.useRflAttr : Bool := {
2020
descr := "use `rfl` attribute rather than theorem body to decide rfl-ness"
2121
}
2222

23+
register_builtin_option debug.tactic.simp.checkRflAttr : Bool := {
24+
defValue := false
25+
descr := "if true, whenever `dsimp` fails to apply a rewrite rule because it is not marked as \
26+
`rfl`, check whether it would have been considered as a rfl theorem before the introduction of \
27+
the `rfl` attribute, and warn if it was. Note that this is a costly check."
28+
}
29+
2330
/--
2431
An `Origin` is an identifier for simp theorems which indicates roughly
2532
what action the user took which lead to this theorem existing in the simp set.

0 commit comments

Comments
 (0)