@@ -247,13 +247,22 @@ def getProofStatus (proofState : ProofSnapshot) : M m String := do
247
247
| _ => return "Incomplete: open goals remain"
248
248
249
249
/--
250
- Returns a list of pairs of metavariables and their assignments from a proof state.
251
- Each pair contains the MVarId and its assigned Expr.
250
+ Returns a list of newly assigned metavariables and their expressions,
251
+ comparing the current proof state with an optional old proof state.
252
+ If no old state is provided, returns all assigned MVars.
252
253
-/
253
- def getAssignedMVars (proofState : ProofSnapshot) : M m (List (MVarId × Expr)) := do
254
+ def getNewlyAssignedMVars (proofState : ProofSnapshot) (oldProofState? : Option ProofSnapshot := none) :
255
+ M m (List (MVarId × Expr)) := do
256
+ -- Get all goals from both states
257
+ let allGoals := match oldProofState? with
258
+ | none => proofState.tacticState.goals
259
+ | some oldState =>
260
+ (proofState.tacticState.goals ++ oldState.tacticState.goals).eraseDups
261
+
262
+ -- Check which have assignments in new state
254
263
let (assignments, _) ← proofState.runMetaM do
255
264
let mut assignments := []
256
- for goalId in proofState.tacticState.goals do
265
+ for goalId in allGoals do
257
266
match proofState.metaState.mctx.getExprAssignmentCore? goalId with
258
267
| none => continue
259
268
| some pf => do
@@ -262,31 +271,6 @@ def getAssignedMVars (proofState : ProofSnapshot) : M m (List (MVarId × Expr))
262
271
return assignments
263
272
return assignments
264
273
265
- /--
266
- Returns a list of newly assigned metavariables and their expressions,
267
- comparing the current proof state with an optional old proof state.
268
- If no old state is provided, returns all assigned MVars.
269
- Returns assignments from both states, preferring new assignments in case of conflicts.
270
- -/
271
- def getNewlyAssignedMVars (proofState : ProofSnapshot) (oldProofState? : Option ProofSnapshot := none) :
272
- M m (List (MVarId × Expr)) := do
273
- let newAssignments ← getAssignedMVars proofState
274
- match oldProofState? with
275
- | none => return newAssignments
276
- | some oldState => do
277
- let oldAssignments ← getAssignedMVars oldState
278
- -- Get all assignments from both states, preferring new assignments
279
- let mut result := []
280
- -- First add all new assignments
281
- for assignment in newAssignments do
282
- result := assignment :: result
283
- -- Then add old assignments that don't have a corresponding new one
284
- for (mvarId, expr) in oldAssignments do
285
- if !newAssignments.any (·.1 == mvarId) then
286
- result := (mvarId, expr) :: result
287
-
288
- return result
289
-
290
274
/--
291
275
Verifies that all assigned goals in the proof state have valid assignments that type check.
292
276
Returns either "OK" or an error message describing the first failing goal.
0 commit comments