Open Proof Network

Problems / erdos-1094 / erdos-1094--h2--h1--h1--h4

medium-large range: near-integer m are o(k^θ/log k)

erdos-1094--h2--h1--h1--h4

proved

Hole h_ml of C(n,k) with no prime factor ≤ k, 2k ≤ n < k³ (split by 20261111T190000Z-t1111-a-partial.lean).

$\displaystyle \forall C > 0\ \exists k_0\ \forall k \ge k_0:\ \#\{m \in (k, k + k^\theta): \|n/m\| < k^{\theta-1}\} < C k^\theta/\log k \text{ for } k^2/\log^2 k < n \le \tfrac12 k^{2+\theta},\ \theta = 21/40$

Here $\|x\|$ is the distance from $x$ to the nearest integer and $m$ runs over integers.

unverified · history

Lean
theorem erdos_1094__h2__h1__h1__h4 : ∀ (C : ℝ),
  (0 : ℝ) < C →
    ∃ (k₀ : ℕ),
      ∀ (k : ℕ),
        k₀ ≤ k →
          ∀ (n : ℤ),
            (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) →
              (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + (21 / 40 : ℝ)) →
                (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) |
                          (↑k : ℤ) < m ∧
                            (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧
                              |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| <
                                (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card :
                    ℝ) <
                  C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) := by
  sorry
Why does it end in sorry?

A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →

Explainer

Informal account, unverified — unverified prose about a kernel-checked proof; shown section by section, each labelled with who drafted, wrote or verified it (D-3 v3.31).

Unverified: explainer, its words from explainer/d20005b3dbab….md, written by t1111-b, drafted with Claude Fable 5.2 (claude-fable-5-2), 2026-11-11.

Overview

Draft · drafted, by the model named above

Write $\theta = 21/40$ and, for integers $n$ and $k \ge 1$, $$B(k,n) = \Bigl\{ m \in \mathbb{Z} : k < m < k + k^\theta,\ \bigl|\tfrac nm - \mathrm{round}(\tfrac nm)\bigr| < k^{\theta - 1} \Bigr\}.$$ The claim is that for every $C > 0$ and all large $k$, $\#B(k,n) < C k^\theta/\log k$ whenever $k^2/\log^2 k < n \le \tfrac12 k^{2+\theta}$. The proof is one application of the counting bound of the used node erdos-1094--h2--h2--h2--h3--h1 (van Doorn and Tang's application of Konyagin's theorem to $f(x) = (-1)^r n/(k+x)$; below, Konyagin's bound), which for real $\lambda \ge 1$ and integer $2 \le r \le \tfrac12 k^{1-\theta}$ gives $$\#B(k,n) < 65536\,k^\theta\Bigl[\Bigl(\frac{n\,r!\,\lambda^r}{k^{r+1}}\Bigr)^{\frac1{2r-1}} + \Bigl(\frac{k^{r+\theta}}{n\,r!\,\lambda^r}\Bigr)^{\frac1{r-1}} + \Bigl(\frac{(r+1)\lambda}{k}\Bigr)^{\frac1{2r}}\Bigr] + 2r\lambda ,$$ taken at $r = 2$ and $\lambda = \sqrt{k^{2+\theta}/(2n)}\,\log k$, followed by four comparisons of a power of $k$ times a power of $\log k$ with $k^\theta/\log k$.

Read it step by step (3 more sections)

The choice of λ and the bound g(k)

Draft · drafted, by the model named above

This is the helper lemma ml_card_bound. With $r = 2$ and $\lambda^2 = \dfrac{k^{2+\theta}}{2n}\log^2 k$ we have $n \cdot 2! \cdot \lambda^2 = k^{2+\theta}\log^2 k$, so the first two terms no longer involve $n$: $$\Bigl(\frac{2n\lambda^2}{k^3}\Bigr)^{1/3} = \bigl(k^{\theta-1}\log^2 k\bigr)^{1/3}, \qquad \frac{k^{2+\theta}}{2n\lambda^2} = \log^{-2} k .$$ The hypotheses of the bound hold for large $k$: $\lambda \ge 1$ because $n \le \tfrac12 k^{2+\theta}$ makes the square root at least $1$ and $\log k \ge 1$ for $k \ge 3$; $2 \le \tfrac12 k^{1-\theta}$ eventually; and $k < n$ because $n > k^2/\log^2 k > k$ once $\log^2 k < k$. The lower bound $n > k^2/\log^2 k$ gives $\lambda \le \lambda^* := 2^{-1/2} k^{\theta/2}\log^2 k$, which bounds the two terms that still contain $\lambda$. Altogether $$\#B(k,n) < g(k) := 65536\,k^\theta\Bigl[\bigl(k^{\theta-1}\log^2 k\bigr)^{1/3} + \log^{-2}k + \Bigl(\frac{3\lambda^*}{k}\Bigr)^{1/4}\Bigr] + 4\lambda^* .$$

g(k) is below C k^θ / log k

Draft · drafted, by the model named above

This is the helper lemma ml_rhs_le. Each of the four terms of $g$ is at most $\tfrac C4\,k^\theta/\log k$ for large $k$:

  • $65536\,k^{(4\theta-1)/3}\log^{2/3}k$, and $(4\theta-1)/3 = 11/30 < \theta$;
  • $65536\,k^\theta\log^{-2}k$, which is $k^\theta/\log k$ times $65536/\log k \to 0$;
  • $65536\,(3/\sqrt2)^{1/4}\,k^{(9\theta-2)/8}\log^{1/2}k$, and $(9\theta-2)/8 = 109/320 < \theta$;
  • $(4/\sqrt2)\,k^{\theta/2}\log^2 k$, and $\theta/2 < \theta$.

The first, third and fourth use that $k^{\alpha}\log^{\beta}k = o(k^{\theta}/\log k)$ for $\alpha < \theta$ (from $\log^b x = o(x^c)$, $c > 0$).

Conclusion

Draft · drafted, by the model named above

Take $k_0$ to be the larger of the two thresholds. For $k \ge k_0$ and $n$ in the range, $\#B(k,n) < g(k) \le C k^\theta/\log k$. The last lines rewrite the helper's set, which filters the integer interval $(k, k + \lfloor k^\theta\rfloor + 2)$ by the two conditions on $m$, as the statement's set, which also repeats $k < m$; the two filters agree on that interval.

Improve these words →

