@@ -269,18 +269,26 @@ def verifyGoalAssignment (ctx : ContextInfo) (proofState : ProofSnapshot) (oldPr
269
269
| none => return s! "Goal { oldGoal.name} was not solved"
270
270
| some pf => do
271
271
let pf ← instantiateMVars pf
272
+ let pft ← Meta.inferType pf >>= instantiateMVars
272
273
273
274
-- Check that all MVars in the proof are goals in new state
274
- -- let mvars ← Meta.getMVars pf
275
275
let (_, mvars) ← ctx.runMetaM proofState.metaContext.lctx ((Meta.collectMVars pf).run {})
276
- IO.println s! "Goal { oldGoal.name} = { pf} ({ mvars.result.map (·.name)} )"
276
+ -- IO.println s!"Goal {oldGoal.name} = {pf} ({mvars.result.map (·.name)})"
277
+ let mut pfWithSorries := pf
277
278
for mvar in mvars.result do
278
279
-- If the metavariable in the assignment is a new goal, it's fine.
279
280
unless proofState.tacticState.goals.contains mvar do
280
281
return s! "Goal { oldGoal.name} assignment contains metavariables"
281
282
283
+ -- If the metavariable is a new goal, replace it with sorry so that we can check the proof.
284
+ let sorryTerm ← Meta.mkSorry pft false
285
+ pfWithSorries ← pure $ pfWithSorries.replace (
286
+ fun e => if e == mkMVar mvar then some sorryTerm else none
287
+ )
288
+ let pf := pfWithSorries
289
+ -- IO.println s!"Goal with sorries {oldGoal.name} = {pf}"
290
+
282
291
-- Check that proof has expected type
283
- let pft ← Meta.inferType pf >>= instantiateMVars
284
292
let expectedType ← Meta.inferType (mkMVar oldGoal) >>= instantiateMVars
285
293
unless (← Meta.isDefEq pft expectedType) do
286
294
return s! "Error: proof has type { pft} but goal has type { expectedType} "
0 commit comments