l3lab/ntp-mathlib huggingface dataset:
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  

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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
⊢ 3 / 4 * ε ≤ |p - q|

Next tactic:
set t : ℝ := ↑(G.edgeDensity U V)
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  set t : ℝ := ↑(G.edgeDensity U V)
  

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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
t : ℝ := ↑(SimpleGraph.edgeDensity G U V)
⊢ 3 / 4 * ε ≤ |p - q|

Next tactic:
have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  set t : ℝ := ↑(G.edgeDensity U V)
  have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
t : ℝ := ↑(SimpleGraph.edgeDensity G U V)
hrs : |r - s| ≤ ε / 5
⊢ 3 / 4 * ε ≤ |p - q|

Next tactic:
have hst : ε ≤ |s - t| := by
    -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`.
    unfold_let s t
    exact mod_cast G.nonuniformWitness_spec hUVne hUV
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  set t : ℝ := ↑(G.edgeDensity U V)
  have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV
  have hst : ε ≤ |s - t| := by
    -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`.
    

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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
t : ℝ := ↑(SimpleGraph.edgeDensity G U V)
hrs : |r - s| ≤ ε / 5
⊢ ε ≤ |s - t|

Next tactic:
unfold_let s t
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  set t : ℝ := ↑(G.edgeDensity U V)
  have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV
  have hst : ε ≤ |s - t| := by
    -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`.
    unfold_let s t
    

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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
t : ℝ := ↑(SimpleGraph.edgeDensity G U V)
hrs : |r - s| ≤ ε / 5
⊢ ε ≤
    |↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U)) -
        ↑(SimpleGraph.edgeDensity G U V)|

Next tactic:
exact mod_cast G.nonuniformWitness_spec hUVne hUV
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  set t : ℝ := ↑(G.edgeDensity U V)
  have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV
  have hst : ε ≤ |s - t| := by
    -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`.
    unfold_let s t
    exact mod_cast G.nonuniformWitness_spec hUVne 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 α
inst✝ : Nonempty α
hPα : Finset.card P.parts * 16 ^ Finset.card P.parts ≤ Fintype.card α
hPε : 100 ≤ 4 ^ Finset.card P.parts * ε ^ 5
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
t : ℝ := ↑(SimpleGraph.edgeDensity G U V)
hrs : |r - s| ≤ ε / 5
hst : ε ≤ |s - t|
⊢ 3 / 4 * ε ≤ |p - q|

Next tactic:
have hpr : |p - r| ≤ ε ^ 5 / 49 :=
    average_density_near_total_density hPα hPε hε₁ star_subset_chunk star_subset_chunk
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/
private theorem edgeDensity_star_not_uniform [Nonempty α]
    (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5)
    (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    ↑3 / ↑4 * ε ≤
    |(∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card) -
        (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
          (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by
  rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)]
  set p : ℝ :=
    (∑ ab in (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) /
      ((star hP G ε hU V).card * (star hP G ε hV U).card)
  set q : ℝ :=
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card)
  change _ ≤ |p - q|
  set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id))
  set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U))
  set t : ℝ := ↑(G.edgeDensity U V)
  have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV
  have hst : ε ≤ |s - t| := by
    -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`.
    unfold_let s t
    exact mod_cast G.nonuniformWitness_spec hUVne hUV
  have hpr : |p - r| ≤ ε ^ 5 / 49 :=
    average_density_near_total_density hPα hPε hε₁ star_subset_chunk star_subset_chunk
  have hqt : |q - t| ≤ ε ^ 5 / 49 := 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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
p : ℝ :=
  (∑ ab in Finset.product (star hP G ε hU V) (star hP G ε hV U), ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)))
q : ℝ :=
  (∑ ab in Finset.product (chunk hP G ε hU).parts (chunk hP G ε hV).parts, ↑(SimpleGraph.edgeDensity G ab.1 ab.2)) /
    (4 ^ Finset.card P.parts * 4 ^ Finset.card P.parts)
r : ℝ := ↑(SimpleGraph.edgeDensity G (Finset.biUnion (star hP G ε hU V) id) (Finset.biUnion (star hP G ε hV U) id))
s : ℝ := ↑(SimpleGraph.edgeDensity G (SimpleGraph.nonuniformWitness G ε U V) (SimpleGraph.nonuniformWitness G ε V U))
t : ℝ := ↑(SimpleGraph.edgeDensity G U V)
hrs : |r - s| ≤ ε / 5
hst : ε ≤ |s - t|
hpr : |p - r| ≤ ε ^ 5 / 49
⊢ |q - t| ≤ ε ^ 5 / 49

Next tactic:
have := average_density_near_total_density hPα hPε hε₁
      (Subset.refl (chunk hP G ε hU).parts) (Subset.refl (chunk hP G ε hV).parts)
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.increment`.
-/
theorem edgeDensity_chunk_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α)
    (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts}
    (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 + ε ^ 4 / ↑3 ≤
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card :=
  calc
    ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / 25 + ε ^ 4 / ↑3 ≤ ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / ↑25 +
        (star hP G ε hU V).card * (star hP G ε hV U).card / ↑16 ^ P.parts.card *
          (↑9 / ↑16) * ε ^ 2 := 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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
⊢ ↑(SimpleGraph.edgeDensity G U V) ^ 2 - ε ^ 5 / 25 + ε ^ 4 / 3 ≤
    ↑(SimpleGraph.edgeDensity G U V) ^ 2 - ε ^ 5 / 25 +
      ↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)) / 16 ^ Finset.card P.parts * (9 / 16) *
        ε ^ 2

