Skip to content

Commit

Permalink
Add a normalize_term command to experiment with the results
Browse files Browse the repository at this point in the history
of the TermModel evaluator.
  • Loading branch information
robdockins committed Jun 16, 2021
1 parent a27f1e2 commit 8e4eea5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/SAWScript/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import Verifier.SAW.Prim (rethrowEvalError)
import Verifier.SAW.Rewriter
import Verifier.SAW.Testing.Random (prepareSATQuery, runManyTests)
import Verifier.SAW.TypedAST
import qualified Verifier.SAW.Simulator.TermModel as TM

import SAWScript.Position

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


normalize_term :: TypedTerm -> TopLevel TypedTerm
normalize_term tt =
do sc <- getSharedContext
modmap <- io (scGetModuleMap sc)
tm' <- io (TM.normalizeSharedTerm sc modmap mempty mempty (ttTerm tt))
pure tt{ ttTerm = tm' }


unfoldGoal :: [String] -> ProofScript ()
unfoldGoal unints =
execTactic $ tacticChange $ \goal ->
Expand Down
5 changes: 5 additions & 0 deletions src/SAWScript/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,11 @@ primitives = Map.fromList
Experimental
[ "hoist ifs in the current proof goal" ]

, prim "normalize_term" "Term -> Term"
(funVal1 normalize_term)
Experimental
[ "Normalize the given term by performing evaluation in SAWCore." ]

, prim "goal_eval" "ProofScript ()"
(pureVal (goal_eval []))
Current
Expand Down

0 comments on commit 8e4eea5

Please sign in to comment.