Theorem: Finpartition.equitabilise_aux
File: Mathlib/Combinatorics/SimpleGraph/Regularity/Equitabilise.lean

tactic: obtain rfl | m_pos := m.eq_zero_or_pos
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case inl
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = 0 ∨ x.card = 0 + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ 0) ∧
        (filter (fun i => i.card = 0 + 1) Q.parts).card = b

case inr
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
m_pos : m > 0
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: induction' s using Finset.strongInduction with s ih generalizing a b
state_before: case inr
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
m_pos : m > 0
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case inr.H
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: by_cases hab : a = 0 ∧ b = 0
state_before: case inr.H
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : a = 0 ∧ b = 0
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : ¬(a = 0 ∧ b = 0)
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: simp_rw [not_and_or, ← Ne.eq_def, ← pos_iff_ne_zero] at hab
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : ¬(a = 0 ∧ b = 0)
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: set n := if 0 < a then m else m + 1 with hn
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: by_cases h : ∀ u ∈ P.parts, card u < m + 1
state_before: case neg.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ¬∀ u ∈ P.parts, u.card < m + 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: push_neg at h
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ¬∀ u ∈ P.parts, u.card < m + 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∃ u ∈ P.parts, m + 1 ≤ u.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: obtain ⟨u, hu₁, hu₂⟩ := h
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∃ u ∈ P.parts, m + 1 ≤ u.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: obtain ⟨t, htu, htn⟩ := exists_subset_card_eq (hn₁.trans hu₂)
state_before: case neg.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: have ht : t.Nonempty := by rwa [← card_pos, htn]
state_before: case neg.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: have hcard : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \ t).card := by
  rw [card_sdiff (htu.trans <| P.le hu₁), htn, hn₃]
state_before: case neg.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: obtain ⟨R, hR₁, hR₂, hR₃⟩ :=
  @ih (s \ t) (sdiff_ssubset (htu.trans <| P.le hu₁) ht) (if 0 < a then a - 1 else a)
    (if 0 < a then b else b - 1) (P.avoid t) hcard
state_before: case neg.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: refine
  ⟨R.extend ht.ne_empty sdiff_disjoint (sdiff_sup_cancel <| htu.trans <| P.le hu₁), ?_, ?_, ?_⟩
state_before: case neg.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ (R.extend ⋯ ⋯ ⋯).parts, x.card = m ∨ x.card = m + 1

case neg.intro.intro.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) (R.extend ⋯ ⋯ ⋯).parts).biUnion id).card ≤ m

case neg.intro.intro.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (filter (fun i => i.card = m + 1) (R.extend ⋯ ⋯ ⋯).parts).card = b

tactic: simp only [extend_parts, filter_insert, htn, hn, m.succ_ne_self.symm.ite_eq_right_iff]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (filter (fun i => i.card = m + 1) (R.extend ⋯ ⋯ ⋯).parts).card = b
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if ¬0 < a then insert t (filter (fun i => i.card = m + 1) R.parts)
      else filter (fun i => i.card = m + 1) R.parts).card =
    b

tactic: split_ifs with h
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if ¬0 < a then insert t (filter (fun i => i.card = m + 1) R.parts)
      else filter (fun i => i.card = m + 1) R.parts).card =
    b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : 0 < a
⊢ (filter (fun i => i.card = m + 1) R.parts).card = b

case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : ¬0 < a
⊢ (insert t (filter (fun i => i.card = m + 1) R.parts)).card = b

tactic: refine ⟨⊥, by simp, ?_, by simpa [Finset.filter_true_of_mem] using hs.symm⟩
state_before: case inl
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = 0 ∨ x.card = 0 + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ 0) ∧
        (filter (fun i => i.card = 0 + 1) Q.parts).card = b
state_after: case inl
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) ⊥.parts).biUnion id).card ≤ 0

tactic: simp only [le_zero_iff, card_eq_zero, mem_biUnion, exists_prop, mem_filter, id, and_assoc,
  sdiff_eq_empty_iff_subset, subset_iff]
