Skip to content

Commit 6ed048a

Browse files
committed
wip
1 parent 6ac211f commit 6ed048a

17 files changed

+94
-294
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ghost fn placeless_inv i p {| inst: placeless p |} : placeless (inv i p) = l1 l2
3636
}
3737
}
3838

39-
ghost fn is_sync_inv i p {| is_sync p |} : is_sync (inv i p) = l1 l2 {
39+
ghost fn is_send_inv i p {| is_send p |} : is_send (inv i p) = l1 l2 {
4040
ghost_impersonate l1 (on l1 (inv i p)) (on l2 (inv i p)) fn _ {
4141
on_elim (inv i p);
4242
unfold inv i p; with l_ l' f g. _;
@@ -47,15 +47,15 @@ ghost fn is_sync_inv i p {| is_sync p |} : is_sync (inv i p) = l1 l2 {
4747
requires on l2 p
4848
ensures on l' p
4949
{
50-
is_sync_elim p l1;
50+
is_send_elim p l1;
5151
let f = f; f ()
5252
};
5353
ghost fn g' ()
5454
requires on l' p
5555
ensures on l2 p
5656
{
5757
let g = g; g ();
58-
is_sync_elim p l2;
58+
is_send_elim p l2;
5959
};
6060
fold move_tag l2 l' p f' g';
6161
loc_dup l2;

lib/pulse/lib/Pulse.Lib.BetterInv.fsti

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ open Pulse.Class.Duplicable
77
val inv (i: iname) (p: slprop) : slprop
88

99
instance val placeless_inv i p {| placeless p |} : placeless (inv i p)
10-
instance val is_sync_inv i p {| is_sync p |} : is_sync (inv i p)
10+
instance val is_send_inv i p {| is_send p |} : is_send (inv i p)
1111
instance val duplicable_inv i p : duplicable (inv i p)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module SLT = Pulse.Lib.SLPropTable
2323
module Box = Pulse.Lib.Box
2424

2525
instance assume_box_is_atomic (r: Box.box U32.t) p i :
26-
is_sync (pts_to r #p i) =
26+
is_send (pts_to r #p i) =
2727
admit ()
2828

2929
noeq
@@ -115,8 +115,8 @@ let recv (b: cvar_t) (p:slprop)
115115
cvar b q **
116116
SLT.pts_to b.core.tab i #0.5R p
117117

118-
instance is_sync_send c p : is_sync (send c p) = Tactics.Typeclasses.solve
119-
instance is_sync_recv c p : is_sync (recv c p) = Tactics.Typeclasses.solve
118+
instance is_send_send c p : is_send (send c p) = Tactics.Typeclasses.solve
119+
instance is_send_recv c p : is_send (recv c p) = Tactics.Typeclasses.solve
120120

121121
fn create (p:slprop)
122122
requires emp
@@ -172,7 +172,7 @@ ensures
172172
{
173173
later_elim _;
174174
admit ();
175-
is_sync_elim_on (cvar_inv b.core p) #_;
175+
is_send_elim_on (cvar_inv b.core p) #_;
176176
unfold cvar_inv;
177177
Box.gather b.core.r;
178178
with v preds. assert (maybe_holds v p preds);

lib/pulse/lib/Pulse.Lib.ConditionVar.fsti

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ val send (c:cvar_t) (p:slprop) : slprop
2727

2828
val recv (c:cvar_t) (p:slprop) : slprop
2929

30-
instance val is_sync_send c p : is_sync (send c p)
31-
instance val is_sync_recv c p : is_sync (recv c p)
30+
instance val is_send_send c p : is_send (send c p)
31+
instance val is_send_recv c p : is_send (recv c p)
3232

3333
fn create (p:slprop)
3434
requires emp

lib/pulse/lib/Pulse.Lib.Mutex.fst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let lock_inv (#a:Type0) (r:B.box a) (v:a -> slprop) : slprop =
4040

4141
let mutex_live #a m #p v = lock_alive m.l #p (lock_inv m.r v)
4242

43-
let is_sync_mutex_live #a m #p v = Tactics.Typeclasses.solve
43+
let is_send_mutex_live #a m #p v = Tactics.Typeclasses.solve
4444

4545
let pts_to mg #p x = pts_to mg #p x
4646

lib/pulse/lib/Pulse.Lib.Mutex.fsti

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ val mutex_live
3636
(#[T.exact (`1.0R)] p:perm)
3737
(v:a -> slprop) : slprop
3838

39-
instance val is_sync_mutex_live #a m #p v : is_sync (mutex_live #a m #p v)
39+
instance val is_send_mutex_live #a m #p v : is_send (mutex_live #a m #p v)
4040

4141
//
4242
// mutex_guard is a ref-like type

lib/pulse/lib/Pulse.Lib.SendSync.fst

Lines changed: 42 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -14,147 +14,6 @@ ghost fn dup_in_same_process p () : duplicable_f (in_same_process p) = {
1414
instance duplicable_in_same_process p : duplicable (in_same_process p) =
1515
{ dup_f = dup_in_same_process p }
1616

17-
let can_see_writes_from (other_loc: loc_id) : slprop =
18-
in_same_process other_loc **
19-
emp // extra assumptions
20-
21-
ghost fn can_see_writes_from_prop other_loc
22-
preserves can_see_writes_from other_loc
23-
ensures in_same_process other_loc
24-
{
25-
unfold can_see_writes_from other_loc;
26-
dup (in_same_process other_loc) ();
27-
fold can_see_writes_from other_loc;
28-
}
29-
30-
ghost fn writes_visible_in_prop other_loc
31-
preserves writes_visible_in other_loc
32-
ensures in_same_process other_loc
33-
{
34-
unfold writes_visible_in other_loc;
35-
with l. assert loc l; loc_dup l;
36-
ghost_impersonate other_loc
37-
(on other_loc (can_see_writes_from l))
38-
(on other_loc (can_see_writes_from l) ** pure (process_of other_loc == process_of l))
39-
fn _ {
40-
on_elim (can_see_writes_from l);
41-
can_see_writes_from_prop l;
42-
on_intro (can_see_writes_from l);
43-
unfold in_same_process l;
44-
loc_gather other_loc #_;
45-
};
46-
fold in_same_process other_loc;
47-
fold writes_visible_in other_loc;
48-
}
49-
50-
51-
[@@deprecated "UNSAFE"]
52-
ghost fn unsafe_attest_can_see_writes_from (other_loc: loc_id)
53-
pre post (k: unit -> stt_ghost unit emp_inames (can_see_writes_from other_loc ** pre)
54-
(fun _ -> can_see_writes_from other_loc ** post))
55-
preserves in_same_process other_loc
56-
requires pre
57-
ensures post
58-
{
59-
dup (in_same_process other_loc) ();
60-
fold can_see_writes_from other_loc;
61-
k ();
62-
drop_ (can_see_writes_from other_loc);
63-
}
64-
65-
[@@deprecated "UNSAFE"]
66-
ghost fn unsafe_attest_writes_visible_in (other_loc: loc_id)
67-
pre post (k: unit -> stt_ghost unit emp_inames (writes_visible_in other_loc ** pre)
68-
(fun _ -> writes_visible_in other_loc ** post))
69-
preserves in_same_process other_loc
70-
requires pre
71-
ensures post
72-
{
73-
unfold in_same_process other_loc;
74-
with l. assert loc l;
75-
on_intro pre;
76-
ghost_impersonate other_loc (on l pre) (on l post) fn _ {
77-
loc_dup other_loc;
78-
fold in_same_process l;
79-
unsafe_attest_can_see_writes_from l (loc other_loc ** on l pre) (loc other_loc ** on l post) fn _ {
80-
on_intro (can_see_writes_from l);
81-
ghost_impersonate l
82-
(on other_loc (can_see_writes_from l) ** on l pre)
83-
(on other_loc (can_see_writes_from l) ** on l post)
84-
fn _ {
85-
loc_dup l;
86-
fold writes_visible_in other_loc;
87-
on_elim pre;
88-
k ();
89-
on_intro post;
90-
unfold writes_visible_in other_loc; with l'. _;
91-
loc_gather l #l';
92-
rewrite each l' as l;
93-
};
94-
on_elim (can_see_writes_from l);
95-
};
96-
drop_ (in_same_process l);
97-
};
98-
on_elim post;
99-
fold in_same_process other_loc;
100-
}
101-
102-
ghost fn is_send_acq (p: slprop) {| inst: is_send p |} (other_loc: loc_id)
103-
preserves can_see_writes_from other_loc
104-
requires on other_loc p
105-
ensures p
106-
{
107-
inst other_loc;
108-
}
109-
110-
ghost fn is_send_rel (p: slprop) {| is_send p |} (other_loc: loc_id)
111-
preserves writes_visible_in other_loc
112-
requires p
113-
ensures on other_loc p
114-
{
115-
unfold writes_visible_in;
116-
with l. assert loc l;
117-
on_intro p;
118-
ghost_impersonate other_loc
119-
(on other_loc (can_see_writes_from l) ** on l p)
120-
(on other_loc (can_see_writes_from l) ** on other_loc p)
121-
fn _ {
122-
on_elim (can_see_writes_from l);
123-
is_send_acq p l;
124-
on_intro p;
125-
on_intro (can_see_writes_from l);
126-
};
127-
fold writes_visible_in other_loc;
128-
}
129-
130-
[@@deprecated "UNSAFE"]
131-
ghost fn unsafe_attest_released (p: slprop) {| is_send p |} (#l:loc_id)
132-
preserves loc l
133-
requires p
134-
ensures on (process_of l) p
135-
{
136-
loc_dup l;
137-
fold in_same_process (process_of l);
138-
unsafe_attest_writes_visible_in (process_of l) p (on (process_of l) p)
139-
fn _ { is_send_rel p (process_of l) };
140-
unfold in_same_process (process_of l);
141-
loc_gather l #_;
142-
}
143-
144-
[@@deprecated "UNSAFE"]
145-
ghost fn unsafe_attest_acquired (p: slprop) {| is_send p |} (#l:loc_id)
146-
preserves loc l
147-
requires on (process_of l) p
148-
ensures p
149-
{
150-
loc_dup l;
151-
fold in_same_process (process_of l);
152-
unsafe_attest_can_see_writes_from (process_of l) (on (process_of l) p) p
153-
fn _ { is_send_acq p (process_of l) };
154-
unfold in_same_process (process_of l);
155-
loc_gather l #_;
156-
}
157-
15817
ghost fn on_star_elim #l (p q: slprop)
15918
requires on l (p ** q)
16019
ensures on l p
@@ -189,64 +48,65 @@ ghost fn on_exists_elim u#a #l (#a: Type u#a) (p: a -> slprop)
18948
}
19049
}
19150

192-
ghost fn is_send_placeless p {| inst: placeless p |} : is_send p = l {
193-
loc_get (); with l0. assert loc l0;
194-
inst l l0;
195-
on_elim p;
196-
drop_ (loc l0);
197-
}
198-
199-
ghost fn is_send_star p q {| is_send p, is_send q |} : is_send (p ** q) = l {
200-
on_star_elim p q;
201-
is_send_acq p l;
202-
is_send_acq q l;
203-
}
204-
205-
ghost fn is_send_exists' u#a (#a: Type u#a) (p: a->slprop) {| ((x:a) -> is_send (p x)) |} :
206-
is_send (exists* x. p x) = l {
207-
on_exists_elim p;
208-
with x. assert on l (p x);
209-
is_send_acq (p x) l;
210-
}
211-
let is_send_exists p = is_send_exists' p
212-
213-
ghost fn is_sync_elim p {| inst: is_sync p |} #l l'
51+
ghost fn is_send_elim p {| inst: is_send p |} #l l'
21452
requires on l p
21553
requires pure (process_of l == process_of l')
21654
ensures on l' p
21755
{
21856
inst l l'
21957
}
22058

221-
ghost fn is_sync_elim_on p {| is_sync p |} #l
59+
ghost fn is_send_elim_on p {| is_send p |} #l
22260
preserves in_same_process l
22361
requires on l p
22462
ensures p
22563
{
22664
unfold in_same_process l;
22765
with l0. assert loc l0;
228-
is_sync_elim p l0;
66+
is_send_elim p l0;
22967
on_elim p;
23068
fold in_same_process l;
23169
}
23270

233-
ghost fn is_sync_intro_on p {| is_sync p |} l
71+
ghost fn is_send_intro_on p {| is_send p |} l
23472
preserves in_same_process l
23573
requires p
23674
ensures on l p
23775
{
23876
unfold in_same_process l;
23977
with l0. assert loc l0;
24078
on_intro p;
241-
is_sync_elim p l;
79+
is_send_elim p l;
24280
fold in_same_process l;
24381
}
24482

245-
ghost fn is_sync_placeless p {| inst: placeless p |} : is_sync p = l l' {
83+
ghost fn is_send_elim_on' p {| is_send p |} #l
84+
preserves loc l
85+
requires on (process_of l) p
86+
ensures p
87+
{
88+
loc_dup l;
89+
fold in_same_process (process_of l);
90+
is_send_elim_on p #_;
91+
drop_ (in_same_process (process_of l));
92+
}
93+
94+
ghost fn is_send_intro_on' p {| is_send p |} l
95+
preserves loc l
96+
requires p
97+
ensures on (process_of l) p
98+
{
99+
loc_dup l;
100+
fold in_same_process (process_of l);
101+
is_send_intro_on p (process_of l);
102+
drop_ (in_same_process (process_of l));
103+
}
104+
105+
ghost fn is_send_placeless p {| inst: placeless p |} : is_send p = l l' {
246106
inst l l'
247107
}
248108

249-
ghost fn is_sync_in_same_process p : is_sync (in_same_process p) = l l' {
109+
ghost fn is_send_in_same_process p : is_send (in_same_process p) = l l' {
250110
ghost_impersonate l
251111
(on l (in_same_process p))
252112
(on l' (in_same_process p))
@@ -262,35 +122,27 @@ ghost fn is_sync_in_same_process p : is_sync (in_same_process p) = l l' {
262122
}
263123
}
264124

265-
ghost fn is_send_of_is_sync p {| is_sync p |} : is_send p = l {
266-
can_see_writes_from_prop l;
267-
unfold in_same_process l; with l0. assert loc l0;
268-
is_sync_elim p l0;
269-
on_elim p;
270-
drop_ (loc l0);
271-
}
272-
273-
ghost fn is_sync_star p q {| is_sync p, is_sync q |} : is_sync (p ** q) = l l' {
125+
ghost fn is_send_star p q {| is_send p, is_send q |} : is_send (p ** q) = l l' {
274126
on_star_elim p q;
275-
is_sync_elim p l';
276-
is_sync_elim q l';
127+
is_send_elim p l';
128+
is_send_elim q l';
277129
on_star_intro p q;
278130
}
279131

280-
ghost fn is_sync_exists' u#a (#a: Type u#a) (p: a->slprop) {| ((x:a) -> is_sync (p x)) |} :
281-
is_sync (exists* x. p x) = l l' {
132+
ghost fn is_send_exists' u#a (#a: Type u#a) (p: a->slprop) {| ((x:a) -> is_send (p x)) |} :
133+
is_send (exists* x. p x) = l l' {
282134
ghost_impersonate l (on l (exists* x. p x)) (on l' (exists* x. p x)) fn _ {
283135
on_elim (exists* x. p x);
284136
with x. assert p x;
285137
on_intro (p x);
286-
is_sync_elim (p x) l';
138+
is_send_elim (p x) l';
287139
ghost_impersonate l' (on l' (p x)) (on l' (exists* x. p x)) fn _ {
288140
on_elim (p x);
289141
on_intro (exists* x. p x)
290142
};
291143
}
292144
}
293-
let is_sync_exists = is_sync_exists'
145+
let is_send_exists = is_send_exists'
294146

295147

296148
inline_for_extraction noextract fn fork'
@@ -299,11 +151,13 @@ inline_for_extraction noextract fn fork'
299151
requires pre
300152
{
301153
loc_get (); with l. assert loc l;
302-
unsafe_attest_released pre #_ #l;
154+
loc_dup l; fold in_same_process (process_of l);
155+
is_send_intro_on pre (process_of l);
156+
drop_ (in_same_process (process_of l));
303157
fork (on (process_of l) pre) #_ #l fn l' {
304-
rewrite on (process_of l) pre as on (process_of l') pre;
305-
unsafe_attest_acquired pre #_ #l';
306-
drop_ (loc l');
158+
fold in_same_process (process_of l);
159+
is_send_elim_on pre #_;
160+
drop_ (in_same_process (process_of l));
307161
f ();
308162
};
309163
}

0 commit comments

Comments
 (0)