The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Data.Finset.CastCard

4 declarations. Mathlib docs · Source

Cardinality of a finite set and subtraction

This file contains results on the cardinality of a Finset and subtraction, by casting the cardinality as element of an AddGroupWithOne.

Main results

  • Finset.cast_card_erase_of_mem: erasing an element of a finset decrements the cardinality (avoiding ℕ subtraction).
  • Finset.cast_card_inter, Finset.cast_card_union: inclusion/exclusion principle.
  • Finset.cast_card_sdiff: cardinality of t \ s is the difference of cardinalities if s ⊆ t.

theorem Finset.cast_card_erase_of_mem E3 #

∀ {α : Type u_1} {R : Type u_2} {s : Finset α} {a : α} [inst : DecidableEq α] [inst_1 : AddGroupWithOne R],
  a ∈ s → ↑(s.erase a).card = ↑s.card - 1

$#(s \setminus {a}) = #s - 1$ if $a \in s$. This result is casted to any additive group with 1, so that we don't have to work with ℕ-subtraction.

theorem Finset.cast_card_inter E3 #

∀ {α : Type u_1} {R : Type u_2} {s t : Finset α} [inst : DecidableEq α] [inst_1 : AddGroupWithOne R],
  ↑(s ∩ t).card = ↑s.card + ↑t.card - ↑(s ∪ t).card

theorem Finset.cast_card_union E3 #

∀ {α : Type u_1} {R : Type u_2} {s t : Finset α} [inst : DecidableEq α] [inst_1 : AddGroupWithOne R],
  ↑(s ∪ t).card = ↑s.card + ↑t.card - ↑(s ∩ t).card

theorem Finset.cast_card_sdiff E3 #

∀ {α : Type u_1} {R : Type u_2} {s t : Finset α} [inst : DecidableEq α] [inst_1 : AddGroupWithOne R],
  s ⊆ t → ↑(t \ s).card = ↑t.card - ↑s.card