File: .lake/packages/lean4/src/lean/Lean/Meta/Tactic/Replace.lean

full_name: Lean.MVarId.replaceTargetEq
code: /--
  Convert the given goal `Ctx |- target` into `Ctx |- targetNew` using an equality proof `eqProof : target = targetNew`.
  It assumes `eqProof` has type `target = targetNew` -/
def _root_.Lean.MVarId.replaceTargetEq (mvarId : MVarId) (targetNew : Expr) (eqProof : Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.replaceTargetEq
code: @[deprecated MVarId.replaceTargetEq (since := "2022-07-15")]
def replaceTargetEq (mvarId : MVarId) (targetNew : Expr) (eqProof : Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.MVarId.replaceTargetDefEq
code: /--
  Convert the given goal `Ctx |- target` into `Ctx |- targetNew`. It assumes the goals are definitionally equal.
  We use the proof term
  ```
  @id target mvarNew
  ```
  to create a checkpoint. -/
def _root_.Lean.MVarId.replaceTargetDefEq (mvarId : MVarId) (targetNew : Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.replaceTargetDefEq
code: @[deprecated MVarId.replaceTargetDefEq (since := "2022-07-15")]
def replaceTargetDefEq (mvarId : MVarId) (targetNew : Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Tactic.Replace.0.Lean.Meta.replaceLocalDeclCore.findMaxFVar
code: private def replaceLocalDeclCore (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult 
goal: StateRefT' IO.RealWorld Lean.LocalDecl Lean.MetaM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Tactic.Replace.0.Lean.Meta.replaceLocalDeclCore
code: private def replaceLocalDeclCore (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult 
goal: Lean.MetaM Lean.Meta.AssertAfterResult

full_name: Lean.MVarId.replaceLocalDecl
code: /--
  Replace type of the local declaration with id `fvarId` with one with the same user-facing name, but with type `typeNew`.
  This method assumes `eqProof` is a proof that the type of `fvarId` is equal to `typeNew`.
  This tactic actually adds a new declaration and (tries to) clear the old one.
  If the old one cannot be cleared, then at least its user-facing name becomes inaccessible.

  The new local declaration is inserted at the soonest point after `fvarId` at which it is
  well-formed. That is, if `typeNew` involves declarations which occur later than `fvarId` in the
  local context, the new local declaration will be inserted immediately after the latest-occurring
  one. Otherwise, it will be inserted immediately after `fvarId`.

  Note: `replaceLocalDecl` should not be used when unassigned pending mvars might be present in
  `typeNew`, as these may later be synthesized to fvars which occur after `fvarId` (by e.g.
  `Term.withSynthesize` or `Term.synthesizeSyntheticMVars`) .
  -/
abbrev _root_.Lean.MVarId.replaceLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult 
goal: Lean.MetaM Lean.Meta.AssertAfterResult

full_name: Lean.Meta.replaceLocalDecl
code: @[deprecated MVarId.replaceLocalDecl (since := "2022-07-15")]
abbrev replaceLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult 
goal: Lean.MetaM Lean.Meta.AssertAfterResult

full_name: Lean.MVarId.replaceLocalDeclDefEq
code: /--
Replace the type of `fvarId` at `mvarId` with `typeNew`.
Remark: this method assumes that `typeNew` is definitionally equal to the current type of `fvarId`.
-/
def _root_.Lean.MVarId.replaceLocalDeclDefEq (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.replaceLocalDeclDefEq
code: @[deprecated MVarId.replaceLocalDeclDefEq (since := "2022-07-15")]
def replaceLocalDeclDefEq (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.MVarId.change
code: /--
Replace the target type of `mvarId` with `typeNew`.
If `checkDefEq = false`, this method assumes that `typeNew` is definitionally equal to the current target type.
If `checkDefEq = true`, throw an error if `typeNew` is not definitionally equal to the current target type.
-/
def _root_.Lean.MVarId.change (mvarId : MVarId) (targetNew : Expr) (checkDefEq := true) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.change
code: @[deprecated MVarId.change (since := "2022-07-15")]
def change (mvarId : MVarId) (targetNew : Expr) (checkDefEq := true) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.MVarId.withReverted
code: /--
Executes the revert/intro pattern, running the continuation `k` after temporarily reverting
the given local variables from the local context of the metavariable `mvarId`,
and then re-introducing the local variables specified by `k`.

- `mvarId` is the goal metavariable to operate on.
- `fvarIds` is an array of `fvarIds` to revert in the order specified.
  An error is thrown if they cannot be reverted in order.
- `clearAuxDeclsInsteadOfRevert` is configuration passed to `Lean.MVarId.revert`.
- `k` is the continuation run once the local variables have been reverted.
  It is provided `mvarId` after the requested variables have been reverted along with the array of reverted variables.
  This array always contains `fvarIds`, but it may contain additional variables that were reverted due to dependencies.
  The continuation returns a value, a new goal, and an _aliasing array_.

Once `k` has completed, one variable is introduced per entry in the aliasing array.
* If the entry is `none`, the variable is just introduced.
* If the entry is `some fv` (where `fv` is a variable from `fvarIds`),
  the variable is introduced and then recorded as an alias of `fv` in the info tree.
  This for example causes the unused variable linter as seeing `fv` and this newly introduced variable as being "the same".

For example, if `k` leaves all the reverted variables in the same order,
having it return `fvars.map .some` as the aliasing array causes those variables to be re-introduced and aliased
to the original local variables.

Returns the value returned by `k` along with the resulting goal after variable introduction.

See `Lean.MVarId.changeLocalDecl` for an example. The motivation is that to work on a local variable,
you need to move it into the goal, alter the goal, and then bring it back into the local context,
all while keeping track of any other local variables that depend on this one.
-/
def _root_.Lean.MVarId.withReverted (mvarId : MVarId) (fvarIds : Array FVarId)
    (k : MVarId → Array FVarId → MetaM (α × Array (Option FVarId) × MVarId))
    (clearAuxDeclsInsteadOfRevert := false) : MetaM (α × MVarId) 
goal: Lean.MetaM (α × Lean.MVarId)

full_name: Lean.MVarId.changeLocalDecl
code: /--
Replaces the type of the free variable `fvarId` with `typeNew`.

If `checkDefEq` is `true` then an error is thrown if `typeNew` is not definitionally
equal to the type of `fvarId`. Otherwise this function assumes `typeNew` and the type
of `fvarId` are definitionally equal.

This function is the same as `Lean.MVarId.changeLocalDecl` but makes sure to push substitution
information into the info tree.
-/
def _root_.Lean.MVarId.changeLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr)
    (checkDefEq := true) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.changeLocalDecl
code: @[deprecated MVarId.changeLocalDecl]
def changeLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (checkDefEq := true) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.MVarId.modifyTarget
code: /--
Modify `mvarId` target type using `f`.
-/
def _root_.Lean.MVarId.modifyTarget (mvarId : MVarId) (f : Expr → MetaM Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.modifyTarget
code: @[deprecated modifyTarget (since := "2022-07-15")]
def modifyTarget (mvarId : MVarId) (f : Expr → MetaM Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.MVarId.modifyTargetEqLHS
code: /--
Modify `mvarId` target type left-hand-side using `f`.
Throw an error if target type is not an equality.
-/
def _root_.Lean.MVarId.modifyTargetEqLHS (mvarId : MVarId) (f : Expr → MetaM Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId

full_name: Lean.Meta.modifyTargetEqLHS
code: @[deprecated MVarId.modifyTargetEqLHS (since := "2022-07-15")]
def modifyTargetEqLHS (mvarId : MVarId) (f : Expr → MetaM Expr) : MetaM MVarId 
goal: Lean.MetaM Lean.MVarId