File: Mathlib/Data/Finset/Card.lean

full_name: Finset.card
code: /-- `s.card` is the number of elements of `s`, aka its cardinality. -/
def card (s : Finset α) : ℕ 
goal: ℕ

full_name: Finset.card_def
code: theorem card_def (s : Finset α) : s.card = Multiset.card s.1 
goal: s.card = Multiset.card s.val

full_name: Finset.card_val
code: @[simp] lemma card_val (s : Finset α) : Multiset.card s.1 = s.card 
goal: Multiset.card s.val = s.card

full_name: Finset.card_mk
code: @[simp]
theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = Multiset.card m 
goal: { val := m, nodup := nodup }.card = Multiset.card m

full_name: Finset.card_empty
code: @[simp]
theorem card_empty : card (∅ : Finset α) = 0 
goal: ∅.card = 0

full_name: Finset.card_le_card
code: @[gcongr]
theorem card_le_card : s ⊆ t → s.card ≤ t.card 
goal: s ⊆ t → s.card ≤ t.card

full_name: Finset.card_mono
code: @[mono]
theorem card_mono : Monotone (@card α) 
goal: Monotone Finset.card

full_name: Finset.card_eq_zero
code: @[simp] lemma card_eq_zero : s.card = 0 ↔ s = ∅ 
goal: s.card = 0 ↔ s = ∅

full_name: Finset.card_ne_zero
code: lemma card_ne_zero : s.card ≠ 0 ↔ s.Nonempty 
goal: s.card ≠ 0 ↔ s.Nonempty

full_name: Finset.card_pos
code: @[simp] lemma card_pos : 0 < s.card ↔ s.Nonempty 
goal: 0 < s.card ↔ s.Nonempty

full_name: Finset.one_le_card
code: @[simp] lemma one_le_card : 1 ≤ s.card ↔ s.Nonempty 
goal: 1 ≤ s.card ↔ s.Nonempty

full_name: Finset.card_ne_zero_of_mem
code: theorem card_ne_zero_of_mem (h : a ∈ s) : s.card ≠ 0 
goal: s.card ≠ 0

full_name: Finset.card_singleton
code: @[simp]
theorem card_singleton (a : α) : card ({a} : Finset α) = 1 
goal: {a}.card = 1

full_name: Finset.card_singleton_inter
code: theorem card_singleton_inter [DecidableEq α] : ({a} ∩ s).card ≤ 1 
goal: ({a} ∩ s).card ≤ 1

full_name: Finset.card_cons
code: @[simp]
theorem card_cons (h : a ∉ s) : (s.cons a h).card = s.card + 1 
goal: (Finset.cons a s h).card = s.card + 1

full_name: Finset.card_insert_of_not_mem
code: @[simp]
theorem card_insert_of_not_mem (h : a ∉ s) : (insert a s).card = s.card + 1 
goal: (insert a s).card = s.card + 1

full_name: Finset.card_insert_of_mem
code: theorem card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card 
goal: (insert a s).card = s.card

full_name: Finset.card_insert_le
code: theorem card_insert_le (a : α) (s : Finset α) : card (insert a s) ≤ s.card + 1 
goal: (insert a s).card ≤ s.card + 1

full_name: Finset.card_le_two
code: theorem card_le_two : card {a, b} ≤ 2 
goal: {a, b}.card ≤ 2

full_name: Finset.card_le_three
code: theorem card_le_three : card {a, b, c} ≤ 3 
goal: {a, b, c}.card ≤ 3

full_name: Finset.card_le_four
code: theorem card_le_four : card {a, b, c, d} ≤ 4 
goal: {a, b, c, d}.card ≤ 4

full_name: Finset.card_le_five
code: theorem card_le_five : card {a, b, c, d, e} ≤ 5 
goal: {a, b, c, d, e}.card ≤ 5