state_before: case inl
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) ⊥.parts).biUnion id).card ≤ 0
state_after: case inl
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∀ x ∈ P.parts, ∀ ⦃x_1 : α⦄, x_1 ∈ x → ∃ a ∈ ⊥.parts, (∀ ⦃x_2 : α⦄, x_2 ∈ a → x_2 ∈ x) ∧ x_1 ∈ a

tactic: exact fun x hx a ha =>
  ⟨{a}, mem_map_of_mem _ (P.le hx ha), singleton_subset_iff.2 ha, mem_singleton_self _⟩
state_before: case inl
α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∀ x ∈ P.parts, ∀ ⦃x_1 : α⦄, x_1 ∈ x → ∃ a ∈ ⊥.parts, (∀ ⦃x_2 : α⦄, x_2 ∈ a → x_2 ∈ x) ∧ x_1 ∈ a
state_after: no goals

tactic: simp
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ ∀ x ∈ ⊥.parts, x.card = 0 ∨ x.card = 0 + 1
state_after: no goals

tactic: simpa [Finset.filter_true_of_mem] using hs.symm
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
n a b : ℕ
P : Finpartition s
hs : a * 0 + b * (0 + 1) = s.card
⊢ (filter (fun i => i.card = 0 + 1) ⊥.parts).card = b
state_after: no goals

tactic: simp only [hab.1, hab.2, add_zero, zero_mul, eq_comm, card_eq_zero, Finset.bot_eq_empty] at hs
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : a = 0 ∧ b = 0
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hab : a = 0 ∧ b = 0
hs : s = ∅
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: subst hs
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hab : a = 0 ∧ b = 0
hs : s = ∅
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: have : P = Finpartition.empty _ := Unique.eq_default (α := Finpartition ⊥) P
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
this : P = Finpartition.empty (Finset α)
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: exact ⟨Finpartition.empty _, by simp, by simp [this], by simp [hab.2]⟩
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
this : P = Finpartition.empty (Finset α)
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: no goals

tactic: simp
state_before: α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
this : P = Finpartition.empty (Finset α)
⊢ ∀ x ∈ (Finpartition.empty (Finset α)).parts, x.card = m ∨ x.card = m + 1
state_after: no goals

tactic: simp [this]
state_before: α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
this : P = Finpartition.empty (Finset α)
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) (Finpartition.empty (Finset α)).parts).biUnion id).card ≤ m
state_after: no goals

tactic: simp [hab.2]
state_before: α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n : ℕ
m_pos : m > 0
a b : ℕ
hab : a = 0 ∧ b = 0
ih :
  ∀ t ⊂ ∅,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
P : Finpartition ∅
this : P = Finpartition.empty (Finset α)
⊢ (filter (fun i => i.card = m + 1) (Finpartition.empty (Finset α)).parts).card = b
state_after: no goals

