The generalized rewriting tactic #
This module defines the core of the grw/grewrite tactic.
This file provides two implementations of the tactic:
- The simple implementation uses
kabstractto determine where to rewrite, and then callsMVarId.gcongrto prove that the rewrite is valid. This is used bynth_grwandgrw' - The more sophisticated implementation has its own congruence loop, applying
gcongrlemmas to create the replacement expression, while at the same time proving that this is related to the original expression. This is used bygrwandapply_rw.
The result returned by Lean.MVarId.grewrite.
- eNew : Lean.Expr
The rewritten expression
- impProof : Lean.Expr
The proof of the implication. The direction depends on the argument
forwardImp. - mvarIds : List Lean.MVarId
The new side goals
- lctx? : Option Lean.LocalContext
The outermost local context in which the rewrite makes sense. If the rewrite does not involve bound variables, this is
none. This is used for fixing the generated info tree, so that the "Expected Type" is displayed correctly.
Instances For
Configures the behavior of the rewrite and rw tactics.
- useRewrite : Bool
When
useRewrite = true, switch to using the defaultrewritetactic when the goal is and equality or iff. - implicationHyp : Bool
When
implicationHyp = true, interpret the rewrite rule as an implication. - useKAbstract : Bool
Whether to use
kabstractto find the rewrites locations.
Instances For
Rewrite e using the relation hrel : x ~ y, and construct an implication proof
using the gcongr tactic to discharge this goal.
if forwardImp = true, we prove that e → eNew; otherwise eNew → e.
If symm = false, we rewrite e to eNew := e[x/y]; otherwise eNew := e[y/x].
The code aligns with Lean.MVarId.rewrite as much as possible.
Equations
- One or more equations did not get rendered due to their size.