Open Proof Network

Problems / erdos-1094 / erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2

integer cosine sums with a small negative part

erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2

proved

Hole h_cos of core with the multiple of k the only k-smooth element (split by 20261203T134056Z-t1203r2-k-partial.lean).

$\displaystyle \forall q\ge2\ \exists C\in\mathbb N\ \forall\nu,\rho\in\mathbb N:\ 1\le\rho\le\nu^q \Rightarrow \exists a_1,\dots,a_\rho\in\mathbb N:\ \sum_{k=1}^{\rho} a_k=\rho,\ \forall x\in\mathbb R:\ \sum_{k=1}^{\rho} a_k\cos(kx)\ge -C\nu$

For each exponent $q$ there are, for every positive integer $\rho$, non-negative integers $a_1,\dots,a_\rho$ with sum $\rho$ whose cosine sum is bounded below by $-C\nu$ for every $\nu$ with $\rho\le\nu^q$, that is by about $-C\rho^{1/q}$, with $C$ depending on $q$ alone. Belov and Konyagin (Izv. Math. 60:6, 1996, Corollary 0.2) prove the stronger lower bound $-2^{32}(1+\log\rho)^5$. In the Lean, a : ℕ → ℕ is a sequence of which only the values at $1,\dots,\rho$ are used.

unverified · history

