Skip to content

Commit d012ffe

Browse files
authored
Merge pull request #1549 from GaloisInc/heapster/existential-fun-out-perms
Heapster: existential function output perms
2 parents 0c22f18 + 9caf767 commit d012ffe

File tree

9 files changed

+1071
-679
lines changed

9 files changed

+1071
-679
lines changed

heapster-saw/examples/rust_data.saw

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ heapster_assume_fun_rename_prim env hashmap_u64_u64_insert_sym "hashmap_u64_u64_
309309
// String::deref
310310
string_deref <- heapster_find_trait_method_symbol env
311311
"core::ops::deref::Deref::deref<String>";
312-
//heapster_assume_fun_rename_prim env string_deref "string_deref"
313-
// "<'a> fn (&'a String) -> &'a str";
312+
heapster_assume_fun_rename_prim env string_deref "string_deref"
313+
"<'a> fn (&'a String) -> &'a str";
314314

315315
// String::fmt
316316
string_fmt <- heapster_find_trait_method_symbol env

heapster-saw/src/Verifier/SAW/Heapster/Implication.hs

+16-6
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ data SimplImpl ps_in ps_out where
532532
-- > x:eq(handle) -o x:fun_perm
533533
SImpl_ConstFunPerm ::
534534
args ~ CtxToRList cargs =>
535-
ExprVar (FunctionHandleType cargs ret) ->
536-
FnHandle cargs ret -> FunPerm ghosts (CtxToRList cargs) ret -> Ident ->
535+
ExprVar (FunctionHandleType cargs ret) -> FnHandle cargs ret ->
536+
FunPerm ghosts (CtxToRList cargs) gouts ret -> Ident ->
537537
SimplImpl (RNil :> FunctionHandleType cargs ret)
538538
(RNil :> FunctionHandleType cargs ret)
539539

@@ -7397,7 +7397,7 @@ proveVarAtomicImpl x ps mb_p = case mbMatch mb_p of
73977397
foldr (\(i::Int,p) rest ->
73987398
case p of
73997399
Perm_Fun fun_perm
7400-
| Just (Refl,Refl,Refl) <- funPermEq3 fun_perm fun_perm' ->
7400+
| Just (Refl,Refl,Refl,Refl) <- funPermEq4 fun_perm fun_perm' ->
74017401
implCopyConjM x ps i >>> implPopM x (ValPerm_Conj ps)
74027402
_ -> rest)
74037403
(proveVarAtomicImplUnfoldOrFail x ps mb_p)
@@ -7712,8 +7712,8 @@ proveVarImplH x p mb_p = case (p, mbMatch mb_p) of
77127712
use implStatePermEnv >>>= \env ->
77137713
case lookupFunPerm env f of
77147714
Just (SomeFunPerm fun_perm, ident)
7715-
| [nuMP| Just (Refl,Refl,Refl) |] <-
7716-
mbMatch $ fmap (funPermEq3 fun_perm) mb_fun_perm ->
7715+
| [nuMP| Just (Refl,Refl,Refl, Refl) |] <-
7716+
mbMatch $ fmap (funPermEq4 fun_perm) mb_fun_perm ->
77177717
introEqCopyM x (PExpr_Fun f) >>>
77187718
implPopM x p >>>
77197719
implSimplM Proxy (SImpl_ConstFunPerm x f fun_perm ident)
@@ -7820,7 +7820,7 @@ distPermsToExDistPerms = emptyMb
78207820

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

8075+
-- | Prove a list of existentially-quantified distinguished permissions and put
8076+
-- those proofs onto the stack, and then return the expressions assigned to the
8077+
-- existential variables
8078+
proveVarsImplEVarExprs :: NuMatchingAny1 r => ExDistPerms vars as ->
8079+
ImplM vars s r as RNil (PermExprs vars)
8080+
proveVarsImplEVarExprs ps =
8081+
proveVarsImpl ps >>>
8082+
use implStateVars >>>= \vars ->
8083+
fmap (exprsOfSubst . completePSubst vars) getPSubst
8084+
80758085
-- | Prove a list of existentially-quantified permissions and put the proofs on
80768086
-- the stack, similarly to 'proveVarsImpl', but ensure that the existential
80778087
-- variables are themselves only instanitated with variables, not arbitrary

heapster-saw/src/Verifier/SAW/Heapster/Parser.y

+3-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ permOffset :: { Maybe AstExpr }
205205

206206
funPerm :: { AstFunPerm }
207207
: '(' ctx ')' '.' funPermList '-o' funPermList
208-
{ AstFunPerm (pos $6) $2 $5 $7 }
208+
{ AstFunPerm (pos $6) $2 $5 [] $7 }
209+
| '(' ctx ')' '.' funPermList '-o' '(' ctx ')' '.' funPermList
210+
{ AstFunPerm (pos $6) $2 $5 $8 $11 }
209211

210212
funPermList :: { [(Located String, AstExpr)] }
211213
: 'empty' { [] }

0 commit comments

Comments
 (0)