Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Iris
c
Commits
e1571a89
Commit
e1571a89
authored
Dec 10, 2018
by
Dan Frumin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A simpler flock API
Get rid of `prop_id`. This also simplifies the proofs.
parent
2ad958e4
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
251 additions
and
289 deletions
+251
-289
theories/c_translation/monad.v
theories/c_translation/monad.v
+13
-12
theories/lib/flock.v
theories/lib/flock.v
+238
-277
No files found.
theories/c_translation/monad.v
View file @
e1571a89
...
...
@@ -64,8 +64,9 @@ Section cwp.
is_mset
env
X
∗
full_locking_heap
σ
)%
I
.
Definition
flock_resources
(
γ
:
flock_name
)
(
I
:
gmap
prop_id
lock_res
)
:
=
([
∗
map
]
i
↦
X
∈
I
,
flock_res
cmonadN
γ
i
X
)%
I
.
Definition
flock_resources
(
γ
:
flock_name
)
(
I
:
gmap
lock_res_gname
(
frac
*
iProp
Σ
))
:
=
([
∗
map
]
ρ
↦
π
R
∈
I
,
flock_res
cmonadN
γ
ρ
π
R
.
1
π
R
.
2
)%
I
.
(** DF: The outer `WP` here is needed to be able to perform some reductions inside a heap_lang context.
Without this, the `cwp_cwp` rule is not provable.
...
...
@@ -77,10 +78,10 @@ Section cwp.
Definition
cwp_def
(
e
:
expr
)
(
R
:
iProp
Σ
)
(
Φ
:
val
→
iProp
Σ
)
:
iProp
Σ
:
=
WP
e
{{
ev
,
∀
(
γ
:
flock_name
)
(
env
:
val
)
(
l
:
val
)
(
I
:
gmap
prop_id
lock_res
)
,
∀
(
γ
:
flock_name
)
(
env
:
val
)
(
l
:
val
)
I
,
is_flock
cmonadN
γ
l
-
∗
flock_resources
γ
I
-
∗
([
∗
map
]
X
∈
I
,
res_prop
X
)
≡
(
env_inv
env
∗
R
)
-
∗
([
∗
map
]
π
R
∈
I
,
π
R
.
2
)
≡
(
env_inv
env
∗
R
)
-
∗
WP
ev
env
l
{{
v
,
Φ
v
∗
flock_resources
γ
I
}}
}}%
I
.
Definition
cwp_aux
:
seal
(@
cwp_def
).
by
eexists
.
Qed
.
...
...
@@ -131,9 +132,9 @@ Section cwp_rules.
iApply
(
wp_wand
with
"Hcwp"
).
iIntros
(
v
)
"HΦ"
.
iIntros
(
γ
env
l
I
)
"#Hflock Hres #Heq"
.
iMod
(
flock_res_alloc_strong
_
(
dom
(
gset
prop_id
)
I
)
with
"Hflock HR1"
)
as
(
j
ρ
)
"[% Hres']"
;
first
done
.
pose
(
I'
:
=
<[
j
:
=
(
LockRes
R1
1
ρ
)]>
I
).
assert
(
I
!!
j
=
None
)
by
by
eapply
not_elem_of_dom
.
iMod
(
flock_res_alloc_strong
_
(
dom
(
gset
lock_res_gname
)
I
)
with
"Hflock HR1"
)
as
(
ρ
)
"[% Hres']"
;
first
done
.
pose
(
I'
:
=
<[
ρ
:
=
(
1
%
Qp
,
R1
)]>
I
).
assert
(
I
!!
ρ
=
None
)
by
by
eapply
not_elem_of_dom
.
iSpecialize
(
"HΦ"
$!
_
env
l
I'
with
"Hflock [Hres Hres'] []"
).
{
rewrite
/
flock_resources
/
I'
.
rewrite
big_sepM_insert
//.
iFrame
.
}
...
...
@@ -224,11 +225,11 @@ Section cwp_rules.
iDestruct
(
"Hwp"
with
"HR"
)
as
(
Q
)
"[HQ Hwp]"
.
wp_apply
(
newflock_spec
cmonadN
)
;
first
done
.
iIntros
(
k
γ
'
)
"#Hlock2"
.
iMod
(
flock_res_alloc_strong
_
∅
_
_
(
env_inv
env
∗
Q
)%
I
with
"Hlock2 [$HQ $Henv]"
)
as
(
s
ρ
)
"[_ Hres]"
;
first
done
.
iMod
(
flock_res_alloc_strong
_
∅
_
_
(
env_inv
env
∗
Q
)%
I
with
"Hlock2 [$HQ $Henv]"
)
as
(
ρ
)
"[_ Hres]"
;
first
done
.
wp_let
.
wp_apply
(
wp_wand
with
"Hwp"
)
;
iIntros
(
ev'
)
"Hwp"
.
wp_bind
(
ev'
_
_
).
iApply
(
wp_wand
with
"[Hwp Hres]"
).
-
iApply
(
"Hwp"
$!
_
_
_
{[
s
:
=(
LockRes
_
1
ρ
)]}
with
"Hlock2 [Hres] []"
).
-
iApply
(
"Hwp"
$!
_
_
_
{[
ρ
:
=(
1
%
Qp
,
_
)]}
with
"Hlock2 [Hres] []"
).
+
rewrite
/
flock_resources
big_sepM_singleton
//.
+
rewrite
big_sepM_singleton
//.
-
iIntros
(
w
)
"[HR Hres]"
.
...
...
@@ -276,7 +277,7 @@ Section cwp_rules.
wp_apply
(
wp_wand
with
"Hwp1"
).
iIntros
(
ev1
)
"Hwp1"
.
wp_lam
.
wp_pures
.
iIntros
(
γ
env
l
I
)
"#Hlock Hres #Heq"
.
wp_pures
.
pose
(
I'
:
=
fmap
(
λ
X
,
LockRes
(
res_prop
X
)
(
res_frac
X
/
2
)
(
res_name
X
))
I
).
pose
(
I'
:
=
fmap
(
λ
π
R
,
((
π
R
.
1
/
2
)%
Qp
,
π
R
.
2
))
I
).
iAssert
(
flock_resources
γ
I'
∗
flock_resources
γ
I'
)%
I
with
"[Hres]"
as
"[Hres1 Hres2]"
.
{
rewrite
/
flock_resources
-
big_sepM_sepM
.
rewrite
/
I'
big_sepM_fmap
/=.
...
...
@@ -345,12 +346,12 @@ Section cwp_run.
wp_apply
(
newflock_spec
cmonadN
)
;
first
done
.
iIntros
(
k
γ
'
)
"#Hlock"
.
iApply
wp_fupd
.
iMod
(
flock_res_alloc_strong
_
∅
_
_
(
env_inv
env
)%
I
with
"Hlock [Henv Hσ]"
)
as
(
s
ρ
)
"[_ Hres]"
;
first
done
.
with
"Hlock [Henv Hσ]"
)
as
(
ρ
)
"[_ Hres]"
;
first
done
.
{
iNext
.
iExists
∅
,
∅
.
iFrame
.
iPureIntro
;
set_solver
.
}
wp_let
.
iMod
(
wp_value_inv
with
"Hwp"
)
as
"Hwp"
.
iApply
(
wp_wand
with
"[Hwp Hres]"
).
-
iApply
(
"Hwp"
$!
_
_
_
{[
s
:
=
LockRes
_
1
ρ
]}
with
"Hlock [Hres] []"
).
-
iApply
(
"Hwp"
$!
_
_
_
{[
ρ
:
=
(
1
%
Qp
,
_
)
]}
with
"Hlock [Hres] []"
).
+
rewrite
/
flock_resources
big_sepM_singleton
//.
+
by
rewrite
big_sepM_singleton
right_id
.
-
iIntros
(
w
)
"[HΦ Hres]"
.
...
...
theories/lib/flock.v
View file @
e1571a89
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment