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
0c069e7d
Commit
0c069e7d
authored
4 years ago
by
Jonas Kastberg
Browse files
Options
Downloads
Plain Diff
Merge branch 'jonas/map_swap_example'
parents
91391d2e
55e3a725
No related branches found
No related tags found
No related merge requests found
Pipeline
#31807
failed
4 years ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theories/examples/basics.v
+32
-0
32 additions, 0 deletions
theories/examples/basics.v
theories/examples/subprotocols.v
+30
-0
30 additions, 0 deletions
theories/examples/subprotocols.v
with
62 additions
and
0 deletions
theories/examples/basics.v
+
32
−
0
View file @
0c069e7d
...
@@ -104,6 +104,18 @@ Definition prog_swap_twice : val := λ: <>,
...
@@ -104,6 +104,18 @@ Definition prog_swap_twice : val := λ: <>,
send
"c"
#
11
;;
send
"c"
#
11
;;
send
"c"
#
11
;;
send
"c"
#
11
;;
recv
"c"
+
recv
"c"
.
recv
"c"
+
recv
"c"
.
Definition
prog_swap_loop
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
let
:
"go"
:=
rec
:
"go"
<>
:=
let
:
"x"
:=
recv
"c'"
in
send
"c'"
(
"x"
+
#
2
);;
"go"
#
()
in
"go"
#
())
in
send
"c"
#
18
;;
send
"c"
#
20
;;
let
:
"x1"
:=
recv
"c"
in
let
:
"x2"
:=
recv
"c"
in
"x1"
+
"x2"
.
Section
proofs
.
Section
proofs
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
...
@@ -171,6 +183,12 @@ Definition prot_swap_twice : iProto Σ :=
...
@@ -171,6 +183,12 @@ Definition prot_swap_twice : iProto Σ :=
<
?
>
MSG
#
20
;
<
?
>
MSG
#
20
;
<
?
>
MSG
#
(
x
+
y
);
END
)
%
proto
.
<
?
>
MSG
#
(
x
+
y
);
END
)
%
proto
.
Definition
prot_swap_loop
:
iProto
Σ
:=
(
<!
(
x
:
Z
)
>
MSG
#
x
;
<!
(
y
:
Z
)
>
MSG
#
y
;
<
?
>
MSG
#
(
x
+
2
);
<
?
>
MSG
#
(
y
+
2
);
prot_loop
)
%
proto
.
(** Specs and proofs of the respective programs *)
(** Specs and proofs of the respective programs *)
Lemma
prog_spec
:
{{{
True
}}}
prog
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog_spec
:
{{{
True
}}}
prog
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
Proof
.
...
@@ -318,4 +336,18 @@ Proof.
...
@@ -318,4 +336,18 @@ Proof.
-
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_loop_swap_spec
:
{{{
True
}}}
prog_swap_loop
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_spec
prot_loop
);
iIntros
(
c
)
"Hc"
.
-
iAssert
(
∀
Ψ
,
WP
(
rec
:
"go"
<>
:=
let
:
"x"
:=
recv
c
in
send
c
(
"x"
+
#
2
)
;;
"go"
#
())
%
V
#
()
{{
Ψ
}})
%
I
with
"[Hc]"
as
"H"
.
{
iIntros
(
Ψ
)
.
iLöb
as
"IH"
.
wp_recv
(
x
)
as
"_"
.
wp_send
with
"[//]"
.
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_pures
.
by
iApply
"HΦ"
.
Qed
.
End
proofs
.
End
proofs
.
This diff is collapsed.
Click to expand it.
theories/examples/subprotocols.v
+
30
−
0
View file @
0c069e7d
From
actris
.
channel
Require
Import
proofmode
proto
channel
.
From
actris
.
channel
Require
Import
proofmode
proto
channel
.
From
actris
.
logrel
Require
Import
subtyping_rules
.
From
actris
.
logrel
Require
Import
subtyping_rules
.
From
iris
.
proofmode
Require
Import
tactics
.
From
iris
.
proofmode
Require
Import
tactics
.
From
actris
.
utils
Require
Import
llist
.
Section
basics
.
Section
basics
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
Context
`{
heapG
Σ
,
chanG
Σ
}
.
...
@@ -10,4 +11,33 @@ Section basics.
...
@@ -10,4 +11,33 @@ Section basics.
(
<!
(
l1
l2
:
loc
)
>
MSG
(
#
l1
,
#
l2
)
{{
l1
↦
#
20
∗
l2
↦
#
22
}};
END
)
⊑
(
<!
(
l1
l2
:
loc
)
>
MSG
(
#
l1
,
#
l2
)
{{
l1
↦
#
20
∗
l2
↦
#
22
}};
END
)
⊑
(
<!
(
l1
:
loc
)
>
MSG
(
#
l1
,
#
l2'
)
{{
l1
↦
#
20
}};
END
)
.
(
<!
(
l1
:
loc
)
>
MSG
(
#
l1
,
#
l2'
)
{{
l1
↦
#
20
}};
END
)
.
Proof
.
iIntros
"Hl2'"
(
l1
)
"Hl1"
.
iExists
l1
,
l2'
.
by
iFrame
"Hl1 Hl2'"
.
Qed
.
Proof
.
iIntros
"Hl2'"
(
l1
)
"Hl1"
.
iExists
l1
,
l2'
.
by
iFrame
"Hl1 Hl2'"
.
Qed
.
Section
program_reuse
.
Context
{
T
U
R
:
Type
}
.
Context
(
IT
:
T
->
val
->
iProp
Σ
)
.
Context
(
ITR
:
(
T
*
R
)
->
val
->
iProp
Σ
)
.
Context
(
IU
:
U
->
val
->
iProp
Σ
)
.
Context
(
IUR
:
(
U
*
R
)
->
val
->
iProp
Σ
)
.
Context
(
IR
:
R
->
iProp
Σ
)
.
Axiom
HIT
:
∀
v
t
r
,
ITR
(
t
,
r
)
v
-∗
IT
t
v
∗
IR
r
.
Axiom
HIU
:
∀
v
u
r
,
(
IU
u
v
∗
IR
r
)
-∗
IUR
(
u
,
r
)
v
.
Lemma
example
:
⊢
(
<!
(
v
:
val
)
(
t
:
T
)
>
MSG
v
{{
IT
t
v
}};
<
?
(
w
:
val
)
(
u
:
U
)
>
MSG
w
{{
IU
u
w
}};
END
)
⊑
(
<!
(
v
:
val
)
(
t
:
T
)
(
r
:
R
)
>
MSG
v
{{
ITR
(
t
,
r
)
v
}};
<
?
(
w
:
val
)
(
u
:
U
)
>
MSG
w
{{
IUR
(
u
,
r
)
w
}};
END
)
.
Proof
.
iIntros
(
v
t
r
)
"HTR"
.
iDestruct
(
HIT
with
"HTR"
)
as
"[HT HR]"
.
iExists
v
,
t
.
iFrame
"HT"
.
iModIntro
.
iIntros
(
w
u
)
"HU"
.
iDestruct
(
HIU
with
"[$HR $HU]"
)
as
"HUR"
.
iExists
w
,
u
.
iFrame
"HUR"
.
eauto
.
Qed
.
End
program_reuse
.
End
basics
.
End
basics
.
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