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.Set.Card

246 declarations and 30 deprecated aliases. Mathlib docs · Source

Noncomputable Set Cardinality

We define the cardinality of set s as a term Set.encard s : ℕ∞ and a term Set.ncard s : ℕ. The latter takes the junk value of zero if s is infinite. Both functions are noncomputable, and are defined in terms of ENat.card (which takes a type as its argument); this file can be seen as an API for the same function in the special case where the type is a coercion of a Set, allowing for smoother interactions with the Set API.

Set.encard never takes junk values, so is more mathematically natural than Set.ncard, even though it takes values in a less convenient type. It is probably the right choice in settings where one is concerned with the cardinalities of sets that may or may not be infinite.

Set.ncard has a nicer codomain, but when using it, Set.Finite hypotheses are normally needed to make sure its values are meaningful. More generally, Set.ncard is intended to be used over the obvious alternative Finset.card when finiteness is 'propositional' rather than 'structural'. When working with sets that are finite by virtue of their definition, then Finset.card probably makes more sense. One setting where Set.ncard works nicely is in a type α with [Finite α], where every set is automatically finite. In this setting, we use default arguments and a simple tactic so that finiteness goals are discharged automatically in Set.ncard theorems.

Main Definitions

  • Set.encard s is the cardinality of the set s as an extended natural number, with value ⊤ if s is infinite.
  • Set.ncard s is the cardinality of the set s as a natural number, provided s is Finite. If s is Infinite, then Set.ncard s = 0.
  • toFinite_tac is a tactic that tries to synthesize a Set.Finite s argument with Set.toFinite. This will work for s : Set α where there is a Finite α instance.

Implementation notes

The theorems in this file are very similar to those in Mathlib/Data/Finset/Card.lean, but with Set operations instead of Finset. We first prove all the theorems for Set.encard, and then derive most of the Set.ncard results as a consequence. Things are done this way to avoid reliance on the Finset API for theorems about infinite sets, and to allow for a refactor that removes or modifies Set.ncard in the future.

Nearly all the theorems for Set.ncard require finiteness of one or more of their arguments. We provide this assumption with a default argument of the form (hs : s.Finite := by toFinite_tac), where toFinite_tac will find an s.Finite term in the cases where s is a set in a Finite type.

Often, where there are two set arguments s and t, the finiteness of one follows from the other in the context of the theorem, in which case we only include the ones that are needed, and derive the other inside the proof. A few of the theorems, such as ncard_union_le do not require finiteness arguments; they are true by coincidence due to junk values.

Explicit description of a set from its cardinality

def Set.encard E1 #

{α : Type u_1} → Set α → ℕ∞

The cardinality of a set as a term in ℕ∞

theorem Set.encard_univ E0 #

∀ (α : Type u_3), Set.univ.encard = ENat.card α

theorem ENat.card_coe_set_eq E0 #

∀ {α : Type u_1} (s : Set α), ENat.card ↑s = s.encard

theorem Set.Finite.encard_eq_coe_toFinset_card E1 #

∀ {α : Type u_1} {s : Set α} (h : s.Finite), s.encard = ↑h.toFinset.card

theorem Set.encard_eq_coe_toFinset_card E1 #

∀ {α : Type u_1} (s : Set α) [inst : Fintype ↑s], s.encard = ↑s.toFinset.card

theorem Set.toENat_cardinalMk E1 #

∀ {α : Type u_1} (s : Set α), Cardinal.toENat (Cardinal.mk ↑s) = s.encard

theorem Set.encard_ofPred E1 #

∀ {α : Type u_1} (P : α → Prop), {x | P x}.encard = ENat.card { x // P x }

theorem Set.coe_fintypeCard E0 #

∀ {α : Type u_1} (s : Set α) [inst : Fintype ↑s], ↑(Fintype.card ↑s) = s.encard

theorem Set.encard_coe_eq_coe_finsetCard E0 #

∀ {α : Type u_1} (s : Finset α), (↑s).encard = ↑s.card

theorem Set.Infinite.encard_eq E0 #

∀ {α : Type u_1} {s : Set α}, s.Infinite → s.encard = ⊤

theorem Set.encard_eq_zero E0 #

∀ {α : Type u_1} {s : Set α}, s.encard = 0 ↔ s = ∅

theorem Set.encard_empty E0 #

∀ {α : Type u_1}, ∅.encard = 0

theorem Set.nonempty_of_encard_ne_zero E1 #

∀ {α : Type u_1} {s : Set α}, s.encard ≠ 0 → s.Nonempty

theorem Set.encard_ne_zero E1 #

∀ {α : Type u_1} {s : Set α}, s.encard ≠ 0 ↔ s.Nonempty

theorem Set.encard_pos E0 #

∀ {α : Type u_1} {s : Set α}, 0 < s.encard ↔ s.Nonempty

theorem Set.Nonempty.encard_pos E1 #

∀ {α : Type u_1} {s : Set α}, s.Nonempty → 0 < s.encard

Alias of the reverse direction of Set.encard_pos.

theorem Set.encard_ne_zero_of_mem E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → s.encard ≠ 0

theorem Set.encard_singleton E0 #

∀ {α : Type u_1} (e : α), {e}.encard = 1

theorem Set.encard_union_eq E0 #

∀ {α : Type u_1} {s t : Set α}, Disjoint s t → (s ∪ t).encard = s.encard + t.encard

theorem Set.encard_ne_add_one E1 #

∀ {α : Type u_1} (a : α), {x | x ≠ a}.encard + 1 = ENat.card α

theorem Set.encard_insert_of_notMem E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∉ s → (insert a s).encard = s.encard + 1

theorem Set.Finite.encard_lt_top E1 #

∀ {α : Type u_1} {s : Set α}, s.Finite → s.encard < ⊤

theorem Set.Finite.encard_eq_coe E0 #

∀ {α : Type u_1} {s : Set α}, s.Finite → s.encard = ↑s.encard.toNat

theorem Set.Finite.exists_encard_eq_coe E0 #

∀ {α : Type u_1} {s : Set α}, s.Finite → ∃ n, s.encard = ↑n

theorem Set.encard_lt_top_iff E0 #

∀ {α : Type u_1} {s : Set α}, s.encard < ⊤ ↔ s.Finite

theorem Set.encard_eq_top_iff E0 #

∀ {α : Type u_1} {s : Set α}, s.encard = ⊤ ↔ s.Infinite

theorem Set.encard_eq_top E1 #

∀ {α : Type u_1} {s : Set α}, s.Infinite → s.encard = ⊤

Alias of the reverse direction of Set.encard_eq_top_iff.

theorem Set.encard_ne_top_iff E0 #

∀ {α : Type u_1} {s : Set α}, s.encard ≠ ⊤ ↔ s.Finite

theorem Set.finite_of_encard_le_coe E0 #

∀ {α : Type u_1} {s : Set α} {k : ℕ}, s.encard ≤ ↑k → s.Finite

theorem Set.finite_of_encard_eq_coe E0 #

∀ {α : Type u_1} {s : Set α} {k : ℕ}, s.encard = ↑k → s.Finite

theorem Set.encard_le_coe_iff E0 #

∀ {α : Type u_1} {s : Set α} {k : ℕ}, s.encard ≤ ↑k ↔ s.Finite ∧ ∃ n₀, s.encard = ↑n₀ ∧ n₀ ≤ k

theorem Set.encard_prod E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β}, (s ×ˢ t).encard = s.encard * t.encard