full_name: Finset.card_le_six
code: theorem card_le_six : card {a, b, c, d, e, f} ≤ 6 
goal: {a, b, c, d, e, f}.card ≤ 6

full_name: Finset.card_insert_eq_ite
code: /-- If `a ∈ s` is known, see also `Finset.card_insert_of_mem` and `Finset.card_insert_of_not_mem`.
-/
theorem card_insert_eq_ite : card (insert a s) = if a ∈ s then s.card else s.card + 1 
goal: (insert a s).card = if a ∈ s then s.card else s.card + 1

full_name: Finset.card_pair_eq_one_or_two
code: @[simp]
theorem card_pair_eq_one_or_two : ({a,b} : Finset α).card = 1 ∨ ({a,b} : Finset α).card = 2 
goal: {a, b}.card = 1 ∨ {a, b}.card = 2

full_name: Finset.card_pair
code: @[simp]
theorem card_pair (h : a ≠ b) : ({a, b} : Finset α).card = 2 
goal: {a, b}.card = 2

full_name: Finset.card_erase_of_mem
code: /-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$. -/
@[simp]
theorem card_erase_of_mem : a ∈ s → (s.erase a).card = s.card - 1 
goal: a ∈ s → (s.erase a).card = s.card - 1

full_name: Finset.cast_card_erase_of_mem
code: /-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$.
  This result is casted to any additive group with 1,
  so that we don't have to work with `ℕ`-subtraction. -/
@[simp]
theorem cast_card_erase_of_mem {R} [AddGroupWithOne R] {s : Finset α} (hs : a ∈ s) :
    ((s.erase a).card : R) = s.card - 1 
goal: ↑(s.erase a).card = ↑s.card - 1

full_name: Finset.card_erase_add_one
code: @[simp]
theorem card_erase_add_one : a ∈ s → (s.erase a).card + 1 = s.card 
goal: a ∈ s → (s.erase a).card + 1 = s.card

full_name: Finset.card_erase_lt_of_mem
code: theorem card_erase_lt_of_mem : a ∈ s → (s.erase a).card < s.card 
goal: a ∈ s → (s.erase a).card < s.card

full_name: Finset.card_erase_le
code: theorem card_erase_le : (s.erase a).card ≤ s.card 
goal: (s.erase a).card ≤ s.card

full_name: Finset.pred_card_le_card_erase
code: theorem pred_card_le_card_erase : s.card - 1 ≤ (s.erase a).card 
goal: s.card - 1 ≤ (s.erase a).card

full_name: Finset.card_erase_eq_ite
code: /-- If `a ∈ s` is known, see also `Finset.card_erase_of_mem` and `Finset.erase_eq_of_not_mem`. -/
theorem card_erase_eq_ite : (s.erase a).card = if a ∈ s then s.card - 1 else s.card 
goal: (s.erase a).card = if a ∈ s then s.card - 1 else s.card

full_name: Finset.card_range
code: @[simp]
theorem card_range (n : ℕ) : (range n).card = n 
goal: (Finset.range n).card = n

full_name: Finset.card_attach
code: @[simp]
theorem card_attach : s.attach.card = s.card 
goal: s.attach.card = s.card

full_name: Multiset.card_toFinset
code: theorem Multiset.card_toFinset : m.toFinset.card = Multiset.card m.dedup 
goal: m.toFinset.card = Multiset.card m.dedup

full_name: Multiset.toFinset_card_le
code: theorem Multiset.toFinset_card_le : m.toFinset.card ≤ Multiset.card m 
goal: m.toFinset.card ≤ Multiset.card m

full_name: Multiset.toFinset_card_of_nodup
code: theorem Multiset.toFinset_card_of_nodup {m : Multiset α} (h : m.Nodup) :
    m.toFinset.card = Multiset.card m 
goal: m.toFinset.card = Multiset.card m

full_name: Multiset.dedup_card_eq_card_iff_nodup
code: theorem Multiset.dedup_card_eq_card_iff_nodup {m : Multiset α} :
    card m.dedup = card m ↔ m.Nodup 
