diff --git a/SciLean/Tactic/LSimp/Main.lean b/SciLean/Tactic/LSimp/Main.lean index b8c8e557..7225bb94 100644 --- a/SciLean/Tactic/LSimp/Main.lean +++ b/SciLean/Tactic/LSimp/Main.lean @@ -642,7 +642,11 @@ partial def processCongrHypothesis (h : Expr) : LSimpM Bool := do return r.proof?.isSome || (xs.size > 0 && lhs != r.expr) /-- Try to rewrite `e` children using the given congruence theorem -/ -partial def trySimpCongrTheorem? (c : SimpCongrTheorem) (e : Expr) : LSimpM (Option Result) := withNewMCtxDepth do +partial def trySimpCongrTheorem? (c : SimpCongrTheorem) (e : Expr) : LSimpM (Option Result) := + -- Looks like that `withNewMCtxDepth` does not work well with `MetaLCtxM` so we need to + -- add `withoutModifyingLCtx` + withoutModifyingLCtx (fun r? => r?.mapM (Result.bindVars ยท)) do + withNewMCtxDepth do trace[Debug.Meta.Tactic.simp.congr] "{c.theoremName}, {e}" let thm โ† mkConstWithFreshMVarLevels c.theoremName let (xs, bis, type) โ† forallMetaTelescopeReducing (โ† inferType thm)