theorem Set.encard_pi_eq_prod_encard E0 #

∀ {α : Type u_1} [h : Fintype α] {ι : α → Type u_3} {s : (i : α) → Set (ι i)},
  (Set.univ.pi s).encard = ∏ i, (s i).encard

theorem Set.encard_le_encard E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊆ t → s.encard ≤ t.encard

theorem Set.encard_le_card E1 #

∀ {α : Type u_1} {s : Set α}, s.encard ≤ ENat.card α

theorem Set.encard_mono E1 #

∀ {α : Type u_3}, Monotone Set.encard

theorem Set.encard_sdiff_add_encard_of_subset E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊆ t → (t \ s).encard + s.encard = t.encard

theorem Set.encard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊆ t → s.Finite → (t \ s).encard = t.encard - s.encard

theorem Set.one_le_encard_iff_nonempty E0 #

∀ {α : Type u_1} {s : Set α}, 1 ≤ s.encard ↔ s.Nonempty

theorem Set.encard_lt_one E1 #

∀ {α : Type u_1} {s : Set α}, s.encard < 1 ↔ s = ∅

theorem Set.encard_sdiff_add_encard_inter E1 #

∀ {α : Type u_1} (s t : Set α), (s \ t).encard + (s ∩ t).encard = s.encard

theorem Set.encard_sdiff' E0 #

∀ {α : Type u_1} {s t : Set α}, (t ∩ s).Finite → (t \ s).encard = t.encard - (t ∩ s).encard

encard of a difference with no subset assumption

theorem Set.encard_union_add_encard_inter E1 #

∀ {α : Type u_1} (s t : Set α), (s ∪ t).encard + (s ∩ t).encard = s.encard + t.encard

theorem Set.encard_eq_encard_iff_encard_sdiff_eq_encard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α}, (s ∩ t).Finite → (s.encard = t.encard ↔ (s \ t).encard = (t \ s).encard)

theorem Set.encard_le_encard_iff_encard_sdiff_le_encard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α}, (s ∩ t).Finite → (s.encard ≤ t.encard ↔ (s \ t).encard ≤ (t \ s).encard)

theorem Set.encard_lt_encard_iff_encard_sdiff_lt_encard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α}, (s ∩ t).Finite → (s.encard < t.encard ↔ (s \ t).encard < (t \ s).encard)

theorem Set.encard_union_le E1 #

∀ {α : Type u_1} (s t : Set α), (s ∪ t).encard ≤ s.encard + t.encard

theorem Set.finite_iff_finite_of_encard_eq_encard E1 #

∀ {α : Type u_1} {s t : Set α}, s.encard = t.encard → (s.Finite ↔ t.Finite)

theorem Set.infinite_iff_infinite_of_encard_eq_encard E1 #

∀ {α : Type u_1} {s t : Set α}, s.encard = t.encard → (s.Infinite ↔ t.Infinite)

theorem Set.Finite.finite_of_encard_le E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β}, s.Finite → t.encard ≤ s.encard → t.Finite

theorem Set.Finite.encard_lt_encard E1 #

∀ {α : Type u_1} {s t : Set α}, s.Finite → s ⊂ t → s.encard < t.encard

theorem Set.encard_strictMono E1 #

∀ {α : Type u_1} [Finite α], StrictMono Set.encard

theorem Set.Finite.encard_strictMonoOn E1 #

∀ {α : Type u_1}, StrictMonoOn Set.encard (Set.ofPred Set.Finite)

theorem Set.Finite.encard_lt_card E1 #

∀ {α : Type u_1} {s : Set α}, s.Finite → s ≠ Set.univ → s.encard < ENat.card α

theorem Set.encard_sdiff_add_encard E1 #

∀ {α : Type u_1} (s t : Set α), (s \ t).encard + t.encard = (s ∪ t).encard

theorem Set.encard_le_encard_sdiff_add_encard E1 #

∀ {α : Type u_1} (s t : Set α), s.encard ≤ (s \ t).encard + t.encard

theorem Set.tsub_encard_le_encard_sdiff E1 #

∀ {α : Type u_1} (s t : Set α), s.encard - t.encard ≤ (s \ t).encard

theorem Set.encard_add_encard_compl E1 #

∀ {α : Type u_1} (s : Set α), s.encard + sᶜ.encard = ENat.card α

theorem Set.encard_compl E0 #

∀ {α : Type u_1} {s : Set α}, s.Finite → sᶜ.encard = ENat.card α - s.encard

theorem Set.encard_insert_le E1 #

∀ {α : Type u_1} (s : Set α) (x : α), (insert x s).encard ≤ s.encard + 1

theorem Set.one_le_encard_insert E1 #

∀ {α : Type u_1} {a : α} (s : Set α), 1 ≤ (insert a s).encard

theorem Set.encard_singleton_inter E1 #

∀ {α : Type u_1} (s : Set α) (x : α), ({x} ∩ s).encard ≤ 1

theorem Set.encard_sdiff_singleton_add_one E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → (s \ {a}).encard + 1 = s.encard

theorem Set.encard_sdiff_singleton_of_mem E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → (s \ {a}).encard = s.encard - 1

theorem Set.encard_tsub_one_le_encard_sdiff_singleton E1 #

∀ {α : Type u_1} (s : Set α) (x : α), s.encard - 1 ≤ (s \ {x}).encard

theorem Set.encard_exchange E1 #

∀ {α : Type u_1} {s : Set α} {a b : α}, a ∉ s → b ∈ s → (insert a (s \ {b})).encard = s.encard

theorem Set.encard_exchange' E1 #

∀ {α : Type u_1} {s : Set α} {a b : α}, a ∉ s → b ∈ s → (insert a s \ {b}).encard = s.encard

theorem Set.encard_eq_add_one_iff E0 #

∀ {α : Type u_1} {s : Set α} {k : ℕ∞}, s.encard = k + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.encard = k

theorem Set.encard_pair E1 #

∀ {α : Type u_1} {x y : α}, x ≠ y → {x, y}.encard = 2

theorem Set.encard_eq_one E1 #

∀ {α : Type u_1} {s : Set α}, s.encard = 1 ↔ ∃ x, s = {x}

theorem Set.encard_le_one_iff_eq E0 #

∀ {α : Type u_1} {s : Set α}, s.encard ≤ 1 ↔ s = ∅ ∨ ∃ x, s = {x}

theorem Set.encard_le_one_iff E0 #

∀ {α : Type u_1} {s : Set α}, s.encard ≤ 1 ↔ ∀ (a b : α), a ∈ s → b ∈ s → a = b

theorem Set.encard_le_one_iff_subsingleton E1 #

∀ {α : Type u_1} {s : Set α}, s.encard ≤ 1 ↔ s.Subsingleton

theorem Set.one_lt_encard_iff_nontrivial E1 #

∀ {α : Type u_1} {s : Set α}, 1 < s.encard ↔ s.Nontrivial

