Documentation

Mathlib.Data.Set.Card

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 PartENat.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 #

Implementation Notes #

The theorems in this file are very similar to those in Data.Finset.Card, 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.

noncomputable def Set.encard {α : Type u_1} (s : Set α) :

The cardinality of a set as a term in ℕ∞

Equations
Instances For
    @[simp]
    theorem Set.encard_univ_coe {α : Type u_1} (s : Set α) :
    theorem Set.encard_univ (α : Type u_3) :
    Set.encard Set.univ = PartENat.withTopEquiv (PartENat.card α)
    theorem Set.encard_eq_coe_toFinset_card {α : Type u_1} (s : Set α) [Fintype s] :
    Set.encard s = (Set.toFinset s).card
    theorem Set.encard_coe_eq_coe_finsetCard {α : Type u_1} (s : Finset α) :
    Set.encard s = s.card
    theorem Set.Infinite.encard_eq {α : Type u_1} {s : Set α} (h : Set.Infinite s) :
    @[simp]
    theorem Set.encard_eq_zero {α : Type u_1} {s : Set α} :
    @[simp]
    theorem Set.encard_empty {α : Type u_1} :
    theorem Set.nonempty_of_encard_ne_zero {α : Type u_1} {s : Set α} (h : Set.encard s 0) :
    theorem Set.encard_ne_zero {α : Type u_1} {s : Set α} :
    @[simp]
    theorem Set.encard_pos {α : Type u_1} {s : Set α} :
    @[simp]
    theorem Set.encard_singleton {α : Type u_1} (e : α) :
    theorem Set.encard_union_eq {α : Type u_1} {s : Set α} {t : Set α} (h : Disjoint s t) :
    theorem Set.encard_insert_of_not_mem {α : Type u_1} {s : Set α} {a : α} (has : as) :
    theorem Set.Finite.encard_lt_top {α : Type u_1} {s : Set α} (h : Set.Finite s) :
    theorem Set.Finite.encard_eq_coe {α : Type u_1} {s : Set α} (h : Set.Finite s) :
    Set.encard s = (ENat.toNat (Set.encard s))
    theorem Set.Finite.exists_encard_eq_coe {α : Type u_1} {s : Set α} (h : Set.Finite s) :
    ∃ (n : ), Set.encard s = n
    @[simp]
    theorem Set.encard_lt_top_iff {α : Type u_1} {s : Set α} :
    @[simp]
    theorem Set.encard_eq_top_iff {α : Type u_1} {s : Set α} :
    theorem Set.finite_of_encard_le_coe {α : Type u_1} {s : Set α} {k : } (h : Set.encard s k) :
    theorem Set.finite_of_encard_eq_coe {α : Type u_1} {s : Set α} {k : } (h : Set.encard s = k) :
    theorem Set.encard_le_coe_iff {α : Type u_1} {s : Set α} {k : } :
    Set.encard s k Set.Finite s ∃ (n₀ : ), Set.encard s = n₀ n₀ k
    theorem Set.encard_le_card {α : Type u_1} {s : Set α} {t : Set α} (h : s t) :
    theorem Set.encard_mono {α : Type u_3} :
    Monotone Set.encard
    theorem Set.encard_diff_add_encard_of_subset {α : Type u_1} {s : Set α} {t : Set α} (h : s t) :
    @[simp]
    theorem Set.encard_diff_add_encard_inter {α : Type u_1} (s : Set α) (t : Set α) :
    theorem Set.encard_union_add_encard_inter {α : Type u_1} (s : Set α) (t : Set α) :
    theorem Set.encard_union_le {α : Type u_1} (s : Set α) (t : Set α) :
    theorem Set.Finite.finite_of_encard_le {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (hs : Set.Finite s) (h : Set.encard t Set.encard s) :
    theorem Set.Finite.eq_of_subset_of_encard_le {α : Type u_1} {s : Set α} {t : Set α} (ht : Set.Finite t) (hst : s t) (hts : Set.encard t Set.encard s) :
    s = t
    theorem Set.Finite.eq_of_subset_of_encard_le' {α : Type u_1} {s : Set α} {t : Set α} (hs : Set.Finite s) (hst : s t) (hts : Set.encard t Set.encard s) :
    s = t
    theorem Set.Finite.encard_lt_encard {α : Type u_1} {s : Set α} {t : Set α} (ht : Set.Finite t) (h : s t) :
    theorem Set.encard_strictMono {α : Type u_1} [Finite α] :
    StrictMono Set.encard
    theorem Set.encard_diff_add_encard {α : Type u_1} (s : Set α) (t : Set α) :
    theorem Set.tsub_encard_le_encard_diff {α : Type u_1} (s : Set α) (t : Set α) :
    theorem Set.encard_insert_le {α : Type u_1} (s : Set α) (x : α) :
    theorem Set.encard_singleton_inter {α : Type u_1} (s : Set α) (x : α) :
    Set.encard ({x} s) 1
    theorem Set.encard_diff_singleton_add_one {α : Type u_1} {s : Set α} {a : α} (h : a s) :
    Set.encard (s \ {a}) + 1 = Set.encard s
    theorem Set.encard_diff_singleton_of_mem {α : Type u_1} {s : Set α} {a : α} (h : a s) :
    Set.encard (s \ {a}) = Set.encard s - 1
    theorem Set.encard_tsub_one_le_encard_diff_singleton {α : Type u_1} (s : Set α) (x : α) :
    theorem Set.encard_exchange {α : Type u_1} {s : Set α} {a : α} {b : α} (ha : as) (hb : b s) :
    theorem Set.encard_exchange' {α : Type u_1} {s : Set α} {a : α} {b : α} (ha : as) (hb : b s) :
    theorem Set.encard_eq_add_one_iff {α : Type u_1} {s : Set α} {k : ℕ∞} :
    Set.encard s = k + 1 ∃ (a : α) (t : Set α), at insert a t = s Set.encard t = k

    Every set is either empty, infinite, or can have its encard reduced by a removal. Intended for well-founded induction on the value of encard.

    theorem Set.encard_pair {α : Type u_1} {x : α} {y : α} (hne : x y) :
    Set.encard {x, y} = 2
    theorem Set.encard_eq_one {α : Type u_1} {s : Set α} :
    Set.encard s = 1 ∃ (x : α), s = {x}
    theorem Set.encard_le_one_iff_eq {α : Type u_1} {s : Set α} :
    Set.encard s 1 s = ∃ (x : α), s = {x}
    theorem Set.encard_le_one_iff {α : Type u_1} {s : Set α} :
    Set.encard s 1 ∀ (a b : α), a sb sa = b
    theorem Set.one_lt_encard_iff {α : Type u_1} {s : Set α} :
    1 < Set.encard s ∃ (a : α) (b : α), a s b s a b
    theorem Set.exists_ne_of_one_lt_encard {α : Type u_1} {s : Set α} (h : 1 < Set.encard s) (a : α) :
    ∃ b ∈ s, b a
    theorem Set.encard_eq_two {α : Type u_1} {s : Set α} :
    Set.encard s = 2 ∃ (x : α) (y : α), x y s = {x, y}
    theorem Set.encard_eq_three {α : Type u_1} {s : Set α} :
    Set.encard s = 3 ∃ (x : α) (y : α) (z : α), x y x z y z s = {x, y, z}
    theorem Set.Nat.encard_range (k : ) :
    Set.encard {i : | i < k} = k
    theorem Set.Finite.eq_insert_of_subset_of_encard_eq_succ {α : Type u_1} {s : Set α} {t : Set α} (hs : Set.Finite s) (h : s t) (hst : Set.encard t = Set.encard s + 1) :
    ∃ (a : α), t = insert a s
    theorem Set.exists_subset_encard_eq {α : Type u_1} {s : Set α} {k : ℕ∞} (hk : k Set.encard s) :
    ∃ t ⊆ s, Set.encard t = k
    theorem Set.exists_superset_subset_encard_eq {α : Type u_1} {s : Set α} {t : Set α} {k : ℕ∞} (hst : s t) (hsk : Set.encard s k) (hkt : k Set.encard t) :
    ∃ (r : Set α), s r r t Set.encard r = k
    theorem Set.InjOn.encard_image {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} (h : Set.InjOn f s) :
    theorem Set.encard_congr {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (e : s t) :
    theorem Function.Injective.encard_image {α : Type u_1} {β : Type u_2} {f : αβ} (hf : Function.Injective f) (s : Set α) :
    theorem Function.Embedding.enccard_le {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (e : s t) :
    theorem Set.encard_image_le {α : Type u_1} {β : Type u_2} (f : αβ) (s : Set α) :
    theorem Set.Finite.injOn_of_encard_image_eq {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} (hs : Set.Finite s) (h : Set.encard (f '' s) = Set.encard s) :
    theorem Set.encard_preimage_of_injective_subset_range {α : Type u_1} {β : Type u_2} {t : Set β} {f : αβ} (hf : Function.Injective f) (ht : t Set.range f) :
    theorem Set.encard_le_encard_of_injOn {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : αβ} (hf : Set.MapsTo f s t) (f_inj : Set.InjOn f s) :
    theorem Set.Finite.exists_injOn_of_encard_le {α : Type u_1} {β : Type u_2} [Nonempty β] {s : Set α} {t : Set β} (hs : Set.Finite s) (hle : Set.encard s Set.encard t) :
    ∃ (f : αβ), s f ⁻¹' t Set.InjOn f s
    theorem Set.Finite.exists_bijOn_of_encard_eq {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} [Nonempty β] (hs : Set.Finite s) (h : Set.encard s = Set.encard t) :
    ∃ (f : αβ), Set.BijOn f s t

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

    Equations
    Instances For

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

      Equations
      Instances For
        noncomputable def Set.ncard {α : Type u_1} (s : Set α) :

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

        Equations
        Instances For
          theorem Set.ncard_def {α : Type u_1} (s : Set α) :
          Set.ncard s = ENat.toNat (Set.encard s)
          theorem Set.Finite.cast_ncard_eq {α : Type u_1} {s : Set α} (hs : Set.Finite s) :
          theorem Set.Nat.card_coe_set_eq {α : Type u_1} (s : Set α) :
          theorem Set.ncard_eq_toFinset_card' {α : Type u_1} (s : Set α) [Fintype s] :
          theorem Set.Infinite.ncard {α : Type u_1} {s : Set α} (hs : Set.Infinite s) :
          theorem Set.ncard_le_ncard {α : Type u_1} {s : Set α} {t : Set α} (hst : s t) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.ncard_mono {α : Type u_1} [Finite α] :
          Monotone Set.ncard
          @[simp]
          theorem Set.ncard_eq_zero {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          @[simp]
          theorem Set.ncard_coe_Finset {α : Type u_1} (s : Finset α) :
          Set.ncard s = s.card
          theorem Set.ncard_univ (α : Type u_3) :
          Set.ncard Set.univ = Nat.card α
          @[simp]
          theorem Set.ncard_empty (α : Type u_3) :
          theorem Set.ncard_pos {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_ne_zero_of_mem {α : Type u_1} {s : Set α} {a : α} (h : a s) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.finite_of_ncard_ne_zero {α : Type u_1} {s : Set α} (hs : Set.ncard s 0) :
          theorem Set.finite_of_ncard_pos {α : Type u_1} {s : Set α} (hs : 0 < Set.ncard s) :
          theorem Set.nonempty_of_ncard_ne_zero {α : Type u_1} {s : Set α} (hs : Set.ncard s 0) :
          @[simp]
          theorem Set.ncard_singleton {α : Type u_1} (a : α) :
          Set.ncard {a} = 1
          theorem Set.ncard_singleton_inter {α : Type u_1} (a : α) (s : Set α) :
          Set.ncard ({a} s) 1
          @[simp]
          theorem Set.ncard_insert_of_not_mem {α : Type u_1} {s : Set α} {a : α} (h : as) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_insert_of_mem {α : Type u_1} {s : Set α} {a : α} (h : a s) :
          theorem Set.ncard_insert_le {α : Type u_1} (a : α) (s : Set α) :
          theorem Set.ncard_insert_eq_ite {α : Type u_1} {s : Set α} {a : α} [Decidable (a s)] (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard (insert a s) = if a s then Set.ncard s else Set.ncard s + 1
          theorem Set.ncard_le_ncard_insert {α : Type u_1} (a : α) (s : Set α) :
          @[simp]
          theorem Set.ncard_pair {α : Type u_1} {a : α} {b : α} (h : a b) :
          Set.ncard {a, b} = 2
          @[simp]
          theorem Set.ncard_diff_singleton_add_one {α : Type u_1} {s : Set α} {a : α} (h : a s) (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard (s \ {a}) + 1 = Set.ncard s
          @[simp]
          theorem Set.ncard_diff_singleton_of_mem {α : Type u_1} {s : Set α} {a : α} (h : a s) (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard (s \ {a}) = Set.ncard s - 1
          theorem Set.ncard_diff_singleton_lt_of_mem {α : Type u_1} {s : Set α} {a : α} (h : a s) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_diff_singleton_le {α : Type u_1} (s : Set α) (a : α) :
          theorem Set.pred_ncard_le_ncard_diff_singleton {α : Type u_1} (s : Set α) (a : α) :
          Set.ncard s - 1 Set.ncard (s \ {a})
          theorem Set.ncard_exchange {α : Type u_1} {s : Set α} {a : α} {b : α} (ha : as) (hb : b s) :
          Set.ncard (insert a (s \ {b})) = Set.ncard s
          theorem Set.ncard_exchange' {α : Type u_1} {s : Set α} {a : α} {b : α} (ha : as) (hb : b s) :
          theorem Set.ncard_image_le {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_image_of_injOn {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} (H : Set.InjOn f s) :
          theorem Set.injOn_of_ncard_image_eq {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} (h : Set.ncard (f '' s) = Set.ncard s) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_image_iff {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_image_of_injective {α : Type u_1} {β : Type u_2} {f : αβ} (s : Set α) (H : Function.Injective f) :
          theorem Set.ncard_preimage_of_injective_subset_range {α : Type u_1} {β : Type u_2} {f : αβ} {s : Set β} (H : Function.Injective f) (hs : s Set.range f) :
          theorem Set.fiber_ncard_ne_zero_iff_mem_image {α : Type u_1} {β : Type u_2} {s : Set α} {f : αβ} {y : β} (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard {x : α | x s f x = y} 0 y f '' s
          @[simp]
          theorem Set.ncard_map {α : Type u_1} {β : Type u_2} {s : Set α} (f : α β) :
          Set.ncard (f '' s) = Set.ncard s
          @[simp]
          theorem Set.ncard_subtype {α : Type u_1} (P : αProp) (s : Set α) :
          Set.ncard {x : Subtype P | x s} = Set.ncard (s setOf P)
          theorem Set.ncard_inter_le_ncard_left {α : Type u_1} (s : Set α) (t : Set α) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_inter_le_ncard_right {α : Type u_1} (s : Set α) (t : Set α) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.eq_of_subset_of_ncard_le {α : Type u_1} {s : Set α} {t : Set α} (h : s t) (h' : Set.ncard t Set.ncard s) (ht : autoParam (Set.Finite t) _auto✝) :
          s = t
          theorem Set.subset_iff_eq_of_ncard_le {α : Type u_1} {s : Set α} {t : Set α} (h : Set.ncard t Set.ncard s) (ht : autoParam (Set.Finite t) _auto✝) :
          s t s = t
          theorem Set.map_eq_of_subset {α : Type u_1} {s : Set α} {f : α α} (h : f '' s s) (hs : autoParam (Set.Finite s) _auto✝) :
          f '' s = s
          theorem Set.sep_of_ncard_eq {α : Type u_1} {s : Set α} {a : α} {P : αProp} (h : Set.ncard {x : α | x s P x} = Set.ncard s) (ha : a s) (hs : autoParam (Set.Finite s) _auto✝) :
          P a
          theorem Set.ncard_lt_ncard {α : Type u_1} {s : Set α} {t : Set α} (h : s t) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.ncard_strictMono {α : Type u_1} [Finite α] :
          StrictMono Set.ncard
          theorem Set.ncard_eq_of_bijective {α : Type u_1} {s : Set α} {n : } (f : (i : ) → i < nα) (hf : as, ∃ (i : ) (h : i < n), f i h = a) (hf' : ∀ (i : ) (h : i < n), f i h s) (f_inj : ∀ (i j : ) (hi : i < n) (hj : j < n), f i hi = f j hji = j) :
          theorem Set.ncard_congr {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : (a : α) → a sβ) (h₁ : ∀ (a : α) (ha : a s), f a ha t) (h₂ : ∀ (a b : α) (ha : a s) (hb : b s), f a ha = f b hba = b) (h₃ : bt, ∃ (a : α) (ha : a s), f a ha = b) :
          theorem Set.ncard_le_ncard_of_injOn {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : αβ) (hf : as, f a t) (f_inj : Set.InjOn f s) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.exists_ne_map_eq_of_ncard_lt_of_maps_to {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (hc : Set.ncard t < Set.ncard s) {f : αβ} (hf : as, f a t) (ht : autoParam (Set.Finite t) _auto✝) :
          ∃ x ∈ s, ∃ y ∈ s, x y f x = f y
          theorem Set.le_ncard_of_inj_on_range {α : Type u_1} {s : Set α} {n : } (f : α) (hf : i < n, f i s) (f_inj : i < n, j < n, f i = f ji = j) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.surj_on_of_inj_on_of_ncard_le {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : (a : α) → a sβ) (hf : ∀ (a : α) (ha : a s), f a ha t) (hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ s) (ha₂ : a₂ s), f a₁ ha₁ = f a₂ ha₂a₁ = a₂) (hst : Set.ncard t Set.ncard s) (ht : autoParam (Set.Finite t) _auto✝) (b : β) :
          b t∃ (a : α) (ha : a s), b = f a ha
          theorem Set.inj_on_of_surj_on_of_ncard_le {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} (f : (a : α) → a sβ) (hf : ∀ (a : α) (ha : a s), f a ha t) (hsurj : bt, ∃ (a : α) (ha : a s), f a ha = b) (hst : Set.ncard s Set.ncard t) ⦃a₁ : α (ha₁ : a₁ s) ⦃a₂ : α (ha₂ : a₂ s) (ha₁a₂ : f a₁ ha₁ = f a₂ ha₂) (hs : autoParam (Set.Finite s) _auto✝) :
          a₁ = a₂
          theorem Set.ncard_union_le {α : Type u_1} (s : Set α) (t : Set α) :
          theorem Set.ncard_union_eq {α : Type u_1} {s : Set α} {t : Set α} (h : Disjoint s t) (hs : autoParam (Set.Finite s) _auto✝) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.ncard_diff_add_ncard_of_subset {α : Type u_1} {s : Set α} {t : Set α} (h : s t) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.ncard_diff {α : Type u_1} {s : Set α} {t : Set α} (h : s t) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.le_ncard_diff {α : Type u_1} (s : Set α) (t : Set α) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.ncard_diff_add_ncard {α : Type u_1} (s : Set α) (t : Set α) (hs : autoParam (Set.Finite s) _auto✝) (ht : autoParam (Set.Finite t) _auto✝) :
          theorem Set.diff_nonempty_of_ncard_lt_ncard {α : Type u_1} {s : Set α} {t : Set α} (h : Set.ncard s < Set.ncard t) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.exists_mem_not_mem_of_ncard_lt_ncard {α : Type u_1} {s : Set α} {t : Set α} (h : Set.ncard s < Set.ncard t) (hs : autoParam (Set.Finite s) _auto✝) :
          ∃ e ∈ t, es
          @[simp]
          theorem Set.ncard_inter_add_ncard_diff_eq_ncard {α : Type u_1} (s : Set α) (t : Set α) (hs : autoParam (Set.Finite s) _auto✝) :
          theorem Set.exists_intermediate_Set {α : Type u_1} {s : Set α} {t : Set α} (i : ) (h₁ : i + Set.ncard s Set.ncard t) (h₂ : s t) :
          ∃ (r : Set α), s r r t Set.ncard r = i + Set.ncard s

          Given a set t and a set s inside it, we can shrink t to any appropriate size, and keep s inside it.

          theorem Set.exists_intermediate_set' {α : Type u_1} {s : Set α} {t : Set α} {m : } (hs : Set.ncard s m) (ht : m Set.ncard t) (h : s t) :
          ∃ (r : Set α), s r r t Set.ncard r = m
          theorem Set.exists_smaller_set {α : Type u_1} (s : Set α) (i : ) (h₁ : i Set.ncard s) :
          ∃ t ⊆ s, Set.ncard t = i

          We can shrink s to any smaller size.

          theorem Set.Infinite.exists_subset_ncard_eq {α : Type u_1} {s : Set α} (hs : Set.Infinite s) (k : ) :
          ∃ t ⊆ s, Set.Finite t Set.ncard t = k
          theorem Set.Infinite.exists_superset_ncard_eq {α : Type u_1} {s : Set α} {t : Set α} (ht : Set.Infinite t) (hst : s t) (hs : Set.Finite s) {k : } (hsk : Set.ncard s k) :
          ∃ (s' : Set α), s s' s' t Set.ncard s' = k
          theorem Set.exists_subset_or_subset_of_two_mul_lt_ncard {α : Type u_1} {s : Set α} {t : Set α} {n : } (hst : 2 * n < Set.ncard (s t)) :
          ∃ (r : Set α), n < Set.ncard r (r s r t)

          Explicit description of a set from its cardinality #

          @[simp]
          theorem Set.ncard_eq_one {α : Type u_1} {s : Set α} :
          Set.ncard s = 1 ∃ (a : α), s = {a}
          theorem Set.exists_eq_insert_iff_ncard {α : Type u_1} {s : Set α} {t : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          (∃ a ∉ s, insert a s = t) s t Set.ncard s + 1 = Set.ncard t
          theorem Set.ncard_le_one {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard s 1 as, bs, a = b
          theorem Set.ncard_le_one_iff {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard s 1 ∀ {a b : α}, a sb sa = b
          theorem Set.ncard_le_one_iff_eq {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard s 1 s = ∃ (a : α), s = {a}
          theorem Set.ncard_le_one_iff_subset_singleton {α : Type u_1} {s : Set α} [Nonempty α] (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard s 1 ∃ (x : α), s {x}
          theorem Set.ncard_le_one_of_subsingleton {α : Type u_1} [Subsingleton α] (s : Set α) :

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

          theorem Set.one_lt_ncard {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          1 < Set.ncard s ∃ a ∈ s, ∃ b ∈ s, a b
          theorem Set.one_lt_ncard_iff {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          1 < Set.ncard s ∃ (a : α) (b : α), a s b s a b
          theorem Set.two_lt_ncard_iff {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          2 < Set.ncard s ∃ (a : α) (b : α) (c : α), a s b s c s a b a c b c
          theorem Set.two_lt_ncard {α : Type u_1} {s : Set α} (hs : autoParam (Set.Finite s) _auto✝) :
          2 < Set.ncard s ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a b a c b c
          theorem Set.exists_ne_of_one_lt_ncard {α : Type u_1} {s : Set α} (hs : 1 < Set.ncard s) (a : α) :
          ∃ b ∈ s, b a
          theorem Set.eq_insert_of_ncard_eq_succ {α : Type u_1} {s : Set α} {n : } (h : Set.ncard s = n + 1) :
          ∃ (a : α) (t : Set α), at insert a t = s Set.ncard t = n
          theorem Set.ncard_eq_succ {α : Type u_1} {s : Set α} {n : } (hs : autoParam (Set.Finite s) _auto✝) :
          Set.ncard s = n + 1 ∃ (a : α) (t : Set α), at insert a t = s Set.ncard t = n
          theorem Set.ncard_eq_two {α : Type u_1} {s : Set α} :
          Set.ncard s = 2 ∃ (x : α) (y : α), x y s = {x, y}
          theorem Set.ncard_eq_three {α : Type u_1} {s : Set α} :
          Set.ncard s = 3 ∃ (x : α) (y : α) (z : α), x y x z y z s = {x, y, z}
          @[deprecated Set.ncard_le_ncard]
          theorem Set.ncard_le_of_subset {α : Type u_1} {s : Set α} {t : Set α} (hst : s t) (ht : autoParam (Set.Finite t) _auto✝) :

          Alias of Set.ncard_le_ncard.