feat: add assertExt
This commit is contained in:
parent
feda5e746f
commit
c59fda4c19
1 changed files with 16 additions and 0 deletions
|
|
@ -34,5 +34,21 @@ withMVarContext mvarId $ do
|
|||
assignExprMVar mvarId newMVar;
|
||||
pure newMVar.mvarId!
|
||||
|
||||
/--
|
||||
Convert the given goal `Ctx |- target` into `Ctx |- forall (name : type) -> name = val -> target`.
|
||||
It assumes `val` has type `type` -/
|
||||
def assertExt (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) (hName : Name := `h) : MetaM MVarId := do
|
||||
withMVarContext mvarId $ do
|
||||
checkNotAssigned mvarId `assert;
|
||||
tag ← getMVarTag mvarId;
|
||||
target ← getMVarType mvarId;
|
||||
u ← getLevel type;
|
||||
let hType := mkApp3 (mkConst `Eq [u]) type (mkBVar 0) val;
|
||||
let newType := Lean.mkForall name BinderInfo.default type $ Lean.mkForall hName BinderInfo.default hType target;
|
||||
newMVar ← mkFreshExprSyntheticOpaqueMVar newType tag;
|
||||
rflPrf ← mkEqRefl val;
|
||||
assignExprMVar mvarId (mkApp2 newMVar val rflPrf);
|
||||
pure newMVar.mvarId!
|
||||
|
||||
end Meta
|
||||
end Lean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue