-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data/(d)finsupp,fintype,fun_like): add fintype and (in)finite in…
…stances (#15725) Co-authored-by: Anne Baanen <t.baanen@vu.nl> Co-authored-by: Vierkantor <vierkantor@vierkantor.com> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
- Loading branch information
1 parent
8c53048
commit 3cd7b57
Showing
5 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/- | ||
Copyright (c) 2022 Anne Baanen. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Anne Baanen, Alex J. Best | ||
-/ | ||
import data.finsupp.defs | ||
import data.fintype.basic | ||
|
||
/-! | ||
# Finiteness and infiniteness of `finsupp` | ||
Some lemmas on the combination of `finsupp`, `fintype` and `infinite`. | ||
-/ | ||
|
||
noncomputable instance finsupp.fintype {ι π : Sort*} [decidable_eq ι] [has_zero π] | ||
[fintype ι] [fintype π] : | ||
fintype (ι →₀ π) := | ||
fintype.of_equiv _ finsupp.equiv_fun_on_fintype.symm | ||
|
||
instance finsupp.infinite_of_left {ι π : Sort*} [nontrivial π] [has_zero π] [infinite ι] : | ||
infinite (ι →₀ π) := | ||
let ⟨m, hm⟩ := exists_ne (0 : π) in infinite.of_injective _ $ finsupp.single_left_injective hm | ||
|
||
instance finsupp.infinite_of_right {ι π : Sort*} [infinite π] [has_zero π] [nonempty ι] : | ||
infinite (ι →₀ π) := | ||
infinite.of_injective (λ i, finsupp.single (classical.arbitrary ι) i) | ||
(finsupp.single_injective (classical.arbitrary ι)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/- | ||
Copyright (c) 2022 Anne Baanen. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Anne Baanen | ||
-/ | ||
|
||
import data.finite.basic | ||
import data.fintype.basic | ||
import data.fun_like.basic | ||
|
||
/-! | ||
# Finiteness of `fun_like` types | ||
We show a type `F` with a `fun_like F α β` is finite if both `α` and `β` are finite. | ||
This corresponds to the following two pairs of declarations: | ||
* `fun_like.fintype` is a definition stating all `fun_like`s are finite if their domain and | ||
codomain are. | ||
* `fun_like.finite` is a lemma stating all `fun_like`s are finite if their domain and | ||
codomain are. | ||
* `fun_like.fintype'` is a non-dependent version of `fun_like.fintype` and | ||
* `fun_like.finite` is a non-dependent version of `fun_like.finite`, because dependent instances | ||
are harder to infer. | ||
You can use these to produce instances for specific `fun_like` types. | ||
(Although there might be options for `fintype` instances with better definitional behaviour.) | ||
They can't be instances themselves since they can cause loops. | ||
-/ | ||
|
||
section type | ||
|
||
variables (F G : Type*) {α γ : Type*} {β : α → Type*} [fun_like F α β] [fun_like G α (λ _, γ)] | ||
|
||
/-- All `fun_like`s are finite if their domain and codomain are. | ||
This is not an instance because specific `fun_like` types might have a better-suited definition. | ||
See also `fun_like.finite`. | ||
-/ | ||
noncomputable def fun_like.fintype [decidable_eq α] [fintype α] [Π i, fintype (β i)] : fintype F := | ||
fintype.of_injective _ fun_like.coe_injective | ||
|
||
/-- All `fun_like`s are finite if their domain and codomain are. | ||
Non-dependent version of `fun_like.fintype` that might be easier to infer. | ||
This is not an instance because specific `fun_like` types might have a better-suited definition. | ||
-/ | ||
noncomputable def fun_like.fintype' [decidable_eq α] [fintype α] [fintype γ] : fintype G := | ||
fun_like.fintype G | ||
|
||
end type | ||
|
||
section sort | ||
|
||
variables (F G : Sort*) {α γ : Sort*} {β : α → Sort*} [fun_like F α β] [fun_like G α (λ _, γ)] | ||
|
||
/-- All `fun_like`s are finite if their domain and codomain are. | ||
Can't be an instance because it can cause infinite loops. | ||
-/ | ||
lemma fun_like.finite [finite α] [∀ i, finite (β i)] : finite F := | ||
finite.of_injective _ fun_like.coe_injective | ||
|
||
/-- All `fun_like`s are finite if their domain and codomain are. | ||
Non-dependent version of `fun_like.finite` that might be easier to infer. | ||
Can't be an instance because it can cause infinite loops. | ||
-/ | ||
lemma fun_like.finite' [finite α] [finite γ] : finite G := | ||
fun_like.finite G | ||
|
||
end sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters