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
1d72cb3f
Commit
1d72cb3f
authored
4 years ago
by
Jonas Kastberg
Browse files
Options
Downloads
Patches
Plain Diff
Added basic program proof of references in loops with swapping
parent
3ee753fd
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
+41
-6
41 additions, 6 deletions
theories/examples/basics.v
with
41 additions
and
6 deletions
theories/examples/basics.v
+
41
−
6
View file @
1d72cb3f
...
@@ -116,6 +116,20 @@ Definition prog_swap_loop : val := λ: <>,
...
@@ -116,6 +116,20 @@ Definition prog_swap_loop : val := λ: <>,
let
:
"x2"
:=
recv
"c"
in
let
:
"x2"
:=
recv
"c"
in
"x1"
+
"x2"
.
"x1"
+
"x2"
.
Definition
prog_ref_swap_loop
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
let
:
"go"
:=
rec
:
"go"
<>
:=
let
:
"l"
:=
recv
"c'"
in
"l"
<-
!
"l"
+
#
2
;;
send
"c'"
#
();;
"go"
#
()
in
"go"
#
())
in
let
:
"l1"
:=
ref
#
18
in
let
:
"l2"
:=
ref
#
20
in
send
"c"
"l1"
;;
send
"c"
"l2"
;;
recv
"c"
;;
recv
"c"
;;
!
"l1"
+
!
"l2"
.
Section
proofs
.
Section
proofs
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
...
@@ -159,6 +173,15 @@ Global Instance prot_loop_unfold :
...
@@ -159,6 +173,15 @@ Global Instance prot_loop_unfold :
ProtoUnfold
prot_loop
(
prot_loop_aux
prot_loop
)
.
ProtoUnfold
prot_loop
(
prot_loop_aux
prot_loop
)
.
Proof
.
apply
proto_unfold_eq
,
(
fixpoint_unfold
_)
.
Qed
.
Proof
.
apply
proto_unfold_eq
,
(
fixpoint_unfold
_)
.
Qed
.
Definition
prot_ref_loop_aux
(
rec
:
iProto
Σ
)
:
iProto
Σ
:=
(
<!
(
l
:
loc
)
(
x
:
Z
)
>
MSG
#
l
{{
l
↦
#
x
}};
<
?
>
MSG
#
()
{{
l
↦
#
(
x
+
2
)
}};
rec
)
%
proto
.
Instance
prot_ref_loop_contractive
:
Contractive
prot_ref_loop_aux
.
Proof
.
solve_proto_contractive
.
Qed
.
Definition
prot_ref_loop
:
iProto
Σ
:=
fixpoint
prot_ref_loop_aux
.
Global
Instance
prot_ref_loop_unfold
:
ProtoUnfold
prot_ref_loop
(
prot_ref_loop_aux
prot_ref_loop
)
.
Proof
.
apply
proto_unfold_eq
,
(
fixpoint_unfold
_)
.
Qed
.
Definition
prot_fun
:
iProto
Σ
:=
Definition
prot_fun
:
iProto
Σ
:=
(
<!
(
P
:
iProp
Σ
)
(
Φ
:
Z
→
iProp
Σ
)
(
vf
:
val
)
>
(
<!
(
P
:
iProp
Σ
)
(
Φ
:
Z
→
iProp
Σ
)
(
vf
:
val
)
>
MSG
vf
{{
{{{
P
}}}
vf
#
()
{{{
x
,
RET
#
x
;
Φ
x
}}}
}};
MSG
vf
{{
{{{
P
}}}
vf
#
()
{{{
x
,
RET
#
x
;
Φ
x
}}}
}};
...
@@ -335,17 +358,29 @@ Proof.
...
@@ -335,17 +358,29 @@ Proof.
wp_pures
.
by
iApply
"HΦ"
.
wp_pures
.
by
iApply
"HΦ"
.
Qed
.
Qed
.
Lemma
prog_
loop_swa
p_spec
:
{{{
True
}}}
prog_swap_loop
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog_
swap_loo
p_spec
:
{{{
True
}}}
prog_swap_loop
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_spec
prot_loop
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_spec
prot_loop
);
iIntros
(
c
)
"Hc"
.
-
iAssert
(
∀
Ψ
,
WP
(
rec
:
"go"
<>
:=
let
:
"x"
:=
recv
c
in
-
wp_pures
.
iLöb
as
"IH"
.
send
c
(
"x"
+
#
2
)
;;
"go"
#
())
%
V
#
()
{{
Ψ
}})
%
I
with
"[Hc]"
as
"H"
.
wp_recv
(
x
)
as
"_"
.
wp_send
with
"[//]"
.
{
iIntros
(
Ψ
)
.
iLöb
as
"IH"
.
wp_recv
(
x
)
as
"_"
.
wp_send
with
"[//]"
.
wp_pures
.
by
iApply
"IH"
.
wp_seq
.
by
iApply
"IH"
.
}
wp_lam
.
wp_closure
.
wp_let
.
iApply
"H"
.
-
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_recv
as
"_"
.
wp_recv
as
"_"
.
-
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_recv
as
"_"
.
wp_recv
as
"_"
.
wp_pures
.
by
iApply
"HΦ"
.
wp_pures
.
by
iApply
"HΦ"
.
Qed
.
Qed
.
Lemma
prog_ref_swap_loop_spec
:
{{{
True
}}}
prog_ref_swap_loop
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_spec
prot_ref_loop
);
iIntros
(
c
)
"Hc"
.
-
do
4
wp_pure
_
.
iLöb
as
"IH"
.
wp_lam
.
wp_recv
(
l
x
)
as
"Hl"
.
wp_load
.
wp_store
.
wp_send
with
"[Hl//]"
.
do
2
wp_pure
_
.
by
iApply
"IH"
.
-
wp_alloc
l1
as
"Hl1"
.
wp_alloc
l2
as
"Hl2"
.
wp_send
with
"[Hl1//]"
.
wp_send
with
"[Hl2//]"
.
wp_recv
as
"Hl1"
.
wp_recv
as
"Hl2"
.
wp_load
.
wp_load
.
wp_pures
.
by
iApply
"HΦ"
.
Qed
.
End
proofs
.
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