theorem Set.one_lt_encard_iff E0 #

∀ {α : Type u_1} {s : Set α}, 1 < s.encard ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b

theorem Set.exists_ne_of_one_lt_encard E1 #

∀ {α : Type u_1} {s : Set α}, 1 < s.encard → ∀ (a : α), ∃ b ∈ s, b ≠ a

theorem Set.encard_eq_two E1 #

∀ {α : Type u_1} {s : Set α}, s.encard = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y}

theorem Set.encard_eq_three E1 #

∀ {α : Type u_1} {s : Set α}, s.encard = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z}

theorem Set.encard_eq_four E1 #

∀ {α : Type u_1} {s : Set α}, s.encard = 4 ↔ ∃ x y z w, x ≠ y ∧ x ≠ z ∧ x ≠ w ∧ y ≠ z ∧ y ≠ w ∧ z ≠ w ∧ s = {x, y, z, w}

theorem Set.Nat.encard_range E1 #

∀ (k : ℕ), {i | i < k}.encard = ↑k

theorem Set.exists_subset_encard_eq E0 #

∀ {α : Type u_1} {s : Set α} {k : ℕ∞}, k ≤ s.encard → ∃ t ⊆ s, t.encard = k

theorem Set.le_encard_iff_exists_fin_injective E1 #

∀ {α : Type u_1} (s : Set α) (n : ℕ), ↑n ≤ s.encard ↔ ∃ f, (∀ (i : Fin n), f i ∈ s) ∧ Function.Injective f

An injection from Fin n into a set is equivalent to a lower bound of n on its extended cardinality.

theorem Set.exists_superset_subset_encard_eq E0 #

∀ {α : Type u_1} {s t : Set α} {k : ℕ∞}, s ⊆ t → s.encard ≤ k → k ≤ t.encard → ∃ r, s ⊆ r ∧ r ⊆ t ∧ r.encard = k

theorem Set.InjOn.encard_image E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β}, Set.InjOn f s → (f '' s).encard = s.encard

theorem Set.encard_congr E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (e : ↑s ≃ ↑t), s.encard = t.encard

theorem Function.Injective.encard_image E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β}, Function.Injective f → ∀ (s : Set α), (f '' s).encard = s.encard

theorem Function.Injective.encard_range E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β}, Function.Injective f → (Set.range f).encard = ENat.card α

theorem Function.Embedding.encard_le E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (e : ↑s ↪ ↑t), s.encard ≤ t.encard

theorem Set.encard_image_le E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α), (f '' s).encard ≤ s.encard

theorem Set.Finite.injOn_of_encard_image_eq E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β}, s.Finite → (f '' s).encard = s.encard → Set.InjOn f s

theorem Set.encard_preimage_of_injective_subset_range E1 #

∀ {α : Type u_1} {β : Type u_2} {t : Set β} {f : α → β},
  Function.Injective f → t ⊆ Set.range f → (f ⁻¹' t).encard = t.encard

theorem Set.encard_preimage_of_bijective E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β}, Function.Bijective f → ∀ (t : Set β), (f ⁻¹' t).encard = t.encard

theorem Set.encard_le_encard_of_injOn E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β},
  Set.MapsTo f s t → Set.InjOn f s → s.encard ≤ t.encard

theorem Set.encard_preimage_val_le_encard_left E1 #

∀ {α : Type u_1} (P Q : Set α), (Subtype.val ⁻¹' Q).encard ≤ P.encard

theorem Set.encard_preimage_val_le_encard_right E1 #

∀ {α : Type u_1} (P Q : Set α), (Subtype.val ⁻¹' Q).encard ≤ Q.encard

theorem Set.Finite.exists_injOn_of_encard_le E1 #

∀ {α : Type u_1} {β : Type u_2} [Nonempty β] {s : Set α} {t : Set β},
  s.Finite → s.encard ≤ t.encard → ∃ f, s ⊆ f ⁻¹' t ∧ Set.InjOn f s

theorem Set.Finite.exists_bijOn_of_encard_eq E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} [Nonempty β],
  s.Finite → s.encard = t.encard → ∃ f, Set.BijOn f s t

theorem Set.exists_ne_map_eq_of_encard_lt_of_maps_to E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β},
  t.encard < s.encard → Set.MapsTo f s t → ∃ a₁ ∈ s, ∃ a₂ ∈ s, a₁ ≠ a₂ ∧ f a₁ = f a₂

A version of the pigeonhole principle for Sets rather than Finsets.

See also Finset.exists_ne_map_eq_of_card_lt_of_maps_to and Set.exists_ne_map_eq_of_ncard_lt_of_maps_to.

def Set.tacticToFinite_tac E1 #

Lean.ParserDescr

A tactic (for use in default params) that applies Set.toFinite to synthesize a Set.Finite term.

def Set.tacticTo_encard_tac E1 #

Lean.ParserDescr

A tactic useful for transferring proofs for encard to their corresponding card statements

def Set.ncard E1 #

{α : Type u_1} → Set α → ℕ

The cardinality of s : Set α . Has the junk value 0 if s is infinite

theorem Set.ncard_def E0 #

∀ {α : Type u_1} (s : Set α), s.ncard = s.encard.toNat

theorem Set.ncard_ofPred E1 #

