Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iris-coq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dan Frumin
iris-coq
Commits
b83e7a10
Commit
b83e7a10
authored
9 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
use parallel composition in the barrier client
parent
930f9f47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
barrier/client.v
+23
-20
23 additions, 20 deletions
barrier/client.v
heap_lang/par.v
+7
-4
7 additions, 4 deletions
heap_lang/par.v
with
30 additions
and
24 deletions
barrier/client.v
+
23
−
20
View file @
b83e7a10
From
barrier
Require
Import
proof
.
From
barrier
Require
Import
proof
.
From
heap_lang
Require
Import
par
.
From
program_logic
Require
Import
auth
sts
saved_prop
hoare
ownership
.
From
program_logic
Require
Import
auth
sts
saved_prop
hoare
ownership
.
Import
uPred
.
Import
uPred
.
...
@@ -7,11 +8,11 @@ Definition worker (n : Z) : val :=
...
@@ -7,11 +8,11 @@ Definition worker (n : Z) : val :=
Definition
client
:
expr
[]
:=
Definition
client
:
expr
[]
:=
let:
"y"
:=
ref
#
0
in
let:
"y"
:=
ref
#
0
in
let:
"b"
:=
^
newbarrier
#()
in
let:
"b"
:=
^
newbarrier
#()
in
Fork
(
Fork
(
^
(
worker
12
)
'
"b"
'
"y"
)
;;
^
(
worker
17
)
'
"b"
'
"y"
)
;;
(
'
"y"
<-
(
λ
:
"z"
,
'
"z"
+
#
42
)
;;
^
signal
'
"b"
)
||
'
"y"
<-
(
λ
:
"z"
,
'
"
z
"
+
#
42
)
;;
^
signal
'
"b"
.
(
^
(
worker
12
)
'
"b"
'
"
y
"
||
^
(
worker
17
)
'
"b"
'
"y"
)
.
Section
client
.
Section
client
.
Context
{
Σ
:
rFunctorG
}
`
{!
heapG
Σ
,
!
barrierG
Σ
}
(
heapN
N
:
namespace
).
Context
{
Σ
:
rFunctorG
}
`
{!
heapG
Σ
,
!
barrierG
Σ
,
!
spawnG
Σ
}
(
heapN
N
:
namespace
).
Local
Notation
iProp
:=
(
iPropG
heap_lang
Σ
).
Local
Notation
iProp
:=
(
iPropG
heap_lang
Σ
).
Definition
y_inv
q
y
:
iProp
:=
Definition
y_inv
q
y
:
iProp
:=
...
@@ -49,29 +50,31 @@ Section client.
...
@@ -49,29 +50,31 @@ Section client.
ewp
eapply
(
newbarrier_spec
heapN
N
(
y_inv
1
y
));
last
done
.
ewp
eapply
(
newbarrier_spec
heapN
N
(
y_inv
1
y
));
last
done
.
rewrite
comm
.
rewrite
{
1
}
[
heap_ctx
_
]
always_sep_dup
-!
assoc
.
rewrite
comm
.
rewrite
{
1
}
[
heap_ctx
_
]
always_sep_dup
-!
assoc
.
apply
sep_mono_r
.
apply
forall_intro
=>
b
.
apply
wand_intro_l
.
apply
sep_mono_r
.
apply
forall_intro
=>
b
.
apply
wand_intro_l
.
wp_let
.
ewp
eapply
wp_fork
.
wp_let
.
(
ewp
eapply
(
wp_par
heapN
N
(
λ
_
,
True
%
I
)
(
λ
_
,
True
%
I
)));
eauto
.
rewrite
[
heap_ctx
_
]
always_sep_dup
!
assoc
[(
_
★
heap_ctx
_
)
%
I
]
comm
.
rewrite
2
!{
1
}
[
heap_ctx
_
]
always_sep_dup
!
assoc
[(
_
★
heap_ctx
_
)
%
I
]
comm
.
rewrite
[(#
>
_
{{
_
}}
★
_
)
%
I
]
comm
-!
assoc
assoc
.
apply
sep_mono
;
last
first
.
ecancel
[
heap_ctx
_
].
sep_split
right
:
[];
last
first
.
{
(
*
The
original
thread
,
the
sender
.
*
)
{
do
2
apply
forall_intro
=>
_.
apply
wand_intro_l
.
eauto
with
I
.
}
wp_seq
.
(
ewp
eapply
wp_store
);
eauto
with
I
.
strip_later
.
sep_split
left
:
[
send
heapN
_
_
_
;
heap_ctx
_
;
y
↦
_
]
%
I
.
rewrite
assoc
[(
_
★
y
↦
_
)
%
I
]
comm
.
apply
sep_mono_r
,
wand_intro_l
.
-
(
*
The
original
thread
,
the
sender
.
*
)
(
ewp
eapply
wp_store
);
eauto
with
I
.
strip_later
.
ecancel
[
y
↦
_
]
%
I
.
apply
wand_intro_l
.
wp_seq
.
rewrite
-
signal_spec
right_id
assoc
sep_elim_l
comm
.
wp_seq
.
rewrite
-
signal_spec
right_id
assoc
sep_elim_l
comm
.
apply
sep_mono_r
.
rewrite
/
y_inv
-
(
exist_intro
(
λ
:
"z"
,
'
"z"
+
#
42
)
%
V
).
apply
sep_mono_r
.
rewrite
/
y_inv
-
(
exist_intro
(
λ
:
"z"
,
'
"z"
+
#
42
)
%
V
).
apply
sep_intro_True_r
;
first
done
.
apply
:
always_intro
.
apply
sep_intro_True_r
;
first
done
.
apply
:
always_intro
.
apply
forall_intro
=>
n
.
wp_let
.
wp_op
.
by
apply
const_intro
.
}
apply
forall_intro
=>
n
.
wp_let
.
wp_op
.
by
apply
const_intro
.
(
*
The
two
spawned
threads
,
the
waiters
.
*
)
-
(
*
The
two
spawned
threads
,
the
waiters
.
*
)
rewrite
recv_mono
;
last
exact
:
y_inv_split
.
rewrite
recv_mono
;
last
exact
:
y_inv_split
.
rewrite
(
recv_split
_
_
⊤
)
// pvs_frame_
l
. apply wp_strip_pvs.
rewrite
(
recv_split
_
_
⊤
)
// pvs_frame_
r
. apply wp_strip_pvs.
ewp
eapply
wp_
fork
.
(
ewp
eapply
(
wp_
par
heapN
N
(
λ
_
,
True
%
I
)
(
λ
_
,
True
%
I
)));
eauto
.
rewrite
[
heap_ctx
_
]
always_sep_dup
!
assoc
[(
_
★
recv
_
_
_
_
)
%
I
]
comm
.
do
2
rewrite
{
1
}
[
heap_ctx
_
]
always_sep_dup
.
rewrite
-
!
assoc
assoc
.
apply
sep_mono
.
ecancel
[
heap_ctx
_
].
rewrite
!
assoc
.
sep_split
right
:
[];
last
first
.
-
wp_seq
.
by
rewrite
-
worker_safe
comm
.
{
do
2
apply
forall_intro
=>
_.
apply
wand_intro_l
.
eauto
with
I
.
}
-
by
rewrite
-
worker_safe
.
sep_split
left
:
[
recv
heapN
_
_
_
;
heap_ctx
_
]
%
I
;
by
rewrite
-
worker_safe
comm
.
Qed
.
Qed
.
End
client
.
End
client
.
Section
ClosedProofs
.
Section
ClosedProofs
.
Definition
Σ
:
rFunctorG
:=
#[
heapGF
;
barrierGF
].
Definition
Σ
:
rFunctorG
:=
#[
heapGF
;
barrierGF
;
spawnGF
].
Notation
iProp
:=
(
iPropG
heap_lang
Σ
).
Notation
iProp
:=
(
iPropG
heap_lang
Σ
).
Lemma
client_safe_closed
σ
:
{{
ownP
σ
:
iProp
}}
client
{{
λ
v
,
True
}}
.
Lemma
client_safe_closed
σ
:
{{
ownP
σ
:
iProp
}}
client
{{
λ
v
,
True
}}
.
...
...
This diff is collapsed.
Click to expand it.
heap_lang/par.v
+
7
−
4
View file @
b83e7a10
From
heap_lang
Require
Export
heap
.
From
heap_lang
Require
Export
heap
spawn
.
From
heap_lang
Require
Import
spawn
wp_tactics
notation
.
From
heap_lang
Require
Import
wp_tactics
notation
.
Import
uPred
.
Import
uPred
.
Definition
par
:
val
:=
Definition
par
:
val
:=
...
@@ -8,6 +8,9 @@ Definition par : val :=
...
@@ -8,6 +8,9 @@ Definition par : val :=
let:
"v1"
:=
^
join
'
"handle"
in
let:
"v1"
:=
^
join
'
"handle"
in
Pair
'
"v1"
'
"v2"
.
Pair
'
"v1"
'
"v2"
.
Notation
Par
e1
e2
:=
(
^
par
(
λ
:
<>
,
e1
)
(
λ
:
<>
,
e2
))
%
E
.
Notation
Par
e1
e2
:=
(
^
par
(
λ
:
<>
,
e1
)
(
λ
:
<>
,
e2
))
%
E
.
Notation
ParV
e1
e2
:=
(
par
(
λ
:
<>
,
e1
)
(
λ
:
<>
,
e2
))
%
E
.
(
*
We
want
both
par
and
par
^
to
print
like
this
.
*
)
Infix
"||"
:=
ParV
:
expr_scope
.
Infix
"||"
:=
Par
:
expr_scope
.
Infix
"||"
:=
Par
:
expr_scope
.
Section
proof
.
Section
proof
.
...
@@ -41,9 +44,9 @@ Lemma wp_par (Ψ1 Ψ2 : val → iProp) (e1 e2 : expr []) (Φ : val → iProp) :
...
@@ -41,9 +44,9 @@ Lemma wp_par (Ψ1 Ψ2 : val → iProp) (e1 e2 : expr []) (Φ : val → iProp) :
heapN
⊥
N
→
heapN
⊥
N
→
(
heap_ctx
heapN
★
#
>
e1
{{
Ψ
1
}}
★
#
>
e2
{{
Ψ
2
}}
★
(
heap_ctx
heapN
★
#
>
e1
{{
Ψ
1
}}
★
#
>
e2
{{
Ψ
2
}}
★
∀
v1
v2
,
Ψ
1
v1
★
Ψ
2
v2
-
★
Φ
(
PairV
v1
v2
))
∀
v1
v2
,
Ψ
1
v1
★
Ψ
2
v2
-
★
Φ
(
PairV
v1
v2
))
⊑
#
>
e1
||
e2
{{
Φ
}}
.
⊑
#
>
ParV
e1
e2
{{
Φ
}}
.
Proof
.
Proof
.
intros
.
rewrite
of_val
'_
closed
-
par_spec
//. apply sep_mono_r.
intros
.
rewrite
-
par_spec
//. apply sep_mono_r.
apply
sep_mono
;
last
apply
sep_mono_l
;
by
wp_seq
.
apply
sep_mono
;
last
apply
sep_mono_l
;
by
wp_seq
.
Qed
.
Qed
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment