@@ -47,7 +47,9 @@ def Lean.Elab.Tactic.withNondepPropLocation (loc : Location) (atLocal : FVarId
4747namespace Mathlib.Tactic
4848open Lean Meta Elab.Tactic
4949
50- /-- Use the procedure `m` to rewrite the provided goal. -/
50+ /-- Use the procedure `m` to rewrite the provided goal.
51+
52+ Assumes `proc` is not surrounded by backticks. -/
5153def transformAtTarget (m : Expr → ReaderT Simp.Context MetaM Simp.Result) (proc : String)
5254 (failIfUnchanged : Bool) (goal : MVarId) :
5355 ReaderT Simp.Context MetaM (Option MVarId) := do
@@ -56,7 +58,7 @@ def transformAtTarget (m : Expr → ReaderT Simp.Context MetaM Simp.Result) (pro
5658 -- we use expression equality here (rather than defeq) to be consistent with, e.g.,
5759 -- `applySimpResultToTarget`
5860 let unchanged := tgt.cleanupAnnotations == r.expr.cleanupAnnotations
59- if failIfUnchanged && unchanged then throwError "{proc} made no progress on the goal"
61+ if failIfUnchanged && unchanged then throwError "` {proc}` made no progress on the goal"
6062 if r.expr.isTrue then
6163 goal.assign (← mkOfEqTrue (← r.getProof))
6264 pure none
@@ -70,24 +72,28 @@ def transformAtTarget (m : Expr → ReaderT Simp.Context MetaM Simp.Result) (pro
7072
7173The `simpTheorems` of the simp-context carried with `m` will be modified to remove `fvarId`;
7274this ensures that if the procedure `m` involves rewriting by this `SimpTheoremsArray`, then, e.g.,
73- `h : x = y` is not transformed (by rewriting `h`) to `True`. -/
75+ `h : x = y` is not transformed (by rewriting `h`) to `True`.
76+
77+ Assumes `proc` is not surrounded by backticks. -/
7478def transformAtLocalDecl (m : Expr → ReaderT Simp.Context MetaM Simp.Result) (proc : String)
7579 (failIfUnchanged : Bool) (mayCloseGoal : Bool) (fvarId : FVarId) (goal : MVarId) :
7680 ReaderT Simp.Context MetaM (Option MVarId) := do
7781 let ldecl ← fvarId.getDecl
7882 if ldecl.isImplementationDetail then
79- throwError "Cannot run {proc} at {ldecl.userName}, it is an implementation detail"
83+ throwError "Cannot run ` {proc}` at ` {ldecl.userName}` , it is an implementation detail"
8084 let tgt ← instantiateMVars (← fvarId.getType)
8185 let eraseFVarId (ctx : Simp.Context) :=
8286 ctx.setSimpTheorems <| ctx.simpTheorems.eraseTheorem (.fvar fvarId)
8387 let r ← withReader eraseFVarId <| m tgt
8488 -- we use expression equality here (rather than defeq) to be consistent with, e.g.,
8589 -- `applySimpResultToLocalDeclCore`
8690 if failIfUnchanged && tgt.cleanupAnnotations == r.expr.cleanupAnnotations then
87- throwError "{proc} made no progress at {ldecl.userName}"
91+ throwError "` {proc}` made no progress at ` {ldecl.userName}` "
8892 return (← applySimpResultToLocalDecl goal fvarId r mayCloseGoal).map Prod.snd
8993
90- /-- Use the procedure `m` to transform at specified locations (hypotheses and/or goal). -/
94+ /-- Use the procedure `m` to transform at specified locations (hypotheses and/or goal).
95+
96+ Assumes `proc` is not surrounded by backticks. -/
9197def transformAtLocation (m : Expr → ReaderT Simp.Context MetaM Simp.Result) (proc : String)
9298 (loc : Location) (failIfUnchanged : Bool := true ) (mayCloseGoalFromHyp : Bool := false )
9399 -- streamline the most common use case, in which the procedure `m`'s implementation is not
@@ -97,11 +103,13 @@ def transformAtLocation (m : Expr → ReaderT Simp.Context MetaM Simp.Result) (p
97103 withLocation loc
98104 (liftMetaTactic1 ∘ (transformAtLocalDecl m proc failIfUnchanged mayCloseGoalFromHyp · · ctx))
99105 (liftMetaTactic1 (transformAtTarget m proc failIfUnchanged · ctx))
100- fun _ ↦ throwError "{proc} made no progress anywhere"
106+ fun _ ↦ throwError "` {proc}` made no progress anywhere"
101107
102108/-- Use the procedure `m` to transform at specified locations (hypotheses and/or goal).
103109
104- In the wildcard case (`*`), filter out all dependent and/or non-Prop hypotheses. -/
110+ In the wildcard case (`*`), filter out all dependent and/or non-`Prop` hypotheses.
111+
112+ Assumes `proc` is not surrounded by backticks. -/
105113def transformAtNondepPropLocation (m : Expr → ReaderT Simp.Context MetaM Simp.Result)
106114 (proc : String) (loc : Location) (failIfUnchanged : Bool := true )
107115 (mayCloseGoalFromHyp : Bool := false )
@@ -112,6 +120,6 @@ def transformAtNondepPropLocation (m : Expr → ReaderT Simp.Context MetaM Simp.
112120 withNondepPropLocation loc
113121 (liftMetaTactic1 ∘ (transformAtLocalDecl m proc failIfUnchanged mayCloseGoalFromHyp · · ctx))
114122 (liftMetaTactic1 (transformAtTarget m proc failIfUnchanged · ctx))
115- fun _ ↦ throwError "{proc} made no progress anywhere"
123+ fun _ ↦ throwError "` {proc}` made no progress anywhere"
116124
117125end Mathlib.Tactic
0 commit comments