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
0d55d5de
Commit
0d55d5de
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Some mapper clean up.
parent
1fa2c070
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_CoqProject
+1
-0
1 addition, 0 deletions
_CoqProject
theories/examples/mapper.v
+16
-17
16 additions, 17 deletions
theories/examples/mapper.v
with
17 additions
and
17 deletions
_CoqProject
+
1
−
0
View file @
0d55d5de
...
...
@@ -15,3 +15,4 @@ theories/examples/sort_client.v
theories/examples/sort_elem.v
theories/examples/loop_sort.v
theories/examples/sort_elem_client.v
theories/examples/mapper.v
This diff is collapsed.
Click to expand it.
theories/examples/mapper.v
+
16
−
17
View file @
0d55d5de
...
...
@@ -26,7 +26,7 @@ Definition start_mappers : val :=
Fork
(
mapper
"f"
"l"
"c"
);;
"go"
(
"n"
-
#
1
)
"f"
"l"
"c"
.
Definition
loop_
mapper
s
:
val
:=
Definition
mapper
_service_loop
:
val
:=
rec
:
"go"
"n"
"c"
"xs"
"ys"
:=
if
:
"n"
=
#
0
then
"ys"
else
if
:
recv
"c"
then
...
...
@@ -45,7 +45,7 @@ Definition mapper_service : val := λ: "n" "f" "xs",
let
:
"l"
:=
new_lock
#
()
in
let
:
"c"
:=
start_chan
(
λ
:
"c"
,
start_mappers
"n"
"f"
"l"
"c"
)
in
loop_
mapper
s
"n"
"c"
"xs"
(
lnil
#
())
.
mapper
_service_loop
"n"
"c"
"xs"
(
lnil
#
())
.
Class
map_sortG
Σ
A
`{
Countable
A
}
:=
{
map_sort_contributionG
:>
contributionG
Σ
(
gmultisetUR
A
);
...
...
@@ -135,19 +135,19 @@ Section mapper.
wp_apply
(
"IH"
with
"[$] [$] [$]"
)
.
Qed
.
Lemma
loop_
mapper
s
_spec
(
n
:
nat
)
c
vs
xs
ws
X_send
xs_recv
:
Lemma
mapper
_service_loop
_spec
(
n
:
nat
)
c
vs
xs
ws
X_send
xs_recv
:
(
n
=
0
→
X_send
=
∅
∧
xs
=
[])
→
{{{
c
↣
mapper_protocol
n
(
X_send
:
gmultiset
A
)
@
N
∗
([
∗
list
]
x
;
v
∈
xs
;
vs
,
IA
x
v
)
∗
([
∗
list
]
x
;
w
∈
xs_recv
;
ws
,
IB
(
f
x
)
w
)
}}}
loop_
mapper
s
#
n
c
(
val_encode
vs
)
(
val_encode
ws
)
mapper
_service_loop
#
n
c
(
val_encode
vs
)
(
val_encode
ws
)
{{{
ys
ws
,
RET
(
val_encode
ws
);
⌜
ys
++
(
f
<$>
xs_recv
)
≡
ₚ
f
<$>
(
elements
X_send
++
xs
++
xs_recv
)
⌝
∗
⌜
ys
≡
ₚ
f
<$>
elements
X_send
++
xs
⌝
∗
[
∗
list
]
y
;
w
∈
ys
++
(
f
<$>
xs_recv
);
ws
,
IB
y
w
}}}
.
Proof
.
iIntros
(
Hn
Φ
)
"(Hc & H
xs
& H
xs_recv
) HΦ"
.
iIntros
(
Hn
Φ
)
"(Hc & H
IA
& H
IB
) HΦ"
.
iLöb
as
"IH"
forall
(
n
vs
xs
ws
X_send
xs_recv
Hn
Φ
);
wp_rec
;
wp_pures
;
simpl
.
case_bool_decide
;
wp_pures
;
simplify_eq
/=.
{
destruct
Hn
as
[
->
->
];
first
lia
.
...
...
@@ -157,26 +157,25 @@ Section mapper.
destruct
vs
as
[|
v
vs
],
xs
as
[|
x
xs
];
csimpl
;
try
done
;
wp_pures
.
+
wp_select
.
wp_pures
.
rewrite
Nat2Z
.
inj_succ
Z
.
sub_1_r
Z
.
pred_succ
.
iApply
(
"IH"
with
"[] Hc [//] [$] HΦ"
)
.
iPureIntro
;
naive_solver
.
+
iDestruct
"H
xs
"
as
"[Hx H
xs
]"
.
wp_select
.
+
iDestruct
"H
IA
"
as
"[H
IA
x H
IA
]"
.
wp_select
.
wp_apply
(
lhead_spec
(
A
:=
val
)
with
"[//]"
);
iIntros
(_)
.
wp_send
with
"[$Hx]"
.
wp_send
with
"[$H
IA
x]"
.
wp_apply
(
ltail_spec
(
A
:=
val
)
with
"[//]"
);
iIntros
(_)
.
wp_apply
(
"IH"
with
"[] Hc H
xs Hxs_recv
"
);
first
done
.
wp_apply
(
"IH"
with
"[] Hc H
IA HIB
"
);
first
done
.
iIntros
(
ys
ws'
)
.
rewrite
gmultiset_elements_disj_union
gmultiset_elements_singleton
-!
assoc_L
.
iApply
"HΦ"
.
-
wp_recv
(
x
w
)
as
(
HH
)
"HIfx"
.
-
wp_recv
(
x
w
)
as
(
HH
)
"HI
B
fx"
.
wp_apply
(
lcons_spec
(
A
:=
val
)
with
"[//]"
);
iIntros
(_)
.
wp_apply
(
"IH"
$!
_
_
_
_
_
(_
::
_)
with
"[] Hc H
xs
[HIfx H
xs_recv
]"
);
first
done
.
wp_apply
(
"IH"
$!
_
_
_
_
_
(_
::
_)
with
"[] Hc H
IA
[HI
B
fx H
IB
]"
);
first
done
.
{
simpl
;
iFrame
.
}
iIntros
(
ys
ws'
);
iDestruct
1
as
(
Hys
)
"H"
;
simplify_eq
/=.
iIntros
(
ys
ws'
);
iDestruct
1
as
(
Hys
)
"H
IB
"
;
simplify_eq
/=.
iApply
(
"HΦ"
$!
(
ys
++
[
f
x
]))
.
iSplit
.
+
iPureIntro
.
rewrite
-
assoc_L
/=
Hys
.
rewrite
{
2
}(
gmultiset_disj_union_difference
{[
x
]}
X_send
)
+
iPureIntro
.
rewrite
(
gmultiset_disj_union_difference
{[
x
]}
X_send
)
-
?gmultiset_elem_of_singleton_subseteq
//.
rewrite
(
comm
disj_union
)
gmultiset_elements_disj_union
.
rewrite
gmultiset_elements_singleton
.
by
rewrite
-
assoc_L
(
assoc_L
_
[
x
])
(
comm
_
[
x
])
-!
assoc_L
.
rewrite
gmultiset_elements_singleton
-
assoc_L
(
comm
_
[
x
])
assoc_L
.
by
rewrite
fmap_app
-
Hys
.
+
by
rewrite
-
assoc_L
.
Qed
.
...
...
@@ -198,7 +197,7 @@ Section mapper.
{
iExists
n
,
∅.
iFrame
.
}
wp_apply
(
start_mappers_spec
with
"Hf [$Hlk $Hu $Hγs]"
);
auto
.
}
wp_pures
.
wp_apply
(
lnil_spec
with
"[//]"
);
iIntros
(_)
.
wp_apply
(
loop_
mapper
s
_spec
_
_
_
_
[]
∅
[]
with
"[$Hc $HI //]"
);
first
lia
.
wp_apply
(
mapper
_service_loop
_spec
_
_
_
_
[]
∅
[]
with
"[$Hc $HI //]"
);
first
lia
.
iIntros
(
ys
ws
)
.
rewrite
/=
!
right_id_L
gmultiset_elements_empty
.
iApply
"HΦ"
.
Qed
.
End
mapper
.
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