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

Heapster: existential function output perms #1549

Merged
merged 18 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0d14087
changed function permissions to have existential variables on the out…
Dec 15, 2021
bb22e68
added parsing support for existential output permissions in fun perms
Dec 15, 2021
e08f0d9
finished updating Implication.hs and RustTypes.hs to work with the ne…
Dec 15, 2021
8915682
whoops, small typo in the new def of AstFunPerm
Dec 15, 2021
c35d321
whoops, reassociated the output permissions of a FunPerm to associate…
Dec 15, 2021
3a92f6c
got TypedCrucible.hs updated with existential function outputs permis…
Dec 16, 2021
cc51230
small tweaks to fix compiler warnings
Dec 16, 2021
e252576
started updating SAWTranslation.hs to handle existential function out…
Dec 16, 2021
27c4f39
finished updating all of Heapster to work with existential function o…
Dec 21, 2021
e13b47a
started writing abstractFunVarsForLifetimes
Dec 22, 2021
5bee504
finished implementing abstractFunVarsForLifetimes
Dec 22, 2021
eaa953d
fixed lownedPermVarAndPErm, lownedPermsVars, and lownedPermsToDistPer…
Dec 23, 2021
5c4f510
uncommented string_deref because now it works!
Dec 23, 2021
8974fc2
Merge branch 'master' into heapster/existential-fun-out-perms
Dec 23, 2021
8be2ac9
Update heapster-saw/src/Verifier/SAW/Heapster/Parser.y
Dec 23, 2021
ec95964
added comments to the components of the AstFunPerm type
Dec 23, 2021
c1ac3b3
moved some helper functions to the top of RustTypes.hs and added comm…
Dec 23, 2021
9caf767
whoops, forgot to update the output of the parsing rule that was chan…
Dec 23, 2021
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
4 changes: 2 additions & 2 deletions heapster-saw/examples/rust_data.saw
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ heapster_assume_fun_rename_prim env hashmap_u64_u64_insert_sym "hashmap_u64_u64_
// String::deref
string_deref <- heapster_find_trait_method_symbol env
"core::ops::deref::Deref::deref<String>";
//heapster_assume_fun_rename_prim env string_deref "string_deref"
// "<'a> fn (&'a String) -> &'a str";
heapster_assume_fun_rename_prim env string_deref "string_deref"
"<'a> fn (&'a String) -> &'a str";

// String::fmt
string_fmt <- heapster_find_trait_method_symbol env
Expand Down
22 changes: 16 additions & 6 deletions heapster-saw/src/Verifier/SAW/Heapster/Implication.hs
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ data SimplImpl ps_in ps_out where
-- > x:eq(handle) -o x:fun_perm
SImpl_ConstFunPerm ::
args ~ CtxToRList cargs =>
ExprVar (FunctionHandleType cargs ret) ->
FnHandle cargs ret -> FunPerm ghosts (CtxToRList cargs) ret -> Ident ->
ExprVar (FunctionHandleType cargs ret) -> FnHandle cargs ret ->
FunPerm ghosts (CtxToRList cargs) gouts ret -> Ident ->
SimplImpl (RNil :> FunctionHandleType cargs ret)
(RNil :> FunctionHandleType cargs ret)

Expand Down Expand Up @@ -7397,7 +7397,7 @@ proveVarAtomicImpl x ps mb_p = case mbMatch mb_p of
foldr (\(i::Int,p) rest ->
case p of
Perm_Fun fun_perm
| Just (Refl,Refl,Refl) <- funPermEq3 fun_perm fun_perm' ->
| Just (Refl,Refl,Refl,Refl) <- funPermEq4 fun_perm fun_perm' ->
implCopyConjM x ps i >>> implPopM x (ValPerm_Conj ps)
_ -> rest)
(proveVarAtomicImplUnfoldOrFail x ps mb_p)
Expand Down Expand Up @@ -7712,8 +7712,8 @@ proveVarImplH x p mb_p = case (p, mbMatch mb_p) of
use implStatePermEnv >>>= \env ->
case lookupFunPerm env f of
Just (SomeFunPerm fun_perm, ident)
| [nuMP| Just (Refl,Refl,Refl) |] <-
mbMatch $ fmap (funPermEq3 fun_perm) mb_fun_perm ->
| [nuMP| Just (Refl,Refl,Refl, Refl) |] <-
mbMatch $ fmap (funPermEq4 fun_perm) mb_fun_perm ->
introEqCopyM x (PExpr_Fun f) >>>
implPopM x p >>>
implSimplM Proxy (SImpl_ConstFunPerm x f fun_perm ident)
Expand Down Expand Up @@ -7820,7 +7820,7 @@ distPermsToExDistPerms = emptyMb

-- | Substitute arguments into a function permission to get the existentially
-- quantified input permissions needed on the arguments
funPermExDistIns :: FunPerm ghosts args ret -> RAssign Name args ->
funPermExDistIns :: FunPerm ghosts args gouts ret -> RAssign Name args ->
ExDistPerms ghosts (ghosts :++: args)
funPermExDistIns fun_perm args =
fmap (varSubst (permVarSubstOfNames args)) $ mbSeparate args $
Expand Down Expand Up @@ -8072,6 +8072,16 @@ proveVarsImpl ps
| Refl <- mbLift (fmap RL.prependRNilEq $ mbDistPermsToValuePerms ps) =
proveVarsImplAppend ps

-- | Prove a list of existentially-quantified distinguished permissions and put
-- those proofs onto the stack, and then return the expressions assigned to the
-- existential variables
proveVarsImplEVarExprs :: NuMatchingAny1 r => ExDistPerms vars as ->
ImplM vars s r as RNil (PermExprs vars)
proveVarsImplEVarExprs ps =
proveVarsImpl ps >>>
use implStateVars >>>= \vars ->
fmap (exprsOfSubst . completePSubst vars) getPSubst

-- | Prove a list of existentially-quantified permissions and put the proofs on
-- the stack, similarly to 'proveVarsImpl', but ensure that the existential
-- variables are themselves only instanitated with variables, not arbitrary
Expand Down
4 changes: 3 additions & 1 deletion heapster-saw/src/Verifier/SAW/Heapster/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ permOffset :: { Maybe AstExpr }

funPerm :: { AstFunPerm }
: '(' ctx ')' '.' funPermList '-o' funPermList
{ AstFunPerm (pos $6) $2 $5 $7 }
{ AstFunPerm (pos $6) $2 $5 [] $7 }
| '(' ctx ')' '.' funPermList '-o' '(' ctx ')' '.' funPermList
{ AstFunPerm (pos $6) $2 $5 $8 $11 }

funPermList :: { [(Located String, AstExpr)] }
: 'empty' { [] }
Expand Down
Loading