Skip to content

Commit

Permalink
Update saw-core submodule to fix addsimp crash.
Browse files Browse the repository at this point in the history
This patch includes PR GaloisInc/saw-core#112, which
implements error handling using the Maybe monad for
the creation of rewrite rules from equational theorems.

Fixes #319.
  • Loading branch information
Brian Huffman committed Dec 9, 2020
1 parent 0748c96 commit a9f4656
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
28 changes: 17 additions & 11 deletions src/SAWScript/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,17 +1021,23 @@ beta_reduce_term (TypedTerm schema t) = do
t' <- io $ betaNormalize sc t
return (TypedTerm schema t')

addsimp :: Theorem -> Simpset -> Simpset
addsimp (Theorem (Prop t) _stats) ss = addRule (ruleOfProp t) ss

addsimp' :: Term -> Simpset -> Simpset
addsimp' t ss = addRule (ruleOfProp t) ss

addsimps :: [Theorem] -> Simpset -> Simpset
addsimps thms ss = foldr addsimp ss thms

addsimps' :: [Term] -> Simpset -> Simpset
addsimps' ts ss = foldr (\t -> addRule (ruleOfProp t)) ss ts
addsimp :: Theorem -> Simpset -> TopLevel Simpset
addsimp (Theorem (Prop t) _stats) ss =
case ruleOfProp t of
Nothing -> fail "addsimp: theorem not an equation"
Just rule -> pure (addRule rule ss)

addsimp' :: Term -> Simpset -> TopLevel Simpset
addsimp' t ss =
case ruleOfProp t of
Nothing -> fail "addsimp': theorem not an equation"
Just rule -> pure (addRule rule ss)

addsimps :: [Theorem] -> Simpset -> TopLevel Simpset
addsimps thms ss = foldM (flip addsimp) ss thms

addsimps' :: [Term] -> Simpset -> TopLevel Simpset
addsimps' ts ss = foldM (flip addsimp') ss ts

print_type :: Term -> TopLevel ()
print_type t = do
Expand Down
8 changes: 4 additions & 4 deletions src/SAWScript/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,22 +1427,22 @@ primitives = Map.fromList
]

, prim "addsimp" "Theorem -> Simpset -> Simpset"
(pureVal addsimp)
(funVal2 addsimp)
Current
[ "Add a proved equality theorem to a given simplification rule set." ]

, prim "addsimp'" "Term -> Simpset -> Simpset"
(pureVal addsimp')
(funVal2 addsimp')
Current
[ "Add an arbitrary equality term to a given simplification rule set." ]

, prim "addsimps" "[Theorem] -> Simpset -> Simpset"
(pureVal addsimps)
(funVal2 addsimps)
Current
[ "Add proved equality theorems to a given simplification rule set." ]

, prim "addsimps'" "[Term] -> Simpset -> Simpset"
(pureVal addsimps')
(funVal2 addsimps')
Current
[ "Add arbitrary equality terms to a given simplification rule set." ]

Expand Down

0 comments on commit a9f4656

Please sign in to comment.