∀ {α : Type u_1} (P : α → Prop), {x | P x}.ncard = Nat.card { x // P x }

theorem Set.Finite.cast_ncard_eq E0 #

∀ {α : Type u_1} {s : Set α}, s.Finite → ↑s.ncard = s.encard

theorem Set.coe_ncard_eq_encard E0 #

∀ {α : Type u_1} (s : Set α) [Finite ↑s], ↑s.ncard = s.encard

theorem Set.ncard_le_encard E1 #

∀ {α : Type u_1} (s : Set α), ↑s.ncard ≤ s.encard

theorem Nat.card_coe_set_eq E0 #

∀ {α : Type u_1} (s : Set α), Nat.card ↑s = s.ncard

theorem Set.ncard_eq_toFinset_card E1 #

∀ {α : Type u_1} (s : Set α) (hs : autoParam s.Finite Set.ncard_eq_toFinset_card._auto_1), s.ncard = hs.toFinset.card

theorem Set.ncard_eq_toFinset_card' E1 #

∀ {α : Type u_1} (s : Set α) [inst : Fintype ↑s], s.ncard = s.toFinset.card

theorem Set.fintypeCard_eq_ncard E0 #

∀ {α : Type u_1} (s : Set α) [inst : Fintype ↑s], Fintype.card ↑s = s.ncard

theorem Set.cast_ncard E1 #

∀ {α : Type u_1} {s : Set α}, s.Finite → ↑s.ncard = Cardinal.mk ↑s

theorem Set.encard_le_coe_iff_finite_ncard_le E1 #

∀ {α : Type u_1} {s : Set α} {k : ℕ}, s.encard ≤ ↑k ↔ s.Finite ∧ s.ncard ≤ k

theorem Set.Infinite.ncard E1 #

∀ {α : Type u_1} {s : Set α}, s.Infinite → s.ncard = 0

theorem Set.ncard_le_ncard E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊆ t → autoParam t.Finite Set.ncard_le_ncard._auto_1 → s.ncard ≤ t.ncard

theorem Set.ncard_mono E1 #

∀ {α : Type u_1} [Finite α], Monotone Set.ncard

theorem Set.ncard_eq_zero E0 #

∀ {α : Type u_1} {s : Set α}, autoParam s.Finite Set.ncard_eq_zero._auto_1 → (s.ncard = 0 ↔ s = ∅)

theorem Set.ncard_eq_zero_iff E0 #

∀ {α : Type u_1} {s : Set α}, s.ncard = 0 ↔ s = ∅ ∨ s.Infinite

A set has ncard zero if and only if it is empty or infinite.

theorem Set.ncard_coe_finset E0 #

∀ {α : Type u_1} (s : Finset α), (↑s).ncard = s.card

theorem Set.ncard_univ E0 #

∀ (α : Type u_3), Set.univ.ncard = Nat.card α

theorem Set.ncard_le_card E1 #

∀ {α : Type u_1} [Finite α] (s : Set α), s.ncard ≤ Nat.card α

theorem Set.ncard_empty E0 #

∀ (α : Type u_3), ∅.ncard = 0

theorem Set.ncard_pos E1 #

∀ {α : Type u_1} {s : Set α}, autoParam s.Finite Set.ncard_pos._auto_1 → (0 < s.ncard ↔ s.Nonempty)

theorem Set.Nonempty.ncard_pos E1 #

∀ {α : Type u_1} {s : Set α}, autoParam s.Finite Set.ncard_pos._auto_1 → s.Nonempty → 0 < s.ncard

Alias of the reverse direction of Set.ncard_pos.

theorem Set.ncard_ne_zero_of_mem E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → autoParam s.Finite Set.ncard_ne_zero_of_mem._auto_1 → s.ncard ≠ 0

theorem Set.finite_of_ncard_ne_zero E1 #

∀ {α : Type u_1} {s : Set α}, s.ncard ≠ 0 → s.Finite

theorem Set.finite_of_ncard_pos E1 #

∀ {α : Type u_1} {s : Set α}, 0 < s.ncard → s.Finite

theorem Set.nonempty_of_ncard_ne_zero E1 #

∀ {α : Type u_1} {s : Set α}, s.ncard ≠ 0 → s.Nonempty

theorem Set.ncard_singleton E0 #

∀ {α : Type u_1} (a : α), {a}.ncard = 1

theorem Set.ncard_singleton_inter E1 #

∀ {α : Type u_1} (a : α) (s : Set α), ({a} ∩ s).ncard ≤ 1

theorem Set.ncard_prod E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β}, (s ×ˢ t).ncard = s.ncard * t.ncard

theorem Set.ncard_powerset E0 #

∀ {α : Type u_1} (s : Set α), autoParam s.Finite Set.ncard_powerset._auto_1 → (𝒫 s).ncard = 2 ^ s.ncard

theorem Set.ncard_insert_of_notMem E0 #

∀ {α : Type u_1} {s : Set α} {a : α},
  a ∉ s → autoParam s.Finite Set.ncard_insert_of_notMem._auto_1 → (insert a s).ncard = s.ncard + 1

theorem Set.ncard_insert_of_mem E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → (insert a s).ncard = s.ncard

theorem Set.ncard_insert_le E1 #

∀ {α : Type u_1} (a : α) (s : Set α), (insert a s).ncard ≤ s.ncard + 1

theorem Set.one_le_ncard_insert E1 #

∀ {α : Type u_1} (a : α) (s : Set α), autoParam s.Finite Set.one_le_ncard_insert._auto_1 → 1 ≤ (insert a s).ncard

theorem Set.ncard_insert_eq_ite E1 #

∀ {α : Type u_1} {s : Set α} {a : α} [inst : Decidable (a ∈ s)],
  autoParam s.Finite Set.ncard_insert_eq_ite._auto_1 → (insert a s).ncard = if a ∈ s then s.ncard else s.ncard + 1

theorem Set.ncard_le_ncard_insert E1 #

∀ {α : Type u_1} (a : α) (s : Set α), s.ncard ≤ (insert a s).ncard

theorem Set.ncard_pair E1 #

∀ {α : Type u_1} {a b : α}, a ≠ b → {a, b}.ncard = 2

theorem Set.ncard_pair_eq_two_iff E0 #

∀ {α : Type u_1} {a b : α}, {a, b}.ncard = 2 ↔ a ≠ b

theorem Set.ncard_sdiff_singleton_add_one E1 #

∀ {α : Type u_1} {s : Set α} {a : α},
  a ∈ s → autoParam s.Finite Set.ncard_sdiff_singleton_add_one._auto_1 → (s \ {a}).ncard + 1 = s.ncard

theorem Set.ncard_sdiff_singleton_lt_of_mem E1 #

∀ {α : Type u_1} {s : Set α} {a : α},
  a ∈ s → autoParam s.Finite Set.ncard_sdiff_singleton_lt_of_mem._auto_1 → (s \ {a}).ncard < s.ncard

theorem Set.ncard_sdiff_singleton_le E1 #

∀ {α : Type u_1} (s : Set α) (a : α), (s \ {a}).ncard ≤ s.ncard

theorem Set.ncard_exchange E1 #

∀ {α : Type u_1} {s : Set α} {a b : α}, a ∉ s → b ∈ s → (insert a (s \ {b})).ncard = s.ncard

theorem Set.ncard_exchange' E1 #

∀ {α : Type u_1} {s : Set α} {a b : α}, a ∉ s → b ∈ s → (insert a s \ {b}).ncard = s.ncard

theorem Set.odd_card_insert_iff E0 #

∀ {α : Type u_1} {s : Set α} {a : α},
  a ∉ s → autoParam s.Finite Set.odd_card_insert_iff._auto_1 → (Odd (insert a s).ncard ↔ Even s.ncard)

theorem Set.even_card_insert_iff E0 #

∀ {α : Type u_1} {s : Set α} {a : α},
  a ∉ s → autoParam s.Finite Set.even_card_insert_iff._auto_1 → (Even (insert a s).ncard ↔ Odd s.ncard)

theorem Set.ncard_image_le E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β},
  autoParam s.Finite Set.ncard_image_le._auto_1 → (f '' s).ncard ≤ s.ncard

theorem Set.ncard_image2_le E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α → β → γ} {s : Set α} {t : Set β},
  s.Finite → t.Finite → (Set.image2 f s t).ncard ≤ s.ncard * t.ncard

theorem Set.InjOn.ncard_image E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β}, Set.InjOn f s → (f '' s).ncard = s.ncard

theorem Set.injOn_of_ncard_image_eq E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β},
  (f '' s).ncard = s.ncard → autoParam s.Finite Set.injOn_of_ncard_image_eq._auto_1 → Set.InjOn f s

theorem Set.ncard_image_iff E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β},
  autoParam s.Finite Set.ncard_image_iff._auto_1 → ((f '' s).ncard = s.ncard ↔ Set.InjOn f s)

theorem Set.ncard_image_of_injective E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β} (s : Set α), Function.Injective f → (f '' s).ncard = s.ncard

