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
C
coqstdpp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
David Swasey
coqstdpp
Commits
7cd44ad5
Commit
7cd44ad5
authored
Jan 25, 2017
by
Robbert Krebbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Curry and uncurry operations on gmap.
parent
c134e48c
Changes
1
Show whitespace changes
Inline
Sidebyside
Showing
1 changed file
with
50 additions
and
0 deletions
+50
0
theories/gmap.v
theories/gmap.v
+50
0
No files found.
theories/gmap.v
View file @
7cd44ad5
...
...
@@ 123,6 +123,56 @@ Next Obligation.
by
rewrite
map_of_to_list
.
Qed
.
(** * Curry and uncurry *)
Definition
gmap_curry
`
{
Countable
K1
,
Countable
K2
}
{
A
}
:
gmap
K1
(
gmap
K2
A
)
→
gmap
(
K1
*
K2
)
A
:
=
map_fold
(
λ
i1
m'
macc
,
map_fold
(
λ
i2
x
,
<[(
i1
,
i2
)
:
=
x
]>)
macc
m'
)
∅
.
Definition
gmap_uncurry
`
{
Countable
K1
,
Countable
K2
}
{
A
}
:
gmap
(
K1
*
K2
)
A
→
gmap
K1
(
gmap
K2
A
)
:
=
map_fold
(
λ
'
(
i1
,
i2
)
x
,
partial_alter
(
Some
∘
<[
i2
:
=
x
]>
∘
from_option
id
∅
)
i1
)
∅
.
Section
curry_uncurry
.
Context
`
{
Countable
K1
,
Countable
K2
}
{
A
:
Type
}.
Lemma
lookup_gmap_curry
(
m
:
gmap
K1
(
gmap
K2
A
))
i
j
:
gmap_curry
m
!!
(
i
,
j
)
=
m
!!
i
≫
=
(!!
j
).
Proof
.
apply
(
map_fold_ind
(
λ
mr
m
,
mr
!!
(
i
,
j
)
=
m
!!
i
≫
=
(!!
j
))).
{
by
rewrite
!
lookup_empty
.
}
clear
m
;
intros
i'
m2
m
m12
Hi'
IH
.
apply
(
map_fold_ind
(
λ
m2r
m2
,
m2r
!!
(
i
,
j
)
=
<[
i'
:
=
m2
]>
m
!!
i
≫
=
(!!
j
))).
{
rewrite
IH
.
destruct
(
decide
(
i'
=
i
))
as
[>].

rewrite
lookup_insert
,
Hi'
;
simpl
;
by
rewrite
lookup_empty
.

by
rewrite
lookup_insert_ne
by
done
.
}
intros
j'
y
m2'
m12'
Hj'
IH'
.
destruct
(
decide
(
i
=
i'
))
as
[>].

rewrite
lookup_insert
;
simpl
.
destruct
(
decide
(
j
=
j'
))
as
[>].
+
by
rewrite
!
lookup_insert
.
+
by
rewrite
!
lookup_insert_ne
,
IH'
,
lookup_insert
by
congruence
.

by
rewrite
!
lookup_insert_ne
,
IH'
,
lookup_insert_ne
by
congruence
.
Qed
.
Lemma
lookup_gmap_uncurry
(
m
:
gmap
(
K1
*
K2
)
A
)
i
j
:
gmap_uncurry
m
!!
i
≫
=
(!!
j
)
=
m
!!
(
i
,
j
).
Proof
.
apply
(
map_fold_ind
(
λ
mr
m
,
mr
!!
i
≫
=
(!!
j
)
=
m
!!
(
i
,
j
))).
{
by
rewrite
!
lookup_empty
.
}
clear
m
;
intros
[
i'
j'
]
x
m12
mr
Hij'
IH
.
destruct
(
decide
(
i
=
i'
))
as
[>].

rewrite
lookup_partial_alter
.
destruct
(
decide
(
j
=
j'
))
as
[>].
+
destruct
(
mr
!!
i'
)
;
simpl
;
by
rewrite
!
lookup_insert
.
+
destruct
(
mr
!!
i'
)
;
simpl
;
by
rewrite
!
lookup_insert_ne
by
congruence
.

by
rewrite
lookup_partial_alter_ne
,
lookup_insert_ne
by
congruence
.
Qed
.
Lemma
gmap_curry_uncurry
(
m
:
gmap
(
K1
*
K2
)
A
)
:
gmap_curry
(
gmap_uncurry
m
)
=
m
.
Proof
.
apply
map_eq
;
intros
[
i
j
].
by
rewrite
lookup_gmap_curry
,
lookup_gmap_uncurry
.
Qed
.
End
curry_uncurry
.
(** * Finite sets *)
Notation
gset
K
:
=
(
mapset
(
gmap
K
)).
Instance
gset_dom
`
{
Countable
K
}
{
A
}
:
Dom
(
gmap
K
A
)
(
gset
K
)
:
=
mapset_dom
.
...
...
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