Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Entropy, box counts, and cost exponents for the sharp-tail analysis

Definition
ThreeSumSharpTail_Analysis

by Yuxuan Xu · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

3sumbinomial-tailscomplexityentropy

Defines H(x)=−xlog⁡x−(1−x)log⁡(1−x)H(x)=-x\log x-(1-x)\log(1-x)H(x)=−xlogx−(1−x)log(1−x) (so H(0)=H(1)=0H(0)=H(1)=0H(0)=H(1)=0), the old preprocessing saving γ(c,θ)=θlog⁡((c−1)/9)/log⁡4\gamma(c,\theta)=\theta\log((c-1)/9)/\log4γ(c,θ)=θlog((c−1)/9)/log4, the sharp saving γ∗(c,θ)=[cH(1/c)−cH((1−θ)/c)−θlog⁡9]/log⁡4\gamma_*(c,\theta)=[cH(1/c)-cH((1-\theta)/c)-\theta\log9]/\log4γ∗​(c,θ)=[cH(1/c)−cH((1−θ)/c)−θlog9]/log4, the query exponent q(θ)=[H(θ)+θlog⁡9]/log⁡4q(\theta)=[H(\theta)+\theta\log9]/\log4q(θ)=[H(θ)+θlog9]/log4, and the encoding exponent A(c)=[clog⁡10−cH(1/c)/2−(c−1)log⁡3]/log⁡4A(c)=[c\log10-cH(1/c)/2-(c-1)\log3]/\log4A(c)=[clog10−cH(1/c)/2−(c−1)log3]/log4. For natural numbers c,m,dc,m,dc,m,d, defines βd=(cmm−d)9cm−m+d\beta_d=\binom{cm}{m-d}9^{cm-m+d}βd​=(m−dcm​)9cm−m+d; later lemmas restrict to c>10c>10c>10, m≥1m\ge1m≥1 and d≤md\le md≤m. These are auxiliary analytic quantities, not a replacement for the campaign's shared word-RAM or 3SUM definitions. Real logarithms and division are total in Lean; intended domains are supplied by theorem hypotheses.

Definition code
import Mathlib

set_option autoImplicit false
set_option relaxedAutoImplicit false

namespace ThreeSumSharpTail

noncomputable def entropy (x : ℝ) : ℝ :=
  -x * Real.log x - (1 - x) * Real.log (1 - x)

noncomputable def oldSaving (c θ : ℝ) : ℝ :=
  θ * Real.log ((c - 1) / 9) / Real.log 4

noncomputable def sharpSaving (c θ : ℝ) : ℝ :=
  (c * entropy (1 / c) - c * entropy ((1 - θ) / c) - θ * Real.log 9) / Real.log 4

noncomputable def queryExponent (θ : ℝ) : ℝ :=
  (entropy θ + θ * Real.log 9) / Real.log 4

noncomputable def encodingExponent (c : ℝ) : ℝ :=
  (c * Real.log 10 - c * entropy (1 / c) / 2 - (c - 1) * Real.log 3) / Real.log 4

def boxCount (c m d : ℕ) : ℕ :=
  Nat.choose (c * m) (m - d) * 9 ^ (c * m - m + d)

end ThreeSumSharpTail
Source
Yuxuan Xu, Deterministic Integer 3SUM in O(n^1.999017) Time via a Sharper Binomial-Tail Analysis (13 October 2026), Hexagon submission https://hexagonmath.org/submit/d57cba23-2d89-4bcb-8180-7c1bde7d14e3; Sections 2 and 3.
Read-back

What the Lean code literally says, in plain math · gpt-6

For every real number xxx, define H(x)=−xlog⁡x−(1−x)log⁡(1−x)H(x)=-x\log x-(1-x)\log(1-x)H(x)=−xlogx−(1−x)log(1−x). Here and throughout these definitions, log⁡\loglog is the total real logarithm: it is the natural logarithm on positive arguments, is 000 at 000, and equals log⁡∣x∣\log|x|log∣x∣ on negative arguments. Thus HHH is defined on all real numbers, not only [0,1][0,1][0,1], and H(0)=H(1)=0H(0)=H(1)=0H(0)=H(1)=0.

For arbitrary real numbers ccc and θ\thetaθ, define O(c,θ)=θlog⁡((c−1)/9)/log⁡4O(c,\theta)=\theta\log((c-1)/9)/\log4O(c,θ)=θlog((c−1)/9)/log4. No restriction on either argument is imposed.

For arbitrary real numbers ccc and θ\thetaθ, define S(c,θ)=[cH(1/c)−cH((1−θ)/c)−θlog⁡9]/log⁡4S(c,\theta)=[cH(1/c)-cH((1-\theta)/c)-\theta\log9]/\log4S(c,θ)=[cH(1/c)−cH((1−θ)/c)−θlog9]/log4, where H(x)=−xlog⁡x−(1−x)log⁡(1−x)H(x)=-x\log x-(1-x)\log(1-x)H(x)=−xlogx−(1−x)log(1−x). Real division is total, with division by 000 equal to 000, so this formula also defines S(0,θ)=−θlog⁡9/log⁡4S(0,\theta)=-\theta\log9/\log4S(0,θ)=−θlog9/log4.

For every real number θ\thetaθ, define Q(θ)=[H(θ)+θlog⁡9]/log⁡4Q(\theta)=[H(\theta)+\theta\log9]/\log4Q(θ)=[H(θ)+θlog9]/log4, where H(x)=−xlog⁡x−(1−x)log⁡(1−x)H(x)=-x\log x-(1-x)\log(1-x)H(x)=−xlogx−(1−x)log(1−x); there is no interval restriction on θ\thetaθ.

For every real number ccc, define E(c)=[clog⁡10−cH(1/c)/2−(c−1)log⁡3]/log⁡4E(c)=[c\log10-cH(1/c)/2-(c-1)\log3]/\log4E(c)=[clog10−cH(1/c)/2−(c−1)log3]/log4, where H(x)=−xlog⁡x−(1−x)log⁡(1−x)H(x)=-x\log x-(1-x)\log(1-x)H(x)=−xlogx−(1−x)log(1−x) and division by zero is zero. In particular, c=0c=0c=0 is included and gives E(0)=log⁡3/log⁡4E(0)=\log3/\log4E(0)=log3/log4.

For all natural numbers c,m,dc,m,dc,m,d, including zero and without assuming d≤md\le md≤m or c≥1c\ge1c≥1, define B(c,m,d)=(cmmax⁡(m−d,0))9max⁡(cm−m,0)+dB(c,m,d)=\binom{cm}{\max(m-d,0)}9^{\max(cm-m,0)+d}B(c,m,d)=(max(m−d,0)cm​)9max(cm−m,0)+d. The subtractions inside the original natural-number expression are truncated at zero, and the exponent subtracts mmm before adding ddd. The binomial coefficient is zero when its lower argument exceeds its upper argument. Consequently B(c,0,d)=9dB(c,0,d)=9^dB(c,0,d)=9d, and if d>md>md>m the lower binomial argument is 000, so B(c,m,d)=9max⁡(cm−m,0)+dB(c,m,d)=9^{\max(cm-m,0)+d}B(c,m,d)=9max(cm−m,0)+d; these values are part of the definition even outside a tail range.

Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Yuxuan Xu · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me