theorem Set.ncard_preimage_of_injective_subset_range E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β} {s : Set β},
  Function.Injective f → s ⊆ Set.range f → (f ⁻¹' s).ncard = s.ncard

theorem Set.fiber_ncard_ne_zero_iff_mem_image E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β} {y : β},
  autoParam s.Finite Set.fiber_ncard_ne_zero_iff_mem_image._auto_1 → ({x | x ∈ s ∧ f x = y}.ncard ≠ 0 ↔ y ∈ f '' s)

theorem Set.ncard_map E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} (f : α ↪ β), (⇑f '' s).ncard = s.ncard

theorem Set.ncard_subtype E0 #

∀ {α : Type u_1} (P : α → Prop) (s : Set α), {x | ↑x ∈ s}.ncard = (s ∩ Set.ofPred P).ncard

theorem Set.ncard_inter_le_ncard_left E1 #

∀ {α : Type u_1} (s t : Set α), autoParam s.Finite Set.ncard_inter_le_ncard_left._auto_1 → (s ∩ t).ncard ≤ s.ncard

theorem Set.ncard_inter_le_ncard_right E1 #

∀ {α : Type u_1} (s t : Set α), autoParam t.Finite Set.ncard_inter_le_ncard_right._auto_1 → (s ∩ t).ncard ≤ t.ncard

theorem Set.subset_iff_eq_of_ncard_le E1 #

∀ {α : Type u_1} {s t : Set α},
  t.ncard ≤ s.ncard → autoParam t.Finite Set.subset_iff_eq_of_ncard_le._auto_1 → (s ⊆ t ↔ s = t)

theorem Set.map_eq_of_subset E0 #

∀ {α : Type u_1} {s : Set α} {f : α ↪ α}, ⇑f '' s ⊆ s → autoParam s.Finite Set.map_eq_of_subset._auto_1 → ⇑f '' s = s

theorem Set.sep_of_ncard_eq E0 #

∀ {α : Type u_1} {s : Set α} {a : α} {P : α → Prop},
  {x | x ∈ s ∧ P x}.ncard = s.ncard → a ∈ s → autoParam s.Finite Set.sep_of_ncard_eq._auto_1 → P a

theorem Set.ncard_lt_ncard E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊂ t → autoParam t.Finite Set.ncard_lt_ncard._auto_1 → s.ncard < t.ncard

theorem Set.ncard_lt_card E1 #

∀ {α : Type u_1} {s : Set α} [Finite α], s ≠ Set.univ → s.ncard < Nat.card α

theorem Set.ncard_strictMono E1 #

∀ {α : Type u_1} [Finite α], StrictMono Set.ncard

theorem Set.Finite.ncard_strictMonoOn E1 #

∀ {α : Type u_1}, StrictMonoOn Set.ncard (Set.ofPred Set.Finite)

theorem Set.ncard_eq_of_bijective E1 #

∀ {α : Type u_1} {s : Set α} {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.ncard = n

theorem Set.ncard_congr E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : (a : α) → a ∈ s → β),
  (∀ (a : α) (ha : a ∈ s), f a ha ∈ t) →
    (∀ (a b : α) (ha : a ∈ s) (hb : b ∈ s), f a ha = f b hb → a = b) →
      (∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), f a ha = b) → s.ncard = t.ncard

theorem Set.ncard_congr' E1 #

∀ {α : Type u_1} {β : Type u_2} {S : Set α} {T : Set β} (f : ↑S ≃ ↑T), S.ncard = T.ncard

theorem Set.ncard_le_ncard_of_injOn E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : α → β),
  (∀ a ∈ s, f a ∈ t) → Set.InjOn f s → autoParam t.Finite Set.ncard_le_ncard_of_injOn._auto_1 → s.ncard ≤ t.ncard

theorem Set.ncard_range_of_injective E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β}, Function.Injective f → (Set.range f).ncard = Nat.card α

theorem Set.BijOn.ncard_eq E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β} {t : Set β}, Set.BijOn f s t → s.ncard = t.ncard

theorem Set.exists_ne_map_eq_of_ncard_lt_of_maps_to E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β},
  t.ncard < s.ncard →
    ∀ {f : α → β},
      (∀ a ∈ s, f a ∈ t) →
        autoParam t.Finite Set.exists_ne_map_eq_of_ncard_lt_of_maps_to._auto_1 → ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y

A version of the pigeonhole principle for Sets rather than Finsets.

See also Finset.exists_ne_map_eq_of_card_lt_of_maps_to and Set.exists_ne_map_eq_of_encard_lt_of_maps_to.

theorem Set.le_ncard_of_inj_on_range E1 #

∀ {α : Type u_1} {s : Set α} {n : ℕ} (f : ℕ → α),
  (∀ i < n, f i ∈ s) →
    (∀ i < n, ∀ j < n, f i = f j → i = j) → autoParam s.Finite Set.le_ncard_of_inj_on_range._auto_1 → n ≤ s.ncard

theorem Set.surj_on_of_inj_on_of_ncard_le E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (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.ncard ≤ s.ncard →
        autoParam t.Finite Set.surj_on_of_inj_on_of_ncard_le._auto_1 → ∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), b = f a ha

theorem Set.inj_on_of_surj_on_of_ncard_le E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : (a : α) → a ∈ s → β),
  (∀ (a : α) (ha : a ∈ s), f a ha ∈ t) →
    (∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), f a ha = b) →
      s.ncard ≤ t.ncard →
        ∀ ⦃a₁ : α⦄ (ha₁ : a₁ ∈ s) ⦃a₂ : α⦄ (ha₂ : a₂ ∈ s),
          f a₁ ha₁ = f a₂ ha₂ → autoParam s.Finite Set.inj_on_of_surj_on_of_ncard_le._auto_1 → a₁ = a₂

theorem Set.ncard_coe E0 #

∀ {α : Type u_3} (s : Set α), Set.univ.ncard = s.ncard

theorem Set.ncard_graphOn E0 #

∀ {α : Type u_1} {β : Type u_2} (s : Set α) (f : α → β), (Set.graphOn f s).ncard = s.ncard

theorem Set.ncard_powerset_ncard E1 #

∀ {α : Type u_1} {s : Set α}, s.Finite → ∀ (n : ℕ), {t | t ⊆ s ∧ t.ncard = n}.ncard = s.ncard.choose n

Given a finite set s, the number of subsets of s with cardinality n is s.ncard.choose n. See also Finset.card_powersetCard.

theorem Set.ncard_union_add_ncard_inter E1 #

∀ {α : Type u_1} (s t : Set α),
  autoParam s.Finite Set.ncard_union_add_ncard_inter._auto_1 →
    autoParam t.Finite Set.ncard_union_add_ncard_inter._auto_3 → (s ∪ t).ncard + (s ∩ t).ncard = s.ncard + t.ncard

theorem Set.ncard_inter_add_ncard_union E1 #

∀ {α : Type u_1} (s t : Set α),
  autoParam s.Finite Set.ncard_inter_add_ncard_union._auto_1 →
    autoParam t.Finite Set.ncard_inter_add_ncard_union._auto_3 → (s ∩ t).ncard + (s ∪ t).ncard = s.ncard + t.ncard

