Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stdpp
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
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
Gregory Malecha
stdpp
Commits
208bf810
Commit
208bf810
authored
7 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Define a `size` for finite maps and prove some properties.
parent
32570aa6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theories/fin_collections.v
+0
-1
0 additions, 1 deletion
theories/fin_collections.v
theories/fin_maps.v
+22
-0
22 additions, 0 deletions
theories/fin_maps.v
with
22 additions
and
1 deletion
theories/fin_collections.v
+
0
−
1
View file @
208bf810
...
...
@@ -284,4 +284,3 @@ Proof.
by
rewrite
set_Exists_elements
.
Defined
.
End
fin_collection
.
This diff is collapsed.
Click to expand it.
theories/fin_maps.v
+
22
−
0
View file @
208bf810
...
...
@@ -64,6 +64,8 @@ Instance map_singleton `{PartialAlter K A M, Empty M} :
Definition
map_of_list
`{
Insert
K
A
M
,
Empty
M
}
:
list
(
K
*
A
)
→
M
:=
fold_right
(
λ
p
,
<
[
p
.
1
:=
p
.
2
]
>
)
∅.
Instance
map_size
`{
FinMapToList
K
A
M
}
:
Size
M
:=
λ
m
,
length
(
map_to_list
m
)
.
Definition
map_to_collection
`{
FinMapToList
K
A
M
,
Singleton
B
C
,
Empty
C
,
Union
C
}
(
f
:
K
→
A
→
B
)
(
m
:
M
)
:
C
:=
of_list
(
curry
f
<$>
map_to_list
m
)
.
...
...
@@ -869,6 +871,26 @@ Proof.
rewrite
elem_of_map_to_list
in
Hj
;
simplify_option_eq
.
Qed
.
(** ** Properties of the size operation *)
Lemma
map_size_empty
{
A
}
:
size
(
∅
:
M
A
)
=
0
.
Proof
.
unfold
size
,
map_size
.
by
rewrite
map_to_list_empty
.
Qed
.
Lemma
map_size_empty_inv
{
A
}
(
m
:
M
A
)
:
size
m
=
0
→
m
=
∅.
Proof
.
unfold
size
,
map_size
.
by
rewrite
length_zero_iff_nil
,
map_to_list_empty'
.
Qed
.
Lemma
map_size_empty_iff
{
A
}
(
m
:
M
A
)
:
size
m
=
0
↔
m
=
∅.
Proof
.
split
.
apply
map_size_empty_inv
.
by
intros
->
;
rewrite
map_size_empty
.
Qed
.
Lemma
map_size_non_empty_iff
{
A
}
(
m
:
M
A
)
:
size
m
≠
0
↔
m
≠
∅.
Proof
.
by
rewrite
map_size_empty_iff
.
Qed
.
Lemma
map_size_singleton
{
A
}
i
(
x
:
A
)
:
size
({[
i
:=
x
]}
:
M
A
)
=
1
.
Proof
.
unfold
size
,
map_size
.
by
rewrite
map_to_list_singleton
.
Qed
.
Lemma
map_size_insert
{
A
}
i
x
(
m
:
M
A
)
:
m
!!
i
=
None
→
size
(
<
[
i
:=
x
]
>
m
)
=
S
(
size
m
)
.
Proof
.
intros
.
unfold
size
,
map_size
.
by
rewrite
map_to_list_insert
.
Qed
.
Lemma
map_size_fmap
{
A
B
}
(
f
:
A
->
B
)
(
m
:
M
A
)
:
size
(
f
<$>
m
)
=
size
m
.
Proof
.
intros
.
unfold
size
,
map_size
.
by
rewrite
map_to_list_fmap
,
fmap_length
.
Qed
.
(** ** Properties of conversion from collections *)
Section
map_of_to_collection
.
Context
{
A
:
Type
}
`{
FinCollection
B
C
}
.
...
...
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