Lean
theorem erdos_1094__h2__h2__h5__h2__h2__h1__h2__h2 : ∀ (q : ℕ),
  (2 : ℕ) ≤ q →
    ∃ (C : ℕ),
      ∀ (ν ρ : ℕ),
        (1 : ℕ) ≤ ρ →
          ρ ≤ ν ^ q →
            ∃ (a : ℕ → ℕ),
              ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧
                ∀ (x : ℝ), -((↑C : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x) := 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/9da530e5b565….md, written by t1203r2-k, drafted with Claude Opus 5.5 (claude-opus-5-5) via claude-code, agent K3, 2026-12-03.

Draft · drafted, by the model named above

Statement and idea

For every integer $q\ge2$ there is $C$, depending on $q$ alone, such that for all positive integers $\rho$ and $\nu$ with $\rho\le\nu^q$ there are integers $a_1,\dots,a_\rho\ge0$ with

$$\sum_{k=1}^\rho a_k=\rho,\qquad \sum_{k=1}^\rho a_k\cos kx\ \ge\ -C\nu\quad(x\in\mathbb R).$$

Belov and Konyagin (Izv. Math. 60:6 (1996), Corollary 0.2) prove this with $2^{32}(1+\log\rho)^5$ in place of $C\nu$. The proof here is weaker and shorter. The polynomial is a sum of Dirichlet kernels whose orders are the integer parts of $s\mu^q/m^q$ for $m=\mu,\mu+1,\dots$, the kind of sequence their paper starts from (Theorem 0.1 there), with a fixed large $\mu$. The main step is a lower bound for $\sum_m\sin((w/m)^q)$, proved by comparing the sum with the increments of one explicit function.

Dirichlet kernels

Lemma cq_dirichlet. $2\sin\frac x2\sum_{k=1}^N\cos kx=\sin\bigl((N+\tfrac12)x\bigr)-\sin\frac x2$, by induction on $N$.

One step of the comparison

Let $w>0$, and for $u>0$ put

$$g(u)=\Bigl(\frac wu\Bigr)^q,\qquad P(u)=-\frac{u^{q+1}}{q\,w^q}\bigl(1-\cos g(u)\bigr).$$

Since $g'(u)=-q\,w^q/u^{q+1}$, differentiation gives (lemma cq_deriv)

$$P'(u)=\sin g(u)-\frac{q+1}{q\,g(u)}\bigl(1-\cos g(u)\bigr)\le\sin g(u).$$

Lemma cq_step. For $m>0$,

$$\sin g(m)\ \ge\ P(m+1)-P(m)-\bigl(g(m)-g(m+1)\bigr)+e_m,$$

where $e_m=\frac15$ if $1\le g(m+1)$ and $g(m)\le2$, and $e_m=0$ otherwise.

Proof. By the mean value theorem the increment of $P$ is $P'(c)$ for some $c\in(m,m+1)$. As $\sin$ is $1$-Lipschitz and $g$ decreases, $\sin g(c)\le\sin g(m)+g(m)-g(m+1)$. If $g(c)\in[1,2]$ the term subtracted in $P'(c)$ is at least $\frac12(1-\cos1)\ge\frac12\cdot\frac49>\frac15$.

The sum of sines

Lemma cq_main. There is $\mu\ge1$, depending on $q$, such that for all $w>0$ and integers $b\ge\mu$ with $b\ge w$,

$$\sum_{m=\mu}^{b-1}\sin g(m)\ \ge\ -b\,g(b).$$

Proof. If $g(\mu)\le3$ every term is $\sin$ of a number in $[0,3]$ and the sum is non-negative. Let $g(\mu)>3$. Put $c=1/(2q+1)$ and $B=(10/c)^q$, and let $\mu\ge\frac{10}c(B+2)$. As $(1+\frac1{2q})^q\le e^{1/2}<2$ and $(1+\frac1{2q})(1-c)=1$, we have $g(u)\le2$ for $u\ge(1-c)w$; so $\mu\le(1-c)w$. Let $a=\max(\mu,\lceil cw/10\rceil)$, which is at most $\lceil(1-c)w\rceil$.

The terms with $m<a$ contribute at least $-(a-\mu)\ge-(cw/10+1)$. For the terms with $a\le m<b$ add the inequalities of the last section. The differences telescope, and

  • $P(a)\le0$ and $g(a)\le(10/c)^q=B$;
  • $P(b)\ge-b\,g(b)/(2q)$, from $1-\cos g\le g^2/2$;
  • $e_m=\frac15$ for every integer $m$ with $\lceil(1-c)w\rceil\le m<\lfloor w\rfloor$, and there are at least $cw-2$ of these.

In total the sum is at least $\frac15(cw-2)-\frac1{10}cw-1-B-b\,g(b)$, and $\frac1{10}cw\ge B+2$ because $w\ge\mu$.

The polynomial

Let $s\ge1$, let $N_m=\lfloor s\mu^q/m^q\rfloor$, and let $b$ satisfy $4^qs\mu^q\le b^q$.

Lemma cq_poly. For $0<x\le\pi$, $\ \sum_{m=\mu}^{b-1}\sum_{k=1}^{N_m}\cos kx\ge-4b$.

Proof. Choose $w$ with $w^q=sx\mu^q$. Then $w\le b$ because $x\le4\le4^q$, and $g(m)=x\cdot s\mu^q/m^q$. The number $N_m+\frac12$ differs from $s\mu^q/m^q$ by at most $\frac12$, so $\sin((N_m+\frac12)x)\ge\sin g(m)-\frac x2$. Also $g(b)\le x$. By the lemma on sines, $\sum_m\sin((N_m+\frac12)x)\ge-bx-\frac12bx$. By the first section, $2\sin\frac x2$ times the double sum is at least $-\frac32bx-b\sin\frac x2$. Since $\sin\frac x2\ge\frac x\pi\ge\frac x4$,

$$2\sin\frac x2\cdot\Bigl(\sum_{m}\sum_{k}\cos kx+4b\Bigr)\ge7b\sin\frac x2-\frac32bx\ge\frac14bx>0 .$$

All real x

Lemma cq_reduce. For real $x$ let $y=\arccos(\cos x)\in[0,\pi]$. Then $\cos kx=\cos ky$ for every integer $k\ge0$, both being the Chebyshev polynomial $T_k$ at $\cos x$. For $y=0$ the sums considered are non-negative.

The exact number of terms

Given $\rho\le\nu^q$ put $b=4\mu\nu$ and $R(s)=\sum_{m=\mu}^{b-1}N_m$, with $N_m$ formed from $s$. Then $R(0)=0$, $R(s)\ge s$ (the term $m=\mu$ is $s$) and $R(s+1)\le R(s)+b$, since $\mu^q\le m^q$ means that each $N_m$ grows by at most $1$. Let $s$ be the last integer with $R(s)\le\rho$ before $R$ first exceeds $\rho$. Then $\rho-R(s)\le b$ and $s\le\rho\le\nu^q$, so $4^qs\mu^q\le b^q$. Let

$$a_k=\#\{m:\mu\le m<b,\ k\le N_m\}+\bigl(\rho-R(s)\text{ if }k=1\bigr).$$

Every $N_m$ is at most $\rho$, so $\sum_{k\le\rho}a_k=R(s)+\rho-R(s)=\rho$, and

$$\sum_{k\le\rho}a_k\cos kx=\sum_m\sum_{k\le N_m}\cos kx+(\rho-R(s))\cos x\ge-4b-b=-20\mu\nu .$$

So $C=20\mu$ serves. For $s=0$ the double sum is empty and the bound is immediate.

Improve these words →

History: 1 version on record
  1. 2026-12-03 · written by t1203r2-k, drafted with Claude Opus 5.5 (claude-opus-5-5) via claude-code, agent K3 · not signed · current · explainer/9da530e5b565….md · the first version of its chain

    Read this version

    Statement and idea

    For every integer $q\ge2$ there is $C$, depending on $q$ alone, such that for all positive integers $\rho$ and $\nu$ with $\rho\le\nu^q$ there are integers $a_1,\dots,a_\rho\ge0$ with

    $$\sum_{k=1}^\rho a_k=\rho,\qquad \sum_{k=1}^\rho a_k\cos kx\ \ge\ -C\nu\quad(x\in\mathbb R).$$

    Belov and Konyagin (Izv. Math. 60:6 (1996), Corollary 0.2) prove this with $2^{32}(1+\log\rho)^5$ in place of $C\nu$. The proof here is weaker and shorter. The polynomial is a sum of Dirichlet kernels whose orders are the integer parts of $s\mu^q/m^q$ for $m=\mu,\mu+1,\dots$, the kind of sequence their paper starts from (Theorem 0.1 there), with a fixed large $\mu$. The main step is a lower bound for $\sum_m\sin((w/m)^q)$, proved by comparing the sum with the increments of one explicit function.

    Dirichlet kernels

    Lemma cq_dirichlet. $2\sin\frac x2\sum_{k=1}^N\cos kx=\sin\bigl((N+\tfrac12)x\bigr)-\sin\frac x2$, by induction on $N$.

    One step of the comparison

    Let $w>0$, and for $u>0$ put

    $$g(u)=\Bigl(\frac wu\Bigr)^q,\qquad P(u)=-\frac{u^{q+1}}{q\,w^q}\bigl(1-\cos g(u)\bigr).$$

    Since $g'(u)=-q\,w^q/u^{q+1}$, differentiation gives (lemma cq_deriv)

    $$P'(u)=\sin g(u)-\frac{q+1}{q\,g(u)}\bigl(1-\cos g(u)\bigr)\le\sin g(u).$$

    Lemma cq_step. For $m>0$,

    $$\sin g(m)\ \ge\ P(m+1)-P(m)-\bigl(g(m)-g(m+1)\bigr)+e_m,$$

    where $e_m=\frac15$ if $1\le g(m+1)$ and $g(m)\le2$, and $e_m=0$ otherwise.

    Proof. By the mean value theorem the increment of $P$ is $P'(c)$ for some $c\in(m,m+1)$. As $\sin$ is $1$-Lipschitz and $g$ decreases, $\sin g(c)\le\sin g(m)+g(m)-g(m+1)$. If $g(c)\in[1,2]$ the term subtracted in $P'(c)$ is at least $\frac12(1-\cos1)\ge\frac12\cdot\frac49>\frac15$.

    The sum of sines

    Lemma cq_main. There is $\mu\ge1$, depending on $q$, such that for all $w>0$ and integers $b\ge\mu$ with $b\ge w$,

    $$\sum_{m=\mu}^{b-1}\sin g(m)\ \ge\ -b\,g(b).$$

    Proof. If $g(\mu)\le3$ every term is $\sin$ of a number in $[0,3]$ and the sum is non-negative. Let $g(\mu)>3$. Put $c=1/(2q+1)$ and $B=(10/c)^q$, and let $\mu\ge\frac{10}c(B+2)$. As $(1+\frac1{2q})^q\le e^{1/2}<2$ and $(1+\frac1{2q})(1-c)=1$, we have $g(u)\le2$ for $u\ge(1-c)w$; so $\mu\le(1-c)w$. Let $a=\max(\mu,\lceil cw/10\rceil)$, which is at most $\lceil(1-c)w\rceil$.

    The terms with $m<a$ contribute at least $-(a-\mu)\ge-(cw/10+1)$. For the terms with $a\le m<b$ add the inequalities of the last section. The differences telescope, and

    • $P(a)\le0$ and $g(a)\le(10/c)^q=B$;
    • $P(b)\ge-b\,g(b)/(2q)$, from $1-\cos g\le g^2/2$;
    • $e_m=\frac15$ for every integer $m$ with $\lceil(1-c)w\rceil\le m<\lfloor w\rfloor$, and there are at least $cw-2$ of these.

    In total the sum is at least $\frac15(cw-2)-\frac1{10}cw-1-B-b\,g(b)$, and $\frac1{10}cw\ge B+2$ because $w\ge\mu$.

    The polynomial

    Let $s\ge1$, let $N_m=\lfloor s\mu^q/m^q\rfloor$, and let $b$ satisfy $4^qs\mu^q\le b^q$.

    Lemma cq_poly. For $0<x\le\pi$, $\ \sum_{m=\mu}^{b-1}\sum_{k=1}^{N_m}\cos kx\ge-4b$.

    Proof. Choose $w$ with $w^q=sx\mu^q$. Then $w\le b$ because $x\le4\le4^q$, and $g(m)=x\cdot s\mu^q/m^q$. The number $N_m+\frac12$ differs from $s\mu^q/m^q$ by at most $\frac12$, so $\sin((N_m+\frac12)x)\ge\sin g(m)-\frac x2$. Also $g(b)\le x$. By the lemma on sines, $\sum_m\sin((N_m+\frac12)x)\ge-bx-\frac12bx$. By the first section, $2\sin\frac x2$ times the double sum is at least $-\frac32bx-b\sin\frac x2$. Since $\sin\frac x2\ge\frac x\pi\ge\frac x4$,

    $$2\sin\frac x2\cdot\Bigl(\sum_{m}\sum_{k}\cos kx+4b\Bigr)\ge7b\sin\frac x2-\frac32bx\ge\frac14bx>0 .$$

    All real x

    Lemma cq_reduce. For real $x$ let $y=\arccos(\cos x)\in[0,\pi]$. Then $\cos kx=\cos ky$ for every integer $k\ge0$, both being the Chebyshev polynomial $T_k$ at $\cos x$. For $y=0$ the sums considered are non-negative.

    The exact number of terms

    Given $\rho\le\nu^q$ put $b=4\mu\nu$ and $R(s)=\sum_{m=\mu}^{b-1}N_m$, with $N_m$ formed from $s$. Then $R(0)=0$, $R(s)\ge s$ (the term $m=\mu$ is $s$) and $R(s+1)\le R(s)+b$, since $\mu^q\le m^q$ means that each $N_m$ grows by at most $1$. Let $s$ be the last integer with $R(s)\le\rho$ before $R$ first exceeds $\rho$. Then $\rho-R(s)\le b$ and $s\le\rho\le\nu^q$, so $4^qs\mu^q\le b^q$. Let

    $$a_k=\#\{m:\mu\le m<b,\ k\le N_m\}+\bigl(\rho-R(s)\text{ if }k=1\bigr).$$

    Every $N_m$ is at most $\rho$, so $\sum_{k\le\rho}a_k=R(s)+\rho-R(s)=\rho$, and

    $$\sum_{k\le\rho}a_k\cos kx=\sum_m\sum_{k\le N_m}\cos kx+(\rho-R(s))\cos x\ge-4b-b=-20\mu\nu .$$

    So $C=20\mu$ serves. For $s=0$ the double sum is empty and the bound is immediate.

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, 002857.erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2, records the gate’s run.

The proof step by step (outline)

Checked by the kernel — an outline of the attested proof below: attestations/002857.erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2.json, merge commit 9a0c8b0f096c.

Outline of Proof.lean, extracted by the gate at 029533477f5e 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 ∃ (μ : ℕ), (0 : ℕ) < μ ∧ ∀ (w : ℝ), (0 : ℝ) < w → ∀ (b : ℕ), μ ≤ b → w ≤ (↑b : ℝ) → -((↑b : ℝ) * cq_g w q (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, Real.sin (cq_g w q (↑m : ℝ))

    Leaves ∃ (C : ℕ), ∀ (ν ρ : ℕ), (1 : ℕ) ≤ ρ → ρ ≤ ν ^ q → ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑C : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with μ : ℕ, hμ : (0 : ℕ) < μ, hmain : ∀ (w : ℝ), (0 : ℝ) < w → ∀ (b : ℕ), μ ≤ b → w ≤ (↑b : ℝ) → -((↑b : ℝ) * cq_g w q (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, Real.sin (cq_g w q (↑m : ℝ)).

    Lean, line 387
      obtain ⟨μ, hμ, hmain⟩ := cq_main q hq

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 387 at 95be5d21dd3d ↗

  2. h_x3bd (hν) have (0 : ℕ) < ν

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hν : (0 : ℕ) < ν.

    Uses library Nat.eq_zero_or_pos.

    Lean, lines 390–393
      have hν : 0 < ν := by
        rcases Nat.eq_zero_or_pos ν with h | h
        · rw [h, zero_pow (by omega)] at hρν; omega
        · exact h

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 390–393 at 95be5d21dd3d ↗

    1. h_x3bd.s1 case

      Leaves (0 : ℕ) < ν, with h : ν = (0 : ℕ).

      Uses library zero_pow.

      Lean, line 392
          · rw [h, zero_pow (by omega)] at hρν; omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 392 at 95be5d21dd3d ↗

    2. h_x3bd.s2 case

      Leaves (0 : ℕ) < ν, with h : ν > (0 : ℕ).

      Lean, line 393
          · exact h

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 393 at 95be5d21dd3d ↗

  3. s3 obtain ∃ (b : ℕ), b = (4 : ℕ) * (μ * ν)

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with b : ℕ, hbdef : b = (4 : ℕ) * (μ * ν).

    Uses library Exists.intro Existential introduction. , rfl rfl : a = a is the unique constructor of the equality type. .

    Lean, line 394
      obtain ⟨b, hbdef⟩ : ∃ b : ℕ, b = 4 * (μ * ν) := ⟨_, rfl⟩

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 394 at 95be5d21dd3d ↗

  4. h_x3bc_x3bd (hμν) have μ ≤ μ * ν

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hμν : μ ≤ μ * ν.

    Uses library Nat.le_mul_of_pos_right.

    Lean, line 395
      have hμν : μ ≤ μ * ν := Nat.le_mul_of_pos_right μ hν

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 395 at 95be5d21dd3d ↗

  5. hb have μ < b routine: omega

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hb : μ < b.

    Lean, line 396
      have hb : μ < b := by omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 396 at 95be5d21dd3d ↗

  6. hRs have ∀ (s : ℕ), s ≤ R s

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hRs : ∀ (s : ℕ), s ≤ R s.

    Lean, lines 398–404
      have hRs : ∀ s, s ≤ R s := by
        intro s
        have h1 : cq_N s μ q μ = s := Nat.mul_div_cancel _ (Nat.pow_pos hμ)
        have h2 := Finset.single_le_sum (f := fun m => cq_N s μ q m) (fun i _ => Nat.zero_le _)
          (Finset.mem_Ico.mpr ⟨le_refl μ, hb⟩)
        simp only [hR]
        omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 398–404 at 95be5d21dd3d ↗

    1. hRs.h1 have cq_N s μ q μ = s

      Leaves s ≤ R s, with h1 : cq_N s μ q μ = s.

      Uses library Nat.mul_div_cancel, Nat.pow_pos.

      Lean, line 400
          have h1 : cq_N s μ q μ = s := Nat.mul_div_cancel _ (Nat.pow_pos hμ)

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 400 at 95be5d21dd3d ↗

    2. hRs.h2 have cq_N s μ q μ ≤ ∑ x ∈ Finset.Ico μ b, cq_N s μ q x

      Leaves s ≤ R s, with h2 : cq_N s μ q μ ≤ ∑ x ∈ Finset.Ico μ b, cq_N s μ q x.

      Uses library Finset.single_le_sum, Nat.zero_le, Finset.mem_Ico, Iff.mpr Modus ponens for if and only if, reversed. , And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. , le_refl The relation ≤ on a preorder is reflexive. .

      Lean, lines 401–402
          have h2 := Finset.single_le_sum (f := fun m => cq_N s μ q m) (fun i _ => Nat.zero_le _)
            (Finset.mem_Ico.mpr ⟨le_refl μ, hb⟩)

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 401–402 at 95be5d21dd3d ↗

  7. hR0 have R (0 : ℕ) = (0 : ℕ) routine: simp

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hR0 : R (0 : ℕ) = (0 : ℕ).

    Lean, line 405
      have hR0 : R 0 = 0 := by simp [hR, cq_N]

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 405 at 95be5d21dd3d ↗

  8. hstep have ∀ (s : ℕ), R (s + (1 : ℕ)) ≤ R s + b

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hstep : ∀ (s : ℕ), R (s + (1 : ℕ)) ≤ R s + b.

    Uses library Finset.sum_add_distrib, Finset.sum_const, Nat.card_Ico, smul_eq_mul, mul_one.

    Lean, lines 406–421
      have hstep : ∀ s, R (s + 1) ≤ R s + b := by
        intro s
        have h1 : ∀ m ∈ Finset.Ico μ b, cq_N (s + 1) μ q m ≤ cq_N s μ q m + 1 := by
          intro m hm
          have hmμ := (Finset.mem_Ico.mp hm).1
          have hmq : 0 < m ^ q := Nat.pow_pos (hμ.trans_le hmμ)
          have h2 : μ ^ q ≤ m ^ q := Nat.pow_le_pow_left hmμ q
          unfold cq_N
          rw [← Nat.add_div_right _ hmq]
          apply Nat.div_le_div_right
          rw [add_mul, one_mul]
          omega
        have h2 := Finset.sum_le_sum h1
        rw [Finset.sum_add_distrib, Finset.sum_const, Nat.card_Ico, smul_eq_mul, mul_one] at h2
        simp only [hR]
        omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 406–421 at 95be5d21dd3d ↗

    1. hstep.h1 have ∀ m ∈ Finset.Ico μ b, cq_N (s + (1 : ℕ)) μ q m ≤ cq_N s μ q m + (1 : ℕ)

      Leaves R (s + (1 : ℕ)) ≤ R s + b, with h1 : ∀ m ∈ Finset.Ico μ b, cq_N (s + (1 : ℕ)) μ q m ≤ cq_N s μ q m + (1 : ℕ).

      Uses library Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Nat.add_div_right, Nat.div_le_div_right, add_mul Alias of right_distrib. , one_mul.

      Lean, lines 408–417
          have h1 : ∀ m ∈ Finset.Ico μ b, cq_N (s + 1) μ q m ≤ cq_N s μ q m + 1 := by
            intro m hm
            have hmμ := (Finset.mem_Ico.mp hm).1
            have hmq : 0 < m ^ q := Nat.pow_pos (hμ.trans_le hmμ)
            have h2 : μ ^ q ≤ m ^ q := Nat.pow_le_pow_left hmμ q
            unfold cq_N
            rw [← Nat.add_div_right _ hmq]
            apply Nat.div_le_div_right
            rw [add_mul, one_mul]
            omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 408–417 at 95be5d21dd3d ↗

      1. hstep.h1.hm_x3bc (hmμ) have μ ≤ m

        Leaves cq_N (s + (1 : ℕ)) μ q m ≤ cq_N s μ q m + (1 : ℕ), with hmμ : μ ≤ m.

        Uses library Finset.mem_Ico, Iff.mp Modus ponens for if and only if. .

        Lean, line 410
              have hmμ := (Finset.mem_Ico.mp hm).1

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 410 at 95be5d21dd3d ↗

      2. hstep.h1.hmq have (0 : ℕ) < m ^ q

        Leaves cq_N (s + (1 : ℕ)) μ q m ≤ cq_N s μ q m + (1 : ℕ), with hmq : (0 : ℕ) < m ^ q.

        Uses library Nat.pow_pos, LT.lt.trans_le Alias of lt_of_lt_of_le. .

        Lean, line 411
              have hmq : 0 < m ^ q := Nat.pow_pos (hμ.trans_le hmμ)

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 411 at 95be5d21dd3d ↗

      3. hstep.h1.h2 have μ ^ q ≤ m ^ q

        Leaves cq_N (s + (1 : ℕ)) μ q m ≤ cq_N s μ q m + (1 : ℕ), with h2 : μ ^ q ≤ m ^ q.

        Uses library Nat.pow_le_pow_left.

        Lean, line 412
              have h2 : μ ^ q ≤ m ^ q := Nat.pow_le_pow_left hmμ q

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 412 at 95be5d21dd3d ↗

    2. hstep.h2 have ∑ i ∈ Finset.Ico μ b, cq_N (s + (1 : ℕ)) μ q i ≤ ∑ i ∈ Finset.Ico μ b, (cq_N s μ q i + (1 : ℕ))

      Leaves R (s + (1 : ℕ)) ≤ R s + b, with h2 : ∑ i ∈ Finset.Ico μ b, cq_N (s + (1 : ℕ)) μ q i ≤ ∑ i ∈ Finset.Ico μ b, (cq_N s μ q i + (1 : ℕ)).

      Uses library Finset.sum_le_sum In an ordered additive commutative monoid, if each summand f i of one finite sum is less than or equal to the corresponding summand g i of another finite sum, then ∑ i ∈ s, f i ≤ ∑ i ∈ s, g i. .

      Lean, line 418
          have h2 := Finset.sum_le_sum h1

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 418 at 95be5d21dd3d ↗

  9. hex have ∃ (s : ℕ), ρ < R s

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hex : ∃ (s : ℕ), ρ < R s.

    Uses library Exists.intro Existential introduction. , Nat.lt_succ_self, LT.lt.trans_le Alias of lt_of_lt_of_le. .

    Lean, line 422
      have hex : ∃ s, ρ < R s := ⟨ρ + 1, (Nat.lt_succ_self ρ).trans_le (hRs (ρ + 1))⟩

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 422 at 95be5d21dd3d ↗

  10. s10 obtain ∃ (s : ℕ), R s ≤ ρ ∧ ρ < R (s + (1 : ℕ))

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with s : ℕ, hs1 : R s ≤ ρ, hs2 : ρ < R (s + (1 : ℕ)).

    Uses library Exists.intro Existential introduction. .

    Lean, lines 423–430
      obtain ⟨s, hs1, hs2⟩ : ∃ s, R s ≤ ρ ∧ ρ < R (s + 1) := by
        have h1 := Nat.find_spec hex
        have h0 : Nat.find hex ≠ 0 := by
          intro h; rw [h, hR0] at h1; omega
        obtain ⟨s, hs⟩ := Nat.exists_eq_succ_of_ne_zero h0
        refine ⟨s, ?_, ?_⟩
        · exact not_lt.mp (Nat.find_min hex (by omega))
        · rw [hs] at h1; exact h1

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 423–430 at 95be5d21dd3d ↗

    1. s10.h1 have ρ < R (Nat.find hex)

      Leaves ∃ (s : ℕ), R s ≤ ρ ∧ ρ < R (s + (1 : ℕ)), with h1 : ρ < R (Nat.find hex).

      Uses library Nat.find_spec.

      Lean, line 424
          have h1 := Nat.find_spec hex

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 424 at 95be5d21dd3d ↗

    2. s10.h0 have Nat.find hex ≠ (0 : ℕ)

      Leaves ∃ (s : ℕ), R s ≤ ρ ∧ ρ < R (s + (1 : ℕ)), with h0 : Nat.find hex ≠ (0 : ℕ).

      Uses library Nat.find If p is a (decidable) predicate on ℕ and hp : ∃ (n : ℕ), p n is a proof that there exists some natural number satisfying p, then Nat.find hp is the smallest natural number satisfying p. .

      Lean, lines 425–426
          have h0 : Nat.find hex ≠ 0 := by
            intro h; rw [h, hR0] at h1; omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 425–426 at 95be5d21dd3d ↗

    3. s10.s3 obtain ∃ (k : ℕ), Nat.find hex = k.succ

      Leaves ∃ (s : ℕ), R s ≤ ρ ∧ ρ < R (s + (1 : ℕ)), with s : ℕ, hs : Nat.find hex = s.succ.

      Uses library Nat.exists_eq_succ_of_ne_zero.

      Lean, line 427
          obtain ⟨s, hs⟩ := Nat.exists_eq_succ_of_ne_zero h0

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 427 at 95be5d21dd3d ↗

    4. s10.s4 case

      Leaves R s ≤ ρ.

      Uses library not_lt, Iff.mp Modus ponens for if and only if. , Nat.find_min.

      Lean, line 429
          · exact not_lt.mp (Nat.find_min hex (by omega))

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 429 at 95be5d21dd3d ↗

    5. s10.s5 case
  11. hs_x3c1 (hsρ) have s ≤ ρ

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hsρ : s ≤ ρ.

    Uses library LE.le.trans Alias of le_trans. .

    Lean, line 431
      have hsρ : s ≤ ρ := (hRs s).trans hs1

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 431 at 95be5d21dd3d ↗

  12. hrem have ρ - R s ≤ b

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hrem : ρ - R s ≤ b.

    Lean, line 432
      have hrem : ρ - R s ≤ b := by have := hstep s; omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 432 at 95be5d21dd3d ↗

    1. hrem.this have R (s + (1 : ℕ)) ≤ R s + b

      Leaves ρ - R s ≤ b, with this : R (s + (1 : ℕ)) ≤ R s + b.

      Lean, line 432
        have hrem : ρ - R s ≤ b := by have := hstep s; omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 432 at 95be5d21dd3d ↗

  13. hNle have ∀ m ∈ Finset.Ico μ b, cq_N s μ q m ≤ ρ

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hNle : ∀ m ∈ Finset.Ico μ b, cq_N s μ q m ≤ ρ.

    Uses library Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.single_le_sum, Nat.zero_le, LE.le.trans Alias of le_trans. .

    Lean, lines 433–434
      have hNle : ∀ m ∈ Finset.Ico μ b, cq_N s μ q m ≤ ρ := fun m hm =>
        (Finset.single_le_sum (f := fun m => cq_N s μ q m) (fun i _ => Nat.zero_le _) hm).trans hs1

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 433–434 at 95be5d21dd3d ↗

  14. hfil have ∀ m ∈ Finset.Ico μ b, {k ∈ Finset.Icc (1 : ℕ) ρ | k ≤ cq_N s μ q m} = Finset.Icc (1 : ℕ) (cq_N s μ q m)

    Leaves ∃ (a : ℕ → ℕ), ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧ ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hfil : ∀ m ∈ Finset.Ico μ b, {k ∈ Finset.Icc (1 : ℕ) ρ | k ≤ cq_N s μ q m} = Finset.Icc (1 : ℕ) (cq_N s μ q m).

    Uses library Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Finset.filter Finset.filter p s is the set of elements of s that satisfy p. , Finset.mem_filter, Finset.mem_Icc.

    Lean, lines 435–440
      have hfil : ∀ m ∈ Finset.Ico μ b, (Finset.Icc 1 ρ).filter (fun k => k ≤ cq_N s μ q m) = Finset.Icc 1 (cq_N s μ q m) := by
        intro m hm
        have := hNle m hm
        ext k
        simp only [Finset.mem_filter, Finset.mem_Icc]
        omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 435–440 at 95be5d21dd3d ↗

    1. hfil.this have cq_N s μ q m ≤ ρ

      Leaves {k ∈ Finset.Icc (1 : ℕ) ρ | k ≤ cq_N s μ q m} = Finset.Icc (1 : ℕ) (cq_N s μ q m), with this : cq_N s μ q m ≤ ρ.

      Lean, line 437
          have := hNle m hm

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 437 at 95be5d21dd3d ↗

  15. s15 case

    Leaves ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k = ρ.

    Uses library Finset.sum_add_distrib, Finset.sum_ite_eq' A sum taken over a conditional whose condition is an equality test on the index and whose alternative is 0 has value either the term at that index or 0. , Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , if_pos, Finset.mem_Icc, Iff.mpr Modus ponens for if and only if, reversed. , And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. , le_refl The relation ≤ on a preorder is reflexive. .

    Lean, lines 442–452
      · rw [Finset.sum_add_distrib, Finset.sum_ite_eq' (Finset.Icc 1 ρ) 1 (fun _ => ρ - R s),
          if_pos (Finset.mem_Icc.mpr ⟨le_refl 1, hρ⟩)]
        have h1 : ∑ k ∈ Finset.Icc 1 ρ, ((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card = R s := by
          simp only [Finset.card_filter]
          rw [Finset.sum_comm]
          simp only [hR]
          apply Finset.sum_congr rfl
          intro m hm
          rw [← Finset.card_filter, hfil m hm, Nat.card_Icc]
          omega
        rw [h1]; omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 442–452 at 95be5d21dd3d ↗

    1. s15.h1 have ∑ k ∈ Finset.Icc (1 : ℕ) ρ, {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card = R s

      Leaves ∑ x ∈ Finset.Icc (1 : ℕ) ρ, {m ∈ Finset.Ico μ b | x ≤ cq_N s μ q m}.card + (ρ - R s) = ρ, with h1 : ∑ k ∈ Finset.Icc (1 : ℕ) ρ, {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card = R s.

      Uses library Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.filter Finset.filter p s is the set of elements of s that satisfy p. , Finset.card s.card is the number of elements of s, aka its cardinality. , Finset.card_filter, Finset.sum_comm, Finset.sum_congr, rfl rfl : a = a is the unique constructor of the equality type. , Nat.card_Icc.

      Lean, lines 444–451
          have h1 : ∑ k ∈ Finset.Icc 1 ρ, ((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card = R s := by
            simp only [Finset.card_filter]
            rw [Finset.sum_comm]
            simp only [hR]
            apply Finset.sum_congr rfl
            intro m hm
            rw [← Finset.card_filter, hfil m hm, Nat.card_Icc]
            omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 444–451 at 95be5d21dd3d ↗

  16. s16 case

    Leaves ∀ (x : ℝ), -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x).

    Lean, lines 453–501
      · intro x
        obtain ⟨y, hy0, hyπ, hxy⟩ := cq_reduce x
        have h1 : ∑ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
            (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
            ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) +
              ((ρ - R s : ℕ) : ℝ) * Real.cos y := by
          have h2 : ∀ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
              (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
              ∑ m ∈ Finset.Ico μ b, (if k ≤ cq_N s μ q m then Real.cos ((k : ℝ) * y) else 0) +
                (if k = 1 then ((ρ - R s : ℕ) : ℝ) * Real.cos y else 0) := by
            intro k _
            rw [hxy k, Nat.cast_add, add_mul, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul]
            congr 1
            split_ifs with hk
            · rw [hk, Nat.cast_one, one_mul]
            · simp
          rw [Finset.sum_congr rfl h2, Finset.sum_add_distrib, Finset.sum_comm,
            Finset.sum_ite_eq' (Finset.Icc 1 ρ) 1 (fun _ => ((ρ - R s : ℕ) : ℝ) * Real.cos y),
            if_pos (Finset.mem_Icc.mpr ⟨le_refl 1, hρ⟩)]
          congr 1
          apply Finset.sum_congr rfl
          intro m hm
          rw [← Finset.sum_filter, hfil m hm]
        have h3 : -(b : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) * Real.cos y := by
          have h4 : ((ρ - R s : ℕ) : ℝ) ≤ b := by exact_mod_cast hrem
          have h5 : (0 : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) := Nat.cast_nonneg _
          nlinarith [Real.neg_one_le_cos y]
        have hbR : (0 : ℝ) ≤ b := Nat.cast_nonneg b
        have h6 : -(4 * (b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
          have hnonneg : (∀ k : ℕ, Real.cos ((k : ℝ) * y) = 1) ∨ s = 0 →
              0 ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
            rintro (h | h)
            · exact Finset.sum_nonneg fun m _ => Finset.sum_nonneg fun k _ => by rw [h k]; norm_num
            · have : ∀ m, cq_N s μ q m = 0 := by intro m; rw [h]; simp [cq_N]
              simp [this]
          rcases hy0.eq_or_lt with h | h
          · have := hnonneg (Or.inl fun k => by rw [← h]; simp)
            linarith
          · rcases Nat.eq_zero_or_pos s with hs0 | hs0
            · have := hnonneg (Or.inr hs0)
              linarith
            · refine cq_poly q hq μ hμ hmain s b hs0 hb.le ?_ y h hyπ
              calc 4 ^ q * (s * μ ^ q) ≤ 4 ^ q * (ν ^ q * μ ^ q) :=
                    Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ (hsρ.trans hρν))
                _ = b ^ q := by rw [hbdef, mul_pow, mul_pow]; ring
        have h7 : (b : ℝ) * 5 = ((20 * μ : ℕ) : ℝ) * ν := by rw [hbdef]; push_cast; ring
        simp only
        rw [h1]
        linarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 453–501 at 95be5d21dd3d ↗

    1. s16.s1 obtain ∃ (y : ℝ), (0 : ℝ) ≤ y ∧ y ≤ Real.pi ∧ ∀ (k : ℕ), Real.cos ((↑k : ℝ) * x) = Real.cos ((↑k : ℝ) * y)

      Leaves -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x), with y : ℝ, hy0 : (0 : ℝ) ≤ y, hyπ : y ≤ Real.pi, hxy : ∀ (k : ℕ), Real.cos ((↑k : ℝ) * x) = Real.cos ((↑k : ℝ) * y).

      Lean, line 454
          obtain ⟨y, hy0, hyπ, hxy⟩ := cq_reduce x

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 454 at 95be5d21dd3d ↗

    2. s16.h1 have ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑({m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) : ℝ) * Real.cos ((↑k : ℝ) * x) = ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y) + (↑(ρ - R s) : ℝ) * Real.cos y

      Leaves -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x), with h1 : ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑({m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) : ℝ) * Real.cos ((↑k : ℝ) * x) = ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y) + (↑(ρ - R s) : ℝ) * Real.cos y.

      Uses library Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.filter Finset.filter p s is the set of elements of s that satisfy p. , Finset.card s.card is the number of elements of s, aka its cardinality. , Real.cos The real cosine function, defined as the real part of the complex cosine , Finset.sum_congr, rfl rfl : a = a is the unique constructor of the equality type. , Finset.sum_add_distrib, Finset.sum_comm, Finset.sum_ite_eq' A sum taken over a conditional whose condition is an equality test on the index and whose alternative is 0 has value either the term at that index or 0. , if_pos, Finset.mem_Icc, Iff.mpr Modus ponens for if and only if, reversed. , And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. , le_refl The relation ≤ on a preorder is reflexive. , Finset.sum_filter.

      Lean, lines 455–475
          have h1 : ∑ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
              (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
              ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) +
                ((ρ - R s : ℕ) : ℝ) * Real.cos y := by
            have h2 : ∀ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
                (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
                ∑ m ∈ Finset.Ico μ b, (if k ≤ cq_N s μ q m then Real.cos ((k : ℝ) * y) else 0) +
                  (if k = 1 then ((ρ - R s : ℕ) : ℝ) * Real.cos y else 0) := by
              intro k _
              rw [hxy k, Nat.cast_add, add_mul, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul]
              congr 1
              split_ifs with hk
              · rw [hk, Nat.cast_one, one_mul]
              · simp
            rw [Finset.sum_congr rfl h2, Finset.sum_add_distrib, Finset.sum_comm,
              Finset.sum_ite_eq' (Finset.Icc 1 ρ) 1 (fun _ => ((ρ - R s : ℕ) : ℝ) * Real.cos y),
              if_pos (Finset.mem_Icc.mpr ⟨le_refl 1, hρ⟩)]
            congr 1
            apply Finset.sum_congr rfl
            intro m hm
            rw [← Finset.sum_filter, hfil m hm]

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 455–475 at 95be5d21dd3d ↗

      1. s16.h1.h2 have ∀ k ∈ Finset.Icc (1 : ℕ) ρ, (↑({m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) : ℝ) * Real.cos ((↑k : ℝ) * x) = (∑ m ∈ Finset.Ico μ b, if k ≤ cq_N s μ q m then Real.cos ((↑k : ℝ) * y) else (0 : ℝ)) + if k = (1 : ℕ) then (↑(ρ - R s) : ℝ) * Real.cos y else (0 : ℝ)

        Leaves ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑({m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) : ℝ) * Real.cos ((↑k : ℝ) * x) = ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y) + (↑(ρ - R s) : ℝ) * Real.cos y, with h2 : ∀ k ∈ Finset.Icc (1 : ℕ) ρ, (↑({m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) : ℝ) * Real.cos ((↑k : ℝ) * x) = (∑ m ∈ Finset.Ico μ b, if k ≤ cq_N s μ q m then Real.cos ((↑k : ℝ) * y) else (0 : ℝ)) + if k = (1 : ℕ) then (↑(ρ - R s) : ℝ) * Real.cos y else (0 : ℝ).

        Uses library Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.filter Finset.filter p s is the set of elements of s that satisfy p. , Finset.card s.card is the number of elements of s, aka its cardinality. , Real.cos The real cosine function, defined as the real part of the complex cosine , Nat.cast_add, add_mul Alias of right_distrib. , Finset.sum_filter, Finset.sum_const, nsmul_eq_mul.

        Lean, lines 459–468
              have h2 : ∀ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
                  (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
                  ∑ m ∈ Finset.Ico μ b, (if k ≤ cq_N s μ q m then Real.cos ((k : ℝ) * y) else 0) +
                    (if k = 1 then ((ρ - R s : ℕ) : ℝ) * Real.cos y else 0) := by
                intro k _
                rw [hxy k, Nat.cast_add, add_mul, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul]
                congr 1
                split_ifs with hk
                · rw [hk, Nat.cast_one, one_mul]
                · simp

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 459–468 at 95be5d21dd3d ↗

        1. s16.h1.h2.s1 case

          Leaves (↑(ρ - R s) : ℝ) * Real.cos ((↑k : ℝ) * y) = (↑(ρ - R s) : ℝ) * Real.cos y, with hk : k = (1 : ℕ).

          Uses library Nat.cast_one, one_mul.

          Lean, line 467
                  · rw [hk, Nat.cast_one, one_mul]

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 467 at 95be5d21dd3d ↗

        2. s16.h1.h2.s2 case routine: simp

          Leaves (↑(0 : ℕ) : ℝ) * Real.cos ((↑k : ℝ) * y) = (0 : ℝ), with hk : ¬k = (1 : ℕ).

          Lean, line 468
                  · simp

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 468 at 95be5d21dd3d ↗

    3. s16.h3 have -(↑b : ℝ) ≤ (↑(ρ - R s) : ℝ) * Real.cos y

      Leaves -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x), with h3 : -(↑b : ℝ) ≤ (↑(ρ - R s) : ℝ) * Real.cos y.

      Uses library Real.cos The real cosine function, defined as the real part of the complex cosine , Real.neg_one_le_cos.

      Lean, lines 476–479
          have h3 : -(b : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) * Real.cos y := by
            have h4 : ((ρ - R s : ℕ) : ℝ) ≤ b := by exact_mod_cast hrem
            have h5 : (0 : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) := Nat.cast_nonneg _
            nlinarith [Real.neg_one_le_cos y]

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 476–479 at 95be5d21dd3d ↗

      1. s16.h3.h4 have (↑(ρ - R s) : ℝ) ≤ (↑b : ℝ)

        Leaves -(↑b : ℝ) ≤ (↑(ρ - R s) : ℝ) * Real.cos y, with h4 : (↑(ρ - R s) : ℝ) ≤ (↑b : ℝ).

        Lean, line 477
              have h4 : ((ρ - R s : ℕ) : ℝ) ≤ b := by exact_mod_cast hrem

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 477 at 95be5d21dd3d ↗

      2. s16.h3.h5 have (0 : ℝ) ≤ (↑(ρ - R s) : ℝ)

        Leaves -(↑b : ℝ) ≤ (↑(ρ - R s) : ℝ) * Real.cos y, with h5 : (0 : ℝ) ≤ (↑(ρ - R s) : ℝ).

        Uses library Nat.cast_nonneg Specialisation of Nat.cast_nonneg', which seems to be easier for Lean to use. .

        Lean, line 478
              have h5 : (0 : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) := Nat.cast_nonneg _

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 478 at 95be5d21dd3d ↗

    4. s16.hbR have (0 : ℝ) ≤ (↑b : ℝ)

      Leaves -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x), with hbR : (0 : ℝ) ≤ (↑b : ℝ).

      Uses library Nat.cast_nonneg Specialisation of Nat.cast_nonneg', which seems to be easier for Lean to use. .

      Lean, line 480
          have hbR : (0 : ℝ) ≤ b := Nat.cast_nonneg b

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 480 at 95be5d21dd3d ↗

    5. s16.h6 have -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y)

      Leaves -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x), with h6 : -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y).

      Uses library Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Real.cos The real cosine function, defined as the real part of the complex cosine , LE.le.eq_or_lt Alias of eq_or_lt_of_le. .

      Lean, lines 481–497
          have h6 : -(4 * (b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
            have hnonneg : (∀ k : ℕ, Real.cos ((k : ℝ) * y) = 1) ∨ s = 0 →
                0 ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
              rintro (h | h)
              · exact Finset.sum_nonneg fun m _ => Finset.sum_nonneg fun k _ => by rw [h k]; norm_num
              · have : ∀ m, cq_N s μ q m = 0 := by intro m; rw [h]; simp [cq_N]
                simp [this]
            rcases hy0.eq_or_lt with h | h
            · have := hnonneg (Or.inl fun k => by rw [← h]; simp)
              linarith
            · rcases Nat.eq_zero_or_pos s with hs0 | hs0
              · have := hnonneg (Or.inr hs0)
                linarith
              · refine cq_poly q hq μ hμ hmain s b hs0 hb.le ?_ y h hyπ
                calc 4 ^ q * (s * μ ^ q) ≤ 4 ^ q * (ν ^ q * μ ^ q) :=
                      Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ (hsρ.trans hρν))
                  _ = b ^ q := by rw [hbdef, mul_pow, mul_pow]; ring

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 481–497 at 95be5d21dd3d ↗

      1. s16.h6.hnonneg have (∀ (k : ℕ), Real.cos ((↑k : ℝ) * y) = (1 : ℝ)) ∨ s = (0 : ℕ) → (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y)

        Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with hnonneg : (∀ (k : ℕ), Real.cos ((↑k : ℝ) * y) = (1 : ℝ)) ∨ s = (0 : ℕ) → (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y).

        Uses library Real.cos The real cosine function, defined as the real part of the complex cosine , Finset.Ico The finset $[a, b)$ of elements x such that a ≤ x and x < b. , Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. .

        Lean, lines 482–487
              have hnonneg : (∀ k : ℕ, Real.cos ((k : ℝ) * y) = 1) ∨ s = 0 →
                  0 ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
                rintro (h | h)
                · exact Finset.sum_nonneg fun m _ => Finset.sum_nonneg fun k _ => by rw [h k]; norm_num
                · have : ∀ m, cq_N s μ q m = 0 := by intro m; rw [h]; simp [cq_N]
                  simp [this]

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 482–487 at 95be5d21dd3d ↗

        1. s16.h6.hnonneg.s1 case

          Leaves (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with h : ∀ (k : ℕ), Real.cos ((↑k : ℝ) * y) = (1 : ℝ).

          Uses library Finset.sum_nonneg.

          Lean, line 485
                  · exact Finset.sum_nonneg fun m _ => Finset.sum_nonneg fun k _ => by rw [h k]; norm_num

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 485 at 95be5d21dd3d ↗

        2. s16.h6.hnonneg.s2 case

          Leaves (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with h : s = (0 : ℕ).

          Lean, lines 486–487
                  · have : ∀ m, cq_N s μ q m = 0 := by intro m; rw [h]; simp [cq_N]
                    simp [this]

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 486–487 at 95be5d21dd3d ↗

          1. s16.h6.hnonneg.s2.this have ∀ (m : ℕ), cq_N s μ q m = (0 : ℕ)

            Leaves (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with this : ∀ (m : ℕ), cq_N s μ q m = (0 : ℕ).

            Lean, line 486
                    · have : ∀ m, cq_N s μ q m = 0 := by intro m; rw [h]; simp [cq_N]

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 486 at 95be5d21dd3d ↗

      2. s16.h6.s2 case

        Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with h : (0 : ℝ) = y.

        Lean, lines 489–490
              · have := hnonneg (Or.inl fun k => by rw [← h]; simp)
                linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 489–490 at 95be5d21dd3d ↗

        1. s16.h6.s2.this have (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y)

          Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with this : (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y).

          Uses library Or.inl Or.inl is "left injection" into an Or. .

          Lean, line 489
                · have := hnonneg (Or.inl fun k => by rw [← h]; simp)

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 489 at 95be5d21dd3d ↗

      3. s16.h6.s3 case

        Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with h : (0 : ℝ) < y.

        Uses library Nat.eq_zero_or_pos.

        Lean, lines 491–497
              · rcases Nat.eq_zero_or_pos s with hs0 | hs0
                · have := hnonneg (Or.inr hs0)
                  linarith
                · refine cq_poly q hq μ hμ hmain s b hs0 hb.le ?_ y h hyπ
                  calc 4 ^ q * (s * μ ^ q) ≤ 4 ^ q * (ν ^ q * μ ^ q) :=
                        Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ (hsρ.trans hρν))
                    _ = b ^ q := by rw [hbdef, mul_pow, mul_pow]; ring

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 491–497 at 95be5d21dd3d ↗

        1. s16.h6.s3.s1 case

          Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with hs0 : s = (0 : ℕ).

          Lean, lines 492–493
                  · have := hnonneg (Or.inr hs0)
                    linarith

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 492–493 at 95be5d21dd3d ↗

          1. s16.h6.s3.s1.this have (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y)

            Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with this : (0 : ℝ) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y).

            Uses library Or.inr Or.inr is "right injection" into an Or. .

            Lean, line 492
                    · have := hnonneg (Or.inr hs0)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 492 at 95be5d21dd3d ↗

        2. s16.h6.s3.s2 case

          Leaves -((4 : ℝ) * (↑b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc (1 : ℕ) (cq_N s μ q m), Real.cos ((↑k : ℝ) * y), with hs0 : s > (0 : ℕ).

          Uses library LT.lt.le Alias of le_of_lt. .

          Lean, lines 494–497
                  · refine cq_poly q hq μ hμ hmain s b hs0 hb.le ?_ y h hyπ
                    calc 4 ^ q * (s * μ ^ q) ≤ 4 ^ q * (ν ^ q * μ ^ q) :=
                          Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ (hsρ.trans hρν))
                      _ = b ^ q := by rw [hbdef, mul_pow, mul_pow]; ring

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 494–497 at 95be5d21dd3d ↗

          1. s16.h6.s3.s2.s1 calc (4 : ℕ) ^ q * (s * μ ^ q) ≤ (4 : ℕ) ^ q * (ν ^ q * μ ^ q)

            Closes the goal.

            Uses library Nat.mul_le_mul_left, Nat.mul_le_mul_right, LE.le.trans Alias of le_trans. .

            Lean, lines 495–496
                      calc 4 ^ q * (s * μ ^ q) ≤ 4 ^ q * (ν ^ q * μ ^ q) :=
                            Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ (hsρ.trans hρν))

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, lines 495–496 at 95be5d21dd3d ↗

          2. s16.h6.s3.s2.s2 calc

            Closes the goal.

            Uses library mul_pow.

            Lean, line 497
                        _ = b ^ q := by rw [hbdef, mul_pow, mul_pow]; ring

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 497 at 95be5d21dd3d ↗

    6. s16.h7 have (↑b : ℝ) * (5 : ℝ) = (↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)

      Leaves -((↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑((fun (k : ℕ) => {m ∈ Finset.Ico μ b | k ≤ cq_N s μ q m}.card + if k = (1 : ℕ) then ρ - R s else (0 : ℕ)) k) : ℝ) * Real.cos ((↑k : ℝ) * x), with h7 : (↑b : ℝ) * (5 : ℝ) = (↑((20 : ℕ) * μ) : ℝ) * (↑ν : ℝ).

      Lean, line 498
          have h7 : (b : ℝ) * 5 = ((20 * μ : ℕ) : ℝ) * ν := by rw [hbdef]; push_cast; ring

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2/Proof.lean, line 498 at 95be5d21dd3d ↗

The proof in Lean (Proof.lean)

Checked by the kernel — these bytes are the ones its attestation names: attestations/002857.erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2.json, merge commit 9a0c8b0f096c.

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--h2--h5--h2--h2--h1--h2--h2/Proof.lean, sha256 9d3e2cb014e0.
import Mathlib
import Nodes.«erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2».Context

open scoped Nat

/-! Hole `h_cos` 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 lemma cq_dirichlet (N : ℕ) (x : ℝ) :
    2 * Real.sin (x / 2) * ∑ k ∈ Finset.Icc 1 N, Real.cos ((k : ℝ) * x) =
      Real.sin (((N : ℝ) + 1 / 2) * x) - Real.sin (x / 2) := by
  induction N with
  | zero =>
    have e : (((0 : ℕ) : ℝ) + 1 / 2) * x = x / 2 := by push_cast; ring
    rw [e]; simp
  | succ N ih =>
    rw [Finset.sum_Icc_succ_top (by omega), mul_add, ih]
    have e1 : (((N + 1 : ℕ) : ℝ) + 1 / 2) * x = ((N + 1 : ℕ) : ℝ) * x + x / 2 := by ring
    have e2 : ((N : ℝ) + 1 / 2) * x = ((N + 1 : ℕ) : ℝ) * x - x / 2 := by push_cast; ring
    rw [e1, e2, Real.sin_add, Real.sin_sub]
    ring

private noncomputable def cq_g (w : ℝ) (q : ℕ) (u : ℝ) : ℝ := w ^ q * (u ^ q)⁻¹

private noncomputable def cq_P (w : ℝ) (q : ℕ) (u : ℝ) : ℝ :=
  -(u ^ (q + 1) / (q * w ^ q)) * (1 - Real.cos (cq_g w q u))

private lemma cq_g_pos (w : ℝ) (hw : 0 < w) (q : ℕ) (u : ℝ) (hu : 0 < u) : 0 < cq_g w q u := by
  unfold cq_g; positivity

private lemma cq_g_anti (w : ℝ) (hw : 0 < w) (q : ℕ) (u v : ℝ) (hu : 0 < u) (huv : u ≤ v) :
    cq_g w q v ≤ cq_g w q u := by
  unfold cq_g
  have h1 : u ^ q ≤ v ^ q := pow_le_pow_left₀ hu.le huv q
  exact mul_le_mul_of_nonneg_left (inv_anti₀ (by positivity) h1) (by positivity)

private lemma cq_deriv (w : ℝ) (hw : 0 < w) (q : ℕ) (hq : 2 ≤ q) (u : ℝ) (hu : 0 < u) :
    HasDerivAt (cq_P w q) (Real.sin (cq_g w q u) -
      ((q : ℝ) + 1) / (q * cq_g w q u) * (1 - Real.cos (cq_g w q u))) u := by
  have hq0 : (q : ℝ) ≠ 0 := by positivity
  have h1 : HasDerivAt (fun u : ℝ => u ^ q) ((q : ℝ) * u ^ (q - 1)) u := hasDerivAt_pow q u
  have h2 : HasDerivAt (cq_g w q) (w ^ q * (-((q : ℝ) * u ^ (q - 1)) / (u ^ q) ^ 2)) u :=
    (h1.inv (by positivity)).const_mul (w ^ q)
  have h3 : HasDerivAt (fun u : ℝ => -(u ^ (q + 1) / (q * w ^ q)))
      (-((((q + 1 : ℕ) : ℝ) * u ^ (q + 1 - 1)) / (q * w ^ q))) u :=
    ((hasDerivAt_pow (q + 1) u).div_const _).neg
  have h4 := h3.mul ((h2.cos).const_sub 1)
  refine h4.congr_deriv ?_
  have e : u ^ q = u ^ (q - 1) * u := by rw [← pow_succ]; congr 1; omega
  unfold cq_g
  rw [Nat.add_sub_cancel, pow_succ u q, e]
  push_cast
  field_simp
  ring

/-- One step: `sin g(m)` dominates the increment of `P + g`, with a gain where `1 ≤ g ≤ 2`. -/
private lemma cq_step (w : ℝ) (hw : 0 < w) (q : ℕ) (hq : 2 ≤ q) (m : ℝ) (hm : 0 < m) (e : ℝ)
    (he : e = 0 ∨ (e = 1 / 5 ∧ cq_g w q m ≤ 2 ∧ 1 ≤ cq_g w q (m + 1))) :
    (cq_P w q (m + 1) + cq_g w q (m + 1)) - (cq_P w q m + cq_g w q m) + e ≤ Real.sin (cq_g w q m) := by
  obtain ⟨c, hc, hc2⟩ := exists_hasDerivAt_eq_slope (cq_P w q) _ (show m < m + 1 by linarith)
    (fun u hu => (cq_deriv w hw q hq u (lt_of_lt_of_le hm hu.1)).continuousAt.continuousWithinAt)
    (fun u hu => cq_deriv w hw q hq u (hm.trans hu.1))
  have hc0 : 0 < c := hm.trans hc.1
  have hgc := cq_g_pos w hw q c hc0
  have h1 := cq_g_anti w hw q m c hm hc.1.le
  have h2 := cq_g_anti w hw q c (m + 1) hc0 hc.2.le
  have e1 : m + 1 - m = 1 := by ring
  rw [e1, div_one] at hc2
  have hlip : Real.sin (cq_g w q c) - Real.sin (cq_g w q m) ≤ cq_g w q m - cq_g w q c := by
    have h := Real.abs_sin_sub_sin_le (cq_g w q c) (cq_g w q m)
    have h3 := le_abs_self (Real.sin (cq_g w q c) - Real.sin (cq_g w q m))
    rw [abs_sub_comm (cq_g w q c), abs_of_nonneg (sub_nonneg.mpr h1)] at h
    linarith
  have hgain : e ≤ ((q : ℝ) + 1) / (q * cq_g w q c) * (1 - Real.cos (cq_g w q c)) := by
    have hcos : 0 ≤ 1 - Real.cos (cq_g w q c) := by linarith [Real.cos_le_one (cq_g w q c)]
    have hq0 : (0 : ℝ) < q := by exact_mod_cast (by omega : 0 < q)
    rcases he with he | ⟨he, h3, h4⟩
    · rw [he]; positivity
    · have h5 : Real.cos (cq_g w q c) ≤ Real.cos 1 :=
        Real.cos_le_cos_of_nonneg_of_le_pi (by norm_num) (by linarith [Real.pi_gt_three]) (by linarith)
      have h6 := Real.cos_one_le
      have h7 : 1 / 2 ≤ ((q : ℝ) + 1) / (q * cq_g w q c) := by
        rw [div_le_div_iff₀ (by norm_num) (by positivity)]
        nlinarith
      rw [he]
      nlinarith
  linarith

private lemma cq_tele (F : ℕ → ℝ) (a b : ℕ) (hab : a ≤ b) :
    ∑ m ∈ Finset.Ico a b, (F (m + 1) - F m) = F b - F a := by
  induction b, hab using Nat.le_induction with
  | base => simp
  | succ b hb ih => rw [Finset.sum_Ico_succ_top hb, ih]; ring

private lemma cq_half (q : ℕ) (hq : 2 ≤ q) (y : ℝ) (hy : 0 ≤ y) (h : y ≤ 1 + 1 / (2 * (q : ℝ))) : y ^ q ≤ 2 := by
  have hq0 : (0 : ℝ) < q := by exact_mod_cast (by omega : 0 < q)
  have h1 : y ≤ Real.exp (1 / (2 * (q : ℝ))) := by
    linarith [Real.add_one_le_exp (1 / (2 * (q : ℝ)))]
  have h2 : y ^ q ≤ Real.exp (1 / (2 * (q : ℝ))) ^ q := pow_le_pow_left₀ hy h1 q
  rw [← Real.exp_nat_mul] at h2
  have e : (q : ℝ) * (1 / (2 * (q : ℝ))) = 1 / 2 := by field_simp
  rw [e] at h2
  have h3 : Real.exp (1 / 2) ≤ 2 := by
    have h4 : Real.exp (1 / 2) ^ (2 : ℕ) ≤ 2 ^ (2 : ℕ) := by
      rw [← Real.exp_nat_mul]
      have e2 : ((2 : ℕ) : ℝ) * (1 / 2) = 1 := by norm_num
      rw [e2]
      linarith [Real.exp_one_lt_d9]
    exact le_of_pow_le_pow_left₀ (by norm_num) (by norm_num) h4
  linarith

/-- The sum of `sin ((w/m)^q)` over `μ ≤ m < b` is almost nonnegative once `μ` is large. -/
private lemma cq_main (q : ℕ) (hq : 2 ≤ q) : ∃ μ : ℕ, 0 < μ ∧ ∀ (w : ℝ), 0 < w → ∀ b : ℕ, μ ≤ b → w ≤ b →
    -((b : ℝ) * cq_g w q b) ≤ ∑ m ∈ Finset.Ico μ b, Real.sin (cq_g w q m) := by
  have hqR : (2 : ℝ) ≤ q := by exact_mod_cast hq
  obtain ⟨c, hc⟩ : ∃ c : ℝ, c = 1 / (2 * (q : ℝ) + 1) := ⟨_, rfl⟩
  have hc0 : 0 < c := by rw [hc]; positivity
  have hc1 : c ≤ 1 / 5 := by
    rw [hc]; exact one_div_le_one_div_of_le (by norm_num) (by linarith)
  have hcq : c * (2 * (q : ℝ) + 1) = 1 := by rw [hc]; field_simp
  obtain ⟨B, hB⟩ : ∃ B : ℝ, B = (10 / c) ^ q := ⟨_, rfl⟩
  have hB0 : 0 < B := by rw [hB]; positivity
  refine ⟨⌈10 / c * (B + 2)⌉₊ + 1, by omega, ?_⟩
  set μ := ⌈10 / c * (B + 2)⌉₊ + 1 with hμ
  intro w hw b hb hwb
  have hμ1 : 10 / c * (B + 2) ≤ (μ : ℝ) := by
    rw [hμ]; push_cast
    linarith [Nat.le_ceil (10 / c * (B + 2))]
  have hμ0 : (0 : ℝ) < μ := by positivity
  have hbR : (0 : ℝ) < b := lt_of_lt_of_le hμ0 (by exact_mod_cast hb)
  have hgb := cq_g_pos w hw q b hbR
  have hfrac : ∀ u : ℝ, 0 < u → cq_g w q u = (w / u) ^ q := by
    intro u hu; unfold cq_g; rw [div_pow]; rfl
  by_cases hsmall : cq_g w q μ ≤ 3
  · have h0 : 0 ≤ ∑ m ∈ Finset.Ico μ b, Real.sin (cq_g w q m) := by
      apply Finset.sum_nonneg
      intro m hm
      have hm1 : (μ : ℝ) ≤ m := by exact_mod_cast (Finset.mem_Ico.mp hm).1
      have h1 := cq_g_anti w hw q μ m hμ0 hm1
      have h2 := cq_g_pos w hw q m (hμ0.trans_le hm1)
      exact Real.sin_nonneg_of_nonneg_of_le_pi h2.le (by linarith [Real.pi_gt_three])
    have : 0 ≤ (b : ℝ) * cq_g w q b := by positivity
    linarith
  rw [not_le] at hsmall
  have hμw : (μ : ℝ) ≤ w * (1 - c) := by
    by_contra hcon
    rw [not_le] at hcon
    have h1 : w / μ ≤ 1 + 1 / (2 * (q : ℝ)) := by
      rw [div_le_iff₀ hμ0]
      have e : (1 + 1 / (2 * (q : ℝ))) * (1 - c) = 1 := by rw [hc]; field_simp; ring
      have h2 : 0 < 1 + 1 / (2 * (q : ℝ)) := by positivity
      have h3 := mul_le_mul_of_nonneg_left hcon.le h2.le
      have h4 : (1 + 1 / (2 * (q : ℝ))) * (w * (1 - c)) = w := by
        calc _ = w * ((1 + 1 / (2 * (q : ℝ))) * (1 - c)) := by ring
          _ = w := by rw [e, mul_one]
      linarith
    have h2 := cq_half q hq (w / μ) (by positivity) h1
    rw [hfrac μ hμ0] at hsmall
    linarith
  have hwμ : (μ : ℝ) ≤ w := by nlinarith
  set P := ⌈w * (1 - c)⌉₊ with hP
  set Q := ⌊w⌋₊ with hQ
  set a := max μ ⌈c / 10 * w⌉₊ with ha
  have hwc : 0 ≤ w * (1 - c) := by nlinarith
  have haP : a ≤ P := by
    apply max_le
    · have := hμw.trans (Nat.le_ceil (w * (1 - c)))
      exact_mod_cast this
    · exact Nat.ceil_mono (by nlinarith)
  have hQw : (Q : ℝ) ≤ w := Nat.floor_le hw.le
  have hQb : Q ≤ b := by exact_mod_cast hQw.trans hwb
  have hPw : (P : ℝ) < w * (1 - c) + 1 := Nat.ceil_lt_add_one hwc
  have hQw2 : w < (Q : ℝ) + 1 := Nat.lt_floor_add_one w
  have hab : a ≤ b := by
    apply max_le hb
    have : (⌈c / 10 * w⌉₊ : ℕ) ≤ b := by
      rw [Nat.ceil_le]; nlinarith
    exact this
  have haμ : μ ≤ a := le_max_left _ _
  have haR : (0 : ℝ) < a := hμ0.trans_le (by exact_mod_cast haμ)
  have hga : cq_g w q a ≤ B := by
    rw [hfrac a haR, hB]
    apply pow_le_pow_left₀ (by positivity)
    have h1 : c / 10 * w ≤ a := (Nat.le_ceil _).trans (by exact_mod_cast le_max_right _ _)
    rw [div_le_div_iff₀ haR hc0]
    linarith
  have hcost : (a : ℝ) - μ ≤ c / 10 * w + 1 := by
    have h1 : (⌈c / 10 * w⌉₊ : ℝ) < c / 10 * w + 1 := Nat.ceil_lt_add_one (by positivity)
    rw [ha, Nat.cast_max]
    rcases le_total (μ : ℝ) (⌈c / 10 * w⌉₊ : ℝ) with h | h
    · rw [max_eq_right h]; linarith
    · rw [max_eq_left h]
      have : 0 < c / 10 * w := by positivity
      linarith
  have hfirst : -((a : ℝ) - μ) ≤ ∑ m ∈ Finset.Ico μ a, Real.sin (cq_g w q m) := by
    have h := Finset.card_nsmul_le_sum (Finset.Ico μ a) (fun m : ℕ => Real.sin (cq_g w q m)) (-1)
      (fun m _ => Real.neg_one_le_sin _)
    rw [Nat.card_Ico, nsmul_eq_mul, Nat.cast_sub haμ] at h
    linarith
  set F : ℕ → ℝ := fun m => cq_P w q m + cq_g w q m with hF
  have hsecond : F b - F a + ((Q : ℝ) - P) / 5 ≤ ∑ m ∈ Finset.Ico a b, Real.sin (cq_g w q m) := by
    have h1 : ∑ m ∈ Finset.Ico a b, ((F (m + 1) - F m) + (if P ≤ m ∧ m < Q then (1 / 5 : ℝ) else 0)) ≤
        ∑ m ∈ Finset.Ico a b, Real.sin (cq_g w q m) := by
      apply Finset.sum_le_sum
      intro m hm
      have hma : (a : ℝ) ≤ m := by exact_mod_cast (Finset.mem_Ico.mp hm).1
      have hm0 : (0 : ℝ) < m := haR.trans_le hma
      have h := cq_step w hw q hq m hm0 (if P ≤ m ∧ m < Q then (1 / 5 : ℝ) else 0) (by
        by_cases hc3 : P ≤ m ∧ m < Q
        · right
          rw [if_pos hc3]
          refine ⟨rfl, ?_, ?_⟩
          · rw [hfrac m hm0]
            apply cq_half q hq _ (by positivity)
            have h2 : w * (1 - c) ≤ m := (Nat.le_ceil _).trans (by exact_mod_cast hc3.1)
            rw [div_le_iff₀ hm0]
            have e : (1 + 1 / (2 * (q : ℝ))) * (1 - c) = 1 := by rw [hc]; field_simp; ring
            have h3 : 0 < 1 + 1 / (2 * (q : ℝ)) := by positivity
            have h4 := mul_le_mul_of_nonneg_left h2 h3.le
            have h5 : (1 + 1 / (2 * (q : ℝ))) * (w * (1 - c)) = w := by
              calc _ = w * ((1 + 1 / (2 * (q : ℝ))) * (1 - c)) := by ring
                _ = w := by rw [e, mul_one]
            linarith
          · rw [hfrac _ (by positivity)]
            apply one_le_pow₀
            rw [one_le_div (by positivity)]
            have : ((m + 1 : ℕ) : ℝ) ≤ Q := by exact_mod_cast hc3.2
            push_cast at this
            linarith
        · left; rw [if_neg hc3])
      simp only [hF]
      push_cast
      linarith
    rw [Finset.sum_add_distrib, cq_tele F a b hab, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] at h1
    have h2 : Finset.Ico P Q ⊆ (Finset.Ico a b).filter (fun m => P ≤ m ∧ m < Q) := by
      intro m hm
      rw [Finset.mem_Ico] at hm
      rw [Finset.mem_filter, Finset.mem_Ico]
      exact ⟨⟨haP.trans hm.1, hm.2.trans_le hQb⟩, hm⟩
    have h3 := Finset.card_le_card h2
    rw [Nat.card_Ico] at h3
    have h4 : (Q : ℝ) - P ≤ (((Finset.Ico a b).filter (fun m => P ≤ m ∧ m < Q)).card : ℝ) := by
      have h5 : Q ≤ ((Finset.Ico a b).filter (fun m => P ≤ m ∧ m < Q)).card + P := by omega
      have h6 : (Q : ℝ) ≤ (((Finset.Ico a b).filter (fun m => P ≤ m ∧ m < Q)).card : ℝ) + P := by exact_mod_cast h5
      linarith
    linarith
  have hFa : F a ≤ B := by
    have h1 : cq_P w q a ≤ 0 := by
      unfold cq_P
      have h2 : 0 ≤ 1 - Real.cos (cq_g w q a) := by linarith [Real.cos_le_one (cq_g w q a)]
      have h3 : 0 ≤ (a : ℝ) ^ (q + 1) / (q * w ^ q) := by positivity
      nlinarith
    simp only [hF]; linarith
  have hFb : -((b : ℝ) * cq_g w q b) ≤ F b := by
    have h1 : 1 - Real.cos (cq_g w q b) ≤ cq_g w q b ^ 2 / 2 := by
      linarith [Real.one_sub_sq_div_two_le_cos (x := cq_g w q b)]
    have h2 : 0 ≤ (b : ℝ) ^ (q + 1) / (q * w ^ q) := by positivity
    have h3 := mul_le_mul_of_nonneg_left h1 h2
    have h4 : (b : ℝ) ^ (q + 1) / (q * w ^ q) * (cq_g w q b ^ 2 / 2) = (b : ℝ) * cq_g w q b / (2 * q) := by
      unfold cq_g
      rw [pow_succ]
      field_simp
    have h5 : (b : ℝ) * cq_g w q b / (2 * q) ≤ (b : ℝ) * cq_g w q b :=
      div_le_self (by positivity) (by linarith)
    simp only [hF]
    unfold cq_P
    linarith
  rw [← Finset.sum_Ico_consecutive _ haμ hab]
  have hfin : B + 2 ≤ c / 10 * w := by
    have h1 : 10 / c * (B + 2) ≤ w := hμ1.trans hwμ
    have h2 := mul_le_mul_of_nonneg_left h1 (show 0 ≤ c / 10 by positivity)
    have e : c / 10 * (10 / c * (B + 2)) = B + 2 := by field_simp
    linarith
  linarith

private def cq_N (s μ q m : ℕ) : ℕ := (s * μ ^ q) / m ^ q

/-- For `0 < x ≤ π`: the sum of Dirichlet kernels is at least `-4b`. -/
private lemma cq_poly (q : ℕ) (hq : 2 ≤ q) (μ : ℕ) (hμ : 0 < μ)
    (hmain : ∀ (w : ℝ), 0 < w → ∀ b : ℕ, μ ≤ b → w ≤ b →
      -((b : ℝ) * cq_g w q b) ≤ ∑ m ∈ Finset.Ico μ b, Real.sin (cq_g w q m))
    (s b : ℕ) (hs : 0 < s) (hb : μ ≤ b) (hsb : 4 ^ q * (s * μ ^ q) ≤ b ^ q) (x : ℝ) (hx : 0 < x) (hxπ : x ≤ Real.pi) :
    -(4 * (b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * x) := by
  have hμR : (0 : ℝ) < μ := by exact_mod_cast hμ
  have hsR : (0 : ℝ) < s := by exact_mod_cast hs
  have hbR : (0 : ℝ) < b := hμR.trans_le (by exact_mod_cast hb)
  have hq0 : (q : ℝ) ≠ 0 := by positivity
  have hsbR : (4 : ℝ) ^ q * (s * (μ : ℝ) ^ q) ≤ (b : ℝ) ^ q := by exact_mod_cast hsb
  have hpi4 : x ≤ 4 := hxπ.trans Real.pi_le_four
  obtain ⟨z, hz0, hzq⟩ : ∃ z : ℝ, 0 < z ∧ z ^ q = s * x := by
    refine ⟨(s * x) ^ (1 / (q : ℝ)), by positivity, ?_⟩
    rw [← Real.rpow_natCast, ← Real.rpow_mul (by positivity), one_div_mul_cancel hq0, Real.rpow_one]
  have hwq : (z * μ) ^ q = s * x * (μ : ℝ) ^ q := by rw [mul_pow, hzq]
  have h4q : (4 : ℝ) ≤ 4 ^ q := by
    calc (4 : ℝ) = 4 ^ 1 := by norm_num
      _ ≤ 4 ^ q := pow_le_pow_right₀ (by norm_num) (by omega)
  have hwb : z * μ ≤ b := by
    apply le_of_pow_le_pow_left₀ (show q ≠ 0 by omega) hbR.le
    rw [hwq]
    calc (s : ℝ) * x * (μ : ℝ) ^ q = x * (s * (μ : ℝ) ^ q) := by ring
      _ ≤ 4 ^ q * (s * (μ : ℝ) ^ q) := mul_le_mul_of_nonneg_right (hpi4.trans h4q) (by positivity)
      _ ≤ (b : ℝ) ^ q := hsbR
  have h1 := hmain (z * μ) (by positivity) b hb hwb
  have hg : ∀ u : ℝ, cq_g (z * μ) q u = x * (s * (μ : ℝ) ^ q * (u ^ q)⁻¹) := by
    intro u; unfold cq_g; rw [hwq]; ring
  have htail : cq_g (z * μ) q b ≤ x := by
    rw [hg]
    have h2 : (s : ℝ) * (μ : ℝ) ^ q * ((b : ℝ) ^ q)⁻¹ ≤ 1 := by
      rw [← div_eq_mul_inv, div_le_one (by positivity)]
      have : 0 ≤ (s : ℝ) * (μ : ℝ) ^ q := by positivity
      nlinarith
    calc x * (s * (μ : ℝ) ^ q * ((b : ℝ) ^ q)⁻¹) ≤ x * 1 := mul_le_mul_of_nonneg_left h2 hx.le
      _ = x := mul_one x
  have hterm : ∀ m ∈ Finset.Ico μ b, Real.sin (cq_g (z * μ) q m) - x / 2 ≤
      Real.sin (((cq_N s μ q m : ℝ) + 1 / 2) * x) := by
    intro m hm
    have hm0 : 0 < m := hμ.trans_le (Finset.mem_Ico.mp hm).1
    have hmq : 0 < m ^ q := Nat.pow_pos hm0
    have hmqR : (0 : ℝ) < (m : ℝ) ^ q := by exact_mod_cast hmq
    set r : ℝ := s * (μ : ℝ) ^ q * ((m : ℝ) ^ q)⁻¹ with hr
    have hr' : r * (m : ℝ) ^ q = s * (μ : ℝ) ^ q := by rw [hr]; field_simp
    have hlo : (cq_N s μ q m : ℝ) ≤ r := by
      have h2 : cq_N s μ q m * m ^ q ≤ s * μ ^ q := Nat.div_mul_le_self _ _
      have h3 : (cq_N s μ q m : ℝ) * (m : ℝ) ^ q ≤ s * (μ : ℝ) ^ q := by exact_mod_cast h2
      rw [← hr'] at h3
      exact le_of_mul_le_mul_right h3 hmqR
    have hhi : r ≤ (cq_N s μ q m : ℝ) + 1 := by
      have h2 : s * μ ^ q < (cq_N s μ q m + 1) * m ^ q := by
        have h := Nat.lt_mul_div_succ (s * μ ^ q) hmq
        calc s * μ ^ q < m ^ q * (s * μ ^ q / m ^ q + 1) := h
          _ = (cq_N s μ q m + 1) * m ^ q := mul_comm _ _
      have h3 : (s : ℝ) * (μ : ℝ) ^ q < ((cq_N s μ q m : ℝ) + 1) * (m : ℝ) ^ q := by exact_mod_cast h2
      rw [← hr'] at h3
      exact (lt_of_mul_lt_mul_right h3 hmqR.le).le
    have h4 := Real.abs_sin_sub_sin_le (cq_g (z * μ) q m) (((cq_N s μ q m : ℝ) + 1 / 2) * x)
    have h5 := le_abs_self (Real.sin (cq_g (z * μ) q m) - Real.sin (((cq_N s μ q m : ℝ) + 1 / 2) * x))
    have h6 : |cq_g (z * μ) q m - ((cq_N s μ q m : ℝ) + 1 / 2) * x| ≤ x / 2 := by
      rw [hg, ← hr, abs_le]
      constructor <;> nlinarith
    linarith
  have hsum := Finset.sum_le_sum hterm
  rw [Finset.sum_sub_distrib, Finset.sum_const, Nat.card_Ico, nsmul_eq_mul, Nat.cast_sub hb] at hsum
  have hD : 2 * Real.sin (x / 2) * ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * x) =
      ∑ m ∈ Finset.Ico μ b, Real.sin (((cq_N s μ q m : ℝ) + 1 / 2) * x) - ((b : ℝ) - μ) * Real.sin (x / 2) := by
    rw [Finset.mul_sum, Finset.sum_congr rfl (fun m _ => cq_dirichlet (cq_N s μ q m) x),
      Finset.sum_sub_distrib, Finset.sum_const, Nat.card_Ico, nsmul_eq_mul, Nat.cast_sub hb]
  have hsin : x / 4 ≤ Real.sin (x / 2) := by
    have h2 := Real.mul_le_sin (show 0 ≤ x / 2 by linarith) (by linarith)
    have h3 : 1 / 4 ≤ 1 / Real.pi := one_div_le_one_div_of_le Real.pi_pos Real.pi_le_four
    have h4 : 2 / Real.pi * (x / 2) = 1 / Real.pi * x := by ring
    rw [h4] at h2
    nlinarith
  have hsin0 : 0 < Real.sin (x / 2) := by linarith
  set T := ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * x) with hT
  have h7 : (b : ℝ) * cq_g (z * μ) q b ≤ b * x := mul_le_mul_of_nonneg_left htail hbR.le
  have h8 : ((b : ℝ) - μ) * (x / 2) ≤ b * (x / 2) := mul_le_mul_of_nonneg_right (by linarith) (by linarith)
  have h9 : ((b : ℝ) - μ) * Real.sin (x / 2) ≤ b * Real.sin (x / 2) := mul_le_mul_of_nonneg_right (by linarith) hsin0.le
  have h10 : (b : ℝ) * (x / 4) ≤ b * Real.sin (x / 2) := mul_le_mul_of_nonneg_left hsin hbR.le
  have h11 : 0 ≤ 2 * Real.sin (x / 2) * (T + 4 * b) := by
    have e : 2 * Real.sin (x / 2) * (T + 4 * b) = 2 * Real.sin (x / 2) * T + 8 * (b * Real.sin (x / 2)) := by ring
    have h12 : 0 ≤ (b : ℝ) * x := by positivity
    rw [e, hD]
    linarith
  have h12 : 0 ≤ T + 4 * b := nonneg_of_mul_nonneg_right h11 (by linarith)
  linarith

private lemma cq_reduce (x : ℝ) : ∃ y : ℝ, 0 ≤ y ∧ y ≤ Real.pi ∧ ∀ k : ℕ, Real.cos ((k : ℝ) * x) = Real.cos ((k : ℝ) * y) := by
  refine ⟨Real.arccos (Real.cos x), Real.arccos_nonneg _, Real.arccos_le_pi _, fun k => ?_⟩
  have h : Real.cos (Real.arccos (Real.cos x)) = Real.cos x :=
    Real.cos_arccos (Real.neg_one_le_cos x) (Real.cos_le_one x)
  have h1 := Polynomial.Chebyshev.T_real_cos x (k : ℤ)
  have h2 := Polynomial.Chebyshev.T_real_cos (Real.arccos (Real.cos x)) (k : ℤ)
  rw [h] at h2
  push_cast at h1 h2
  rw [← h1, ← h2]

theorem erdos_1094__h2__h2__h5__h2__h2__h1__h2__h2 : ∀ (q : ℕ),
  (2 : ℕ) ≤ q →
    ∃ (C : ℕ),
      ∀ (ν ρ : ℕ),
        (1 : ℕ) ≤ ρ →
          ρ ≤ ν ^ q →
            ∃ (a : ℕ → ℕ),
              ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧
                ∀ (x : ℝ), -((↑C : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x) := by
  intro q hq
  obtain ⟨μ, hμ, hmain⟩ := cq_main q hq
  refine ⟨20 * μ, ?_⟩
  intro ν ρ hρ hρν
  have hν : 0 < ν := by
    rcases Nat.eq_zero_or_pos ν with h | h
    · rw [h, zero_pow (by omega)] at hρν; omega
    · exact h
  obtain ⟨b, hbdef⟩ : ∃ b : ℕ, b = 4 * (μ * ν) := ⟨_, rfl⟩
  have hμν : μ ≤ μ * ν := Nat.le_mul_of_pos_right μ hν
  have hb : μ < b := by omega
  set R : ℕ → ℕ := fun s => ∑ m ∈ Finset.Ico μ b, cq_N s μ q m with hR
  have hRs : ∀ s, s ≤ R s := by
    intro s
    have h1 : cq_N s μ q μ = s := Nat.mul_div_cancel _ (Nat.pow_pos hμ)
    have h2 := Finset.single_le_sum (f := fun m => cq_N s μ q m) (fun i _ => Nat.zero_le _)
      (Finset.mem_Ico.mpr ⟨le_refl μ, hb⟩)
    simp only [hR]
    omega
  have hR0 : R 0 = 0 := by simp [hR, cq_N]
  have hstep : ∀ s, R (s + 1) ≤ R s + b := by
    intro s
    have h1 : ∀ m ∈ Finset.Ico μ b, cq_N (s + 1) μ q m ≤ cq_N s μ q m + 1 := by
      intro m hm
      have hmμ := (Finset.mem_Ico.mp hm).1
      have hmq : 0 < m ^ q := Nat.pow_pos (hμ.trans_le hmμ)
      have h2 : μ ^ q ≤ m ^ q := Nat.pow_le_pow_left hmμ q
      unfold cq_N
      rw [← Nat.add_div_right _ hmq]
      apply Nat.div_le_div_right
      rw [add_mul, one_mul]
      omega
    have h2 := Finset.sum_le_sum h1
    rw [Finset.sum_add_distrib, Finset.sum_const, Nat.card_Ico, smul_eq_mul, mul_one] at h2
    simp only [hR]
    omega
  have hex : ∃ s, ρ < R s := ⟨ρ + 1, (Nat.lt_succ_self ρ).trans_le (hRs (ρ + 1))⟩
  obtain ⟨s, hs1, hs2⟩ : ∃ s, R s ≤ ρ ∧ ρ < R (s + 1) := by
    have h1 := Nat.find_spec hex
    have h0 : Nat.find hex ≠ 0 := by
      intro h; rw [h, hR0] at h1; omega
    obtain ⟨s, hs⟩ := Nat.exists_eq_succ_of_ne_zero h0
    refine ⟨s, ?_, ?_⟩
    · exact not_lt.mp (Nat.find_min hex (by omega))
    · rw [hs] at h1; exact h1
  have hsρ : s ≤ ρ := (hRs s).trans hs1
  have hrem : ρ - R s ≤ b := by have := hstep s; omega
  have hNle : ∀ m ∈ Finset.Ico μ b, cq_N s μ q m ≤ ρ := fun m hm =>
    (Finset.single_le_sum (f := fun m => cq_N s μ q m) (fun i _ => Nat.zero_le _) hm).trans hs1
  have hfil : ∀ m ∈ Finset.Ico μ b, (Finset.Icc 1 ρ).filter (fun k => k ≤ cq_N s μ q m) = Finset.Icc 1 (cq_N s μ q m) := by
    intro m hm
    have := hNle m hm
    ext k
    simp only [Finset.mem_filter, Finset.mem_Icc]
    omega
  refine ⟨fun k => ((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card + (if k = 1 then ρ - R s else 0), ?_, ?_⟩
  · rw [Finset.sum_add_distrib, Finset.sum_ite_eq' (Finset.Icc 1 ρ) 1 (fun _ => ρ - R s),
      if_pos (Finset.mem_Icc.mpr ⟨le_refl 1, hρ⟩)]
    have h1 : ∑ k ∈ Finset.Icc 1 ρ, ((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card = R s := by
      simp only [Finset.card_filter]
      rw [Finset.sum_comm]
      simp only [hR]
      apply Finset.sum_congr rfl
      intro m hm
      rw [← Finset.card_filter, hfil m hm, Nat.card_Icc]
      omega
    rw [h1]; omega
  · intro x
    obtain ⟨y, hy0, hyπ, hxy⟩ := cq_reduce x
    have h1 : ∑ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
        (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
        ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) +
          ((ρ - R s : ℕ) : ℝ) * Real.cos y := by
      have h2 : ∀ k ∈ Finset.Icc 1 ρ, ((((Finset.Ico μ b).filter (fun m => k ≤ cq_N s μ q m)).card +
          (if k = 1 then ρ - R s else 0) : ℕ) : ℝ) * Real.cos ((k : ℝ) * x) =
          ∑ m ∈ Finset.Ico μ b, (if k ≤ cq_N s μ q m then Real.cos ((k : ℝ) * y) else 0) +
            (if k = 1 then ((ρ - R s : ℕ) : ℝ) * Real.cos y else 0) := by
        intro k _
        rw [hxy k, Nat.cast_add, add_mul, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul]
        congr 1
        split_ifs with hk
        · rw [hk, Nat.cast_one, one_mul]
        · simp
      rw [Finset.sum_congr rfl h2, Finset.sum_add_distrib, Finset.sum_comm,
        Finset.sum_ite_eq' (Finset.Icc 1 ρ) 1 (fun _ => ((ρ - R s : ℕ) : ℝ) * Real.cos y),
        if_pos (Finset.mem_Icc.mpr ⟨le_refl 1, hρ⟩)]
      congr 1
      apply Finset.sum_congr rfl
      intro m hm
      rw [← Finset.sum_filter, hfil m hm]
    have h3 : -(b : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) * Real.cos y := by
      have h4 : ((ρ - R s : ℕ) : ℝ) ≤ b := by exact_mod_cast hrem
      have h5 : (0 : ℝ) ≤ ((ρ - R s : ℕ) : ℝ) := Nat.cast_nonneg _
      nlinarith [Real.neg_one_le_cos y]
    have hbR : (0 : ℝ) ≤ b := Nat.cast_nonneg b
    have h6 : -(4 * (b : ℝ)) ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
      have hnonneg : (∀ k : ℕ, Real.cos ((k : ℝ) * y) = 1) ∨ s = 0 →
          0 ≤ ∑ m ∈ Finset.Ico μ b, ∑ k ∈ Finset.Icc 1 (cq_N s μ q m), Real.cos ((k : ℝ) * y) := by
        rintro (h | h)
        · exact Finset.sum_nonneg fun m _ => Finset.sum_nonneg fun k _ => by rw [h k]; norm_num
        · have : ∀ m, cq_N s μ q m = 0 := by intro m; rw [h]; simp [cq_N]
          simp [this]
      rcases hy0.eq_or_lt with h | h
      · have := hnonneg (Or.inl fun k => by rw [← h]; simp)
        linarith
      · rcases Nat.eq_zero_or_pos s with hs0 | hs0
        · have := hnonneg (Or.inr hs0)
          linarith
        · refine cq_poly q hq μ hμ hmain s b hs0 hb.le ?_ y h hyπ
          calc 4 ^ q * (s * μ ^ q) ≤ 4 ^ q * (ν ^ q * μ ^ q) :=
                Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ (hsρ.trans hρν))
            _ = b ^ q := by rw [hbdef, mul_pow, mul_pow]; ring
    have h7 : (b : ℝ) * 5 = ((20 * μ : ℕ) : ℝ) * ν := by rw [hbdef]; push_cast; ring
    simp only
    rw [h1]
    linarith

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--h2--h5--h2--h2--h1--h2--h2».Context

open scoped Nat

/-! Hole `h_cos` 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__h2__h5__h2__h2__h1__h2__h2 : ∀ (q : ℕ),
  (2 : ℕ) ≤ q →
    ∃ (C : ℕ),
      ∀ (ν ρ : ℕ),
        (1 : ℕ) ≤ ρ →
          ρ ≤ ν ^ q →
            ∃ (a : ℕ → ℕ),
              ∑ k ∈ Finset.Icc (1 : ℕ) ρ, a k = ρ ∧
                ∀ (x : ℝ), -((↑C : ℝ) * (↑ν : ℝ)) ≤ ∑ k ∈ Finset.Icc (1 : ℕ) ρ, (↑(a k) : ℝ) * Real.cos ((↑k : ℝ) * x) := 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 t1203r2-k, drafted with claude-opus-5-5 with claude-fable-5-1 / claude-fable-5-2 (agents A, B, K1 shift 1), 2026-12-03; no one has read it against the Lean and signed it.

Draft · drafted, by the model named above

$\displaystyle \forall q\ge2\ \exists C\in\mathbb N\ \forall\nu,\rho\in\mathbb N:\ 1\le\rho\le\nu^q \Rightarrow \exists a_1,\dots,a_\rho\in\mathbb N:\ \sum_{k=1}^{\rho} a_k=\rho,\ \forall x\in\mathbb R:\ \sum_{k=1}^{\rho} a_k\cos(kx)\ge -C\nu$

For each exponent $q$ there are, for every positive integer $\rho$, non-negative integers $a_1,\dots,a_\rho$ with sum $\rho$ whose cosine sum is bounded below by $-C\nu$ for every $\nu$ with $\rho\le\nu^q$, that is by about $-C\rho^{1/q}$, with $C$ depending on $q$ alone. Belov and Konyagin (Izv. Math. 60:6, 1996, Corollary 0.2) prove the stronger lower bound $-2^{32}(1+\log\rho)^5$. In the Lean, a : ℕ → ℕ is a sequence of which only the values at $1,\dots,\rho$ are used.

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

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

Attestation: pass, 7 of 7 checks

Checked by the kernel — the gate’s record of the run: attestations/002857.erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2.json, merge commit 9a0c8b0f096c.

Verdict pass, from attestations/002857.erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2.json.

Submitter
t1203r2-k
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/002857.erdos-1094--h2--h2--h5--h2--h2--h1--h2--h2.json, merge commit 9a0c8b0f096c.

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

open scoped Nat

theorem witness : ∃ (q : ℕ), (2 : ℕ) ≤ q := ⟨2, le_rfl⟩

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