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
afed8a40
Commit
afed8a40
authored
1 year ago
by
Jonas Kastberg
Browse files
Options
Downloads
Patches
Plain Diff
Clean up
parent
4dd80e83
Branches
Branches containing commit
No related tags found
1 merge request
!39
Multiparty synchronous
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
multi_actris/examples/leader_election_del_alt.v
+36
-57
36 additions, 57 deletions
multi_actris/examples/leader_election_del_alt.v
with
36 additions
and
57 deletions
multi_actris/examples/leader_election_del_alt.v
+
36
−
57
View file @
afed8a40
...
@@ -24,7 +24,6 @@ Definition process : val :=
...
@@ -24,7 +24,6 @@ Definition process : val :=
Definition
init
:
val
:=
Definition
init
:
val
:=
λ
:
"c"
"idl"
"id"
"idr"
,
λ
:
"c"
"idl"
"id"
"idr"
,
(* Notice missing leader *)
send
"c"
"idl"
#
true
;;
send
"c"
"idl"
"id"
;;
send
"c"
"idl"
#
true
;;
send
"c"
"idl"
"id"
;;
process
"c"
"idl"
"id"
"idr"
#
true
.
process
"c"
"idl"
"id"
"idr"
#
true
.
...
@@ -53,11 +52,11 @@ Definition program : val :=
...
@@ -53,11 +52,11 @@ Definition program : val :=
let
:
"c1"
:=
get_chan
"cs"
#
1
in
let
:
"c1"
:=
get_chan
"cs"
#
1
in
let
:
"c2"
:=
get_chan
"cs"
#
2
in
let
:
"c2"
:=
get_chan
"cs"
#
2
in
let
:
"c3"
:=
get_chan
"cs"
#
3
in
let
:
"c3"
:=
get_chan
"cs"
#
3
in
Fork
(
let
:
"id_max"
:=
process
"c1"
#
0
#
1
#
2
#
false
in
Fork
(
let
:
"id_max"
:=
process
"c1"
#
0
#
1
#
2
#
false
in
forward
"c1"
"c1'"
#
0
#
1
#
2
"id_max"
);;
forward
"c1"
"c1'"
#
0
#
1
#
2
"id_max"
);;
Fork
(
let
:
"id_max"
:=
process
"c2"
#
1
#
2
#
3
#
false
in
Fork
(
let
:
"id_max"
:=
process
"c2"
#
1
#
2
#
3
#
false
in
forward
"c2"
"c1'"
#
1
#
2
#
3
"id_max"
);;
forward
"c2"
"c1'"
#
1
#
2
#
3
"id_max"
);;
Fork
(
let
:
"id_max"
:=
process
"c3"
#
2
#
3
#
0
#
false
in
Fork
(
let
:
"id_max"
:=
process
"c3"
#
2
#
3
#
0
#
false
in
forward
"c3"
"c1'"
#
2
#
3
#
0
"id_max"
);;
forward
"c3"
"c1'"
#
2
#
3
#
0
"id_max"
);;
let
:
"id_max"
:=
init
"c0"
#
3
#
0
#
1
in
let
:
"id_max"
:=
init
"c0"
#
3
#
0
#
1
in
forward
"c0"
"c1'"
#
3
#
0
#
1
"id_max"
.
forward
"c0"
"c1'"
#
3
#
0
#
1
"id_max"
.
...
@@ -79,15 +78,18 @@ Section ring_leader_election_example.
...
@@ -79,15 +78,18 @@ Section ring_leader_election_example.
then
<
(
Send
,
il
)
>
MSG
#
false
;
<
(
Send
,
il
)
>
MSG
#
i
;
rec
false
then
<
(
Send
,
il
)
>
MSG
#
false
;
<
(
Send
,
il
)
>
MSG
#
i
;
rec
false
else
if
isp
then
rec
isp
else
if
isp
then
rec
isp
else
<
(
Send
,
il
)
>
MSG
#
true
;
<
(
Send
,
il
)
>
MSG
#
i
;
rec
true
)
%
proto
else
<
(
Send
,
il
)
>
MSG
#
true
;
<
(
Send
,
il
)
>
MSG
#
i
;
rec
true
)
%
proto
(
<
(
Recv
,
ir
)
@
(
i'
:
nat
)
>
MSG
#
i'
{{
if
bool_decide
(
i
=
i'
)
then
P
else
True
%
I
}};
(
<
(
Recv
,
ir
)
@
(
i'
:
nat
)
>
MSG
#
i'
{{
if
bool_decide
(
i
=
i'
)
then
P
else
True
%
I
}};
if
(
bool_decide
(
i
=
i'
))
then
p
i
if
(
bool_decide
(
i
=
i'
))
then
p
i
else
<
(
Send
,
il
)
>
MSG
#
false
;
<
(
Send
,
il
)
>
MSG
#
i'
;
p
i'
)
%
proto
.
else
<
(
Send
,
il
)
>
MSG
#
false
;
<
(
Send
,
il
)
>
MSG
#
i'
;
p
i'
)
%
proto
.
Instance
rle_prot_aux_contractive
il
i
ir
P
p
:
Contractive
(
my_recv_prot
il
i
ir
P
p
)
.
Instance
rle_prot_aux_contractive
il
i
ir
P
p
:
Contractive
(
my_recv_prot
il
i
ir
P
p
)
.
Proof
.
rewrite
/
my_recv_prot
.
solve_proto_contractive
.
Qed
.
Proof
.
rewrite
/
my_recv_prot
.
solve_proto_contractive
.
Qed
.
Definition
rle_prot
il
i
ir
P
p
:=
fixpoint
(
my_recv_prot
il
i
ir
P
p
)
.
Definition
rle_prot
il
i
ir
P
p
:=
fixpoint
(
my_recv_prot
il
i
ir
P
p
)
.
Instance
rle_prot_unfold
il
i
ir
isp
P
p
:
Instance
rle_prot_unfold
il
i
ir
isp
P
p
:
ProtoUnfold
(
rle_prot
il
i
ir
P
p
isp
)
(
my_recv_prot
il
i
ir
P
p
(
rle_prot
il
i
ir
P
p
)
isp
)
.
ProtoUnfold
(
rle_prot
il
i
ir
P
p
isp
)
(
my_recv_prot
il
i
ir
P
p
(
rle_prot
il
i
ir
P
p
)
isp
)
.
Proof
.
apply
proto_unfold_eq
,
(
fixpoint_unfold
(
my_recv_prot
il
i
ir
P
p
))
.
Qed
.
Proof
.
apply
proto_unfold_eq
,
(
fixpoint_unfold
(
my_recv_prot
il
i
ir
P
p
))
.
Qed
.
Lemma
rle_prot_unfold'
il
i
ir
isp
P
p
:
Lemma
rle_prot_unfold'
il
i
ir
isp
P
p
:
(
rle_prot
il
i
ir
P
p
isp
)
≡
(
rle_prot
il
i
ir
P
p
isp
)
≡
...
@@ -107,42 +109,27 @@ Section ring_leader_election_example.
...
@@ -107,42 +109,27 @@ Section ring_leader_election_example.
iLöb
as
"IH"
forall
(
Φ
isp
)
.
iLöb
as
"IH"
forall
(
Φ
isp
)
.
wp_lam
.
wp_recv
(
b
)
as
"_"
.
wp_lam
.
wp_recv
(
b
)
as
"_"
.
destruct
b
.
destruct
b
.
-
wp_pures
.
wp_recv
(
i'
)
as
"_"
.
-
wp_recv
(
i'
)
as
"_"
.
wp_pures
.
wp_pures
.
case_bool_decide
as
Hlt
.
case_bool_decide
as
Hlt
.
{
case_bool_decide
;
[|
lia
]
.
{
case_bool_decide
;
[|
lia
]
.
wp_pures
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_pures
.
wp_smart_apply
(
"IH"
with
"Hc HΦ"
)
.
}
iApply
(
"IH"
with
"Hc HΦ"
)
.
}
case_bool_decide
as
Hlt2
.
case_bool_decide
as
Hlt2
.
{
case_bool_decide
;
[
lia
|]
.
{
case_bool_decide
;
[
lia
|]
.
wp_pures
.
case_bool_decide
;
[|
simplify_eq
;
lia
]
.
wp_pures
.
case_bool_decide
;
[|
simplify_eq
;
lia
]
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_smart_apply
(
"IH"
with
"Hc HΦ"
)
.
}
wp_send
with
"[//]"
.
wp_pures
.
iApply
(
"IH"
with
"Hc HΦ"
)
.
}
case_bool_decide
;
[
lia
|]
.
case_bool_decide
;
[
lia
|]
.
wp_pures
.
wp_pures
.
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
wp_pures
.
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
destruct
isp
;
[
by
wp_smart_apply
(
"IH"
with
"Hc HΦ"
)|]
.
wp_pures
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
destruct
isp
.
wp_smart_apply
(
"IH"
with
"Hc HΦ"
)
.
{
wp_pures
.
iApply
(
"IH"
with
"Hc HΦ"
)
.
}
-
wp_recv
(
id'
)
as
"HP"
.
wp_pures
.
wp_pures
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_pures
.
iApply
(
"IH"
with
"Hc HΦ"
)
.
-
wp_pures
.
wp_recv
(
id'
)
as
"HP"
.
wp_pures
.
case_bool_decide
as
Hlt
.
case_bool_decide
as
Hlt
.
{
case_bool_decide
;
[|
simplify_eq
;
lia
]
.
{
case_bool_decide
;
[|
simplify_eq
;
lia
]
.
wp_pures
.
subst
.
iApply
"HΦ"
.
wp_pures
.
subst
.
iApply
"HΦ"
.
iFrame
.
by
case_bool_decide
.
}
iFrame
.
case_bool_decide
;
[|
lia
]
.
done
.
}
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_pures
.
iApply
"HΦ"
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_pures
.
iApply
"HΦ"
.
iFrame
.
iFrame
.
by
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
done
.
Qed
.
Qed
.
Lemma
init_spec
c
il
i
ir
p
P
:
Lemma
init_spec
c
il
i
ir
p
P
:
...
@@ -151,7 +138,7 @@ Section ring_leader_election_example.
...
@@ -151,7 +138,7 @@ Section ring_leader_election_example.
{{{
i'
,
RET
#
i'
;
c
↣
p
i'
∗
if
(
bool_decide
(
i
=
i'
))
then
P
else
True
%
I
}}}
.
{{{
i'
,
RET
#
i'
;
c
↣
p
i'
∗
if
(
bool_decide
(
i
=
i'
))
then
P
else
True
%
I
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"[Hc HP] HΦ"
.
wp_lam
.
wp_send
with
"[//]"
.
wp_send
with
"[HP//]"
.
iIntros
(
Φ
)
"[Hc HP] HΦ"
.
wp_lam
.
wp_send
with
"[//]"
.
wp_send
with
"[HP//]"
.
wp_
pures
.
iA
pply
(
process_spec
with
"Hc HΦ"
)
.
wp_
smart_a
pply
(
process_spec
with
"Hc HΦ"
)
.
Qed
.
Qed
.
Definition
forward_prot
(
P
:
iProp
Σ
)
(
il
i
ir
i_max
:
nat
)
:
iProto
Σ
:=
Definition
forward_prot
(
P
:
iProp
Σ
)
(
il
i
ir
i_max
:
nat
)
:
iProto
Σ
:=
...
@@ -214,8 +201,7 @@ Section ring_leader_election_example.
...
@@ -214,8 +201,7 @@ Section ring_leader_election_example.
Qed
.
Qed
.
Definition
prot_pool'
:
list
(
iProto
Σ
)
:=
Definition
prot_pool'
:
list
(
iProto
Σ
)
:=
[
relay_recv_preprot
;
[
relay_recv_preprot
;
relay_send_preprot
]
.
relay_send_preprot
]
.
Lemma
prot_pool_consistent'
:
⊢
iProto_consistent
(
prot_pool'
)
.
Lemma
prot_pool_consistent'
:
⊢
iProto_consistent
(
prot_pool'
)
.
Proof
.
Proof
.
...
@@ -229,7 +215,7 @@ Section ring_leader_election_example.
...
@@ -229,7 +215,7 @@ Section ring_leader_election_example.
Qed
.
Qed
.
Lemma
forward_spec
c
c'
il
i
ir
i_max
:
Lemma
forward_spec
c
c'
il
i
ir
i_max
:
{{{
c
↣
forward_prot
(
c'
↣
relay_send_prot
i_max
)
il
i
ir
i_max
∗
{{{
c
↣
forward_prot
(
c'
↣
relay_send_prot
i_max
)
il
i
ir
i_max
∗
if
(
bool_decide
(
i
=
i_max
))
then
c'
↣
relay_send_preprot
else
True
%
I
}}}
if
(
bool_decide
(
i
=
i_max
))
then
c'
↣
relay_send_preprot
else
True
%
I
}}}
forward
c
c'
#
il
#
i
#
ir
#
i_max
forward
c
c'
#
il
#
i
#
ir
#
i_max
{{{
RET
#
();
True
}}}
.
{{{
RET
#
();
True
}}}
.
...
@@ -239,34 +225,27 @@ Section ring_leader_election_example.
...
@@ -239,34 +225,27 @@ Section ring_leader_election_example.
wp_pures
.
case_bool_decide
.
wp_pures
.
case_bool_decide
.
-
simplify_eq
.
wp_pures
.
-
simplify_eq
.
wp_pures
.
case_bool_decide
;
[|
simplify_eq
;
lia
]
.
case_bool_decide
;
[|
simplify_eq
;
lia
]
.
wp_send
with
"[//]"
.
wp_send
with
"[//]"
.
wp_send
with
"[Hc'//]"
.
wp_recv
as
"Hc'"
.
wp_pures
.
wp_send
with
"[Hc'//]"
.
wp_recv
as
"Hc'"
.
by
iApply
"HΦ"
.
-
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
wp_pures
.
iClear
"Hc'"
.
wp_recv
as
"Hc'"
.
wp_send
with
"[//]"
.
wp_send
with
"[Hc'//]"
.
by
iApply
"HΦ"
.
by
iApply
"HΦ"
.
-
case_bool_decide
;
[
simplify_eq
;
lia
|]
.
iClear
"Hc'"
.
wp_recv
as
"Hc'"
.
wp_send
with
"[//]"
.
wp_send
with
"[Hc'//]"
.
by
iApply
"HΦ"
.
Qed
.
Qed
.
Lemma
program_spec
:
Lemma
program_spec
:
{{{
True
}}}
program
#
()
{{{
RET
#
();
True
}}}
.
{{{
True
}}}
program
#
()
{{{
RET
#
();
True
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_new_chan
(
prot_pool'
)
with
(
prot_pool_consistent'
)
wp_new_chan
(
prot_pool'
)
with
(
prot_pool_consistent'
)
as
(
c0'
c1'
)
"Hc0'"
"Hc1'"
.
as
(
c0'
c1'
)
"Hc0'"
"Hc1'"
.
wp_smart_apply
(
wp_fork
with
"[Hc0']"
)
.
wp_smart_apply
(
wp_fork
with
"[Hc0']"
)
.
{
iIntros
"!>"
.
{
iIntros
"!>"
.
wp_recv
(
i_max
)
as
"_"
.
wp_pures
.
wp_pures
.
iLöb
as
"IH"
.
wp_recv
as
"_"
.
wp_smart_apply
wp_assert
.
wp_recv
(
i_max
)
as
"_"
.
wp_pures
.
iLöb
as
"IH"
.
wp_recv
as
"_"
.
wp_pures
.
wp_smart_apply
wp_assert
.
wp_pures
.
iModIntro
.
iSplit
;
[
iPureIntro
;
f_equiv
;
by
case_bool_decide
|]
.
wp_pures
.
iModIntro
.
iSplit
;
[
iPureIntro
;
f_equiv
;
by
case_bool_decide
|]
.
iIntros
"!>"
.
wp_pures
.
by
iApply
"IH"
.
}
iIntros
"!>"
.
wp_pures
.
by
iApply
"IH"
.
}
wp_new_chan
(
prot_pool
(
c1'
↣
relay_send_preprot
)
(
λ
i_max
,
c1'
↣
relay_send_prot
i_max
))
with
prot_pool_consistent
wp_new_chan
(
prot_pool
(
c1'
↣
relay_send_preprot
)
as
(
c0
c1
c2
c3
)
"Hc0"
"Hc1"
"Hc2"
"Hc3"
.
(
λ
i_max
,
c1'
↣
relay_send_prot
i_max
))
with
prot_pool_consistent
as
(
c0
c1
c2
c3
)
"Hc0"
"Hc1"
"Hc2"
"Hc3"
.
wp_smart_apply
(
wp_fork
with
"[Hc1]"
)
.
wp_smart_apply
(
wp_fork
with
"[Hc1]"
)
.
{
iIntros
"!>"
.
wp_smart_apply
(
process_spec
with
"Hc1"
)
.
{
iIntros
"!>"
.
wp_smart_apply
(
process_spec
with
"Hc1"
)
.
iIntros
(
i'
)
"Hc1"
.
by
wp_smart_apply
(
forward_spec
with
"[$Hc1]"
)
.
}
iIntros
(
i'
)
"Hc1"
.
by
wp_smart_apply
(
forward_spec
with
"[$Hc1]"
)
.
}
...
...
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