goal: Multiset.card m.dedup = Multiset.card m ↔ m.Nodup

full_name: Multiset.toFinset_card_eq_card_iff_nodup
code: theorem Multiset.toFinset_card_eq_card_iff_nodup {m : Multiset α} :
    m.toFinset.card = card m ↔ m.Nodup 
goal: m.toFinset.card = Multiset.card m ↔ m.Nodup

full_name: List.card_toFinset
code: theorem List.card_toFinset : l.toFinset.card = l.dedup.length 
goal: l.toFinset.card = l.dedup.length

full_name: List.toFinset_card_le
code: theorem List.toFinset_card_le : l.toFinset.card ≤ l.length 
goal: l.toFinset.card ≤ l.length

full_name: List.toFinset_card_of_nodup
code: theorem List.toFinset_card_of_nodup {l : List α} (h : l.Nodup) : l.toFinset.card = l.length 
goal: l.toFinset.card = l.length

full_name: Finset.length_toList
code: @[simp]
theorem length_toList (s : Finset α) : s.toList.length = s.card 
goal: s.toList.length = s.card

full_name: Finset.card_image_le
code: theorem card_image_le [DecidableEq β] : (s.image f).card ≤ s.card 
goal: (Finset.image f s).card ≤ s.card

full_name: Finset.card_image_of_injOn
code: theorem card_image_of_injOn [DecidableEq β] (H : Set.InjOn f s) : (s.image f).card = s.card 
goal: (Finset.image f s).card = s.card

full_name: Finset.injOn_of_card_image_eq
code: theorem injOn_of_card_image_eq [DecidableEq β] (H : (s.image f).card = s.card) : Set.InjOn f s 
goal: Set.InjOn f ↑s

full_name: Finset.card_image_iff
code: theorem card_image_iff [DecidableEq β] : (s.image f).card = s.card ↔ Set.InjOn f s 
goal: (Finset.image f s).card = s.card ↔ Set.InjOn f ↑s

full_name: Finset.card_image_of_injective
code: theorem card_image_of_injective [DecidableEq β] (s : Finset α) (H : Injective f) :
    (s.image f).card = s.card 
goal: (Finset.image f s).card = s.card

full_name: Finset.fiber_card_ne_zero_iff_mem_image
code: theorem fiber_card_ne_zero_iff_mem_image (s : Finset α) (f : α → β) [DecidableEq β] (y : β) :
    (s.filter fun x => f x = y).card ≠ 0 ↔ y ∈ s.image f 
goal: (Finset.filter (fun x => f x = y) s).card ≠ 0 ↔ y ∈ Finset.image f s

