Skip to content

Commit 0907c55

Browse files
committed
Add a proof_checkpoint command that captures and
allows the user to restore proof states.
1 parent 0efff4b commit 0907c55

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/SAWScript/Interpreter.hs

+14
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,20 @@ primitives = Map.fromList
896896
, "subshell and resume execution."
897897
]
898898

899+
, prim "proof_checkpoint" "ProofScript (() -> ProofScript ())"
900+
(pureVal proof_checkpoint)
901+
Experimental
902+
[ "Capture the current state of the proof and return a"
903+
, "ProofScript monadic action that, if invoked, will reset the"
904+
, "state of the proof back to to what it was at the"
905+
, "moment checkpoint was invoked."
906+
, ""
907+
, "NOTE that this facility is highly experimental and may not"
908+
, "be entirely reliable. It is intended only for proof development"
909+
, "where it can speed up the process of experimenting with"
910+
, "mid-proof changes. Finalized proofs should not use this facility."
911+
]
912+
899913
, prim "define" "String -> Term -> TopLevel Term"
900914
(pureVal definePrim)
901915
Current

src/SAWScript/Value.hs

+9
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,15 @@ checkpoint = TopLevel_ $
624624
do printOutLnTop Info "Restoring state from checkpoint"
625625
restoreCheckpoint chk
626626

627+
-- | Capture the current proof state and return an
628+
-- action that, if invoked, resets the state back to that point.
629+
proof_checkpoint :: ProofScript (() -> ProofScript ())
630+
proof_checkpoint =
631+
do ps <- get
632+
return $ \_ ->
633+
do scriptTopLevel (printOutLnTop Info "Restoring proof state from checkpoint")
634+
put ps
635+
627636
throwTopLevel :: String -> TopLevel a
628637
throwTopLevel msg = do
629638
pos <- getPosition

0 commit comments

Comments
 (0)