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) = s.card
hm : m ≠ 0
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card = a
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) = a * m + b * (m + 1)

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) = s.card
hm : m ≠ 0
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) = a * m + b * (m + 1)
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) = ∑ i ∈ (equitabilise h).parts, i.card

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) = s.card
hm : m ≠ 0
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) = ∑ i ∈ (equitabilise h).parts, i.card
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) = ∑ i ∈ (equitabilise h).parts, i.card

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) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) = ∑ i ∈ (equitabilise h).parts, i.card
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) =
    ∑ i ∈ filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts,
      i.card

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) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ (filter (fun u => u.card = m) (equitabilise h).parts).card * m + b * (m + 1) =
    ∑ i ∈ filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts,
      i.card
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ Disjoint (filter (fun u => u.card = m) (equitabilise h).parts)
    (filter (fun u => u.card = m + 1) (equitabilise h).parts)

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) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ Disjoint (filter (fun u => u.card = m) (equitabilise h).parts)
    (filter (fun u => u.card = m + 1) (equitabilise h).parts)
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ Disjoint (fun u => u.card = m) fun u => u.card = m + 1

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) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
⊢ Disjoint (fun u => u.card = m) fun u => u.card = m + 1
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h✝ : a * m + b * (m + 1) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h✝).parts =
    filter (fun u => u.card = m) (equitabilise h✝).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h✝).parts
x : Finset α → Prop
ha : x ≤ fun u => u.card = m
hb : x ≤ fun u => u.card = m + 1
i : Finset α
h : x i
⊢ ⊥ i

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) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h✝).parts =
    filter (fun u => u.card = m) (equitabilise h✝).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h✝).parts
x : Finset α → Prop
ha : x ≤ fun u => u.card = m
hb : x ≤ fun u => u.card = m + 1
i : Finset α
h : x i
⊢ ⊥ i
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h✝ : a * m + b * (m + 1) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h✝).parts =
    filter (fun u => u.card = m) (equitabilise h✝).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h✝).parts
x : Finset α → Prop
ha : x ≤ fun u => u.card = m
hb : x ≤ fun u => u.card = m + 1
i : Finset α
h : x i
⊢ m.succ = m

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) = s.card
hm : m ≠ 0
hunion :
  (equitabilise h✝).parts =
    filter (fun u => u.card = m) (equitabilise h✝).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h✝).parts
x : Finset α → Prop
ha : x ≤ fun u => u.card = m
hb : x ≤ fun u => u.card = m + 1
i : Finset α
h : x i
⊢ m.succ = m
state_after: no goals

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) = s.card
hm : m ≠ 0
⊢ (equitabilise h).parts =
    filter (fun u => u.card = m) (equitabilise h).parts ∪ filter (fun u => u.card = m + 1) (equitabilise h).parts
state_after: α : Type u_1
inst✝ : DecidableEq α
s t : Finset α
m n a b : ℕ
P : Finpartition s
h : a * m + b * (m + 1) = s.card
hm : m ≠ 0
⊢ ∀ x ∈ (equitabilise h).parts, x.card = m ∨ x.card = m + 1

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) = s.card
hm : m ≠ 0
⊢ ∀ x ∈ (equitabilise h).parts, x.card = m ∨ x.card = m + 1
state_after: no goals