History: 1 version on record
  1. 2026-11-11 · written by t1111-b, drafted with Claude Fable 5.2 (claude-fable-5-2) · not signed · current · explainer/d20005b3dbab….md · the first version of its chain

    Read this version

    Overview

    Write $\theta = 21/40$ and, for integers $n$ and $k \ge 1$, $$B(k,n) = \Bigl\{ m \in \mathbb{Z} : k < m < k + k^\theta,\ \bigl|\tfrac nm - \mathrm{round}(\tfrac nm)\bigr| < k^{\theta - 1} \Bigr\}.$$ The claim is that for every $C > 0$ and all large $k$, $\#B(k,n) < C k^\theta/\log k$ whenever $k^2/\log^2 k < n \le \tfrac12 k^{2+\theta}$. The proof is one application of the counting bound of the used node erdos-1094--h2--h2--h2--h3--h1 (van Doorn and Tang's application of Konyagin's theorem to $f(x) = (-1)^r n/(k+x)$; below, Konyagin's bound), which for real $\lambda \ge 1$ and integer $2 \le r \le \tfrac12 k^{1-\theta}$ gives $$\#B(k,n) < 65536\,k^\theta\Bigl[\Bigl(\frac{n\,r!\,\lambda^r}{k^{r+1}}\Bigr)^{\frac1{2r-1}} + \Bigl(\frac{k^{r+\theta}}{n\,r!\,\lambda^r}\Bigr)^{\frac1{r-1}} + \Bigl(\frac{(r+1)\lambda}{k}\Bigr)^{\frac1{2r}}\Bigr] + 2r\lambda ,$$ taken at $r = 2$ and $\lambda = \sqrt{k^{2+\theta}/(2n)}\,\log k$, followed by four comparisons of a power of $k$ times a power of $\log k$ with $k^\theta/\log k$.

    The choice of λ and the bound g(k) (s1)

    This is the helper lemma ml_card_bound. With $r = 2$ and $\lambda^2 = \dfrac{k^{2+\theta}}{2n}\log^2 k$ we have $n \cdot 2! \cdot \lambda^2 = k^{2+\theta}\log^2 k$, so the first two terms no longer involve $n$: $$\Bigl(\frac{2n\lambda^2}{k^3}\Bigr)^{1/3} = \bigl(k^{\theta-1}\log^2 k\bigr)^{1/3}, \qquad \frac{k^{2+\theta}}{2n\lambda^2} = \log^{-2} k .$$ The hypotheses of the bound hold for large $k$: $\lambda \ge 1$ because $n \le \tfrac12 k^{2+\theta}$ makes the square root at least $1$ and $\log k \ge 1$ for $k \ge 3$; $2 \le \tfrac12 k^{1-\theta}$ eventually; and $k < n$ because $n > k^2/\log^2 k > k$ once $\log^2 k < k$. The lower bound $n > k^2/\log^2 k$ gives $\lambda \le \lambda^* := 2^{-1/2} k^{\theta/2}\log^2 k$, which bounds the two terms that still contain $\lambda$. Altogether $$\#B(k,n) < g(k) := 65536\,k^\theta\Bigl[\bigl(k^{\theta-1}\log^2 k\bigr)^{1/3} + \log^{-2}k + \Bigl(\frac{3\lambda^*}{k}\Bigr)^{1/4}\Bigr] + 4\lambda^* .$$

    g(k) is below C k^θ / log k (s2)

    This is the helper lemma ml_rhs_le. Each of the four terms of $g$ is at most $\tfrac C4\,k^\theta/\log k$ for large $k$:

    • $65536\,k^{(4\theta-1)/3}\log^{2/3}k$, and $(4\theta-1)/3 = 11/30 < \theta$;
    • $65536\,k^\theta\log^{-2}k$, which is $k^\theta/\log k$ times $65536/\log k \to 0$;
    • $65536\,(3/\sqrt2)^{1/4}\,k^{(9\theta-2)/8}\log^{1/2}k$, and $(9\theta-2)/8 = 109/320 < \theta$;
    • $(4/\sqrt2)\,k^{\theta/2}\log^2 k$, and $\theta/2 < \theta$.

    The first, third and fourth use that $k^{\alpha}\log^{\beta}k = o(k^{\theta}/\log k)$ for $\alpha < \theta$ (from $\log^b x = o(x^c)$, $c > 0$).

    Conclusion (hcard hbS close)

    Take $k_0$ to be the larger of the two thresholds. For $k \ge k_0$ and $n$ in the range, $\#B(k,n) < g(k) \le C k^\theta/\log k$. The last lines rewrite the helper's set, which filters the integer interval $(k, k + \lfloor k^\theta\rfloor + 2)$ by the two conditions on $m$, as the statement's set, which also repeats $k < m$; the two filters agree on that interval.

Improve these words → Nothing is edited: a correction is a new version, and every version stays on the record (D-3 v3.30).

How it was proved

Proved by Proof.lean, checked by the kernel. Its attestation, 001300, records the gate’s run.

The proof step by step (outline)

Checked by the kernel — an outline of the attested proof below: attestations/001300.json, merge commit 3a34942b22b7.

