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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Dan Frumin
Actris
Commits
be06d3b6
Commit
be06d3b6
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Move `group` stuff to its own file.
parent
6c83c489
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
_CoqProject
+1
-0
1 addition, 0 deletions
_CoqProject
theories/examples/map_reduce.v
+2
-118
2 additions, 118 deletions
theories/examples/map_reduce.v
theories/examples/sort_fg.v
+1
-1
1 addition, 1 deletion
theories/examples/sort_fg.v
theories/utils/group.v
+114
-0
114 additions, 0 deletions
theories/utils/group.v
with
118 additions
and
119 deletions
_CoqProject
+
1
−
0
View file @
be06d3b6
...
...
@@ -4,6 +4,7 @@ theories/utils/auth_excl.v
theories/utils/llist.v
theories/utils/compare.v
theories/utils/contribution.v
theories/utils/group.v
theories/channel/channel.v
theories/channel/proto_model.v
theories/channel/proto_channel.v
...
...
This diff is collapsed.
Click to expand it.
theories/examples/map_reduce.v
+
2
−
118
View file @
be06d3b6
From
stdpp
Require
Import
sorting
.
From
actris
.
channel
Require
Import
proto_channel
proofmode
.
From
iris
.
heap_lang
Require
Import
proofmode
notation
.
From
actris
.
utils
Require
Import
llist
compare
contribution
.
From
actris
.
utils
Require
Import
llist
compare
contribution
group
.
From
actris
.
examples
Require
Import
map
sort_fg_client
.
From
iris
.
algebra
Require
Import
gmultiset
.
From
Coq
Require
Import
SetoidPermutation
.
(** Functional version of map reduce (aka the specification) *)
Fixpoint
group_insert
{
A
}
`{
EqDecision
K
}
(
i
:
K
)
(
x
:
A
)
(
ixss
:
list
(
K
*
list
A
))
:
list
(
K
*
list
A
)
:=
match
ixss
with
|
[]
=>
[(
i
,[
x
])]
|
(
j
,
xs
)
::
ixss
=>
if
decide
(
i
=
j
)
then
(
j
,
x
::
xs
)
::
ixss
else
(
j
,
xs
)
::
group_insert
i
x
ixss
end
.
Fixpoint
group
{
A
}
`{
EqDecision
K
}
(
ixs
:
list
(
K
*
A
))
:
list
(
K
*
list
A
)
:=
match
ixs
with
|
[]
=>
[]
|
(
i
,
x
)
::
ixs
=>
group_insert
i
x
(
group
ixs
)
end
.
Definition
map_reduce
{
A
B
C
}
`{
EqDecision
K
}
(
map
:
A
→
list
(
K
*
B
))
(
red
:
K
→
list
B
→
list
C
)
:
list
A
→
list
C
:=
mbind
(
curry
red
)
∘
group
∘
mbind
map
.
Instance
:
Params
(
@
group_insert
)
5
.
Instance
:
Params
(
@
group
)
3
.
Instance
:
Params
(
@
group
)
7
.
Instance
:
Params
(
@
map_reduce
)
7
.
(** Distributed version *)
Definition
par_map_reduce_map
:
val
:=
...
...
@@ -91,101 +71,6 @@ Definition par_map_reduce : val := λ: "n" "map" "red" "xs",
(** Properties about the functional version *)
Local
Infix
"≡ₚₚ"
:=
(
PermutationA
(
prod_relation
(
=
)
(
≡
ₚ
)))
(
at
level
70
,
no
associativity
)
:
stdpp_scope
.
Notation
"(≡ₚₚ)"
:=
(
PermutationA
(
prod_relation
(
=
)
(
≡
ₚ
)))
(
only
parsing
)
:
stdpp_scope
.
Section
group
.
Context
{
A
:
Type
}
`{
EqDecision
K
}
.
Implicit
Types
i
:
K
.
Implicit
Types
xs
:
list
A
.
Implicit
Types
ixs
:
list
(
K
*
A
)
.
Implicit
Types
ixss
:
list
(
K
*
list
A
)
.
Lemma
elem_of_group_insert
j
i
x
ixss
:
j
∈
(
group_insert
i
x
ixss
).
*
1
→
i
=
j
∨
j
∈
ixss
.
*
1
.
Proof
.
induction
ixss
as
[|[
i'
x'
]
ixss
IH
];
repeat
(
simplify_eq
/=
||
case_decide
);
set_solver
.
Qed
.
Lemma
group_insert_commute
i1
i2
x1
x2
ixss
:
group_insert
i1
x1
(
group_insert
i2
x2
ixss
)
≡
ₚₚ
group_insert
i2
x2
(
group_insert
i1
x1
ixss
)
.
Proof
.
induction
ixss
as
[|[
j
x
]
ixss
IH
];
repeat
(
simplify_eq
/=
||
case_decide
);
repeat
constructor
;
done
.
Qed
.
Lemma
group_insert_nodup
i
x
ixss
:
NoDup
ixss
.
*
1
→
NoDup
(
group_insert
i
x
ixss
).
*
1
.
Proof
.
pose
proof
@
elem_of_group_insert
.
induction
ixss
as
[|[
j
xs
]
ixss
IH
];
csimpl
;
inversion_clear
1
;
repeat
(
simplify_eq
/=
||
case_decide
);
repeat
constructor
;
set_solver
.
Qed
.
Lemma
group_nodup
ixs
:
NoDup
(
group
ixs
).
*
1
.
Proof
.
induction
ixs
as
[|[
i
x
]
ixs
IH
];
csimpl
;
auto
using
group_insert_nodup
,
NoDup_nil_2
.
Qed
.
Lemma
grouped_permutation_elem_of
ixss1
ixss2
i
:
ixss1
≡
ₚₚ
ixss2
→
i
∈
ixss1
.
*
1
→
i
∈
ixss2
.
*
1
.
Proof
.
induction
1
as
[|[
i1
xs1
]
[
i2
xs2
]
ixss1
ixss2
[??]|[
i1
xs1
]
[
i2
xs2
]
ixss
|];
set_solver
.
Qed
.
Lemma
grouped_permutation_nodup
ixss1
ixss2
:
ixss1
≡
ₚₚ
ixss2
→
NoDup
ixss1
.
*
1
→
NoDup
ixss2
.
*
1
.
Proof
.
pose
proof
@
grouped_permutation_elem_of
.
induction
1
as
[|[
i1
xs1
]
[
i2
xs2
]
ixss1
ixss2
[??]|[
i1
xs1
]
[
i2
xs2
]
ixss
|];
csimpl
;
rewrite
?NoDup_cons
;
try
set_solver
.
Qed
.
Lemma
group_insert_perm
ixss1
ixss2
i
x
:
NoDup
ixss1
.
*
1
→
ixss1
≡
ₚₚ
ixss2
→
group_insert
i
x
ixss1
≡
ₚₚ
group_insert
i
x
ixss2
.
Proof
.
induction
2
as
[|[
i1
xs1
]
[
i2
xs2
]
ixss1
ixss2
[??]|[
i1
xs1
]
[
i2
xs2
]
ixss
|];
repeat
match
goal
with
|
_
=>
progress
(
simplify_eq
/=
||
case_decide
)
|
H
:
NoDup
(_
::
_)
|
-
_
=>
inversion_clear
H
end
;
first
[
repeat
constructor
;
by
auto
|
set_solver
|
etrans
;
eauto
using
grouped_permutation_nodup
]
.
Qed
.
Global
Instance
group_perm
:
Proper
((
≡
ₚ
)
==>
(
≡
ₚₚ
))
(
@
group
A
K
_)
.
Proof
.
induction
1
;
repeat
(
simplify_eq
/=
||
case_decide
||
case_match
);
first
[
by
etrans
|
auto
using
group_insert_perm
,
group_nodup
,
group_insert_commute
]
.
Qed
.
Lemma
group_fmap
(
i
:
K
)
xs
:
xs
≠
[]
→
group
((
i
,)
<$>
xs
)
≡
ₚₚ
[(
i
,
xs
)]
.
Proof
.
induction
xs
as
[|
x1
[|
x2
xs
]
IH
];
intros
;
simplify_eq
/=
;
try
done
.
etrans
.
{
apply
group_insert_perm
,
IH
;
auto
using
group_insert_nodup
,
group_nodup
.
}
simpl
;
by
case_decide
.
Qed
.
Lemma
group_insert_snoc
ixss
i
x
j
ys
:
i
≠
j
→
group_insert
i
x
(
ixss
++
[(
j
,
ys
)])
≡
ₚₚ
group_insert
i
x
ixss
++
[(
j
,
ys
)]
.
Proof
.
intros
.
induction
ixss
as
[|[
i'
xs'
]
ixss
IH
];
repeat
(
simplify_eq
/=
||
case_decide
);
repeat
constructor
;
by
auto
.
Qed
.
Lemma
group_snoc
ixs
j
ys
:
j
∉
ixs
.
*
1
→
ys
≠
[]
→
group
(
ixs
++
((
j
,)
<$>
ys
))
≡
ₚₚ
group
ixs
++
[(
j
,
ys
)]
.
Proof
.
induction
ixs
as
[|[
i
x
]
ixs
IH
];
csimpl
;
first
by
auto
using
group_fmap
.
rewrite
?not_elem_of_cons
=>
-
[??]
.
etrans
;
last
by
apply
group_insert_snoc
.
apply
group_insert_perm
,
IH
;
auto
using
group_nodup
.
Qed
.
End
group
.
Section
map_reduce
.
Context
{
A
B
C
}
`{
EqDecision
K
}
(
map
:
A
→
list
(
K
*
B
))
(
red
:
K
→
list
B
→
list
C
)
.
Context
`{
!∀
j
,
Proper
((
≡
ₚ
)
==>
(
≡
ₚ
))
(
red
j
)}
.
...
...
@@ -202,7 +87,6 @@ Section map_reduce.
Proof
.
intros
xs1
xs2
Hxs
.
by
rewrite
/
map_reduce
/=
Hxs
.
Qed
.
End
map_reduce
.
(** Correctness proofs of the distributed version *)
Class
map_reduceG
Σ
A
B
`{
Countable
A
,
Countable
B
}
:=
{
map_reduce_mapG
:>
mapG
Σ
A
;
...
...
This diff is collapsed.
Click to expand it.
theories/examples/sort_fg.v
+
1
−
1
View file @
be06d3b6
From
stdpp
Require
Im
port
sorting
.
From
stdpp
Require
Ex
port
sorting
.
From
actris
.
channel
Require
Import
proto_channel
proofmode
.
From
iris
.
heap_lang
Require
Import
proofmode
notation
.
From
iris
.
heap_lang
Require
Import
assert
.
...
...
This diff is collapsed.
Click to expand it.
theories/utils/group.v
0 → 100644
+
114
−
0
View file @
be06d3b6
From
stdpp
Require
Export
prelude
.
From
Coq
Require
Export
SetoidPermutation
.
Fixpoint
group_insert
{
A
}
`{
EqDecision
K
}
(
i
:
K
)
(
x
:
A
)
(
ixss
:
list
(
K
*
list
A
))
:
list
(
K
*
list
A
)
:=
match
ixss
with
|
[]
=>
[(
i
,[
x
])]
|
(
j
,
xs
)
::
ixss
=>
if
decide
(
i
=
j
)
then
(
j
,
x
::
xs
)
::
ixss
else
(
j
,
xs
)
::
group_insert
i
x
ixss
end
.
Fixpoint
group
{
A
}
`{
EqDecision
K
}
(
ixs
:
list
(
K
*
A
))
:
list
(
K
*
list
A
)
:=
match
ixs
with
|
[]
=>
[]
|
(
i
,
x
)
::
ixs
=>
group_insert
i
x
(
group
ixs
)
end
.
Instance
:
Params
(
@
group_insert
)
5
.
Instance
:
Params
(
@
group
)
3
.
Local
Infix
"≡ₚₚ"
:=
(
PermutationA
(
prod_relation
(
=
)
(
≡
ₚ
)))
(
at
level
70
,
no
associativity
)
:
stdpp_scope
.
Notation
"(≡ₚₚ)"
:=
(
PermutationA
(
prod_relation
(
=
)
(
≡
ₚ
)))
(
only
parsing
)
:
stdpp_scope
.
Section
group
.
Context
{
A
:
Type
}
`{
EqDecision
K
}
.
Implicit
Types
i
:
K
.
Implicit
Types
xs
:
list
A
.
Implicit
Types
ixs
:
list
(
K
*
A
)
.
Implicit
Types
ixss
:
list
(
K
*
list
A
)
.
Lemma
elem_of_group_insert
j
i
x
ixss
:
j
∈
(
group_insert
i
x
ixss
).
*
1
→
i
=
j
∨
j
∈
ixss
.
*
1
.
Proof
.
induction
ixss
as
[|[
i'
x'
]
ixss
IH
];
repeat
(
simplify_eq
/=
||
case_decide
);
set_solver
.
Qed
.
Lemma
group_insert_commute
i1
i2
x1
x2
ixss
:
group_insert
i1
x1
(
group_insert
i2
x2
ixss
)
≡
ₚₚ
group_insert
i2
x2
(
group_insert
i1
x1
ixss
)
.
Proof
.
induction
ixss
as
[|[
j
x
]
ixss
IH
];
repeat
(
simplify_eq
/=
||
case_decide
);
repeat
constructor
;
done
.
Qed
.
Lemma
group_insert_nodup
i
x
ixss
:
NoDup
ixss
.
*
1
→
NoDup
(
group_insert
i
x
ixss
).
*
1
.
Proof
.
pose
proof
@
elem_of_group_insert
.
induction
ixss
as
[|[
j
xs
]
ixss
IH
];
csimpl
;
inversion_clear
1
;
repeat
(
simplify_eq
/=
||
case_decide
);
repeat
constructor
;
set_solver
.
Qed
.
Lemma
group_nodup
ixs
:
NoDup
(
group
ixs
).
*
1
.
Proof
.
induction
ixs
as
[|[
i
x
]
ixs
IH
];
csimpl
;
auto
using
group_insert_nodup
,
NoDup_nil_2
.
Qed
.
Lemma
grouped_permutation_elem_of
ixss1
ixss2
i
:
ixss1
≡
ₚₚ
ixss2
→
i
∈
ixss1
.
*
1
→
i
∈
ixss2
.
*
1
.
Proof
.
induction
1
as
[|[
i1
xs1
]
[
i2
xs2
]
ixss1
ixss2
[??]|[
i1
xs1
]
[
i2
xs2
]
ixss
|];
set_solver
.
Qed
.
Lemma
grouped_permutation_nodup
ixss1
ixss2
:
ixss1
≡
ₚₚ
ixss2
→
NoDup
ixss1
.
*
1
→
NoDup
ixss2
.
*
1
.
Proof
.
pose
proof
@
grouped_permutation_elem_of
.
induction
1
as
[|[
i1
xs1
]
[
i2
xs2
]
ixss1
ixss2
[??]|[
i1
xs1
]
[
i2
xs2
]
ixss
|];
csimpl
;
rewrite
?NoDup_cons
;
try
set_solver
.
Qed
.
Lemma
group_insert_perm
ixss1
ixss2
i
x
:
NoDup
ixss1
.
*
1
→
ixss1
≡
ₚₚ
ixss2
→
group_insert
i
x
ixss1
≡
ₚₚ
group_insert
i
x
ixss2
.
Proof
.
induction
2
as
[|[
i1
xs1
]
[
i2
xs2
]
ixss1
ixss2
[??]|[
i1
xs1
]
[
i2
xs2
]
ixss
|];
repeat
match
goal
with
|
_
=>
progress
(
simplify_eq
/=
||
case_decide
)
|
H
:
NoDup
(_
::
_)
|
-
_
=>
inversion_clear
H
end
;
first
[
repeat
constructor
;
by
auto
|
set_solver
|
etrans
;
eauto
using
grouped_permutation_nodup
]
.
Qed
.
Global
Instance
group_perm
:
Proper
((
≡
ₚ
)
==>
(
≡
ₚₚ
))
(
@
group
A
K
_)
.
Proof
.
induction
1
;
repeat
(
simplify_eq
/=
||
case_decide
||
case_match
);
first
[
by
etrans
|
auto
using
group_insert_perm
,
group_nodup
,
group_insert_commute
]
.
Qed
.
Lemma
group_fmap
(
i
:
K
)
xs
:
xs
≠
[]
→
group
((
i
,)
<$>
xs
)
≡
ₚₚ
[(
i
,
xs
)]
.
Proof
.
induction
xs
as
[|
x1
[|
x2
xs
]
IH
];
intros
;
simplify_eq
/=
;
try
done
.
etrans
.
{
apply
group_insert_perm
,
IH
;
auto
using
group_insert_nodup
,
group_nodup
.
}
simpl
;
by
case_decide
.
Qed
.
Lemma
group_insert_snoc
ixss
i
x
j
ys
:
i
≠
j
→
group_insert
i
x
(
ixss
++
[(
j
,
ys
)])
≡
ₚₚ
group_insert
i
x
ixss
++
[(
j
,
ys
)]
.
Proof
.
intros
.
induction
ixss
as
[|[
i'
xs'
]
ixss
IH
];
repeat
(
simplify_eq
/=
||
case_decide
);
repeat
constructor
;
by
auto
.
Qed
.
Lemma
group_snoc
ixs
j
ys
:
j
∉
ixs
.
*
1
→
ys
≠
[]
→
group
(
ixs
++
((
j
,)
<$>
ys
))
≡
ₚₚ
group
ixs
++
[(
j
,
ys
)]
.
Proof
.
induction
ixs
as
[|[
i
x
]
ixs
IH
];
csimpl
;
[
by
auto
using
group_fmap
|]
.
rewrite
?not_elem_of_cons
;
intros
[??]
.
etrans
;
[|
by
apply
group_insert_snoc
]
.
apply
group_insert_perm
,
IH
;
auto
using
group_nodup
.
Qed
.
End
group
.
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