theorem Set.ncard_union_le E1 #

∀ {α : Type u_1} (s t : Set α), (s ∪ t).ncard ≤ s.ncard + t.ncard

theorem Set.ncard_union_eq E0 #

∀ {α : Type u_1} {s t : Set α},
  Disjoint s t →
    autoParam s.Finite Set.ncard_union_eq._auto_1 →
      autoParam t.Finite Set.ncard_union_eq._auto_3 → (s ∪ t).ncard = s.ncard + t.ncard

theorem Set.ncard_union_eq_iff E0 #

∀ {α : Type u_1} {s t : Set α},
  autoParam s.Finite Set.ncard_union_eq_iff._auto_1 →
    autoParam t.Finite Set.ncard_union_eq_iff._auto_3 → ((s ∪ t).ncard = s.ncard + t.ncard ↔ Disjoint s t)

theorem Set.ncard_union_lt E1 #

∀ {α : Type u_1} {s t : Set α},
  autoParam s.Finite Set.ncard_union_lt._auto_1 →
    autoParam t.Finite Set.ncard_union_lt._auto_3 → ¬Disjoint s t → (s ∪ t).ncard < s.ncard + t.ncard

theorem Set.ncard_sdiff_add_ncard_of_subset E1 #

∀ {α : Type u_1} {s t : Set α},
  s ⊆ t → autoParam t.Finite Set.ncard_sdiff_add_ncard_of_subset._auto_1 → (t \ s).ncard + s.ncard = t.ncard

theorem Set.ncard_sdiff' E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊆ t → autoParam t.Finite Set.ncard_sdiff'._auto_1 → (t \ s).ncard = t.ncard - s.ncard

This is the same as ncard_sdiff but we require t to be finite instead.

theorem Set.ncard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α}, s ⊆ t → autoParam s.Finite Set.ncard_sdiff._auto_1 → (t \ s).ncard = t.ncard - s.ncard

This is the same as ncard_sdiff' but we require s to be finite instead.

theorem Set.cast_ncard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α} {R : Type u_3} [inst : AddGroupWithOne R],
  s ⊆ t → t.Finite → ↑(t \ s).ncard = ↑t.ncard - ↑s.ncard

theorem Set.ncard_le_ncard_sdiff_add_ncard E1 #

∀ {α : Type u_1} (s t : Set α),
  autoParam t.Finite Set.ncard_le_ncard_sdiff_add_ncard._auto_1 → s.ncard ≤ (s \ t).ncard + t.ncard

theorem Set.le_ncard_sdiff E1 #

∀ {α : Type u_1} (s t : Set α), autoParam s.Finite Set.le_ncard_sdiff._auto_1 → t.ncard - s.ncard ≤ (t \ s).ncard

theorem Set.ncard_sdiff_add_ncard E1 #

∀ {α : Type u_1} (s t : Set α),
  autoParam s.Finite Set.ncard_sdiff_add_ncard._auto_1 →
    autoParam t.Finite Set.ncard_sdiff_add_ncard._auto_3 → (s \ t).ncard + t.ncard = (s ∪ t).ncard

theorem Set.sdiff_nonempty_of_ncard_lt_ncard E1 #

∀ {α : Type u_1} {s t : Set α},
  s.ncard < t.ncard → autoParam s.Finite Set.sdiff_nonempty_of_ncard_lt_ncard._auto_1 → (t \ s).Nonempty

theorem Set.exists_mem_notMem_of_ncard_lt_ncard E1 #

∀ {α : Type u_1} {s t : Set α},
  s.ncard < t.ncard → autoParam s.Finite Set.exists_mem_notMem_of_ncard_lt_ncard._auto_1 → ∃ e ∈ t, e ∉ s

theorem Set.ncard_inter_add_ncard_sdiff_eq_ncard E0 #

∀ {α : Type u_1} (s t : Set α),
  autoParam s.Finite Set.ncard_inter_add_ncard_sdiff_eq_ncard._auto_1 → (s ∩ t).ncard + (s \ t).ncard = s.ncard

theorem Set.ncard_sdiff'' E0 #

∀ {α : Type u_1} {s t : Set α},
  autoParam (t ∩ s).Finite Set.ncard_sdiff''._auto_1 → (t \ s).ncard = t.ncard - (t ∩ s).ncard

ncard of a difference with no subset assumption

theorem Set.ncard_sdiff_singleton_of_mem E1 #

∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → (s \ {a}).ncard = s.ncard - 1

theorem Set.pred_ncard_le_ncard_sdiff_singleton E1 #

∀ {α : Type u_1} (s : Set α) (a : α), s.ncard - 1 ≤ (s \ {a}).ncard

theorem Set.ncard_eq_ncard_iff_ncard_sdiff_eq_ncard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α},
  autoParam s.Finite Set.ncard_eq_ncard_iff_ncard_sdiff_eq_ncard_sdiff._auto_1 →
    autoParam t.Finite Set.ncard_eq_ncard_iff_ncard_sdiff_eq_ncard_sdiff._auto_3 →
      (s.ncard = t.ncard ↔ (s \ t).ncard = (t \ s).ncard)

theorem Set.ncard_le_ncard_iff_ncard_sdiff_le_ncard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α},
  autoParam s.Finite Set.ncard_le_ncard_iff_ncard_sdiff_le_ncard_sdiff._auto_1 →
    autoParam t.Finite Set.ncard_le_ncard_iff_ncard_sdiff_le_ncard_sdiff._auto_3 →
      (s.ncard ≤ t.ncard ↔ (s \ t).ncard ≤ (t \ s).ncard)

theorem Set.ncard_lt_ncard_iff_ncard_sdiff_lt_ncard_sdiff E1 #

∀ {α : Type u_1} {s t : Set α},
  autoParam s.Finite Set.ncard_lt_ncard_iff_ncard_sdiff_lt_ncard_sdiff._auto_1 →
    autoParam t.Finite Set.ncard_lt_ncard_iff_ncard_sdiff_lt_ncard_sdiff._auto_3 →
      (s.ncard < t.ncard ↔ (s \ t).ncard < (t \ s).ncard)

theorem Set.ncard_add_ncard_compl E1 #

∀ {α : Type u_1} (s : Set α),
  autoParam s.Finite Set.ncard_add_ncard_compl._auto_1 →
    autoParam sᶜ.Finite Set.ncard_add_ncard_compl._auto_3 → s.ncard + sᶜ.ncard = Nat.card α

theorem Set.ncard_compl_add_ncard E1 #

∀ {α : Type u_1} (s : Set α),
  autoParam s.Finite Set.ncard_compl_add_ncard._auto_1 →
    autoParam sᶜ.Finite Set.ncard_compl_add_ncard._auto_3 → sᶜ.ncard + s.ncard = Nat.card α

theorem Set.ncard_compl E0 #

∀ {α : Type u_1} (s : Set α), autoParam s.Finite Set.ncard_compl._auto_1 → sᶜ.ncard = Nat.card α - s.ncard

theorem Set.ncard_compl_of_ncard_eq_add E1 #

∀ {α : Type u_1} (s : Set α) {n : ℕ},
  Nat.card α = n + s.ncard → autoParam s.Finite Set.ncard_compl_of_ncard_eq_add._auto_1 → sᶜ.ncard = n