tactic: rw [hn, ← hs]
state_before: α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
⊢ 0 < n ∧
    n ≤ m + 1 ∧
      n ≤ a * m + b * (m + 1) ∧ (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
state_after: α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
⊢ (0 < if 0 < a then m else m + 1) ∧
    (if 0 < a then m else m + 1) ≤ m + 1 ∧
      (if 0 < a then m else m + 1) ≤ a * m + b * (m + 1) ∧
        (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) =
          a * m + b * (m + 1) - if 0 < a then m else m + 1

tactic: split_ifs with h <;> rw [tsub_mul, one_mul]
state_before: α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
⊢ (0 < if 0 < a then m else m + 1) ∧
    (if 0 < a then m else m + 1) ≤ m + 1 ∧
      (if 0 < a then m else m + 1) ≤ a * m + b * (m + 1) ∧
        (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) =
          a * m + b * (m + 1) - if 0 < a then m else m + 1
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : 0 < a
⊢ 0 < m ∧ m ≤ m + 1 ∧ m ≤ a * m + b * (m + 1) ∧ a * m - m + b * (m + 1) = a * m + b * (m + 1) - m

case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : ¬0 < a
⊢ 0 < m + 1 ∧
    m + 1 ≤ m + 1 ∧ m + 1 ≤ a * m + b * (m + 1) ∧ a * m + (b * (m + 1) - (m + 1)) = a * m + b * (m + 1) - (m + 1)

tactic: refine ⟨m_pos, le_succ _, le_add_right (Nat.le_mul_of_pos_left _ ‹0 < a›), ?_⟩
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : 0 < a
⊢ 0 < m ∧ m ≤ m + 1 ∧ m ≤ a * m + b * (m + 1) ∧ a * m - m + b * (m + 1) = a * m + b * (m + 1) - m
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : 0 < a
⊢ a * m - m + b * (m + 1) = a * m + b * (m + 1) - m

tactic: rw [tsub_add_eq_add_tsub (Nat.le_mul_of_pos_left _ h)]
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : 0 < a
⊢ a * m - m + b * (m + 1) = a * m + b * (m + 1) - m
state_after: no goals

tactic: refine ⟨succ_pos', le_rfl,
  le_add_left (Nat.le_mul_of_pos_left _ <| hab.resolve_left ‹¬0 < a›), ?_⟩
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : ¬0 < a
⊢ 0 < m + 1 ∧
    m + 1 ≤ m + 1 ∧ m + 1 ≤ a * m + b * (m + 1) ∧ a * m + (b * (m + 1) - (m + 1)) = a * m + b * (m + 1) - (m + 1)
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : ¬0 < a
⊢ a * m + (b * (m + 1) - (m + 1)) = a * m + b * (m + 1) - (m + 1)

tactic: rw [← add_tsub_assoc_of_le (Nat.le_mul_of_pos_left _ <| hab.resolve_left ‹¬0 < a›)]
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
h : ¬0 < a
⊢ a * m + (b * (m + 1) - (m + 1)) = a * m + b * (m + 1) - (m + 1)
state_after: no goals

tactic: obtain ⟨t, hts, htn⟩ := exists_subset_card_eq (hn₂.trans_eq hs)
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: have ht : t.Nonempty := by rwa [← card_pos, htn]
state_before: case pos.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: have hcard : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \ t).card := by
  rw [card_sdiff ‹t ⊆ s›, htn, hn₃]
state_before: case pos.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: obtain ⟨R, hR₁, _, hR₃⟩ :=
  @ih (s \ t) (sdiff_ssubset hts ‹t.Nonempty›) (if 0 < a then a - 1 else a)
    (if 0 < a then b else b - 1) (P.avoid t) hcard
state_before: case pos.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos.intro.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b

tactic: refine ⟨R.extend ht.ne_empty sdiff_disjoint (sdiff_sup_cancel hts), ?_, ?_, ?_⟩
state_before: case pos.intro.intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∃ Q,
    (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
      (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
        (filter (fun i => i.card = m + 1) Q.parts).card = b
state_after: case pos.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ (R.extend ⋯ ⋯ ⋯).parts, x.card = m ∨ x.card = m + 1

case pos.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) (R.extend ⋯ ⋯ ⋯).parts).biUnion id).card ≤ m

case pos.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (filter (fun i => i.card = m + 1) (R.extend ⋯ ⋯ ⋯).parts).card = b

tactic: simp_rw [extend_parts, filter_insert, htn, m.succ_ne_self.symm.ite_eq_right_iff]
state_before: case pos.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (filter (fun i => i.card = m + 1) (R.extend ⋯ ⋯ ⋯).parts).card = b
state_after: case pos.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if ¬0 < a then insert t (filter (fun i => i.card = m + 1) R.parts)
      else filter (fun i => i.card = m + 1) R.parts).card =
    b

tactic: split_ifs with ha
state_before: case pos.intro.intro.intro.intro.intro.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if ¬0 < a then insert t (filter (fun i => i.card = m + 1) R.parts)
      else filter (fun i => i.card = m + 1) R.parts).card =
    b
state_after: case pos
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : 0 < a
⊢ (filter (fun i => i.card = m + 1) R.parts).card = b

