Zulip Chat Archive

Stream: lean4

Topic: Instantiating MVars in decls


Jannis Limperg (Aug 19 2021 at 11:28):

I just wrote this function:

def instantiateMVarsInMVarType (mvarId : MVarId) : MetaM Expr := do
  let type  instantiateMVars ( getMVarDecl mvarId).type
  setMVarType mvarId type
  return type

I was wondering why this isn't defined in the stdlib (or maybe I just didn't find it). Isn't it a good idea to replace an expression with its mvar-instantiated counterpart whenever possible?

Leonardo de Moura (Aug 20 2021 at 17:00):

We have

def instantiateMVarDeclMVars (mctx : MetavarContext) (mvarId : MVarId) : MetavarContext :=

which instantiates all assigned metavariables in the MetavarDecl for mvarId.
It is not just the type, but the local context too.
We used this function in the by tac implementation. It is executed at the beginning. I can see it may be useful for tactics like the one you are building.

Jannis Limperg (Aug 20 2021 at 17:20):

Ah nice, thanks! I'll continue to do this sort of caching then.


Last updated: Dec 20 2023 at 11:08 UTC