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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
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
Iris
stdpp
Commits
4fb85912
Commit
4fb85912
authored
3 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Plain Diff
Merge branch 'robbert/pigeon_hole' into 'master'
Add Pigeon Hole principle. See merge request
iris/stdpp!373
parents
f83560b2
6f9dea44
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!373
Add Pigeon Hole principle.
Pipeline
#64673
passed
3 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
theories/finite.v
+43
-0
43 additions, 0 deletions
theories/finite.v
with
45 additions
and
0 deletions
CHANGELOG.md
+
2
−
0
View file @
4fb85912
...
...
@@ -29,6 +29,8 @@ lot to everyone involved!
-
Add some more lemmas about
`Finite`
and
`pred_finite`
.
-
Add lemmas about
`last`
:
`last_app_cons`
,
`last_app`
,
`last_Some`
, and
`last_Some_elem_of`
.
-
Add versions of Pigeonhole principle for Finite types, natural numbers, and
lists.
The following
`sed`
script should perform most of the renaming
(on macOS, replace
`sed`
by
`gsed`
, installed via e.g.
`brew install gnu-sed`
).
...
...
This diff is collapsed.
Click to expand it.
theories/finite.v
+
43
−
0
View file @
4fb85912
...
...
@@ -419,3 +419,46 @@ Section sig_finite.
Lemma
sig_card
:
card
(
sig
P
)
=
length
(
filter
P
(
enum
A
))
.
Proof
.
by
rewrite
<-
list_filter_sig_filter
,
fmap_length
.
Qed
.
End
sig_finite
.
Lemma
finite_pigeonhole
`{
Finite
A
}
`{
Finite
B
}
(
f
:
A
→
B
)
:
card
B
<
card
A
→
∃
x1
x2
,
x1
≠
x2
∧
f
x1
=
f
x2
.
Proof
.
intros
.
apply
dec_stable
;
intros
Heq
.
cut
(
Inj
eq
eq
f
);
[
intros
?
%
inj_card
;
lia
|]
.
intros
x1
x2
?
.
apply
dec_stable
.
naive_solver
.
Qed
.
Lemma
nat_pigeonhole
(
f
:
nat
→
nat
)
(
n1
n2
:
nat
)
:
n2
<
n1
→
(
∀
i
,
i
<
n1
→
f
i
<
n2
)
→
∃
i1
i2
,
i1
<
i2
<
n1
∧
f
i1
=
f
i2
.
Proof
.
intros
Hn
Hf
.
pose
(
f'
(
i
:
fin
n1
)
:=
nat_to_fin
(
Hf
_
(
fin_to_nat_lt
i
)))
.
destruct
(
finite_pigeonhole
f'
)
as
(
i1
&
i2
&
Hi
&
Hf'
);
[
by
rewrite
!
fin_card
|]
.
apply
(
not_inj
(
f
:=
fin_to_nat
))
in
Hi
.
apply
(
f_equal
fin_to_nat
)
in
Hf'
.
unfold
f'
in
Hf'
.
rewrite
!
fin_to_nat_to_fin
in
Hf'
.
pose
proof
(
fin_to_nat_lt
i1
);
pose
proof
(
fin_to_nat_lt
i2
)
.
destruct
(
decide
(
i1
<
i2
));
[
exists
i1
,
i2
|
exists
i2
,
i1
];
lia
.
Qed
.
Lemma
list_pigeonhole
{
A
}
(
l1
l2
:
list
A
)
:
l1
⊆
l2
→
length
l2
<
length
l1
→
∃
i1
i2
x
,
i1
<
i2
∧
l1
!!
i1
=
Some
x
∧
l1
!!
i2
=
Some
x
.
Proof
.
intros
Hl
Hlen
.
assert
(
∀
i
:
fin
(
length
l1
),
∃
(
j
:
fin
(
length
l2
))
x
,
l1
!!
(
fin_to_nat
i
)
=
Some
x
∧
l2
!!
(
fin_to_nat
j
)
=
Some
x
)
as
[
f
Hf
]
%
fin_choice
.
{
intros
i
.
destruct
(
lookup_lt_is_Some_2
l1
i
)
as
[
x
Hix
];
[
apply
fin_to_nat_lt
|]
.
assert
(
x
∈
l2
)
as
[
j
Hjx
]
%
elem_of_list_lookup_1
by
(
by
eapply
Hl
,
elem_of_list_lookup_2
)
.
exists
(
nat_to_fin
(
lookup_lt_Some
_
_
_
Hjx
)),
x
.
by
rewrite
fin_to_nat_to_fin
.
}
destruct
(
finite_pigeonhole
f
)
as
(
i1
&
i2
&
Hi
&
Hf'
);
[
by
rewrite
!
fin_card
|]
.
destruct
(
Hf
i1
)
as
(
x1
&
?
&
?),
(
Hf
i2
)
as
(
x2
&
?
&
?)
.
assert
(
x1
=
x2
)
as
->
by
congruence
.
apply
(
not_inj
(
f
:=
fin_to_nat
))
in
Hi
.
apply
(
f_equal
fin_to_nat
)
in
Hf'
.
destruct
(
decide
(
i1
<
i2
));
[
exists
i1
,
i2
|
exists
i2
,
i1
];
eauto
with
lia
.
Qed
.
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