case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
⊢ (insert t (filter (fun i => i.card = m + 1) R.parts)).card = b

tactic: rw [card_insert_of_not_mem, hR₃, if_neg ha, tsub_add_cancel_of_le]
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
⊢ (insert t (filter (fun i => i.card = m + 1) R.parts)).card = b
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
⊢ 1 ≤ b

case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
⊢ t ∉ filter (fun i => i.card = m + 1) R.parts

tactic: rwa [← card_pos, htn]
state_before: α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
⊢ t.Nonempty
state_after: no goals

tactic: rw [card_sdiff ‹t ⊆ s›, htn, hn₃]
state_before: α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
⊢ (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
state_after: no goals

tactic: simp only [extend_parts, mem_insert, forall_eq_or_imp, and_iff_left hR₁, htn, hn]
state_before: case pos.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ (R.extend ⋯ ⋯ ⋯).parts, x.card = m ∨ x.card = m + 1
state_after: case pos.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if 0 < a then m else m + 1) = m ∨ (if 0 < a then m else m + 1) = m + 1

tactic: exact ite_eq_or_eq _ _ _
state_before: case pos.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if 0 < a then m else m + 1) = m ∨ (if 0 < a then m else m + 1) = m + 1
state_after: no goals

tactic: exact fun x hx => (card_le_card sdiff_subset).trans (Nat.lt_succ_iff.1 <| h _ hx)
state_before: case pos.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) (R.extend ⋯ ⋯ ⋯).parts).biUnion id).card ≤ m
state_after: no goals

tactic: rw [hR₃, if_pos ha]
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : 0 < a
⊢ (filter (fun i => i.card = m + 1) R.parts).card = b
state_after: no goals

tactic: exact hab.resolve_left ha
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
⊢ 1 ≤ b
state_after: no goals

tactic: intro H
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
⊢ t ∉ filter (fun i => i.card = m + 1) R.parts
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
H : t ∈ filter (fun i => i.card = m + 1) R.parts
⊢ False

tactic: exact ht.ne_empty (le_sdiff_iff.1 <| R.le <| filter_subset _ _ H)
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
h : ∀ u ∈ P.parts, u.card < m + 1
t : Finset α
hts : t ⊆ s
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
left✝ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
ha : ¬0 < a
H : t ∈ filter (fun i => i.card = m + 1) R.parts
⊢ False
state_after: no goals

tactic: rwa [← card_pos, htn]
state_before: α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
⊢ t.Nonempty
state_after: no goals

tactic: rw [card_sdiff (htu.trans <| P.le hu₁), htn, hn₃]
state_before: α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
⊢ (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
state_after: no goals

tactic: simp only [mem_insert, forall_eq_or_imp, extend_parts, and_iff_left hR₁, htn, hn]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ (R.extend ⋯ ⋯ ⋯).parts, x.card = m ∨ x.card = m + 1
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if 0 < a then m else m + 1) = m ∨ (if 0 < a then m else m + 1) = m + 1

tactic: exact ite_eq_or_eq _ _ _
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (if 0 < a then m else m + 1) = m ∨ (if 0 < a then m else m + 1) = m + 1
state_after: no goals

tactic: conv in _ ∈ _ => rw [← insert_erase hu₁]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) (R.extend ⋯ ⋯ ⋯).parts).biUnion id).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ insert u (P.parts.erase u), (x \ (filter (fun y => y ⊆ x) (R.extend ⋯ ⋯ ⋯).parts).biUnion id).card ≤ m

tactic: simp only [and_imp, mem_insert, forall_eq_or_imp, Ne, extend_parts]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∀ x ∈ insert u (P.parts.erase u), (x \ (filter (fun y => y ⊆ x) (R.extend ⋯ ⋯ ⋯).parts).biUnion id).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (filter (fun y => y ⊆ u) (insert t R.parts)).biUnion id).card ≤ m ∧
    ∀ a ∈ P.parts.erase u, (a \ (filter (fun y => y ⊆ a) (insert t R.parts)).biUnion id).card ≤ m

