Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stdpp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
52
Issues
52
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Iris
stdpp
Commits
d101c562
Commit
d101c562
authored
Sep 20, 2015
by
Robbert Krebbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indexed map function for finite maps.
parent
c5bdf622
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
theories/fin_maps.v
theories/fin_maps.v
+23
-0
No files found.
theories/fin_maps.v
View file @
d101c562
...
...
@@ -104,6 +104,12 @@ index contains a value in the second map as well. *)
Instance
map_difference
`
{
Merge
M
}
{
A
}
:
Difference
(
M
A
)
:
=
difference_with
(
λ
_
_
,
None
).
(** A stronger variant of map that allows the mapped function to use the index
of the elements. Implemented by conversion to lists, so not very efficient. *)
Definition
map_imap
`
{
∀
A
,
Insert
K
A
(
M
A
),
∀
A
,
Empty
(
M
A
),
∀
A
,
FinMapToList
K
A
(
M
A
)}
{
A
B
}
(
f
:
K
→
A
→
option
B
)
(
m
:
M
A
)
:
M
B
:
=
map_of_list
(
omap
(
λ
ix
,
(
fst
ix
,)
<$>
curry
f
ix
)
(
map_to_list
m
)).
(** * Theorems *)
Section
theorems
.
Context
`
{
FinMap
K
M
}.
...
...
@@ -585,6 +591,23 @@ Proof.
exists
i
x
.
rewrite
<-
elem_of_map_to_list
,
Hm
.
by
left
.
Qed
.
(** Properties of the imap function *)
Lemma
lookup_imap
{
A
B
}
(
f
:
K
→
A
→
option
B
)
m
i
:
map_imap
f
m
!!
i
=
m
!!
i
≫
=
f
i
.
Proof
.
unfold
map_imap
;
destruct
(
m
!!
i
≫
=
f
i
)
as
[
y
|]
eqn
:
Hi
;
simpl
.
*
destruct
(
m
!!
i
)
as
[
x
|]
eqn
:
?
;
simplify_equality'
.
apply
elem_of_map_of_list_1_help
.
{
apply
elem_of_list_omap
;
exists
(
i
,
x
)
;
split
;
[
by
apply
elem_of_map_to_list
|
by
simplify_option_equality
].
}
intros
y'
;
rewrite
elem_of_list_omap
;
intros
([
i'
x'
]&
Hi'
&?).
by
rewrite
elem_of_map_to_list
in
Hi'
;
simplify_option_equality
.
*
apply
not_elem_of_map_of_list
;
rewrite
elem_of_list_fmap
.
intros
([
i'
x
]&->&
Hi'
)
;
simplify_equality'
.
rewrite
elem_of_list_omap
in
Hi'
;
destruct
Hi'
as
([
j
y
]&
Hj
&?).
rewrite
elem_of_map_to_list
in
Hj
;
simplify_option_equality
.
Qed
.
(** ** Properties of conversion from collections *)
Lemma
lookup_map_of_collection
{
A
}
`
{
FinCollection
K
C
}
(
f
:
K
→
option
A
)
X
i
x
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment