The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Finset.Card
157 declarations. Mathlib docs · Source
Cardinality of a finite set
This defines the cardinality of a Finset and provides induction principles for finsets.
Main declarations
Finset.card:#s : ℕreturns the cardinality ofs : Finset α.
Induction principles
Finset.strongInduction: Strong inductionFinset.strongInductionOnFinset.strongDownwardInductionFinset.strongDownwardInductionOnFinset.case_strong_induction_onFinset.Nonempty.strong_inductionFinset.eraseInduction
Lattice structure
Explicit description of a finset from its card
Inductions
def Finset.card E3 #
{α : Type u_1} → Finset α → ℕ
s.card is the number of elements of s, aka its cardinality.
The notation #s can be accessed in the Finset locale.
def Finset.«term#_» E1 #
Lean.ParserDescr
s.card is the number of elements of s, aka its cardinality.
The notation #s can be accessed in the Finset locale.
theorem Finset.card_def E0 #
∀ {α : Type u_1} (s : Finset α), s.card = s.val.card
theorem Finset.card_val E0 #
∀ {α : Type u_1} (s : Finset α), s.val.card = s.card
theorem Finset.card_mk E0 #
∀ {α : Type u_1} {m : Multiset α} {nodup : m.Nodup}, { val := m, nodup := nodup }.card = m.card
theorem Finset.card_empty E0 #
∀ {α : Type u_1}, ∅.card = 0
theorem Finset.card_le_card E1 #
∀ {α : Type u_1} {s t : Finset α}, s ⊆ t → s.card ≤ t.card
theorem Finset.card_mono E1 #
∀ {α : Type u_1}, Monotone Finset.card
theorem Finset.card_eq_zero E0 #
∀ {α : Type u_1} {s : Finset α}, s.card = 0 ↔ s = ∅
theorem Finset.card_ne_zero E1 #
∀ {α : Type u_1} {s : Finset α}, s.card ≠ 0 ↔ s.Nonempty
theorem Finset.card_pos E0 #
∀ {α : Type u_1} {s : Finset α}, 0 < s.card ↔ s.Nonempty
theorem Finset.one_le_card E0 #
∀ {α : Type u_1} {s : Finset α}, 1 ≤ s.card ↔ s.Nonempty
theorem Finset.Nonempty.card_pos E1 #
∀ {α : Type u_1} {s : Finset α}, s.Nonempty → 0 < s.card
Alias of the reverse direction of Finset.card_pos.
theorem Finset.Nonempty.card_ne_zero E1 #
∀ {α : Type u_1} {s : Finset α}, s.Nonempty → s.card ≠ 0
Alias of the reverse direction of Finset.card_ne_zero.
theorem Finset.card_ne_zero_of_mem E1 #
∀ {α : Type u_1} {s : Finset α} {a : α}, a ∈ s → s.card ≠ 0
theorem Finset.card_singleton E0 #
∀ {α : Type u_1} (a : α), {a}.card = 1
theorem Finset.card_singleton_inter E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], ({a} ∩ s).card ≤ 1
theorem Finset.card_cons E0 #
∀ {α : Type u_1} {s : Finset α} {a : α} (h : a ∉ s), (Finset.cons a s h).card = s.card + 1
theorem Finset.card_insert_of_notMem E0 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], a ∉ s → (insert a s).card = s.card + 1
theorem Finset.card_insert_of_mem E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], a ∈ s → (insert a s).card = s.card
theorem Finset.card_insert_le E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (s : Finset α), (insert a s).card ≤ s.card + 1
theorem Finset.card_le_two E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {a b : α}, {a, b}.card ≤ 2
theorem Finset.card_le_three E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {a b c : α}, {a, b, c}.card ≤ 3
theorem Finset.card_le_four E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {a b c d : α}, {a, b, c, d}.card ≤ 4
theorem Finset.card_le_five E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {a b c d e : α}, {a, b, c, d, e}.card ≤ 5
theorem Finset.card_le_six E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {a b c d e f : α}, {a, b, c, d, e, f}.card ≤ 6
theorem Finset.card_insert_eq_ite E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], (insert a s).card = if a ∈ s then s.card else s.card + 1
If a ∈ s is known, see also Finset.card_insert_of_mem and Finset.card_insert_of_notMem.
theorem Finset.card_pair_eq_one_or_two E0 #
∀ {α : Type u_1} {a b : α} [inst : DecidableEq α], {a, b}.card = 1 ∨ {a, b}.card = 2
theorem Finset.card_pair_eq_two_iff E0 #
∀ {α : Type u_1} {a b : α} [inst : DecidableEq α], {a, b}.card = 2 ↔ a ≠ b
A two-element finset {a, b} has cardinality 2 iff a ≠ b. The reverse direction is
Finset.card_pair.
theorem Finset.card_pair E1 #
∀ {α : Type u_1} {a b : α} [inst : DecidableEq α], a ≠ b → {a, b}.card = 2
Alias of the reverse direction of Finset.card_pair_eq_two_iff.
A two-element finset {a, b} has cardinality 2 iff a ≠ b. The reverse direction is
Finset.card_pair.
theorem Finset.card_triple_eq_three_iff E0 #
∀ {α : Type u_1} {a b c : α} [inst : DecidableEq α], {a, b, c}.card = 3 ↔ a ≠ b ∧ a ≠ c ∧ b ≠ c
A three-element finset {a, b, c} has cardinality 3 iff a, b, c are pairwise
distinct.
theorem Finset.card_erase_of_mem E0 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], a ∈ s → (s.erase a).card = s.card - 1
$#(s \setminus {a}) = #s - 1$ if $a \in s$.
theorem Finset.card_erase_add_one E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], a ∈ s → (s.erase a).card + 1 = s.card
theorem Finset.card_erase_lt_of_mem E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], a ∈ s → (s.erase a).card < s.card
theorem Finset.card_erase_le E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], (s.erase a).card ≤ s.card
theorem Finset.pred_card_le_card_erase E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], s.card - 1 ≤ (s.erase a).card
theorem Finset.card_erase_eq_ite E1 #
∀ {α : Type u_1} {s : Finset α} {a : α} [inst : DecidableEq α], (s.erase a).card = if a ∈ s then s.card - 1 else s.card
If a ∈ s is known, see also Finset.card_erase_of_mem and Finset.erase_eq_of_notMem.
theorem Finset.card_range E0 #
∀ (n : ℕ), (Finset.range n).card = n
theorem Finset.card_attach E0 #
∀ {α : Type u_1} {s : Finset α}, s.attach.card = s.card
theorem Multiset.card_toFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), m.toFinset.card = m.dedup.card
theorem Multiset.toFinset_card_le E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), m.toFinset.card ≤ m.card
theorem Multiset.toFinset_card_of_nodup E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α}, m.Nodup → m.toFinset.card = m.card
theorem Multiset.dedup_card_eq_card_iff_nodup E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α}, m.dedup.card = m.card ↔ m.Nodup
theorem Multiset.toFinset_card_eq_card_iff_nodup E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α}, m.toFinset.card = m.card ↔ m.Nodup
theorem nodup_iff_le_length_dedup E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), m.Nodup ↔ m.card ≤ m.dedup.card
theorem List.card_toFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (l : List α), l.toFinset.card = l.dedup.length
theorem List.toFinset_card_le E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (l : List α), l.toFinset.card ≤ l.length
theorem List.toFinset_card_of_nodup E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {l : List α}, l.Nodup → l.toFinset.card = l.length
theorem List.Nodup.card_eq_countP E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {l : List α} {P : α → Prop} [inst_1 : DecidablePred P],
l.Nodup → (Finset.filter P l.toFinset).card = List.countP (fun b ↦ decide (P b)) l
theorem Finset.length_toList E0 #
∀ {α : Type u_1} (s : Finset α), s.toList.length = s.card
theorem Finset.card_image_le E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {f : α → β} [inst : DecidableEq β], (Finset.image f s).card ≤ s.card
theorem Finset.card_image_of_injOn E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {f : α → β} [inst : DecidableEq β],
Set.InjOn f ↑s → (Finset.image f s).card = s.card
theorem Finset.injOn_of_card_image_eq E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {f : α → β} [inst : DecidableEq β],
(Finset.image f s).card = s.card → Set.InjOn f ↑s
theorem Finset.card_image_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {f : α → β} [inst : DecidableEq β],
(Finset.image f s).card = s.card ↔ Set.InjOn f ↑s
theorem Finset.card_image_of_injective E1 #
∀ {α : Type u_1} {β : Type u_2} {f : α → β} [inst : DecidableEq β] (s : Finset α),
Function.Injective f → (Finset.image f s).card = s.card
theorem Finset.fiber_card_ne_zero_iff_mem_image E1 #
∀ {α : Type u_1} {β : Type u_2} (s : Finset α) (f : α → β) [inst : DecidableEq β] (y : β),
{x ∈ s | f x = y}.card ≠ 0 ↔ y ∈ Finset.image f s
theorem Finset.card_filter_le_iff E0 #
∀ {α : Type u_1} (s : Finset α) (P : α → Prop) [inst : DecidablePred P] (n : ℕ),
(Finset.filter P s).card ≤ n ↔ ∀ s' ⊆ s, n < s'.card → ∃ a ∈ s', ¬P a
theorem Finset.card_map E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} (f : α ↪ β), (Finset.map f s).card = s.card
theorem Finset.card_subtype E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (s : Finset α),
(Finset.subtype p s).card = (Finset.filter p s).card
theorem Finset.card_filter_le E1 #
∀ {α : Type u_1} (s : Finset α) (p : α → Prop) [inst : DecidablePred p], (Finset.filter p s).card ≤ s.card
theorem Finset.subset_iff_eq_of_card_le E1 #
∀ {α : Type u_1} {s t : Finset α}, t.card ≤ s.card → (s ⊆ t ↔ s = t)
theorem Finset.map_eq_of_subset E0 #
∀ {α : Type u_1} {s : Finset α} {f : α ↪ α}, Finset.map f s ⊆ s → Finset.map f s = s
theorem Finset.card_filter_eq_iff E0 #
∀ {α : Type u_1} {s : Finset α} {p : α → Prop} [inst : DecidablePred p],
(Finset.filter p s).card = s.card ↔ ∀ x ∈ s, p x
theorem Finset.filter_card_eq E0 #
∀ {α : Type u_1} {s : Finset α} {p : α → Prop} [inst : DecidablePred p],
(Finset.filter p s).card = s.card → ∀ x ∈ s, p x
Alias of the forward direction of Finset.card_filter_eq_iff.
theorem Finset.card_filter_eq_zero_iff E0 #
∀ {α : Type u_1} {s : Finset α} {p : α → Prop} [inst : DecidablePred p], (Finset.filter p s).card = 0 ↔ ∀ x ∈ s, ¬p x
theorem Finset.card_lt_card E1 #
∀ {α : Type u_1} {s t : Finset α}, s ⊂ t → s.card < t.card
theorem Finset.card_strictMono E1 #
∀ {α : Type u_1}, StrictMono Finset.card
theorem Finset.card_eq_of_bijective E1 #
∀ {α : Type u_1} {s : Finset α} {n : ℕ} (f : (i : ℕ) → i < n → α),
(∀ a ∈ s, ∃ i, ∃ (h : i < n), f i h = a) →
(∀ (i : ℕ) (h : i < n), f i h ∈ s) → (∀ (i j : ℕ) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) → s.card = n
See also card_bij.
TODO: consider deprecating, since this has been unused in mathlib for a long time and is just a
special case of card_bij.
theorem Finset.card_bij E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (i : (a : α) → a ∈ s → β),
(∀ (a : α) (ha : a ∈ s), i a ha ∈ t) →
(∀ (a₁ : α) (ha₁ : a₁ ∈ s) (a₂ : α) (ha₂ : a₂ ∈ s), i a₁ ha₁ = i a₂ ha₂ → a₁ = a₂) →
(∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), i a ha = b) → s.card = t.card
Given a bijection from a finite set s to a finite set t, the cardinalities of s and t
are equal.
The difference with Finset.card_bij' is that the bijection is specified as a surjective injection,
rather than by an inverse function.
The difference with Finset.card_nbij is that the bijection is allowed to use membership of the
domain, rather than being a non-dependent function.
theorem Finset.card_bij' E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (i : (a : α) → a ∈ s → β) (j : (a : β) → a ∈ t → α)
(hi : ∀ (a : α) (ha : a ∈ s), i a ha ∈ t) (hj : ∀ (a : β) (ha : a ∈ t), j a ha ∈ s),
(∀ (a : α) (ha : a ∈ s), j (i a ha) ⋯ = a) → (∀ (a : β) (ha : a ∈ t), i (j a ha) ⋯ = a) → s.card = t.card
Given a bijection from a finite set s to a finite set t, the cardinalities of s and t
are equal.
The difference with Finset.card_bij is that the bijection is specified with an inverse, rather
than as a surjective injection.
The difference with Finset.card_nbij' is that the bijection and its inverse are allowed to use
membership of the domains, rather than being non-dependent functions.
theorem Finset.card_nbij E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (i : α → β),
Set.MapsTo i ↑s ↑t → Set.InjOn i ↑s → Set.SurjOn i ↑s ↑t → s.card = t.card
Given a bijection from a finite set s to a finite set t, the cardinalities of s and t
are equal.
The difference with Finset.card_nbij' is that the bijection is specified as a surjective
injection, rather than by an inverse function.
The difference with Finset.card_bij is that the bijection is a non-dependent function, rather than
being allowed to use membership of the domain.
theorem Finset.card_nbij' E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (i : α → β) (j : β → α),
Set.MapsTo i ↑s ↑t → Set.MapsTo j ↑t ↑s → Set.LeftInvOn j i ↑s → Set.RightInvOn j i ↑t → s.card = t.card
Given a bijection from a finite set s to a finite set t, the cardinalities of s and t
are equal.
The difference with Finset.card_nbij is that the bijection is specified with an inverse, rather
than as a surjective injection.
The difference with Finset.card_bij' is that the bijection and its inverse are non-dependent
functions, rather than being allowed to use membership of the domains.
The difference with Finset.card_equiv is that bijectivity is only required to hold on the domains,
rather than on the entire types.
theorem Finset.card_equiv E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (e : α ≃ β),
(∀ (i : α), i ∈ s ↔ e i ∈ t) → s.card = t.card
Specialization of Finset.card_nbij' that automatically fills in most arguments.
See Fintype.card_equiv for the version where s and t are univ.
theorem Finset.card_bijective E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (e : α → β),
Function.Bijective e → (∀ (i : α), i ∈ s ↔ e i ∈ t) → s.card = t.card
Specialization of Finset.card_nbij that automatically fills in most arguments.
See Fintype.card_bijective for the version where s and t are univ.
theorem Set.BijOn.finsetCard_eq E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (e : α → β), Set.BijOn e ↑s ↑t → s.card = t.card
theorem Finset.card_le_card_of_injOn E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (f : α → β),
Set.MapsTo f ↑s ↑t → Set.InjOn f ↑s → s.card ≤ t.card
theorem Finset.card_le_card_of_injective E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} {f : ↥s → ↥t}, Function.Injective f → s.card ≤ t.card
theorem Finset.card_le_card_of_surjOn E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (f : α → β), Set.SurjOn f ↑s ↑t → t.card ≤ s.card
theorem Finset.card_le_card_of_surjective E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} {f : ↥s → ↥t}, Function.Surjective f → t.card ≤ s.card
theorem Finset.exists_ne_map_eq_of_card_lt_of_maps_to E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β},
t.card < s.card → ∀ {f : α → β}, Set.MapsTo f ↑s ↑t → ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y
If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
See also Set.exists_ne_map_eq_of_encard_lt_of_maps_to and
Set.exists_ne_map_eq_of_ncard_lt_of_maps_to.
theorem Finset.exists_ne_map_eq_of_card_image_lt E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} [inst : DecidableEq β] {f : α → β},
(Finset.image f s).card < s.card → ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y
a special case of Finset.exists_ne_map_eq_of_card_lt_of_maps_to where t is s.image f
theorem Finset.not_injOn_of_card_image_lt E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} [inst : DecidableEq β] {f : α → β},
(Finset.image f s).card < s.card → ¬Set.InjOn f ↑s
a variant of Finset.exists_ne_map_eq_of_card_image_lt using Set.InjOn
theorem Finset.le_card_of_inj_on_range E1 #
∀ {α : Type u_1} {s : Finset α} {n : ℕ} (f : ℕ → α),
(∀ i < n, f i ∈ s) → (∀ i < n, ∀ j < n, f i = f j → i = j) → n ≤ s.card
See also Finset.card_le_card_of_injOn, which is a more general version of this lemma.
TODO: consider deprecating, since this is just a special case of Finset.card_le_card_of_injOn.
theorem Finset.surjOn_of_injOn_of_card_le E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (f : α → β),
Set.MapsTo f ↑s ↑t → Set.InjOn f ↑s → t.card ≤ s.card → Set.SurjOn f ↑s ↑t
Given an injective map f from a finite set s to another finite set t, if t is no larger
than s, then f is surjective to t when restricted to s.
See Finset.surj_on_of_inj_on_of_card_le for the version where f is a dependent function.
theorem Finset.surj_on_of_inj_on_of_card_le E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (f : (a : α) → a ∈ s → β),
(∀ (a : α) (ha : a ∈ s), f a ha ∈ t) →
(∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) →
t.card ≤ s.card → ∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), b = f a ha
Given an injective map f defined on a finite set s to another finite set t, if t is no
larger than s, then f is surjective to t when restricted to s.
See Finset.surjOn_of_injOn_of_card_le for the version where f is a non-dependent function.
theorem Finset.injOn_of_surjOn_of_card_le E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (f : α → β),
Set.MapsTo f ↑s ↑t → Set.SurjOn f ↑s ↑t → s.card ≤ t.card → Set.InjOn f ↑s
Given a surjective map f from a finite set s to another finite set t, if s is no larger
than t, then f is injective when restricted to s.
See Finset.inj_on_of_surj_on_of_card_le for the version where f is a dependent function.
theorem Finset.inj_on_of_surj_on_of_card_le E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (f : (a : α) → a ∈ s → β),
(∀ (a : α) (ha : a ∈ s), f a ha ∈ t) →
(∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), f a ha = b) →
s.card ≤ t.card → ∀ ⦃a₁ : α⦄ (ha₁ : a₁ ∈ s) ⦃a₂ : α⦄ (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
Given a surjective map f defined on a finite set s to another finite set t, if s is no
larger than t, then f is injective when restricted to s.
See Finset.injOn_of_surjOn_of_card_le for the version where f is a non-dependent function.
theorem Finset.image_eq_iff_bijOn_of_card E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {f : α → β} {t : Finset β} [inst : DecidableEq β],
s.card ≤ t.card → (Finset.image f s = t ↔ Set.BijOn f ↑s ↑t)
theorem Finset.card_disjUnion E0 #
∀ {α : Type u_1} (s t : Finset α) (h : Disjoint s t), (s.disjUnion t h).card = s.card + t.card
theorem Finset.card_union_add_card_inter E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s ∪ t).card + (s ∩ t).card = s.card + t.card
theorem Finset.card_inter_add_card_union E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s ∩ t).card + (s ∪ t).card = s.card + t.card
theorem Finset.card_union E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s ∪ t).card = s.card + t.card - (s ∩ t).card
theorem Finset.card_inter E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s ∩ t).card = s.card + t.card - (s ∪ t).card
theorem Finset.card_union_le E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s ∪ t).card ≤ s.card + t.card
theorem Finset.card_union_eq_card_add_card E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], (s ∪ t).card = s.card + t.card ↔ Disjoint s t
theorem Finset.card_union_of_disjoint E0 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], Disjoint s t → (s ∪ t).card = s.card + t.card
Alias of the reverse direction of Finset.card_union_eq_card_add_card.
theorem Finset.card_sdiff_of_subset E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], s ⊆ t → (t \ s).card = t.card - s.card
theorem Finset.card_sdiff E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], (t \ s).card = t.card - (s ∩ t).card
theorem Finset.card_sdiff_add_card_eq_card E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], s ⊆ t → (t \ s).card + s.card = t.card
theorem Finset.card_sub_card_eq E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), t.card - s.card = (t \ s).card - (s \ t).card
theorem Finset.le_card_sdiff E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), t.card - s.card ≤ (t \ s).card
theorem Finset.card_le_card_sdiff_add_card E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], s.card ≤ (s \ t).card + t.card
theorem Finset.card_sdiff_add_card E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s \ t).card + t.card = (s ∪ t).card
theorem Finset.sdiff_nonempty_of_card_lt_card E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], s.card < t.card → (t \ s).Nonempty
theorem Finset.exists_mem_notMem_of_card_lt_card E1 #
∀ {α : Type u_1} {s t : Finset α}, s.card < t.card → ∃ e ∈ t, e ∉ s
theorem Finset.card_sdiff_add_card_inter E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s \ t).card + (s ∩ t).card = s.card
theorem Finset.card_inter_add_card_sdiff E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α), (s ∩ t).card + (s \ t).card = s.card
theorem Finset.card_sdiff_le_card_sdiff_iff E0 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], (s \ t).card ≤ (t \ s).card ↔ s.card ≤ t.card
theorem Finset.card_sdiff_lt_card_sdiff_iff E0 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], (s \ t).card < (t \ s).card ↔ s.card < t.card
theorem Finset.card_sdiff_eq_card_sdiff_iff E0 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], (s \ t).card = (t \ s).card ↔ s.card = t.card
theorem Finset.card_sdiff_comm E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], s.card = t.card → (s \ t).card = (t \ s).card
Alias of the reverse direction of Finset.card_sdiff_eq_card_sdiff_iff.
theorem Finset.inter_nonempty_of_card_lt_card_add_card E2 #
∀ {α : Type u_1} {s t u : Finset α} [inst : DecidableEq α], t ⊆ s → u ⊆ s → s.card < t.card + u.card → (t ∩ u).Nonempty
Pigeonhole principle for two finsets inside an ambient finset.
theorem Finset.card_filter_add_card_filter_not E1 #
∀ {α : Type u_1} {s : Finset α} (p : α → Prop) [inst : DecidablePred p] [inst_1 : (x : α) → Decidable ¬p x],
(Finset.filter p s).card + {a ∈ s | ¬p a}.card = s.card
theorem Finset.exists_subsuperset_card_eq E0 #
∀ {α : Type u_1} {s t : Finset α} {n : ℕ}, s ⊆ t → s.card ≤ n → n ≤ t.card → ∃ u, s ⊆ u ∧ u ⊆ t ∧ u.card = n
Given a subset s of a set t, of sizes at most and at least n respectively, there exists a
set u of size n which is both a superset of s and a subset of t.
theorem Finset.exists_subset_card_eq E0 #
∀ {α : Type u_1} {s : Finset α} {n : ℕ}, n ≤ s.card → ∃ t ⊆ s, t.card = n
We can shrink a set to any smaller size.
theorem Finset.le_card_iff_exists_subset_card E1 #
∀ {α : Type u_1} {s : Finset α} {n : ℕ}, n ≤ s.card ↔ ∃ t ⊆ s, t.card = n
theorem Finset.exists_subset_or_subset_of_two_mul_lt_card E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {X Y : Finset α} {n : ℕ},
2 * n < (X ∪ Y).card → ∃ C, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y)
theorem Finset.card_eq_one E1 #
∀ {α : Type u_1} {s : Finset α}, s.card = 1 ↔ ∃ a, s = {a}
theorem Finset.card_eq_one_iff_existsUnique E1 #
∀ {α : Type u_1} {s : Finset α}, s.card = 1 ↔ ∃! a, a ∈ s
theorem Finset.exists_eq_insert_iff E0 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α], (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card
theorem Finset.card_le_one E1 #
∀ {α : Type u_1} {s : Finset α}, s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b
theorem Finset.card_le_one_iff E0 #
∀ {α : Type u_1} {s : Finset α}, s.card ≤ 1 ↔ ∀ {a b : α}, a ∈ s → b ∈ s → a = b
theorem Finset.card_le_one_iff_subsingleton_coe E0 #
∀ {α : Type u_1} {s : Finset α}, s.card ≤ 1 ↔ Subsingleton ↥s
theorem Finset.card_le_one_iff_subsingleton E1 #
∀ {α : Type u_1} {s : Finset α}, s.card ≤ 1 ↔ (↑s).Subsingleton
A finset has cardinality at most 1 iff its underlying set is subsingleton.
theorem Finset.card_le_one_iff_subset_singleton E1 #
∀ {α : Type u_1} {s : Finset α} [Nonempty α], s.card ≤ 1 ↔ ∃ x, s ⊆ {x}
theorem Finset.exists_mem_ne E1 #
∀ {α : Type u_1} {s : Finset α}, 1 < s.card → ∀ (a : α), ∃ b ∈ s, b ≠ a
theorem Finset.card_le_one_of_subsingleton E1 #
∀ {α : Type u_1} [Subsingleton α] (s : Finset α), s.card ≤ 1
A Finset of a subsingleton type has cardinality at most one.
theorem Finset.one_lt_card E1 #
∀ {α : Type u_1} {s : Finset α}, 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b
theorem Finset.one_lt_card_iff E0 #
∀ {α : Type u_1} {s : Finset α}, 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b
theorem Finset.one_lt_card_iff_nontrivial E1 #
∀ {α : Type u_1} {s : Finset α}, 1 < s.card ↔ s.Nontrivial
theorem Finset.Nontrivial.one_lt_card E1 #
∀ {α : Type u_1} {s : Finset α}, s.Nontrivial → 1 < s.card
theorem Finset.Nontrivial.two_le_card E1 #
∀ {α : Type u_1} {s : Finset α}, s.Nontrivial → 2 ≤ s.card
theorem Finset.existsUnique_notMem_image_of_injOn_of_card_eq_add_one E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {f : α → β} {t : Finset β} [inst : DecidableEq β],
Set.InjOn f ↑s → Set.MapsTo f ↑s ↑t → t.card = s.card + 1 → ∃! x, x ∈ t ∧ x ∉ Finset.image f s
Given an injective map f : α → β for finite sets s ⊂ α and t ⊂ β such that t has
cardinality one more than s, there exists a unique element of t not in f(s).
theorem Finset.exists_of_one_lt_card_pi E1 #
∀ {ι : Type u_3} {α : ι → Type u_4} [inst : (i : ι) → DecidableEq (α i)] {s : Finset ((i : ι) → α i)},
1 < s.card → ∃ i, 1 < (Finset.image (fun x ↦ x i) s).card ∧ ∀ (ai : α i), {x ∈ s | x i = ai} ⊂ s
If a Finset in a Pi type is nontrivial (has at least two elements), then its projection to some factor is nontrivial, and the fibers of the projection are proper subsets.
theorem Finset.card_eq_succ_iff_cons E1 #
∀ {α : Type u_1} {s : Finset α} {n : ℕ}, s.card = n + 1 ↔ ∃ a t, ∃ (h : a ∉ t), Finset.cons a t h = s ∧ t.card = n
theorem Finset.card_eq_succ E1 #
∀ {α : Type u_1} {s : Finset α} {n : ℕ} [inst : DecidableEq α],
s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n
theorem Finset.card_eq_two E1 #
∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α], s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y}
theorem Finset.card_eq_three E1 #
∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α], s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z}
theorem Finset.card_eq_four E1 #
∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α],
s.card = 4 ↔ ∃ x y z w, x ≠ y ∧ x ≠ z ∧ x ≠ w ∧ y ≠ z ∧ y ≠ w ∧ z ≠ w ∧ s = {x, y, z, w}
theorem Finset.two_lt_card_iff E0 #
∀ {α : Type u_1} {s : Finset α}, 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c
theorem Finset.two_lt_card E1 #
∀ {α : Type u_1} {s : Finset α}, 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c
theorem Finset.three_lt_card_iff E0 #
∀ {α : Type u_1} {s : Finset α},
3 < s.card ↔ ∃ a b c d, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ d ∈ s ∧ a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d
theorem Finset.three_lt_card E1 #
∀ {α : Type u_1} {s : Finset α},
3 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, ∃ d ∈ s, a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d
def Finset.strongInduction E1 #
{α : Type u_1} →
{p : Finset α → Sort u_3} → ((s : Finset α) → ((t : Finset α) → t ⊂ s → p t) → p s) → (s : Finset α) → p s
Suppose that, given objects defined on all strict subsets of any finset s, one knows how to
define an object on s. Then one can inductively define an object on all finsets, starting from
the empty set and iterating. This can be used either to define data, or to prove properties.
theorem Finset.strongInduction_eq E0 #
∀ {α : Type u_1} {p : Finset α → Sort u_3} (H : (s : Finset α) → ((t : Finset α) → t ⊂ s → p t) → p s) (s : Finset α),
Finset.strongInduction H s = H s fun t x ↦ Finset.strongInduction H t
def Finset.strongInductionOn E1 #
{α : Type u_1} →
{p : Finset α → Sort u_3} → (s : Finset α) → ((s : Finset α) → ((t : Finset α) → t ⊂ s → p t) → p s) → p s
Analogue of strongInduction with order of arguments swapped.
theorem Finset.strongInductionOn_eq E0 #
∀ {α : Type u_1} {p : Finset α → Sort u_3} (s : Finset α) (H : (s : Finset α) → ((t : Finset α) → t ⊂ s → p t) → p s),
s.strongInductionOn H = H s fun t x ↦ t.strongInductionOn H
theorem Finset.case_strong_induction_on E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {p : Finset α → Prop} (s : Finset α),
p ∅ → (∀ (a : α) (s : Finset α), a ∉ s → (∀ t ⊆ s, p t) → p (insert a s)) → p s
theorem Finset.Nonempty.strong_induction E1 #
∀ {α : Type u_1} {p : (s : Finset α) → s.Nonempty → Prop},
(∀ (a : α), p {a} ⋯) →
(∀ ⦃s : Finset α⦄ (hs : s.Nontrivial), (∀ (t : Finset α) (ht : t.Nonempty), t ⊂ s → p t ht) → p s ⋯) →
∀ ⦃s : Finset α⦄ (hs : s.Nonempty), p s hs
Suppose that, given objects defined on all nonempty strict subsets of any nontrivial finset s,
one knows how to define an object on s. Then one can inductively define an object on all finsets,
starting from singletons and iterating.
TODO: Currently this can only be used to prove properties.
Replace Finset.Nonempty.exists_eq_singleton_or_nontrivial with computational content
in order to let p be Sort-valued.
def Finset.strongDownwardInduction E1 #
{α : Type u_1} →
{p : Finset α → Sort u_3} →
{n : ℕ} →
((t₁ : Finset α) → ({t₂ : Finset α} → t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) →
(s : Finset α) → s.card ≤ n → p s
Suppose that, given that p t can be defined on all supersets of s of cardinality less than
n, one knows how to define p s. Then one can inductively define p s for all finsets s of
cardinality less than n, starting from finsets of card n and iterating. This
can be used either to define data, or to prove properties.
theorem Finset.strongDownwardInduction_eq E0 #
∀ {α : Type u_1} {n : ℕ} {p : Finset α → Sort u_3}
(H : (t₁ : Finset α) → ({t₂ : Finset α} → t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) (s : Finset α),
Finset.strongDownwardInduction H s = H s fun {t} ht x ↦ Finset.strongDownwardInduction H t ht
def Finset.strongDownwardInductionOn E1 #
{α : Type u_1} →
{n : ℕ} →
{p : Finset α → Sort u_3} →
(s : Finset α) →
((t₁ : Finset α) → ({t₂ : Finset α} → t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) → s.card ≤ n → p s
Analogue of strongDownwardInduction with order of arguments swapped.
theorem Finset.strongDownwardInductionOn_eq E0 #
∀ {α : Type u_1} {n : ℕ} {p : Finset α → Sort u_3} (s : Finset α)
(H : (t₁ : Finset α) → ({t₂ : Finset α} → t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁),
(fun a ↦ s.strongDownwardInductionOn H a) = H s fun {t} ht x ↦ t.strongDownwardInductionOn H ht
theorem Finset.lt_wf E1 #
∀ {α : Type u_3}, WellFounded LT.lt
theorem Finset.eraseInduction E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {p : Finset α → Prop},
(∀ (S : Finset α), (∀ s ∈ S, p (S.erase s)) → p S) → ∀ (S : Finset α), p S
To prove a proposition for an arbitrary Finset α,
it suffices to prove that for any S : Finset α, the following is true:
the property is true for S with any element s removed, then the property holds for S.
This is a weaker version of Finset.strongInduction.
But it can be more precise when the induction argument
only requires removing single elements at a time.
theorem Finset.image_iterate_stabilises_lt_card E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {f : α → α} {s : Finset α},
Set.MapsTo f ↑s ↑s → s.Nonempty → ∃ n < s.card, ∀ (m : ℕ), n ≤ m → Finset.image f^[m] s = Finset.image f^[n] s
Given a function f which sends the finite set s to itself, the sequence of images of s under
iterates of f is eventually constant. Furthermore, the sequence of images stabilises in fewer
than #s steps.
theorem Finset.image_iterate_stabilises_le_card E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {f : α → α} {s : Finset α},
Set.MapsTo f ↑s ↑s → ∃ n ≤ s.card, ∀ (m : ℕ), n ≤ m → Finset.image f^[m] s = Finset.image f^[n] s
Given a function f which sends the finite set s to itself, the sequence of images of s under
iterates of f is eventually constant. Furthermore, the sequence of images stabilises in at most
#s steps.