full_name: Finset.card_filter_le_iff
code: lemma card_filter_le_iff (s : Finset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
    (s.filter P).card ≤ n ↔ ∀ s' ⊆ s, n < s'.card → ∃ a ∈ s', ¬ P a 
goal: (Finset.filter P s).card ≤ n ↔ ∀ s' ⊆ s, n < s'.card → ∃ a ∈ s', ¬P a

full_name: Finset.card_map
code: @[simp]
theorem card_map (f : α ↪ β) : (s.map f).card = s.card 
goal: (Finset.map f s).card = s.card

full_name: Finset.card_subtype
code: @[simp]
theorem card_subtype (p : α → Prop) [DecidablePred p] (s : Finset α) :
    (s.subtype p).card = (s.filter p).card 
goal: (Finset.subtype p s).card = (Finset.filter p s).card

full_name: Finset.card_filter_le
code: theorem card_filter_le (s : Finset α) (p : α → Prop) [DecidablePred p] :
    (s.filter p).card ≤ s.card 
goal: (Finset.filter p s).card ≤ s.card

full_name: Finset.eq_of_subset_of_card_le
code: theorem eq_of_subset_of_card_le {s t : Finset α} (h : s ⊆ t) (h₂ : t.card ≤ s.card) : s = t 
goal: s = t

full_name: Finset.eq_of_superset_of_card_ge
code: theorem eq_of_superset_of_card_ge (hst : s ⊆ t) (hts : t.card ≤ s.card) : t = s 
goal: t = s

full_name: Finset.subset_iff_eq_of_card_le
code: theorem subset_iff_eq_of_card_le (h : t.card ≤ s.card) : s ⊆ t ↔ s = t 
goal: s ⊆ t ↔ s = t

full_name: Finset.map_eq_of_subset
code: theorem map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s 
goal: Finset.map f s = s

full_name: Finset.filter_card_eq
code: theorem filter_card_eq {p : α → Prop} [DecidablePred p] (h : (s.filter p).card = s.card) (x : α)
    (hx : x ∈ s) : p x 
goal: p x

full_name: Finset.card_lt_card
code: nonrec lemma card_lt_card (h : s ⊂ t) : s.card < t.card 
goal: s.card < t.card

full_name: Finset.card_strictMono
code: lemma card_strictMono : StrictMono (card : Finset α → ℕ) 
goal: StrictMono Finset.card

full_name: Finset.card_eq_of_bijective
code: theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ 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 hj → i = j) : s.card = n 
goal: s.card = n

full_name: Finset.card_bij
code: /-- Reorder a finset.

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. -/
lemma card_bij (i : ∀ a ∈ s, β) (hi : ∀ a ha, i a ha ∈ t)
    (i_inj : ∀ a₁ ha₁ a₂ ha₂, i a₁ ha₁ = i a₂ ha₂ → a₁ = a₂)
    (i_surj : ∀ b ∈ t, ∃ a ha, i a ha = b) : s.card = t.card 
goal: s.card = t.card

full_name: Finset.card_bij'
code: /-- Reorder a finset.

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. -/
lemma card_bij' (i : ∀ a ∈ s, β) (j : ∀ a ∈ t, α) (hi : ∀ a ha, i a ha ∈ t)
    (hj : ∀ a ha, j a ha ∈ s) (left_inv : ∀ a ha, j (i a ha) (hi a ha) = a)
    (right_inv : ∀ a ha, i (j a ha) (hj a ha) = a) : s.card = t.card 
goal: s.card = t.card

full_name: Finset.card_nbij
code: /-- Reorder a finset.

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. -/
lemma card_nbij (i : α → β) (hi : ∀ a ∈ s, i a ∈ t) (i_inj : (s : Set α).InjOn i)
    (i_surj : (s : Set α).SurjOn i t) : s.card = t.card 
goal: s.card = t.card

full_name: Finset.card_nbij'
code: /-- Reorder a finset.

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. -/
lemma card_nbij' (i : α → β) (j : β → α) (hi : ∀ a ∈ s, i a ∈ t) (hj : ∀ a ∈ t, j a ∈ s)
    (left_inv : ∀ a ∈ s, j (i a) = a) (right_inv : ∀ a ∈ t, i (j a) = a) : s.card = t.card 
goal: s.card = t.card

full_name: Finset.card_equiv
code: /-- Specialization of `Finset.card_nbij'` that automatically fills in most arguments.

See `Fintype.card_equiv` for the version where `s` and `t` are `univ`. -/
lemma card_equiv (e : α ≃ β) (hst : ∀ i, i ∈ s ↔ e i ∈ t) : s.card = t.card 
goal: s.card = t.card

full_name: Finset.card_bijective
code: /-- Specialization of `Finset.card_nbij` that automatically fills in most arguments.

See `Fintype.card_bijective` for the version where `s` and `t` are `univ`. -/
lemma card_bijective (e : α → β) (he : e.Bijective) (hst : ∀ i, i ∈ s ↔ e i ∈ t) :
    s.card = t.card 
goal: s.card = t.card