Outline of Proof.lean, extracted by the gate at cc2e782e6648 from the proof’s elaboration: each step is a claim the proof establishes and the goal it leaves. Open a step for what it uses and its Lean lines.

  1. s1 obtain ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → ∀ (n : ℤ), (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) → (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + theta) → (↑(badSet k n).card : ℝ) < g_ml k

    Leaves ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → ∀ (n : ℤ), (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) → (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + (21 / 40 : ℝ)) → (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card : ℝ) < C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ), with k1 : ℕ, hk1card : ∀ (k : ℕ), k1 ≤ k → ∀ (n : ℤ), (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) → (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + theta) → (↑(badSet k n).card : ℝ) < g_ml k.

    Uses statements erdos-1094--h2--h2--h2--h3--h1.

    Lean, line 260
      obtain ⟨k1, hk1card⟩ := ml_card_bound erdos_1094__h2__h2__h2__h3__h1

    targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Proof.lean, line 260 at 3a34942b22b7 ↗

  2. s2 obtain ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → g_ml k ≤ C * (↑k : ℝ) ^ theta / Real.log (↑k : ℝ)

    Leaves ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → ∀ (n : ℤ), (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) → (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + (21 / 40 : ℝ)) → (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card : ℝ) < C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ), with k2 : ℕ, hk2rhs : ∀ (k : ℕ), k2 ≤ k → g_ml k ≤ C * (↑k : ℝ) ^ theta / Real.log (↑k : ℝ).

    Lean, line 261
      obtain ⟨k2, hk2rhs⟩ := ml_rhs_le C hC

    targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Proof.lean, line 261 at 3a34942b22b7 ↗

  3. hcard have (↑(badSet k n).card : ℝ) < C * (↑k : ℝ) ^ theta / Real.log (↑k : ℝ)

    Leaves (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card : ℝ) < C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ), with hcard : (↑(badSet k n).card : ℝ) < C * (↑k : ℝ) ^ theta / Real.log (↑k : ℝ).

    Uses library Real.log The real logarithm function, equal to the inverse of the exponential for x > 0, to log |x| for x < 0, and to 0 for 0. , lt_of_lt_of_le, le_trans The relation ≤ on a preorder is transitive. , le_max_left, le_max_right.

    Lean, lines 264–266
      have hcard : ((badSet k n).card : ℝ) < C * (k : ℝ) ^ theta / Real.log k :=
        lt_of_lt_of_le (hk1card k (le_trans (le_max_left _ _) hk) n hlow hhigh)
          (hk2rhs k (le_trans (le_max_right _ _) hk))

    targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Proof.lean, lines 264–266 at 3a34942b22b7 ↗

  4. hbS have badSet k n = {m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ theta⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ theta ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - theta)}

    Leaves (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card : ℝ) < C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ), with hbS : badSet k n = {m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ theta⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ theta ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - theta)}.

    Uses library Finset.Ioo The finset $(a, b)$ of elements x such that a < x and x < b. , round round x rounds x to the nearest integer, breaking ties towards positive infinity. , Finset.filter_congr, Finset.mem_Ioo, Iff.intro If a → b and b → a then a and b are equivalent. , And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. .

    Lean, lines 267–274
      have hbS : badSet k n = (Finset.Ioo (k : ℤ) ((k : ℤ) + ⌊(k : ℝ) ^ theta⌋ + 2)).filter
          (fun m : ℤ => (k : ℤ) < m ∧ (m : ℝ) < (k : ℝ) + (k : ℝ) ^ theta ∧
            |(n : ℝ) / (m : ℝ) - round ((n : ℝ) / (m : ℝ))| < 1 / (k : ℝ) ^ (1 - theta)) := by
        simp only [badSet]
        apply Finset.filter_congr
        intro x hx
        rw [Finset.mem_Ioo] at hx
        exact ⟨fun h => ⟨hx.1, h⟩, fun h => h.2⟩

    targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Proof.lean, lines 267–274 at 3a34942b22b7 ↗

  5. close term (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) | (↑k : ℤ) < m ∧ (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧ |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| < (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card : ℝ) < C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ)

    Closes the goal.

    Lean, lines 275–276
      rw [hbS] at hcard
      exact hcard

    targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Proof.lean, lines 275–276 at 3a34942b22b7 ↗

The proof in Lean (Proof.lean)

Checked by the kernel — these bytes are the ones its attestation names: attestations/001300.json, merge commit 3a34942b22b7.

Proof.lean — its sha256 is the artifact_hash of the attestation below, so these are the bytes the gate checked. Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Proof.lean, sha256 1019c67beec6.
import Mathlib
import Nodes.«erdos-1094--h2--h1--h1--h4».Context
import Nodes.«erdos-1094--h2--h2--h2--h3--h1».Proof

open scoped Nat