tactic: refine ⟨?_, fun x hx => (card_le_card ?_).trans <| hR₂ x ?_⟩
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (filter (fun y => y ⊆ u) (insert t R.parts)).biUnion id).card ≤ m ∧
    ∀ a ∈ P.parts.erase u, (a \ (filter (fun y => y ⊆ a) (insert t R.parts)).biUnion id).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (filter (fun y => y ⊆ u) (insert t R.parts)).biUnion id).card ≤ m

case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ x \ (filter (fun y => y ⊆ x) (insert t R.parts)).biUnion id ⊆ x \ (filter (fun y => y ⊆ x) R.parts).biUnion id

case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ x ∈ (P.avoid t).parts

tactic: simp only [avoid, ofErase, mem_erase, mem_image, bot_eq_empty]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ x ∈ (P.avoid t).parts
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ x ≠ ∅ ∧ ∃ a ∈ P.parts, a \ t = x

tactic: exact
  ⟨(nonempty_of_mem_parts _ <| mem_of_mem_erase hx).ne_empty, _, mem_of_mem_erase hx,
    (disjoint_of_subset_right htu <|
        P.disjoint (mem_of_mem_erase hx) hu₁ <| ne_of_mem_erase hx).sdiff_eq_left⟩
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_3
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ x ≠ ∅ ∧ ∃ a ∈ P.parts, a \ t = x
state_after: no goals

tactic: simp only [filter_insert, if_pos htu, biUnion_insert, mem_erase, id]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (filter (fun y => y ⊆ u) (insert t R.parts)).biUnion id).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (t ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id)).card ≤ m

tactic: obtain rfl | hut := eq_or_ne u t
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (t ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id)).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inl
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
htu : u ⊆ u
htn : u.card = n
ht : u.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ u).card
R : Finpartition (s \ u)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid u).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (u ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id)).card ≤ m

case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inr
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
hut : u ≠ t
⊢ (u \ (t ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id)).card ≤ m

tactic: refine
  (card_le_card fun i => ?_).trans
    (hR₂ (u \ t) <| P.mem_avoid.2 ⟨u, hu₁, fun i => hut <| i.antisymm htu, rfl⟩)
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inr
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
hut : u ≠ t
⊢ (u \ (t ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id)).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inr
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
hut : u ≠ t
i : α
⊢ i ∈ u \ (t ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id) →
    i ∈ (u \ t) \ (filter (fun y => y ⊆ u \ t) R.parts).biUnion id

tactic: simp only [not_exists, not_and, mem_biUnion, and_imp, mem_union, mem_filter, mem_sdiff,
  id, not_or]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inr
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
hut : u ≠ t
i : α
⊢ i ∈ u \ (t ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id) →
    i ∈ (u \ t) \ (filter (fun y => y ⊆ u \ t) R.parts).biUnion id
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inr
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
hut : u ≠ t
i : α
⊢ i ∈ u → i ∉ t → (∀ x ∈ R.parts, x ⊆ u → i ∉ x) → (i ∈ u ∧ i ∉ t) ∧ ∀ x ∈ R.parts, x ⊆ u \ t → i ∉ x

tactic: exact fun hi₁ hi₂ hi₃ =>
  ⟨⟨hi₁, hi₂⟩, fun x hx hx' => hi₃ _ hx <| hx'.trans sdiff_subset⟩
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inr
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
hut : u ≠ t
i : α
⊢ i ∈ u → i ∉ t → (∀ x ∈ R.parts, x ⊆ u → i ∉ x) → (i ∈ u ∧ i ∉ t) ∧ ∀ x ∈ R.parts, x ⊆ u \ t → i ∉ x
state_after: no goals

tactic: rw [sdiff_eq_empty_iff_subset.2 subset_union_left]
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inl
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
htu : u ⊆ u
htn : u.card = n
ht : u.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ u).card
R : Finpartition (s \ u)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid u).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ (u \ (u ∪ (filter (fun y => y ⊆ u) R.parts).biUnion id)).card ≤ m
state_after: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inl
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
htu : u ⊆ u
htn : u.card = n
ht : u.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ u).card
R : Finpartition (s \ u)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid u).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∅.card ≤ m

