Skip to content

Commit 009c0b5

Browse files
committed
Unify implicit type arguments in slprops.
1 parent 29e3219 commit 009c0b5

File tree

6 files changed

+37
-60
lines changed

6 files changed

+37
-60
lines changed

lib/pulse/lib/Pulse.Lib.Array.Core.fst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ fn mask_alloc_with_vis u#a (elt: Type u#a) {| small_type u#a |}
238238
let arr: array elt = { base_ref = b; base_len = SZ.v n; length = SZ.v n; offset = 0; alloc_loc = l; vis };
239239
rewrite each b as lptr_of arr;
240240
assert pure (v `Map.equal` mk_carrier' arr 1.0R (Seq.create (SZ.v n) None) (fun _ -> l_True) (vis l));
241+
rewrite each hide (SZ.v n) as arr.base_len;
241242
fold pts_to_mask arr (Seq.create (SZ.v n) None) (fun _ -> l_True);
242243
arr
243244
}
@@ -290,6 +291,7 @@ ghost fn pcm_rw u#a (#t: Type u#a)
290291
let i = get_mask_idx m2 (length a2);
291292
assert pure (mask_nonempty m2 (length a2) ==>
292293
Map.sel (mk_carrier' a2 p2 s2 m2 (process_of l)) (i + a2.offset) == Some ((Seq.index s2 i, process_of l), p2));
294+
rewrite each a1.base_len as a2.base_len;
293295
fold pts_to_mask a2 #p2 s2 m2;
294296
}
295297

lib/pulse/lib/Pulse.Lib.GhostPCMReference.fst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ fn read u#a
7171
returns v:(v:a { compatible p x v /\ p.refine v })
7272
ensures pts_to r (f v)
7373
{
74-
with inst. unfold small_token u#a inst; let inst = inst; fold small_token inst;
75-
U.downgrade_val (C.ghost_read #(U.raise_t a) #(raise p) r (hide (U.raise_val (reveal x))) (raise_refine p x f));
74+
with inst. assert small_token inst;
75+
U.downgrade_val (C.ghost_read #(U.raise_t #inst a) r (U.raise_val (reveal x)) (raise_refine p x f));
7676
}
7777

7878

@@ -100,8 +100,8 @@ fn write u#a
100100
requires pts_to r x
101101
ensures pts_to r y
102102
{
103-
with inst. unfold small_token u#a inst; let inst = inst; fold small_token inst;
104-
C.ghost_write #(U.raise_t a) #(raise p) r (hide (U.raise_val (reveal x))) (hide (U.raise_val (reveal y)))
103+
with inst. assert small_token inst;
104+
C.ghost_write #(U.raise_t #inst a) r (U.raise_val (reveal x)) (U.raise_val (reveal y))
105105
(raise_upd f)
106106
}
107107

@@ -116,10 +116,9 @@ fn share u#a
116116
ensures pts_to r v0
117117
ensures pts_to r v1
118118
{
119-
with inst. unfold small_token u#a inst; let inst = inst;
119+
with inst. assert small_token inst;
120120
fold small_token inst;
121-
fold small_token inst;
122-
C.ghost_share #_ #(PR.raise pcm) r (U.raise_val v0) (U.raise_val v1)
121+
C.ghost_share #(U.raise_t #inst a) r (U.raise_val v0) (U.raise_val v1)
123122
}
124123

125124
[@@allow_ambiguous]
@@ -135,9 +134,11 @@ fn gather u#a
135134
returns squash (composable pcm v0 v1)
136135
ensures pts_to r (op pcm v0 v1)
137136
{
138-
with inst. assert C.ghost_pcm_pts_to #_ #(raise #a #inst pcm) r (U.raise_val #a #inst v1);
139-
drop_ (small_token inst);
140-
C.ghost_gather #_ #(PR.raise #a #inst pcm) r (U.raise_val #a #inst v0) (U.raise_val #a #inst v1)
137+
with inst0. assert C.ghost_pcm_pts_to r (U.raise_val #a #inst0 v0);
138+
with inst1. assert C.ghost_pcm_pts_to r (U.raise_val #a #inst1 v1);
139+
drop_ (small_token inst1);
140+
rewrite each inst1 as inst0;
141+
C.ghost_gather #(U.raise_t #inst0 a) r (U.raise_val v0) (U.raise_val v1)
141142
}
142143

143144
ghost fn pts_to_not_null u#a (#a:Type u#a)

lib/pulse/lib/Pulse.Lib.PCMReference.fst

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,17 @@ fn read u#a (#a:Type u#a) (#p:pcm a) (r:pcm_ref p) (x:erased a)
7979
returns v:(v:a {compatible p x v /\ p.refine v})
8080
ensures pcm_pts_to r (f v)
8181
{
82-
let inst = pts_to_small r _;
83-
drop_ (small_token u#a _);
84-
fold small_token u#a inst;
85-
U.downgrade_val (C.read #(U.raise_t a) #(raise p) r (hide (U.raise_val (reveal x))) (raise_refine p x f));
82+
with inst. assert small_token inst;
83+
U.downgrade_val (C.read #(U.raise_t #inst a) r (U.raise_val (reveal x)) (raise_refine p x f));
8684
}
8785

8886
fn write u#a (#a:Type u#a) (#p:pcm a) (r:pcm_ref p) (x y:erased a)
8987
(f:frame_preserving_upd p x y)
9088
requires pcm_pts_to r x
9189
ensures pcm_pts_to r y
9290
{
93-
let inst = pts_to_small r _;
94-
drop_ (small_token u#a _);
95-
fold small_token u#a inst;
96-
C.write #(U.raise_t a) #(raise p) r (hide (U.raise_val (reveal x))) (hide (U.raise_val (reveal y)))
91+
with inst. assert small_token inst;
92+
C.write #(U.raise_t #inst a) r (U.raise_val (reveal x)) (U.raise_val (reveal y))
9793
(raise_upd f)
9894
}
9995

@@ -103,11 +99,9 @@ ghost fn share u#a (#a:Type u#a) (#pcm:pcm a) (r:pcm_ref pcm)
10399
ensures pcm_pts_to r v0
104100
ensures pcm_pts_to r v1
105101
{
106-
let inst = pts_to_small r _;
107-
drop_ (small_token u#a _);
108-
fold small_token inst;
102+
with inst. assert small_token inst;
109103
fold small_token inst;
110-
C.share #(U.raise_t a) #(raise pcm) r (U.raise_val v0) (U.raise_val v1);
104+
C.share #(U.raise_t #inst a) r (U.raise_val v0) (U.raise_val v1);
111105
}
112106

113107
[@@allow_ambiguous]
@@ -117,9 +111,9 @@ ghost fn gather u#a (#a:Type u#a) (#pcm:pcm a) (r:pcm_ref pcm) (v0:a) (v1:a)
117111
returns _: squash (composable pcm v0 v1)
118112
ensures pcm_pts_to r (op pcm v0 v1)
119113
{
120-
let inst = pts_to_small r v0;
121-
with inst'. assert C.pcm_pts_to #_ #(raise #a #inst' pcm) r (U.raise_val #a #inst' v1);
122-
rewrite each inst' as inst;
123-
drop_ (small_token u#a inst');
124-
C.gather #(U.raise_t #inst a) #(raise #a #inst pcm) r (U.raise_val #a #inst v0) (U.raise_val #a #inst v1);
114+
with inst0. assert C.pcm_pts_to r (U.raise_val #a #inst0 v0);
115+
with inst1. assert C.pcm_pts_to r (U.raise_val #a #inst1 v1);
116+
drop_ (small_token inst1);
117+
rewrite each inst1 as inst0;
118+
C.gather #(U.raise_t #inst0 a) r (U.raise_val v0) (U.raise_val v1);
125119
}

lib/pulse/lib/Pulse.Lib.Send.fst

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -304,24 +304,6 @@ ghost fn on_exists_intro u#a #l (#a: Type u#a) (p: a -> slprop)
304304
}
305305
}
306306

307-
[@@pulse_eager_intro]
308-
ghost fn on_exists_intro2 u#a u#b #l (#a: Type u#a) (#b: Type u#b)
309-
(p: (x:a -> y:b -> slprop))
310-
requires literally (exists* (x:a) (y:b). on l (p x y))
311-
ensures on l (exists* (x:a) (y:b). p x y)
312-
{
313-
admit ()
314-
}
315-
316-
[@@pulse_eager_intro]
317-
ghost fn on_exists_intro3 u#a u#b u#c #l (#a: Type u#a) (#b: Type u#b) (#c: Type u#c)
318-
(p: (a -> b -> c -> slprop))
319-
requires literally (exists* (x:a) (y:b) (z:c). on l (p x y z))
320-
ensures on l (exists* (x:a) (y:b) (z:c). p x y z)
321-
{
322-
admit()
323-
}
324-
325307
[@@pulse_eager_elim]
326308
ghost fn on_exists_elim u#a #l (#a: Type u#a) (p: a -> slprop)
327309
requires on l (exists* x. p x)
@@ -424,11 +406,13 @@ ghost fn is_send_across_exists' u#a #b #g (#a: Type u#a) (p: a->slprop) {| ((x:a
424406
let is_send_across_exists = is_send_across_exists'
425407

426408
ghost fn is_send_in_same_process p : is_send (in_same_process p) = l l' {
427-
admit ();
428409
ghost_impersonate l
429410
(on l (in_same_process p))
430411
(on l' (in_same_process p))
431412
fn _ {
413+
on_elim (in_same_process p);
414+
unfold in_same_process p;
415+
loc_gather l;
432416
ghost_impersonate l' emp (on l' (in_same_process p)) fn _ {
433417
loc_dup l';
434418
fold in_same_process p;
@@ -463,7 +447,6 @@ let timeless_on_same_process p =
463447
assert_norm (on_same_process p == (exists* l. in_same_process l ** on l p))
464448

465449
ghost fn is_send_on_same_process p : is_send (on_same_process p) = l1 l2 {
466-
admit ();
467450
ghost_impersonate l1
468451
(on l1 (on_same_process p))
469452
(on l2 (on_same_process p))
@@ -503,7 +486,6 @@ ghost fn sendable_intro p {| inst: is_send p |}
503486
}
504487

505488
ghost fn is_send_sendable p : is_send (sendable p) = l1 l2 {
506-
admit ();
507489
ghost_impersonate l1 (on l1 (sendable p)) (on l2 (sendable p)) fn _ {
508490
on_elim (sendable p);
509491
unfold sendable p;

src/checker/Pulse.Checker.Prover.fst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,10 @@ let is_mkey (t:R.term) : bool =
754754
| _ -> false
755755

756756
let binder_is_mkey (b:R.binder) : bool =
757-
List.Tot.existsb is_mkey (R.inspect_binder b).attrs
757+
if List.Tot.existsb is_mkey (R.inspect_binder b).attrs then true else
758+
// Treat type arguments as mkeys, as F* will happily unify terms of different types.
759+
if R.Tv_Type? (R.inspect_ln (R.inspect_binder b).sort) then true else
760+
false
758761

759762
let binder_is_pred (b:R.binder) : option nat =
760763
let doms, c = R.collect_arr_ln (R.inspect_binder b).sort in
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
* Info at Bug174.fst(15,30-15,42):
1+
* Info at Bug174.fst(15,10-15,37):
22
- Expected failure:
3-
- Ill-typed term: !r
4-
- Expected a term of type
5-
fn
6-
requires r |-> Frac 1.0R v
7-
returns x : t
8-
ensures r |-> Frac 1.0R v ** rewrites_to x v
9-
- Assertion failed
10-
- The SMT solver could not prove the query. Use --query_stats for more
11-
details.
12-
- See also Bug174.fst(14,1-15,40)
3+
- Tactic failed
4+
- Cannot prove:
5+
Pulse.Lib.Reference.pts_to r (*?u173*)_
6+
- In the context:
7+
Pulse.Lib.Reference.pts_to r v
138

0 commit comments

Comments
 (0)