l3lab/ntp-mathlib huggingface dataset:
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  

Proof state:
case inr
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : ε ^ 5 / 50 ≤ ↑(SimpleGraph.edgeDensity G U V)
⊢ ↑(SimpleGraph.edgeDensity G U V) ^ 2 - ε ^ 5 / 25 ≤
    ((∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
        16 ^ Finset.card P.parts) ^
      2

Next tactic:
rw [← sub_nonneg] at hGε
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  

Proof state:
case inr
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
⊢ ↑(SimpleGraph.edgeDensity G U V) ^ 2 - ε ^ 5 / 25 ≤
    ((∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
        16 ^ Finset.card P.parts) ^
      2

Next tactic:
have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
      norm_cast
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
⊢ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts

Next tactic:
have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    

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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
rflU : ↑(chunk hP G ε hU).parts ⊆ ↑(chunk hP G ε hU).parts
⊢ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts

Next tactic:
have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    

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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
rflU : ↑(chunk hP G ε hU).parts ⊆ ↑(chunk hP G ε hU).parts
rflV : ↑(chunk hP G ε hV).parts ⊆ ↑(chunk hP G ε hV).parts
⊢ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts

Next tactic:
refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · 

Proof state:
case refine'_1
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
rflU : ↑(chunk hP G ε hU).parts ⊆ ↑(chunk hP G ε hU).parts
rflV : ↑(chunk hP G ε hV).parts ⊆ ↑(chunk hP G ε hV).parts
⊢ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    ↑(SimpleGraph.edgeDensity G (Finset.biUnion (chunk hP G ε hU).parts id)
          (Finset.biUnion (chunk hP G ε hV).parts id)) -
      ε ^ 5 / 50

Next tactic:
rw [biUnion_parts, biUnion_parts]
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · 

Proof state:
case refine'_2
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
rflU : ↑(chunk hP G ε hU).parts ⊆ ↑(chunk hP G ε hU).parts
rflV : ↑(chunk hP G ε hV).parts ⊆ ↑(chunk hP G ε hV).parts
⊢ (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      (↑(Finset.card (chunk hP G ε hU).parts) * ↑(Finset.card (chunk hP G ε hV).parts)) ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts

Next tactic:
rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
      

Proof state:
case refine'_2
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
rflU : ↑(chunk hP G ε hU).parts ⊆ ↑(chunk hP G ε hU).parts
rflV : ↑(chunk hP G ε hV).parts ⊆ ↑(chunk hP G ε hV).parts
⊢ (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      ↑(4 * 4) ^ Finset.card P.parts ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts

Next tactic:
norm_cast
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
      norm_cast
  

Proof state:
case inr
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
this :
  ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts
⊢ ↑(SimpleGraph.edgeDensity G U V) ^ 2 - ε ^ 5 / 25 ≤
    ((∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
        16 ^ Finset.card P.parts) ^
      2

Next tactic:
refine' le_trans _ (pow_le_pow_left hGε this 2)
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
      norm_cast
  refine' le_trans _ (pow_le_pow_left hGε this 2)
  

Proof state:
case inr
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
this :
  ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts
⊢ ↑(SimpleGraph.edgeDensity G U V) ^ 2 - ε ^ 5 / 25 ≤ (↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50) ^ 2

Next tactic:
rw [sub_sq, sub_add, sub_le_sub_iff_left]
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
      norm_cast
  refine' le_trans _ (pow_le_pow_left hGε this 2)
  rw [sub_sq, sub_add, sub_le_sub_iff_left]
  

Proof state:
case inr
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
this :
  ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts
⊢ 2 * ↑(SimpleGraph.edgeDensity G U V) * (ε ^ 5 / 50) - (ε ^ 5 / 50) ^ 2 ≤ ε ^ 5 / 25

Next tactic:
refine' (sub_le_self _ <| sq_nonneg <| ε ^ 5 / 50).trans _
private theorem edgeDensity_chunk_aux [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hU : U ∈ P.parts) (hV : V ∈ P.parts) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤
    ((∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by
  obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50)
  · refine' (sub_nonpos_of_le <| (sq_le _ _).trans <| hGε.trans _).trans (sq_nonneg _)
    · exact mod_cast G.edgeDensity_nonneg _ _
    · exact mod_cast G.edgeDensity_le_one _ _
    · exact div_le_div_of_le_left (by sz_positivity) (by norm_num) (by norm_num)
  rw [← sub_nonneg] at hGε
  have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤
      (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
        (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by
    have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet
    have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet
    refine' (le_trans _ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans _
    · rw [biUnion_parts, biUnion_parts]
    · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow]
      norm_cast
  refine' le_trans _ (pow_le_pow_left hGε this 2)
  rw [sub_sq, sub_add, sub_le_sub_iff_left]
  refine' (sub_le_self _ <| sq_nonneg <| ε ^ 5 / 50).trans _
  

Proof state:
case inr
α : 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hU : U ∈ P.parts
hV : V ∈ P.parts
hGε : 0 ≤ ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50
this :
  ↑(SimpleGraph.edgeDensity G U V) - ε ^ 5 / 50 ≤
    (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
      16 ^ Finset.card P.parts
⊢ 2 * ↑(SimpleGraph.edgeDensity G U V) * (ε ^ 5 / 50) ≤ ε ^ 5 / 25

Next tactic:
rw [mul_right_comm, mul_div_left_comm, div_eq_mul_inv (ε ^ 5),
    show (2 : ℝ) / 50 = 25⁻¹ by norm_num]