Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Actris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
tlsomers
Actris
Commits
405f577c
Commit
405f577c
authored
5 years ago
by
Jonas Kastberg Hinrichsen
Browse files
Options
Downloads
Patches
Plain Diff
Update to semantic let's
parent
36124591
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/channel.v
+31
-39
31 additions, 39 deletions
theories/channel.v
with
31 additions
and
39 deletions
theories/channel.v
+
31
−
39
View file @
405f577c
...
...
@@ -33,20 +33,20 @@ Definition get_side c s :=
Definition
send
:
val
:=
λ
:
"c"
"s"
"v"
,
let
lk
:=
get_lock
"c"
in
acquire
lk
;;
let
l
:=
get_side
"c"
"s"
in
l
<-
lsnoc
!
l
"v"
;;
release
lk
.
let
:
"
lk
"
:=
get_lock
"c"
in
acquire
"
lk
"
;;
let
:
"l"
:=
get_side
"c"
"s"
in
"l"
<-
lsnoc
!
"l"
"v"
;;
release
"
lk
"
.
Definition
try_recv
:
val
:=
λ
:
"c"
"s"
,
let
lk
:=
get_lock
"c"
in
acquire
lk
;;
let
l
:=
(
get_side
"c"
(
dual_side
"s"
))
in
match
:
!
l
with
SOME
"p"
=>
l
<-
Snd
"p"
;;
release
lk
;;
SOME
(
Fst
"p"
)
|
NONE
=>
release
lk
;;
NONE
let
:
"
lk
"
:=
get_lock
"c"
in
acquire
"
lk
"
;;
let
:
"l"
:=
(
get_side
"c"
(
dual_side
"s"
))
in
match
:
!
"l"
with
SOME
"p"
=>
"l"
<-
Snd
"p"
;;
release
"
lk
"
;;
SOME
(
Fst
"p"
)
|
NONE
=>
release
"
lk
"
;;
NONE
end
.
Definition
recv
:
val
:=
...
...
@@ -142,7 +142,7 @@ Section channel.
destruct
Hside
as
[
->
|
->
]
.
-
wp_pures
.
iDestruct
"Hl"
as
(
ll
lhd
->
)
"(Hl & Hll)"
.
wp_load
.
wp_apply
(
lsnoc_spec
with
"Hll"
)
.
iIntros
(
hd'
)
"
Hll
"
.
wp_pures
.
iIntros
(
hd'
Hll
)
.
wp_pures
.
wp_bind
(_
<-
_)
%
E
.
iMod
"HΦ"
as
(
ls'
rs'
)
"[Hchan HΦ]"
.
wp_store
.
iDestruct
"Hchan"
as
(
l'
r'
lk'
[
=
<-
<-
<-
])
"[Hls' Hrs']"
.
...
...
@@ -151,12 +151,11 @@ Section channel.
iMod
(
"HΦ"
with
"[Hls' Hrs']"
)
as
"HΦ"
.
{
rewrite
/=
/
chan_frag
.
eauto
with
iFrame
.
}
iModIntro
.
wp_apply
(
release_spec
with
"[-HΦ $Hlock $Hlocked]"
)
.
wp_apply
(
release_spec
with
"[-HΦ $Hlock $Hlocked]"
)
;
last
eauto
.
{
rewrite
/
is_list_ref
.
eauto
10
with
iFrame
.
}
iIntros
"_ //"
.
-
wp_pures
.
iDestruct
"Hr"
as
(
lr
rhd
->
)
"(Hr & Hlr)"
.
wp_load
.
wp_apply
(
lsnoc_spec
with
"Hlr"
)
.
iIntros
(
hd'
)
"
Hlr
"
.
wp_pures
.
iIntros
(
hd'
Hlr
)
.
wp_pures
.
wp_bind
(_
<-
_)
%
E
.
iMod
"HΦ"
as
(
ls'
rs'
)
"[Hchan HΦ]"
.
wp_store
.
iDestruct
"Hchan"
as
(
l'
r'
lk'
[
=
<-
<-
<-
])
"[Hls' Hrs']"
.
...
...
@@ -165,41 +164,37 @@ Section channel.
iMod
(
"HΦ"
with
"[Hls' Hrs']"
)
as
"HΦ"
.
{
rewrite
/=
/
chan_frag
.
eauto
with
iFrame
.
}
iModIntro
.
wp_apply
(
release_spec
with
"[-HΦ $Hlock $Hlocked]"
)
.
wp_apply
(
release_spec
with
"[-HΦ $Hlock $Hlocked]"
)
;
last
eauto
.
{
rewrite
/
is_list_ref
.
eauto
10
with
iFrame
.
}
iIntros
"_ //"
.
Qed
.
Definition
try_recv_
upd_
fail
γ
c
ls
rs
s
:
iProp
Σ
:=
Definition
try_recv_fail
γ
c
ls
rs
s
:
iProp
Σ
:=
match
s
with
|
left
=>
(
chan_frag
γ
c
ls
rs
∧
⌜
rs
=
[]
⌝
)
%
I
|
right
=>
(
chan_frag
γ
c
ls
rs
∧
⌜
ls
=
[]
⌝
)
%
I
|
_
=>
⌜
False
⌝%
I
end
.
Definition
try_recv_
upd_
succ
γ
c
ls
rs
s
v
:
iProp
Σ
:=
Definition
try_recv_succ
γ
c
ls
rs
s
v
:
iProp
Σ
:=
match
s
with
|
left
=>
(
∃
rs'
,
chan_frag
γ
c
ls
rs'
∧
⌜
rs
=
v
::
rs'
⌝
)
%
I
|
right
=>
(
∃
ls'
,
chan_frag
γ
c
ls'
rs
∧
⌜
ls
=
v
::
ls'
⌝
)
%
I
|
_
=>
⌜
False
⌝%
I
end
.
Definition
try_recv_
upd
γ
c
ls
rs
s
v
:
iProp
Σ
:=
Definition
try_recv_
get
γ
c
ls
rs
s
v
:
iProp
Σ
:=
match
v
with
|
NONEV
=>
try_recv_
upd_
fail
γ
c
ls
rs
s
|
SOMEV
w
=>
try_recv_
upd_
succ
γ
c
ls
rs
s
w
|
NONEV
=>
try_recv_fail
γ
c
ls
rs
s
|
SOMEV
w
=>
try_recv_succ
γ
c
ls
rs
s
w
|
_
=>
⌜
False
⌝%
I
end
.
Definition
try_recv_vs
E
γ
c
s
Φ
:=
(|
=
{
⊤
,
E
}=>
∃
ls
rs
,
chan_frag
γ
c
ls
rs
∗
(
∀
v
,
try_recv_upd
γ
c
ls
rs
s
v
=
{
E
,
⊤
}
=∗
Φ
v
))
%
I
.
Lemma
try_recv_spec
Φ
E
γ
(
c
s
:
val
)
:
is_side
s
→
chan_ctx
γ
c
-∗
try_recv_vs
E
γ
c
s
Φ
-∗
(|
=
{
⊤
,
E
}=>
∃
ls
rs
,
chan_frag
γ
c
ls
rs
∗
(
∀
v
,
try_recv_get
γ
c
ls
rs
s
v
=
{
E
,
⊤
}
=∗
Φ
v
))
-∗
WP
try_recv
c
s
{{
Φ
}}
.
Proof
.
iIntros
(
Hside
)
"Hc HΦ"
.
wp_lam
;
wp_pures
.
...
...
@@ -219,7 +214,7 @@ Section channel.
iDestruct
(
excl_eq
with
"Hrsa Hrsf"
)
as
%->
.
iSpecialize
(
"HΦ"
$!
(
InjLV
#
()))
.
iMod
(
"HΦ"
with
"[Hlsf Hrsf]"
)
as
"HΦ"
.
{
rewrite
/
try_recv_
upd
/
try_recv_
upd_
fail
/
chan_frag
.
{
rewrite
/
try_recv_
get
/
try_recv_fail
/
chan_frag
.
eauto
10
with
iFrame
.
}
iModIntro
.
wp_apply
(
release_spec
with
"[-HΦ $Hlocked $Hlock]"
)
.
...
...
@@ -237,7 +232,7 @@ Section channel.
iDestruct
(
excl_update
_
_
_
(
rs
)
with
"Hrsa Hrsf"
)
as
">[Hrsa Hrsf]"
.
iSpecialize
(
"HΦ"
$!
(
InjRV
(
v
)))
.
iMod
(
"HΦ"
with
"[Hlsf Hrsf]"
)
as
"HΦ"
.
{
rewrite
/
try_recv_
upd
/
try_recv_
upd_
succ
/
chan_frag
.
{
rewrite
/
try_recv_
get
/
try_recv_succ
/
chan_frag
.
eauto
10
with
iFrame
.
}
iModIntro
.
wp_store
.
...
...
@@ -258,7 +253,7 @@ Section channel.
iDestruct
(
excl_eq
with
"Hrsa Hrsf"
)
as
%->
.
iSpecialize
(
"HΦ"
$!
(
InjLV
#
()))
.
iMod
(
"HΦ"
with
"[Hlsf Hrsf]"
)
as
"HΦ"
.
{
rewrite
/
try_recv_
upd
/
try_recv_
upd_
fail
/
chan_frag
.
{
rewrite
/
try_recv_
get
/
try_recv_fail
/
chan_frag
.
eauto
10
with
iFrame
.
}
iModIntro
.
wp_apply
(
release_spec
with
"[-HΦ $Hlocked $Hlock]"
)
.
...
...
@@ -276,7 +271,7 @@ Section channel.
iDestruct
(
excl_update
_
_
_
(
ls
)
with
"Hlsa Hlsf"
)
as
">[Hlsa Hlsf]"
.
iSpecialize
(
"HΦ"
$!
(
InjRV
(
v
)))
.
iMod
(
"HΦ"
with
"[Hlsf Hrsf]"
)
as
"HΦ"
.
{
rewrite
/
try_recv_
upd
/
try_recv_
upd_
succ
/
chan_frag
.
{
rewrite
/
try_recv_
get
/
try_recv_succ
/
chan_frag
.
eauto
10
with
iFrame
.
}
iModIntro
.
wp_store
.
...
...
@@ -287,16 +282,13 @@ Section channel.
by
iApply
"HΦ"
.
Qed
.
Definition
recv_vs
E
γ
c
s
Φ
:=
(
□
(|
=
{
⊤
,
E
}=>
∃
ls
rs
,
chan_frag
γ
c
ls
rs
∗
((
try_recv_upd_fail
γ
c
ls
rs
s
=
{
E
,
⊤
}
=∗
True
)
∗
(
∀
v
,
try_recv_upd_succ
γ
c
ls
rs
s
v
=
{
E
,
⊤
}
=∗
Φ
v
))))
%
I
.
Lemma
recv_spec
Φ
E
γ
c
s
:
is_side
s
→
chan_ctx
γ
c
-∗
recv_vs
E
γ
c
s
Φ
-∗
(
□
(|
=
{
⊤
,
E
}=>
∃
ls
rs
,
chan_frag
γ
c
ls
rs
∗
((
try_recv_fail
γ
c
ls
rs
s
=
{
E
,
⊤
}
=∗
True
)
∗
(
∀
v
,
try_recv_succ
γ
c
ls
rs
s
v
=
{
E
,
⊤
}
=∗
Φ
v
))))
-∗
WP
recv
c
s
{{
Φ
}}
.
Proof
.
iIntros
(
Hside
)
"#Hc #HΦ"
.
...
...
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