l3lab/ntp-mathlib huggingface dataset:
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
⊢ ∑ x in offDiag P.parts, ↑(edgeDensity G x.1 x.2) ^ 2 + ↑(Finset.card P.parts) ^ 2 * (ε ^ 5 / 4) ≤
    ∑ x in offDiag P.parts, ↑(edgeDensity G x.1 x.2) ^ 2 - ↑(Finset.card (offDiag P.parts)) * (ε ^ 5 / 25) +
      ↑(Finset.card (nonUniforms P G ε)) * (ε ^ 4 / 3)

Next tactic:
refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
⊢ 0 ≤ ε ^ 4 / 3

Next tactic:
positivity
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
⊢ ∑ x in offDiag P.parts, ↑(edgeDensity G x.1 x.2) ^ 2 + ↑(Finset.card P.parts) ^ 2 * (ε ^ 5 / 4) ≤
    ∑ x in offDiag P.parts, ↑(edgeDensity G x.1 x.2) ^ 2 - ↑(Finset.card (offDiag P.parts)) * (ε ^ 5 / 25) +
      ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε * (ε ^ 4 / 3)

Next tactic:
conv_rhs =>
    enter [1, 2]
    rw [offDiag_card]
    conv => enter [1, 1, 2]; rw [← mul_one P.parts.card]
    rw [← Nat.mul_sub_left_distrib]
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  conv_rhs =>
    

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
| ∑ x in offDiag P.parts, ↑(edgeDensity G x.1 x.2) ^ 2 - ↑(Finset.card (offDiag P.parts)) * (ε ^ 5 / 25) +
    ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε * (ε ^ 4 / 3)

Next tactic:
enter [1, 2]
    rw [offDiag_card]
    conv => enter [1, 1, 2]; rw [← mul_one P.parts.card]
    rw [← Nat.mul_sub_left_distrib]
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  conv_rhs =>
    

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
| ∑ x in offDiag P.parts, ↑(edgeDensity G x.1 x.2) ^ 2 - ↑(Finset.card (offDiag P.parts)) * (ε ^ 5 / 25) +
    ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε * (ε ^ 4 / 3)

Next tactic:
enter [1, 2]
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  conv_rhs =>
    enter [1, 2]
    

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
| ↑(Finset.card (offDiag P.parts)) * (ε ^ 5 / 25)

Next tactic:
rw [offDiag_card]
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  conv_rhs =>
    enter [1, 2]
    rw [offDiag_card]
    

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
| ↑(Finset.card P.parts * Finset.card P.parts - Finset.card P.parts) * (ε ^ 5 / 25)

Next tactic:
conv => enter [1, 1, 2]; rw [← mul_one P.parts.card]
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  conv_rhs =>
    enter [1, 2]
    rw [offDiag_card]
    conv => 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
| ↑(Finset.card P.parts * Finset.card P.parts - Finset.card P.parts) * (ε ^ 5 / 25)

Next tactic:
enter [1, 1, 2]; rw [← mul_one P.parts.card]
theorem uniform_add_nonuniform_eq_offDiag_pairs [Nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hPG : ¬P.IsUniform G ε) :
    (∑ x in P.parts.offDiag, (G.edgeDensity x.1 x.2 : ℝ) ^ 2 +
      ↑P.parts.card ^ 2 * (ε ^ 5 / 4) : ℝ) / (P.parts.card : ℝ) ^ 2 ≤
    ∑ x in P.parts.offDiag.attach,
      (pairContrib G ε hP x : ℝ) / ((increment hP G ε).parts.card : ℝ) ^ 2 := by
  conv_rhs =>
    rw [← sum_div, card_increment hPα hPG, stepBound, ← Nat.cast_pow, mul_pow, pow_right_comm,
      Nat.cast_mul, mul_comm, ← div_div, show 4 ^ 2 = 16 by norm_num, sum_div]
  rw [← Nat.cast_pow, Nat.cast_pow 16]
  refine' div_le_div_of_le_of_nonneg _ (Nat.cast_nonneg _)
  norm_num
  trans ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
    if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ)
  swap
  · exact sum_le_sum fun i _ => pairContrib_lower_bound i hε₁ hPα hPε
  have :
      ∑ x in P.parts.offDiag.attach, ((G.edgeDensity x.1.1 x.1.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1.1 x.1.2 then (0 : ℝ) else ε ^ 4 / 3 : ℝ) =
      ∑ x in P.parts.offDiag, ((G.edgeDensity x.1 x.2 : ℝ) ^ 2 - ε ^ 5 / ↑25 +
        if G.IsUniform ε x.1 x.2 then (0 : ℝ) else ε ^ 4 / 3) := by
    convert sum_attach (β := ℝ); rfl
  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,
    zero_add, sum_const, nsmul_eq_mul, ← Finpartition.nonUniforms]
  rw [Finpartition.IsUniform, not_le] at hPG
  refine' le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le <| by positivity) _)
  conv_rhs =>
    enter [1, 2]
    rw [offDiag_card]
    conv => 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
P : Finpartition univ
hP : IsEquipartition P
G : SimpleGraph α
ε : ℝ
inst✝ : Nonempty α
hε₁ : ε ≤ 1
hP₇ : 7 ≤ Finset.card P.parts
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hPG : ↑(Finset.card P.parts * (Finset.card P.parts - 1)) * ε < ↑(Finset.card (nonUniforms P G ε))
this :
  ∑ x in attach (offDiag P.parts),
      (↑(edgeDensity G (↑x).1 (↑x).2) ^ 2 - ε ^ 5 / 25 +
        if SimpleGraph.IsUniform G ε (↑x).1 (↑x).2 then 0 else ε ^ 4 / 3) =
    ∑ x in offDiag P.parts,
      (↑(edgeDensity G x.1 x.2) ^ 2 - ε ^ 5 / 25 + if SimpleGraph.IsUniform G ε x.1 x.2 then 0 else ε ^ 4 / 3)
| ↑(Finset.card P.parts * Finset.card P.parts - Finset.card P.parts) * (ε ^ 5 / 25)

Next tactic:
enter [1, 1, 2]