Skip to content

Commit 924c3a8

Browse files
committed
wip
1 parent 6ed048a commit 924c3a8

File tree

6 files changed

+68
-20
lines changed

6 files changed

+68
-20
lines changed

lib/common/Pulse.Lib.Core.fsti

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ inline_for_extraction instance non_informative_loc_id
450450
: NonInformative.non_informative loc_id
451451
= { reveal = (fun x -> reveal x) <: NonInformative.revealer loc_id }
452452

453-
val loc : loc_id -> slprop
453+
val loc : loc_id -> timeless_slprop
454454

455455
val loc_get () : stt_ghost loc_id emp_inames emp (fun l -> loc l)
456456
val loc_dup l : stt_ghost unit emp_inames (loc l) (fun _ -> loc l ** loc l)
@@ -460,6 +460,12 @@ val on (l:loc_id) ([@@@mkey] p:slprop) : slprop
460460
val on_intro #l p : stt_ghost unit emp_inames (loc l ** p) (fun _ -> loc l ** on l p)
461461
val on_elim #l p : stt_ghost unit emp_inames (loc l ** on l p) (fun _ -> loc l ** p)
462462

463+
val timeless_on (l:loc_id) (p : slprop)
464+
: Lemma
465+
(requires timeless p)
466+
(ensures timeless (on l p))
467+
[SMTPat (timeless (on l p))]
468+
463469
[@@Tactics.Typeclasses.tcclass; erasable]
464470
type placeless (p: slprop) =
465471
l:loc_id -> l':loc_id -> stt_ghost unit emp_inames (on l p) (fun _ -> on l' p)
@@ -510,6 +516,9 @@ val later_star p q : squash (later (p ** q) == later p ** later q)
510516
val later_exists (#t: Type) (f:t->slprop) : stt_ghost unit emp_inames (later (exists* x. f x)) (fun _ -> exists* x. later (f x))
511517
val exists_later (#t: Type) (f:t->slprop) : stt_ghost unit emp_inames (exists* x. later (f x)) (fun _ -> later (exists* x. f x))
512518

519+
val later_on l p : stt_ghost unit emp_inames (later (on l p)) (fun _ -> on l (later p))
520+
val on_later l p : stt_ghost unit emp_inames (on l (later p)) (fun _ -> later (on l p))
521+
513522
//////////////////////////////////////////////////////////////////////////
514523
// Equivalence
515524
//////////////////////////////////////////////////////////////////////////

lib/core/Pulse.Lib.Core.fst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ let on l p = p
196196
let on_intro p = admit ()
197197
let on_elim p = admit ()
198198

199+
let timeless_on = admit ()
200+
199201
let placeless_emp = admit ()
200202
let placeless_star _ _ = admit ()
201203
let placeless_pure _ = admit ()
@@ -241,6 +243,9 @@ let exists_later #t f =
241243
let h: squash ((exists* x. later (f x)) `implies` later (exists* x. f x)) = h in
242244
A.implies_elim _ _
243245

246+
let later_on = admit ()
247+
let on_later = admit ()
248+
244249
//////////////////////////////////////////////////////////////////////////
245250
// Equivalence
246251
//////////////////////////////////////////////////////////////////////////

lib/pulse/lib/Pulse.Lib.BetterInv.fst

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ghost fn placeless_inv i p {| inst: placeless p |} : placeless (inv i p) = l1 l2
2828
loc_gather l1 #l_;
2929
drop_ (move_tag l_ l' p _ _);
3030
ghost_impersonate l2 (C.inv i (on l' p)) (on l2 (inv i p)) fn _ {
31-
fold move_tag l2 l' p (aux inst l2 l') (aux inst l' l2);
31+
fold move_tag l2 l' p (aux #p inst l2 l') (aux #p inst l' l2);
3232
loc_dup l2;
3333
fold inv i p;
3434
on_intro (inv i p);
@@ -76,3 +76,27 @@ ghost fn dup_inv i p () : duplicable_f (inv i p) = {
7676

7777
instance duplicable_inv i p : duplicable (inv i p) =
7878
{ dup_f = dup_inv i p }
79+
80+
open PulseCore.Observability
81+
82+
unobservable fn with_inv_unobs u#a (#a: Type u#a) #is (i: iname { not (mem_inv is i) }) (p: slprop) pre (post: a->slprop)
83+
(k: unit -> stt_atomic a #Neutral is (pre ** later p) (fun x -> post x ** later p))
84+
opens is
85+
preserves inv i p
86+
requires pre
87+
returns x:a
88+
ensures post x
89+
{
90+
unfold inv i p; with l_ l' f g. _;
91+
assume pure (inames_subset (add_inv is i) is);
92+
let x = with_invariant #a #Neutral #pre #post #is #(on l' p) i fn _ {
93+
later_on l' p;
94+
// { let g=g; g() };
95+
admit ();
96+
let x = k ();
97+
on_later l' p;
98+
x
99+
};
100+
admit ();
101+
fold inv i p;
102+
}

lib/pulse/lib/Pulse.Lib.ConditionVar.fst

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ module U32 = FStar.UInt32
2121
module OR = Pulse.Lib.OnRange
2222
module SLT = Pulse.Lib.SLPropTable
2323
module Box = Pulse.Lib.Box
24-
25-
instance assume_box_is_atomic (r: Box.box U32.t) p i :
26-
is_send (pts_to r #p i) =
27-
admit ()
2824

2925
noeq
3026
type cvar_t_core = {
@@ -97,6 +93,8 @@ let cvar_inv (b: cvar_t_core) (p:slprop)
9793
pure (Seq.length preds == n) **
9894
maybe_holds v p preds
9995

96+
instance is_send_cvar_inv b p : is_send (cvar_inv b p) = admit ()
97+
10098
let cvar (b: cvar_t) (p:slprop)
10199
: slprop
102100
= exists* l'. in_same_process l' **
@@ -171,7 +169,6 @@ ensures
171169
ensures later (on l <| cvar_inv b.core p)
172170
{
173171
later_elim _;
174-
admit ();
175172
is_send_elim_on (cvar_inv b.core p) #_;
176173
unfold cvar_inv;
177174
Box.gather b.core.r;
@@ -185,7 +182,9 @@ ensures
185182
rewrite (istar preds) as (maybe_holds 1ul p preds);
186183
Box.share b.core.r;
187184
fold (cvar_inv b.core p);
188-
later_intro (cvar_inv b.core p);
185+
is_send_intro_on (cvar_inv b.core p) l;
186+
later_intro (on l <| cvar_inv b.core p);
187+
drop_ (in_same_process l);
189188
drop_ (Box.pts_to b.core.r #0.5R _)
190189
};
191190
drop_ (inv _ _)
@@ -267,13 +266,14 @@ ensures
267266
(if res then p else SLT.pts_to b.core.tab i #0.5R p)
268267
{
269268
later_elim _;
270-
admit ();
269+
is_send_elim_on (cvar_inv b.core q) #_;
271270
unfold cvar_inv;
272271
let vv = read_atomic_box b.core.r;
273272
if (vv = 0ul)
274273
{
275274
fold (cvar_inv b.core q);
276-
later_intro (cvar_inv b.core q);
275+
is_send_intro_on (cvar_inv b.core q) l;
276+
later_intro (on l <| cvar_inv b.core q);
277277
drop_ (later_credit 1);
278278
false;
279279
}
@@ -306,7 +306,8 @@ ensures
306306
rewrite (istar preds') as (maybe_holds v q preds');
307307
// fold (maybe_holds v q preds');
308308
fold (cvar_inv b.core q);
309-
later_intro (cvar_inv b.core q);
309+
is_send_intro_on (cvar_inv b.core q) l;
310+
later_intro (on l <| cvar_inv b.core q);
310311
drop_ (SLT.pts_to b.core.tab i #0.5R _);
311312
true
312313
}
@@ -448,7 +449,7 @@ opens
448449
SLT.pts_to b.core.tab k #0.5R p2)
449450
{
450451
later_elim _;
451-
admit ();
452+
is_send_elim_on (cvar_inv b.core q) #_;
452453
unfold cvar_inv;
453454
with v preds. assert (maybe_holds v q preds);
454455
get_predicate_at_i b.core.tab i (p1 ** p2) preds;
@@ -482,7 +483,8 @@ opens
482483
// step ();
483484
rewrite equiv (istar preds') q as maybe_holds v q preds';
484485
fold (cvar_inv b.core q);
485-
later_intro (cvar_inv b.core q);
486+
is_send_intro_on (cvar_inv b.core q) l;
487+
later_intro (on l <| cvar_inv b.core q);
486488
drop_ (SLT.pts_to b.core.tab i #0.5R emp);
487489
}
488490
else
@@ -491,7 +493,8 @@ opens
491493
rewrite_istar preds preds' i p1 p2 q;
492494
rewrite istar preds' as maybe_holds v q preds';
493495
fold (cvar_inv b.core q);
494-
later_intro (cvar_inv b.core q);
496+
is_send_intro_on (cvar_inv b.core q) l;
497+
later_intro (on l <| cvar_inv b.core q);
495498
drop_ (SLT.pts_to b.core.tab i #0.5R emp);
496499
}
497500
};

lib/pulse/lib/Pulse.Lib.SpinLock.fst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ module U32 = FStar.UInt32
2424
module B = Pulse.Lib.Box
2525
module GR = Pulse.Lib.GhostReference
2626
module CInv = Pulse.Lib.CancellableInvariant
27-
28-
instance assume_box_is_atomic (r: B.box U32.t) i :
29-
is_send (pts_to r #1.0R i) =
30-
admit ()
3127

3228
let lock_inv_aux l' (r:B.box U32.t) (gr:GR.ref U32.t) (v:slprop) : slprop =
3329
exists* i p. pts_to r #1.0R i **
@@ -37,7 +33,7 @@ let lock_inv_aux l' (r:B.box U32.t) (gr:GR.ref U32.t) (v:slprop) : slprop =
3733
(i =!= 0ul ==> p == 0.5R))
3834

3935
let is_send_if (i: U32.t) (v: slprop) (inst: is_send v) : is_send (if i = 0ul then v else emp) =
40-
if i = 0ul then inst else is_send_placeless emp #placeless_emp
36+
if i = 0ul then inst else is_send_placeless emp
4137

4238
instance is_send_lock_inv_aux l' r gr v : is_send (lock_inv_aux l' r gr v) =
4339
Tactics.Typeclasses.solve

lib/pulse/lib/pledge/Pulse.Lib.SendableTrade.fst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@ let trade (#is:inames) (hyp concl:slprop) =
2727
exists* extra inst f. extra ** trade_elim_exists is hyp extra concl inst f
2828

2929
ghost fn is_send_trade #is (p1 p2: slprop) : is_send (trade #is p1 p2) = l l' {
30-
admit ()
30+
ghost_impersonate l (on l (trade #is p1 p2)) (on l' (trade #is p1 p2)) fn _ {
31+
on_elim (trade #is p1 p2);
32+
unfold trade #is p1 p2; with extra inst f. _;
33+
on_intro extra;
34+
is_send_elim extra #inst l';
35+
ghost_impersonate l' (on l' extra ** trade_elim_exists is p1 extra p2 inst f)
36+
(on l' (trade #is p1 p2)) fn _ {
37+
on_elim extra;
38+
fold trade #is p1 p2;
39+
on_intro (trade #is p1 p2);
40+
}
41+
}
3142
}
3243

3344
ghost

0 commit comments

Comments
 (0)