l3lab/ntp-mathlib huggingface dataset:
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
inside it. -/
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 := by
  classical
    rcases Nat.le.dest h₁ with ⟨k, h⟩
    clear h₁
    induction' k with k ih generalizing A
    · exact ⟨A, h₂, Subset.refl _, h.symm⟩
    obtain ⟨a, ha⟩ : (A \ B).Nonempty := by
      rw [← card_pos, card_sdiff h₂, ← h, Nat.add_right_comm, add_tsub_cancel_right, Nat.add_succ]
      apply Nat.succ_pos
    have z : i + card B + k = card (erase A a) := by
      rw [card_erase_of_mem (mem_sdiff.1 ha).1, ← h,
        Nat.add_sub_assoc (Nat.one_le_iff_ne_zero.mpr k.succ_ne_zero), ← pred_eq_sub_one,
        k.pred_succ]
    have : B ⊆ A.erase a := by
      rintro t th
      apply mem_erase_of_ne_of_mem _ (h₂ th)
      rintro rfl
      exact not_mem_sdiff_of_mem_right th ha
    rcases ih this z with ⟨B', hB', B'subA', cards⟩
    

Proof state:
case intro.succ.intro.intro.intro.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
B : Finset α
i k : ℕ
ih : ∀ {A : Finset α}, B ⊆ A → i + card B + k = card A → ∃ C, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B
A : Finset α
h₂ : B ⊆ A
h : i + card B + succ k = card A
a : α
ha : a ∈ A \ B
z : i + card B + k = card (erase A a)
this : B ⊆ erase A a
B' : Finset α
hB' : B ⊆ B'
B'subA' : B' ⊆ erase A a
cards : card B' = i + card B
⊢ ∃ C, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B

Next tactic:
exact ⟨B', hB', B'subA'.trans (erase_subset _ _), cards⟩
/-- We can shrink `A` to any smaller size. -/
theorem exists_smaller_set (A : Finset α) (i : ℕ) (h₁ : i ≤ card A) :
    ∃ B : Finset α, B ⊆ A ∧ card B = i :=
  let ⟨B, _, x₁, x₂⟩ := exists_intermediate_set i (by 

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
A : Finset α
i : ℕ
h₁ : i ≤ card A
⊢ i + card ∅ ≤ card A

Next tactic:
simpa
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) := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : 2 * n < card (X ∪ Y)
⊢ ∃ C, n < card C ∧ (C ⊆ X ∨ C ⊆ Y)

Next tactic:
have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
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) := by
  have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : 2 * n < card (X ∪ Y)
h₁ : card (X ∩ (Y \ X)) = 0
⊢ ∃ C, n < card C ∧ (C ⊆ X ∨ C ⊆ Y)

Next tactic:
have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
    rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
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) := by
  have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
  have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
    

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : 2 * n < card (X ∪ Y)
h₁ : card (X ∩ (Y \ X)) = 0
⊢ card (X ∪ Y) = card X + card (Y \ X)

Next tactic:
rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
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) := by
  have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
  have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
    rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : 2 * n < card (X ∪ Y)
h₁ : card (X ∩ (Y \ X)) = 0
h₂ : card (X ∪ Y) = card X + card (Y \ X)
⊢ ∃ C, n < card C ∧ (C ⊆ X ∨ C ⊆ Y)

Next tactic:
rw [h₂, two_mul] at hXY
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) := by
  have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
  have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
    rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
  rw [h₂, two_mul] at hXY
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : n + n < card X + card (Y \ X)
h₁ : card (X ∩ (Y \ X)) = 0
h₂ : card (X ∪ Y) = card X + card (Y \ X)
⊢ ∃ C, n < card C ∧ (C ⊆ X ∨ C ⊆ Y)

Next tactic:
rcases lt_or_lt_of_add_lt_add hXY with (h | h)
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) := by
  have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
  have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
    rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
  rw [h₂, two_mul] at hXY
  rcases lt_or_lt_of_add_lt_add hXY with (h | h)
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : n + n < card X + card (Y \ X)
h₁ : card (X ∩ (Y \ X)) = 0
h₂ : card (X ∪ Y) = card X + card (Y \ X)
h : n < card X
⊢ ∃ C, n < card C ∧ (C ⊆ X ∨ C ⊆ Y)

Next tactic:
exact ⟨X, h, Or.inl (Finset.Subset.refl X)⟩
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) := by
  have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
  have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
    rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
  rw [h₂, two_mul] at hXY
  rcases lt_or_lt_of_add_lt_add hXY with (h | h)
  · exact ⟨X, h, Or.inl (Finset.Subset.refl X)⟩
  · 

