Lean4
/-- `modifyLocalContext mvarId f` updates the local context of the metavariable
`mvarId` with `f`. The new local context must contain the same fvars as the old
local context and the types (and values, if any) of the fvars in the new local
context must be defeq to their equivalents in the old local context.
If `mvarId` does not refer to a declared metavariable, nothing happens.
-/
def modifyLocalContext [MonadMCtx m] (mvarId : MVarId) (f : LocalContext → LocalContext) : m Unit :=
modifyMetavarDecl mvarId fun mdecl ↦ { mdecl with lctx := f mdecl.lctx }