AFTD Auto-Formalizing Theoretical Domains

equal_length_proportional_cake_suffix_volume

theoremverified

In any equal-length proportional cake allocation C : Fin n → Set ℝ for n ≥ 1 under the identical valuation profile where each agent values only the prefix [0, 1/n], each bundle C i has suffix Lebesgue measure volume (C i ∩ Set.Ioc (1 / n) 1) equal to ENNReal.ofReal (1 / n - 1 / n^2).

Statement

theorem equal_length_proportional_cake_suffix_volume (n : ℕ) (hn : 1 ≤ n)
    (C : Fin n → Set ℝ)
    (h_alloc : is_cake_allocation n C)
    (h_len : is_equal_length_allocation n C)
    (h_prop : is_prop_lb_proportional n C)
    (i : Fin n) :
    MeasureTheory.volume (C i ∩ Set.Ioc (1 / (n : ℝ)) 1) =
      ENNReal.ofReal (1 / (n : ℝ) - 1 / ((n : ℝ) ^ 2))
Source
scout/2610-19733-exact-cut-complexity-of-equal-length-proportional-cake-cutt.md:386
Verified
24 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • is_cake_allocationAn allocation of the cake [0, 1] among n agents is a measurable partition of [0, 1] into n bundles C i.
  • is_equal_length_allocationAn allocation is equal-length if each bundle has Lebesgue measure equal to 1 / n.
  • is_prop_lb_proportionalAn allocation is proportional with respect to the identical valuation profile where each agent's value is n * λ(S ∩ [0, 1/n]) if each…
Used by 1

Read back from the Lean

