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

Proof steps:
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: obtain rfl | m_pos := m.eq_zero_or_pos
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: induction' s using Finset.strongInduction with s ih generalizing a b
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: by_cases hab : a = 0 ∧ b = 0
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: 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 : 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: set n := if 0 < a then m else m + 1 with hn
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: by_cases h : ∀ u ∈ P.parts, card u < m + 1
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: 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, 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 ⟨u, hu₁, hu₂⟩ := h
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: obtain ⟨t, htu, htn⟩ := exists_subset_card_eq (hn₁.trans hu₂)
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 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
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: 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
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: 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.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: 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.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: 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
⊢ (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: split_ifs with h