Skip to content

Commit

Permalink
feat(data/fintype): card_univ and card_univ_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
johoelzl committed Mar 5, 2019
1 parent c0b1eb1 commit 332121d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/data/fintype.lean
Expand Up @@ -190,6 +190,14 @@ def of_subsingleton (a : α) [subsingleton α] : fintype α :=

end fintype

lemma finset.card_univ [fintype α] : (finset.univ : finset α).card = fintype.card α :=
rfl

lemma finset.card_univ_diff [fintype α] [decidable_eq α] (s : finset α) :
(finset.univ \ s).card = fintype.card α - s.card :=
eq.symm $ nat.sub_eq_of_eq_add $
by rw [← card_disjoint_union disjoint_sdiff, union_sdiff_of_subset (subset_univ _)]; refl

instance (n : ℕ) : fintype (fin n) :=
⟨⟨list.pmap fin.mk (list.range n) (λ a, list.mem_range.1),
list.nodup_pmap (λ a _ b _, congr_arg fin.val) (list.nodup_range _)⟩,
Expand Down

0 comments on commit 332121d

Please sign in to comment.