l3lab/ntp-mathlib huggingface dataset:
/-- Apply the function `f : α → β → γ` to each corresponding pair of elements from two vectors. -/
def zipWith : Vector α n → Vector β n → Vector γ n := fun x y => ⟨List.zipWith f x.1 y.1, by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
x : Vector α n
y : Vector β n
⊢ List.length (List.zipWith f ↑x ↑y) = n

Next tactic:
simp
@[simp]
theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) :
    (Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
x : Vector α n
y : Vector β n
i : Fin n
⊢ get (zipWith f x y) i = f (get x i) (get y i)

Next tactic:
dsimp only [Vector.zipWith, Vector.get]
@[simp]
theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) :
    (Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by
  dsimp only [Vector.zipWith, Vector.get]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
x : Vector α n
y : Vector β n
i : Fin n
⊢ List.nthLe (List.zipWith f ↑x ↑y) ↑i (_ : ↑i < List.length (List.zipWith f ↑x ↑y)) =
    f
      (match x, i with
      | { val := l, property := h }, i => List.nthLe l ↑i (_ : ↑i < List.length l))
      (match y, i with
      | { val := l, property := h }, i => List.nthLe l ↑i (_ : ↑i < List.length l))

Next tactic:
cases x
@[simp]
theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) :
    (Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by
  dsimp only [Vector.zipWith, Vector.get]
  cases x; 

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
y : Vector β n
i : Fin n
val✝ : List α
property✝ : List.length val✝ = n
⊢ List.nthLe (List.zipWith f ↑{ val := val✝, property := property✝ } ↑y) ↑i
      (_ : ↑i < List.length (List.zipWith f ↑{ val := val✝, property := property✝ } ↑y)) =
    f
      (match { val := val✝, property := property✝ }, i with
      | { val := l, property := h }, i => List.nthLe l ↑i (_ : ↑i < List.length l))
      (match y, i with
      | { val := l, property := h }, i => List.nthLe l ↑i (_ : ↑i < List.length l))

Next tactic:
cases y
@[simp]
theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) :
    (Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by
  dsimp only [Vector.zipWith, Vector.get]
  cases x; cases y
  

Proof state:
case mk.mk
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
i : Fin n
val✝¹ : List α
property✝¹ : List.length val✝¹ = n
val✝ : List β
property✝ : List.length val✝ = n
⊢ List.nthLe (List.zipWith f ↑{ val := val✝¹, property := property✝¹ } ↑{ val := val✝, property := property✝ }) ↑i
      (_ :
        ↑i <
          List.length
            (List.zipWith f ↑{ val := val✝¹, property := property✝¹ } ↑{ val := val✝, property := property✝ })) =
    f
      (match { val := val✝¹, property := property✝¹ }, i with
      | { val := l, property := h }, i => List.nthLe l ↑i (_ : ↑i < List.length l))
      (match { val := val✝, property := property✝ }, i with
      | { val := l, property := h }, i => List.nthLe l ↑i (_ : ↑i < List.length l))

Next tactic:
simp only [List.nthLe_zipWith]
@[simp]
theorem zipWith_tail (x : Vector α n) (y : Vector β n) :
    (Vector.zipWith f x y).tail = Vector.zipWith f x.tail y.tail := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
x : Vector α n
y : Vector β n
⊢ tail (zipWith f x y) = zipWith f (tail x) (tail y)

Next tactic:
ext
@[simp]
theorem zipWith_tail (x : Vector α n) (y : Vector β n) :
    (Vector.zipWith f x y).tail = Vector.zipWith f x.tail y.tail := by
  ext
  

Proof state:
case x
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
f : α → β → γ
x : Vector α n
y : Vector β n
m✝ : Fin (n - 1)
⊢ get (tail (zipWith f x y)) m✝ = get (zipWith f (tail x) (tail y)) m✝

Next tactic:
simp [get_tail]
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  

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

Next tactic:
have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  

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

Next tactic:
have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
    exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    

Proof state:
α : Type u_1
inst✝ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
𝒜 : Finset (Finset α)
s : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬SimpleGraph.IsUniform G ε U V
hX : SimpleGraph.nonuniformWitness G ε U V ∈ nonuniformWitnesses P G ε U
⊢ SimpleGraph.nonuniformWitness G ε U V \ Finset.biUnion (star hP G ε hU V) id ⊆
    Finset.biUnion
      (filter (fun B => B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B)
        (atomise U (nonuniformWitnesses P G ε U)).parts)
      fun B => B \ Finset.biUnion (filter (fun x => x ⊆ B) (chunk hP G ε hU).parts) id

Next tactic:
intro x hx
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    

Proof state:
α : Type u_1
inst✝ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
𝒜 : Finset (Finset α)
s : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬SimpleGraph.IsUniform G ε U V
hX : SimpleGraph.nonuniformWitness G ε U V ∈ nonuniformWitnesses P G ε U
x : α
hx : x ∈ SimpleGraph.nonuniformWitness G ε U V \ Finset.biUnion (star hP G ε hU V) id
⊢ x ∈
    Finset.biUnion
      (filter (fun B => B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B)
        (atomise U (nonuniformWitnesses P G ε U)).parts)
      fun B => B \ Finset.biUnion (filter (fun x => x ⊆ B) (chunk hP G ε hU).parts) id

Next tactic:
rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    

Proof state:
α : Type u_1
inst✝ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
𝒜 : Finset (Finset α)
s : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬SimpleGraph.IsUniform G ε U V
hX : SimpleGraph.nonuniformWitness G ε U V ∈ nonuniformWitnesses P G ε U
x : α
hx :
  (∃
      a ∈
        filter (fun u => u ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty u)
          (atomise U (nonuniformWitnesses P G ε U)).parts,
      x ∈ id a) ∧
    x ∉ Finset.biUnion (filter (fun x => x ⊆ SimpleGraph.nonuniformWitness G ε U V) (chunk hP G ε hU).parts) id
⊢ x ∈
    Finset.biUnion
      (filter (fun B => B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B)
        (atomise U (nonuniformWitnesses P G ε U)).parts)
      fun B => B \ Finset.biUnion (filter (fun x => x ⊆ B) (chunk hP G ε hU).parts) id

Next tactic:
simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    

Proof state:
α : Type u_1
inst✝ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
𝒜 : Finset (Finset α)
s : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬SimpleGraph.IsUniform G ε U V
hX : SimpleGraph.nonuniformWitness G ε U V ∈ nonuniformWitnesses P G ε U
x : α
hx :
  (∃ a,
      (a ∈ (atomise U (nonuniformWitnesses P G ε U)).parts ∧
          a ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty a) ∧
        x ∈ a) ∧
    ∀ x_1 ∈ (chunk hP G ε hU).parts, x_1 ⊆ SimpleGraph.nonuniformWitness G ε U V → x ∉ x_1
⊢ ∃ a,
    (a ∈ (atomise U (nonuniformWitnesses P G ε U)).parts ∧
        a ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty a) ∧
      x ∈ a ∧ ∀ x_1 ∈ (chunk hP G ε hU).parts, x_1 ⊆ a → x ∉ x_1

Next tactic:
obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
    

Proof state:
case intro.intro.intro
α : Type u_1
inst✝ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
𝒜 : Finset (Finset α)
s : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬SimpleGraph.IsUniform G ε U V
hX : SimpleGraph.nonuniformWitness G ε U V ∈ nonuniformWitnesses P G ε U
x : α
hx : ∀ x_1 ∈ (chunk hP G ε hU).parts, x_1 ⊆ SimpleGraph.nonuniformWitness G ε U V → x ∉ x_1
B : Finset α
hB₁ :
  B ∈ (atomise U (nonuniformWitnesses P G ε U)).parts ∧ B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B
hB₂ : x ∈ B
⊢ ∃ a,
    (a ∈ (atomise U (nonuniformWitnesses P G ε U)).parts ∧
        a ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty a) ∧
      x ∈ a ∧ ∀ x_1 ∈ (chunk hP G ε hU).parts, x_1 ⊆ a → x ∉ x_1

Next tactic:
exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
    exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩
  

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

Next tactic:
apply (card_le_of_subset q).trans (card_biUnion_le.trans _)
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
    exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩
  apply (card_le_of_subset q).trans (card_biUnion_le.trans _)
  

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

Next tactic:
trans ∑ _i in (atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
    B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
    exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩
  apply (card_le_of_subset q).trans (card_biUnion_le.trans _)
  trans ∑ _i in (atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
    B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m
  · 

Proof state:
α : Type u_1
inst✝ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
U : Finset α
hU : U ∈ P.parts
V : Finset α
𝒜 : Finset (Finset α)
s : Finset α
hV : V ∈ P.parts
hUV : U ≠ V
h₂ : ¬SimpleGraph.IsUniform G ε U V
hX : SimpleGraph.nonuniformWitness G ε U V ∈ nonuniformWitnesses P G ε U
q :
  SimpleGraph.nonuniformWitness G ε U V \ Finset.biUnion (star hP G ε hU V) id ⊆
    Finset.biUnion
      (filter (fun B => B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B)
        (atomise U (nonuniformWitnesses P G ε U)).parts)
      fun B => B \ Finset.biUnion (filter (fun x => x ⊆ B) (chunk hP G ε hU).parts) id
⊢ ∑ a in
      filter (fun B => B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B)
        (atomise U (nonuniformWitnesses P G ε U)).parts,
      Finset.card (a \ Finset.biUnion (filter (fun x => x ⊆ a) (chunk hP G ε hU).parts) id) ≤
    ∑ _i in
      filter (fun B => B ⊆ SimpleGraph.nonuniformWitness G ε U V ∧ Finset.Nonempty B)
        (atomise U (nonuniformWitnesses P G ε U)).parts,
      m

Next tactic:
suffices ∀ B ∈ (atomise U <| P.nonuniformWitnesses G ε U).parts,
        (B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id).card ≤ m by
      exact sum_le_sum fun B hB => this B <| filter_subset _ _ hB
private 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).card ≤
    2 ^ (P.parts.card - 1) * m := by
  have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U :=
    nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV
  have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆
      ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
        B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion
        fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by
    intro x hx
    rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff,
      mem_biUnion] at hx
    simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter,
      not_and, mem_sdiff, id.def, mem_sdiff] at hx ⊢
    obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx
    exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩
  apply (card_le_of_subset q).trans (card_biUnion_le.trans _)
  trans ∑ _i in (atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B =>
    B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m
  · suffices ∀ B ∈ (atomise U <| P.nonuniformWitnesses G ε U).parts,
        (B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id).card ≤ m by
      

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

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