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
5a50b219
Commit
5a50b219
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
loop_sort_service
parent
e74d668a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/examples/list_sort.v
+49
-0
49 additions, 0 deletions
theories/examples/list_sort.v
with
49 additions
and
0 deletions
theories/examples/list_sort.v
+
49
−
0
View file @
5a50b219
...
...
@@ -39,6 +39,20 @@ Definition list_sort_service : val :=
"xs"
<-
lmerge
"cmp"
!
"ys"
!
"zs"
;;
send
"c"
#
()
.
Definition
loop_sort_service_go
:
val
:=
rec
:
"go"
"c"
:=
if
:
recv
"c"
then
list_sort_service
"c"
;;
"go"
"c"
else
if
:
recv
"c"
then
let
:
"d"
:=
new_chan
#
()
in
Fork
(
"go"
(
Snd
"d"
));;
send
"c"
(
Fst
"d"
);;
"go"
"c"
else
#
()
.
Definition
loop_sort_service
:
val
:=
λ
:
<>
,
let
:
"c"
:=
new_chan
#
()
in
Fork
(
loop_sort_service_go
(
Snd
"c"
));;
Fst
"c"
.
Section
list_sort
.
Context
`{
!
heapG
Σ
,
!
proto_chanG
Σ
}
(
N
:
namespace
)
.
...
...
@@ -145,6 +159,41 @@ Section list_sort.
-
by
apply
(
Sorted_list_merge
_)
.
-
rewrite
(
merge_Permutation
R
)
.
by
f_equiv
.
Qed
.
Definition
loop_sort_protocol_aux
(
rec
:
iProto
Σ
)
:
iProto
Σ
:=
((
sort_protocol
<++>
rec
)
<+>
((
<
?
>
c
,
MSG
c
{{
c
↣
rec
@
N
}};
rec
)
<+>
END
))
%
proto
.
Instance
loop_sort_protocol_aux_contractive
:
Contractive
loop_sort_protocol_aux
.
Proof
.
intros
n
p
p'
Hp
.
rewrite
/
loop_sort_protocol_aux
.
f_contractive
;
f_equiv
=>
//.
apply
iProto_message_ne
=>
c
/=
;
by
repeat
f_equiv
.
Qed
.
Definition
loop_sort_protocol
:
iProto
Σ
:=
fixpoint
loop_sort_protocol_aux
.
Lemma
loop_sort_protocol_unfold
:
loop_sort_protocol
≡
loop_sort_protocol_aux
loop_sort_protocol
.
Proof
.
apply
(
fixpoint_unfold
loop_sort_protocol_aux
)
.
Qed
.
Lemma
loop_sort_service_go_spec
c
:
{{{
c
↣
iProto_dual
loop_sort_protocol
@
N
}}}
loop_sort_service_go
c
{{{
RET
#
();
c
↣
END
@
N
}}}
.
Proof
.
iIntros
(
Ψ
)
"Hc HΨ"
.
iLöb
as
"IH"
forall
(
c
Ψ
)
.
wp_rec
.
rewrite
{
2
}
loop_sort_protocol_unfold
/
loop_sort_protocol_aux
.
rewrite
!
iProto_dual_branch
iProto_dual_app
iProto_dual_end
/=.
wp_apply
(
branch_spec
with
"Hc"
);
iIntros
([])
"/= Hc"
;
wp_if
.
{
wp_apply
(
list_sort_service_spec
with
"Hc"
);
iIntros
"Hc"
.
by
wp_apply
(
"IH"
with
"Hc"
)
.
}
wp_apply
(
branch_spec
with
"Hc"
);
iIntros
([])
"/= Hc"
;
wp_if
.
-
wp_apply
(
new_chan_proto_spec
N
loop_sort_protocol
with
"[//]"
);
iIntros
(
d1
d2
)
"[Hd1 Hd2]"
.
wp_apply
(
wp_fork
with
"[Hd2]"
)
.
{
iNext
.
wp_apply
(
"IH"
with
"Hd2"
);
auto
.
}
wp_apply
(
send_proto_spec
with
"Hc"
);
simpl
.
iExists
d1
;
iSplit
;
first
done
.
iIntros
"{$Hd1} !> Hc"
.
by
wp_apply
(
"IH"
with
"Hc"
)
.
-
by
iApply
"HΨ"
.
Qed
.
End
list_sort
.
(*
...
...
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