Proof state:
case inr
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n✝ : ℕ
inst✝ : DecidableEq α
X Y : Finset α
n : ℕ
hXY : n + n < card X + card (Y \ X)
h₁ : card (X ∩ (Y \ X)) = 0
h₂ : card (X ∪ Y) = card X + card (Y \ X)
h : n < card (Y \ X)
⊢ ∃ C, n < card C ∧ (C ⊆ X ∨ C ⊆ Y)

Next tactic:
exact ⟨Y \ X, h, Or.inr (Finset.sdiff_subset Y X)⟩
theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ card s = 1 ↔ ∃ a, s = {a}

Next tactic:
cases s
theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
  cases s
  

Proof state:
case mk
α : Type u_1
β : Type u_2
t : Finset α
f : α → β
n : ℕ
val✝ : Multiset α
nodup✝ : Nodup val✝
⊢ card { val := val✝, nodup := nodup✝ } = 1 ↔ ∃ a, { val := val✝, nodup := nodup✝ } = {a}

Next tactic:
simp only [Multiset.card_eq_one, Finset.card, ← val_inj, singleton_val]
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  

Proof state:
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
⊢ (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ card s + 1 = card t

Next tactic:
constructor
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
⊢ (∃ a ∉ s, insert a s = t) → s ⊆ t ∧ card s + 1 = card t

Next tactic:
rintro ⟨a, ha, rfl⟩
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    

Proof state:
case mp.intro.intro
α : Type u_1
β : Type u_2
s✝ t : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s : Finset α
a : α
ha : a ∉ s
⊢ s ⊆ insert a s ∧ card s + 1 = card (insert a s)

Next tactic:
exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · 

Proof state:
case mpr
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
⊢ s ⊆ t ∧ card s + 1 = card t → ∃ a ∉ s, insert a s = t

Next tactic:
rintro ⟨hst, h⟩
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · rintro ⟨hst, h⟩
    

Proof state:
case mpr.intro
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
hst : s ⊆ t
h : card s + 1 = card t
⊢ ∃ a ∉ s, insert a s = t

Next tactic:
obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
      card_eq_one.1 (by rw [card_sdiff hst, ← h, add_tsub_cancel_left])
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · rintro ⟨hst, h⟩
    obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
      card_eq_one.1 (by 

Proof state:
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
hst : s ⊆ t
h : card s + 1 = card t
⊢ card (t \ s) = 1

Next tactic:
rw [card_sdiff hst, ← h, add_tsub_cancel_left]
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · rintro ⟨hst, h⟩
    obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
      card_eq_one.1 (by rw [card_sdiff hst, ← h, add_tsub_cancel_left])
    

Proof state:
case mpr.intro.intro
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
hst : s ⊆ t
h : card s + 1 = card t
a : α
ha : t \ s = {a}
⊢ ∃ a ∉ s, insert a s = t

Next tactic:
refine'
      ⟨a, fun hs => (_ : a ∉ {a}) <| mem_singleton_self _, by
        rw [insert_eq, ← ha, sdiff_union_of_subset hst]⟩
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · rintro ⟨hst, h⟩
    obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
      card_eq_one.1 (by rw [card_sdiff hst, ← h, add_tsub_cancel_left])
    refine'
      ⟨a, fun hs => (_ : a ∉ {a}) <| mem_singleton_self _, by
        

Proof state:
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
hst : s ⊆ t
h : card s + 1 = card t
a : α
ha : t \ s = {a}
⊢ insert a s = t

Next tactic:
rw [insert_eq, ← ha, sdiff_union_of_subset hst]
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · rintro ⟨hst, h⟩
    obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
      card_eq_one.1 (by rw [card_sdiff hst, ← h, add_tsub_cancel_left])
    refine'
      ⟨a, fun hs => (_ : a ∉ {a}) <| mem_singleton_self _, by
        rw [insert_eq, ← ha, sdiff_union_of_subset hst]⟩
    

Proof state:
case mpr.intro.intro
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
hst : s ⊆ t
h : card s + 1 = card t
a : α
ha : t \ s = {a}
hs : a ∈ s
⊢ a ∉ {a}

Next tactic:
rw [← ha]
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
    (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
  constructor
  · rintro ⟨a, ha, rfl⟩
    exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
  · rintro ⟨hst, h⟩
    obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
      card_eq_one.1 (by rw [card_sdiff hst, ← h, add_tsub_cancel_left])
    refine'
      ⟨a, fun hs => (_ : a ∉ {a}) <| mem_singleton_self _, by
        rw [insert_eq, ← ha, sdiff_union_of_subset hst]⟩
    rw [← ha]
    

Proof state:
case mpr.intro.intro
α : Type u_1
β : Type u_2
s✝ t✝ : Finset α
f : α → β
n : ℕ
inst✝ : DecidableEq α
s t : Finset α
hst : s ⊆ t
h : card s + 1 = card t
a : α
ha : t \ s = {a}
hs : a ∈ s
⊢ a ∉ t \ s

Next tactic:
exact not_mem_sdiff_of_mem_right hs
theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ card s ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b

Next tactic:
obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b := by
  obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
t : Finset α
f : α → β
n : ℕ
⊢ card ∅ ≤ 1 ↔ ∀ a ∈ ∅, ∀ b ∈ ∅, a = b

Next tactic:
simp
theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b := by
  obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
  · simp
  

Proof state:
case inr.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
x : α
hx : x ∈ s
⊢ card s ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b

Next tactic:
refine' (Nat.succ_le_of_lt (card_pos.2 ⟨x, hx⟩)).le_iff_eq.trans (card_eq_one.trans ⟨_, _⟩)
theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b := by
  obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
  · simp
  refine' (Nat.succ_le_of_lt (card_pos.2 ⟨x, hx⟩)).le_iff_eq.trans (card_eq_one.trans ⟨_, _⟩)
  · 

Proof state:
case inr.intro.refine'_1
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
x : α
hx : x ∈ s
⊢ (∃ a, s = {a}) → ∀ a ∈ s, ∀ b ∈ s, a = b

Next tactic:
rintro ⟨y, rfl⟩
theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b := by
  obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
  · simp
  refine' (Nat.succ_le_of_lt (card_pos.2 ⟨x, hx⟩)).le_iff_eq.trans (card_eq_one.trans ⟨_, _⟩)
  · rintro ⟨y, rfl⟩
    

Proof state:
case inr.intro.refine'_1.intro
α : Type u_1
β : Type u_2
t : Finset α
f : α → β
n : ℕ
x y : α
hx : x ∈ {y}
⊢ ∀ a ∈ {y}, ∀ b ∈ {y}, a = b

Next tactic:
simp
theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b := by
  obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
  · simp
  refine' (Nat.succ_le_of_lt (card_pos.2 ⟨x, hx⟩)).le_iff_eq.trans (card_eq_one.trans ⟨_, _⟩)
  · rintro ⟨y, rfl⟩
    simp
  · 

Proof state:
case inr.intro.refine'_2
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
x : α
hx : x ∈ s
⊢ (∀ a ∈ s, ∀ b ∈ s, a = b) → ∃ a, s = {a}

Next tactic:
exact fun h => ⟨x, eq_singleton_iff_unique_mem.2 ⟨hx, fun y hy => h _ hy _ hx⟩⟩
theorem card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a = b := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ card s ≤ 1 ↔ ∀ {a b : α}, a ∈ s → b ∈ s → a = b

Next tactic:
rw [card_le_one]
theorem card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a = b := by
  rw [card_le_one]
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ (∀ a ∈ s, ∀ b ∈ s, a = b) ↔ ∀ {a b : α}, a ∈ s → b ∈ s → a = b

Next tactic:
tauto
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
⊢ card s ≤ 1 ↔ ∃ x, s ⊆ {x}

Next tactic:
refine' ⟨fun H => _, _⟩
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
H : card s ≤ 1
⊢ ∃ x, s ⊆ {x}

Next tactic:
obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
    · 

Proof state:
case refine'_1.inl
α : Type u_1
β : Type u_2
t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
H : card ∅ ≤ 1
⊢ ∃ x, ∅ ⊆ {x}

Next tactic:
exact ⟨Classical.arbitrary α, empty_subset _⟩
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
    · exact ⟨Classical.arbitrary α, empty_subset _⟩
    · 

Proof state:
case refine'_1.inr.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
H : card s ≤ 1
x : α
hx : x ∈ s
⊢ ∃ x, s ⊆ {x}

Next tactic:
exact ⟨x, fun y hy => by rw [card_le_one.1 H y hy x hx, mem_singleton]⟩
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
    · exact ⟨Classical.arbitrary α, empty_subset _⟩
    · exact ⟨x, fun y hy => by 

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
H : card s ≤ 1
x : α
hx : x ∈ s
y : α
hy : y ∈ s
⊢ y ∈ {x}

Next tactic:
rw [card_le_one.1 H y hy x hx, mem_singleton]
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
    · exact ⟨Classical.arbitrary α, empty_subset _⟩
    · exact ⟨x, fun y hy => by rw [card_le_one.1 H y hy x hx, mem_singleton]⟩
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
⊢ (∃ x, s ⊆ {x}) → card s ≤ 1

Next tactic:
rintro ⟨x, hx⟩
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
    · exact ⟨Classical.arbitrary α, empty_subset _⟩
    · exact ⟨x, fun y hy => by rw [card_le_one.1 H y hy x hx, mem_singleton]⟩
  · rintro ⟨x, hx⟩
    

Proof state:
case refine'_2.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
x : α
hx : s ⊆ {x}
⊢ card s ≤ 1

Next tactic:
rw [← card_singleton x]
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
  refine' ⟨fun H => _, _⟩
  · obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
    · exact ⟨Classical.arbitrary α, empty_subset _⟩
    · exact ⟨x, fun y hy => by rw [card_le_one.1 H y hy x hx, mem_singleton]⟩
  · rintro ⟨x, hx⟩
    rw [← card_singleton x]
    

Proof state:
case refine'_2.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
inst✝ : Nonempty α
x : α
hx : s ⊆ {x}
⊢ card s ≤ card {x}

Next tactic:
exact card_le_of_subset hx
lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
hs : 1 < card s
a : α
⊢ ∃ b ∈ s, b ≠ a

Next tactic:
have : Nonempty α := ⟨a⟩
lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a := by
  have : Nonempty α := ⟨a⟩
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
hs : 1 < card s
a : α
this : Nonempty α
⊢ ∃ b ∈ s, b ≠ a

Next tactic:
by_contra!
lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a := by
  have : Nonempty α := ⟨a⟩
  by_contra!
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
hs : 1 < card s
a : α
this✝ : Nonempty α
this : ∀ b ∈ s, b = a
⊢ False

Next tactic:
exact hs.not_le (card_le_one_iff_subset_singleton.2 ⟨a, subset_singleton_iff'.2 this⟩)
theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ 1 < card s ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b

Next tactic:
rw [← not_iff_not]
theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by
  rw [← not_iff_not]
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ ¬1 < card s ↔ ¬∃ a ∈ s, ∃ b ∈ s, a ≠ b

Next tactic:
push_neg
theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by
  rw [← not_iff_not]
  push_neg
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ card s ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b

Next tactic:
exact card_le_one
theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ 1 < card s ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b

Next tactic:
rw [one_lt_card]
theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by
  rw [one_lt_card]
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ (∃ a ∈ s, ∃ b ∈ s, a ≠ b) ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b

Next tactic:
simp only [exists_prop, exists_and_left]
theorem one_lt_card_iff_nontrivial_coe : 1 < s.card ↔ Nontrivial (s : Type _) := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ 1 < card s ↔ Nontrivial { x // x ∈ s }

Next tactic:
rw [← not_iff_not, not_lt, not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe]
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
  

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ 2 < card s ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c

Next tactic:
classical
    refine' ⟨fun h => _, _⟩
    · obtain ⟨c, hc⟩ := card_pos.mp (pos_of_gt h)
      have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
      obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this
      exact
        ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc, hab, ne_of_mem_erase ha,
          ne_of_mem_erase hb⟩
    · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
      rw [← card_erase_add_one hc, ← card_erase_add_one (mem_erase_of_ne_of_mem hbc hb), ←
        card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))]
      apply Nat.le_add_left
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
  classical
    

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
⊢ 2 < card s ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c

Next tactic:
refine' ⟨fun h => _, _⟩
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
  classical
    refine' ⟨fun h => _, _⟩
    · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
h : 2 < card s
⊢ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c

Next tactic:
obtain ⟨c, hc⟩ := card_pos.mp (pos_of_gt h)
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
  classical
    refine' ⟨fun h => _, _⟩
    · obtain ⟨c, hc⟩ := card_pos.mp (pos_of_gt h)
      

Proof state:
case refine'_1.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
h : 2 < card s
c : α
hc : c ∈ s
⊢ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c

Next tactic:
have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
  classical
    refine' ⟨fun h => _, _⟩
    · obtain ⟨c, hc⟩ := card_pos.mp (pos_of_gt h)
      have : 1 < (s.erase c).card := by 

Proof state:
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
h : 2 < card s
c : α
hc : c ∈ s
⊢ 1 < card (erase s c)

Next tactic:
rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
  classical
    refine' ⟨fun h => _, _⟩
    · obtain ⟨c, hc⟩ := card_pos.mp (pos_of_gt h)
      have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
      

Proof state:
case refine'_1.intro
α : Type u_1
β : Type u_2
s t : Finset α
f : α → β
n : ℕ
h : 2 < card s
c : α
hc : c ∈ s
this : 1 < card (erase s c)
⊢ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c

Next tactic:
obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this