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
270596d4
Commit
270596d4
authored
4 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Some examples.
parent
bbf9df55
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/basics.v
+48
-0
48 additions, 0 deletions
theories/examples/basics.v
with
48 additions
and
0 deletions
theories/examples/basics.v
+
48
−
0
View file @
270596d4
...
...
@@ -86,6 +86,24 @@ Definition prog_lock : val := λ: <>,
acquire
"l"
;;
send
"c'"
#
21
;;
release
"l"
)
in
recv
"c"
+
recv
"c"
.
(** Swapping of sends *)
Definition
prog_swap
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
send
"c'"
#
20
;;
let
:
"y"
:=
recv
"c'"
in
send
"c'"
"y"
)
in
send
"c"
#
22
;;
recv
"c"
+
recv
"c"
.
Definition
prog_swap_twice
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
send
"c'"
#
20
;;
let
:
"y1"
:=
recv
"c'"
in
let
:
"y2"
:=
recv
"c'"
in
send
"c'"
(
"y1"
+
"y2"
))
in
send
"c"
#
11
;;
send
"c"
#
11
;;
recv
"c"
+
recv
"c"
.
Section
proofs
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
...
...
@@ -142,6 +160,17 @@ Fixpoint prot_lock (n : nat) : iProto Σ :=
|
S
n'
=>
<
?
>
MSG
#
21
;
prot_lock
n'
end
%
proto
.
Definition
prot_swap
:
iProto
Σ
:=
(
<!>
x
:
Z
,
MSG
#
x
;
<
?
>
MSG
#
20
;
<
?
>
MSG
#
x
;
END
)
%
proto
.
Definition
prot_swap_twice
:
iProto
Σ
:=
(
<!>
x
:
Z
,
MSG
#
x
;
<!>
y
:
Z
,
MSG
#
y
;
<
?
>
MSG
#
20
;
<
?
>
MSG
#
(
x
+
y
);
END
)
%
proto
.
(** Specs and proofs of the respective programs *)
Lemma
prog_spec
:
{{{
True
}}}
prog
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
...
...
@@ -270,4 +299,23 @@ Proof.
by
wp_apply
"Hhelp"
.
-
wp_recv
as
"_"
.
wp_recv
as
"_"
.
wp_pures
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog_swap_spec
:
{{{
True
}}}
prog_swap
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_spec
prot_swap
);
iIntros
(
c
)
"Hc"
.
-
wp_send
with
"[//]"
.
wp_recv
(
x
)
as
"_"
.
by
wp_send
with
"[//]"
.
-
wp_send
with
"[//]"
.
wp_recv
as
"_"
.
wp_recv
as
"_"
.
wp_pures
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog_swap_twice_spec
:
{{{
True
}}}
prog_swap_twice
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_spec
prot_swap_twice
);
iIntros
(
c
)
"Hc"
.
-
wp_send
with
"[//]"
.
wp_recv
(
x1
)
as
"_"
.
wp_recv
(
x2
)
as
"_"
.
by
wp_send
with
"[//]"
.
-
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_recv
as
"_"
.
wp_recv
as
"_"
.
wp_pures
.
by
iApply
"HΦ"
.
Qed
.
End
proofs
.
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