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
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
Iris
Actris
Commits
314e5f72
Commit
314e5f72
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Finish `list_sort_elem` client proof.
parent
842726e2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_CoqProject
+1
-0
1 addition, 0 deletions
_CoqProject
theories/examples/list_sort_elem_client.v
+42
-39
42 additions, 39 deletions
theories/examples/list_sort_elem_client.v
with
43 additions
and
39 deletions
_CoqProject
+
1
−
0
View file @
314e5f72
...
@@ -12,3 +12,4 @@ theories/examples/list_sort.v
...
@@ -12,3 +12,4 @@ theories/examples/list_sort.v
theories/examples/list_sort_instances.v
theories/examples/list_sort_instances.v
theories/examples/list_sort_elem.v
theories/examples/list_sort_elem.v
theories/examples/loop_sort.v
theories/examples/loop_sort.v
theories/examples/list_sort_elem_client.v
This diff is collapsed.
Click to expand it.
theories/examples/list_sort_elem_client.v
+
42
−
39
View file @
314e5f72
...
@@ -15,67 +15,70 @@ Definition send_all : val :=
...
@@ -15,67 +15,70 @@ Definition send_all : val :=
Definition
recv_all
:
val
:=
Definition
recv_all
:
val
:=
rec
:
"go"
"c"
:=
rec
:
"go"
"c"
:=
if
:
recv
"c"
if
:
recv
"c"
then
l
cons
(
recv
"c"
)
(
"go"
"c"
)
then
l
et
:
"x"
:=
recv
"c"
in
lcons
"x"
(
"go"
"c"
)
else
lnil
#
()
.
else
lnil
#
()
.
Definition
list_sort_elem_client
:
val
:=
Definition
list_sort_elem_client
:
val
:=
λ
:
"cmp"
"xs"
,
λ
:
"cmp"
"xs"
,
let
:
"c"
:=
start_chan
list_sort_elem_service_top
in
let
:
"c"
:=
start_chan
list_sort_elem_service_top
in
send
"c"
"cmp"
;;
send
"c"
"cmp"
;;
send_all
"c"
(
"xs"
)
;;
send_all
"c"
"xs"
;;
recv_all
"c"
.
recv_all
"c"
.
Section
list_sort_elem_client
.
Section
list_sort_elem_client
.
Context
`{
!
heapG
Σ
,
!
proto_chanG
Σ
}
(
N
:
namespace
)
.
Context
`{
!
heapG
Σ
,
!
proto_chanG
Σ
}
(
N
:
namespace
)
.
Context
{
A
}
(
I
:
A
→
val
→
iProp
Σ
)
(
R
:
relation
A
)
`{
!
RelDecision
R
,
!
Total
R
}
.
Lemma
send_all_spec
Lemma
send_all_spec
c
p
xs'
xs
vs
:
{
A
:
Type
}
(
I
:
A
→
val
→
iProp
Σ
)
R
`{
!
RelDecision
R
,
!
Total
R
}
{{{
c
↣
head_protocol
I
R
xs'
<++>
p
@
N
∗
[
∗
list
]
x
;
v
∈
xs
;
vs
,
I
x
v
}}}
(
xs
:
list
A
)
(
vs
:
list
val
)
c
:
{{{
([
∗
list
]
x
;
v
∈
xs
;
vs
,
I
x
v
)
∗
c
↣
head_protocol
I
R
[]
@
N
}}}
send_all
c
(
val_encode
vs
)
send_all
c
(
val_encode
vs
)
{{{
RET
#
();
{{{
RET
#
();
c
↣
tail_protocol
I
R
(
xs'
++
xs
)
[]
<++>
p
@
N
}}}
.
([
∗
list
]
x
;
v
∈
xs
;
vs
,
I
x
v
)
∗
Proof
.
c
↣
tail_protocol
I
R
(
zip
xs
vs
)
[]
@
N
}}}
.
iIntros
(
Φ
)
"[Hc HI] HΦ"
.
Proof
.
Admitted
.
iInduction
xs
as
[|
x
xs
]
"IH"
forall
(
xs'
vs
);
destruct
vs
as
[|
v
vs
]=>
//.
{
wp_lam
;
wp_pures
.
wp_select
.
iApply
"HΦ"
.
rewrite
right_id_L
.
iFrame
.
}
iDestruct
"HI"
as
"[HIxv HI]"
.
wp_lam
;
wp_pures
.
wp_select
.
wp_send
with
"[$HIxv]"
.
wp_apply
(
"IH"
with
"Hc HI"
)
.
by
rewrite
-
assoc_L
.
Qed
.
Lemma
recv_all_spec
Lemma
recv_all_spec
c
p
xs
ys
:
{
A
:
Type
}
(
I
:
A
→
val
→
iProp
Σ
)
R
`{
!
RelDecision
R
,
!
Total
R
}
Sorted
R
ys
→
(
xs
:
list
A
)
(
vs
:
list
val
)
c
:
{{{
c
↣
tail_protocol
I
R
xs
ys
<++>
p
@
N
}}}
{{{
([
∗
list
]
x
;
v
∈
xs
;
vs
,
I
x
v
)
∗
c
↣
tail_protocol
I
R
(
zip
xs
vs
)
[]
@
N
}}}
recv_all
c
recv_all
c
{{{
ys
ws
,
RET
(
val_encode
ws
);
{{{
ys'
ws
,
RET
(
val_encode
ws
);
c
↣
END
@
N
∗
⌜
Sorted
R
(
ys
++
ys'
)
⌝
∗
⌜
ys
++
ys'
≡
ₚ
xs
⌝
∗
⌜
Sorted
R
ys
⌝
∗
⌜
ys
≡
ₚ
xs
⌝
∗
c
↣
p
@
N
∗
[
∗
list
]
y
;
w
∈
ys'
;
ws
,
I
y
w
[
∗
list
]
y
;
w
∈
ys
;
ws
,
I
y
w
}}}
.
}}}
.
Proof
.
Admitted
.
Proof
.
iIntros
(
Hsort
Φ
)
"Hc HΦ"
.
iLöb
as
"IH"
forall
(
xs
ys
Φ
Hsort
)
.
wp_lam
.
wp_branch
as
"_"
"Hperm"
;
wp_pures
.
-
wp_recv
(
y
v
)
as
(
Htl
)
"HIxv"
.
wp_apply
(
"IH"
with
"[] Hc"
);
first
by
auto
using
Sorted_snoc
.
iIntros
(
ys'
ws
)
.
rewrite
-!
assoc_L
.
iDestruct
1
as
(??)
"[Hc HI]"
.
wp_apply
(
lcons_spec
(
A
:=
val
)
with
"[//]"
);
iIntros
(_)
.
iApply
(
"HΦ"
$!
(
y
::
ys'
))
.
simpl
;
iFrame
;
auto
.
-
wp_apply
(
lnil_spec
with
"[//]"
);
iIntros
(_)
.
iApply
(
"HΦ"
$!
[]
[]);
rewrite
/=
right_id_L
;
by
iFrame
.
Qed
.
Lemma
list_sort_client_spec
{
A
}
(
I
:
A
→
val
→
iProp
Σ
)
R
Lemma
list_sort_client_spec
cmp
vs
xs
:
`{
!
RelDecision
R
,
!
Total
R
}
cmp
(
vs
:
list
val
)
(
xs
:
list
A
)
:
cmp_spec
I
R
cmp
-∗
cmp_spec
I
R
cmp
-∗
{{{
[
∗
list
]
x
;
v
∈
xs
;
vs
,
I
x
v
}}}
{{{
[
∗
list
]
x
;
v
∈
xs
;
vs
,
I
x
v
}}}
list_sort_elem_client
cmp
(
val_encode
vs
)
list_sort_elem_client
cmp
(
val_encode
vs
)
{{{
ys
ws
,
RET
(
val_encode
ws
);
⌜
Sorted
R
ys
⌝
∗
⌜
ys
≡
ₚ
xs
⌝
∗
{{{
ys
ws
,
RET
(
val_encode
ws
);
⌜
Sorted
R
ys
⌝
∗
⌜
ys
≡
ₚ
xs
⌝
∗
[
∗
list
]
y
;
w
∈
ys
;
ws
,
I
y
w
}}}
.
[
∗
list
]
y
;
w
∈
ys
;
ws
,
I
y
w
}}}
.
Proof
.
Proof
.
iIntros
"#Hcmp !>"
(
Φ
)
"Hinterp HΦ"
.
wp_lam
.
iIntros
"#Hcmp !>"
(
Φ
)
"HI HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
N
list_sort_elem_top_protocol
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
N
(
list_sort_elem_top_protocol
<++>
END
)
%
proto
);
iIntros
(
c
)
"Hc"
.
{
wp_apply
(
list_sort_elem_service_top_spec
N
with
"Hc"
);
auto
.
}
{
wp_apply
(
list_sort_elem_service_top_spec
N
with
"Hc"
);
auto
.
}
wp_pures
.
rewrite
/
list_sort_elem_top_protocol
.
rewrite
/
list_sort_elem_top_protocol
.
simpl
.
wp_send
(
A
I
R
)
with
"[$Hcmp]"
.
wp_send
with
"[$Hcmp]"
.
wp_apply
(
send_all_spec
with
"[$HI $Hc]"
);
iIntros
"Hc"
.
wp_pures
.
wp_apply
(
recv_all_spec
_
_
_
[]
with
"[$Hc]"
);
auto
.
wp_apply
(
send_all_spec
with
"[Hinterp Hc]"
)=>
//.
iIntros
(
ys
ws
)
"/="
.
iDestruct
1
as
(??)
"[_ HI]"
.
iFrame
.
iApply
"HΦ"
;
auto
.
iIntros
"Hc"
.
wp_pures
.
wp_apply
(
recv_all_spec
with
"[Hc]"
)=>
//.
iIntros
(
ys
ws
)
"(Hc & Hsorted & Hperm & Hinterp)"
.
iApply
"HΦ"
.
iFrame
.
Qed
.
Qed
.
End
list_sort_elem_client
.
End
list_sort_elem_client
.
\ No newline at end of file
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