For any natural number $n \ge 1$, any allocation $C : \text{Fin } n \to \text{Set } \mathbb{R}$, if $C$ is a cake allocation of $[0, 1]$ (is_cake_allocation n C), each piece $C_i$ has equal measure $1/n$ (is_equal_length_allocation n C), and $C$ satisfies the proportional lower bound condition on $[0, 1/n]$ (is_prop_lb_proportional n C), then for every agent $i : \text{Fin } n$, the Lebesgue volume of the intersection of $C_i$ with the interval $(1/n, 1]$ is equal to $\text{ENNReal.ofReal}(1/n - 1/n^2)$.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The theorem establishes that in any equal-length proportional cake division among n agents where each agent's valuation is concentrated on the prefix [0, 1/n], every agent's bundle C i has suffix volume vol(C i ∩ (1/n, 1]) equal to 1/n - 1/n^2. Because each bundle has total volume 1/n, the suffix volume is entirely determined by the prefix volume in [0, 1/n]. Proportionality requires each bundle to have prefix volume at least 1/n^2. Since the n bundles partition the prefix [0, 1/n], whose total volume is 1/n, the n terms sum to n * (1/n^2) = 1/n, which forces every prefix volume to be exactly 1/n^2. Subtracting this prefix volume from the bundle's total volume 1/n yields the suffix volume 1/n - 1/n^2.

  1. The number of agents satisfies 1 ≤ n and 0 < n as real numbers, and each bundle C i is a measurable subset of [0, 1].

    We cast the hypothesis 1 ≤ n from ℕ to ℝ, which also implies 0 < n. We unpack the cake allocation hypothesis h_alloc into measurability of each C i, pairwise disjointness of bundles, and the fact that their union is the entire cake [0, 1]. Since each C i is contained in ⋃ j, C j = [0, 1], every bundle is a subset of [0, 1].

    lines 10–16

    uses Set.subset_iUnion

      have hn1 : (1:ℝ) ≤ (n:ℝ) := by exact_mod_cast hn
      have hnpos : (0:ℝ) < (n:ℝ) := by linarith
      obtain ⟨hmeas, hdisj, hunion⟩ := h_alloc
      have hsub : ∀ i : Fin n, C i ⊆ Set.Icc (0:ℝ) 1 := by
        intro i x hx
        rw [← hunion]
        exact Set.subset_iUnion C i hx
  2. The prefix boundary q = 1/n satisfies 0 ≤ q ≤ 1.

    We define q = 1/n. Positivity establishes 0 ≤ q, and dividing the inequality 1 ≤ n by the positive real n shows that q = 1/n ≤ 1.

    lines 17–21

    uses div_le_one

      set q : ℝ := 1 / (n:ℝ) with hq
      have hq0 : 0 ≤ q := by rw [hq]; positivity
      have hq1 : q ≤ 1 := by
        rw [hq, div_le_one hnpos]
        exact hn1
  3. The prefix slices C i ∩ [0, q] are measurable, pairwise disjoint, and partition the prefix [0, q].

    Each slice C i ∩ [0, q] is measurable as the intersection of two measurable sets. Disjointness of the slices is inherited from the disjointness of the bundles C i and C j for i ≠ j. Distributing intersection over the union shows that ⋃ i, (C i ∩ [0, q]) = (⋃ i, C i) ∩ [0, q] = [0, 1] ∩ [0, q] = [0, q], because q ≤ 1.

    lines 22–28

    uses measurableSet_Icc, Set.inter_subset_left, Set.iUnion_inter, Set.inter_eq_right.mpr, le_trans

      have hSmeas : ∀ i, MeasurableSet (C i ∩ Set.Icc (0:ℝ) q) := fun i => (hmeas i).inter measurableSet_Icc
      have hSdisj : Pairwise (Function.onFun Disjoint (fun i => C i ∩ Set.Icc (0:ℝ) q)) := by
        intro i j hij
        exact (hdisj i j hij).mono Set.inter_subset_left Set.inter_subset_left
      have hSunion : (⋃ i : Fin n, (C i ∩ Set.Icc (0:ℝ) q)) = Set.Icc (0:ℝ) q := by
        rw [← Set.iUnion_inter, hunion]
        exact Set.inter_eq_right.mpr (fun x hx => ⟨hx.1, le_trans hx.2 hq1⟩)
  4. Each prefix slice has finite Lebesgue measure, and their volumes sum to q = 1/n in both ENNReal and ℝ.

    Since C i ∩ [0, q] ⊆ [0, q], its volume is bounded by the volume of [0, q], which is q - 0 = q < ∞, so each slice has finite volume. By countable additivity on the disjoint partition of [0, q], the sum of the volumes equals the volume of [0, q], namely q. Since every term is finite, converting this sum of extended non-negative reals to standard real numbers yields ∑ i, vol(C i ∩ [0, q]) = q.

    lines 29–41

    uses MeasureTheory.measure_mono, Set.inter_subset_right, Real.volume_Icc, sub_zero, ne_top_of_le_ne_top, ENNReal.ofReal_ne_top, MeasureTheory.measure_iUnion, tsum_fintype, ENNReal.toReal_sum, Finset.univ, ENNReal.toReal_ofReal

      have hSfin : ∀ i, MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q) ≠ ⊤ := by
        intro i
        have hle := MeasureTheory.measure_mono (μ := MeasureTheory.volume) (Set.inter_subset_right : C i ∩ Set.Icc (0:ℝ) q ⊆ Set.Icc (0:ℝ) q)
        rw [Real.volume_Icc, sub_zero] at hle
        exact ne_top_of_le_ne_top (ENNReal.ofReal_ne_top (r := q)) hle
      have hsum_enn : (∑ i : Fin n, MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q)) = ENNReal.ofReal q := by
        have h := MeasureTheory.measure_iUnion (μ := MeasureTheory.volume) hSdisj hSmeas
        rw [hSunion, Real.volume_Icc, sub_zero] at h
        rw [h, tsum_fintype]
      have hsum_real : (∑ i : Fin n, (MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q)).toReal) = q := by
        have h := ENNReal.toReal_sum (s := Finset.univ) (f := fun i => MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q)) (fun i _ => hSfin i)
        rw [hsum_enn, ENNReal.toReal_ofReal hq0] at h
        simpa using h.symm
  5. Every agent's prefix slice has volume at least (1/n) * (1/n) = 1/n^2.

    Under the lower-bound valuation profile, each agent's valuation of their bundle is concentrated on [0, q] and proportionality ensures 1/n ≤ n * vol(C j ∩ [0, q]) in ENNReal. Since the volume is finite, converting this inequality to real numbers preserves it. Multiplying both sides by the non-negative real factor 1/n gives (1/n) * (1/n) ≤ vol(C j ∩ [0, q]).

    lines 42–55

    uses ENNReal.mul_ne_top, ENNReal.natCast_ne_top, ENNReal.toReal_mono, ENNReal.toReal_div, ENNReal.toReal_mul, ENNReal.toReal_one, ENNReal.toReal_natCast, mul_le_mul_of_nonneg_left

      have hc0 : 0 ≤ (1/(n:ℝ))*(1/(n:ℝ)) := by positivity
      have hlower : ∀ j, (1/(n:ℝ))*(1/(n:ℝ)) ≤ (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal := by
        intro j
        have h1 : (1:ENNReal) / (n:ENNReal) ≤ (n:ENNReal) * MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q) := h_prop j
        have htop : (n:ENNReal) * MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q) ≠ ⊤ :=
          ENNReal.mul_ne_top (ENNReal.natCast_ne_top n) (hSfin j)
        have hreal : (1:ℝ) / (n:ℝ) ≤ (n:ℝ) * (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal := by
          have h2 := ENNReal.toReal_mono htop h1
          rwa [ENNReal.toReal_div, ENNReal.toReal_mul, ENNReal.toReal_one, ENNReal.toReal_natCast] at h2
        have hmul := mul_le_mul_of_nonneg_left hreal (show (0:ℝ) ≤ 1/(n:ℝ) by positivity)
        have hsimp : (1/(n:ℝ)) * ((n:ℝ) * (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal) = (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal := by
          field_simp
        rw [hsimp] at hmul
        exact hmul
  6. Every agent's prefix slice has volume exactly 1/n^2, both as a real number and as an extended real.

    The n prefix volumes sum to q = 1/n = n * (1/n^2), and each term is bounded below by 1/n^2. Consequently, the sum of the non-negative differences vol(C l ∩ [0, q]) - 1/n^2 over all n bundles is zero. Since a sum of non-negative real numbers can only vanish if each term is zero, each slice has real volume exactly 1/n^2. Converting back from ℝ to ENNReal gives vol(C i ∩ [0, q]) = ENNReal.ofReal (1/n^2).

    lines 56–70

    uses Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Finset.sum_sub_distrib, sub_self, Finset.sum_eq_zero_iff_of_nonneg, Finset.mem_univ, ENNReal.ofReal_toReal

      have hzero : ∀ j, (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal = (1/(n:ℝ))*(1/(n:ℝ)) := by
        intro j
        have hqc : q = (n:ℝ) * ((1/(n:ℝ))*(1/(n:ℝ))) := by
          rw [hq]; field_simp
        have hsc : (∑ _l : Fin n, ((1/(n:ℝ))*(1/(n:ℝ)))) = (n:ℝ) * ((1/(n:ℝ))*(1/(n:ℝ))) := by
          rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]
        have hsum_sub : (∑ l : Fin n, ((MeasureTheory.volume (C l ∩ Set.Icc (0:ℝ) q)).toReal - (1/(n:ℝ))*(1/(n:ℝ)))) = 0 := by
          rw [Finset.sum_sub_distrib, hsum_real, hsc, hqc, sub_self]
        have hnonneg : ∀ l ∈ (Finset.univ : Finset (Fin n)), 0 ≤ ((MeasureTheory.volume (C l ∩ Set.Icc (0:ℝ) q)).toReal - (1/(n:ℝ))*(1/(n:ℝ))) := by
          intro l _
          linarith [hlower l]
        have hfinal := (Finset.sum_eq_zero_iff_of_nonneg hnonneg).mp hsum_sub j (Finset.mem_univ j)
        linarith
      have hVj : MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q) = ENNReal.ofReal ((1/(n:ℝ))*(1/(n:ℝ))) := by
        rw [← ENNReal.ofReal_toReal (hSfin i), hzero i]
  7. The bundle C i is the disjoint union of its prefix slice C i ∩ [0, q] and its suffix slice C i ∩ (q, 1].

    Since C i ⊆ [0, 1], every element x ∈ C i lies in [0, 1]. A case split on whether x ≤ q or x > q shows that x belongs to either C i ∩ [0, q] or C i ∩ (q, 1]. The two sets are disjoint because no real number can be both ≤ q and > q.

    lines 71–83

    uses lt_or_ge, Or.inr, Or.inl, Set.disjoint_left, not_lt.mpr

      have hCeq : C i = (C i ∩ Set.Icc (0:ℝ) q) ∪ (C i ∩ Set.Ioc q 1) := by
        ext x; constructor
        · intro hx
          have hx1 := hsub i hx
          rcases lt_or_ge q x with h | h
          · exact Or.inr ⟨hx, h, hx1.2⟩
          · exact Or.inl ⟨hx, hx1.1, h⟩
        · intro hx
          rcases hx with ⟨hx, _⟩ | ⟨hx, _⟩ <;> exact hx
      have hdisj_AB : Disjoint (C i ∩ Set.Icc (0:ℝ) q) (C i ∩ Set.Ioc q 1) := by
        rw [Set.disjoint_left]
        intro x hx hy
        exact absurd hy.2.1 (not_lt.mpr hx.2.2)
  8. The suffix volume vol(C i ∩ (1/n, 1]) is equal to ENNReal.ofReal (1/n - 1/n^2).

    By finite additivity of Lebesgue measure on disjoint sets, vol(C i) = vol(C i ∩ [0, q]) + vol(C i ∩ (q, 1]). Since the allocation is of equal length, vol(C i) = 1/n. Subtracting the prefix volume vol(C i ∩ [0, q]) = 1/n^2 from the total volume 1/n shows that the suffix volume is 1/n - 1/n^2. Subtracting the extended non-negative reals and simplifying the algebraic expression completes the proof.

    lines 84–92

    uses MeasureTheory.measure_union, measurableSet_Ioc, ENNReal.sub_eq_of_eq_add, ENNReal.ofReal_ne_top, add_comm, ENNReal.ofReal_sub

      have hmu := MeasureTheory.measure_union (μ := MeasureTheory.volume) hdisj_AB ((hmeas i).inter measurableSet_Ioc)
      rw [← hCeq, h_len i] at hmu
      rw [hVj] at hmu
      have hres := ENNReal.sub_eq_of_eq_add (a := ENNReal.ofReal (1/(n:ℝ)))
          (b := ENNReal.ofReal ((1/(n:ℝ))*(1/(n:ℝ)))) (c := MeasureTheory.volume (C i ∩ Set.Ioc q 1))
          ENNReal.ofReal_ne_top (by rw [add_comm]; exact hmu)
      rw [← hres, hq, ← ENNReal.ofReal_sub (1/(n:ℝ)) (q := (1/(n:ℝ))*(1/(n:ℝ))) hc0]
      congr 1
      field_simp
add_comm
Addition is commutative: a + b = b + a.
div_le_one
For b > 0, a / b ≤ 1 if and only if a ≤ b.
ENNReal.mul_ne_top
The product of two finite extended non-negative reals is finite.
ENNReal.natCast_ne_top
The coercion of any natural number into the extended non-negative reals is finite (not ⊤).
ENNReal.ofReal_ne_top
For any real number r, ENNReal.ofReal r is finite (not ⊤).
ENNReal.ofReal_sub
For real numbers p and q with 0 ≤ q, ENNReal.ofReal (p - q) = ENNReal.ofReal p - ENNReal.ofReal q.
ENNReal.ofReal_toReal
For any finite extended non-negative real a ≠ ⊤, converting to a real and back to ENNReal returns a.
ENNReal.sub_eq_of_eq_add
If b ≠ ⊤ and a = c + b in ENNReal, then a - b = c.
ENNReal.toReal_div
The real value of a quotient of extended non-negative reals is the quotient of their real values.
ENNReal.toReal_mono
For extended non-negative reals a ≤ b, if b ≠ ⊤, then a.toReal ≤ b.toReal.
ENNReal.toReal_mul
The real value of a product of extended non-negative reals is the product of their real values.
ENNReal.toReal_natCast
The real value of n : ℕ cast into ENNReal equals n cast into ℝ.
ENNReal.toReal_ofReal
For any real r ≥ 0, the real value of ENNReal.ofReal r is r.
ENNReal.toReal_one
The real value of 1 in ENNReal is 1 in ℝ.
ENNReal.toReal_sum
The real value of a finite sum of extended non-negative reals is the sum of their real values, provided every term is finite.
Finset.card_univ
The cardinality of the universal set of a finite type equals the cardinality of the type.
Finset.mem_univ
Every element of a finite type belongs to its universal Finset.
Finset.sum_const
The sum of a constant over a finite set equals the cardinality of the set times the constant.
Finset.sum_eq_zero_iff_of_nonneg
A sum of non-negative elements over a finite set is zero if and only if every term is zero.
Finset.sum_sub_distrib
The sum of differences over a finite set distributes into the difference of the sums.
Finset.univ
The universal finite set containing all terms of a finite type.
Fintype.card_fin
The cardinality of Fin n is n.
le_trans
Transitivity of the order relation: if a ≤ b and b ≤ c, then a ≤ c.
lt_or_ge
In any linear order, either a < b or b ≤ a.
measurableSet_Icc
A closed interval [a, b] is a measurable set.
measurableSet_Ioc
A half-open interval (a, b] is a measurable set.
MeasureTheory.measure_iUnion
The measure of a countable pairwise disjoint union of measurable sets equals the sum of their measures.
MeasureTheory.measure_mono
Lebesgue measure is monotone: if s ⊆ t, then μ(s) ≤ μ(t).
MeasureTheory.measure_union
The measure of the union of two disjoint measurable sets equals the sum of their measures.
mul_le_mul_of_nonneg_left
Multiplying both sides of an inequality b ≤ c by a non-negative number a ≥ 0 preserves the inequality: a * b ≤ a * c.
ne_top_of_le_ne_top
In a partial order with a top element ⊤, if b ≠ ⊤ and a ≤ b, then a ≠ ⊤.
not_lt.mpr
In a linear order, if b ≤ a, then not a < b.
nsmul_eq_mul
Multiplying a ring element by a natural number scalar n • a is equal to (n : α) * a.
Or.inl
From a proof of A, infer the disjunction A ∨ B.
Or.inr
From a proof of B, infer the disjunction A ∨ B.
Real.volume_Icc
The Lebesgue volume of a closed interval [a, b] is ENNReal.ofReal (b - a).
Set.disjoint_left
Two sets s and t are disjoint if and only if no element of s belongs to t.
Set.inter_eq_right.mpr
If t ⊆ s, then s ∩ t = t.
Set.inter_subset_left
The intersection s ∩ t is a subset of s.
Set.inter_subset_right
The intersection s ∩ t is a subset of t.
Set.iUnion_inter
Intersection distributes over an indexed union of sets: (⋃ i, t i) ∩ s = ⋃ i, (t i ∩ s).
Set.subset_iUnion
Each set in an indexed family is a subset of the union of the family.
sub_self
Subtracting an element from itself yields zero: a - a = 0.
sub_zero
Subtracting zero leaves an element unchanged: a - 0 = a.
tsum_fintype
An infinite sum over a finite index type equals the finite sum.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

/-- In any equal-length proportional allocation under the lower-bound valuation profile, each bundle has suffix volume 1/n - 1/n^2. -/theorem equal_length_proportional_cake_suffix_volume (n : ℕ) (hn : 1 ≤ n)    (C : Fin n → Set ℝ)    (h_alloc : is_cake_allocation n C)    (h_len : is_equal_length_allocation n C)    (h_prop : is_prop_lb_proportional n C)    (i : Fin n) :    MeasureTheory.volume (C i ∩ Set.Ioc (1 / (n : ℝ)) 1) =      ENNReal.ofReal (1 / (n : ℝ) - 1 / ((n : ℝ) ^ 2)) := by  have hn1 : (1:ℝ) ≤ (n:ℝ) := by exact_mod_cast hn  have hnpos : (0:ℝ) < (n:ℝ) := by linarith  obtain ⟨hmeas, hdisj, hunion⟩ := h_alloc  have hsub : ∀ i : Fin n, C i ⊆ Set.Icc (0:ℝ) 1 := by    intro i x hx    rw [← hunion]    exact Set.subset_iUnion C i hx  set q : ℝ := 1 / (n:ℝ) with hq  have hq0 : 0 ≤ q := by rw [hq]; positivity  have hq1 : q ≤ 1 := by    rw [hq, div_le_one hnpos]    exact hn1  have hSmeas : ∀ i, MeasurableSet (C i ∩ Set.Icc (0:ℝ) q) := fun i => (hmeas i).inter measurableSet_Icc  have hSdisj : Pairwise (Function.onFun Disjoint (fun i => C i ∩ Set.Icc (0:ℝ) q)) := by    intro i j hij    exact (hdisj i j hij).mono Set.inter_subset_left Set.inter_subset_left  have hSunion : (⋃ i : Fin n, (C i ∩ Set.Icc (0:ℝ) q)) = Set.Icc (0:ℝ) q := by    rw [← Set.iUnion_inter, hunion]    exact Set.inter_eq_right.mpr (fun x hx => ⟨hx.1, le_trans hx.2 hq1⟩)  have hSfin : ∀ i, MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q) ≠ ⊤ := by    intro i    have hle := MeasureTheory.measure_mono (μ := MeasureTheory.volume) (Set.inter_subset_right : C i ∩ Set.Icc (0:ℝ) q ⊆ Set.Icc (0:ℝ) q)    rw [Real.volume_Icc, sub_zero] at hle    exact ne_top_of_le_ne_top (ENNReal.ofReal_ne_top (r := q)) hle  have hsum_enn : (∑ i : Fin n, MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q)) = ENNReal.ofReal q := by    have h := MeasureTheory.measure_iUnion (μ := MeasureTheory.volume) hSdisj hSmeas    rw [hSunion, Real.volume_Icc, sub_zero] at h    rw [h, tsum_fintype]  have hsum_real : (∑ i : Fin n, (MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q)).toReal) = q := by    have h := ENNReal.toReal_sum (s := Finset.univ) (f := fun i => MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q)) (fun i _ => hSfin i)    rw [hsum_enn, ENNReal.toReal_ofReal hq0] at h    simpa using h.symm  have hc0 : 0 ≤ (1/(n:ℝ))*(1/(n:ℝ)) := by positivity  have hlower : ∀ j, (1/(n:ℝ))*(1/(n:ℝ)) ≤ (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal := by    intro j    have h1 : (1:ENNReal) / (n:ENNReal) ≤ (n:ENNReal) * MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q) := h_prop j    have htop : (n:ENNReal) * MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q) ≠ ⊤ :=      ENNReal.mul_ne_top (ENNReal.natCast_ne_top n) (hSfin j)    have hreal : (1:ℝ) / (n:ℝ) ≤ (n:ℝ) * (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal := by      have h2 := ENNReal.toReal_mono htop h1      rwa [ENNReal.toReal_div, ENNReal.toReal_mul, ENNReal.toReal_one, ENNReal.toReal_natCast] at h2    have hmul := mul_le_mul_of_nonneg_left hreal (show (0:ℝ) ≤ 1/(n:ℝ) by positivity)    have hsimp : (1/(n:ℝ)) * ((n:ℝ) * (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal) = (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal := by      field_simp    rw [hsimp] at hmul    exact hmul  have hzero : ∀ j, (MeasureTheory.volume (C j ∩ Set.Icc (0:ℝ) q)).toReal = (1/(n:ℝ))*(1/(n:ℝ)) := by    intro j    have hqc : q = (n:ℝ) * ((1/(n:ℝ))*(1/(n:ℝ))) := by      rw [hq]; field_simp    have hsc : (∑ _l : Fin n, ((1/(n:ℝ))*(1/(n:ℝ)))) = (n:ℝ) * ((1/(n:ℝ))*(1/(n:ℝ))) := by      rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]    have hsum_sub : (∑ l : Fin n, ((MeasureTheory.volume (C l ∩ Set.Icc (0:ℝ) q)).toReal - (1/(n:ℝ))*(1/(n:ℝ)))) = 0 := by      rw [Finset.sum_sub_distrib, hsum_real, hsc, hqc, sub_self]    have hnonneg : ∀ l ∈ (Finset.univ : Finset (Fin n)), 0 ≤ ((MeasureTheory.volume (C l ∩ Set.Icc (0:ℝ) q)).toReal - (1/(n:ℝ))*(1/(n:ℝ))) := by      intro l _      linarith [hlower l]    have hfinal := (Finset.sum_eq_zero_iff_of_nonneg hnonneg).mp hsum_sub j (Finset.mem_univ j)    linarith  have hVj : MeasureTheory.volume (C i ∩ Set.Icc (0:ℝ) q) = ENNReal.ofReal ((1/(n:ℝ))*(1/(n:ℝ))) := by    rw [← ENNReal.ofReal_toReal (hSfin i), hzero i]  have hCeq : C i = (C i ∩ Set.Icc (0:ℝ) q) ∪ (C i ∩ Set.Ioc q 1) := by    ext x; constructor    · intro hx      have hx1 := hsub i hx      rcases lt_or_ge q x with h | h      · exact Or.inr ⟨hx, h, hx1.2⟩      · exact Or.inl ⟨hx, hx1.1, h⟩    · intro hx      rcases hx with ⟨hx, _⟩ | ⟨hx, _⟩ <;> exact hx  have hdisj_AB : Disjoint (C i ∩ Set.Icc (0:ℝ) q) (C i ∩ Set.Ioc q 1) := by    rw [Set.disjoint_left]    intro x hx hy    exact absurd hy.2.1 (not_lt.mpr hx.2.2)  have hmu := MeasureTheory.measure_union (μ := MeasureTheory.volume) hdisj_AB ((hmeas i).inter measurableSet_Ioc)  rw [← hCeq, h_len i] at hmu  rw [hVj] at hmu  have hres := ENNReal.sub_eq_of_eq_add (a := ENNReal.ofReal (1/(n:ℝ)))      (b := ENNReal.ofReal ((1/(n:ℝ))*(1/(n:ℝ)))) (c := MeasureTheory.volume (C i ∩ Set.Ioc q 1))      ENNReal.ofReal_ne_top (by rw [add_comm]; exact hmu)  rw [← hres, hq, ← ENNReal.ofReal_sub (1/(n:ℝ)) (q := (1/(n:ℝ))*(1/(n:ℝ))) hc0]  congr 1  field_simp
See it in the graphDiscuss this resultChallenge it