full_name: Finset.card_le_card_of_injOn
code: lemma card_le_card_of_injOn (f : α → β) (hf : ∀ a ∈ s, f a ∈ t) (f_inj : (s : Set α).InjOn f) :
    s.card ≤ t.card 
goal: s.card ≤ t.card

full_name: Finset.card_le_card_of_surjOn
code: lemma card_le_card_of_surjOn (f : α → β) (hf : Set.SurjOn f s t) : t.card ≤ s.card 
goal: t.card ≤ s.card

full_name: Finset.exists_ne_map_eq_of_card_lt_of_maps_to
code: /-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
-/
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
    (hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y 
goal: ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y

full_name: Finset.le_card_of_inj_on_range
code: lemma le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
    (f_inj : ∀ i < n, ∀ j < n, f i = f j → i = j) : n ≤ s.card 
goal: n ≤ s.card

full_name: Finset.surj_on_of_inj_on_of_card_le
code: lemma surj_on_of_inj_on_of_card_le (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
    (hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.card ≤ s.card) :
    ∀ b ∈ t, ∃ a ha, b = f a ha 
goal: b ∈ t → ∃ a, ∃ (ha : a ∈ s), b = f a ha

full_name: Finset.inj_on_of_surj_on_of_card_le
code: theorem inj_on_of_surj_on_of_card_le (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
    (hsurj : ∀ b ∈ t, ∃ a ha, f a ha = b) (hst : s.card ≤ t.card) ⦃a₁⦄ (ha₁ : a₁ ∈ s) ⦃a₂⦄
    (ha₂ : a₂ ∈ s) (ha₁a₂ : f a₁ ha₁ = f a₂ ha₂) : a₁ = a₂ 
goal: a₁ = a₂

full_name: Finset.card_disjUnion
code: @[simp]
theorem card_disjUnion (s t : Finset α) (h) : (s.disjUnion t h).card = s.card + t.card 
goal: (s.disjUnion t h).card = s.card + t.card

full_name: Finset.card_union_add_card_inter
code: theorem card_union_add_card_inter (s t : Finset α) :
    (s ∪ t).card + (s ∩ t).card = s.card + t.card 
goal: (s ∪ t).card + (s ∩ t).card = s.card + t.card

full_name: Finset.card_inter_add_card_union
code: theorem card_inter_add_card_union (s t : Finset α) :
    (s ∩ t).card + (s ∪ t).card = s.card + t.card 
goal: (s ∩ t).card + (s ∪ t).card = s.card + t.card

full_name: Finset.card_union
code: lemma card_union (s t : Finset α) : (s ∪ t).card = s.card + t.card - (s ∩ t).card 
goal: (s ∪ t).card = s.card + t.card - (s ∩ t).card

full_name: Finset.card_inter
code: lemma card_inter (s t : Finset α) : (s ∩ t).card = s.card + t.card - (s ∪ t).card 
goal: (s ∩ t).card = s.card + t.card - (s ∪ t).card

full_name: Finset.card_union_le
code: theorem card_union_le (s t : Finset α) : (s ∪ t).card ≤ s.card + t.card 
goal: (s ∪ t).card ≤ s.card + t.card

full_name: Finset.card_union_eq_card_add_card
code: lemma card_union_eq_card_add_card : (s ∪ t).card = s.card + t.card ↔ Disjoint s t 
goal: (s ∪ t).card = s.card + t.card ↔ Disjoint s t

full_name: Finset.cast_card_inter
code: lemma cast_card_inter [AddGroupWithOne R] :
    ((s ∩ t).card : R) = s.card + t.card - (s ∪ t).card 
goal: ↑(s ∩ t).card = ↑s.card + ↑t.card - ↑(s ∪ t).card

full_name: Finset.cast_card_union
code: lemma cast_card_union [AddGroupWithOne R] :
    ((s ∪ t).card : R) = s.card + t.card - (s ∩ t).card 
goal: ↑(s ∪ t).card = ↑s.card + ↑t.card - ↑(s ∩ t).card

full_name: Finset.card_sdiff
code: theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card 
goal: (t \ s).card = t.card - s.card

full_name: Finset.cast_card_sdiff
code: lemma cast_card_sdiff [AddGroupWithOne R] (h : s ⊆ t) : ((t \ s).card : R) = t.card - s.card 
goal: ↑(t \ s).card = ↑t.card - ↑s.card

full_name: Finset.card_sdiff_add_card_eq_card
code: theorem card_sdiff_add_card_eq_card {s t : Finset α} (h : s ⊆ t) : card (t \ s) + card s = card t 
goal: (t \ s).card + s.card = t.card

full_name: Finset.le_card_sdiff
code: theorem le_card_sdiff (s t : Finset α) : t.card - s.card ≤ card (t \ s) 
goal: t.card - s.card ≤ (t \ s).card

full_name: Finset.card_le_card_sdiff_add_card
code: theorem card_le_card_sdiff_add_card : s.card ≤ (s \ t).card + t.card 
goal: s.card ≤ (s \ t).card + t.card

full_name: Finset.card_sdiff_add_card
code: theorem card_sdiff_add_card (s t : Finset α) : (s \ t).card + t.card = (s ∪ t).card 
goal: (s \ t).card + t.card = (s ∪ t).card

full_name: Finset.card_sdiff_comm
code: lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card 
goal: (s \ t).card = (t \ s).card

full_name: Finset.card_sdiff_add_card_inter
code: @[simp]
lemma card_sdiff_add_card_inter (s t : Finset α) :
    (s \ t).card + (s ∩ t).card = s.card 
goal: (s \ t).card + (s ∩ t).card = s.card

full_name: Finset.card_inter_add_card_sdiff
code: @[simp]
lemma card_inter_add_card_sdiff (s t : Finset α) :
    (s ∩ t).card + (s \ t).card = s.card 
goal: (s ∩ t).card + (s \ t).card = s.card

full_name: Finset.inter_nonempty_of_card_lt_card_add_card
code: /-- **Pigeonhole principle** for two finsets inside an ambient finset. -/
theorem inter_nonempty_of_card_lt_card_add_card (hts : t ⊆ s) (hus : u ⊆ s)
    (hstu : s.card < t.card + u.card) : (t ∩ u).Nonempty 
goal: (t ∩ u).Nonempty

full_name: Finset.filter_card_add_filter_neg_card_eq_card
code: theorem filter_card_add_filter_neg_card_eq_card
    (p : α → Prop) [DecidablePred p] [∀ x, Decidable (¬p x)] :
    (s.filter p).card + (s.filter (fun a => ¬ p a)).card = s.card 
goal: (Finset.filter p s).card + (Finset.filter (fun a => ¬p a) s).card = s.card

full_name: Finset.exists_subsuperset_card_eq
code: /-- 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`. -/
lemma exists_subsuperset_card_eq (hst : s ⊆ t) (hsn : s.card ≤ n) (hnt : n ≤ t.card) :
    ∃ u, s ⊆ u ∧ u ⊆ t ∧ card u = n 
goal: ∃ u, s ⊆ u ∧ u ⊆ t ∧ u.card = n

full_name: Finset.exists_subset_card_eq
code: /-- We can shrink a set to any smaller size. -/
lemma exists_subset_card_eq (hns : n ≤ s.card) : ∃ t ⊆ s, t.card = n 
goal: ∃ t ⊆ s, t.card = n

full_name: Finset.exists_intermediate_set
code: /-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
inside it. -/
@[deprecated exists_subsuperset_card_eq (since := "2024-06-23")]
theorem exists_intermediate_set {A B : Finset α} (i : ℕ) (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) :
    ∃ C : Finset α, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B 
goal: ∃ C, B ⊆ C ∧ C ⊆ A ∧ C.card = i + B.card

full_name: Finset.exists_smaller_set
code: /-- We can shrink `A` to any smaller size. -/
@[deprecated exists_subset_card_eq (since := "2024-06-23")]
theorem exists_smaller_set (A : Finset α) (i : ℕ) (h₁ : i ≤ card A) :
    ∃ B : Finset α, B ⊆ A ∧ card B = i 
goal: ∃ B ⊆ A, B.card = i

full_name: Finset.le_card_iff_exists_subset_card
code: theorem le_card_iff_exists_subset_card : n ≤ s.card ↔ ∃ t ⊆ s, t.card = n 
goal: n ≤ s.card ↔ ∃ t ⊆ s, t.card = n

full_name: Finset.exists_subset_or_subset_of_two_mul_lt_card
code: theorem exists_subset_or_subset_of_two_mul_lt_card [DecidableEq α] {X Y : Finset α} {n : ℕ}
    (hXY : 2 * n < (X ∪ Y).card) : ∃ C : Finset α, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y) 
goal: ∃ C, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y)

full_name: Finset.card_eq_one
code: theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} 
goal: s.card = 1 ↔ ∃ a, s = {a}

full_name: Multiset.toFinset_card_eq_one_iff
code: theorem _root_.Multiset.toFinset_card_eq_one_iff [DecidableEq α] (s : Multiset α) :
    s.toFinset.card = 1 ↔ Multiset.card s ≠ 0 ∧ ∃ a : α, s = Multiset.card s • {a} 
goal: s.toFinset.card = 1 ↔ Multiset.card s ≠ 0 ∧ ∃ a, s = Multiset.card s • {a}

full_name: Finset.exists_eq_insert_iff
code: theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card 
goal: (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card

full_name: Finset.card_le_one
code: theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b 
goal: s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b

full_name: Finset.card_le_one_iff
code: theorem card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a = b 
goal: s.card ≤ 1 ↔ ∀ {a b : α}, a ∈ s → b ∈ s → a = b

full_name: Finset.card_le_one_iff_subsingleton_coe
code: theorem card_le_one_iff_subsingleton_coe : s.card ≤ 1 ↔ Subsingleton (s : Type _) 
goal: s.card ≤ 1 ↔ Subsingleton { x // x ∈ s }

full_name: Finset.card_le_one_iff_subset_singleton
code: theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} 
goal: s.card ≤ 1 ↔ ∃ x, s ⊆ {x}

full_name: Finset.exists_mem_ne
code: lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a 
goal: ∃ b ∈ s, b ≠ a

full_name: Finset.card_le_one_of_subsingleton
code: /-- A `Finset` of a subsingleton type has cardinality at most one. -/
theorem card_le_one_of_subsingleton [Subsingleton α] (s : Finset α) : s.card ≤ 1 
goal: s.card ≤ 1

full_name: Finset.one_lt_card
code: theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b 
goal: 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b

full_name: Finset.one_lt_card_iff
code: theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b 
goal: 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b

full_name: Finset.one_lt_card_iff_nontrivial
code: theorem one_lt_card_iff_nontrivial : 1 < s.card ↔ s.Nontrivial 
goal: 1 < s.card ↔ s.Nontrivial

full_name: Finset.exists_ne_of_one_lt_card
code: theorem exists_ne_of_one_lt_card (hs : 1 < s.card) (a : α) : ∃ b, b ∈ s ∧ b ≠ a 
goal: ∃ b ∈ s, b ≠ a

full_name: Finset.exists_of_one_lt_card_pi
code: /-- 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. -/
lemma exists_of_one_lt_card_pi {ι : Type*} {α : ι → Type*} [∀ i, DecidableEq (α i)]
    {s : Finset (∀ i, α i)} (h : 1 < s.card) :
    ∃ i, 1 < (s.image (· i)).card ∧ ∀ ai, s.filter (· i = ai) ⊂ s 
goal: ∃ i, 1 < (Finset.image (fun x => x i) s).card ∧ ∀ (ai : α i), Finset.filter (fun x => x i = ai) s ⊂ s

full_name: Finset.card_eq_succ
code: theorem card_eq_succ : s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n 
goal: s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n

full_name: Finset.card_eq_two
code: theorem card_eq_two : s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} 
goal: s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y}

full_name: Finset.card_eq_three
code: theorem card_eq_three : s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} 
goal: s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z}

full_name: Finset.two_lt_card_iff
code: theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c 
goal: 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c

full_name: Finset.two_lt_card
code: theorem two_lt_card : 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c 
goal: 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c

full_name: Finset.strongInduction
code: /-- 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. -/
def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s) :
    ∀ s : Finset α, p s
  
goal: p s

full_name: Finset.strongInduction_eq
code: @[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongInduction_eq {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s)
    (s : Finset α) : strongInduction H s = H s fun t _ => strongInduction H t 
goal: Finset.strongInduction H s = H s fun t x => Finset.strongInduction H t

full_name: Finset.strongInductionOn
code: /-- Analogue of `strongInduction` with order of arguments swapped. -/
@[elab_as_elim]
def strongInductionOn {p : Finset α → Sort*} (s : Finset α) :
    (∀ s, (∀ t ⊂ s, p t) → p s) → p s 
goal: ((s : Finset α) → ((t : Finset α) → t ⊂ s → p t) → p s) → p s

full_name: Finset.strongInductionOn_eq
code: @[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
    (H : ∀ s, (∀ t ⊂ s, p t) → p s) :
    s.strongInductionOn H = H s fun t _ => t.strongInductionOn H 
goal: s.strongInductionOn H = H s fun t x => t.strongInductionOn H

full_name: Finset.case_strong_induction_on
code: @[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
    (h₁ : ∀ a s, a ∉ s → (∀ t ⊆ s, p t) → p (insert a s)) : p s 
goal: p s

full_name: Finset.Nonempty.strong_induction
code: /-- 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. -/
@[elab_as_elim]
protected lemma Nonempty.strong_induction {p : ∀ s, s.Nonempty → Prop}
    (h₀ : ∀ a, p {a} (singleton_nonempty _))
    (h₁ : ∀ ⦃s⦄ (hs : s.Nontrivial), (∀ t ht, t ⊂ s → p t ht) → p s hs.nonempty) :
    ∀ ⦃s : Finset α⦄ (hs), p s hs
  
goal: p s hs

full_name: Finset.strongDownwardInduction
code: /-- 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. -/
def strongDownwardInduction {p : Finset α → Sort*} {n : ℕ}
    (H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
    ∀ s : Finset α, s.card ≤ n → p s
  
goal: s.card ≤ n → p s

full_name: Finset.strongDownwardInduction_eq
code: @[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongDownwardInduction_eq {p : Finset α → Sort*}
    (H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁)
    (s : Finset α) :
    strongDownwardInduction H s = H s fun {t} ht _ => strongDownwardInduction H t ht 
goal: Finset.strongDownwardInduction H s = H s fun {t} ht x => Finset.strongDownwardInduction H t ht

full_name: Finset.strongDownwardInductionOn
code: /-- Analogue of `strongDownwardInduction` with order of arguments swapped. -/
@[elab_as_elim]
def strongDownwardInductionOn {p : Finset α → Sort*} (s : Finset α)
    (H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
    s.card ≤ n → p s 
goal: s.card ≤ n → p s

full_name: Finset.strongDownwardInductionOn_eq
code: @[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongDownwardInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
    (H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
    s.strongDownwardInductionOn H = H s fun {t} ht _ => t.strongDownwardInductionOn H ht 
goal: (fun a => s.strongDownwardInductionOn H a) = H s fun {t} ht x => t.strongDownwardInductionOn H ht

full_name: Finset.lt_wf
code: theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) 
goal: WellFounded LT.lt