Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make goal_eval_unint handle functions with arguments of type Nat. #1589

Merged
merged 2 commits into from
Feb 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions saw-core-what4/src/Verifier/SAW/Simulator/What4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ applyUnintApp sym app0 v =
VCtorApp i ps xv -> foldM (applyUnintApp sym) app' =<< traverse force (ps++xv)
where app' = suffixUnintApp ("_" ++ (Text.unpack (identBaseName (primName i)))) app0
VNat n -> return (suffixUnintApp ("_" ++ show n) app0)
VBVToNat w v' -> applyUnintApp sym app' v'
where app' = suffixUnintApp ("_" ++ show w) app0
TValue (suffixTValue -> Just s)
-> return (suffixUnintApp s app0)
VFun _ _ ->
Expand Down Expand Up @@ -1399,6 +1401,7 @@ data ArgTerm
-- ^ length, element type, list, index
| ArgTermPairLeft ArgTerm
| ArgTermPairRight ArgTerm
| ArgTermBVToNat Natural ArgTerm

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

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

(_, VNat n) ->
do x <- scNat sc n
pure (ArgTermConst x)

(_, VBVToNat w v) ->
do let w' = fromIntegral w -- FIXME: make w :: Natural to avoid fromIntegral
x <- mkArgTerm sc (VVecType w' VBoolType) v
pure (ArgTermBVToNat w' x)

_ -> fail $ "could not create uninterpreted function argument of type " ++ show ty

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