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

tactic: refine' (mul_eq_mul_right_iff.1 <| (add_left_inj (b * (m + 1))).1 _).resolve_right hm
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
⊢ card (filter (fun u => card u = m) (equitabilise h).parts) = a

tactic: rw [h, ← (P.equitabilise h).sum_card_parts]
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
⊢ card (filter (fun u => card u = m) (equitabilise h).parts) * m + b * (m + 1) = a * m + b * (m + 1)

tactic: have hunion :
  (P.equitabilise h).parts =
    ((P.equitabilise h).parts.filter fun u => u.card = m) ∪
      (P.equitabilise h).parts.filter fun u => u.card = m + 1 := by
  rw [← filter_or, filter_true_of_mem]
  exact fun x => card_eq_of_mem_parts_equitabilise
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
⊢ card (filter (fun u => card u = m) (equitabilise h).parts) * m + b * (m + 1) =
    Finset.sum (equitabilise h).parts fun i => card i

tactic: nth_rw 2 [hunion]
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => card u = m) (equitabilise h).parts ∪ filter (fun u => card u = m + 1) (equitabilise h).parts
⊢ card (filter (fun u => card u = m) (equitabilise h).parts) * m + b * (m + 1) =
    Finset.sum (equitabilise h).parts fun i => card i

tactic: rw [sum_union, sum_const_nat fun x hx => (mem_filter.1 hx).2,
  sum_const_nat fun x hx => (mem_filter.1 hx).2, P.card_filter_equitabilise_big]
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => card u = m) (equitabilise h).parts ∪ filter (fun u => card u = m + 1) (equitabilise h).parts
⊢ card (filter (fun u => card u = m) (equitabilise h).parts) * m + b * (m + 1) =
    Finset.sum
      (filter (fun u => card u = m) (equitabilise h).parts ∪ filter (fun u => card u = m + 1) (equitabilise h).parts)
      fun i => card i

tactic: refine' disjoint_filter_filter' _ _ _
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => card u = m) (equitabilise h).parts ∪ filter (fun u => card u = m + 1) (equitabilise h).parts
⊢ Disjoint (filter (fun u => card u = m) (equitabilise h).parts)
    (filter (fun u => card u = m + 1) (equitabilise h).parts)

tactic: intro x ha hb i h
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => card u = m) (equitabilise h).parts ∪ filter (fun u => card u = m + 1) (equitabilise h).parts
⊢ Disjoint (fun u => card u = m) fun u => card u = m + 1

tactic: apply succ_ne_self m _
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h✝ : a * m + b * (m + 1) = card s
hm : m ≠ 0
hunion :
  (equitabilise h✝).parts =
    filter (fun u => card u = m) (equitabilise h✝).parts ∪ filter (fun u => card u = m + 1) (equitabilise h✝).parts
x : Finset α → Prop
ha : x ≤ fun u => card u = m
hb : x ≤ fun u => card u = m + 1
i : Finset α
h : x i
⊢ ⊥ i

tactic: exact (hb i h).symm.trans (ha i h)
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h✝ : a * m + b * (m + 1) = card s
hm : m ≠ 0
hunion :
  (equitabilise h✝).parts =
    filter (fun u => card u = m) (equitabilise h✝).parts ∪ filter (fun u => card u = m + 1) (equitabilise h✝).parts
x : Finset α → Prop
ha : x ≤ fun u => card u = m
hb : x ≤ fun u => card u = m + 1
i : Finset α
h : x i
⊢ succ m = m

tactic: rw [← filter_or, filter_true_of_mem]
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
⊢ (equitabilise h).parts =
    filter (fun u => card u = m) (equitabilise h).parts ∪ filter (fun u => card u = m + 1) (equitabilise h).parts

tactic: exact fun x => card_eq_of_mem_parts_equitabilise
state_before: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = card s
hm : m ≠ 0
⊢ ∀ (x : Finset α), x ∈ (equitabilise h).parts → card x = m ∨ card x = m + 1