Skip to content

Commit e2fef66

Browse files
authored
Merge pull request #1589 from GaloisInc/goal-eval-unint-Nat
Make `goal_eval_unint` handle functions with arguments of type `Nat`.
2 parents a134e4a + 60e5a48 commit e2fef66

File tree

1 file changed

+16
-0
lines changed
  • saw-core-what4/src/Verifier/SAW/Simulator

1 file changed

+16
-0
lines changed

saw-core-what4/src/Verifier/SAW/Simulator/What4.hs

+16
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,8 @@ applyUnintApp sym app0 v =
961961
VCtorApp i ps xv -> foldM (applyUnintApp sym) app' =<< traverse force (ps++xv)
962962
where app' = suffixUnintApp ("_" ++ (Text.unpack (identBaseName (primName i)))) app0
963963
VNat n -> return (suffixUnintApp ("_" ++ show n) app0)
964+
VBVToNat w v' -> applyUnintApp sym app' v'
965+
where app' = suffixUnintApp ("_" ++ show w) app0
964966
TValue (suffixTValue -> Just s)
965967
-> return (suffixUnintApp s app0)
966968
VFun _ _ ->
@@ -1399,6 +1401,7 @@ data ArgTerm
13991401
-- ^ length, element type, list, index
14001402
| ArgTermPairLeft ArgTerm
14011403
| ArgTermPairRight ArgTerm
1404+
| ArgTermBVToNat Natural ArgTerm
14021405

14031406
-- | Reassemble a saw-core term from an 'ArgTerm' and a list of parts.
14041407
-- The length of the list should be equal to the number of
@@ -1468,6 +1471,10 @@ reconstructArgTerm atrm sc ts =
14681471
do (x1, ts1) <- parse at1 ts0
14691472
x <- scPairRight sc x1
14701473
return (x, ts1)
1474+
ArgTermBVToNat w at1 ->
1475+
do (x1, ts1) <- parse at1 ts0
1476+
x <- scBvToNat sc w x1
1477+
pure (x, ts1)
14711478

14721479
parseList :: [ArgTerm] -> [Term] -> IO ([Term], [Term])
14731480
parseList [] ts0 = return ([], ts0)
@@ -1519,6 +1526,15 @@ mkArgTerm sc ty val =
15191526
do x <- termOfTValue sc tval
15201527
pure (ArgTermConst x)
15211528

1529+
(_, VNat n) ->
1530+
do x <- scNat sc n
1531+
pure (ArgTermConst x)
1532+
1533+
(_, VBVToNat w v) ->
1534+
do let w' = fromIntegral w -- FIXME: make w :: Natural to avoid fromIntegral
1535+
x <- mkArgTerm sc (VVecType w' VBoolType) v
1536+
pure (ArgTermBVToNat w' x)
1537+
15221538
_ -> fail $ "could not create uninterpreted function argument of type " ++ show ty
15231539

15241540
termOfTValue :: SharedContext -> TValue (What4 sym) -> IO Term

0 commit comments

Comments
 (0)