Skip to content

Commit 8e4eea5

Browse files
committed
Add a normalize_term command to experiment with the results
of the TermModel evaluator.
1 parent a27f1e2 commit 8e4eea5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/SAWScript/Builtins.hs

+9
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import Verifier.SAW.Prim (rethrowEvalError)
7474
import Verifier.SAW.Rewriter
7575
import Verifier.SAW.Testing.Random (prepareSATQuery, runManyTests)
7676
import Verifier.SAW.TypedAST
77+
import qualified Verifier.SAW.Simulator.TermModel as TM
7778

7879
import SAWScript.Position
7980

@@ -492,6 +493,14 @@ resolveName sc nm =
492493
fallback = fst <$> io (scResolveUnambiguous sc tnm)
493494

494495

496+
normalize_term :: TypedTerm -> TopLevel TypedTerm
497+
normalize_term tt =
498+
do sc <- getSharedContext
499+
modmap <- io (scGetModuleMap sc)
500+
tm' <- io (TM.normalizeSharedTerm sc modmap mempty mempty (ttTerm tt))
501+
pure tt{ ttTerm = tm' }
502+
503+
495504
unfoldGoal :: [String] -> ProofScript ()
496505
unfoldGoal unints =
497506
execTactic $ tacticChange $ \goal ->

src/SAWScript/Interpreter.hs

+5
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,11 @@ primitives = Map.fromList
12091209
Experimental
12101210
[ "hoist ifs in the current proof goal" ]
12111211

1212+
, prim "normalize_term" "Term -> Term"
1213+
(funVal1 normalize_term)
1214+
Experimental
1215+
[ "Normalize the given term by performing evaluation in SAWCore." ]
1216+
12121217
, prim "goal_eval" "ProofScript ()"
12131218
(pureVal (goal_eval []))
12141219
Current

0 commit comments

Comments
 (0)