Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit f5d4fa1

Browse files
feat(data/fintype/basic): add fintype_of_{equiv,option} (#13086)
`fintype_of_option_equiv` was extracted from @huynhtrankhanh's #11162, moved here to a separate PR. The split into `fintype_of_option` and `fintype_of_equiv` is based on a comment on that PR by @jcommelin. Co-authored-by: Huỳnh Trần Khanh [qcdz9r6wpcbh59@gmail.com](mailto:qcdz9r6wpcbh59@gmail.com)
1 parent d96e17d commit f5d4fa1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/data/fintype/basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,14 @@ lemma univ_option (α : Type*) [fintype α] : (univ : finset (option α)) = inse
841841
fintype.card (option α) = fintype.card α + 1 :=
842842
(finset.card_cons _).trans $ congr_arg2 _ (card_map _) rfl
843843

844+
/-- If `option α` is a `fintype` then so is `α` -/
845+
def fintype_of_option {α : Type*} [fintype (option α)] : fintype α :=
846+
⟨finset.erase_none (fintype.elems (option α)), λ x, mem_erase_none.mpr (fintype.complete (some x))⟩
847+
848+
/-- A type is a `fintype` if its successor (using `option`) is a `fintype`. -/
849+
def fintype_of_option_equiv [fintype α] (f : option α ≃ β) : fintype β :=
850+
by { haveI := fintype.of_equiv (option α) f, exact fintype_of_option }
851+
844852
instance {α : Type*} (β : α → Type*)
845853
[fintype α] [∀ a, fintype (β a)] : fintype (sigma β) :=
846854
⟨univ.sigma (λ _, univ), λ ⟨a, b⟩, by simp⟩

0 commit comments

Comments
 (0)