theorem Set.even_ncard_compl_iff E0 #

∀ {α : Type u_1} [Finite α], Even (Nat.card α) → ∀ (s : Set α), Even sᶜ.ncard ↔ Even s.ncard

theorem Set.odd_ncard_compl_iff E0 #

∀ {α : Type u_1} [Finite α], Even (Nat.card α) → ∀ (s : Set α), Odd sᶜ.ncard ↔ Odd s.ncard

theorem Set.even_ncard_compl_iff' E1 #

∀ {α : Type u_1}, Odd (Nat.card α) → ∀ (s : Set α), Even sᶜ.ncard ↔ Odd s.ncard

theorem Set.odd_ncard_compl_iff' E1 #

∀ {α : Type u_1}, Odd (Nat.card α) → ∀ (s : Set α), Odd sᶜ.ncard ↔ Even s.ncard

theorem Set.nonempty_inter_of_lt_ncard_add_ncard E1 #

∀ {α : Type u_1} {s t : Set α} [Finite α], Nat.card α < s.ncard + t.ncard → (s ∩ t).Nonempty

theorem Set.nonempty_inter_of_le_ncard_add_ncard E1 #

∀ {α : Type u_1} {s t : Set α} [Finite α], Nat.card α ≤ s.ncard + t.ncard → s ∪ t ≠ Set.univ → (s ∩ t).Nonempty

theorem Set.union_ne_univ_of_ncard_add_ncard_lt E1 #

∀ {α : Type u_1} {s t : Set α}, s.ncard + t.ncard < Nat.card α → s ∪ t ≠ Set.univ

theorem Set.nonempty_inter_compl_of_ncard_add_ncard_lt E1 #

∀ {α : Type u_1} {s t : Set α}, s.ncard + t.ncard < Nat.card α → (sᶜ ∩ tᶜ).Nonempty

theorem Set.exists_subsuperset_card_eq E0 #

∀ {α : Type u_1} {s t : Set α} {n : ℕ}, s ⊆ t → s.ncard ≤ n → n ≤ t.ncard → ∃ u, s ⊆ u ∧ u ⊆ t ∧ u.ncard = 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 Set.exists_subset_card_eq E0 #

∀ {α : Type u_1} {s : Set α} {n : ℕ}, n ≤ s.ncard → ∃ t ⊆ s, t.ncard = n

We can shrink a set to any smaller size.

theorem Set.exists_subset_ncard_eq E0 #

∀ {α : Type u_1} {s : Set α} {k : ℕ}, k ≤ s.ncard → ∃ t ⊆ s, t.Finite ∧ t.ncard = k

Every k ≤ s.ncard is the ncard of a finite subset of s. For infinite s, s.ncard = 0 makes k = 0 so it remains true.

theorem Set.Infinite.exists_subset_ncard_eq E0 #

∀ {α : Type u_1} {s : Set α}, s.Infinite → ∀ (k : ℕ), ∃ t ⊆ s, t.Finite ∧ t.ncard = k

theorem Set.Infinite.exists_superset_ncard_eq E0 #

∀ {α : Type u_1} {s t : Set α},
  t.Infinite → s ⊆ t → s.Finite → ∀ {k : ℕ}, s.ncard ≤ k → ∃ s', s'.Finite ∧ s ⊆ s' ∧ s' ⊆ t ∧ s'.ncard = k

theorem Set.exists_superset_ncard_eq E0 #

∀ {α : Type u_1} {s : Set α} [Infinite α] {k : ℕ}, s.Finite → s.ncard ≤ k → ∃ t, t.Finite ∧ s ⊆ t ∧ t.ncard = k

theorem Set.exists_ncard_eq E0 #

∀ (α : Type u_1) [Infinite α] (k : ℕ), ∃ s, s.Finite ∧ s.ncard = k

theorem Set.exists_subset_or_subset_of_two_mul_lt_ncard E1 #

∀ {α : Type u_1} {s t : Set α} {n : ℕ}, 2 * n < (s ∪ t).ncard → ∃ r, n < r.ncard ∧ (r ⊆ s ∨ r ⊆ t)

theorem Finset.exists_notMem_of_card_lt_enatCard E1 #

∀ {α : Type u_1} {s : Finset α}, ↑s.card < ENat.card α → ∃ a, a ∉ s

theorem Set.ncard_eq_one E0 #

∀ {α : Type u_1} {s : Set α}, s.ncard = 1 ↔ ∃ a, s = {a}

theorem Set.exists_eq_insert_iff_ncard E1 #

∀ {α : Type u_1} {s t : Set α},
  autoParam s.Finite Set.exists_eq_insert_iff_ncard._auto_1 →
    ((∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.ncard + 1 = t.ncard)

theorem Set.ncard_le_one E1 #

∀ {α : Type u_1} {s : Set α}, autoParam s.Finite Set.ncard_le_one._auto_1 → (s.ncard ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b)

theorem Set.ncard_le_one_iff_subsingleton E0 #

∀ {α : Type u_1} {s : Set α} [Finite ↑s], s.ncard ≤ 1 ↔ s.Subsingleton

theorem Set.ncard_le_one_iff E0 #

∀ {α : Type u_1} {s : Set α},
  autoParam s.Finite Set.ncard_le_one_iff._auto_1 → (s.ncard ≤ 1 ↔ ∀ {a b : α}, a ∈ s → b ∈ s → a = b)

theorem Set.ncard_le_one_iff_eq E0 #

∀ {α : Type u_1} {s : Set α}, autoParam s.Finite Set.ncard_le_one_iff_eq._auto_1 → (s.ncard ≤ 1 ↔ s = ∅ ∨ ∃ a, s = {a})

theorem Set.ncard_le_one_iff_subset_singleton E1 #

∀ {α : Type u_1} {s : Set α} [Nonempty α],
  autoParam s.Finite Set.ncard_le_one_iff_subset_singleton._auto_1 → (s.ncard ≤ 1 ↔ ∃ x, s ⊆ {x})

theorem Set.ncard_le_one_of_subsingleton E1 #

∀ {α : Type u_1} [Subsingleton α] (s : Set α), s.ncard ≤ 1

A Set of a subsingleton type has cardinality at most one.

theorem Set.one_lt_ncard_iff_nontrivial E1 #

∀ {α : Type u_1} {s : Set α} [Finite ↑s], 1 < s.ncard ↔ s.Nontrivial

theorem Set.one_lt_ncard_iff_nontrivial_and_finite E1 #

∀ {α : Type u_1} {s : Set α}, 1 < s.ncard ↔ s.Nontrivial ∧ s.Finite

theorem Set.one_lt_ncard E1 #

∀ {α : Type u_1} {s : Set α}, autoParam s.Finite Set.one_lt_ncard._auto_1 → (1 < s.ncard ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b)

theorem Set.one_lt_ncard_iff E0 #

∀ {α : Type u_1} {s : Set α},
  autoParam s.Finite Set.one_lt_ncard_iff._auto_1 → (1 < s.ncard ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b)

theorem Set.one_lt_ncard_of_nonempty_of_even E1 #

∀ {α : Type u_1} {s : Set α},
  s.Finite → autoParam s.Nonempty Set.one_lt_ncard_of_nonempty_of_even._auto_1 → Even s.ncard → 1 < s.ncard

theorem Set.two_lt_ncard_iff E0 #

∀ {α : Type u_1} {s : Set α},
  autoParam s.Finite Set.two_lt_ncard_iff._auto_1 →
    (2 < s.ncard ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c)

theorem Set.two_lt_ncard E1 #

∀ {α : Type u_1} {s : Set α},
  autoParam s.Finite Set.two_lt_ncard._auto_1 → (2 < s.ncard ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c)

theorem Set.three_lt_ncard_iff E0 #

∀ {α : Type u_1} {s : Set α},
  autoParam s.Finite Set.three_lt_ncard_iff._auto_1 →
    (3 < s.ncard ↔ ∃ 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 Set.three_lt_ncard E1 #

∀ {α : Type u_1} {s : Set α},
  autoParam s.Finite Set.three_lt_ncard._auto_1 →
    (3 < s.ncard ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, ∃ d ∈ s, a ≠ b ∧ a ≠ c ∧ a ≠ d ∧ b ≠ c ∧ b ≠ d ∧ c ≠ d)

theorem Set.exists_ne_of_one_lt_ncard E1 #

∀ {α : Type u_1} {s : Set α}, 1 < s.ncard → ∀ (a : α), ∃ b ∈ s, b ≠ a

theorem Set.ncard_eq_succ E1 #

∀ {α : Type u_1} {s : Set α} {n : ℕ},
  autoParam s.Finite Set.ncard_eq_succ._auto_1 → (s.ncard = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.ncard = n)

theorem Set.ncard_eq_two E1 #

∀ {α : Type u_1} {s : Set α}, s.ncard = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y}

theorem Set.ncard_eq_three E1 #

∀ {α : Type u_1} {s : Set α}, s.ncard = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z}