tactic: exact bot_le
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_1.inl
α : Type u_1
inst✝ : DecidableEq α
t : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
htu : u ⊆ u
htn : u.card = n
ht : u.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ u).card
R : Finpartition (s \ u)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid u).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
⊢ ∅.card ≤ m
state_after: no goals

tactic: apply sdiff_subset_sdiff Subset.rfl (biUnion_subset_biUnion_of_subset_left _ _)
state_before: case neg.intro.intro.intro.intro.intro.intro.intro.refine_2.refine_2
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ x \ (filter (fun y => y ⊆ x) (insert t R.parts)).biUnion id ⊆ x \ (filter (fun y => y ⊆ x) R.parts).biUnion id
state_after: α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ filter (fun y => y ⊆ x) R.parts ⊆ filter (fun y => y ⊆ x) (insert t R.parts)

tactic: exact filter_subset_filter _ (subset_insert _ _)
state_before: α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
x : Finset α
hx : x ∈ P.parts.erase u
⊢ filter (fun y => y ⊆ x) R.parts ⊆ filter (fun y => y ⊆ x) (insert t R.parts)
state_after: no goals

tactic: rw [hR₃, if_pos h]
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : 0 < a
⊢ (filter (fun i => i.card = m + 1) R.parts).card = b
state_after: no goals

tactic: rw [card_insert_of_not_mem, hR₃, if_neg h, Nat.sub_add_cancel (hab.resolve_left h)]
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : ¬0 < a
⊢ (insert t (filter (fun i => i.card = m + 1) R.parts)).card = b
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : ¬0 < a
⊢ t ∉ filter (fun i => i.card = m + 1) R.parts

tactic: intro H
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : ¬0 < a
⊢ t ∉ filter (fun i => i.card = m + 1) R.parts
state_after: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : ¬0 < a
H : t ∈ filter (fun i => i.card = m + 1) R.parts
⊢ False

tactic: exact ht.ne_empty (le_sdiff_iff.1 <| R.le <| filter_subset _ _ H)
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
t✝ : Finset α
m n✝ : ℕ
m_pos : m > 0
s : Finset α
ih :
  ∀ t ⊂ s,
    ∀ {a b : ℕ} {P : Finpartition t},
      a * m + b * (m + 1) = t.card →
        ∃ Q,
          (∀ x ∈ Q.parts, x.card = m ∨ x.card = m + 1) ∧
            (∀ x ∈ P.parts, (x \ (filter (fun y => y ⊆ x) Q.parts).biUnion id).card ≤ m) ∧
              (filter (fun i => i.card = m + 1) Q.parts).card = b
a b : ℕ
P : Finpartition s
hs : a * m + b * (m + 1) = s.card
hab : 0 < a ∨ 0 < b
n : ℕ := if 0 < a then m else m + 1
hn : n = if 0 < a then m else m + 1
hn₀ : 0 < n
hn₁ : n ≤ m + 1
hn₂ : n ≤ a * m + b * (m + 1)
hn₃ : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = s.card - n
u : Finset α
hu₁ : u ∈ P.parts
hu₂ : m + 1 ≤ u.card
t : Finset α
htu : t ⊆ u
htn : t.card = n
ht : t.Nonempty
hcard : (if 0 < a then a - 1 else a) * m + (if 0 < a then b else b - 1) * (m + 1) = (s \ t).card
R : Finpartition (s \ t)
hR₁ : ∀ x ∈ R.parts, x.card = m ∨ x.card = m + 1
hR₂ : ∀ x ∈ (P.avoid t).parts, (x \ (filter (fun y => y ⊆ x) R.parts).biUnion id).card ≤ m
hR₃ : (filter (fun i => i.card = m + 1) R.parts).card = if 0 < a then b else b - 1
h : ¬0 < a
H : t ∈ filter (fun i => i.card = m + 1) R.parts
⊢ False
state_after: no goals