Next tactic:
apply add_le_add_left
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.increment`.
-/
theorem edgeDensity_chunk_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α)
    (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts}
    (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 + ε ^ 4 / ↑3 ≤
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card :=
  calc
    ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / 25 + ε ^ 4 / ↑3 ≤ ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / ↑25 +
        (star hP G ε hU V).card * (star hP G ε hV U).card / ↑16 ^ P.parts.card *
          (↑9 / ↑16) * ε ^ 2 := by
      apply add_le_add_left
      

Proof state:
case bc
α : 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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
⊢ ε ^ 4 / 3 ≤
    ↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)) / 16 ^ Finset.card P.parts * (9 / 16) * ε ^ 2

Next tactic:
have Ul : 4 / 5 * ε ≤ (star hP G ε hU V).card / _ :=
        eps_le_card_star_div hPα hPε hε₁ hU hV hUVne hUV
/-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.increment`.
-/
theorem edgeDensity_chunk_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α)
    (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts}
    (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) :
    (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 + ε ^ 4 / ↑3 ≤
    (∑ ab in (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts,
      (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card :=
  calc
    ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / 25 + ε ^ 4 / ↑3 ≤ ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / ↑25 +
        (star hP G ε hU V).card * (star hP G ε hV U).card / ↑16 ^ P.parts.card *
          (↑9 / ↑16) * ε ^ 2 := by
      apply add_le_add_left
      have Ul : 4 / 5 * ε ≤ (star hP G ε hU V).card / _ :=
        eps_le_card_star_div hPα hPε hε₁ hU hV hUVne hUV
      

Proof state:
case bc
α : 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
hε₁ : ε ≤ 1
hU : U ∈ P.parts
hV : V ∈ P.parts
hUVne : U ≠ V
hUV : ¬SimpleGraph.IsUniform G ε U V
Ul : 4 / 5 * ε ≤ ↑(Finset.card (star hP G ε hU V)) / 4 ^ Finset.card P.parts
⊢ ε ^ 4 / 3 ≤
    ↑(Finset.card (star hP G ε hU V)) * ↑(Finset.card (star hP G ε hV U)) / 16 ^ Finset.card P.parts * (9 / 16) * ε ^ 2

Next tactic:
have Vl : 4 / 5 * ε ≤ (star hP G ε hV U).card / _ :=
        eps_le_card_star_div hPα hPε hε₁ hV hU hUVne.symm fun h => hUV h.symm