theorem Set.ncard_eq_four E1 #

∀ {α : Type u_1} {s : Set α}, s.ncard = 4 ↔ ∃ x y z w, x ≠ y ∧ x ≠ z ∧ x ≠ w ∧ y ≠ z ∧ y ≠ w ∧ z ≠ w ∧ s = {x, y, z, w}

theorem Set.ncard_sumEquiv_symm_apply E0 #

∀ {α : Type u_3} (s : Set α), (Set.sumEquiv.symm (s, s)).ncard = s.ncard + s.ncard

theorem Function.Surjective.card_le_card_add_one_iff E0 #

∀ {α : Type u_1} {β : Type u_2} [Finite α] {f : α → β},
  Function.Surjective f →
    (Nat.card α ≤ Nat.card β + 1 ↔ ∀ (a b c d : α), f a = f b → f c = f d → a ≠ b → c ≠ d → {a, b} = {c, d})

A surjective function f : α → β decreases cardinality by at most one if and only if there is at most a collision between a unique pair of elements.

theorem Set.ncard_le_ncard_image_add_one_iff E0 #

∀ {α : Type u_1} {β : Type u_2} (s : Set α) [Finite ↑s] (f : α → β),
  s.ncard ≤ (f '' s).ncard + 1 ↔
    ∀ a ∈ s, ∀ b ∈ s, ∀ c ∈ s, ∀ d ∈ s, f a = f b → f c = f d → a ≠ b → c ≠ d → {a, b} = {c, d}

A function f : α → β decreases cardinality by at most one if and only if there is at most a collision between a unique pair of elements.

Deprecated aliases

NameNew nameSince
Finset.exists_not_mem_of_card_lt_enatCardFinset.exists_notMem_of_card_lt_enatCard2026-09-28
Set.diff_nonempty_of_ncard_lt_ncardSet.sdiff_nonempty_of_ncard_lt_ncard2026-06-03
Set.encard_diffSet.encard_sdiff2026-06-03
Set.encard_diff_add_encardSet.encard_sdiff_add_encard2026-06-03
Set.encard_diff_add_encard_interSet.encard_sdiff_add_encard_inter2026-06-03
Set.encard_diff_add_encard_of_subsetSet.encard_sdiff_add_encard_of_subset2026-06-03
Set.encard_diff_singleton_add_oneSet.encard_sdiff_singleton_add_one2026-06-03
Set.encard_diff_singleton_of_memSet.encard_sdiff_singleton_of_mem2026-06-03
Set.encard_eq_encard_iff_encard_diff_eq_encard_diffSet.encard_eq_encard_iff_encard_sdiff_eq_encard_sdiff2026-06-03
Set.encard_le_encard_diff_add_encardSet.encard_le_encard_sdiff_add_encard2026-06-03
Set.encard_le_encard_iff_encard_diff_le_encard_diffSet.encard_le_encard_iff_encard_sdiff_le_encard_sdiff2026-06-03
Set.encard_lt_encard_iff_encard_diff_lt_encard_diffSet.encard_lt_encard_iff_encard_sdiff_lt_encard_sdiff2026-06-03
Set.encard_tsub_one_le_encard_diff_singletonSet.encard_tsub_one_le_encard_sdiff_singleton2026-06-03
Set.le_ncard_diffSet.le_ncard_sdiff2026-06-03
Set.ncard_diffSet.ncard_sdiff2026-06-03
Set.ncard_diff'Set.ncard_sdiff'2026-06-03
Set.ncard_diff_add_ncardSet.ncard_sdiff_add_ncard2026-06-03
Set.ncard_diff_add_ncard_of_subsetSet.ncard_sdiff_add_ncard_of_subset2026-06-03
Set.ncard_diff_singleton_add_oneSet.ncard_sdiff_singleton_add_one2026-06-03
Set.ncard_diff_singleton_leSet.ncard_sdiff_singleton_le2026-06-03
Set.ncard_diff_singleton_lt_of_memSet.ncard_sdiff_singleton_lt_of_mem2026-06-03
Set.ncard_diff_singleton_of_memSet.ncard_sdiff_singleton_of_mem2026-06-03
Set.ncard_eq_ncard_iff_ncard_diff_eq_ncard_diffSet.ncard_eq_ncard_iff_ncard_sdiff_eq_ncard_sdiff2026-06-03
Set.ncard_inter_add_ncard_diff_eq_ncardSet.ncard_inter_add_ncard_sdiff_eq_ncard2026-06-03
Set.ncard_le_ncard_diff_add_ncardSet.ncard_le_ncard_sdiff_add_ncard2026-06-03
Set.ncard_le_ncard_iff_ncard_diff_le_ncard_diffSet.ncard_le_ncard_iff_ncard_sdiff_le_ncard_sdiff2026-06-03
Set.ncard_lt_ncard_iff_ncard_diff_lt_ncard_diffSet.ncard_lt_ncard_iff_ncard_sdiff_lt_ncard_sdiff2026-06-03
Set.pred_ncard_le_ncard_diff_singletonSet.pred_ncard_le_ncard_sdiff_singleton2026-06-03
Set.toENat_cardinalMk_subtypeSet.encard_ofPred2026-10-01
Set.tsub_encard_le_encard_diffSet.tsub_encard_le_encard_sdiff2026-06-03