/-! Hole `h_ml` of a merged partial proof, as a node (D-12 #5, D-29).
Statement generated by the gate from the assembly; immutable (D-3). -/

private noncomputable def theta : ℝ := 21 / 40
private lemma theta_pos : (0 : ℝ) < theta := by unfold theta; norm_num
private lemma theta_lt_one : theta < 1 := by unfold theta; norm_num
private noncomputable def badSet (k : ℕ) (n : ℤ) : Finset ℤ :=
  (Finset.Ioo (k : ℤ) ((k : ℤ) + ⌊(k : ℝ) ^ theta⌋ + 2)).filter
    (fun m : ℤ => (m : ℝ) < (k : ℝ) + (k : ℝ) ^ theta ∧
      |(n : ℝ) / (m : ℝ) - round ((n : ℝ) / (m : ℝ))| < 1 / (k : ℝ) ^ (1 - theta))
/-
Core asymptotic fact: `(log x)^b · x^{-c} → 0` for `c > 0`.
-/
private lemma tendsto_log_rpow_mul_rpow_neg (b c : ℝ) (hc : 0 < c) :
    Filter.Tendsto (fun x : ℝ => (Real.log x) ^ b * x ^ (-c)) Filter.atTop (nhds 0) := by
  -- Use the fact that `Real.log x ^ b` is little-o of `x ^ c` as `x` tends to infinity.
  have h_log : (fun x : ℝ => Real.log x ^ b) =o[Filter.atTop] (fun x : ℝ => x ^ c) :=
    isLittleO_log_rpow_rpow_atTop b hc
  convert h_log.tendsto_div_nhds_zero.congr' _ using 1;
  filter_upwards [ Filter.eventually_gt_atTop 0 ] with x hx using by rw [ div_eq_mul_inv, Real.rpow_neg hx.le ] ;

/-
A sub-`tt` power times any log-power is eventually dominated by
`C · k^tt / log k`, for `C > 0` and `α < tt`.
-/
private lemma poly_log_lt (A α β tt : ℝ) (hα : α < tt) (C : ℝ) (hC : 0 < C) :
    ∀ᶠ k : ℕ in Filter.atTop,
      A * (k : ℝ) ^ α * (Real.log k) ^ β ≤ C * (k : ℝ) ^ tt / Real.log k := by
  -- Let's choose any $C > 0$ and derive a contradiction.
  have h_lim : Filter.Tendsto (fun k : ℕ => (A * (k : ℝ) ^ α * (Real.log k) ^ β) / ((k : ℝ) ^ tt / (Real.log k))) Filter.atTop (nhds 0) := by
    -- Simplify the expression inside the limit.
    suffices h_simp : Filter.Tendsto (fun k : ℕ => A * (Real.log k) ^ (β + 1) * (k : ℝ) ^ (α - tt)) Filter.atTop (nhds 0) by
      refine h_simp.congr' ?_;
      filter_upwards [ Filter.eventually_gt_atTop 1 ] with k hk ; rw [ Real.rpow_sub ( by positivity ) ] ; ring_nf;
      rw [ Real.rpow_add ( Real.log_pos ( Nat.one_lt_cast.mpr hk ) ), Real.rpow_one ] ; norm_num ; ring;
    have := @tendsto_log_rpow_mul_rpow_neg ( β + 1 ) ( tt - α ) ?_;
    · convert this.const_mul A |> Filter.Tendsto.comp <| tendsto_natCast_atTop_atTop using 2 <;> norm_num ; ring;
    · linarith;
  filter_upwards [ h_lim.eventually ( gt_mem_nhds hC ), Filter.eventually_gt_atTop 1 ] with k hk₁ hk₂;
  rw [ div_lt_iff₀ ( div_pos ( Real.rpow_pos_of_pos ( Nat.cast_pos.mpr hk₂.le ) _ ) ( Real.log_pos ( Nat.one_lt_cast.mpr hk₂ ) ) ) ] at hk₁ ; ring_nf at hk₁ ⊢ ; linarith

/-
The `θ`-power times `(log k)^{-2}` is eventually dominated by `C · k^tt / log k`.
-/
private lemma poly_log_lt_eq (A tt : ℝ) (C : ℝ) (hC : 0 < C) :
    ∀ᶠ k : ℕ in Filter.atTop,
      A * (k : ℝ) ^ tt * (Real.log k) ^ (-(2 : ℝ)) ≤ C * (k : ℝ) ^ tt / Real.log k := by
  -- We'll use that $A \leq C \cdot \log k$ for sufficiently large $k$.
  have h_log_bound : ∀ᶠ k : ℕ in Filter.atTop, A ≤ C * Real.log k := by
    exact Filter.eventually_atTop.mpr ⟨ ⌈Real.exp ( A / C ) ⌉₊ + 1, fun k hk => by nlinarith [ Nat.le_ceil ( Real.exp ( A / C ) ), Real.log_exp ( A / C ), Real.log_le_log ( by positivity ) ( show ( k :ℝ ) ≥ Real.exp ( A / C ) by exact le_of_lt ( Nat.lt_of_ceil_lt hk ) ), mul_div_cancel₀ A hC.ne' ] ⟩;
  filter_upwards [ h_log_bound, Filter.eventually_gt_atTop 1 ] with k hk₁ hk₂;
  have hl : 0 < Real.log k := Real.log_pos (by exact_mod_cast hk₂)
  have hp : 0 ≤ (k:ℝ)^tt := Real.rpow_nonneg (Nat.cast_nonneg _) _
  rw [Real.rpow_neg hl.le, Real.rpow_two]
  have e : A * (k:ℝ)^tt * (Real.log k ^ 2)⁻¹ = A * (k:ℝ)^tt / Real.log k / Real.log k := by
    field_simp
  rw [e, div_le_div_iff_of_pos_right hl, div_le_iff₀ hl]
  nlinarith [mul_le_mul_of_nonneg_right hk₁ hp]

/-
The `tt`-power times `(log k)^β` with `β < -1` is eventually dominated by
`C · k^tt / log k`.
-/
private lemma poly_log_lt_logpow (A tt β : ℝ) (hβ : β < -1) (C : ℝ) (hC : 0 < C) :
    ∀ᶠ k : ℕ in Filter.atTop,
      A * (k : ℝ) ^ tt * (Real.log k) ^ β ≤ C * (k : ℝ) ^ tt / Real.log k := by
  have h_log_pow : Filter.Tendsto (fun k : ℕ => A * (Real.log k) ^ (β + 1)) Filter.atTop (nhds 0) := by
    simpa using tendsto_const_nhds.mul ( tendsto_rpow_neg_atTop ( by linarith : 0 < - ( β + 1 ) ) |> Filter.Tendsto.comp <| Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop );
  filter_upwards [ h_log_pow.eventually ( gt_mem_nhds hC ), Filter.eventually_gt_atTop 1 ] with k hk₁ hk₂ ; rw [ le_div_iff₀ ( Real.log_pos <| Nat.one_lt_cast.mpr hk₂ ) ] ; ring_nf at *;
  convert mul_le_mul_of_nonneg_left hk₁.le ( Real.rpow_nonneg ( Nat.cast_nonneg k ) tt ) using 1 ; rw [ show ( 1 + β ) = β + 1 by ring, Real.rpow_add ( Real.log_pos <| Nat.one_lt_cast.mpr hk₂ ), Real.rpow_one ] ; ring
private lemma eventually_le_rpow (p A : ℝ) (hp : 0 < p) :
    ∀ᶠ k : ℕ in Filter.atTop, A ≤ (k : ℝ) ^ p := by
  exact Filter.Tendsto.eventually_ge_atTop ( tendsto_rpow_atTop hp |> Filter.Tendsto.comp <| tendsto_natCast_atTop_atTop ) A

private noncomputable def lamML (k : ℕ) (n : ℤ) : ℝ := Real.sqrt ((k : ℝ) ^ (2 + theta) / (2 * (n : ℝ))) * Real.log k

/-- An `n`-free upper bound for `lamML` on the medium-large range. -/
private noncomputable def lamUB (k : ℕ) : ℝ := (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2

private noncomputable def g_ml (k : ℕ) : ℝ :=
  (65536 : ℝ) * (k : ℝ) ^ theta * (
    ((k : ℝ) ^ (theta - 1) * (Real.log k) ^ 2) ^ ((1 : ℝ) / 3) +
    (Real.log k) ^ (-(2 : ℝ)) +
    (3 * lamUB k / (k : ℝ)) ^ ((1 : ℝ) / 4)) + 4 * lamUB k

private lemma log_sq_lt_self : ∀ᶠ k : ℕ in Filter.atTop, (Real.log k) ^ 2 < (k : ℝ) := by
  have h_log_sq_lt_k : Filter.Tendsto (fun k : ℕ => (Real.log k) ^ 2 / (k : ℝ)) Filter.atTop (nhds 0) := by
    have h_log_sq_lt_k : Filter.Tendsto (fun x : ℝ => (Real.log x) ^ 2 / x) Filter.atTop (nhds 0) := by
      convert tendsto_log_rpow_mul_rpow_neg 2 1 ( by norm_num ) using 2 ; norm_num;
      rw [ Real.rpow_neg_one, div_eq_mul_inv ];
    exact h_log_sq_lt_k.comp tendsto_natCast_atTop_atTop;
  filter_upwards [ h_log_sq_lt_k.eventually ( gt_mem_nhds zero_lt_one ), Filter.eventually_gt_atTop 0 ] with k hk₁ hk₂ using by rw [ div_lt_one ( by positivity ) ] at hk₁; exact hk₁;

/-
On the medium-large range, `lamML ≥ 1`.
-/
private lemma lamML_ge_one (k : ℕ) (n : ℤ) (hk : 3 ≤ k) (hnpos : 0 < n)
    (hn : (n : ℝ) ≤ (1 / 2) * (k : ℝ) ^ (2 + theta)) : 1 ≤ lamML k n := by
  refine' one_le_mul_of_one_le_of_one_le ( Real.le_sqrt_of_sq_le _ ) ( Real.le_log_iff_exp_le _ |>.2 _ );
  · rw [ le_div_iff₀ ] <;> first | positivity | linarith;
  · positivity;
  · exact le_trans ( Real.exp_one_lt_d9.le ) ( by norm_num; linarith [ show ( k : ℝ ) ≥ 3 by norm_cast ] )

/-
On the medium-large range, `lamML ≤ lamUB`.
-/
private lemma lamML_le_lamUB (k : ℕ) (n : ℤ) (hk : 2 ≤ k)
    (hn : (k : ℝ) ^ 2 / (Real.log k) ^ 2 < (n : ℝ)) : lamML k n ≤ lamUB k := by
  have h_lamML : Real.sqrt ((k : ℝ) ^ (2 + theta) / (2 * (n : ℝ))) ≤ (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * Real.log k := by
    have h_sqrt : (k : ℝ) ^ (2 + theta) / (2 * (n : ℝ)) ≤ (k : ℝ) ^ theta * (Real.log k) ^ 2 / 2 := by
      rw [ div_le_iff₀ ] <;> norm_num [ Real.rpow_add ( by positivity : 0 < ( k : ℝ ) ) ] at *;
      · rw [ div_lt_iff₀ ] at hn <;> nlinarith [ show 0 < ( k : ℝ ) ^ theta by positivity, show 0 < ( Real.log k ) ^ 2 by exact sq_pos_of_pos <| Real.log_pos <| Nat.one_lt_cast.mpr hk ];
      · exact_mod_cast hn.trans_le' ( div_nonneg ( sq_nonneg _ ) ( sq_nonneg _ ) );
    convert Real.sqrt_le_sqrt h_sqrt using 1 ; norm_num [ Real.sqrt_div_self ] ; ring_nf;
    rw [ Real.sqrt_mul ( by positivity ), Real.sqrt_sq ( by positivity ), Real.sqrt_eq_rpow, Real.sqrt_eq_rpow, ← Real.rpow_mul ( by positivity ) ] ; ring;
  unfold lamML lamUB
  have hl := mul_le_mul_of_nonneg_right h_lamML ( Real.log_nonneg <| Nat.one_le_cast.mpr <| by linarith )
  calc _ ≤ _ := hl
    _ = _ := by ring

/-
`lamML^2 = k^{2+θ}/(2n) · (log k)^2`.
-/
private lemma lamML_sq (k : ℕ) (n : ℤ) (hn0 : 0 < n) :
    (lamML k n) ^ 2 = (k : ℝ) ^ (2 + theta) / (2 * (n : ℝ)) * (Real.log k) ^ 2 := by
  unfold lamML
  rw [mul_pow, Real.sq_sqrt (by positivity)]

private lemma ml_card_bound (hK : ∀ (lam : ℝ), 1 ≤ lam → ∀ (n : ℤ) (k r : ℕ), (k : ℤ) < n → 2 ≤ r →
      (r : ℝ) ≤ (1 / 2) * (k : ℝ) ^ (1 - theta) →
      (((Finset.Ioo (k : ℤ) ((k : ℤ) + ⌊(k : ℝ) ^ theta⌋ + 2)).filter
        (fun m : ℤ => (k : ℤ) < m ∧ (m : ℝ) < (k : ℝ) + (k : ℝ) ^ theta ∧
          |(n : ℝ) / (m : ℝ) - round ((n : ℝ) / (m : ℝ))| < 1 / (k : ℝ) ^ (1 - theta))).card : ℝ)
      < (65536 : ℝ) * (k : ℝ) ^ theta *
          (((n : ℝ) * (Nat.factorial r : ℝ) * lam ^ r / (k : ℝ) ^ (r + 1)) ^ ((2 * (r : ℝ) - 1)⁻¹) +
           ((k : ℝ) ^ ((r : ℝ) + theta) / ((n : ℝ) * (Nat.factorial r : ℝ) * lam ^ r)) ^ (((r : ℝ) - 1)⁻¹) +
           (((r : ℝ) + 1) * lam / (k : ℝ)) ^ ((2 * (r : ℝ))⁻¹)) +
        2 * (r : ℝ) * lam) : ∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → ∀ n : ℤ,
    (k : ℝ) ^ 2 / (Real.log k) ^ 2 < (n : ℝ) →
    (n : ℝ) ≤ (1 / 2) * (k : ℝ) ^ (2 + theta) →
    ((badSet k n).card : ℝ) < g_ml k := by
      obtain ⟨k₀, hk₀⟩ : ∃ k₀ : ℕ, ∀ k ≥ k₀, 2 ≤ (1 / 2) * (k : ℝ) ^ (1 - theta) ∧ (Real.log k) ^ 2 < k ∧ 3 ≤ k := by
        obtain ⟨k₁, hk₁⟩ : ∃ k₁ : ℕ, ∀ k ≥ k₁, 2 ≤ (1 / 2) * (k : ℝ) ^ (1 - theta) := by
          have := @eventually_le_rpow ( 1 - theta ) 4 ( by norm_num [ theta ] );
          exact Filter.eventually_atTop.mp ( this.mono fun k hk => by linarith )
        obtain ⟨k₂, hk₂⟩ : ∃ k₂ : ℕ, ∀ k ≥ k₂, (Real.log k) ^ 2 < k := by
          exact Filter.eventually_atTop.mp ( log_sq_lt_self )
        use max k₁ (max k₂ 3);
        exact fun k hk => ⟨ hk₁ k ( le_trans ( le_max_left _ _ ) hk ), hk₂ k ( le_trans ( le_max_of_le_right ( le_max_left _ _ ) ) hk ), le_trans ( le_max_of_le_right ( le_max_right _ _ ) ) hk ⟩;
      refine' ⟨ k₀ + 3, fun k hk n hn₁ hn₂ => _ ⟩;
      have hKon : ((badSet k n).card : ℝ) < (65536 : ℝ) * (k : ℝ) ^ theta * (((n : ℝ) * ((2 : ℕ)!) * (lamML k n) ^ 2 / (k : ℝ) ^ (2 + 1)) ^ ((1 : ℝ) / 3) + ((k : ℝ) ^ ((2 : ℝ) + theta) / ((n : ℝ) * ((2 : ℕ)!) * (lamML k n) ^ 2)) ^ 1 + ((3 * lamML k n) / (k : ℝ)) ^ ((1 : ℝ) / 4)) + 2 * (2 : ℝ) * (lamML k n) := by
        have hbS : badSet k n = (Finset.Ioo (k : ℤ) ((k : ℤ) + ⌊(k : ℝ) ^ theta⌋ + 2)).filter
            (fun m : ℤ => (k : ℤ) < m ∧ (m : ℝ) < (k : ℝ) + (k : ℝ) ^ theta ∧
              |(n : ℝ) / (m : ℝ) - round ((n : ℝ) / (m : ℝ))| < 1 / (k : ℝ) ^ (1 - theta)) := by
          simp only [badSet]
          apply Finset.filter_congr
          intro x hx
          rw [Finset.mem_Ioo] at hx
          exact ⟨fun h => ⟨hx.1, h⟩, fun h => h.2⟩
        rw [hbS]
        convert hK ( lamML k n ) ( lamML_ge_one k n ( by linarith [ hk₀ k ( by linarith ) ] ) ( by
          exact_mod_cast hn₁.trans_le' ( div_nonneg ( sq_nonneg _ ) ( sq_nonneg _ ) ) ) ( by
          exact hn₂ ) ) n k 2 ( by
          rw [ div_lt_iff₀ ] at hn₁;
          · exact_mod_cast ( by nlinarith [ hk₀ k ( by linarith ), show ( k : ℝ ) ≥ 3 by norm_cast; linarith ] : ( k : ℝ ) < n );
          · exact sq_pos_of_pos <| Real.log_pos <| Nat.one_lt_cast.mpr <| by linarith [ hk₀ k <| by linarith ] ; ) ( by norm_num ) ( by
          exact hk₀ k ( by linarith ) |>.1 ) using 1 ; norm_num [ Nat.factorial ];
      have hT1 : ((n : ℝ) * ((2 : ℕ)!) * (lamML k n) ^ 2 / (k : ℝ) ^ (2 + 1)) ^ ((1 : ℝ) / 3) = ((k : ℝ) ^ (theta - 1) * (Real.log k) ^ 2) ^ ((1 : ℝ) / 3) := by
        have hT1 : (n : ℝ) * ((2 : ℕ)!) * (lamML k n) ^ 2 = (k : ℝ) ^ (2 + theta) * (Real.log k) ^ 2 := by
          rw [ lamML_sq ] ; ring_nf;
          · simp +decide [ mul_comm, show n ≠ 0 by rintro rfl; exact absurd hn₁ ( by norm_num; positivity ) ];
          · exact_mod_cast hn₁.trans_le' ( div_nonneg ( sq_nonneg _ ) ( sq_nonneg _ ) );
        rw [ hT1, mul_div_right_comm ];
        rw [ ← Real.rpow_natCast, ← Real.rpow_sub ( by norm_cast; linarith ) ] ; ring_nf
      have hT2 : ((k : ℝ) ^ ((2 : ℝ) + theta) / ((n : ℝ) * ((2 : ℕ)!) * (lamML k n) ^ 2)) ^ 1 = (Real.log k) ^ (-(2 : ℝ)) := by
        rw [ show ( n : ℝ ) * 2! * lamML k n ^ 2 = ( k : ℝ ) ^ ( 2 + theta ) * ( Real.log k ) ^ 2 by
              rw [ lamML_sq ] ; ring_nf;
              · by_cases hn : n = 0 <;> simp_all +decide [ mul_comm ];
                exact absurd hT1 ( ne_of_lt ( Real.rpow_pos_of_pos ( mul_pos ( Real.rpow_pos_of_pos ( Nat.cast_pos.mpr ( by linarith ) ) _ ) ( sq_pos_of_pos ( Real.log_pos ( Nat.one_lt_cast.mpr ( by linarith [ hk₀ k ( by linarith ) ] ) ) ) ) ) _ ) );
              · exact_mod_cast hn₁.trans_le' ( div_nonneg ( sq_nonneg _ ) ( sq_nonneg _ ) ) ] ; norm_cast ; norm_num;
        rw [ ← div_div, div_self ( by exact ne_of_gt ( Real.rpow_pos_of_pos ( Nat.cast_pos.mpr ( by linarith ) ) _ ) ), one_div ]
      have hT3 : ((3 * lamML k n) / (k : ℝ)) ^ ((1 : ℝ) / 4) ≤ (3 * lamUB k / (k : ℝ)) ^ ((1 : ℝ) / 4) := by
        gcongr;
        · exact div_nonneg ( mul_nonneg zero_le_three ( show 0 ≤ lamML k n from mul_nonneg ( Real.sqrt_nonneg _ ) ( Real.log_natCast_nonneg _ ) ) ) ( Nat.cast_nonneg _ );
        · have h := lamML_le_lamUB k n ( by linarith ) hn₁; gcongr
      have hLast : 2 * (2 : ℝ) * (lamML k n) ≤ 4 * (lamUB k) := by
        have := lamML_le_lamUB k n ( by linarith ) hn₁; norm_num at *; linarith;
      unfold g_ml; nlinarith [ show 0 < (65536 : ℝ) * ( k : ℝ ) ^ theta by exact mul_pos ( by exact lt_of_lt_of_le ( by norm_num ) ( show ( 256 : ℝ ) ≤ (65536 : ℝ) by norm_num ) ) ( Real.rpow_pos_of_pos ( Nat.cast_pos.mpr <| by linarith ) _ ) ] ;
/-
The medium-large bound `g_ml` is eventually dominated by `C · k^θ / log k`.
-/
private lemma ml_rhs_le (C : ℝ) (hC : 0 < C) :
    ∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → g_ml k ≤ C * (k : ℝ) ^ theta / Real.log k := by
  obtain ⟨k₁, hk₁⟩ : ∃ k₁ : ℕ, ∀ k : ℕ, k₁ ≤ k → ((65536 : ℝ) * (k : ℝ) ^ theta * ((k : ℝ) ^ (theta - 1) * (Real.log k) ^ 2) ^ ((1 : ℝ) / 3)) ≤ C / 4 * (k : ℝ) ^ theta / Real.log k := by
    have h_poly_log : ∀ᶠ k : ℕ in Filter.atTop, (65536 : ℝ) * (k : ℝ) ^ ((4 * theta - 1) / 3 : ℝ) * (Real.log k) ^ (2 / 3 : ℝ) ≤ C / 4 * (k : ℝ) ^ theta / Real.log k := by
      have := poly_log_lt (65536 : ℝ) ( ( 4 * theta - 1 ) / 3 ) ( 2 / 3 ) theta ?_ ( C / 4 ) ( by linarith ) <;> norm_num at *;
      · exact this;
      · unfold theta; norm_num;
    obtain ⟨ k₁, hk₁ ⟩ := Filter.eventually_atTop.mp h_poly_log;
    refine' ⟨ k₁ + 2, fun k hk => le_trans _ ( hk₁ k ( by linarith ) ) ⟩ ; norm_num [ Real.rpow_def_of_pos, show k > 0 by linarith ] ; ring_nf ; norm_num;
    rw [ Real.mul_rpow ( by positivity ) ( by positivity ), ← Real.exp_mul ] ; ring_nf ; norm_num [ Real.exp_add, Real.exp_neg, Real.exp_mul, Real.exp_log ( show 0 < ( k : ℝ ) by norm_cast; linarith ) ] ; ring_nf ; norm_num;
    rw [ ← Real.rpow_natCast, ← Real.rpow_mul ( by positivity ) ] ; ring_nf ; norm_num [ ← Real.rpow_mul ( Nat.cast_nonneg _ ), ← Real.rpow_neg ( Nat.cast_nonneg _ ) ] ; ring_nf ; norm_num;
    rw [ show ( theta * ( 4 / 3 ) : ℝ ) = theta + theta * ( 1 / 3 ) by ring, Real.rpow_add ( by norm_cast; linarith ) ] ; ring_nf ; norm_num;
  -- Apply the asymptotic lemmas to get the bounds for E2, E3, and E4.
  obtain ⟨k₂, hk₂⟩ : ∃ k₂ : ℕ, ∀ k : ℕ, k₂ ≤ k → (65536 : ℝ) * (k : ℝ) ^ theta * (Real.log k) ^ (-(2 : ℝ)) ≤ C / 4 * (k : ℝ) ^ theta / Real.log k := by
    have := poly_log_lt_eq (65536 : ℝ) theta ( C / 4 ) ( by linarith );
    exact Filter.eventually_atTop.mp this;
  obtain ⟨k₃, hk₃⟩ : ∃ k₃ : ℕ, ∀ k : ℕ, k₃ ≤ k → (65536 : ℝ) * (k : ℝ) ^ theta * (3 * (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2 / (k : ℝ)) ^ (1 / 4 : ℝ) ≤ C / 4 * (k : ℝ) ^ theta / Real.log k := by
    have := poly_log_lt ( (65536 : ℝ) * ( 3 * ( 1 / Real.sqrt 2 ) ) ^ ( 1 / 4 : ℝ ) ) ( ( 9 * theta - 2 ) / 8 ) ( 1 / 2 ) theta ?_ ( C / 4 ) ( by linarith ) <;> norm_num at *;
    · obtain ⟨ k₃, hk₃ ⟩ := this; use k₃ + 2; intros k hk; convert hk₃ k ( by linarith ) using 1; rw [ Real.div_rpow ( by positivity ) ( by positivity ), Real.mul_rpow ( by positivity ) ( by positivity ), Real.mul_rpow ( by positivity ) ( by positivity ) ] ; ring_nf;
      rw [ ← Real.rpow_mul ( by positivity ), ← Real.rpow_natCast, ← Real.rpow_mul ( by positivity ) ] ; ring_nf;
      rw [ show ( -1 / 4 + theta * ( 9 / 8 ) : ℝ ) = theta + theta * ( 1 / 8 ) - 1 / 4 by ring ] ; norm_num [ Real.rpow_add ( by norm_cast; linarith : 0 < ( k : ℝ ) ), Real.rpow_sub ( by norm_cast; linarith : 0 < ( k : ℝ ) ) ] ; ring;
    · unfold theta; norm_num;
  obtain ⟨k₄, hk₄⟩ : ∃ k₄ : ℕ, ∀ k : ℕ, k₄ ≤ k → 4 * (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2 ≤ C / 4 * (k : ℝ) ^ theta / Real.log k := by
    have := poly_log_lt ( 4 * ( 1 / Real.sqrt 2 ) ) ( theta / 2 ) 2 theta ?_ ( C / 4 ) ?_ <;> norm_num at *;
    · exact this;
    · linarith [theta_pos];
    · positivity;
  refine ⟨max k₁ (max k₂ (max k₃ k₄)), fun k hk => ?_⟩
  have a1 := hk₁ k (le_trans (le_max_left _ _) hk)
  have a2 := hk₂ k (le_trans (le_trans (le_max_left _ _) (le_max_right _ _)) hk)
  have a3 := hk₃ k (le_trans (le_trans (le_trans (le_max_left _ _) (le_max_right _ _)) (le_max_right _ _)) hk)
  have a4 := hk₄ k (le_trans (le_trans (le_trans (le_max_right _ _) (le_max_right _ _)) (le_max_right _ _)) hk)
  have e3 : (3 * lamUB k / (k:ℝ)) = 3 * (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2 / (k : ℝ) := by
    unfold lamUB; ring
  have e4 : 4 * lamUB k = 4 * (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2 := by
    unfold lamUB; ring
  unfold g_ml
  rw [e3, e4]
  have e : C * (k:ℝ)^theta / Real.log k = 4 * (C/4 * (k:ℝ)^theta / Real.log k) := by ring
  have ex : (65536 : ℝ) * (k : ℝ) ^ theta * (((k : ℝ) ^ (theta - 1) * (Real.log k) ^ 2) ^ ((1 : ℝ) / 3) +
      (Real.log k) ^ (-(2 : ℝ)) + (3 * (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2 / (k : ℝ)) ^ ((1 : ℝ) / 4))
      = (65536 : ℝ) * (k : ℝ) ^ theta * ((k : ℝ) ^ (theta - 1) * (Real.log k) ^ 2) ^ ((1 : ℝ) / 3) +
        (65536 : ℝ) * (k : ℝ) ^ theta * (Real.log k) ^ (-(2 : ℝ)) +
        (65536 : ℝ) * (k : ℝ) ^ theta * (3 * (1 / Real.sqrt 2) * (k : ℝ) ^ (theta / 2) * (Real.log k) ^ 2 / (k : ℝ)) ^ ((1 : ℝ) / 4) := by ring
  linarith

theorem erdos_1094__h2__h1__h1__h4 : ∀ (C : ℝ),
  (0 : ℝ) < C →
    ∃ (k₀ : ℕ),
      ∀ (k : ℕ),
        k₀ ≤ k →
          ∀ (n : ℤ),
            (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) →
              (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + (21 / 40 : ℝ)) →
                (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) |
                          (↑k : ℤ) < m ∧
                            (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧
                              |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| <
                                (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card :
                    ℝ) <
                  C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) := by
  intro C hC
  obtain ⟨k1, hk1card⟩ := ml_card_bound erdos_1094__h2__h2__h2__h3__h1
  obtain ⟨k2, hk2rhs⟩ := ml_rhs_le C hC
  refine ⟨max k1 k2, ?_⟩
  intro k hk n hlow hhigh
  have hcard : ((badSet k n).card : ℝ) < C * (k : ℝ) ^ theta / Real.log k :=
    lt_of_lt_of_le (hk1card k (le_trans (le_max_left _ _) hk) n hlow hhigh)
      (hk2rhs k (le_trans (le_max_right _ _) hk))
  have hbS : badSet k n = (Finset.Ioo (k : ℤ) ((k : ℤ) + ⌊(k : ℝ) ^ theta⌋ + 2)).filter
      (fun m : ℤ => (k : ℤ) < m ∧ (m : ℝ) < (k : ℝ) + (k : ℝ) ^ theta ∧
        |(n : ℝ) / (m : ℝ) - round ((n : ℝ) / (m : ℝ))| < 1 / (k : ℝ) ^ (1 - theta)) := by
    simp only [badSet]
    apply Finset.filter_congr
    intro x hx
    rw [Finset.mem_Ioo] at hx
    exact ⟨fun h => ⟨hx.1, h⟩, fun h => h.2⟩
  rw [hbS] at hcard
  exact hcard

What is known

Work on it

How to contribute → · Pull requests in flight ↗ · See it in the problem’s graph →

Record

Statement: the Lean file and its words (1 version)

Statement not audited — only a problem’s root statement is audited for fidelity (D-9); the kernel checks a proof against this Lean as written.

import Mathlib
import Nodes.«erdos-1094--h2--h1--h1--h4».Context

open scoped Nat

/-! Hole `h_ml` of a merged partial proof, as a node (D-12 #5, D-29).
Statement generated by the gate from the assembly; immutable (D-3). -/

theorem erdos_1094__h2__h1__h1__h4 : ∀ (C : ℝ),
  (0 : ℝ) < C →
    ∃ (k₀ : ℕ),
      ∀ (k : ℕ),
        k₀ ≤ k →
          ∀ (n : ℤ),
            (↑k : ℝ) ^ (2 : ℕ) / Real.log (↑k : ℝ) ^ (2 : ℕ) < (↑n : ℝ) →
              (↑n : ℝ) ≤ (1 / 2 : ℝ) * (↑k : ℝ) ^ ((2 : ℝ) + (21 / 40 : ℝ)) →
                (↑{m ∈ Finset.Ioo (↑k : ℤ) ((↑k : ℤ) + ⌊(↑k : ℝ) ^ (21 / 40 : ℝ)⌋ + (2 : ℤ)) |
                          (↑k : ℤ) < m ∧
                            (↑m : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ) ∧
                              |(↑n : ℝ) / (↑m : ℝ) - (↑(round ((↑n : ℝ) / (↑m : ℝ))) : ℝ)| <
                                (1 : ℝ) / (↑k : ℝ) ^ ((1 : ℝ) - (21 / 40 : ℝ))}.card :
                    ℝ) <
                  C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) := by
  sorry

A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →

In words, unverified — what this statement says; written by t1111-a, drafted with claude-fable-5-2, 2026-11-11; no one has read it against the Lean and signed it.

Draft · drafted, by the model named above

$\displaystyle \forall C > 0\ \exists k_0\ \forall k \ge k_0:\ \#\{m \in (k, k + k^\theta): \|n/m\| < k^{\theta-1}\} < C k^\theta/\log k \text{ for } k^2/\log^2 k < n \le \tfrac12 k^{2+\theta},\ \theta = 21/40$

Here $\|x\|$ is the distance from $x$ to the nearest integer and $m$ runs over integers.

Rendered from gloss/a9ba86731029….md · Improve these words →

Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Statement.lean. Origin: compiler-derived.

Attestation: pass, 7 of 7 checks

Checked by the kernel — the gate’s record of the run: attestations/001300.json, merge commit 3a34942b22b7.

Verdict pass, from attestations/001300.json.

Submitter
t1111-b
Toolchain
leanprover/lean4:v4.33.1 (hash f54d0bc916bf76a7fae460ce9d078ccd1f74aeb4fd12c4b6546bca28b6aa1c63)
Mathlib
0df444a360eaa60ab8c11dca51a86af692955474
Reviewer
none needed (intermediate)
StepCheckResult
1toolchainpass
2pathspass
4kernel-replaypass
5axiomspass
6hazardspass
7witnesspass
8depspass
Witness

Checked by the kernel — step 7 passed in the run its attestation records: attestations/001300.json, merge commit 3a34942b22b7.

Witness.lean — checked at step 7 of the run recorded below: pass. Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h4/Witness.lean, sha256 df075cd69f7d.
import Mathlib

open scoped Nat

theorem witness : ∃ C : ℝ, (0 : ℝ) < C := ⟨1, one_pos⟩

No gloss yet: no one has written in words what this witness says (D-3 v3.30); the Lean above is the witness. How to write one →

How to read this page