-- Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean
theorem card_nonuniformWitness_sdiff_biUnion_star (hV : V ∈ P.parts) (hUV : U ≠ V)
    (h₂ : ¬G.IsUniform ε U V) :
    #(G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id) ≤ 2 ^ (#P.parts - 1) * m

Proof state:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
⊢ ∑ a ∈ filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts,
      #(a \ (filter (fun A => A ⊆ a) (chunk hP G ε hU).parts).biUnion id) ≤
    2 ^ (#P.parts - 1) * m

Tactic:
trans ∑ B ∈ (atomise U <| P.nonuniformWitnesses G ε U).parts with
  B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m

Result:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
⊢ ∑ a ∈ filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts,
      #(a \ (filter (fun A => A ⊆ a) (chunk hP G ε hU).parts).biUnion id) ≤
    ∑ B ∈ filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts,
      m

α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
⊢ ∑ B ∈ filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts,
      m ≤
    2 ^ (#P.parts - 1) * m

Proof state:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
this :
  ∀ B ∈ (atomise U (P.nonuniformWitnesses G ε U)).parts,
    #(B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id) ≤ m
⊢ ∑ a ∈ filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts,
      #(a \ (filter (fun A => A ⊆ a) (chunk hP G ε hU).parts).biUnion id) ≤
    ∑ B ∈ filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts,
      m

Tactic:
exact sum_le_sum fun B hB => this B <| filter_subset _ _ hB

Result:
no goals

Proof state:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
t :
  #(filter (fun u => u ⊆ G.nonuniformWitness ε U V ∧ u.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts) ≤
    2 ^ (#(P.nonuniformWitnesses G ε U) - 1)
⊢ #(filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts) ≤
    2 ^ (#P.parts - 1)

Tactic:
refine t.trans (pow_right_mono₀ (by norm_num) <| tsub_le_tsub_right ?_ _)

Result:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
t :
  #(filter (fun u => u ⊆ G.nonuniformWitness ε U V ∧ u.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts) ≤
    2 ^ (#(P.nonuniformWitnesses G ε U) - 1)
⊢ #(P.nonuniformWitnesses G ε U) ≤ #P.parts

Proof state:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
q :
  G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
    (filter (fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty)
          (atomise U (P.nonuniformWitnesses G ε U)).parts).biUnion
      fun B => B \ (filter (fun A => A ⊆ B) (chunk hP G ε hU).parts).biUnion id
t :
  #(filter (fun u => u ⊆ G.nonuniformWitness ε U V ∧ u.Nonempty) (atomise U (P.nonuniformWitnesses G ε U)).parts) ≤
    2 ^ (#(P.nonuniformWitnesses G ε U) - 1)
⊢ #(P.nonuniformWitnesses G ε U) ≤ #P.parts

Tactic:
exact card_image_le.trans (card_le_card <| filter_subset _ _)

Result:
no goals

Proof state:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
⊢ #(G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id) ≤ 2 ^ (#P.parts - 1) * m

Tactic:
have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
  nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV

Result:
α : Type u_1
inst✝² : Fintype α
inst✝¹ : DecidableEq α
P : Finpartition univ
hP : P.IsEquipartition
G : SimpleGraph α
inst✝ : DecidableRel G.Adj
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬G.IsUniform ε U V
hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U
⊢ #(G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id) ≤ 2 ^ (#P.parts - 1) * m