You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: RCC.v
+8-6Lines changed: 8 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -35,13 +35,14 @@ Module Type RCC.
35
35
{pres:(forall h, P meta_x h -> P meta_e (hwrite x meta_e h))}
36
36
, rgref Γ unit Γ.
37
37
*)
38
-
Parameter rcc_write : forall {Γ Γ'}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}{l:lock}{w:var}{pf:tymember w (ref{lockwitness l | locked}[empty,locked-->unlocked]) Γ}(x:rccref A P R G l)(e:rgref Γ A Γ')
38
+
Parameter rcc_write : forall {Γ Γ'}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}{l:lock}{w:var}{pf:tymember w (ref{lockwitness l | locked}[empty,locked-->unlocked]) Γ}(x:rccref A P R G l)(e:rgref Γ A Γ')`{ESafe 0 _ e}
39
39
(meta_x_deref:rgref Γ A Γ') (meta_e_fold:rgref Γ A Γ')
40
40
{guar:forall h env, G (valueOf _ _ _ env h meta_x_deref) (valueOf _ _ _ env h e) h (hwrite x (valueOf _ _ _ env h e) h)}
41
41
{pres:(forall h env, P (valueOf _ _ _ env h meta_x_deref) h -> P (valueOf _ _ _ env h meta_e_fold) (hwrite x (valueOf _ _ _ env h meta_e_fold) h))}
42
42
, rgref Γ unit Γ'.
43
43
44
44
Parameter rcc_alloc : forall {Γ}{T:Set}{RT:ImmediateReachability T}{CT:Containment T}{FT:rel_fold T} P R G (l:lock) (e:T),
45
+
`(ESafe 0 e) ->
45
46
stable P R -> (* predicate is stable *)
46
47
(forall h, P e h) -> (* predicate is true *)
47
48
precise_pred P -> (* P precise *)
@@ -76,21 +77,22 @@ Module RCCImpl : RCC.
76
77
{pres:(forall h, P meta_x h -> P meta_e (heap_write x meta_e h))}
77
78
: rgref Γ unit Γ :=
78
79
@write' Γ A _ P R G _ x e meta_x meta_e _ _.*)
79
-
ProgramDefinition rcc_write {Γ Γ'}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}{l:lock}{w:var}{pf:tymember w (ref{lockwitness l | locked}[empty,locked-->unlocked]) Γ}(x:rccref A P R G l)(e:rgref Γ A Γ')
80
+
ProgramDefinition rcc_write {Γ Γ'}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}{l:lock}{w:var}{pf:tymember w (ref{lockwitness l | locked}[empty,locked-->unlocked]) Γ}(x:rccref A P R G l)(e:rgref Γ A Γ')`{ESafe 0 _ e}
80
81
(meta_x_deref:rgref Γ A Γ') (meta_e_fold:rgref Γ A Γ')
81
82
{guar:forall h env, G (valueOf _ _ _ env h meta_x_deref) (valueOf _ _ _ env h e) h (hwrite l _ _ _ _ x (valueOf _ _ _ env h e) h)}
82
83
{pres:(forall h env, P (valueOf _ _ _ env h meta_x_deref) h -> P (valueOf _ _ _ env h meta_e_fold) (hwrite _ _ _ _ _ x (valueOf _ _ _ env h meta_e_fold) h))}
83
84
: rgref Γ unit Γ' :=
84
-
@write_imp_exp Γ Γ' A _ P R G _ x e meta_x_deref meta_e_fold guar pres.
85
+
@write_imp_exp Γ Γ' A _ P R G _ x e _ meta_x_deref meta_e_fold guar pres.
85
86
86
87
ProgramDefinition rcc_alloc {Γ}{T:Set}{RT:ImmediateReachability T}{CT:Containment T}{FT:rel_fold T} P R G (l:lock) (e:T)
88
+
`(ESafe 0 _ e)
87
89
`(stable P R) (* predicate is stable *)
88
90
`((forall h, P e h)) (* predicate is true *)
89
91
`(precise_pred P) (* P precise *)
90
92
`(precise_rel R) (* R precise *)
91
93
`(precise_rel G) (* G precise *)
92
94
: rgref Γ (rccref T P R G l) Γ :=
93
-
alloc _ _ _ e _ _ _ _ _.
95
+
alloc _ _ _ e _ _ _ _ _ _.
94
96
Parameter acquire : forall {Γ}(w:var)(l:lock), rgref Γ unit (w:ref{lockwitness l | locked}[empty,locked-->unlocked],Γ).
95
97
Parameter release : forall {Γ}{l:lock}(w:var){pf:(tymember w (ref{lockwitness l | locked}[empty,locked-->unlocked]) Γ)}, rgref Γ unit (tyrem pf).
(** The core problem with folding here is that we want the user (and automated provers!) to see the same dereference on either side of
39
78
G's state. But G applies to elements of A, not [R,G]>>A. We could introduce an internal "cheat_deref" that skipped
40
79
folding, but then the two sides aren't equal, and many automated tactics that treat !e as essentially an uninterpreted
@@ -63,15 +102,15 @@ Axiom dropvar : forall {Γ} (v:var) (t:Set) (tm:tymember v t Γ), rgref Γ unit
63
102
G (!l) e h (heap_write l e h)}
64
103
{pres:(forall h (l:ref{A|P}[R,G]), P (!l) h -> P e (heap_write l e h))}
65
104
, rgref Γ unit Γ.*)
66
-
ProgramAxiom write' : forall {Γ:tyenv}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}(x:ref{A|P}[R,G])(e:A)
105
+
ProgramAxiom write' : forall {Γ:tyenv}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}(x:ref{A|P}[R,G])(e:A)`{ESafe 0 A e}
67
106
(meta_x_deref:A) (meta_e_fold:A)
68
107
(** These meta args are notationally expanded x and e using the identity relation folding *)
69
108
(*{guar:forall h, G (!x) e h (heap_write x e h)} *)
70
109
{guar:forall h, (forall A (fa:rel_fold A), fa = meta_fold) -> G (meta_x_deref) e h (heap_write x e h)}
71
110
(** temporarily not using meta_e_fold... the cases where I needed the "nop" behavior are once where the types are actually equal *)
72
111
{pres:(forall h, P meta_x_deref h -> P meta_e_fold (heap_write x meta_e_fold h))}
73
112
, rgref Γ unit Γ.
74
-
Notation "[ x ]:= e" := (@write' _ _ _ _ _ _ _ x e ({{{!x}}}) ({{{e}}}) _ _) (at level 70).
113
+
Notation "[ x ]:= e" := (@write' _ _ _ _ _ _ _ x e _ ({{{!x}}}) ({{{e}}}) _ _) (at level 70).
75
114
(** TODO: heap writes that update the predicate. Because of the monadic style, we'll actually
76
115
need a new axiom and syntax support for this, to rebind the variable at the strengthened type *)
77
116
@@ -99,6 +138,7 @@ Program Axiom read_imp : forall {Γ}{A B:Set}`{rel_fold A}{P R G}`{hreflexive G}
99
138
100
139
(* Writing with an impure source expression (and direct ref value) *)
101
140
ProgramAxiom write_imp_exp : forall {Γ Γ'}{A:Set}`{rel_fold A}{P R G}`{hreflexive G}(x:ref{A|P}[R,G])(e:rgref Γ A Γ')
141
+
`{ESafe 0 _ e}
102
142
(meta_x_deref:rgref Γ A Γ') (meta_e_fold:rgref Γ A Γ')
103
143
{guar:forall h env, G (valueOf _ _ _ env h meta_x_deref) (valueOf _ _ _ env h e) h (heap_write x (valueOf _ _ _ env h e) h)}
104
144
{pres:(forall h env, P (valueOf _ _ _ env h meta_x_deref) h -> P (valueOf _ _ _ env h meta_e_fold) (heap_write x (valueOf _ _ _ env h meta_e_fold) h))}
@@ -109,36 +149,39 @@ Definition locally_const {A:Set} (R:hrel A) := forall a a' h h', R a a' h h' ->
109
149
110
150
111
151
Axiom alloc : forall {Γ}{T:Set}{RT:ImmediateReachability T}{CT:Containment T}{FT:rel_fold T} P R G (e:T),
0 commit comments