Problems / erdos-1094 / erdos-1094--h2--h2--h2--h3--h1--h1--h1
Konyagin's theorem at scale in [1, 2) when 65536X < 1
erdos-1094--h2--h2--h2--h3--h1--h1--h1
proved
Hole core of erdos-1094--h2--h2--h2--h3--h1--h1 (split by 20261015T063320Z-opn-prove-aristotle-1015-partial.lean).
$\displaystyle 65536\,X'<1\ \Longrightarrow\ |S'|<65536\,N'X'+2r\lambda',\qquad X'=(D'\lambda'^{\,r}W^2)^{\frac{1}{2r-1}}+\Bigl(\frac{\delta W^2}{D'\lambda'^{\,r}}\Bigr)^{\frac{1}{r-1}}+\Bigl(\frac{D_1'\lambda' W^2}{D'}\Bigr)^{\frac{1}{2r}}$
Fix $r\ge 2$, $W\ge 1$, $\delta>0$ and the data of the enclosing statement ($N>0$, $\lambda\ge 1$, $D_r,D_{r+1}>0$, $f:\mathbb{R}\to\mathbb{R}$ of class $C^{r+1}$ with $D_r/2\le|f^{(r)}(x)|\le D_r$ and $|f^{(r+1)}(x)|\le D_{r+1}$ for all $x\in[0,N]$, every finite set $S$ of integers in $[0,\lfloor N\rfloor]$ each of whose points $u$ has $|f(u)-v/w|<\delta$ for some integer $v$ and natural $w$ with $0<w\le W$), and assume moreover $\neg(1\le 65536\,X)$ for $X$ the same three-term expression in $D_r,\lambda,D_{r+1}$. Then for every $N'>0$, every $\lambda'$ with $1\le\lambda'<2$, every $D'>0$ and $D_1'>0$, every $g:\mathbb{R}\to\mathbb{R}$ of class $C^{r+1}$ with $D'/2\le|g^{(r)}|\le D'$ and $|g^{(r+1)}|\le D_1'$ on $[0,N']$, and every finite set $S'$ of integers in $[0,\lfloor N'\rfloor]$ each of whose points $u$ has $|g(u)-v/w|<\delta$ for some integer $v$ and natural $0<w\le W$, the displayed bound holds. The hypotheses on $N$, $\lambda$, $D_r$, $D_{r+1}$, $f$ and $S$ are carried from the enclosing statement and play no part in the conclusion; the Lean names $\lambda'$ lam' and $D_1'$ D1', $W^2$ is a natural power and the fractional exponents are real powers.
Lean
theorem erdos_1094__h2__h2__h2__h3__h1__h1__h1 : ∀ (r : ℕ),
(2 : ℕ) ≤ r →
∀ (N : ℝ),
(0 : ℝ) < N →
∀ (W : ℝ),
(1 : ℝ) ≤ W →
∀ (δ : ℝ),
(0 : ℝ) < δ →
∀ (lam : ℝ),
(1 : ℝ) ≤ lam →
∀ (D_r : ℝ),
(0 : ℝ) < D_r →
∀ (D_r1 : ℝ),
(0 : ℝ) < D_r1 →
∀ (f : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f →
(∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) →
∀ (S : Finset ℤ),
(∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) →
(∀ u ∈ S,
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) →
let X :=
(D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹;
¬(1 : ℝ) ≤ (65536 : ℝ) * X →
∀ (N' : ℝ),
(0 : ℝ) < N' →
∀ (lam' : ℝ),
(1 : ℝ) ≤ lam' →
lam' < (2 : ℝ) →
∀ (D' : ℝ),
(0 : ℝ) < D' →
∀ (D1' : ℝ),
(0 : ℝ) < D1' →
∀ (g : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g →
(∀ x ∈ Set.Icc (0 : ℝ) N',
D' / (2 : ℝ) ≤ |iteratedDeriv r g x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv r g x| ≤ D') →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv (r + (1 : ℕ)) g x| ≤ D1') →
∀ (S' : Finset ℤ),
(∀ u ∈ S', (0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋) →
(∀ u ∈ S',
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧
(↑w : ℝ) ≤ W ∧
|g (↑u : ℝ) -
(↑v : ℝ) / (↑w : ℝ)| <
δ) →
(65536 : ℝ) *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) <
(1 : ℝ) →
(↑S'.card : ℝ) <
(65536 : ℝ) * N' *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) +
(2 : ℝ) * (↑r : ℝ) * lam' := by
sorryWhy 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 →
How it was proved
Proved by Proof.lean, checked by the kernel. Its attestation, 000560, records the gate’s run.
The proof step by step (outline)
Checked by the kernel — an outline of the attested proof below: attestations/000560.json, merge commit 49bbfabd0d60.
Outline of Proof.lean, extracted by the gate at 067497e74a8b 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.
hsilrhave∀ (r : ℕ), (1 : ℕ) ≤ r → ∀ (s : ℕ), s = (2 : ℕ) * r → ∀ (M : ℝ), (↑s : ℝ) - (1 : ℝ) ≤ M → ∀ (W : ℝ), (1 : ℝ) ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ), (∀ (i : Fin s), (0 : ℤ) ≤ u i ∧ (↑(u i) : ℝ) ≤ M) → StrictMono u → (∀ (i : Fin s), (0 : ℕ) < w i) → (∀ (i : Fin s), (↑(w i) : ℝ) ≤ W) → ∃ (a : Fin s → ℤ), (∀ j < r, ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ j = (0 : ℝ)) ∧ ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ r ≠ (0 : ℝ) ∧ ∀ (i : Fin s), |(↑(a i) : ℝ)| ≤ ((256 : ℝ) * M / (↑r : ℝ)) ^ (r - (1 : ℕ)) * WLeaves
∀ (r : ℕ), (2 : ℕ) ≤ r → ∀ (N : ℝ), (0 : ℝ) < N → ∀ (W : ℝ), (1 : ℝ) ≤ W → ∀ (δ : ℝ), (0 : ℝ) < δ → ∀ (lam : ℝ), (1 : ℝ) ≤ lam → ∀ (D_r : ℝ), (0 : ℝ) < D_r → ∀ (D_r1 : ℝ), (0 : ℝ) < D_r1 → ∀ (f : ℝ → ℝ), ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f → (∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) → (∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) → (∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) → ∀ (S : Finset ℤ), (∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) → (∀ u ∈ S, ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) → let X := (D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹; ¬(1 : ℝ) ≤ (65536 : ℝ) * X → ∀ (N' : ℝ), (0 : ℝ) < N' → ∀ (lam' : ℝ), (1 : ℝ) ≤ lam' → lam' < (2 : ℝ) → (truncated), withhsilr : ∀ (r : ℕ), (1 : ℕ) ≤ r → ∀ (s : ℕ), s = (2 : ℕ) * r → ∀ (M : ℝ), (↑s : ℝ) - (1 : ℝ) ≤ M → ∀ (W : ℝ), (1 : ℝ) ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ), (∀ (i : Fin s), (0 : ℤ) ≤ u i ∧ (↑(u i) : ℝ) ≤ M) → StrictMono u → (∀ (i : Fin s), (0 : ℕ) < w i) → (∀ (i : Fin s), (↑(w i) : ℝ) ≤ W) → ∃ (a : Fin s → ℤ), (∀ j < r, ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ j = (0 : ℝ)) ∧ ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ r ≠ (0 : ℝ) ∧ ∀ (i : Fin s), |(↑(a i) : ℝ)| ≤ ((256 : ℝ) * M / (↑r : ℝ)) ^ (r - (1 : ℕ)) * W.Uses statements erdos-1094--h2--h2--h2--h3--h1--h1--h1--h1.
Lean, line 884
have hsilr := erdos_1094__h2__h2__h2__h3__h1__h1__h1__h1
hS'subhaveS' ⊆ intIcc N'Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhS'sub : S' ⊆ intIcc N'.Uses library
Finset.mem_Icc,And.introAnd.intro : a → b → a ∧ bis the constructor for the And operation. .Lean, lines 886–890
have hS'sub : ↑S' ⊆ ↑(intIcc N') := by intro u hu obtain ⟨a, b⟩ := hS' u hu unfold intIcc exact Finset.mem_Icc.mpr ⟨a, b⟩hS'sub.s1obtain(0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋Leaves
u ∈ intIcc N', witha : (0 : ℤ) ≤ u,b : u ≤ ⌊N'⌋.Lean, line 888
obtain ⟨a, b⟩ := hS' u hu
keyhave(↑S'.card : ℝ) < C₀_const * N' * ((D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / D') ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ)Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withkey : (↑S'.card : ℝ) < C₀_const * N' * ((D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / D') ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ).Lean, lines 891–892
have key := lambda_one_case r hr hsilr N' hN' W hW δ hδ D' hD' D1' hD1' g hg g1 g2 g3 S' hS'sub (fun u hu => hS'2 u hu)hcmphaveC₀_const * (((↑(1 : ℕ) : ℝ) ^ r * D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / ((↑(1 : ℕ) : ℝ) ^ r * D')) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + ((↑(1 : ℕ) : ℝ) * D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) ≤ c₆ * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹)Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhcmp : C₀_const * (((↑(1 : ℕ) : ℝ) ^ r * D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / ((↑(1 : ℕ) : ℝ) ^ r * D')) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + ((↑(1 : ℕ) : ℝ) * D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) ≤ c₆ * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹).Uses library
one_posAlias ofzero_lt_one. .Lean, lines 893–894
have hcmp := algebraic_comparison r hr D' D1' W δ hD' hD1' hW hδ 1 lam' one_pos (by simpa using hl1) (by norm_num; linarith)hc6havec₆ = (65536 : ℝ)Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhc6 : c₆ = (65536 : ℝ).Lean, lines 896–897
have hc6 : c₆ = 65536 := by unfold c₆ C₀_const B_const K_const c₉; norm_numhr0have(0 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ)routine: positivityLeaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhr0 : (0 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ).Lean, line 899
have hr0 : (0 : ℝ) ≤ 2 * (r : ℝ) := by positivity
h2rhave(2 : ℝ) * (↑r : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'routine: nlinarithLeaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withh2r : (2 : ℝ) * (↑r : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'.Lean, line 900
have h2r : 2 * (r : ℝ) ≤ 2 * (r : ℝ) * lam' := by nlinarith
closeterm(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam'Closes the goal.
Uses library
mul_le_mul_of_nonneg_left.Lean, line 901
nlinarith [mul_le_mul_of_nonneg_left hcmp hN'.le]
The proof in Lean (Proof.lean)
Checked by the kernel — these bytes are the ones its attestation names: attestations/000560.json, merge commit 49bbfabd0d60.
artifact_hash of the attestation below, so these are the bytes the gate checked. Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1--h1/Proof.lean, sha256 f28a92bf98a3.import Mathlib
import Nodes.«erdos-1094--h2--h2--h2--h3--h1--h1--h1».Context
open scoped Nat
/-! Hole `core` 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 intIcc (M : ℝ) : Finset ℤ := Finset.Icc 0 ⌊M⌋
private noncomputable def IsGood (f : ℝ → ℝ) (W δ : ℝ) (u : ℤ) : Prop :=
∃ (v : ℤ) (w : ℕ), 0 < w ∧ (w : ℝ) ≤ W ∧ |f (u : ℝ) - (v : ℝ) / (w : ℝ)| < δ
private noncomputable def c₉ : ℝ := 256
private noncomputable def K_const : ℝ := max 4 c₉
private noncomputable def B_const : ℝ := 16 * K_const
private noncomputable def C₀_const : ℝ := 4 * B_const
private noncomputable def c₆ : ℝ := 4 * C₀_const
/-
Properties of constants
-/
private lemma four_le_K : (4 : ℝ) ≤ K_const := le_max_left _ _
private lemma K_pos : (0 : ℝ) < K_const := lt_of_lt_of_le (by norm_num : (0:ℝ) < 4) four_le_K
private lemma B_pos : (0 : ℝ) < B_const := by unfold B_const; linarith [K_pos]
private lemma C₀_pos : (0 : ℝ) < C₀_const := by unfold C₀_const; linarith [B_pos]
private lemma c₆_pos : (0 : ℝ) < c₆ := by unfold c₆; linarith [C₀_pos]
private lemma mem_intIcc_iff (M : ℝ) (u : ℤ) :
u ∈ intIcc M ↔ 0 ≤ u ∧ u ≤ ⌊M⌋ := by
simp [intIcc, Finset.mem_Icc]
private lemma intIcc_nonneg {M : ℝ} {u : ℤ} (hu : u ∈ intIcc M) : 0 ≤ u :=
((mem_intIcc_iff M u).mp hu).1
private lemma intIcc_le_M {M : ℝ} {u : ℤ} (hu : u ∈ intIcc M) : (u : ℝ) ≤ M := by
have h := ((mem_intIcc_iff M u).mp hu).2
exact le_trans (Int.cast_le.mpr h) (Int.floor_le M)
private lemma short_cardinality (s : ℕ) (M : ℝ) (hMs : M < (s : ℝ) - 1) :
(intIcc M).card ≤ s - 1 := by
-- Since $M < s - 1$, we have $\lfloor M \rfloor \leq s - 2$.
have h_floor_le : ⌊M⌋ ≤ s - 2 := by
exact Int.le_of_lt_add_one <| Int.floor_lt.2 <| by norm_num; linarith;
unfold intIcc; cases s <;> norm_num at * ; omega;
linarith
/-
Given `2r` points with positive integer weights bounded by `W`, there exist integer
coefficients that annihilate the first `r` moments, have nonzero `r`-th moment,
and are bounded by `(c₉ M / r)^{r-1} · W`.
-/
private noncomputable def SILRProp : Prop := ∀ (r : ℕ), 1 ≤ r → ∀ (s : ℕ), s = 2 * r → ∀ (M : ℝ), (s : ℝ) - 1 ≤ M →
∀ (W : ℝ), 1 ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ),
(∀ i, 0 ≤ u i ∧ (u i : ℝ) ≤ M) → StrictMono u → (∀ i, 0 < w i) → (∀ i, (w i : ℝ) ≤ W) →
∃ a : Fin s → ℤ,
(∀ (j : ℕ), j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ j = 0) ∧
(∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ r ≠ 0) ∧
(∀ i, |(a i : ℝ)| ≤ (c₉ * M / (r : ℝ)) ^ (r - 1 : ℕ) * W)
/-- Translation rule: `(d/dx)^n f(a + x) = f^{(n)}(a + x)`. -/
private lemma iteratedDeriv_comp_translate (f : ℝ → ℝ) (a : ℝ) (n : ℕ) :
iteratedDeriv n (fun x => f (a + x)) = fun x => iteratedDeriv n f (a + x) :=
iteratedDeriv_comp_const_add n f a
/-- Affine chain rule: `(d/dx)^n f(a + bx) = b^n · f^{(n)}(a + bx)`.
Requires `f` to be `C^n`. -/
private lemma iteratedDeriv_comp_affine (f : ℝ → ℝ) (a b : ℝ) (n : ℕ) (x : ℝ)
(hf : ContDiff ℝ n f) :
iteratedDeriv n (fun x => f (a + b * x)) x =
b ^ n * iteratedDeriv n f (a + b * x) := by
have hg : ContDiff ℝ n (fun y => f (a + y)) :=
hf.comp (contDiff_const.add contDiff_id)
have h1 := congr_fun (iteratedDeriv_comp_const_mul hg b) x
have h2 := congr_fun (iteratedDeriv_comp_const_add n f a) (b * x)
rw [show (fun x => f (a + b * x)) = (fun x => (fun y => f (a + y)) (b * x)) from rfl]
rw [h1, h2]
/-- Smoothness is preserved under affine composition. -/
private lemma isGood_comp_affine {f : ℝ → ℝ} {W δ : ℝ} {u : ℤ} {a : ℤ} {b : ℕ}
(hgood : IsGood f W δ (a + b * u)) :
IsGood (fun x => f (↑a + ↑b * x)) W δ u := by
obtain ⟨v, w, hw_pos, hw_le, happrox⟩ := hgood
refine ⟨v, w, hw_pos, hw_le, ?_⟩
convert happrox using 2 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)))
push_cast
ring
/-
For positive reals, 1/min(min(a,b),c) ≤ 1/a + 1/b + 1/c
-/
private lemma one_div_min_le_sum_inv {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) :
1 / min (min a b) c ≤ 1 / a + 1 / b + 1 / c := by
field_simp;
rw [ min_def, min_def ] ; split_ifs <;> nlinarith [ mul_pos ha hb, mul_pos ha hc, mul_pos hb hc ] ;
/-
(2r-1)/r ≤ 2 for r ≥ 1
-/
private lemma finset_card_eq_sum_residue_classes (S : Finset ℤ) (ell : ℕ) (hell : 0 < ell) :
S.card = ∑ j ∈ Finset.range ell,
(S.filter (fun u => u % (ell : ℤ) = ↑j)).card := by
rw [ ← Finset.card_biUnion ];
· congr with u ; simp +decide;
exact ⟨ fun hu => ⟨ Int.toNat ( u % ell ), by linarith [ Int.emod_lt_of_pos u ( by positivity : 0 < ( ell : ℤ ) ), Int.toNat_of_nonneg ( Int.emod_nonneg u ( by positivity : ( ell : ℤ ) ≠ 0 ) ) ], hu, by rw [ Int.toNat_of_nonneg ( Int.emod_nonneg u ( by positivity : ( ell : ℤ ) ≠ 0 ) ) ] ⟩, by aesop ⟩;
· exact fun i hi j hj hij => Finset.disjoint_left.mpr fun x hx₁ hx₂ => hij <| by aesop;
private lemma iteratedDeriv_comp_affine_lower_bound
(f : ℝ → ℝ) (a : ℝ) (b : ℝ) (hb : 0 < b)
(r : ℕ) (D_r : ℝ)
(N' : ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_lower : ∀ x ∈ Set.Icc 0 (a + b * N'), D_r / 2 ≤ |iteratedDeriv r f x|)
(x : ℝ) (hx : x ∈ Set.Icc 0 N')
(ha_range : 0 ≤ a) :
b ^ r * D_r / 2 ≤ |iteratedDeriv r (fun x => f (a + b * x)) x| := by
rw [ iteratedDeriv_comp_affine ];
· rw [ abs_mul, abs_of_nonneg ( by positivity ) ] ; nlinarith [ hf_lower ( a + b * x ) ⟨ by nlinarith [ hx.1 ], by nlinarith [ hx.2 ] ⟩, pow_pos hb r ] ;
· exact hf_smooth.of_le (by exact_mod_cast Nat.le_succ r)
/-
Upper bound on r-th derivative of f(a + b·x)
-/
private lemma good_point_transfer
(f : ℝ → ℝ) (W δ : ℝ) (u : ℤ) (ell : ℕ)
(j : ℕ) (hmod : u % (ell : ℤ) = ↑j)
(hgood : IsGood f W δ u) :
IsGood (fun x => f (↑j + ↑ell * x)) W δ (u / ↑ell) := by
obtain ⟨v, w, hw_pos, hw_le, happrox⟩ := hgood
refine ⟨v, w, hw_pos, hw_le, ?_⟩
have h : (j : ℤ) + (ell : ℤ) * (u / ell) = u := by rw [← hmod]; exact Int.emod_add_mul_ediv u ell
have h' : (j : ℝ) + (ell : ℝ) * ((u / ell : ℤ) : ℝ) = (u : ℝ) := by exact_mod_cast h
show |f ((j : ℝ) + (ell : ℝ) * ((u / ell : ℤ) : ℝ)) - _| < δ
rw [h']; exact happrox
/-
If every sub-interval of length M contains fewer than B elements of S,
then |S| ≤ (N/M + 1) * (B-1).
-/
private lemma block_subdivision_count
(N M : ℝ) (hN : 0 < N) (hM : 0 < M)
(B : ℕ) (hB : 1 ≤ B)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(h_per_block : ∀ (k : ℕ), (S.filter (fun u : ℤ =>
(k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)).card < B) :
(S.card : ℝ) ≤ (N / M + 1) * ((B : ℝ) - 1) := by
-- By partitioning S into blocks of length M, we can bound the cardinality of S by the sum of the cardinalities of these blocks.
have h_partition : S.card ≤ ∑ k ∈ Finset.range (Nat.floor (N / M) + 1), (S.filter (fun u : ℤ => k * M ≤ (u : ℝ) ∧ (u : ℝ) < (k + 1) * M)).card := by
refine le_trans ?_ ( Finset.card_biUnion_le );
refine Finset.card_le_card ?_;
intro u hu; specialize hS_sub hu; simp_all +decide [ intIcc ] ;
refine' ⟨ ⌊ ( u : ℝ ) / M⌋₊, _, _, _ ⟩;
· gcongr;
exact Int.le_floor.mp hS_sub.2;
· nlinarith [ Nat.floor_le ( show 0 ≤ ( u : ℝ ) / M by exact div_nonneg ( mod_cast hS_sub.1 ) hM.le ), mul_div_cancel₀ ( u : ℝ ) hM.ne' ];
· nlinarith [ Nat.lt_floor_add_one ( ( u : ℝ ) / M ), mul_div_cancel₀ ( u : ℝ ) hM.ne' ];
refine' le_trans ( Nat.cast_le.mpr h_partition ) _;
refine' le_trans ( Nat.cast_le.mpr <| Finset.sum_le_sum fun _ _ => Nat.le_sub_one_of_lt <| h_per_block _ ) _ ; norm_num;
gcongr <;> cases B <;> norm_num at * ; linarith [ Nat.floor_le ( by positivity : 0 ≤ N / M ) ]
/-
For j < ℓ and x ∈ [0, (N-j)/ℓ], j + ℓx ∈ [0, N]
-/
private lemma sum_N_sub_j_div_ell_le (N : ℝ) (ell : ℕ) (hell : 0 < ell) :
∑ j ∈ Finset.range ell, ((N - ↑j) / ↑ell) ≤ N := by
rw [ ← Finset.sum_div _ _ _, div_le_iff₀ ] <;> norm_num [ hell ];
exact le_add_of_le_of_nonneg ( by linarith ) ( Finset.sum_nonneg fun _ _ => Nat.cast_nonneg _ )
/-
(N - j)/ℓ > 0 when j < ℓ ≤ N
-/
private lemma ediv_in_intIcc {u : ℤ} {N : ℝ} {ell : ℕ} {j : ℕ}
(hell : 0 < ell) (hu_mem : u ∈ intIcc N)
(hmod : u % (ell : ℤ) = ↑j) :
u / (ell : ℤ) ∈ intIcc ((N - ↑j) / ↑ell) := by
unfold intIcc at *;
norm_num at *;
rw [ Int.le_floor ] at *;
rw [ le_div_iff₀ ( by positivity ) ];
exact ⟨ Int.ediv_nonneg hu_mem.1 ( by positivity ), by linarith [ show ( u : ℝ ) = ( u / ell : ℤ ) * ell + j by exact mod_cast by linarith [ Int.emod_add_mul_ediv u ell ] ] ⟩
/-
The algebraic part of lambda_one_case: given |S| ≤ (N/M + 1)(2r-1),
derive the final C₀ bound.
-/
private lemma block_count_to_C0_bound
(r : ℕ) (hr : 2 ≤ r)
(N : ℝ) (hN : 0 < N)
(D_r D_r1 W δ : ℝ) (hDr : 0 < D_r) (hDr1 : 0 < D_r1)
(hW : 1 ≤ W) (hδ : 0 < δ)
(card_bound : ℝ)
(h_card : card_bound ≤ (N / ((r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1)))) + 1) *
(2 * (r : ℝ) - 1)) :
card_bound < C₀_const * N *
((D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / D_r) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) +
2 * (r : ℝ) := by
-- Let's simplify the expression.
suffices h_simp : (N / ((r : ℝ) / B_const * min (min ((D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ)) ((D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ))) ((D_r / (δ * W ^ 2)) ^ (1 / (r - 1) : ℝ)))) * (2 * r - 1) ≤ C₀_const * N * ((D_r * W ^ 2) ^ (2 * r - 1 : ℝ)⁻¹ + (δ * W ^ 2 / D_r) ^ (r - 1 : ℝ)⁻¹ + (D_r1 * W ^ 2 / D_r) ^ (2 * r : ℝ)⁻¹) by
linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ];
-- By simplifying, we can see that the left-hand side is less than or equal to the right-hand side.
have h_simp : (1 / (min (min ((D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ)) ((D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ))) ((D_r / (δ * W ^ 2)) ^ (1 / (r - 1) : ℝ)))) ≤ ((D_r * W ^ 2) ^ (2 * r - 1 : ℝ)⁻¹ + (δ * W ^ 2 / D_r) ^ (r - 1 : ℝ)⁻¹ + (D_r1 * W ^ 2 / D_r) ^ (2 * r : ℝ)⁻¹) := by
convert one_div_min_le_sum_inv _ _ _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· norm_num [ neg_div, Real.rpow_neg_eq_inv_rpow ];
rw [ ← Real.inv_rpow ( by positivity ), ← Real.inv_rpow ( by positivity ), ← Real.inv_rpow ( by positivity ) ] ; ring_nf;
norm_num ; ring_nf;
· positivity;
· positivity;
· positivity;
refine le_trans ?_ ( mul_le_mul_of_nonneg_left h_simp <| by exact mul_nonneg ( by exact le_of_lt <| by exact show 0 < C₀_const by exact C₀_pos ) <| by positivity );
field_simp [mul_comm, mul_assoc, mul_left_comm] at *;
unfold B_const C₀_const; ring_nf; norm_num;
unfold B_const; nlinarith [ show ( r : ℝ ) ≥ 2 by norm_cast, show ( K_const : ℝ ) ≥ 4 by exact_mod_cast four_le_K ] ;
private lemma int_abs_lt_one_imp_zero (L : ℤ) (h : |(L : ℝ)| < 1) : L = 0 := by
norm_cast at h; aesop;
/-
If intIcc M has at least n elements (n ≥ 1), then M ≥ n - 1.
-/
private lemma eight_r_le_sixteen_pow (r : ℕ) (hr : 2 ≤ r) : (8 : ℝ) * r ≤ 16 ^ (r - 1) := by
rcases r with ( _ | _ | r ) <;> norm_num at *;
exact mod_cast Nat.recOn r ( by norm_num ) fun n ihn => by norm_num [ Nat.pow_succ' ] at * ; linarith;
/-
Constant inequality (i): Under M bound from T₁,
2r D_r W² (K_const M/r)^{2r-1} ≤ 1/2.
-/
private lemma constant_ineq_i
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(D_r : ℝ) (hDr : 0 < D_r)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1))) :
2 * (r : ℝ) * D_r * W ^ 2 * (K_const * M / (r : ℝ)) ^ (2 * r - 1) ≤ 1 / 2 := by
-- From hM_le: KM/r ≤ 1/16 · (D_r W²)^{-1/(2r-1)} (since K = B/16)
have hKM_div_r_le : (K_const * M / r) ^ (2 * r - 1) ≤ (1 / 16) ^ (2 * r - 1) * (D_r * W ^ 2) ^ (-1 : ℝ) := by
have hKM_div_r_pow : (K_const * M / r) ≤ (1 / 16) * (D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ) := by
rw [ div_le_iff₀ ( by positivity ) ];
convert mul_le_mul_of_nonneg_left hM_le ( show 0 ≤ K_const by exact le_trans ( by norm_num ) ( le_max_left _ _ ) ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring_nf;
unfold K_const B_const; ring_nf;
unfold K_const; norm_num [ c₉ ] ;
ring;
convert pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_of_lt K_pos ) hM.le ) ( Nat.cast_nonneg _ ) ) hKM_div_r_pow _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ mul_pow, ← Real.rpow_natCast _ ( 2 * r - 1 ), ← Real.rpow_natCast _ ( 2 * r - 1 ), ← Real.rpow_mul ( by positivity ) ] ; norm_num [ Nat.cast_sub ( show 1 ≤ 2 * r by linarith ) ];
exact Or.inl ( by rw [ div_mul_cancel₀ _ ( sub_ne_zero_of_ne ( by norm_cast; linarith ) ) ] );
refine le_trans ( mul_le_mul_of_nonneg_left hKM_div_r_le <| by positivity ) ?_;
norm_cast ; norm_num [ mul_assoc, mul_comm, mul_left_comm, hDr.ne', show W ≠ 0 by positivity ];
rw [ show r * 2 - 1 = 2 * r - 1 by ring_nf ] ; rcases r with ( _ | _ | r ) <;> norm_num [ Nat.mul_succ, pow_succ' ] at *;
exact Nat.recOn r ( by norm_num ) fun n ihn => by norm_num [ Nat.mul_succ, pow_succ' ] at ihn ⊢ ; nlinarith [ pow_pos ( by norm_num : ( 0 : ℝ ) < 1 / 16 ) n ] ;
/-
Constant inequality (ii): Under M bound from T₂,
2r D_{r+1} W² (K_const M/r)^{2r} ≤ D_r/4.
-/
private lemma constant_ineq_ii
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))) :
2 * (r : ℝ) * D_r1 * W ^ 2 * (K_const * M / (r : ℝ)) ^ (2 * r) ≤ D_r / 4 := by
-- Since $B = 16K$, $M \le r/B T₂$ gives $KM/r \le T₂/16$ where $T₂ = (D_r/(D_{r+1}W²))^{1/(2r)}$.
have hKM_le_T2_div_16 : K_const * M / r ≤ (D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ) / 16 := by
convert div_le_div_of_nonneg_right ( mul_le_mul_of_nonneg_left hM_le <| show ( 0 : ℝ ) ≤ K_const by exact le_of_lt K_pos ) ( show ( 0 : ℝ ) ≤ r by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring_nf! ; norm_num [ show B_const = 16 * K_const by rfl ] ; ring_nf!;
norm_num [ show r ≠ 0 by positivity, show K_const ≠ 0 by exact ne_of_gt ( lt_max_of_lt_left ( by norm_num ) ) ];
-- So $2r D_{r+1} W² (KM/r)^{2r} ≤ 2r D_r / 16^{2r}$.
have h_bound : 2 * r * D_r1 * W ^ 2 * (K_const * M / r) ^ (2 * r) ≤ 2 * r * D_r / 16 ^ (2 * r) := by
refine le_trans ( mul_le_mul_of_nonneg_left ( pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_of_lt ( show 0 < K_const by exact lt_max_of_lt_left ( by norm_num ) ) ) hM.le ) ( Nat.cast_nonneg _ ) ) hKM_le_T2_div_16 _ ) ( by positivity ) ) ?_;
rw [ div_pow, ← Real.rpow_natCast _ ( 2 * r ), ← Real.rpow_natCast _ ( 2 * r ), ← Real.rpow_mul ( by positivity ) ] ; norm_num [ mul_assoc, mul_comm, mul_left_comm, ne_of_gt ( zero_lt_two.trans_le hr ) ];
field_simp;
norm_num;
refine le_trans h_bound ?_;
rw [ div_le_div_iff₀ ] <;> norm_cast <;> norm_num [ pow_mul ];
nlinarith [ show ( 256 : ℝ ) ^ r ≥ 2 * r * 4 by exact mod_cast Nat.le_induction ( by norm_num ) ( fun k hk ih ↦ by norm_num [ Nat.pow_succ ] at * ; nlinarith ) r hr ]
/-
Constant inequality (iii): Under M bound from T₃,
2r δ W² (K_const M/r)^{r-1} ≤ D_r/4.
-/
private lemma constant_ineq_iii
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))) :
2 * (r : ℝ) * δ * W ^ 2 * (K_const * M / (r : ℝ)) ^ (r - 1) ≤ D_r / 4 := by
-- By multiplying both sides of the inequality $K_const * M / r \leq 1/16 * (D_r / (δ * W ^ 2)) ^ (1 / (r - 1))$ by $r$, we get $K_const * M \leq 1/16 * (D_r / (δ * W ^ 2)) ^ (1 / (r - 1)) * r$.
have h_mul : (K_const * M / r) ^ (r - 1) ≤ (1 / 16) ^ (r - 1) * (D_r / (δ * W ^ 2)) := by
convert pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_max_of_le_left ( by norm_num ) ) hM.le ) ( Nat.cast_nonneg _ ) ) ( show K_const * M / r ≤ ( 1 / 16 ) * ( D_r / ( δ * W ^ 2 ) ) ^ ( 1 / ( r - 1 : ℝ ) ) by
rw [ div_le_iff₀ ] <;> norm_num [ B_const ] at *;
· rw [ div_mul_eq_mul_div, le_div_iff₀ ] at hM_le <;> nlinarith [ show ( 0 : ℝ ) < K_const by exact lt_max_of_lt_left ( by norm_num ) ];
· linarith ) ( r - 1 ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ mul_pow, ← Real.rpow_natCast _ ( r - 1 ), ← Real.rpow_natCast _ ( r - 1 ), ← Real.rpow_mul ( by positivity ), Nat.cast_sub ( by linarith ), Nat.cast_one, div_mul_cancel₀ _ ( sub_ne_zero_of_ne ( by norm_cast; linarith ) ) ] ; norm_num;
refine le_trans ( mul_le_mul_of_nonneg_left h_mul <| by positivity ) ?_;
-- We can divide both sides by $δ * W^2$ to simplify the inequality.
have h_div : 2 * (r : ℝ) * (1 / 16) ^ (r - 1) ≤ 1 / 4 := by
have := eight_r_le_sixteen_pow r hr;
rw [ one_div, inv_pow ] ; nlinarith [ show ( 0 : ℝ ) < 16 ^ ( r - 1 ) by positivity, mul_inv_cancel₀ ( show ( 16 : ℝ ) ^ ( r - 1 ) ≠ 0 by positivity ) ]
have hδW : 0 < δ * W ^ 2 := by positivity
calc 2 * (r : ℝ) * δ * W ^ 2 * ((1 / 16) ^ (r - 1) * (D_r / (δ * W ^ 2)))
= (2 * (r : ℝ) * (1 / 16) ^ (r - 1)) * D_r := by
have := hδW.ne'; first | (field_simp; done) | (field_simp; ring)
_ ≤ 1 / 4 * D_r := mul_le_mul_of_nonneg_right h_div hDr.le
_ = D_r / 4 := by ring
/-
For r ≥ 1: 1/r! ≤ (4/r)^r.
-/
private lemma factorial_inv_le (r : ℕ) (hr : 1 ≤ r) :
(1 : ℝ) / (r.factorial : ℝ) ≤ (4 / (r : ℝ)) ^ r := by
-- We'll use the fact that $r! \geq (r/4)^r$ for $r \geq 1$.
have h_factorial : ∀ r : ℕ, 1 ≤ r → (r.factorial : ℝ) ≥ (r / 4) ^ r := by
intro r hr;
induction hr <;> norm_num [ Nat.factorial ] at *;
-- We'll use the fact that $(1 + 1/m)^m \leq 4$ for all $m \geq 1$.
have h_exp : ∀ m : ℕ, 1 ≤ m → (1 + 1 / (m : ℝ)) ^ m ≤ 4 := by
-- We'll use the fact that $(1 + 1/m)^m \leq e$ for all $m \geq 1$.
have h_exp : ∀ m : ℕ, 1 ≤ m → (1 + 1 / (m : ℝ)) ^ m ≤ Real.exp 1 := by
intro m hm; rw [ ← Real.rpow_natCast, Real.rpow_def_of_pos ( by positivity ) ] ; norm_num;
nlinarith [ Real.log_le_sub_one_of_pos ( by positivity : 0 < 1 + ( m : ℝ ) ⁻¹ ), mul_inv_cancel₀ ( by positivity : ( m : ℝ ) ≠ 0 ) ];
exact fun m hm => le_trans ( h_exp m hm ) ( Real.exp_one_lt_d9.le.trans ( by norm_num ) );
have := h_exp _ ‹_›; rw [ one_add_div ( by positivity ) ] at this; rw [ div_pow, div_le_iff₀ ( by positivity ) ] at *; ring_nf at *; nlinarith;
have hr0 : (0 : ℝ) < (r : ℝ) / 4 := div_pos (by exact_mod_cast Nat.one_pos.trans_le hr) (by norm_num)
have h := one_div_le_one_div_of_le (pow_pos hr0 r) (h_factorial r hr)
calc (1 : ℝ) / (r.factorial : ℝ) ≤ 1 / ((r : ℝ) / 4) ^ r := h
_ = (4 / (r : ℝ)) ^ r := by rw [one_div, ← inv_pow, inv_div]
/-
The Taylor polynomial of degree r at 0 approximates f with error ≤ D_{r+1} (4M/r)^{r+1}.
More precisely, if f ∈ C^{r+1}[0,M] and |f^{(r+1)}| ≤ D_{r+1}, then
|f(x) - ∑_{j=0}^r f^{(j)}(0)/j! x^j| ≤ D_{r+1} (4M/r)^{r+1} for x ∈ [0,M].
We actually bound by D_{r+1} (K·M/r)^{r+1} since K ≥ 4.
-/
private lemma taylor_degree_r_remainder
(r : ℕ) (hr : 1 ≤ r) (M : ℝ) (_ : 0 < M)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ) (hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(x : ℝ) (hx : x ∈ Set.Icc (0 : ℝ) M) :
|f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * x ^ j| ≤
D_r1 * (K_const * M / (r : ℝ)) ^ (r + 1) := by
-- By Taylor's theorem with remainder, we have |f(x) - ∑_{j=0}^r f^(j)(0)/j! x^j| ≤ D_{r+1} x^{r+1}/(r+1)!.
have h_taylor_remainder : abs (f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j) ≤ D_r1 * x ^ (r + 1) / Nat.factorial (r + 1) := by
by_cases hx0 : x = 0;
· simp_all +decide [ Finset.sum_range_succ' ];
· obtain ⟨x', hx'⟩ : ∃ x' ∈ Set.Ioo 0 x, f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j = iteratedDeriv (r + 1) f x' * x ^ (r + 1) / Nat.factorial (r + 1) := by
have hxpos : 0 < x := lt_of_le_of_ne hx.1 (Ne.symm hx0)
have hC : ContDiffOn ℝ (↑r + 1) f (Set.uIcc 0 x) := by
have := hf_smooth.contDiffOn (s := Set.uIcc 0 x); exact_mod_cast this
obtain ⟨x', hx'mem, hx'eq⟩ := taylor_mean_remainder_lagrange_iteratedDeriv (ne_of_lt hxpos) hC
refine ⟨x', by simpa [Set.uIoo, hxpos.le] using hx'mem, ?_⟩
rw [sub_zero] at hx'eq
rw [← hx'eq]
congr 1
rw [taylor_within_apply, Set.uIcc_of_le hx.1]
apply Finset.sum_congr rfl
intro i hi
have hi' : i ≤ r + 1 := by have := Finset.mem_range.mp hi; omega
rw [iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc hxpos)
(hf_smooth.contDiffAt.of_le (by exact_mod_cast hi')) ⟨le_rfl, hx.1⟩, smul_eq_mul, sub_zero]
ring
rw [ hx'.2, abs_div, abs_mul, abs_of_nonneg ( by exact pow_nonneg hx.1 _ : ( 0 : ℝ ) ≤ x ^ ( r + 1 ) ), abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ ( r + 1 ).factorial ) ];
gcongr ; aesop;
exact hf_r1 x' ⟨ hx'.1.1.le, hx'.1.2.le.trans hx.2 ⟩;
-- By the factorial estimate, we have 1/(r+1)! ≤ (4/(r+1))^{r+1} ≤ (4/r)^{r+1} ≤ (K/r)^{r+1}.
have h_factorial_estimate : (1 : ℝ) / Nat.factorial (r + 1) ≤ (4 / r) ^ (r + 1) := by
convert factorial_inv_le ( r + 1 ) ( by linarith ) |> le_trans <| ?_ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
gcongr ; norm_num;
-- Substitute the factorial estimate into the Taylor remainder bound.
have h_substitute : abs (f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j) ≤ D_r1 * x ^ (r + 1) * (4 / r) ^ (r + 1) := by
exact h_taylor_remainder.trans ( by rw [ div_eq_mul_one_div ] ; exact mul_le_mul_of_nonneg_left ( by simpa using h_factorial_estimate ) ( mul_nonneg hDr1.le ( pow_nonneg hx.1 _ ) ) );
-- Since $x \leq M$, we have $x^{r+1} \leq M^{r+1}$.
have h_x_le_M : x ^ (r + 1) ≤ M ^ (r + 1) := by
exact pow_le_pow_left₀ hx.1 hx.2 _;
refine le_trans h_substitute ?_
have h4K : (4 : ℝ) ≤ K_const := le_max_left 4 c₉
have hx0 : (0 : ℝ) ≤ x := hx.1
have key : (4 * x / ↑r) ^ (r + 1) ≤ (K_const * M / ↑r) ^ (r + 1) := by
apply pow_le_pow_left₀ (by positivity)
apply div_le_div_of_nonneg_right _ (by positivity : (0:ℝ) ≤ ↑r)
exact mul_le_mul h4K hx.2 hx0 (by positivity)
nlinarith [show D_r1 * x ^ (r + 1) * (4 / ↑r) ^ (r + 1) = D_r1 * (4 * x / ↑r) ^ (r + 1) from by ring]
/-
The approximation error: |∑ aᵢ(vᵢ - wᵢf(uᵢ))| ≤ ∑ |aᵢ| · δ · wᵢ
-/
private lemma coeff_sum_bound'
{s : ℕ} {a : Fin s → ℤ} {w : Fin s → ℕ}
{W C_a : ℝ} (hCa : 0 ≤ C_a)
(hw_bound : ∀ i, (w i : ℝ) ≤ W)
(ha_bound : ∀ i, |(a i : ℝ)| ≤ C_a) :
∑ i, |(a i : ℝ)| * (w i : ℝ) ≤ (s : ℝ) * C_a * W := by
exact le_trans ( Finset.sum_le_sum fun _ _ => mul_le_mul ( ha_bound _ ) ( hw_bound _ ) ( by positivity ) ( by positivity ) ) ( by norm_num; nlinarith )
/-- The "binomial polynomial" P_r(n) = n!/(r!(n-r)!) = C(n,r) is a nonneg integer for n ≥ 0. -/
private lemma binomial_poly_eq_choose (n r : ℕ) :
(1 : ℝ) / (r.factorial : ℝ) * ∏ m ∈ Finset.range r, ((n : ℝ) - m) = Nat.choose n r := by
by_cases hn : n < r;
· rw [ Nat.choose_eq_zero_of_lt hn, eq_comm ];
rw [ Finset.prod_eq_zero ( Finset.mem_range.mpr hn ) ] <;> aesop;
· field_simp;
rw_mod_cast [ ← Nat.descFactorial_eq_factorial_mul_choose ];
rw [ Nat.descFactorial_eq_prod_range ];
rw [ Nat.cast_prod, Finset.prod_congr rfl fun x hx => Int.subNatNat_of_le ( by linarith [ Finset.mem_range.mp hx ] ) ]
/-
If ∑ aᵢwᵢuᵢ^j = 0 for j < r and ∑ aᵢwᵢuᵢ^r ≠ 0,
then Z₀ = ∑ aᵢwᵢP_r(uᵢ) is a nonzero integer, so |Z₀| ≥ 1.
Here Z₀ = 1/r! ∑ aᵢwᵢuᵢ^r (by moment annihilation applied to P_r - X^r/r!).
-/
private lemma Z0_nonzero_integer
{s r : ℕ}
{a : Fin s → ℤ} {w : Fin s → ℕ} {u : Fin s → ℤ}
(hu_nonneg : ∀ i, 0 ≤ u i)
(h_vanish : ∀ j : ℕ, j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ j = 0)
(h_nonzero : ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r ≠ 0) :
∃ Z₀ : ℤ, Z₀ ≠ 0 ∧ (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r := by
-- Define Z₀ as the sum of a_i w_i binom(u_i, r).
set Z₀ : ℤ := ∑ i, (a i : ℤ) * (w i : ℤ) * Nat.choose (u i).toNat r;
-- By definition of $Z₀$, we know that
have hZ₀ : (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r := by
have hZ₀ : (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) := by
have hZ₀ : ∀ i, (Nat.choose (u i).toNat r : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) := by
intro i; specialize hu_nonneg i
obtain ⟨n, hn⟩ := Int.eq_ofNat_of_zero_le hu_nonneg
simp only [hn]; exact (binomial_poly_eq_choose n r).symm
simp +zetaDelta at *;
simp +decide only [hZ₀, Finset.mul_sum _ _ _, mul_left_comm];
-- By definition of polynomial interpolation, we know that $\prod_{j=0}^{r-1} (u_i - j)$ is a polynomial of degree $r$.
have h_poly_interpolate : ∃ p : Polynomial ℝ, p.degree ≤ r ∧ ∀ i, (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) = p.eval (u i : ℝ) ∧ p.coeff r = 1 := by
refine' ⟨ ∏ j ∈ Finset.range r, ( Polynomial.X - Polynomial.C ( j : ℝ ) ), _, _ ⟩;
· norm_num [ Polynomial.degree_prod ];
erw [ Finset.sum_congr rfl fun _ _ => Polynomial.degree_X_sub_C _ ] ; norm_num;
· refine' fun i => ⟨ _, _ ⟩;
· simp +decide [ Polynomial.eval_prod ];
· have h_coeff : Polynomial.leadingCoeff (∏ j ∈ Finset.range r, (Polynomial.X - Polynomial.C (j : ℝ))) = 1 := by
rw [ Polynomial.leadingCoeff_prod ] ; exact Finset.prod_eq_one fun _ _ => Polynomial.leadingCoeff_X_sub_C _;
rw [ Polynomial.leadingCoeff, Polynomial.natDegree_prod _ _ fun x hx => Polynomial.X_sub_C_ne_zero _ ] at h_coeff;
simpa [ Polynomial.natDegree_sub_eq_left_of_natDegree_lt ] using h_coeff;
obtain ⟨ p, hp₁, hp₂ ⟩ := h_poly_interpolate;
have h_poly_interpolate : ∑ i, (a i : ℝ) * (w i : ℝ) * p.eval (u i : ℝ) = ∑ j ∈ Finset.range (r + 1), p.coeff j * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ j := by
simp +decide [ Finset.mul_sum _ _ _, mul_assoc, mul_comm, mul_left_comm ];
rw [ Finset.sum_comm, Finset.sum_congr rfl ] ; intros ; rw [ Polynomial.eval_eq_sum_range' ] ; ring_nf;
exacts [ by rw [ Finset.mul_sum _ _ _ ] ; exact Finset.sum_congr rfl fun _ _ => by ring, by linarith [ Polynomial.natDegree_le_of_degree_le hp₁ ] ];
simp_all +decide [ Finset.sum_range_succ ];
exact Or.inl ( by rw [ Finset.sum_eq_zero fun j hj => by rw [ h_vanish j ( Finset.mem_range.mp hj ) ] ; ring ] ; rw [ hp₂ ⟨ 0, Nat.pos_of_ne_zero ( by aesop_cat ) ⟩ |>.2 ] ; ring );
exact ⟨ Z₀, by contrapose! h_nonzero; simp_all +decide [ Nat.factorial_ne_zero ], hZ₀ ⟩
/-
Short interval bound.
-/
private theorem short_interval
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) M, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc M))
(hS_good : ∀ u ∈ S, IsGood f W δ u)
(hM_le : M ≤ (r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1)))) :
S.card < 2 * r := by
-- Convert hS_sub to Finset subset
have hS_sub' : S ⊆ intIcc M := Finset.coe_subset.mp hS_sub
-- If M < 2r - 1, use short_cardinality
by_cases h_small : M < (2 * r : ℝ) - 1
· have h1 := Finset.card_le_card hS_sub'
have h2 := short_cardinality (2 * r) M (by push_cast; exact h_small)
omega
push_neg at h_small
-- Suppose for contradiction |S| ≥ 2r
by_contra h_contra; push_neg at h_contra
obtain ⟨T, hT_sub, hT_card⟩ := Finset.le_card_iff_exists_subset_card.mp h_contra
set e := Finset.orderIsoOfFin T hT_card
set u_fn := fun (i : Fin (2 * r)) => (e i : ℤ)
have h_strict : StrictMono u_fn := fun i j hij => by exact_mod_cast (e.strictMono hij)
have h_range : ∀ i, 0 ≤ u_fn i ∧ (u_fn i : ℝ) ≤ M := by
intro i; have := hS_sub' (hT_sub (Finset.coe_mem (e i)))
exact ⟨intIcc_nonneg this, intIcc_le_M this⟩
have h_good : ∀ i, IsGood f W δ (u_fn i) := by
intro i; exact hS_good _ (hT_sub (Finset.coe_mem (e i)))
choose v_fn w_fn hw_pos hw_le h_approx using h_good
have h_small' : ((2 * r : ℕ) : ℝ) - 1 ≤ M := by push_cast; exact h_small
obtain ⟨a_fn, h_moment_zero, h_moment_r, h_coeff_bound⟩ :=
hSILR r (by linarith) (2 * r) rfl M h_small' W hW
u_fn w_fn h_range h_strict hw_pos hw_le
-- Define key quantities
set I : ℤ := ∑ i, a_fn i * v_fn i
set I₁ : ℝ := iteratedDeriv r f 0 / (r.factorial : ℝ) *
∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r
set R₁ : ℝ := ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) *
(f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1),
iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j)
set R₂ : ℝ := ∑ i, (a_fn i : ℝ) * ((v_fn i : ℝ) - (w_fn i : ℝ) * f (u_fn i : ℝ))
-- I = I₁ + R₁ + R₂ (splitting the integer into three real parts)
have hI_split : (I : ℝ) = I₁ + R₁ + R₂ := by
have hI : ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j) = I₁ := by
simp +zetaDelta at *;
simp +decide [Finset.mul_sum _ _ _, mul_assoc, mul_left_comm];
rw [ Finset.sum_comm ];
simp +decide [ Finset.sum_range_succ ];
exact Finset.sum_eq_zero fun i hi => by simpa [ mul_assoc, mul_comm, mul_left_comm, Finset.mul_sum _ _ _ ] using mul_eq_zero_of_right ( iteratedDeriv i f 0 / ( i.factorial : ℝ ) ) ( h_moment_zero i ( Finset.mem_range.mp hi ) ) ;
convert congr_arg₂ ( · + · ) ( congr_arg₂ ( · + · ) hI rfl ) rfl using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
simp +zetaDelta at *;
rw [ ← Finset.sum_add_distrib, ← Finset.sum_add_distrib ] ; congr ; ext ; ring;
-- Key bounds
have hI₁_upper : |I₁| ≤ 1 / 2 := by
-- By the properties of the derivative and the bounds on the coefficients, we have:
have hI1_bound : |I₁| ≤ D_r / (r.factorial : ℝ) * (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r := by
have hI1_bound : |∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r := by
have hI1_bound : ∀ i, |(a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ (c₉ * M / r) ^ (r - 1) * W * W * M ^ r := by
intros i
have h_abs : |(a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ |(a_fn i : ℝ)| * (w_fn i : ℝ) * M ^ r := by
norm_num [ abs_mul ];
exact mul_le_mul_of_nonneg_left ( pow_le_pow_left₀ ( abs_nonneg _ ) ( by rw [ abs_of_nonneg ( mod_cast h_range i |>.1 ) ] ; exact h_range i |>.2 ) _ ) ( by positivity );
exact h_abs.trans ( mul_le_mul_of_nonneg_right ( mul_le_mul ( h_coeff_bound i ) ( hw_le i ) ( by positivity ) ( by exact mul_nonneg ( pow_nonneg ( by exact div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ( by positivity ) ) ) ( by positivity ) );
exact le_trans ( Finset.abs_sum_le_sum_abs _ _ ) ( le_trans ( Finset.sum_le_sum fun _ _ => hI1_bound _ ) ( by norm_num; linarith ) );
have := hf_r_upper 0 ⟨ by norm_num, by linarith ⟩;
rw [ abs_mul, abs_div ];
rw [ abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ r.factorial ) ] ; convert mul_le_mul ( div_le_div_of_nonneg_right this ( by positivity : ( 0 : ℝ ) ≤ r.factorial ) ) hI1_bound ( by positivity ) ( by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring;
-- Using the factorial bound and the fact that $c₉ \leq K$, we can simplify the expression.
have h_factorial_bound : D_r / (r.factorial : ℝ) * (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r ≤ D_r * 2 * r * W ^ 2 * (K_const * M / r) ^ (2 * r - 1) := by
have h_factorial_bound : M ^ r / (r.factorial : ℝ) ≤ (K_const * M / r) ^ r := by
have hM_r_bound : M ^ r / (r.factorial : ℝ) ≤ (4 * M / r) ^ r := by
have := factorial_inv_le r ( by linarith );
convert mul_le_mul_of_nonneg_left this ( pow_nonneg hM.le r ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> ring;
exact hM_r_bound.trans ( pow_le_pow_left₀ ( by positivity ) ( by rw [ div_le_div_iff_of_pos_right ( by positivity ) ] ; exact mul_le_mul_of_nonneg_right ( by exact le_max_left _ _ ) hM.le ) _ );
have h_factorial_bound : (c₉ * M / r) ^ (r - 1) * M ^ r / (r.factorial : ℝ) ≤ (K_const * M / r) ^ (2 * r - 1) := by
rw [ show 2 * r - 1 = r - 1 + r by omega, pow_add ];
rw [ mul_div_assoc ];
gcongr;
· exact pow_nonneg ( div_nonneg ( mul_nonneg ( by exact le_max_of_le_left ( by norm_num ) ) hM.le ) ( Nat.cast_nonneg _ ) ) _;
· exact div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ );
· exact le_max_right _ _;
convert mul_le_mul_of_nonneg_left h_factorial_bound ( show 0 ≤ D_r * 2 * r * W ^ 2 by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring;
refine le_trans hI1_bound <| h_factorial_bound.trans ?_;
convert constant_ineq_i r hr M hM W hW D_r hDr _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· ring;
· exact hM_le.trans ( mul_le_mul_of_nonneg_left ( min_le_left _ _ |> le_trans <| min_le_left _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact mul_nonneg ( by norm_num ) <| le_max_of_le_left <| by norm_num )
have hI₁_lower : D_r / 2 ≤ |I₁| := by
-- By definition of $Z₀$, we have $Z₀ = 1/r! \sum a_i w_i u_i^r$.
obtain ⟨Z₀, hZ₀_nonzero, hZ₀_eq⟩ : ∃ Z₀ : ℤ, Z₀ ≠ 0 ∧ (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * u_fn i ^ r := by
convert Z0_nonzero_integer ( fun i => h_range i |>.1 ) h_moment_zero h_moment_r using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
-- By definition of $I₁$, we have $I₁ = f^{(r)}(0) \cdot Z₀$.
have hI₁_def : I₁ = iteratedDeriv r f 0 * Z₀ := by
grind;
rw [ hI₁_def, abs_mul ];
exact le_trans ( hf_r_lower 0 ⟨ by norm_num, by linarith ⟩ ) ( le_mul_of_one_le_right ( abs_nonneg _ ) ( mod_cast abs_pos.mpr hZ₀_nonzero ) )
have hR_sum : |R₁ + R₂| < D_r / 2 := by
-- We bound |R₁| using taylor_degree_r_remainder and constant_ineq_ii.
have hR₁_bound : |R₁| ≤ 2 * r * D_r1 * W ^ 2 * (K_const * M / r) ^ (2 * r) := by
have hR₁_bound : |R₁| ≤ D_r1 * (K_const * M / r) ^ (r + 1) * (∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ)) := by
have hR₁_upper : ∀ i, |(a_fn i : ℝ) * (w_fn i : ℝ) * (f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j)| ≤ |(a_fn i : ℝ)| * (w_fn i : ℝ) * D_r1 * (K_const * M / r) ^ (r + 1) := by
intros i
have h_remainder_bound : |f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j| ≤ D_r1 * (K_const * M / r) ^ (r + 1) := by
apply taylor_degree_r_remainder;
grind;
· linarith;
· positivity;
· exact hf_smooth;
· exact hf_r1;
· exact ⟨ mod_cast h_range i |>.1, h_range i |>.2 ⟩;
rw [ abs_mul, abs_mul, abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ w_fn i ) ] ; nlinarith [ show ( 0 : ℝ ) ≤ |↑ ( a_fn i )| * ↑ ( w_fn i ) by positivity ] ;
exact le_trans ( Finset.abs_sum_le_sum_abs _ _ ) ( by rw [ Finset.mul_sum _ _ _ ] ; exact Finset.sum_le_sum fun i _ => by convert hR₁_upper i using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring );
have hR₁_bound : |R₁| ≤ D_r1 * (K_const * M / r) ^ (r + 1) * (2 * r) * (c₉ * M / r) ^ (r - 1) * W ^ 2 := by
have hR₁_bound : ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) ≤ (2 * r) * (c₉ * M / r) ^ (r - 1) * W ^ 2 := by
convert coeff_sum_bound' ( show 0 ≤ ( c₉ * M / r ) ^ ( r - 1 ) * W by exact mul_nonneg ( pow_nonneg ( div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ( by positivity ) ) ( fun i => hw_le i ) ( fun i => h_coeff_bound i ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; norm_num [ mul_assoc, mul_comm, mul_left_comm ];
ring;
exact le_trans ‹_› ( by nlinarith [ show 0 ≤ D_r1 * ( K_const * M / r ) ^ ( r + 1 ) by exact mul_nonneg hDr1.le ( pow_nonneg ( div_nonneg ( mul_nonneg ( by norm_num [ K_const ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ] );
refine le_trans hR₁_bound ?_;
rcases r <;> simp_all +decide [ Nat.mul_succ, pow_succ' ] ; ring_nf;
simp only [c₉, K_const]; norm_num [pow_mul]; ring_nf; norm_num;
-- We bound |R₂| using approx_error_bound' and constant_ineq_iii.
have hR₂_bound : |R₂| < 2 * r * δ * W ^ 2 * (K_const * M / r) ^ (r - 1) := by
have hR₂_bound : |R₂| < δ * ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) := by
have hR₂_bound : |R₂| ≤ ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) * |f (u_fn i : ℝ) - (v_fn i : ℝ) / (w_fn i : ℝ)| := by
convert Finset.abs_sum_le_sum_abs _ _ using 2 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; norm_num [ abs_mul, abs_sub_comm, mul_assoc, mul_comm, mul_left_comm, div_eq_mul_inv, ne_of_gt ( hw_pos _ ) ];
· field_simp;
exact Or.inl ( by rw [ show ( v_fn _ : ℝ ) / w_fn _ - f ( u_fn _ : ℝ ) = ( v_fn _ - w_fn _ * f ( u_fn _ : ℝ ) ) / w_fn _ by rw [ sub_div, mul_div_cancel_left₀ _ ( Nat.cast_ne_zero.mpr <| ne_of_gt <| hw_pos _ ) ] ] ; rw [ abs_div, abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ w_fn _ ) ] ; rw [ mul_div_cancel₀ _ ( Nat.cast_ne_zero.mpr <| ne_of_gt <| hw_pos _ ) ] );
· infer_instance;
rw [ Finset.mul_sum _ _ _ ];
refine' lt_of_le_of_lt hR₂_bound ( Finset.sum_lt_sum _ _ );
· exact fun i _ => by nlinarith only [ h_approx i, show 0 ≤ |( a_fn i : ℝ )| * ( w_fn i : ℝ ) by positivity ] ;
· obtain ⟨i, hi⟩ : ∃ i, a_fn i ≠ 0 := by
exact not_forall.mp fun h => h_moment_r <| by simp +decide [ h ] ;
exact ⟨ i, Finset.mem_univ _, by nlinarith only [ show 0 < |( a_fn i : ℝ )| * w_fn i by exact mul_pos ( abs_pos.mpr ( Int.cast_ne_zero.mpr hi ) ) ( Nat.cast_pos.mpr ( hw_pos i ) ), h_approx i ] ⟩;
refine lt_of_lt_of_le hR₂_bound ?_;
refine' le_trans ( mul_le_mul_of_nonneg_left ( Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left ( hw_le i ) ( abs_nonneg _ ) ) hδ.le ) _;
refine' le_trans ( mul_le_mul_of_nonneg_left ( Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_right ( h_coeff_bound i ) ( by positivity ) ) hδ.le ) _ ; norm_num ; ring_nf ; norm_num;
simp only [c₉, K_const]; norm_num [pow_mul]; ring_nf; norm_num;
-- We use constant_ineq_ii and constant_ineq_iii to bound |R₁| and |R₂|.
have hR₁_bound' : |R₁| ≤ D_r / 4 := by
refine le_trans hR₁_bound ?_;
apply_rules [ constant_ineq_ii ];
exact hM_le.trans ( mul_le_mul_of_nonneg_left ( min_le_left _ _ |> le_trans <| min_le_right _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact le_of_lt <| by exact B_pos )
have hR₂_bound' : |R₂| < D_r / 4 := by
refine lt_of_lt_of_le hR₂_bound ?_;
convert constant_ineq_iii r hr M hM W hW δ hδ D_r hDr ( show M ≤ ( r : ℝ ) / B_const * ( D_r / ( δ * W ^ 2 ) ) ^ ( ( 1 : ℝ ) / ( r - 1 ) ) from le_trans hM_le <| mul_le_mul_of_nonneg_left ( min_le_right _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact le_of_lt <| by exact B_pos ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
exact abs_lt.mpr ⟨ by linarith [ abs_le.mp hR₁_bound', abs_lt.mp hR₂_bound' ], by linarith [ abs_le.mp hR₁_bound', abs_lt.mp hR₂_bound' ] ⟩
-- Contradiction: I ≠ 0 but |I| < 1
have hI_ne_zero : I ≠ 0 := by
intro hI_zero
have : (I : ℝ) = 0 := by exact_mod_cast hI_zero
rw [hI_split] at this
have : I₁ = -(R₁ + R₂) := by linarith
have : |I₁| = |R₁ + R₂| := by rw [this, abs_neg]
linarith
have hI_bound : |(I : ℝ)| < 1 := by
rw [hI_split]
have : |I₁ + (R₁ + R₂)| ≤ |I₁| + |R₁ + R₂| := abs_add_le _ _
linarith [show |I₁ + R₁ + R₂| = |I₁ + (R₁ + R₂)| from by ring_nf]
exact hI_ne_zero (int_abs_lt_one_imp_zero I hI_bound)
/-
For each block [kM, (k+1)M), translating f and applying short_interval gives < 2r good points.
-/
private lemma per_block_bound
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(M N : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) N, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(hM_le : M ≤ (r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))))
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(hS_good : ∀ u ∈ S, IsGood f W δ u)
(k : ℕ) :
(S.filter (fun u : ℤ =>
(k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)).card < 2 * r := by
by_contra h_contra;
-- Let $a$ be the minimum element in the set $\{u \in S \mid kM \leq u < (k+1)M\}$.
obtain ⟨a, ha⟩ : ∃ a ∈ S, (k : ℝ) * M ≤ (a : ℝ) ∧ (a : ℝ) < ((k : ℝ) + 1) * M ∧ ∀ u ∈ S, (k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M → a ≤ u := by
obtain ⟨a, ha⟩ : ∃ a ∈ S, (k : ℝ) * M ≤ (a : ℝ) ∧ (a : ℝ) < ((k : ℝ) + 1) * M := by
exact Exists.elim ( Finset.card_pos.mp ( by linarith ) ) fun x hx => ⟨ x, Finset.mem_filter.mp hx |>.1, Finset.mem_filter.mp hx |>.2 ⟩;
exact ⟨ Finset.min' ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.1, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.2.1, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.2.2, fun u hu hu' => Finset.min'_le _ _ <| by aesop ⟩;
-- Define $T = \{u - a \mid u \in S, kM \leq u < (k+1)M\}$.
set T := Finset.image (fun u => u - a) (S.filter (fun u => (k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)) with hT;
-- Apply the short_interval lemma to the set $T$.
have hT_short : T.card < 2 * r := by
apply short_interval r hr hSILR (min M (N - a)) (by
have := Finset.exists_mem_ne ( by linarith ) a; obtain ⟨ u, hu, hu' ⟩ := this; simp_all +decide [ Finset.subset_iff ] ;
exact lt_of_lt_of_le ( show ( a : ℝ ) < u from mod_cast lt_of_le_of_ne ( ha.2.2.2 u hu.1 hu.2.1 hu.2.2 ) ( Ne.symm hu' ) ) ( mod_cast intIcc_le_M ( hS_sub hu.1 ) )) W hW δ hδ D_r hDr D_r1 hDr1 (fun x => f (a + x)) (by
exact hf_smooth.comp ((contDiff_const.add contDiff_id).of_le le_top)) (by
intro x hx
have h_deriv : iteratedDeriv r (fun x => f (a + x)) x = iteratedDeriv r f (a + x) := by
rw [ iteratedDeriv_comp_translate ];
convert hf_r_lower ( a + x ) ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 from mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; (first | rw [h_deriv] | exact congrArg abs h_deriv | simp only [iteratedDeriv_comp_translate] | rw [iteratedDeriv_comp_translate])) (by
intro x hx; rw [ iteratedDeriv_comp_translate ] ;
exact hf_r_upper _ ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 by exact_mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩) (by
intro x hx; rw [ iteratedDeriv_comp_translate ] ; norm_num;
exact hf_r1 _ ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 by exact_mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩) T (by
simp_all +decide [ Finset.subset_iff ];
rintro _ u hu hu₁ hu₂ rfl; specialize hS_sub hu; simp_all +decide [ intIcc ] ;
exact Int.le_of_lt_add_one ( by rw [ ← @Int.cast_lt ℝ ] ; push_cast; cases min_cases M ( N - a ) <;> linarith [ Int.floor_le ( min M ( N - a ) ), Int.lt_floor_add_one ( min M ( N - a ) ), show ( u : ℝ ) ≤ ⌊N⌋ from mod_cast hS_sub.2, Int.floor_le N, Int.lt_floor_add_one N ] )) (by
simp +zetaDelta at *;
rintro u x hx hx₁ hx₂ rfl; specialize hS_good x hx; obtain ⟨ v, w, hw₁, hw₂, hw₃ ⟩ := hS_good; use v, w; aesop;) (by
exact le_trans ( min_le_left _ _ ) hM_le);
rw [ Finset.card_image_of_injective _ ( sub_left_injective ) ] at hT_short ; linarith
/-
The `λ = 1` case
-/
private theorem lambda_one_case
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(N : ℝ) (hN : 0 < N)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) N, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(hS_good : ∀ u ∈ S, IsGood f W δ u) :
(S.card : ℝ) < C₀_const * N *
((D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / D_r) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) +
2 * (r : ℝ) := by
-- Let $M = (r/B_const) * \min(\min(T₁, T₂), T₃)$.
set M := (r : ℝ) / B_const * min (min ((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1))) ((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r)))) ((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))) with hM_def;
by_cases hM_pos : 0 < M;
· have h_card_bound : (S.card : ℝ) ≤ (N / M + 1) * (2 * r - 1) := by
convert block_subdivision_count N M hN hM_pos ( 2 * r ) ( by linarith ) S ( fun u hu => hS_sub hu ) _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· norm_cast;
· convert per_block_bound r hr hSILR M N hM_pos W hW δ hδ D_r hDr D_r1 hDr1 f hf_smooth _ _ _ _ S ( fun u hu => hS_sub hu ) hS_good using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· exact hf_r_lower;
· exact hf_r_upper;
· exact hf_r1;
convert block_count_to_C0_bound r hr N hN D_r D_r1 W δ hDr hDr1 hW hδ _ h_card_bound using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· contrapose! hM_pos;
refine' mul_pos ( div_pos ( Nat.cast_pos.mpr ( by linarith ) ) ( by exact mul_pos ( by norm_num ) ( by exact lt_max_of_lt_left ( by norm_num ) ) ) ) ( lt_min ( lt_min ( Real.rpow_pos_of_pos ( by positivity ) _ ) ( Real.rpow_pos_of_pos ( by positivity ) _ ) ) ( Real.rpow_pos_of_pos ( by positivity ) _ ) )
/-- The main rpow term is positive. -/
private lemma konyagin_main_term_pos
(r : ℕ) (N W δ lam D_r D_r1 : ℝ)
(hN : 0 < N) (hW : 1 ≤ W) (hδ : 0 < δ) (hlam : 1 ≤ lam)
(hDr : 0 < D_r) (hDr1 : 0 < D_r1) :
0 < c₆ * N *
((D_r * lam ^ (r : ℕ) * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * lam * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) := by
refine' mul_pos _ ( add_pos_of_pos_of_nonneg ( add_pos_of_pos_of_nonneg _ _ ) _ )
· exact mul_pos ( c₆_pos ) hN
· positivity
· positivity
· positivity
/-- `A + 4B + C ≤ 4(A + B + C)` for nonneg reals. -/
private lemma two_rpow_le_four (r : ℕ) (hr : 2 ≤ r) :
(2 : ℝ) ^ ((r : ℝ) / ((r : ℝ) - 1)) ≤ 4 := by
exact le_trans ( Real.rpow_le_rpow_of_exponent_le ( by norm_num ) ( show ( r : ℝ ) / ( r - 1 ) ≤ 2 by rw [ div_le_iff₀ ] <;> linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ] ) ) ( by norm_num )
/-
The term `(δW²/(ℓ^r D_r))^{1/(r-1)}` is at most
`4 · (δW²/(λ^r D_r))^{1/(r-1)}` when `ℓ > λ/2` and `r ≥ 2`.
-/
private lemma term2_comparison
(r : ℕ) (hr : 2 ≤ r)
(D_r W δ : ℝ) (hDr : 0 < D_r) (hW : 1 ≤ W) (hδ : 0 < δ)
(ell : ℕ) (lam : ℝ) (hell : 0 < ell)
(hell_le : (ell : ℝ) ≤ lam) (hlam_lt : lam < 2 * (ell : ℝ)) :
(δ * W ^ 2 / ((ell : ℝ) ^ (r : ℕ) * D_r)) ^ (((r : ℝ) - 1)⁻¹) ≤
4 * (δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) := by
-- Since ℓ > λ/2, we have ℓ^r > (λ/2)^r, so 1/(ℓ^r) < 1/((λ/2)^r) = 2^r/λ^r.
have h_bound : 1 / (ell : ℝ) ^ r < (2 : ℝ) ^ r / (lam : ℝ) ^ r := by
rw [ div_lt_div_iff₀ ] <;> try positivity;
· simpa only [ one_mul, ← mul_pow ] using pow_lt_pow_left₀ hlam_lt ( by linarith ) ( by linarith );
· exact pow_pos ( by linarith [ show ( ell : ℝ ) ≥ 1 by norm_cast ] ) _;
-- Therefore, δW²/(ℓ^r D_r) < 2^r δW²/(λ^r D_r).
have h_bound' : δ * W ^ 2 / ((ell : ℝ) ^ r * D_r) < 2 ^ r * δ * W ^ 2 / (lam ^ r * D_r) := by
convert mul_lt_mul_of_pos_left h_bound ( show 0 < δ * W ^ 2 / D_r by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> (first | ring | (field_simp; done) | (field_simp; ring));
refine' le_trans ( Real.rpow_le_rpow ( by positivity ) h_bound'.le ( inv_nonneg.mpr ( sub_nonneg.mpr ( Nat.one_le_cast.mpr ( by linarith ) ) ) ) ) _;
rw [ show ( 2 ^ r * δ * W ^ 2 / ( lam ^ r * D_r ) ) = ( δ * W ^ 2 / ( D_r * lam ^ r ) ) * ( 2 ^ r ) by ring, Real.mul_rpow ( by exact div_nonneg ( by positivity ) ( by exact mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) ( by positivity ) ];
rw [ mul_comm ] ; gcongr;
· exact Real.rpow_nonneg ( div_nonneg ( mul_nonneg hδ.le ( sq_nonneg _ ) ) ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) _;
· convert two_rpow_le_four r hr using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ ← Real.rpow_natCast, ← Real.rpow_mul ( by positivity ), mul_comm ] ; ring_nf
/-
The `C₀ · (terms with ℓ) ≤ c₆ · (terms with λ)` algebraic comparison.
-/
private lemma algebraic_comparison
(r : ℕ) (hr : 2 ≤ r)
(D_r D_r1 W δ : ℝ) (hDr : 0 < D_r) (hDr1 : 0 < D_r1)
(hW : 1 ≤ W) (hδ : 0 < δ)
(ell : ℕ) (lam : ℝ) (hell : 0 < ell)
(hell_le : (ell : ℝ) ≤ lam) (hlam_lt : lam < 2 * (ell : ℝ)) :
C₀_const *
(((ell : ℝ) ^ (r : ℕ) * D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / ((ell : ℝ) ^ (r : ℕ) * D_r)) ^ (((r : ℝ) - 1)⁻¹) +
((ell : ℝ) * D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) ≤
c₆ *
((D_r * lam ^ (r : ℕ) * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * lam * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) := by
-- Apply the term2_comparison lemma.
have h_term2 : (δ * W ^ 2 / (ell ^ r * D_r)) ^ (1 / (r - 1 : ℝ)) ≤ 4 * (δ * W ^ 2 / (D_r * lam ^ r)) ^ (1 / (r - 1 : ℝ)) := by
convert term2_comparison r hr D_r W δ hDr hW hδ ell lam hell hell_le hlam_lt using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> (try simp only [one_div])
-- Apply the term1_comparison lemma.
have h_term1 : (ell ^ r * D_r * W ^ 2) ^ (1 / (2 * r - 1 : ℝ)) ≤ (D_r * lam ^ r * W ^ 2) ^ (1 / (2 * r - 1 : ℝ)) := by
exact Real.rpow_le_rpow ( by positivity ) ( by nlinarith [ show ( ell : ℝ ) ^ r ≤ lam ^ r by gcongr, show ( 0 : ℝ ) < D_r * W ^ 2 by positivity ] ) ( by exact one_div_nonneg.mpr ( by linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ] ) );
-- Apply the term3_comparison lemma.
have h_term3 : (ell * D_r1 * W ^ 2 / D_r) ^ (1 / (2 * r : ℝ)) ≤ (D_r1 * lam * W ^ 2 / D_r) ^ (1 / (2 * r : ℝ)) := by
exact Real.rpow_le_rpow ( by positivity ) ( by rw [ div_le_div_iff_of_pos_right ( by positivity ) ] ; nlinarith [ show 0 < D_r1 * W ^ 2 by positivity ] ) ( by positivity );
rw [ show c₆ = 4 * C₀_const by rfl ];
norm_num at *;
nlinarith [ show 0 < C₀_const by exact C₀_pos, show 0 ≤ ( D_r * lam ^ r * W ^ 2 ) ^ ( 2 * r - 1 : ℝ ) ⁻¹ by exact Real.rpow_nonneg ( by exact mul_nonneg ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ( sq_nonneg _ ) ) _, show 0 ≤ ( δ * W ^ 2 / ( D_r * lam ^ r ) ) ^ ( r - 1 : ℝ ) ⁻¹ by exact Real.rpow_nonneg ( by exact div_nonneg ( mul_nonneg hδ.le ( sq_nonneg _ ) ) ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) _, show 0 ≤ ( D_r1 * lam * W ^ 2 / D_r ) ^ ( ( r : ℝ ) ⁻¹ * ( 1 / 2 ) ) by exact Real.rpow_nonneg ( by exact div_nonneg ( mul_nonneg ( mul_nonneg hDr1.le ( by linarith ) ) ( sq_nonneg _ ) ) hDr.le ) _ ]
/-
Sum over residue classes.
-/
theorem erdos_1094__h2__h2__h2__h3__h1__h1__h1 : ∀ (r : ℕ),
(2 : ℕ) ≤ r →
∀ (N : ℝ),
(0 : ℝ) < N →
∀ (W : ℝ),
(1 : ℝ) ≤ W →
∀ (δ : ℝ),
(0 : ℝ) < δ →
∀ (lam : ℝ),
(1 : ℝ) ≤ lam →
∀ (D_r : ℝ),
(0 : ℝ) < D_r →
∀ (D_r1 : ℝ),
(0 : ℝ) < D_r1 →
∀ (f : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f →
(∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) →
∀ (S : Finset ℤ),
(∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) →
(∀ u ∈ S,
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) →
let X :=
(D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹;
¬(1 : ℝ) ≤ (65536 : ℝ) * X →
∀ (N' : ℝ),
(0 : ℝ) < N' →
∀ (lam' : ℝ),
(1 : ℝ) ≤ lam' →
lam' < (2 : ℝ) →
∀ (D' : ℝ),
(0 : ℝ) < D' →
∀ (D1' : ℝ),
(0 : ℝ) < D1' →
∀ (g : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g →
(∀ x ∈ Set.Icc (0 : ℝ) N',
D' / (2 : ℝ) ≤ |iteratedDeriv r g x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv r g x| ≤ D') →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv (r + (1 : ℕ)) g x| ≤ D1') →
∀ (S' : Finset ℤ),
(∀ u ∈ S', (0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋) →
(∀ u ∈ S',
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧
(↑w : ℝ) ≤ W ∧
|g (↑u : ℝ) -
(↑v : ℝ) / (↑w : ℝ)| <
δ) →
(65536 : ℝ) *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) <
(1 : ℝ) →
(↑S'.card : ℝ) <
(65536 : ℝ) * N' *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) +
(2 : ℝ) * (↑r : ℝ) * lam' := by
have hsilr := erdos_1094__h2__h2__h2__h3__h1__h1__h1__h1
intro r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1 f hf h1 h2 h3 S hS hS2 X hX N' hN' lam' hl1 hl2 D' hD' D1' hD1' g hg g1 g2 g3 S' hS' hS'2 hlt
have hS'sub : ↑S' ⊆ ↑(intIcc N') := by
intro u hu
obtain ⟨a, b⟩ := hS' u hu
unfold intIcc
exact Finset.mem_Icc.mpr ⟨a, b⟩
have key := lambda_one_case r hr hsilr N' hN' W hW δ hδ D' hD' D1' hD1' g hg g1 g2 g3 S' hS'sub
(fun u hu => hS'2 u hu)
have hcmp := algebraic_comparison r hr D' D1' W δ hD' hD1' hW hδ 1 lam' one_pos
(by simpa using hl1) (by norm_num; linarith)
simp only [Nat.cast_one, one_pow, one_mul] at hcmp
have hc6 : c₆ = 65536 := by
unfold c₆ C₀_const B_const K_const c₉; norm_num
rw [hc6] at hcmp
have hr0 : (0 : ℝ) ≤ 2 * (r : ℝ) := by positivity
have h2r : 2 * (r : ℝ) ≤ 2 * (r : ℝ) * lam' := by nlinarith
nlinarith [mul_le_mul_of_nonneg_left hcmp hN'.le]How it was split
Proved from this hole by 20261015T130229Z-t1015b-s-partial.lean (merged in 47220d7f6556, attestation 000540).
hsilr→ erdos-1094--h2--h2--h2--h3--h1--h1--h1--h1 (proved)$\displaystyle \exists a:\{0,\dots,2r-1\}\to\mathbb{Z}:\quad \sum_{i}a_i w_i u_i^{\,j}=0\ (j<r),\qquad \sum_{i}a_i w_i u_i^{\,r}\ne 0,\qquad |a_i|\le\Bigl(\frac{256\,M}{r}\Bigr)^{r-1}W$
Read the partial proof (Lean)
private noncomputable def intIcc (M : ℝ) : Finset ℤ := Finset.Icc 0 ⌊M⌋
private noncomputable def IsGood (f : ℝ → ℝ) (W δ : ℝ) (u : ℤ) : Prop :=
∃ (v : ℤ) (w : ℕ), 0 < w ∧ (w : ℝ) ≤ W ∧ |f (u : ℝ) - (v : ℝ) / (w : ℝ)| < δ
private noncomputable def c₉ : ℝ := 256
private noncomputable def K_const : ℝ := max 4 c₉
private noncomputable def B_const : ℝ := 16 * K_const
private noncomputable def C₀_const : ℝ := 4 * B_const
private noncomputable def c₆ : ℝ := 4 * C₀_const
/-
Properties of constants
-/
private lemma four_le_K : (4 : ℝ) ≤ K_const := le_max_left _ _
private lemma K_pos : (0 : ℝ) < K_const := lt_of_lt_of_le (by norm_num : (0:ℝ) < 4) four_le_K
private lemma B_pos : (0 : ℝ) < B_const := by unfold B_const; linarith [K_pos]
private lemma C₀_pos : (0 : ℝ) < C₀_const := by unfold C₀_const; linarith [B_pos]
private lemma c₆_pos : (0 : ℝ) < c₆ := by unfold c₆; linarith [C₀_pos]
private lemma mem_intIcc_iff (M : ℝ) (u : ℤ) :
u ∈ intIcc M ↔ 0 ≤ u ∧ u ≤ ⌊M⌋ := by
simp [intIcc, Finset.mem_Icc]
private lemma intIcc_nonneg {M : ℝ} {u : ℤ} (hu : u ∈ intIcc M) : 0 ≤ u :=
((mem_intIcc_iff M u).mp hu).1
private lemma intIcc_le_M {M : ℝ} {u : ℤ} (hu : u ∈ intIcc M) : (u : ℝ) ≤ M := by
have h := ((mem_intIcc_iff M u).mp hu).2
exact le_trans (Int.cast_le.mpr h) (Int.floor_le M)
private lemma short_cardinality (s : ℕ) (M : ℝ) (hMs : M < (s : ℝ) - 1) :
(intIcc M).card ≤ s - 1 := by
-- Since $M < s - 1$, we have $\lfloor M \rfloor \leq s - 2$.
have h_floor_le : ⌊M⌋ ≤ s - 2 := by
exact Int.le_of_lt_add_one <| Int.floor_lt.2 <| by norm_num; linarith;
unfold intIcc; cases s <;> norm_num at * ; omega;
linarith
/-
Given `2r` points with positive integer weights bounded by `W`, there exist integer
coefficients that annihilate the first `r` moments, have nonzero `r`-th moment,
and are bounded by `(c₉ M / r)^{r-1} · W`.
-/
private noncomputable def SILRProp : Prop := ∀ (r : ℕ), 1 ≤ r → ∀ (s : ℕ), s = 2 * r → ∀ (M : ℝ), (s : ℝ) - 1 ≤ M →
∀ (W : ℝ), 1 ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ),
(∀ i, 0 ≤ u i ∧ (u i : ℝ) ≤ M) → StrictMono u → (∀ i, 0 < w i) → (∀ i, (w i : ℝ) ≤ W) →
∃ a : Fin s → ℤ,
(∀ (j : ℕ), j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ j = 0) ∧
(∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ r ≠ 0) ∧
(∀ i, |(a i : ℝ)| ≤ (c₉ * M / (r : ℝ)) ^ (r - 1 : ℕ) * W)
/-- Translation rule: `(d/dx)^n f(a + x) = f^{(n)}(a + x)`. -/
private lemma iteratedDeriv_comp_translate (f : ℝ → ℝ) (a : ℝ) (n : ℕ) :
iteratedDeriv n (fun x => f (a + x)) = fun x => iteratedDeriv n f (a + x) :=
iteratedDeriv_comp_const_add n f a
/-- Affine chain rule: `(d/dx)^n f(a + bx) = b^n · f^{(n)}(a + bx)`.
Requires `f` to be `C^n`. -/
private lemma iteratedDeriv_comp_affine (f : ℝ → ℝ) (a b : ℝ) (n : ℕ) (x : ℝ)
(hf : ContDiff ℝ n f) :
iteratedDeriv n (fun x => f (a + b * x)) x =
b ^ n * iteratedDeriv n f (a + b * x) := by
have hg : ContDiff ℝ n (fun y => f (a + y)) :=
hf.comp (contDiff_const.add contDiff_id)
have h1 := congr_fun (iteratedDeriv_comp_const_mul hg b) x
have h2 := congr_fun (iteratedDeriv_comp_const_add n f a) (b * x)
rw [show (fun x => f (a + b * x)) = (fun x => (fun y => f (a + y)) (b * x)) from rfl]
rw [h1, h2]
/-- Smoothness is preserved under affine composition. -/
private lemma isGood_comp_affine {f : ℝ → ℝ} {W δ : ℝ} {u : ℤ} {a : ℤ} {b : ℕ}
(hgood : IsGood f W δ (a + b * u)) :
IsGood (fun x => f (↑a + ↑b * x)) W δ u := by
obtain ⟨v, w, hw_pos, hw_le, happrox⟩ := hgood
refine ⟨v, w, hw_pos, hw_le, ?_⟩
convert happrox using 2 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)))
push_cast
ring
/-
For positive reals, 1/min(min(a,b),c) ≤ 1/a + 1/b + 1/c
-/
private lemma one_div_min_le_sum_inv {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) :
1 / min (min a b) c ≤ 1 / a + 1 / b + 1 / c := by
field_simp;
rw [ min_def, min_def ] ; split_ifs <;> nlinarith [ mul_pos ha hb, mul_pos ha hc, mul_pos hb hc ] ;
/-
(2r-1)/r ≤ 2 for r ≥ 1
-/
private lemma finset_card_eq_sum_residue_classes (S : Finset ℤ) (ell : ℕ) (hell : 0 < ell) :
S.card = ∑ j ∈ Finset.range ell,
(S.filter (fun u => u % (ell : ℤ) = ↑j)).card := by
rw [ ← Finset.card_biUnion ];
· congr with u ; simp +decide;
exact ⟨ fun hu => ⟨ Int.toNat ( u % ell ), by linarith [ Int.emod_lt_of_pos u ( by positivity : 0 < ( ell : ℤ ) ), Int.toNat_of_nonneg ( Int.emod_nonneg u ( by positivity : ( ell : ℤ ) ≠ 0 ) ) ], hu, by rw [ Int.toNat_of_nonneg ( Int.emod_nonneg u ( by positivity : ( ell : ℤ ) ≠ 0 ) ) ] ⟩, by aesop ⟩;
· exact fun i hi j hj hij => Finset.disjoint_left.mpr fun x hx₁ hx₂ => hij <| by aesop;
private lemma iteratedDeriv_comp_affine_lower_bound
(f : ℝ → ℝ) (a : ℝ) (b : ℝ) (hb : 0 < b)
(r : ℕ) (D_r : ℝ)
(N' : ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_lower : ∀ x ∈ Set.Icc 0 (a + b * N'), D_r / 2 ≤ |iteratedDeriv r f x|)
(x : ℝ) (hx : x ∈ Set.Icc 0 N')
(ha_range : 0 ≤ a) :
b ^ r * D_r / 2 ≤ |iteratedDeriv r (fun x => f (a + b * x)) x| := by
rw [ iteratedDeriv_comp_affine ];
· rw [ abs_mul, abs_of_nonneg ( by positivity ) ] ; nlinarith [ hf_lower ( a + b * x ) ⟨ by nlinarith [ hx.1 ], by nlinarith [ hx.2 ] ⟩, pow_pos hb r ] ;
· exact hf_smooth.of_le (by exact_mod_cast Nat.le_succ r)
/-
Upper bound on r-th derivative of f(a + b·x)
-/
private lemma good_point_transfer
(f : ℝ → ℝ) (W δ : ℝ) (u : ℤ) (ell : ℕ)
(j : ℕ) (hmod : u % (ell : ℤ) = ↑j)
(hgood : IsGood f W δ u) :
IsGood (fun x => f (↑j + ↑ell * x)) W δ (u / ↑ell) := by
obtain ⟨v, w, hw_pos, hw_le, happrox⟩ := hgood
refine ⟨v, w, hw_pos, hw_le, ?_⟩
have h : (j : ℤ) + (ell : ℤ) * (u / ell) = u := by rw [← hmod]; exact Int.emod_add_mul_ediv u ell
have h' : (j : ℝ) + (ell : ℝ) * ((u / ell : ℤ) : ℝ) = (u : ℝ) := by exact_mod_cast h
show |f ((j : ℝ) + (ell : ℝ) * ((u / ell : ℤ) : ℝ)) - _| < δ
rw [h']; exact happrox
/-
If every sub-interval of length M contains fewer than B elements of S,
then |S| ≤ (N/M + 1) * (B-1).
-/
private lemma block_subdivision_count
(N M : ℝ) (hN : 0 < N) (hM : 0 < M)
(B : ℕ) (hB : 1 ≤ B)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(h_per_block : ∀ (k : ℕ), (S.filter (fun u : ℤ =>
(k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)).card < B) :
(S.card : ℝ) ≤ (N / M + 1) * ((B : ℝ) - 1) := by
-- By partitioning S into blocks of length M, we can bound the cardinality of S by the sum of the cardinalities of these blocks.
have h_partition : S.card ≤ ∑ k ∈ Finset.range (Nat.floor (N / M) + 1), (S.filter (fun u : ℤ => k * M ≤ (u : ℝ) ∧ (u : ℝ) < (k + 1) * M)).card := by
refine le_trans ?_ ( Finset.card_biUnion_le );
refine Finset.card_le_card ?_;
intro u hu; specialize hS_sub hu; simp_all +decide [ intIcc ] ;
refine' ⟨ ⌊ ( u : ℝ ) / M⌋₊, _, _, _ ⟩;
· gcongr;
exact Int.le_floor.mp hS_sub.2;
· nlinarith [ Nat.floor_le ( show 0 ≤ ( u : ℝ ) / M by exact div_nonneg ( mod_cast hS_sub.1 ) hM.le ), mul_div_cancel₀ ( u : ℝ ) hM.ne' ];
· nlinarith [ Nat.lt_floor_add_one ( ( u : ℝ ) / M ), mul_div_cancel₀ ( u : ℝ ) hM.ne' ];
refine' le_trans ( Nat.cast_le.mpr h_partition ) _;
refine' le_trans ( Nat.cast_le.mpr <| Finset.sum_le_sum fun _ _ => Nat.le_sub_one_of_lt <| h_per_block _ ) _ ; norm_num;
gcongr <;> cases B <;> norm_num at * ; linarith [ Nat.floor_le ( by positivity : 0 ≤ N / M ) ]
/-
For j < ℓ and x ∈ [0, (N-j)/ℓ], j + ℓx ∈ [0, N]
-/
private lemma sum_N_sub_j_div_ell_le (N : ℝ) (ell : ℕ) (hell : 0 < ell) :
∑ j ∈ Finset.range ell, ((N - ↑j) / ↑ell) ≤ N := by
rw [ ← Finset.sum_div _ _ _, div_le_iff₀ ] <;> norm_num [ hell ];
exact le_add_of_le_of_nonneg ( by linarith ) ( Finset.sum_nonneg fun _ _ => Nat.cast_nonneg _ )
/-
(N - j)/ℓ > 0 when j < ℓ ≤ N
-/
private lemma ediv_in_intIcc {u : ℤ} {N : ℝ} {ell : ℕ} {j : ℕ}
(hell : 0 < ell) (hu_mem : u ∈ intIcc N)
(hmod : u % (ell : ℤ) = ↑j) :
u / (ell : ℤ) ∈ intIcc ((N - ↑j) / ↑ell) := by
unfold intIcc at *;
norm_num at *;
rw [ Int.le_floor ] at *;
rw [ le_div_iff₀ ( by positivity ) ];
exact ⟨ Int.ediv_nonneg hu_mem.1 ( by positivity ), by linarith [ show ( u : ℝ ) = ( u / ell : ℤ ) * ell + j by exact mod_cast by linarith [ Int.emod_add_mul_ediv u ell ] ] ⟩
/-
The algebraic part of lambda_one_case: given |S| ≤ (N/M + 1)(2r-1),
derive the final C₀ bound.
-/
private lemma block_count_to_C0_bound
(r : ℕ) (hr : 2 ≤ r)
(N : ℝ) (hN : 0 < N)
(D_r D_r1 W δ : ℝ) (hDr : 0 < D_r) (hDr1 : 0 < D_r1)
(hW : 1 ≤ W) (hδ : 0 < δ)
(card_bound : ℝ)
(h_card : card_bound ≤ (N / ((r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1)))) + 1) *
(2 * (r : ℝ) - 1)) :
card_bound < C₀_const * N *
((D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / D_r) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) +
2 * (r : ℝ) := by
-- Let's simplify the expression.
suffices h_simp : (N / ((r : ℝ) / B_const * min (min ((D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ)) ((D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ))) ((D_r / (δ * W ^ 2)) ^ (1 / (r - 1) : ℝ)))) * (2 * r - 1) ≤ C₀_const * N * ((D_r * W ^ 2) ^ (2 * r - 1 : ℝ)⁻¹ + (δ * W ^ 2 / D_r) ^ (r - 1 : ℝ)⁻¹ + (D_r1 * W ^ 2 / D_r) ^ (2 * r : ℝ)⁻¹) by
linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ];
-- By simplifying, we can see that the left-hand side is less than or equal to the right-hand side.
have h_simp : (1 / (min (min ((D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ)) ((D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ))) ((D_r / (δ * W ^ 2)) ^ (1 / (r - 1) : ℝ)))) ≤ ((D_r * W ^ 2) ^ (2 * r - 1 : ℝ)⁻¹ + (δ * W ^ 2 / D_r) ^ (r - 1 : ℝ)⁻¹ + (D_r1 * W ^ 2 / D_r) ^ (2 * r : ℝ)⁻¹) := by
convert one_div_min_le_sum_inv _ _ _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· norm_num [ neg_div, Real.rpow_neg_eq_inv_rpow ];
rw [ ← Real.inv_rpow ( by positivity ), ← Real.inv_rpow ( by positivity ), ← Real.inv_rpow ( by positivity ) ] ; ring_nf;
norm_num ; ring_nf;
· positivity;
· positivity;
· positivity;
refine le_trans ?_ ( mul_le_mul_of_nonneg_left h_simp <| by exact mul_nonneg ( by exact le_of_lt <| by exact show 0 < C₀_const by exact C₀_pos ) <| by positivity );
field_simp [mul_comm, mul_assoc, mul_left_comm] at *;
unfold B_const C₀_const; ring_nf; norm_num;
unfold B_const; nlinarith [ show ( r : ℝ ) ≥ 2 by norm_cast, show ( K_const : ℝ ) ≥ 4 by exact_mod_cast four_le_K ] ;
private lemma int_abs_lt_one_imp_zero (L : ℤ) (h : |(L : ℝ)| < 1) : L = 0 := by
norm_cast at h; aesop;
/-
If intIcc M has at least n elements (n ≥ 1), then M ≥ n - 1.
-/
private lemma eight_r_le_sixteen_pow (r : ℕ) (hr : 2 ≤ r) : (8 : ℝ) * r ≤ 16 ^ (r - 1) := by
rcases r with ( _ | _ | r ) <;> norm_num at *;
exact mod_cast Nat.recOn r ( by norm_num ) fun n ihn => by norm_num [ Nat.pow_succ' ] at * ; linarith;
/-
Constant inequality (i): Under M bound from T₁,
2r D_r W² (K_const M/r)^{2r-1} ≤ 1/2.
-/
private lemma constant_ineq_i
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(D_r : ℝ) (hDr : 0 < D_r)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1))) :
2 * (r : ℝ) * D_r * W ^ 2 * (K_const * M / (r : ℝ)) ^ (2 * r - 1) ≤ 1 / 2 := by
-- From hM_le: KM/r ≤ 1/16 · (D_r W²)^{-1/(2r-1)} (since K = B/16)
have hKM_div_r_le : (K_const * M / r) ^ (2 * r - 1) ≤ (1 / 16) ^ (2 * r - 1) * (D_r * W ^ 2) ^ (-1 : ℝ) := by
have hKM_div_r_pow : (K_const * M / r) ≤ (1 / 16) * (D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ) := by
rw [ div_le_iff₀ ( by positivity ) ];
convert mul_le_mul_of_nonneg_left hM_le ( show 0 ≤ K_const by exact le_trans ( by norm_num ) ( le_max_left _ _ ) ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring_nf;
unfold K_const B_const; ring_nf;
unfold K_const; norm_num [ c₉ ] ;
ring;
convert pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_of_lt K_pos ) hM.le ) ( Nat.cast_nonneg _ ) ) hKM_div_r_pow _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ mul_pow, ← Real.rpow_natCast _ ( 2 * r - 1 ), ← Real.rpow_natCast _ ( 2 * r - 1 ), ← Real.rpow_mul ( by positivity ) ] ; norm_num [ Nat.cast_sub ( show 1 ≤ 2 * r by linarith ) ];
exact Or.inl ( by rw [ div_mul_cancel₀ _ ( sub_ne_zero_of_ne ( by norm_cast; linarith ) ) ] );
refine le_trans ( mul_le_mul_of_nonneg_left hKM_div_r_le <| by positivity ) ?_;
norm_cast ; norm_num [ mul_assoc, mul_comm, mul_left_comm, hDr.ne', show W ≠ 0 by positivity ];
rw [ show r * 2 - 1 = 2 * r - 1 by ring_nf ] ; rcases r with ( _ | _ | r ) <;> norm_num [ Nat.mul_succ, pow_succ' ] at *;
exact Nat.recOn r ( by norm_num ) fun n ihn => by norm_num [ Nat.mul_succ, pow_succ' ] at ihn ⊢ ; nlinarith [ pow_pos ( by norm_num : ( 0 : ℝ ) < 1 / 16 ) n ] ;
/-
Constant inequality (ii): Under M bound from T₂,
2r D_{r+1} W² (K_const M/r)^{2r} ≤ D_r/4.
-/
private lemma constant_ineq_ii
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))) :
2 * (r : ℝ) * D_r1 * W ^ 2 * (K_const * M / (r : ℝ)) ^ (2 * r) ≤ D_r / 4 := by
-- Since $B = 16K$, $M \le r/B T₂$ gives $KM/r \le T₂/16$ where $T₂ = (D_r/(D_{r+1}W²))^{1/(2r)}$.
have hKM_le_T2_div_16 : K_const * M / r ≤ (D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ) / 16 := by
convert div_le_div_of_nonneg_right ( mul_le_mul_of_nonneg_left hM_le <| show ( 0 : ℝ ) ≤ K_const by exact le_of_lt K_pos ) ( show ( 0 : ℝ ) ≤ r by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring_nf! ; norm_num [ show B_const = 16 * K_const by rfl ] ; ring_nf!;
norm_num [ show r ≠ 0 by positivity, show K_const ≠ 0 by exact ne_of_gt ( lt_max_of_lt_left ( by norm_num ) ) ];
-- So $2r D_{r+1} W² (KM/r)^{2r} ≤ 2r D_r / 16^{2r}$.
have h_bound : 2 * r * D_r1 * W ^ 2 * (K_const * M / r) ^ (2 * r) ≤ 2 * r * D_r / 16 ^ (2 * r) := by
refine le_trans ( mul_le_mul_of_nonneg_left ( pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_of_lt ( show 0 < K_const by exact lt_max_of_lt_left ( by norm_num ) ) ) hM.le ) ( Nat.cast_nonneg _ ) ) hKM_le_T2_div_16 _ ) ( by positivity ) ) ?_;
rw [ div_pow, ← Real.rpow_natCast _ ( 2 * r ), ← Real.rpow_natCast _ ( 2 * r ), ← Real.rpow_mul ( by positivity ) ] ; norm_num [ mul_assoc, mul_comm, mul_left_comm, ne_of_gt ( zero_lt_two.trans_le hr ) ];
field_simp;
norm_num;
refine le_trans h_bound ?_;
rw [ div_le_div_iff₀ ] <;> norm_cast <;> norm_num [ pow_mul ];
nlinarith [ show ( 256 : ℝ ) ^ r ≥ 2 * r * 4 by exact mod_cast Nat.le_induction ( by norm_num ) ( fun k hk ih ↦ by norm_num [ Nat.pow_succ ] at * ; nlinarith ) r hr ]
/-
Constant inequality (iii): Under M bound from T₃,
2r δ W² (K_const M/r)^{r-1} ≤ D_r/4.
-/
private lemma constant_ineq_iii
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))) :
2 * (r : ℝ) * δ * W ^ 2 * (K_const * M / (r : ℝ)) ^ (r - 1) ≤ D_r / 4 := by
-- By multiplying both sides of the inequality $K_const * M / r \leq 1/16 * (D_r / (δ * W ^ 2)) ^ (1 / (r - 1))$ by $r$, we get $K_const * M \leq 1/16 * (D_r / (δ * W ^ 2)) ^ (1 / (r - 1)) * r$.
have h_mul : (K_const * M / r) ^ (r - 1) ≤ (1 / 16) ^ (r - 1) * (D_r / (δ * W ^ 2)) := by
convert pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_max_of_le_left ( by norm_num ) ) hM.le ) ( Nat.cast_nonneg _ ) ) ( show K_const * M / r ≤ ( 1 / 16 ) * ( D_r / ( δ * W ^ 2 ) ) ^ ( 1 / ( r - 1 : ℝ ) ) by
rw [ div_le_iff₀ ] <;> norm_num [ B_const ] at *;
· rw [ div_mul_eq_mul_div, le_div_iff₀ ] at hM_le <;> nlinarith [ show ( 0 : ℝ ) < K_const by exact lt_max_of_lt_left ( by norm_num ) ];
· linarith ) ( r - 1 ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ mul_pow, ← Real.rpow_natCast _ ( r - 1 ), ← Real.rpow_natCast _ ( r - 1 ), ← Real.rpow_mul ( by positivity ), Nat.cast_sub ( by linarith ), Nat.cast_one, div_mul_cancel₀ _ ( sub_ne_zero_of_ne ( by norm_cast; linarith ) ) ] ; norm_num;
refine le_trans ( mul_le_mul_of_nonneg_left h_mul <| by positivity ) ?_;
-- We can divide both sides by $δ * W^2$ to simplify the inequality.
have h_div : 2 * (r : ℝ) * (1 / 16) ^ (r - 1) ≤ 1 / 4 := by
have := eight_r_le_sixteen_pow r hr;
rw [ one_div, inv_pow ] ; nlinarith [ show ( 0 : ℝ ) < 16 ^ ( r - 1 ) by positivity, mul_inv_cancel₀ ( show ( 16 : ℝ ) ^ ( r - 1 ) ≠ 0 by positivity ) ]
have hδW : 0 < δ * W ^ 2 := by positivity
calc 2 * (r : ℝ) * δ * W ^ 2 * ((1 / 16) ^ (r - 1) * (D_r / (δ * W ^ 2)))
= (2 * (r : ℝ) * (1 / 16) ^ (r - 1)) * D_r := by
have := hδW.ne'; first | (field_simp; done) | (field_simp; ring)
_ ≤ 1 / 4 * D_r := mul_le_mul_of_nonneg_right h_div hDr.le
_ = D_r / 4 := by ring
/-
For r ≥ 1: 1/r! ≤ (4/r)^r.
-/
private lemma factorial_inv_le (r : ℕ) (hr : 1 ≤ r) :
(1 : ℝ) / (r.factorial : ℝ) ≤ (4 / (r : ℝ)) ^ r := by
-- We'll use the fact that $r! \geq (r/4)^r$ for $r \geq 1$.
have h_factorial : ∀ r : ℕ, 1 ≤ r → (r.factorial : ℝ) ≥ (r / 4) ^ r := by
intro r hr;
induction hr <;> norm_num [ Nat.factorial ] at *;
-- We'll use the fact that $(1 + 1/m)^m \leq 4$ for all $m \geq 1$.
have h_exp : ∀ m : ℕ, 1 ≤ m → (1 + 1 / (m : ℝ)) ^ m ≤ 4 := by
-- We'll use the fact that $(1 + 1/m)^m \leq e$ for all $m \geq 1$.
have h_exp : ∀ m : ℕ, 1 ≤ m → (1 + 1 / (m : ℝ)) ^ m ≤ Real.exp 1 := by
intro m hm; rw [ ← Real.rpow_natCast, Real.rpow_def_of_pos ( by positivity ) ] ; norm_num;
nlinarith [ Real.log_le_sub_one_of_pos ( by positivity : 0 < 1 + ( m : ℝ ) ⁻¹ ), mul_inv_cancel₀ ( by positivity : ( m : ℝ ) ≠ 0 ) ];
exact fun m hm => le_trans ( h_exp m hm ) ( Real.exp_one_lt_d9.le.trans ( by norm_num ) );
have := h_exp _ ‹_›; rw [ one_add_div ( by positivity ) ] at this; rw [ div_pow, div_le_iff₀ ( by positivity ) ] at *; ring_nf at *; nlinarith;
have hr0 : (0 : ℝ) < (r : ℝ) / 4 := div_pos (by exact_mod_cast Nat.one_pos.trans_le hr) (by norm_num)
have h := one_div_le_one_div_of_le (pow_pos hr0 r) (h_factorial r hr)
calc (1 : ℝ) / (r.factorial : ℝ) ≤ 1 / ((r : ℝ) / 4) ^ r := h
_ = (4 / (r : ℝ)) ^ r := by rw [one_div, ← inv_pow, inv_div]
/-
The Taylor polynomial of degree r at 0 approximates f with error ≤ D_{r+1} (4M/r)^{r+1}.
More precisely, if f ∈ C^{r+1}[0,M] and |f^{(r+1)}| ≤ D_{r+1}, then
|f(x) - ∑_{j=0}^r f^{(j)}(0)/j! x^j| ≤ D_{r+1} (4M/r)^{r+1} for x ∈ [0,M].
We actually bound by D_{r+1} (K·M/r)^{r+1} since K ≥ 4.
-/
private lemma taylor_degree_r_remainder
(r : ℕ) (hr : 1 ≤ r) (M : ℝ) (_ : 0 < M)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ) (hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(x : ℝ) (hx : x ∈ Set.Icc (0 : ℝ) M) :
|f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * x ^ j| ≤
D_r1 * (K_const * M / (r : ℝ)) ^ (r + 1) := by
-- By Taylor's theorem with remainder, we have |f(x) - ∑_{j=0}^r f^(j)(0)/j! x^j| ≤ D_{r+1} x^{r+1}/(r+1)!.
have h_taylor_remainder : abs (f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j) ≤ D_r1 * x ^ (r + 1) / Nat.factorial (r + 1) := by
by_cases hx0 : x = 0;
· simp_all +decide [ Finset.sum_range_succ' ];
· obtain ⟨x', hx'⟩ : ∃ x' ∈ Set.Ioo 0 x, f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j = iteratedDeriv (r + 1) f x' * x ^ (r + 1) / Nat.factorial (r + 1) := by
have hxpos : 0 < x := lt_of_le_of_ne hx.1 (Ne.symm hx0)
have hC : ContDiffOn ℝ (↑r + 1) f (Set.uIcc 0 x) := by
have := hf_smooth.contDiffOn (s := Set.uIcc 0 x); exact_mod_cast this
obtain ⟨x', hx'mem, hx'eq⟩ := taylor_mean_remainder_lagrange_iteratedDeriv (ne_of_lt hxpos) hC
refine ⟨x', by simpa [Set.uIoo, hxpos.le] using hx'mem, ?_⟩
rw [sub_zero] at hx'eq
rw [← hx'eq]
congr 1
rw [taylor_within_apply, Set.uIcc_of_le hx.1]
apply Finset.sum_congr rfl
intro i hi
have hi' : i ≤ r + 1 := by have := Finset.mem_range.mp hi; omega
rw [iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc hxpos)
(hf_smooth.contDiffAt.of_le (by exact_mod_cast hi')) ⟨le_rfl, hx.1⟩, smul_eq_mul, sub_zero]
ring
rw [ hx'.2, abs_div, abs_mul, abs_of_nonneg ( by exact pow_nonneg hx.1 _ : ( 0 : ℝ ) ≤ x ^ ( r + 1 ) ), abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ ( r + 1 ).factorial ) ];
gcongr ; aesop;
exact hf_r1 x' ⟨ hx'.1.1.le, hx'.1.2.le.trans hx.2 ⟩;
-- By the factorial estimate, we have 1/(r+1)! ≤ (4/(r+1))^{r+1} ≤ (4/r)^{r+1} ≤ (K/r)^{r+1}.
have h_factorial_estimate : (1 : ℝ) / Nat.factorial (r + 1) ≤ (4 / r) ^ (r + 1) := by
convert factorial_inv_le ( r + 1 ) ( by linarith ) |> le_trans <| ?_ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
gcongr ; norm_num;
-- Substitute the factorial estimate into the Taylor remainder bound.
have h_substitute : abs (f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j) ≤ D_r1 * x ^ (r + 1) * (4 / r) ^ (r + 1) := by
exact h_taylor_remainder.trans ( by rw [ div_eq_mul_one_div ] ; exact mul_le_mul_of_nonneg_left ( by simpa using h_factorial_estimate ) ( mul_nonneg hDr1.le ( pow_nonneg hx.1 _ ) ) );
-- Since $x \leq M$, we have $x^{r+1} \leq M^{r+1}$.
have h_x_le_M : x ^ (r + 1) ≤ M ^ (r + 1) := by
exact pow_le_pow_left₀ hx.1 hx.2 _;
refine le_trans h_substitute ?_
have h4K : (4 : ℝ) ≤ K_const := le_max_left 4 c₉
have hx0 : (0 : ℝ) ≤ x := hx.1
have key : (4 * x / ↑r) ^ (r + 1) ≤ (K_const * M / ↑r) ^ (r + 1) := by
apply pow_le_pow_left₀ (by positivity)
apply div_le_div_of_nonneg_right _ (by positivity : (0:ℝ) ≤ ↑r)
exact mul_le_mul h4K hx.2 hx0 (by positivity)
nlinarith [show D_r1 * x ^ (r + 1) * (4 / ↑r) ^ (r + 1) = D_r1 * (4 * x / ↑r) ^ (r + 1) from by ring]
/-
The approximation error: |∑ aᵢ(vᵢ - wᵢf(uᵢ))| ≤ ∑ |aᵢ| · δ · wᵢ
-/
private lemma coeff_sum_bound'
{s : ℕ} {a : Fin s → ℤ} {w : Fin s → ℕ}
{W C_a : ℝ} (hCa : 0 ≤ C_a)
(hw_bound : ∀ i, (w i : ℝ) ≤ W)
(ha_bound : ∀ i, |(a i : ℝ)| ≤ C_a) :
∑ i, |(a i : ℝ)| * (w i : ℝ) ≤ (s : ℝ) * C_a * W := by
exact le_trans ( Finset.sum_le_sum fun _ _ => mul_le_mul ( ha_bound _ ) ( hw_bound _ ) ( by positivity ) ( by positivity ) ) ( by norm_num; nlinarith )
/-- The "binomial polynomial" P_r(n) = n!/(r!(n-r)!) = C(n,r) is a nonneg integer for n ≥ 0. -/
private lemma binomial_poly_eq_choose (n r : ℕ) :
(1 : ℝ) / (r.factorial : ℝ) * ∏ m ∈ Finset.range r, ((n : ℝ) - m) = Nat.choose n r := by
by_cases hn : n < r;
· rw [ Nat.choose_eq_zero_of_lt hn, eq_comm ];
rw [ Finset.prod_eq_zero ( Finset.mem_range.mpr hn ) ] <;> aesop;
· field_simp;
rw_mod_cast [ ← Nat.descFactorial_eq_factorial_mul_choose ];
rw [ Nat.descFactorial_eq_prod_range ];
rw [ Nat.cast_prod, Finset.prod_congr rfl fun x hx => Int.subNatNat_of_le ( by linarith [ Finset.mem_range.mp hx ] ) ]
/-
If ∑ aᵢwᵢuᵢ^j = 0 for j < r and ∑ aᵢwᵢuᵢ^r ≠ 0,
then Z₀ = ∑ aᵢwᵢP_r(uᵢ) is a nonzero integer, so |Z₀| ≥ 1.
Here Z₀ = 1/r! ∑ aᵢwᵢuᵢ^r (by moment annihilation applied to P_r - X^r/r!).
-/
private lemma Z0_nonzero_integer
{s r : ℕ}
{a : Fin s → ℤ} {w : Fin s → ℕ} {u : Fin s → ℤ}
(hu_nonneg : ∀ i, 0 ≤ u i)
(h_vanish : ∀ j : ℕ, j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ j = 0)
(h_nonzero : ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r ≠ 0) :
∃ Z₀ : ℤ, Z₀ ≠ 0 ∧ (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r := by
-- Define Z₀ as the sum of a_i w_i binom(u_i, r).
set Z₀ : ℤ := ∑ i, (a i : ℤ) * (w i : ℤ) * Nat.choose (u i).toNat r;
-- By definition of $Z₀$, we know that
have hZ₀ : (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r := by
have hZ₀ : (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) := by
have hZ₀ : ∀ i, (Nat.choose (u i).toNat r : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) := by
intro i; specialize hu_nonneg i
obtain ⟨n, hn⟩ := Int.eq_ofNat_of_zero_le hu_nonneg
simp only [hn]; exact (binomial_poly_eq_choose n r).symm
simp +zetaDelta at *;
simp +decide only [hZ₀, Finset.mul_sum _ _ _, mul_left_comm];
-- By definition of polynomial interpolation, we know that $\prod_{j=0}^{r-1} (u_i - j)$ is a polynomial of degree $r$.
have h_poly_interpolate : ∃ p : Polynomial ℝ, p.degree ≤ r ∧ ∀ i, (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) = p.eval (u i : ℝ) ∧ p.coeff r = 1 := by
refine' ⟨ ∏ j ∈ Finset.range r, ( Polynomial.X - Polynomial.C ( j : ℝ ) ), _, _ ⟩;
· norm_num [ Polynomial.degree_prod ];
erw [ Finset.sum_congr rfl fun _ _ => Polynomial.degree_X_sub_C _ ] ; norm_num;
· refine' fun i => ⟨ _, _ ⟩;
· simp +decide [ Polynomial.eval_prod ];
· have h_coeff : Polynomial.leadingCoeff (∏ j ∈ Finset.range r, (Polynomial.X - Polynomial.C (j : ℝ))) = 1 := by
rw [ Polynomial.leadingCoeff_prod ] ; exact Finset.prod_eq_one fun _ _ => Polynomial.leadingCoeff_X_sub_C _;
rw [ Polynomial.leadingCoeff, Polynomial.natDegree_prod _ _ fun x hx => Polynomial.X_sub_C_ne_zero _ ] at h_coeff;
simpa [ Polynomial.natDegree_sub_eq_left_of_natDegree_lt ] using h_coeff;
obtain ⟨ p, hp₁, hp₂ ⟩ := h_poly_interpolate;
have h_poly_interpolate : ∑ i, (a i : ℝ) * (w i : ℝ) * p.eval (u i : ℝ) = ∑ j ∈ Finset.range (r + 1), p.coeff j * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ j := by
simp +decide [ Finset.mul_sum _ _ _, mul_assoc, mul_comm, mul_left_comm ];
rw [ Finset.sum_comm, Finset.sum_congr rfl ] ; intros ; rw [ Polynomial.eval_eq_sum_range' ] ; ring_nf;
exacts [ by rw [ Finset.mul_sum _ _ _ ] ; exact Finset.sum_congr rfl fun _ _ => by ring, by linarith [ Polynomial.natDegree_le_of_degree_le hp₁ ] ];
simp_all +decide [ Finset.sum_range_succ ];
exact Or.inl ( by rw [ Finset.sum_eq_zero fun j hj => by rw [ h_vanish j ( Finset.mem_range.mp hj ) ] ; ring ] ; rw [ hp₂ ⟨ 0, Nat.pos_of_ne_zero ( by aesop_cat ) ⟩ |>.2 ] ; ring );
exact ⟨ Z₀, by contrapose! h_nonzero; simp_all +decide [ Nat.factorial_ne_zero ], hZ₀ ⟩
/-
Short interval bound.
-/
private theorem short_interval
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) M, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc M))
(hS_good : ∀ u ∈ S, IsGood f W δ u)
(hM_le : M ≤ (r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1)))) :
S.card < 2 * r := by
-- Convert hS_sub to Finset subset
have hS_sub' : S ⊆ intIcc M := Finset.coe_subset.mp hS_sub
-- If M < 2r - 1, use short_cardinality
by_cases h_small : M < (2 * r : ℝ) - 1
· have h1 := Finset.card_le_card hS_sub'
have h2 := short_cardinality (2 * r) M (by push_cast; exact h_small)
omega
push_neg at h_small
-- Suppose for contradiction |S| ≥ 2r
by_contra h_contra; push_neg at h_contra
obtain ⟨T, hT_sub, hT_card⟩ := Finset.le_card_iff_exists_subset_card.mp h_contra
set e := Finset.orderIsoOfFin T hT_card
set u_fn := fun (i : Fin (2 * r)) => (e i : ℤ)
have h_strict : StrictMono u_fn := fun i j hij => by exact_mod_cast (e.strictMono hij)
have h_range : ∀ i, 0 ≤ u_fn i ∧ (u_fn i : ℝ) ≤ M := by
intro i; have := hS_sub' (hT_sub (Finset.coe_mem (e i)))
exact ⟨intIcc_nonneg this, intIcc_le_M this⟩
have h_good : ∀ i, IsGood f W δ (u_fn i) := by
intro i; exact hS_good _ (hT_sub (Finset.coe_mem (e i)))
choose v_fn w_fn hw_pos hw_le h_approx using h_good
have h_small' : ((2 * r : ℕ) : ℝ) - 1 ≤ M := by push_cast; exact h_small
obtain ⟨a_fn, h_moment_zero, h_moment_r, h_coeff_bound⟩ :=
hSILR r (by linarith) (2 * r) rfl M h_small' W hW
u_fn w_fn h_range h_strict hw_pos hw_le
-- Define key quantities
set I : ℤ := ∑ i, a_fn i * v_fn i
set I₁ : ℝ := iteratedDeriv r f 0 / (r.factorial : ℝ) *
∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r
set R₁ : ℝ := ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) *
(f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1),
iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j)
set R₂ : ℝ := ∑ i, (a_fn i : ℝ) * ((v_fn i : ℝ) - (w_fn i : ℝ) * f (u_fn i : ℝ))
-- I = I₁ + R₁ + R₂ (splitting the integer into three real parts)
have hI_split : (I : ℝ) = I₁ + R₁ + R₂ := by
have hI : ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j) = I₁ := by
simp +zetaDelta at *;
simp +decide [Finset.mul_sum _ _ _, mul_assoc, mul_left_comm];
rw [ Finset.sum_comm ];
simp +decide [ Finset.sum_range_succ ];
exact Finset.sum_eq_zero fun i hi => by simpa [ mul_assoc, mul_comm, mul_left_comm, Finset.mul_sum _ _ _ ] using mul_eq_zero_of_right ( iteratedDeriv i f 0 / ( i.factorial : ℝ ) ) ( h_moment_zero i ( Finset.mem_range.mp hi ) ) ;
convert congr_arg₂ ( · + · ) ( congr_arg₂ ( · + · ) hI rfl ) rfl using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
simp +zetaDelta at *;
rw [ ← Finset.sum_add_distrib, ← Finset.sum_add_distrib ] ; congr ; ext ; ring;
-- Key bounds
have hI₁_upper : |I₁| ≤ 1 / 2 := by
-- By the properties of the derivative and the bounds on the coefficients, we have:
have hI1_bound : |I₁| ≤ D_r / (r.factorial : ℝ) * (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r := by
have hI1_bound : |∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r := by
have hI1_bound : ∀ i, |(a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ (c₉ * M / r) ^ (r - 1) * W * W * M ^ r := by
intros i
have h_abs : |(a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ |(a_fn i : ℝ)| * (w_fn i : ℝ) * M ^ r := by
norm_num [ abs_mul ];
exact mul_le_mul_of_nonneg_left ( pow_le_pow_left₀ ( abs_nonneg _ ) ( by rw [ abs_of_nonneg ( mod_cast h_range i |>.1 ) ] ; exact h_range i |>.2 ) _ ) ( by positivity );
exact h_abs.trans ( mul_le_mul_of_nonneg_right ( mul_le_mul ( h_coeff_bound i ) ( hw_le i ) ( by positivity ) ( by exact mul_nonneg ( pow_nonneg ( by exact div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ( by positivity ) ) ) ( by positivity ) );
exact le_trans ( Finset.abs_sum_le_sum_abs _ _ ) ( le_trans ( Finset.sum_le_sum fun _ _ => hI1_bound _ ) ( by norm_num; linarith ) );
have := hf_r_upper 0 ⟨ by norm_num, by linarith ⟩;
rw [ abs_mul, abs_div ];
rw [ abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ r.factorial ) ] ; convert mul_le_mul ( div_le_div_of_nonneg_right this ( by positivity : ( 0 : ℝ ) ≤ r.factorial ) ) hI1_bound ( by positivity ) ( by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring;
-- Using the factorial bound and the fact that $c₉ \leq K$, we can simplify the expression.
have h_factorial_bound : D_r / (r.factorial : ℝ) * (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r ≤ D_r * 2 * r * W ^ 2 * (K_const * M / r) ^ (2 * r - 1) := by
have h_factorial_bound : M ^ r / (r.factorial : ℝ) ≤ (K_const * M / r) ^ r := by
have hM_r_bound : M ^ r / (r.factorial : ℝ) ≤ (4 * M / r) ^ r := by
have := factorial_inv_le r ( by linarith );
convert mul_le_mul_of_nonneg_left this ( pow_nonneg hM.le r ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> ring;
exact hM_r_bound.trans ( pow_le_pow_left₀ ( by positivity ) ( by rw [ div_le_div_iff_of_pos_right ( by positivity ) ] ; exact mul_le_mul_of_nonneg_right ( by exact le_max_left _ _ ) hM.le ) _ );
have h_factorial_bound : (c₉ * M / r) ^ (r - 1) * M ^ r / (r.factorial : ℝ) ≤ (K_const * M / r) ^ (2 * r - 1) := by
rw [ show 2 * r - 1 = r - 1 + r by omega, pow_add ];
rw [ mul_div_assoc ];
gcongr;
· exact pow_nonneg ( div_nonneg ( mul_nonneg ( by exact le_max_of_le_left ( by norm_num ) ) hM.le ) ( Nat.cast_nonneg _ ) ) _;
· exact div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ );
· exact le_max_right _ _;
convert mul_le_mul_of_nonneg_left h_factorial_bound ( show 0 ≤ D_r * 2 * r * W ^ 2 by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring;
refine le_trans hI1_bound <| h_factorial_bound.trans ?_;
convert constant_ineq_i r hr M hM W hW D_r hDr _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· ring;
· exact hM_le.trans ( mul_le_mul_of_nonneg_left ( min_le_left _ _ |> le_trans <| min_le_left _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact mul_nonneg ( by norm_num ) <| le_max_of_le_left <| by norm_num )
have hI₁_lower : D_r / 2 ≤ |I₁| := by
-- By definition of $Z₀$, we have $Z₀ = 1/r! \sum a_i w_i u_i^r$.
obtain ⟨Z₀, hZ₀_nonzero, hZ₀_eq⟩ : ∃ Z₀ : ℤ, Z₀ ≠ 0 ∧ (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * u_fn i ^ r := by
convert Z0_nonzero_integer ( fun i => h_range i |>.1 ) h_moment_zero h_moment_r using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
-- By definition of $I₁$, we have $I₁ = f^{(r)}(0) \cdot Z₀$.
have hI₁_def : I₁ = iteratedDeriv r f 0 * Z₀ := by
grind;
rw [ hI₁_def, abs_mul ];
exact le_trans ( hf_r_lower 0 ⟨ by norm_num, by linarith ⟩ ) ( le_mul_of_one_le_right ( abs_nonneg _ ) ( mod_cast abs_pos.mpr hZ₀_nonzero ) )
have hR_sum : |R₁ + R₂| < D_r / 2 := by
-- We bound |R₁| using taylor_degree_r_remainder and constant_ineq_ii.
have hR₁_bound : |R₁| ≤ 2 * r * D_r1 * W ^ 2 * (K_const * M / r) ^ (2 * r) := by
have hR₁_bound : |R₁| ≤ D_r1 * (K_const * M / r) ^ (r + 1) * (∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ)) := by
have hR₁_upper : ∀ i, |(a_fn i : ℝ) * (w_fn i : ℝ) * (f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j)| ≤ |(a_fn i : ℝ)| * (w_fn i : ℝ) * D_r1 * (K_const * M / r) ^ (r + 1) := by
intros i
have h_remainder_bound : |f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j| ≤ D_r1 * (K_const * M / r) ^ (r + 1) := by
apply taylor_degree_r_remainder;
grind;
· linarith;
· positivity;
· exact hf_smooth;
· exact hf_r1;
· exact ⟨ mod_cast h_range i |>.1, h_range i |>.2 ⟩;
rw [ abs_mul, abs_mul, abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ w_fn i ) ] ; nlinarith [ show ( 0 : ℝ ) ≤ |↑ ( a_fn i )| * ↑ ( w_fn i ) by positivity ] ;
exact le_trans ( Finset.abs_sum_le_sum_abs _ _ ) ( by rw [ Finset.mul_sum _ _ _ ] ; exact Finset.sum_le_sum fun i _ => by convert hR₁_upper i using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring );
have hR₁_bound : |R₁| ≤ D_r1 * (K_const * M / r) ^ (r + 1) * (2 * r) * (c₉ * M / r) ^ (r - 1) * W ^ 2 := by
have hR₁_bound : ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) ≤ (2 * r) * (c₉ * M / r) ^ (r - 1) * W ^ 2 := by
convert coeff_sum_bound' ( show 0 ≤ ( c₉ * M / r ) ^ ( r - 1 ) * W by exact mul_nonneg ( pow_nonneg ( div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ( by positivity ) ) ( fun i => hw_le i ) ( fun i => h_coeff_bound i ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; norm_num [ mul_assoc, mul_comm, mul_left_comm ];
ring;
exact le_trans ‹_› ( by nlinarith [ show 0 ≤ D_r1 * ( K_const * M / r ) ^ ( r + 1 ) by exact mul_nonneg hDr1.le ( pow_nonneg ( div_nonneg ( mul_nonneg ( by norm_num [ K_const ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ] );
refine le_trans hR₁_bound ?_;
rcases r <;> simp_all +decide [ Nat.mul_succ, pow_succ' ] ; ring_nf;
simp only [c₉, K_const]; norm_num [pow_mul]; ring_nf; norm_num;
-- We bound |R₂| using approx_error_bound' and constant_ineq_iii.
have hR₂_bound : |R₂| < 2 * r * δ * W ^ 2 * (K_const * M / r) ^ (r - 1) := by
have hR₂_bound : |R₂| < δ * ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) := by
have hR₂_bound : |R₂| ≤ ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) * |f (u_fn i : ℝ) - (v_fn i : ℝ) / (w_fn i : ℝ)| := by
convert Finset.abs_sum_le_sum_abs _ _ using 2 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; norm_num [ abs_mul, abs_sub_comm, mul_assoc, mul_comm, mul_left_comm, div_eq_mul_inv, ne_of_gt ( hw_pos _ ) ];
· field_simp;
exact Or.inl ( by rw [ show ( v_fn _ : ℝ ) / w_fn _ - f ( u_fn _ : ℝ ) = ( v_fn _ - w_fn _ * f ( u_fn _ : ℝ ) ) / w_fn _ by rw [ sub_div, mul_div_cancel_left₀ _ ( Nat.cast_ne_zero.mpr <| ne_of_gt <| hw_pos _ ) ] ] ; rw [ abs_div, abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ w_fn _ ) ] ; rw [ mul_div_cancel₀ _ ( Nat.cast_ne_zero.mpr <| ne_of_gt <| hw_pos _ ) ] );
· infer_instance;
rw [ Finset.mul_sum _ _ _ ];
refine' lt_of_le_of_lt hR₂_bound ( Finset.sum_lt_sum _ _ );
· exact fun i _ => by nlinarith only [ h_approx i, show 0 ≤ |( a_fn i : ℝ )| * ( w_fn i : ℝ ) by positivity ] ;
· obtain ⟨i, hi⟩ : ∃ i, a_fn i ≠ 0 := by
exact not_forall.mp fun h => h_moment_r <| by simp +decide [ h ] ;
exact ⟨ i, Finset.mem_univ _, by nlinarith only [ show 0 < |( a_fn i : ℝ )| * w_fn i by exact mul_pos ( abs_pos.mpr ( Int.cast_ne_zero.mpr hi ) ) ( Nat.cast_pos.mpr ( hw_pos i ) ), h_approx i ] ⟩;
refine lt_of_lt_of_le hR₂_bound ?_;
refine' le_trans ( mul_le_mul_of_nonneg_left ( Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left ( hw_le i ) ( abs_nonneg _ ) ) hδ.le ) _;
refine' le_trans ( mul_le_mul_of_nonneg_left ( Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_right ( h_coeff_bound i ) ( by positivity ) ) hδ.le ) _ ; norm_num ; ring_nf ; norm_num;
simp only [c₉, K_const]; norm_num [pow_mul]; ring_nf; norm_num;
-- We use constant_ineq_ii and constant_ineq_iii to bound |R₁| and |R₂|.
have hR₁_bound' : |R₁| ≤ D_r / 4 := by
refine le_trans hR₁_bound ?_;
apply_rules [ constant_ineq_ii ];
exact hM_le.trans ( mul_le_mul_of_nonneg_left ( min_le_left _ _ |> le_trans <| min_le_right _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact le_of_lt <| by exact B_pos )
have hR₂_bound' : |R₂| < D_r / 4 := by
refine lt_of_lt_of_le hR₂_bound ?_;
convert constant_ineq_iii r hr M hM W hW δ hδ D_r hDr ( show M ≤ ( r : ℝ ) / B_const * ( D_r / ( δ * W ^ 2 ) ) ^ ( ( 1 : ℝ ) / ( r - 1 ) ) from le_trans hM_le <| mul_le_mul_of_nonneg_left ( min_le_right _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact le_of_lt <| by exact B_pos ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
exact abs_lt.mpr ⟨ by linarith [ abs_le.mp hR₁_bound', abs_lt.mp hR₂_bound' ], by linarith [ abs_le.mp hR₁_bound', abs_lt.mp hR₂_bound' ] ⟩
-- Contradiction: I ≠ 0 but |I| < 1
have hI_ne_zero : I ≠ 0 := by
intro hI_zero
have : (I : ℝ) = 0 := by exact_mod_cast hI_zero
rw [hI_split] at this
have : I₁ = -(R₁ + R₂) := by linarith
have : |I₁| = |R₁ + R₂| := by rw [this, abs_neg]
linarith
have hI_bound : |(I : ℝ)| < 1 := by
rw [hI_split]
have : |I₁ + (R₁ + R₂)| ≤ |I₁| + |R₁ + R₂| := abs_add_le _ _
linarith [show |I₁ + R₁ + R₂| = |I₁ + (R₁ + R₂)| from by ring_nf]
exact hI_ne_zero (int_abs_lt_one_imp_zero I hI_bound)
/-
For each block [kM, (k+1)M), translating f and applying short_interval gives < 2r good points.
-/
private lemma per_block_bound
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(M N : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) N, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(hM_le : M ≤ (r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))))
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(hS_good : ∀ u ∈ S, IsGood f W δ u)
(k : ℕ) :
(S.filter (fun u : ℤ =>
(k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)).card < 2 * r := by
by_contra h_contra;
-- Let $a$ be the minimum element in the set $\{u \in S \mid kM \leq u < (k+1)M\}$.
obtain ⟨a, ha⟩ : ∃ a ∈ S, (k : ℝ) * M ≤ (a : ℝ) ∧ (a : ℝ) < ((k : ℝ) + 1) * M ∧ ∀ u ∈ S, (k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M → a ≤ u := by
obtain ⟨a, ha⟩ : ∃ a ∈ S, (k : ℝ) * M ≤ (a : ℝ) ∧ (a : ℝ) < ((k : ℝ) + 1) * M := by
exact Exists.elim ( Finset.card_pos.mp ( by linarith ) ) fun x hx => ⟨ x, Finset.mem_filter.mp hx |>.1, Finset.mem_filter.mp hx |>.2 ⟩;
exact ⟨ Finset.min' ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.1, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.2.1, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.2.2, fun u hu hu' => Finset.min'_le _ _ <| by aesop ⟩;
-- Define $T = \{u - a \mid u \in S, kM \leq u < (k+1)M\}$.
set T := Finset.image (fun u => u - a) (S.filter (fun u => (k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)) with hT;
-- Apply the short_interval lemma to the set $T$.
have hT_short : T.card < 2 * r := by
apply short_interval r hr hSILR (min M (N - a)) (by
have := Finset.exists_mem_ne ( by linarith ) a; obtain ⟨ u, hu, hu' ⟩ := this; simp_all +decide [ Finset.subset_iff ] ;
exact lt_of_lt_of_le ( show ( a : ℝ ) < u from mod_cast lt_of_le_of_ne ( ha.2.2.2 u hu.1 hu.2.1 hu.2.2 ) ( Ne.symm hu' ) ) ( mod_cast intIcc_le_M ( hS_sub hu.1 ) )) W hW δ hδ D_r hDr D_r1 hDr1 (fun x => f (a + x)) (by
exact hf_smooth.comp ((contDiff_const.add contDiff_id).of_le le_top)) (by
intro x hx
have h_deriv : iteratedDeriv r (fun x => f (a + x)) x = iteratedDeriv r f (a + x) := by
rw [ iteratedDeriv_comp_translate ];
convert hf_r_lower ( a + x ) ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 from mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; (first | rw [h_deriv] | exact congrArg abs h_deriv | simp only [iteratedDeriv_comp_translate] | rw [iteratedDeriv_comp_translate])) (by
intro x hx; rw [ iteratedDeriv_comp_translate ] ;
exact hf_r_upper _ ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 by exact_mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩) (by
intro x hx; rw [ iteratedDeriv_comp_translate ] ; norm_num;
exact hf_r1 _ ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 by exact_mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩) T (by
simp_all +decide [ Finset.subset_iff ];
rintro _ u hu hu₁ hu₂ rfl; specialize hS_sub hu; simp_all +decide [ intIcc ] ;
exact Int.le_of_lt_add_one ( by rw [ ← @Int.cast_lt ℝ ] ; push_cast; cases min_cases M ( N - a ) <;> linarith [ Int.floor_le ( min M ( N - a ) ), Int.lt_floor_add_one ( min M ( N - a ) ), show ( u : ℝ ) ≤ ⌊N⌋ from mod_cast hS_sub.2, Int.floor_le N, Int.lt_floor_add_one N ] )) (by
simp +zetaDelta at *;
rintro u x hx hx₁ hx₂ rfl; specialize hS_good x hx; obtain ⟨ v, w, hw₁, hw₂, hw₃ ⟩ := hS_good; use v, w; aesop;) (by
exact le_trans ( min_le_left _ _ ) hM_le);
rw [ Finset.card_image_of_injective _ ( sub_left_injective ) ] at hT_short ; linarith
/-
The `λ = 1` case
-/
private theorem lambda_one_case
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(N : ℝ) (hN : 0 < N)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) N, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(hS_good : ∀ u ∈ S, IsGood f W δ u) :
(S.card : ℝ) < C₀_const * N *
((D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / D_r) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) +
2 * (r : ℝ) := by
-- Let $M = (r/B_const) * \min(\min(T₁, T₂), T₃)$.
set M := (r : ℝ) / B_const * min (min ((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1))) ((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r)))) ((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))) with hM_def;
by_cases hM_pos : 0 < M;
· have h_card_bound : (S.card : ℝ) ≤ (N / M + 1) * (2 * r - 1) := by
convert block_subdivision_count N M hN hM_pos ( 2 * r ) ( by linarith ) S ( fun u hu => hS_sub hu ) _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· norm_cast;
· convert per_block_bound r hr hSILR M N hM_pos W hW δ hδ D_r hDr D_r1 hDr1 f hf_smooth _ _ _ _ S ( fun u hu => hS_sub hu ) hS_good using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· exact hf_r_lower;
· exact hf_r_upper;
· exact hf_r1;
convert block_count_to_C0_bound r hr N hN D_r D_r1 W δ hDr hDr1 hW hδ _ h_card_bound using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· contrapose! hM_pos;
refine' mul_pos ( div_pos ( Nat.cast_pos.mpr ( by linarith ) ) ( by exact mul_pos ( by norm_num ) ( by exact lt_max_of_lt_left ( by norm_num ) ) ) ) ( lt_min ( lt_min ( Real.rpow_pos_of_pos ( by positivity ) _ ) ( Real.rpow_pos_of_pos ( by positivity ) _ ) ) ( Real.rpow_pos_of_pos ( by positivity ) _ ) )
/-- The main rpow term is positive. -/
private lemma konyagin_main_term_pos
(r : ℕ) (N W δ lam D_r D_r1 : ℝ)
(hN : 0 < N) (hW : 1 ≤ W) (hδ : 0 < δ) (hlam : 1 ≤ lam)
(hDr : 0 < D_r) (hDr1 : 0 < D_r1) :
0 < c₆ * N *
((D_r * lam ^ (r : ℕ) * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * lam * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) := by
refine' mul_pos _ ( add_pos_of_pos_of_nonneg ( add_pos_of_pos_of_nonneg _ _ ) _ )
· exact mul_pos ( c₆_pos ) hN
· positivity
· positivity
· positivity
/-- `A + 4B + C ≤ 4(A + B + C)` for nonneg reals. -/
private lemma two_rpow_le_four (r : ℕ) (hr : 2 ≤ r) :
(2 : ℝ) ^ ((r : ℝ) / ((r : ℝ) - 1)) ≤ 4 := by
exact le_trans ( Real.rpow_le_rpow_of_exponent_le ( by norm_num ) ( show ( r : ℝ ) / ( r - 1 ) ≤ 2 by rw [ div_le_iff₀ ] <;> linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ] ) ) ( by norm_num )
/-
The term `(δW²/(ℓ^r D_r))^{1/(r-1)}` is at most
`4 · (δW²/(λ^r D_r))^{1/(r-1)}` when `ℓ > λ/2` and `r ≥ 2`.
-/
private lemma term2_comparison
(r : ℕ) (hr : 2 ≤ r)
(D_r W δ : ℝ) (hDr : 0 < D_r) (hW : 1 ≤ W) (hδ : 0 < δ)
(ell : ℕ) (lam : ℝ) (hell : 0 < ell)
(hell_le : (ell : ℝ) ≤ lam) (hlam_lt : lam < 2 * (ell : ℝ)) :
(δ * W ^ 2 / ((ell : ℝ) ^ (r : ℕ) * D_r)) ^ (((r : ℝ) - 1)⁻¹) ≤
4 * (δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) := by
-- Since ℓ > λ/2, we have ℓ^r > (λ/2)^r, so 1/(ℓ^r) < 1/((λ/2)^r) = 2^r/λ^r.
have h_bound : 1 / (ell : ℝ) ^ r < (2 : ℝ) ^ r / (lam : ℝ) ^ r := by
rw [ div_lt_div_iff₀ ] <;> try positivity;
· simpa only [ one_mul, ← mul_pow ] using pow_lt_pow_left₀ hlam_lt ( by linarith ) ( by linarith );
· exact pow_pos ( by linarith [ show ( ell : ℝ ) ≥ 1 by norm_cast ] ) _;
-- Therefore, δW²/(ℓ^r D_r) < 2^r δW²/(λ^r D_r).
have h_bound' : δ * W ^ 2 / ((ell : ℝ) ^ r * D_r) < 2 ^ r * δ * W ^ 2 / (lam ^ r * D_r) := by
convert mul_lt_mul_of_pos_left h_bound ( show 0 < δ * W ^ 2 / D_r by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> (first | ring | (field_simp; done) | (field_simp; ring));
refine' le_trans ( Real.rpow_le_rpow ( by positivity ) h_bound'.le ( inv_nonneg.mpr ( sub_nonneg.mpr ( Nat.one_le_cast.mpr ( by linarith ) ) ) ) ) _;
rw [ show ( 2 ^ r * δ * W ^ 2 / ( lam ^ r * D_r ) ) = ( δ * W ^ 2 / ( D_r * lam ^ r ) ) * ( 2 ^ r ) by ring, Real.mul_rpow ( by exact div_nonneg ( by positivity ) ( by exact mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) ( by positivity ) ];
rw [ mul_comm ] ; gcongr;
· exact Real.rpow_nonneg ( div_nonneg ( mul_nonneg hδ.le ( sq_nonneg _ ) ) ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) _;
· convert two_rpow_le_four r hr using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ ← Real.rpow_natCast, ← Real.rpow_mul ( by positivity ), mul_comm ] ; ring_nf
/-
The `C₀ · (terms with ℓ) ≤ c₆ · (terms with λ)` algebraic comparison.
-/
private lemma algebraic_comparison
(r : ℕ) (hr : 2 ≤ r)
(D_r D_r1 W δ : ℝ) (hDr : 0 < D_r) (hDr1 : 0 < D_r1)
(hW : 1 ≤ W) (hδ : 0 < δ)
(ell : ℕ) (lam : ℝ) (hell : 0 < ell)
(hell_le : (ell : ℝ) ≤ lam) (hlam_lt : lam < 2 * (ell : ℝ)) :
C₀_const *
(((ell : ℝ) ^ (r : ℕ) * D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / ((ell : ℝ) ^ (r : ℕ) * D_r)) ^ (((r : ℝ) - 1)⁻¹) +
((ell : ℝ) * D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) ≤
c₆ *
((D_r * lam ^ (r : ℕ) * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * lam * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) := by
-- Apply the term2_comparison lemma.
have h_term2 : (δ * W ^ 2 / (ell ^ r * D_r)) ^ (1 / (r - 1 : ℝ)) ≤ 4 * (δ * W ^ 2 / (D_r * lam ^ r)) ^ (1 / (r - 1 : ℝ)) := by
convert term2_comparison r hr D_r W δ hDr hW hδ ell lam hell hell_le hlam_lt using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> (try simp only [one_div])
-- Apply the term1_comparison lemma.
have h_term1 : (ell ^ r * D_r * W ^ 2) ^ (1 / (2 * r - 1 : ℝ)) ≤ (D_r * lam ^ r * W ^ 2) ^ (1 / (2 * r - 1 : ℝ)) := by
exact Real.rpow_le_rpow ( by positivity ) ( by nlinarith [ show ( ell : ℝ ) ^ r ≤ lam ^ r by gcongr, show ( 0 : ℝ ) < D_r * W ^ 2 by positivity ] ) ( by exact one_div_nonneg.mpr ( by linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ] ) );
-- Apply the term3_comparison lemma.
have h_term3 : (ell * D_r1 * W ^ 2 / D_r) ^ (1 / (2 * r : ℝ)) ≤ (D_r1 * lam * W ^ 2 / D_r) ^ (1 / (2 * r : ℝ)) := by
exact Real.rpow_le_rpow ( by positivity ) ( by rw [ div_le_div_iff_of_pos_right ( by positivity ) ] ; nlinarith [ show 0 < D_r1 * W ^ 2 by positivity ] ) ( by positivity );
rw [ show c₆ = 4 * C₀_const by rfl ];
norm_num at *;
nlinarith [ show 0 < C₀_const by exact C₀_pos, show 0 ≤ ( D_r * lam ^ r * W ^ 2 ) ^ ( 2 * r - 1 : ℝ ) ⁻¹ by exact Real.rpow_nonneg ( by exact mul_nonneg ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ( sq_nonneg _ ) ) _, show 0 ≤ ( δ * W ^ 2 / ( D_r * lam ^ r ) ) ^ ( r - 1 : ℝ ) ⁻¹ by exact Real.rpow_nonneg ( by exact div_nonneg ( mul_nonneg hδ.le ( sq_nonneg _ ) ) ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) _, show 0 ≤ ( D_r1 * lam * W ^ 2 / D_r ) ^ ( ( r : ℝ ) ⁻¹ * ( 1 / 2 ) ) by exact Real.rpow_nonneg ( by exact div_nonneg ( mul_nonneg ( mul_nonneg hDr1.le ( by linarith ) ) ( sq_nonneg _ ) ) hDr.le ) _ ]
/-
Sum over residue classes.
-/
theorem erdos_1094__h2__h2__h2__h3__h1__h1__h1 : ∀ (r : ℕ),
(2 : ℕ) ≤ r →
∀ (N : ℝ),
(0 : ℝ) < N →
∀ (W : ℝ),
(1 : ℝ) ≤ W →
∀ (δ : ℝ),
(0 : ℝ) < δ →
∀ (lam : ℝ),
(1 : ℝ) ≤ lam →
∀ (D_r : ℝ),
(0 : ℝ) < D_r →
∀ (D_r1 : ℝ),
(0 : ℝ) < D_r1 →
∀ (f : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f →
(∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) →
∀ (S : Finset ℤ),
(∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) →
(∀ u ∈ S,
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) →
let X :=
(D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹;
¬(1 : ℝ) ≤ (65536 : ℝ) * X →
∀ (N' : ℝ),
(0 : ℝ) < N' →
∀ (lam' : ℝ),
(1 : ℝ) ≤ lam' →
lam' < (2 : ℝ) →
∀ (D' : ℝ),
(0 : ℝ) < D' →
∀ (D1' : ℝ),
(0 : ℝ) < D1' →
∀ (g : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g →
(∀ x ∈ Set.Icc (0 : ℝ) N',
D' / (2 : ℝ) ≤ |iteratedDeriv r g x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv r g x| ≤ D') →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv (r + (1 : ℕ)) g x| ≤ D1') →
∀ (S' : Finset ℤ),
(∀ u ∈ S', (0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋) →
(∀ u ∈ S',
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧
(↑w : ℝ) ≤ W ∧
|g (↑u : ℝ) -
(↑v : ℝ) / (↑w : ℝ)| <
δ) →
(65536 : ℝ) *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) <
(1 : ℝ) →
(↑S'.card : ℝ) <
(65536 : ℝ) * N' *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) +
(2 : ℝ) * (↑r : ℝ) * lam' := by
have hsilr : ∀ (r : ℕ), 1 ≤ r → ∀ (s : ℕ), s = 2 * r → ∀ (M : ℝ), (s : ℝ) - 1 ≤ M →
∀ (W : ℝ), 1 ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ),
(∀ i, 0 ≤ u i ∧ (u i : ℝ) ≤ M) → StrictMono u → (∀ i, 0 < w i) → (∀ i, (w i : ℝ) ≤ W) →
∃ a : Fin s → ℤ,
(∀ (j : ℕ), j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ j = 0) ∧
(∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ r ≠ 0) ∧
(∀ i, |(a i : ℝ)| ≤ (256 * M / (r : ℝ)) ^ (r - 1 : ℕ) * W) := by
sorry
intro r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1 f hf h1 h2 h3 S hS hS2 X hX N' hN' lam' hl1 hl2 D' hD' D1' hD1' g hg g1 g2 g3 S' hS' hS'2 hlt
have hS'sub : ↑S' ⊆ ↑(intIcc N') := by
intro u hu
obtain ⟨a, b⟩ := hS' u hu
unfold intIcc
exact Finset.mem_Icc.mpr ⟨a, b⟩
have key := lambda_one_case r hr hsilr N' hN' W hW δ hδ D' hD' D1' hD1' g hg g1 g2 g3 S' hS'sub
(fun u hu => hS'2 u hu)
have hcmp := algebraic_comparison r hr D' D1' W δ hD' hD1' hW hδ 1 lam' one_pos
(by simpa using hl1) (by norm_num; linarith)
simp only [Nat.cast_one, one_pow, one_mul] at hcmp
have hc6 : c₆ = 65536 := by
unfold c₆ C₀_const B_const K_const c₉; norm_num
rw [hc6] at hcmp
have hr0 : (0 : ℝ) ≤ 2 * (r : ℝ) := by positivity
have h2r : 2 * (r : ℝ) ≤ 2 * (r : ℝ) * lam' := by nlinarith
nlinarith [mul_le_mul_of_nonneg_left hcmp hN'.le]The gate replayed this file at its merge, each hole a sorry (D-12 #5); the whole file: targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1--h1/attempts/20261015T130229Z-t1015b-s-partial.lean
What is known
Work on it
No explainer yet. This proof written as a journal would print it, labelled unverified, is the next thing a writer could add, by pull request (D-3, D-36; the guide shows how).
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--h2--h3--h1--h1--h1».Context
open scoped Nat
/-! Hole `core` 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__h2__h3__h1__h1__h1 : ∀ (r : ℕ),
(2 : ℕ) ≤ r →
∀ (N : ℝ),
(0 : ℝ) < N →
∀ (W : ℝ),
(1 : ℝ) ≤ W →
∀ (δ : ℝ),
(0 : ℝ) < δ →
∀ (lam : ℝ),
(1 : ℝ) ≤ lam →
∀ (D_r : ℝ),
(0 : ℝ) < D_r →
∀ (D_r1 : ℝ),
(0 : ℝ) < D_r1 →
∀ (f : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f →
(∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) →
∀ (S : Finset ℤ),
(∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) →
(∀ u ∈ S,
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) →
let X :=
(D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹;
¬(1 : ℝ) ≤ (65536 : ℝ) * X →
∀ (N' : ℝ),
(0 : ℝ) < N' →
∀ (lam' : ℝ),
(1 : ℝ) ≤ lam' →
lam' < (2 : ℝ) →
∀ (D' : ℝ),
(0 : ℝ) < D' →
∀ (D1' : ℝ),
(0 : ℝ) < D1' →
∀ (g : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g →
(∀ x ∈ Set.Icc (0 : ℝ) N',
D' / (2 : ℝ) ≤ |iteratedDeriv r g x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv r g x| ≤ D') →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv (r + (1 : ℕ)) g x| ≤ D1') →
∀ (S' : Finset ℤ),
(∀ u ∈ S', (0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋) →
(∀ u ∈ S',
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧
(↑w : ℝ) ≤ W ∧
|g (↑u : ℝ) -
(↑v : ℝ) / (↑w : ℝ)| <
δ) →
(65536 : ℝ) *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) <
(1 : ℝ) →
(↑S'.card : ℝ) <
(65536 : ℝ) * N' *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) +
(2 : ℝ) * (↑r : ℝ) * lam' := by
sorryA 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 f29-words, drafted with Claude Fable 5.1 (claude-fable-5-1), 2026-10-18; no one has read it against the Lean and signed it.
Draft · drafted, by the model named above
$\displaystyle 65536\,X'<1\ \Longrightarrow\ |S'|<65536\,N'X'+2r\lambda',\qquad X'=(D'\lambda'^{\,r}W^2)^{\frac{1}{2r-1}}+\Bigl(\frac{\delta W^2}{D'\lambda'^{\,r}}\Bigr)^{\frac{1}{r-1}}+\Bigl(\frac{D_1'\lambda' W^2}{D'}\Bigr)^{\frac{1}{2r}}$
Fix $r\ge 2$, $W\ge 1$, $\delta>0$ and the data of the enclosing statement ($N>0$, $\lambda\ge 1$, $D_r,D_{r+1}>0$, $f:\mathbb{R}\to\mathbb{R}$ of class $C^{r+1}$ with $D_r/2\le|f^{(r)}(x)|\le D_r$ and $|f^{(r+1)}(x)|\le D_{r+1}$ for all $x\in[0,N]$, every finite set $S$ of integers in $[0,\lfloor N\rfloor]$ each of whose points $u$ has $|f(u)-v/w|<\delta$ for some integer $v$ and natural $w$ with $0<w\le W$), and assume moreover $\neg(1\le 65536\,X)$ for $X$ the same three-term expression in $D_r,\lambda,D_{r+1}$. Then for every $N'>0$, every $\lambda'$ with $1\le\lambda'<2$, every $D'>0$ and $D_1'>0$, every $g:\mathbb{R}\to\mathbb{R}$ of class $C^{r+1}$ with $D'/2\le|g^{(r)}|\le D'$ and $|g^{(r+1)}|\le D_1'$ on $[0,N']$, and every finite set $S'$ of integers in $[0,\lfloor N'\rfloor]$ each of whose points $u$ has $|g(u)-v/w|<\delta$ for some integer $v$ and natural $0<w\le W$, the displayed bound holds. The hypotheses on $N$, $\lambda$, $D_r$, $D_{r+1}$, $f$ and $S$ are carried from the enclosing statement and play no part in the conclusion; the Lean names $\lambda'$ lam' and $D_1'$ D1', $W^2$ is a natural power and the fractional exponents are real powers.
Rendered from gloss/5d52bcdff0a3….md · Improve these words →
Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1--h1/Statement.lean. Origin: compiler-derived.
Depends on (1), each in words
Depends on, each in words where someone has written them:
- erdos-1094--h2--h2--h2--h3--h1--h1--h1--h1: $\exists a:\{0,\dots,2r-1\}\to\mathbb{Z}:\quad \sum_{i}a_i w_i u_i^{\,j}=0\ (j<r),\qquad \sum_{i}a_i w_i u_i^{\,r}\ne 0,\qquad |a_i|\le\Bigl(\frac{256\,M}{r}\Bigr)^{r-1}W$ · used by the proof
Attestation: pass, 7 of 7 checks
Checked by the kernel — the gate’s record of the run: attestations/000560.json, merge commit 49bbfabd0d60.
Verdict pass, from attestations/000560.json.
- Submitter
t1015c-a04- Toolchain
- leanprover/lean4:v4.33.1 (hash
f54d0bc916bf76a7fae460ce9d078ccd1f74aeb4fd12c4b6546bca28b6aa1c63) - Mathlib
- 0df444a360eaa60ab8c11dca51a86af692955474
- Reviewer
- none needed (intermediate)
| Step | Check | Result |
|---|---|---|
| 1 | toolchain | pass |
| 2 | paths | pass |
| 4 | kernel-replay | pass |
| 5 | axioms | pass |
| 6 | hazards | pass |
| 7 | witness | pass |
| 8 | deps | pass |
Witness
Checked by the kernel — step 7 passed in the run its attestation records: attestations/000560.json, merge commit 49bbfabd0d60.
b0f2827aa046.import Mathlib
open scoped Nat
theorem witness : ∃ (r : ℕ) (N : ℝ) (W : ℝ) (δ : ℝ) (lam : ℝ) (D_r : ℝ) (D_r1 : ℝ) (f : ℝ → ℝ) (S : Finset ℤ),
(2 : ℕ) ≤ r ∧
(0 : ℝ) < N ∧
(1 : ℝ) ≤ W ∧
(0 : ℝ) < δ ∧
(1 : ℝ) ≤ lam ∧
(0 : ℝ) < D_r ∧
(0 : ℝ) < D_r1 ∧
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f ∧
(∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) ∧
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) ∧
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) ∧
(∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) ∧
∀ u ∈ S,
∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ := by
-- r = 2, f x = x ^ 2 (second derivative 2, third 0), every scale 1 except D_r = 2, S empty
have h1 : deriv (fun x : ℝ => x ^ 2) = fun x => 2 * x := by
funext x
simp
have h2 : iteratedDeriv 2 (fun x : ℝ => x ^ 2) = fun _ => 2 := by
rw [iteratedDeriv_succ, iteratedDeriv_one, h1]
funext x
simp
have h3 : iteratedDeriv 3 (fun x : ℝ => x ^ 2) = fun _ => 0 := by
rw [iteratedDeriv_succ, h2]
funext x
simp
refine ⟨2, 1, 1, 1, 1, 2, 1, fun x => x ^ 2, ∅, le_refl _, one_pos, le_refl _, one_pos,
le_refl _, two_pos, one_pos, ?_, ?_, ?_, ?_, ?_, ?_⟩
· fun_prop
· intro x _
rw [h2]
norm_num
· intro x _
rw [h2]
norm_num
· intro x _
rw [show (2 : ℕ) + 1 = 3 from rfl, h3]
norm_num
· simp
· simpNo 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 →
Attempts (2)
2 recorded. Routes refuted: none. Failure classes: route-dead-ends 1.
Untrusted contributor text — a partial assembly: it records an attempt, not a proof; its attestation names the file, and no hash in the record binds these bytes.
Untrusted: partial assembly (D-12 #5), by t1015b-s; merged in 47220d7f6556 under attestations/000540.json, whose step 2 took this file as a partial. A partial records an attempt, not a proof: the gate replayed it with its holes left as sorry. Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1--h1/attempts/20261015T130229Z-t1015b-s-partial.lean.
Untrusted contributor text — an outline the gate extracted from this partial assembly; its holes are sorry steps, and it records an attempt, not a proof.
Outline of 20261015T130229Z-t1015b-s-partial.lean, extracted by the gate at fa0a13ba270d 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.
hsilrhole∀ (r : ℕ), (1 : ℕ) ≤ r → ∀ (s : ℕ), s = (2 : ℕ) * r → ∀ (M : ℝ), (↑s : ℝ) - (1 : ℝ) ≤ M → ∀ (W : ℝ), (1 : ℝ) ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ), (∀ (i : Fin s), (0 : ℤ) ≤ u i ∧ (↑(u i) : ℝ) ≤ M) → StrictMono u → (∀ (i : Fin s), (0 : ℕ) < w i) → (∀ (i : Fin s), (↑(w i) : ℝ) ≤ W) → ∃ (a : Fin s → ℤ), (∀ j < r, ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ j = (0 : ℝ)) ∧ ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ r ≠ (0 : ℝ) ∧ ∀ (i : Fin s), |(↑(a i) : ℝ)| ≤ ((256 : ℝ) * M / (↑r : ℝ)) ^ (r - (1 : ℕ)) * WholeLeaves
∀ (r : ℕ), (2 : ℕ) ≤ r → ∀ (N : ℝ), (0 : ℝ) < N → ∀ (W : ℝ), (1 : ℝ) ≤ W → ∀ (δ : ℝ), (0 : ℝ) < δ → ∀ (lam : ℝ), (1 : ℝ) ≤ lam → ∀ (D_r : ℝ), (0 : ℝ) < D_r → ∀ (D_r1 : ℝ), (0 : ℝ) < D_r1 → ∀ (f : ℝ → ℝ), ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f → (∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) → (∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) → (∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) → ∀ (S : Finset ℤ), (∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) → (∀ u ∈ S, ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) → let X := (D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹; ¬(1 : ℝ) ≤ (65536 : ℝ) * X → ∀ (N' : ℝ), (0 : ℝ) < N' → ∀ (lam' : ℝ), (1 : ℝ) ≤ lam' → lam' < (2 : ℝ) → (truncated), withhsilr : ∀ (r : ℕ), (1 : ℕ) ≤ r → ∀ (s : ℕ), s = (2 : ℕ) * r → ∀ (M : ℝ), (↑s : ℝ) - (1 : ℝ) ≤ M → ∀ (W : ℝ), (1 : ℝ) ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ), (∀ (i : Fin s), (0 : ℤ) ≤ u i ∧ (↑(u i) : ℝ) ≤ M) → StrictMono u → (∀ (i : Fin s), (0 : ℕ) < w i) → (∀ (i : Fin s), (↑(w i) : ℝ) ≤ W) → ∃ (a : Fin s → ℤ), (∀ j < r, ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ j = (0 : ℝ)) ∧ ∑ i : Fin s, (↑(a i) : ℝ) * (↑(w i) : ℝ) * (↑(u i) : ℝ) ^ r ≠ (0 : ℝ) ∧ ∀ (i : Fin s), |(↑(a i) : ℝ)| ≤ ((256 : ℝ) * M / (↑r : ℝ)) ^ (r - (1 : ℕ)) * W.Uses library
FinNatural numbers less than some upper bound. ,StrictMonoA functionfis strictly monotone ifa < bimpliesf a < f b. .Left open as a hole; its statement is erdos-1094--h2--h2--h2--h3--h1--h1--h1--h1 (proved).
Lean, lines 884–891
have hsilr : ∀ (r : ℕ), 1 ≤ r → ∀ (s : ℕ), s = 2 * r → ∀ (M : ℝ), (s : ℝ) - 1 ≤ M → ∀ (W : ℝ), 1 ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ), (∀ i, 0 ≤ u i ∧ (u i : ℝ) ≤ M) → StrictMono u → (∀ i, 0 < w i) → (∀ i, (w i : ℝ) ≤ W) → ∃ a : Fin s → ℤ, (∀ (j : ℕ), j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ j = 0) ∧ (∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ r ≠ 0) ∧ (∀ i, |(a i : ℝ)| ≤ (256 * M / (r : ℝ)) ^ (r - 1 : ℕ) * W) := by sorryhS'subhaveS' ⊆ intIcc N'Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhS'sub : S' ⊆ intIcc N'.Uses library
Finset.mem_Icc,And.introAnd.intro : a → b → a ∧ bis the constructor for the And operation. .Lean, lines 893–897
have hS'sub : ↑S' ⊆ ↑(intIcc N') := by intro u hu obtain ⟨a, b⟩ := hS' u hu unfold intIcc exact Finset.mem_Icc.mpr ⟨a, b⟩hS'sub.s1obtain(0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋Leaves
u ∈ intIcc N', witha : (0 : ℤ) ≤ u,b : u ≤ ⌊N'⌋.Lean, line 895
obtain ⟨a, b⟩ := hS' u hu
keyhave(↑S'.card : ℝ) < C₀_const * N' * ((D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / D') ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ)Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withkey : (↑S'.card : ℝ) < C₀_const * N' * ((D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / D') ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ).Lean, lines 898–899
have key := lambda_one_case r hr hsilr N' hN' W hW δ hδ D' hD' D1' hD1' g hg g1 g2 g3 S' hS'sub (fun u hu => hS'2 u hu)hcmphaveC₀_const * (((↑(1 : ℕ) : ℝ) ^ r * D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / ((↑(1 : ℕ) : ℝ) ^ r * D')) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + ((↑(1 : ℕ) : ℝ) * D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) ≤ c₆ * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹)Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhcmp : C₀_const * (((↑(1 : ℕ) : ℝ) ^ r * D' * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / ((↑(1 : ℕ) : ℝ) ^ r * D')) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + ((↑(1 : ℕ) : ℝ) * D1' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) ≤ c₆ * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹).Uses library
one_posAlias ofzero_lt_one. .Lean, lines 900–901
have hcmp := algebraic_comparison r hr D' D1' W δ hD' hD1' hW hδ 1 lam' one_pos (by simpa using hl1) (by norm_num; linarith)hc6havec₆ = (65536 : ℝ)Leaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhc6 : c₆ = (65536 : ℝ).Lean, lines 903–904
have hc6 : c₆ = 65536 := by unfold c₆ C₀_const B_const K_const c₉; norm_numhr0have(0 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ)routine: positivityLeaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withhr0 : (0 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ).Lean, line 906
have hr0 : (0 : ℝ) ≤ 2 * (r : ℝ) := by positivity
h2rhave(2 : ℝ) * (↑r : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'routine: nlinarithLeaves
(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam', withh2r : (2 : ℝ) * (↑r : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'.Lean, line 907
have h2r : 2 * (r : ℝ) ≤ 2 * (r : ℝ) * lam' := by nlinarith
closeterm(↑S'.card : ℝ) < (65536 : ℝ) * N' * ((D' * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D' * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D1' * lam' * W ^ (2 : ℕ) / D') ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam'Closes the goal.
Uses library
mul_le_mul_of_nonneg_left.Lean, line 908
nlinarith [mul_le_mul_of_nonneg_left hcmp hN'.le]
import Mathlib
import Nodes.«erdos-1094--h2--h2--h2--h3--h1--h1--h1».Context
open scoped Nat
/-! Hole `core` 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 intIcc (M : ℝ) : Finset ℤ := Finset.Icc 0 ⌊M⌋
private noncomputable def IsGood (f : ℝ → ℝ) (W δ : ℝ) (u : ℤ) : Prop :=
∃ (v : ℤ) (w : ℕ), 0 < w ∧ (w : ℝ) ≤ W ∧ |f (u : ℝ) - (v : ℝ) / (w : ℝ)| < δ
private noncomputable def c₉ : ℝ := 256
private noncomputable def K_const : ℝ := max 4 c₉
private noncomputable def B_const : ℝ := 16 * K_const
private noncomputable def C₀_const : ℝ := 4 * B_const
private noncomputable def c₆ : ℝ := 4 * C₀_const
/-
Properties of constants
-/
private lemma four_le_K : (4 : ℝ) ≤ K_const := le_max_left _ _
private lemma K_pos : (0 : ℝ) < K_const := lt_of_lt_of_le (by norm_num : (0:ℝ) < 4) four_le_K
private lemma B_pos : (0 : ℝ) < B_const := by unfold B_const; linarith [K_pos]
private lemma C₀_pos : (0 : ℝ) < C₀_const := by unfold C₀_const; linarith [B_pos]
private lemma c₆_pos : (0 : ℝ) < c₆ := by unfold c₆; linarith [C₀_pos]
private lemma mem_intIcc_iff (M : ℝ) (u : ℤ) :
u ∈ intIcc M ↔ 0 ≤ u ∧ u ≤ ⌊M⌋ := by
simp [intIcc, Finset.mem_Icc]
private lemma intIcc_nonneg {M : ℝ} {u : ℤ} (hu : u ∈ intIcc M) : 0 ≤ u :=
((mem_intIcc_iff M u).mp hu).1
private lemma intIcc_le_M {M : ℝ} {u : ℤ} (hu : u ∈ intIcc M) : (u : ℝ) ≤ M := by
have h := ((mem_intIcc_iff M u).mp hu).2
exact le_trans (Int.cast_le.mpr h) (Int.floor_le M)
private lemma short_cardinality (s : ℕ) (M : ℝ) (hMs : M < (s : ℝ) - 1) :
(intIcc M).card ≤ s - 1 := by
-- Since $M < s - 1$, we have $\lfloor M \rfloor \leq s - 2$.
have h_floor_le : ⌊M⌋ ≤ s - 2 := by
exact Int.le_of_lt_add_one <| Int.floor_lt.2 <| by norm_num; linarith;
unfold intIcc; cases s <;> norm_num at * ; omega;
linarith
/-
Given `2r` points with positive integer weights bounded by `W`, there exist integer
coefficients that annihilate the first `r` moments, have nonzero `r`-th moment,
and are bounded by `(c₉ M / r)^{r-1} · W`.
-/
private noncomputable def SILRProp : Prop := ∀ (r : ℕ), 1 ≤ r → ∀ (s : ℕ), s = 2 * r → ∀ (M : ℝ), (s : ℝ) - 1 ≤ M →
∀ (W : ℝ), 1 ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ),
(∀ i, 0 ≤ u i ∧ (u i : ℝ) ≤ M) → StrictMono u → (∀ i, 0 < w i) → (∀ i, (w i : ℝ) ≤ W) →
∃ a : Fin s → ℤ,
(∀ (j : ℕ), j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ j = 0) ∧
(∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ r ≠ 0) ∧
(∀ i, |(a i : ℝ)| ≤ (c₉ * M / (r : ℝ)) ^ (r - 1 : ℕ) * W)
/-- Translation rule: `(d/dx)^n f(a + x) = f^{(n)}(a + x)`. -/
private lemma iteratedDeriv_comp_translate (f : ℝ → ℝ) (a : ℝ) (n : ℕ) :
iteratedDeriv n (fun x => f (a + x)) = fun x => iteratedDeriv n f (a + x) :=
iteratedDeriv_comp_const_add n f a
/-- Affine chain rule: `(d/dx)^n f(a + bx) = b^n · f^{(n)}(a + bx)`.
Requires `f` to be `C^n`. -/
private lemma iteratedDeriv_comp_affine (f : ℝ → ℝ) (a b : ℝ) (n : ℕ) (x : ℝ)
(hf : ContDiff ℝ n f) :
iteratedDeriv n (fun x => f (a + b * x)) x =
b ^ n * iteratedDeriv n f (a + b * x) := by
have hg : ContDiff ℝ n (fun y => f (a + y)) :=
hf.comp (contDiff_const.add contDiff_id)
have h1 := congr_fun (iteratedDeriv_comp_const_mul hg b) x
have h2 := congr_fun (iteratedDeriv_comp_const_add n f a) (b * x)
rw [show (fun x => f (a + b * x)) = (fun x => (fun y => f (a + y)) (b * x)) from rfl]
rw [h1, h2]
/-- Smoothness is preserved under affine composition. -/
private lemma isGood_comp_affine {f : ℝ → ℝ} {W δ : ℝ} {u : ℤ} {a : ℤ} {b : ℕ}
(hgood : IsGood f W δ (a + b * u)) :
IsGood (fun x => f (↑a + ↑b * x)) W δ u := by
obtain ⟨v, w, hw_pos, hw_le, happrox⟩ := hgood
refine ⟨v, w, hw_pos, hw_le, ?_⟩
convert happrox using 2 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)))
push_cast
ring
/-
For positive reals, 1/min(min(a,b),c) ≤ 1/a + 1/b + 1/c
-/
private lemma one_div_min_le_sum_inv {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) :
1 / min (min a b) c ≤ 1 / a + 1 / b + 1 / c := by
field_simp;
rw [ min_def, min_def ] ; split_ifs <;> nlinarith [ mul_pos ha hb, mul_pos ha hc, mul_pos hb hc ] ;
/-
(2r-1)/r ≤ 2 for r ≥ 1
-/
private lemma finset_card_eq_sum_residue_classes (S : Finset ℤ) (ell : ℕ) (hell : 0 < ell) :
S.card = ∑ j ∈ Finset.range ell,
(S.filter (fun u => u % (ell : ℤ) = ↑j)).card := by
rw [ ← Finset.card_biUnion ];
· congr with u ; simp +decide;
exact ⟨ fun hu => ⟨ Int.toNat ( u % ell ), by linarith [ Int.emod_lt_of_pos u ( by positivity : 0 < ( ell : ℤ ) ), Int.toNat_of_nonneg ( Int.emod_nonneg u ( by positivity : ( ell : ℤ ) ≠ 0 ) ) ], hu, by rw [ Int.toNat_of_nonneg ( Int.emod_nonneg u ( by positivity : ( ell : ℤ ) ≠ 0 ) ) ] ⟩, by aesop ⟩;
· exact fun i hi j hj hij => Finset.disjoint_left.mpr fun x hx₁ hx₂ => hij <| by aesop;
private lemma iteratedDeriv_comp_affine_lower_bound
(f : ℝ → ℝ) (a : ℝ) (b : ℝ) (hb : 0 < b)
(r : ℕ) (D_r : ℝ)
(N' : ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_lower : ∀ x ∈ Set.Icc 0 (a + b * N'), D_r / 2 ≤ |iteratedDeriv r f x|)
(x : ℝ) (hx : x ∈ Set.Icc 0 N')
(ha_range : 0 ≤ a) :
b ^ r * D_r / 2 ≤ |iteratedDeriv r (fun x => f (a + b * x)) x| := by
rw [ iteratedDeriv_comp_affine ];
· rw [ abs_mul, abs_of_nonneg ( by positivity ) ] ; nlinarith [ hf_lower ( a + b * x ) ⟨ by nlinarith [ hx.1 ], by nlinarith [ hx.2 ] ⟩, pow_pos hb r ] ;
· exact hf_smooth.of_le (by exact_mod_cast Nat.le_succ r)
/-
Upper bound on r-th derivative of f(a + b·x)
-/
private lemma good_point_transfer
(f : ℝ → ℝ) (W δ : ℝ) (u : ℤ) (ell : ℕ)
(j : ℕ) (hmod : u % (ell : ℤ) = ↑j)
(hgood : IsGood f W δ u) :
IsGood (fun x => f (↑j + ↑ell * x)) W δ (u / ↑ell) := by
obtain ⟨v, w, hw_pos, hw_le, happrox⟩ := hgood
refine ⟨v, w, hw_pos, hw_le, ?_⟩
have h : (j : ℤ) + (ell : ℤ) * (u / ell) = u := by rw [← hmod]; exact Int.emod_add_mul_ediv u ell
have h' : (j : ℝ) + (ell : ℝ) * ((u / ell : ℤ) : ℝ) = (u : ℝ) := by exact_mod_cast h
show |f ((j : ℝ) + (ell : ℝ) * ((u / ell : ℤ) : ℝ)) - _| < δ
rw [h']; exact happrox
/-
If every sub-interval of length M contains fewer than B elements of S,
then |S| ≤ (N/M + 1) * (B-1).
-/
private lemma block_subdivision_count
(N M : ℝ) (hN : 0 < N) (hM : 0 < M)
(B : ℕ) (hB : 1 ≤ B)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(h_per_block : ∀ (k : ℕ), (S.filter (fun u : ℤ =>
(k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)).card < B) :
(S.card : ℝ) ≤ (N / M + 1) * ((B : ℝ) - 1) := by
-- By partitioning S into blocks of length M, we can bound the cardinality of S by the sum of the cardinalities of these blocks.
have h_partition : S.card ≤ ∑ k ∈ Finset.range (Nat.floor (N / M) + 1), (S.filter (fun u : ℤ => k * M ≤ (u : ℝ) ∧ (u : ℝ) < (k + 1) * M)).card := by
refine le_trans ?_ ( Finset.card_biUnion_le );
refine Finset.card_le_card ?_;
intro u hu; specialize hS_sub hu; simp_all +decide [ intIcc ] ;
refine' ⟨ ⌊ ( u : ℝ ) / M⌋₊, _, _, _ ⟩;
· gcongr;
exact Int.le_floor.mp hS_sub.2;
· nlinarith [ Nat.floor_le ( show 0 ≤ ( u : ℝ ) / M by exact div_nonneg ( mod_cast hS_sub.1 ) hM.le ), mul_div_cancel₀ ( u : ℝ ) hM.ne' ];
· nlinarith [ Nat.lt_floor_add_one ( ( u : ℝ ) / M ), mul_div_cancel₀ ( u : ℝ ) hM.ne' ];
refine' le_trans ( Nat.cast_le.mpr h_partition ) _;
refine' le_trans ( Nat.cast_le.mpr <| Finset.sum_le_sum fun _ _ => Nat.le_sub_one_of_lt <| h_per_block _ ) _ ; norm_num;
gcongr <;> cases B <;> norm_num at * ; linarith [ Nat.floor_le ( by positivity : 0 ≤ N / M ) ]
/-
For j < ℓ and x ∈ [0, (N-j)/ℓ], j + ℓx ∈ [0, N]
-/
private lemma sum_N_sub_j_div_ell_le (N : ℝ) (ell : ℕ) (hell : 0 < ell) :
∑ j ∈ Finset.range ell, ((N - ↑j) / ↑ell) ≤ N := by
rw [ ← Finset.sum_div _ _ _, div_le_iff₀ ] <;> norm_num [ hell ];
exact le_add_of_le_of_nonneg ( by linarith ) ( Finset.sum_nonneg fun _ _ => Nat.cast_nonneg _ )
/-
(N - j)/ℓ > 0 when j < ℓ ≤ N
-/
private lemma ediv_in_intIcc {u : ℤ} {N : ℝ} {ell : ℕ} {j : ℕ}
(hell : 0 < ell) (hu_mem : u ∈ intIcc N)
(hmod : u % (ell : ℤ) = ↑j) :
u / (ell : ℤ) ∈ intIcc ((N - ↑j) / ↑ell) := by
unfold intIcc at *;
norm_num at *;
rw [ Int.le_floor ] at *;
rw [ le_div_iff₀ ( by positivity ) ];
exact ⟨ Int.ediv_nonneg hu_mem.1 ( by positivity ), by linarith [ show ( u : ℝ ) = ( u / ell : ℤ ) * ell + j by exact mod_cast by linarith [ Int.emod_add_mul_ediv u ell ] ] ⟩
/-
The algebraic part of lambda_one_case: given |S| ≤ (N/M + 1)(2r-1),
derive the final C₀ bound.
-/
private lemma block_count_to_C0_bound
(r : ℕ) (hr : 2 ≤ r)
(N : ℝ) (hN : 0 < N)
(D_r D_r1 W δ : ℝ) (hDr : 0 < D_r) (hDr1 : 0 < D_r1)
(hW : 1 ≤ W) (hδ : 0 < δ)
(card_bound : ℝ)
(h_card : card_bound ≤ (N / ((r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1)))) + 1) *
(2 * (r : ℝ) - 1)) :
card_bound < C₀_const * N *
((D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / D_r) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) +
2 * (r : ℝ) := by
-- Let's simplify the expression.
suffices h_simp : (N / ((r : ℝ) / B_const * min (min ((D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ)) ((D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ))) ((D_r / (δ * W ^ 2)) ^ (1 / (r - 1) : ℝ)))) * (2 * r - 1) ≤ C₀_const * N * ((D_r * W ^ 2) ^ (2 * r - 1 : ℝ)⁻¹ + (δ * W ^ 2 / D_r) ^ (r - 1 : ℝ)⁻¹ + (D_r1 * W ^ 2 / D_r) ^ (2 * r : ℝ)⁻¹) by
linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ];
-- By simplifying, we can see that the left-hand side is less than or equal to the right-hand side.
have h_simp : (1 / (min (min ((D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ)) ((D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ))) ((D_r / (δ * W ^ 2)) ^ (1 / (r - 1) : ℝ)))) ≤ ((D_r * W ^ 2) ^ (2 * r - 1 : ℝ)⁻¹ + (δ * W ^ 2 / D_r) ^ (r - 1 : ℝ)⁻¹ + (D_r1 * W ^ 2 / D_r) ^ (2 * r : ℝ)⁻¹) := by
convert one_div_min_le_sum_inv _ _ _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· norm_num [ neg_div, Real.rpow_neg_eq_inv_rpow ];
rw [ ← Real.inv_rpow ( by positivity ), ← Real.inv_rpow ( by positivity ), ← Real.inv_rpow ( by positivity ) ] ; ring_nf;
norm_num ; ring_nf;
· positivity;
· positivity;
· positivity;
refine le_trans ?_ ( mul_le_mul_of_nonneg_left h_simp <| by exact mul_nonneg ( by exact le_of_lt <| by exact show 0 < C₀_const by exact C₀_pos ) <| by positivity );
field_simp [mul_comm, mul_assoc, mul_left_comm] at *;
unfold B_const C₀_const; ring_nf; norm_num;
unfold B_const; nlinarith [ show ( r : ℝ ) ≥ 2 by norm_cast, show ( K_const : ℝ ) ≥ 4 by exact_mod_cast four_le_K ] ;
private lemma int_abs_lt_one_imp_zero (L : ℤ) (h : |(L : ℝ)| < 1) : L = 0 := by
norm_cast at h; aesop;
/-
If intIcc M has at least n elements (n ≥ 1), then M ≥ n - 1.
-/
private lemma eight_r_le_sixteen_pow (r : ℕ) (hr : 2 ≤ r) : (8 : ℝ) * r ≤ 16 ^ (r - 1) := by
rcases r with ( _ | _ | r ) <;> norm_num at *;
exact mod_cast Nat.recOn r ( by norm_num ) fun n ihn => by norm_num [ Nat.pow_succ' ] at * ; linarith;
/-
Constant inequality (i): Under M bound from T₁,
2r D_r W² (K_const M/r)^{2r-1} ≤ 1/2.
-/
private lemma constant_ineq_i
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(D_r : ℝ) (hDr : 0 < D_r)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1))) :
2 * (r : ℝ) * D_r * W ^ 2 * (K_const * M / (r : ℝ)) ^ (2 * r - 1) ≤ 1 / 2 := by
-- From hM_le: KM/r ≤ 1/16 · (D_r W²)^{-1/(2r-1)} (since K = B/16)
have hKM_div_r_le : (K_const * M / r) ^ (2 * r - 1) ≤ (1 / 16) ^ (2 * r - 1) * (D_r * W ^ 2) ^ (-1 : ℝ) := by
have hKM_div_r_pow : (K_const * M / r) ≤ (1 / 16) * (D_r * W ^ 2) ^ (-1 / (2 * r - 1) : ℝ) := by
rw [ div_le_iff₀ ( by positivity ) ];
convert mul_le_mul_of_nonneg_left hM_le ( show 0 ≤ K_const by exact le_trans ( by norm_num ) ( le_max_left _ _ ) ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring_nf;
unfold K_const B_const; ring_nf;
unfold K_const; norm_num [ c₉ ] ;
ring;
convert pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_of_lt K_pos ) hM.le ) ( Nat.cast_nonneg _ ) ) hKM_div_r_pow _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ mul_pow, ← Real.rpow_natCast _ ( 2 * r - 1 ), ← Real.rpow_natCast _ ( 2 * r - 1 ), ← Real.rpow_mul ( by positivity ) ] ; norm_num [ Nat.cast_sub ( show 1 ≤ 2 * r by linarith ) ];
exact Or.inl ( by rw [ div_mul_cancel₀ _ ( sub_ne_zero_of_ne ( by norm_cast; linarith ) ) ] );
refine le_trans ( mul_le_mul_of_nonneg_left hKM_div_r_le <| by positivity ) ?_;
norm_cast ; norm_num [ mul_assoc, mul_comm, mul_left_comm, hDr.ne', show W ≠ 0 by positivity ];
rw [ show r * 2 - 1 = 2 * r - 1 by ring_nf ] ; rcases r with ( _ | _ | r ) <;> norm_num [ Nat.mul_succ, pow_succ' ] at *;
exact Nat.recOn r ( by norm_num ) fun n ihn => by norm_num [ Nat.mul_succ, pow_succ' ] at ihn ⊢ ; nlinarith [ pow_pos ( by norm_num : ( 0 : ℝ ) < 1 / 16 ) n ] ;
/-
Constant inequality (ii): Under M bound from T₂,
2r D_{r+1} W² (K_const M/r)^{2r} ≤ D_r/4.
-/
private lemma constant_ineq_ii
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))) :
2 * (r : ℝ) * D_r1 * W ^ 2 * (K_const * M / (r : ℝ)) ^ (2 * r) ≤ D_r / 4 := by
-- Since $B = 16K$, $M \le r/B T₂$ gives $KM/r \le T₂/16$ where $T₂ = (D_r/(D_{r+1}W²))^{1/(2r)}$.
have hKM_le_T2_div_16 : K_const * M / r ≤ (D_r / (D_r1 * W ^ 2)) ^ (1 / (2 * r) : ℝ) / 16 := by
convert div_le_div_of_nonneg_right ( mul_le_mul_of_nonneg_left hM_le <| show ( 0 : ℝ ) ≤ K_const by exact le_of_lt K_pos ) ( show ( 0 : ℝ ) ≤ r by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring_nf! ; norm_num [ show B_const = 16 * K_const by rfl ] ; ring_nf!;
norm_num [ show r ≠ 0 by positivity, show K_const ≠ 0 by exact ne_of_gt ( lt_max_of_lt_left ( by norm_num ) ) ];
-- So $2r D_{r+1} W² (KM/r)^{2r} ≤ 2r D_r / 16^{2r}$.
have h_bound : 2 * r * D_r1 * W ^ 2 * (K_const * M / r) ^ (2 * r) ≤ 2 * r * D_r / 16 ^ (2 * r) := by
refine le_trans ( mul_le_mul_of_nonneg_left ( pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_of_lt ( show 0 < K_const by exact lt_max_of_lt_left ( by norm_num ) ) ) hM.le ) ( Nat.cast_nonneg _ ) ) hKM_le_T2_div_16 _ ) ( by positivity ) ) ?_;
rw [ div_pow, ← Real.rpow_natCast _ ( 2 * r ), ← Real.rpow_natCast _ ( 2 * r ), ← Real.rpow_mul ( by positivity ) ] ; norm_num [ mul_assoc, mul_comm, mul_left_comm, ne_of_gt ( zero_lt_two.trans_le hr ) ];
field_simp;
norm_num;
refine le_trans h_bound ?_;
rw [ div_le_div_iff₀ ] <;> norm_cast <;> norm_num [ pow_mul ];
nlinarith [ show ( 256 : ℝ ) ^ r ≥ 2 * r * 4 by exact mod_cast Nat.le_induction ( by norm_num ) ( fun k hk ih ↦ by norm_num [ Nat.pow_succ ] at * ; nlinarith ) r hr ]
/-
Constant inequality (iii): Under M bound from T₃,
2r δ W² (K_const M/r)^{r-1} ≤ D_r/4.
-/
private lemma constant_ineq_iii
(r : ℕ) (hr : 2 ≤ r)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(hM_le : M ≤ (r : ℝ) / B_const * (D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))) :
2 * (r : ℝ) * δ * W ^ 2 * (K_const * M / (r : ℝ)) ^ (r - 1) ≤ D_r / 4 := by
-- By multiplying both sides of the inequality $K_const * M / r \leq 1/16 * (D_r / (δ * W ^ 2)) ^ (1 / (r - 1))$ by $r$, we get $K_const * M \leq 1/16 * (D_r / (δ * W ^ 2)) ^ (1 / (r - 1)) * r$.
have h_mul : (K_const * M / r) ^ (r - 1) ≤ (1 / 16) ^ (r - 1) * (D_r / (δ * W ^ 2)) := by
convert pow_le_pow_left₀ ( by exact div_nonneg ( mul_nonneg ( by exact le_max_of_le_left ( by norm_num ) ) hM.le ) ( Nat.cast_nonneg _ ) ) ( show K_const * M / r ≤ ( 1 / 16 ) * ( D_r / ( δ * W ^ 2 ) ) ^ ( 1 / ( r - 1 : ℝ ) ) by
rw [ div_le_iff₀ ] <;> norm_num [ B_const ] at *;
· rw [ div_mul_eq_mul_div, le_div_iff₀ ] at hM_le <;> nlinarith [ show ( 0 : ℝ ) < K_const by exact lt_max_of_lt_left ( by norm_num ) ];
· linarith ) ( r - 1 ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ mul_pow, ← Real.rpow_natCast _ ( r - 1 ), ← Real.rpow_natCast _ ( r - 1 ), ← Real.rpow_mul ( by positivity ), Nat.cast_sub ( by linarith ), Nat.cast_one, div_mul_cancel₀ _ ( sub_ne_zero_of_ne ( by norm_cast; linarith ) ) ] ; norm_num;
refine le_trans ( mul_le_mul_of_nonneg_left h_mul <| by positivity ) ?_;
-- We can divide both sides by $δ * W^2$ to simplify the inequality.
have h_div : 2 * (r : ℝ) * (1 / 16) ^ (r - 1) ≤ 1 / 4 := by
have := eight_r_le_sixteen_pow r hr;
rw [ one_div, inv_pow ] ; nlinarith [ show ( 0 : ℝ ) < 16 ^ ( r - 1 ) by positivity, mul_inv_cancel₀ ( show ( 16 : ℝ ) ^ ( r - 1 ) ≠ 0 by positivity ) ]
have hδW : 0 < δ * W ^ 2 := by positivity
calc 2 * (r : ℝ) * δ * W ^ 2 * ((1 / 16) ^ (r - 1) * (D_r / (δ * W ^ 2)))
= (2 * (r : ℝ) * (1 / 16) ^ (r - 1)) * D_r := by
have := hδW.ne'; first | (field_simp; done) | (field_simp; ring)
_ ≤ 1 / 4 * D_r := mul_le_mul_of_nonneg_right h_div hDr.le
_ = D_r / 4 := by ring
/-
For r ≥ 1: 1/r! ≤ (4/r)^r.
-/
private lemma factorial_inv_le (r : ℕ) (hr : 1 ≤ r) :
(1 : ℝ) / (r.factorial : ℝ) ≤ (4 / (r : ℝ)) ^ r := by
-- We'll use the fact that $r! \geq (r/4)^r$ for $r \geq 1$.
have h_factorial : ∀ r : ℕ, 1 ≤ r → (r.factorial : ℝ) ≥ (r / 4) ^ r := by
intro r hr;
induction hr <;> norm_num [ Nat.factorial ] at *;
-- We'll use the fact that $(1 + 1/m)^m \leq 4$ for all $m \geq 1$.
have h_exp : ∀ m : ℕ, 1 ≤ m → (1 + 1 / (m : ℝ)) ^ m ≤ 4 := by
-- We'll use the fact that $(1 + 1/m)^m \leq e$ for all $m \geq 1$.
have h_exp : ∀ m : ℕ, 1 ≤ m → (1 + 1 / (m : ℝ)) ^ m ≤ Real.exp 1 := by
intro m hm; rw [ ← Real.rpow_natCast, Real.rpow_def_of_pos ( by positivity ) ] ; norm_num;
nlinarith [ Real.log_le_sub_one_of_pos ( by positivity : 0 < 1 + ( m : ℝ ) ⁻¹ ), mul_inv_cancel₀ ( by positivity : ( m : ℝ ) ≠ 0 ) ];
exact fun m hm => le_trans ( h_exp m hm ) ( Real.exp_one_lt_d9.le.trans ( by norm_num ) );
have := h_exp _ ‹_›; rw [ one_add_div ( by positivity ) ] at this; rw [ div_pow, div_le_iff₀ ( by positivity ) ] at *; ring_nf at *; nlinarith;
have hr0 : (0 : ℝ) < (r : ℝ) / 4 := div_pos (by exact_mod_cast Nat.one_pos.trans_le hr) (by norm_num)
have h := one_div_le_one_div_of_le (pow_pos hr0 r) (h_factorial r hr)
calc (1 : ℝ) / (r.factorial : ℝ) ≤ 1 / ((r : ℝ) / 4) ^ r := h
_ = (4 / (r : ℝ)) ^ r := by rw [one_div, ← inv_pow, inv_div]
/-
The Taylor polynomial of degree r at 0 approximates f with error ≤ D_{r+1} (4M/r)^{r+1}.
More precisely, if f ∈ C^{r+1}[0,M] and |f^{(r+1)}| ≤ D_{r+1}, then
|f(x) - ∑_{j=0}^r f^{(j)}(0)/j! x^j| ≤ D_{r+1} (4M/r)^{r+1} for x ∈ [0,M].
We actually bound by D_{r+1} (K·M/r)^{r+1} since K ≥ 4.
-/
private lemma taylor_degree_r_remainder
(r : ℕ) (hr : 1 ≤ r) (M : ℝ) (_ : 0 < M)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ) (hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(x : ℝ) (hx : x ∈ Set.Icc (0 : ℝ) M) :
|f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * x ^ j| ≤
D_r1 * (K_const * M / (r : ℝ)) ^ (r + 1) := by
-- By Taylor's theorem with remainder, we have |f(x) - ∑_{j=0}^r f^(j)(0)/j! x^j| ≤ D_{r+1} x^{r+1}/(r+1)!.
have h_taylor_remainder : abs (f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j) ≤ D_r1 * x ^ (r + 1) / Nat.factorial (r + 1) := by
by_cases hx0 : x = 0;
· simp_all +decide [ Finset.sum_range_succ' ];
· obtain ⟨x', hx'⟩ : ∃ x' ∈ Set.Ioo 0 x, f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j = iteratedDeriv (r + 1) f x' * x ^ (r + 1) / Nat.factorial (r + 1) := by
have hxpos : 0 < x := lt_of_le_of_ne hx.1 (Ne.symm hx0)
have hC : ContDiffOn ℝ (↑r + 1) f (Set.uIcc 0 x) := by
have := hf_smooth.contDiffOn (s := Set.uIcc 0 x); exact_mod_cast this
obtain ⟨x', hx'mem, hx'eq⟩ := taylor_mean_remainder_lagrange_iteratedDeriv (ne_of_lt hxpos) hC
refine ⟨x', by simpa [Set.uIoo, hxpos.le] using hx'mem, ?_⟩
rw [sub_zero] at hx'eq
rw [← hx'eq]
congr 1
rw [taylor_within_apply, Set.uIcc_of_le hx.1]
apply Finset.sum_congr rfl
intro i hi
have hi' : i ≤ r + 1 := by have := Finset.mem_range.mp hi; omega
rw [iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc hxpos)
(hf_smooth.contDiffAt.of_le (by exact_mod_cast hi')) ⟨le_rfl, hx.1⟩, smul_eq_mul, sub_zero]
ring
rw [ hx'.2, abs_div, abs_mul, abs_of_nonneg ( by exact pow_nonneg hx.1 _ : ( 0 : ℝ ) ≤ x ^ ( r + 1 ) ), abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ ( r + 1 ).factorial ) ];
gcongr ; aesop;
exact hf_r1 x' ⟨ hx'.1.1.le, hx'.1.2.le.trans hx.2 ⟩;
-- By the factorial estimate, we have 1/(r+1)! ≤ (4/(r+1))^{r+1} ≤ (4/r)^{r+1} ≤ (K/r)^{r+1}.
have h_factorial_estimate : (1 : ℝ) / Nat.factorial (r + 1) ≤ (4 / r) ^ (r + 1) := by
convert factorial_inv_le ( r + 1 ) ( by linarith ) |> le_trans <| ?_ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
gcongr ; norm_num;
-- Substitute the factorial estimate into the Taylor remainder bound.
have h_substitute : abs (f x - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / Nat.factorial j * x ^ j) ≤ D_r1 * x ^ (r + 1) * (4 / r) ^ (r + 1) := by
exact h_taylor_remainder.trans ( by rw [ div_eq_mul_one_div ] ; exact mul_le_mul_of_nonneg_left ( by simpa using h_factorial_estimate ) ( mul_nonneg hDr1.le ( pow_nonneg hx.1 _ ) ) );
-- Since $x \leq M$, we have $x^{r+1} \leq M^{r+1}$.
have h_x_le_M : x ^ (r + 1) ≤ M ^ (r + 1) := by
exact pow_le_pow_left₀ hx.1 hx.2 _;
refine le_trans h_substitute ?_
have h4K : (4 : ℝ) ≤ K_const := le_max_left 4 c₉
have hx0 : (0 : ℝ) ≤ x := hx.1
have key : (4 * x / ↑r) ^ (r + 1) ≤ (K_const * M / ↑r) ^ (r + 1) := by
apply pow_le_pow_left₀ (by positivity)
apply div_le_div_of_nonneg_right _ (by positivity : (0:ℝ) ≤ ↑r)
exact mul_le_mul h4K hx.2 hx0 (by positivity)
nlinarith [show D_r1 * x ^ (r + 1) * (4 / ↑r) ^ (r + 1) = D_r1 * (4 * x / ↑r) ^ (r + 1) from by ring]
/-
The approximation error: |∑ aᵢ(vᵢ - wᵢf(uᵢ))| ≤ ∑ |aᵢ| · δ · wᵢ
-/
private lemma coeff_sum_bound'
{s : ℕ} {a : Fin s → ℤ} {w : Fin s → ℕ}
{W C_a : ℝ} (hCa : 0 ≤ C_a)
(hw_bound : ∀ i, (w i : ℝ) ≤ W)
(ha_bound : ∀ i, |(a i : ℝ)| ≤ C_a) :
∑ i, |(a i : ℝ)| * (w i : ℝ) ≤ (s : ℝ) * C_a * W := by
exact le_trans ( Finset.sum_le_sum fun _ _ => mul_le_mul ( ha_bound _ ) ( hw_bound _ ) ( by positivity ) ( by positivity ) ) ( by norm_num; nlinarith )
/-- The "binomial polynomial" P_r(n) = n!/(r!(n-r)!) = C(n,r) is a nonneg integer for n ≥ 0. -/
private lemma binomial_poly_eq_choose (n r : ℕ) :
(1 : ℝ) / (r.factorial : ℝ) * ∏ m ∈ Finset.range r, ((n : ℝ) - m) = Nat.choose n r := by
by_cases hn : n < r;
· rw [ Nat.choose_eq_zero_of_lt hn, eq_comm ];
rw [ Finset.prod_eq_zero ( Finset.mem_range.mpr hn ) ] <;> aesop;
· field_simp;
rw_mod_cast [ ← Nat.descFactorial_eq_factorial_mul_choose ];
rw [ Nat.descFactorial_eq_prod_range ];
rw [ Nat.cast_prod, Finset.prod_congr rfl fun x hx => Int.subNatNat_of_le ( by linarith [ Finset.mem_range.mp hx ] ) ]
/-
If ∑ aᵢwᵢuᵢ^j = 0 for j < r and ∑ aᵢwᵢuᵢ^r ≠ 0,
then Z₀ = ∑ aᵢwᵢP_r(uᵢ) is a nonzero integer, so |Z₀| ≥ 1.
Here Z₀ = 1/r! ∑ aᵢwᵢuᵢ^r (by moment annihilation applied to P_r - X^r/r!).
-/
private lemma Z0_nonzero_integer
{s r : ℕ}
{a : Fin s → ℤ} {w : Fin s → ℕ} {u : Fin s → ℤ}
(hu_nonneg : ∀ i, 0 ≤ u i)
(h_vanish : ∀ j : ℕ, j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ j = 0)
(h_nonzero : ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r ≠ 0) :
∃ Z₀ : ℤ, Z₀ ≠ 0 ∧ (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r := by
-- Define Z₀ as the sum of a_i w_i binom(u_i, r).
set Z₀ : ℤ := ∑ i, (a i : ℤ) * (w i : ℤ) * Nat.choose (u i).toNat r;
-- By definition of $Z₀$, we know that
have hZ₀ : (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ r := by
have hZ₀ : (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a i : ℝ) * (w i : ℝ) * (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) := by
have hZ₀ : ∀ i, (Nat.choose (u i).toNat r : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) := by
intro i; specialize hu_nonneg i
obtain ⟨n, hn⟩ := Int.eq_ofNat_of_zero_le hu_nonneg
simp only [hn]; exact (binomial_poly_eq_choose n r).symm
simp +zetaDelta at *;
simp +decide only [hZ₀, Finset.mul_sum _ _ _, mul_left_comm];
-- By definition of polynomial interpolation, we know that $\prod_{j=0}^{r-1} (u_i - j)$ is a polynomial of degree $r$.
have h_poly_interpolate : ∃ p : Polynomial ℝ, p.degree ≤ r ∧ ∀ i, (∏ j ∈ Finset.range r, ((u i : ℝ) - j)) = p.eval (u i : ℝ) ∧ p.coeff r = 1 := by
refine' ⟨ ∏ j ∈ Finset.range r, ( Polynomial.X - Polynomial.C ( j : ℝ ) ), _, _ ⟩;
· norm_num [ Polynomial.degree_prod ];
erw [ Finset.sum_congr rfl fun _ _ => Polynomial.degree_X_sub_C _ ] ; norm_num;
· refine' fun i => ⟨ _, _ ⟩;
· simp +decide [ Polynomial.eval_prod ];
· have h_coeff : Polynomial.leadingCoeff (∏ j ∈ Finset.range r, (Polynomial.X - Polynomial.C (j : ℝ))) = 1 := by
rw [ Polynomial.leadingCoeff_prod ] ; exact Finset.prod_eq_one fun _ _ => Polynomial.leadingCoeff_X_sub_C _;
rw [ Polynomial.leadingCoeff, Polynomial.natDegree_prod _ _ fun x hx => Polynomial.X_sub_C_ne_zero _ ] at h_coeff;
simpa [ Polynomial.natDegree_sub_eq_left_of_natDegree_lt ] using h_coeff;
obtain ⟨ p, hp₁, hp₂ ⟩ := h_poly_interpolate;
have h_poly_interpolate : ∑ i, (a i : ℝ) * (w i : ℝ) * p.eval (u i : ℝ) = ∑ j ∈ Finset.range (r + 1), p.coeff j * ∑ i, (a i : ℝ) * (w i : ℝ) * (u i : ℝ) ^ j := by
simp +decide [ Finset.mul_sum _ _ _, mul_assoc, mul_comm, mul_left_comm ];
rw [ Finset.sum_comm, Finset.sum_congr rfl ] ; intros ; rw [ Polynomial.eval_eq_sum_range' ] ; ring_nf;
exacts [ by rw [ Finset.mul_sum _ _ _ ] ; exact Finset.sum_congr rfl fun _ _ => by ring, by linarith [ Polynomial.natDegree_le_of_degree_le hp₁ ] ];
simp_all +decide [ Finset.sum_range_succ ];
exact Or.inl ( by rw [ Finset.sum_eq_zero fun j hj => by rw [ h_vanish j ( Finset.mem_range.mp hj ) ] ; ring ] ; rw [ hp₂ ⟨ 0, Nat.pos_of_ne_zero ( by aesop_cat ) ⟩ |>.2 ] ; ring );
exact ⟨ Z₀, by contrapose! h_nonzero; simp_all +decide [ Nat.factorial_ne_zero ], hZ₀ ⟩
/-
Short interval bound.
-/
private theorem short_interval
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(M : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) M, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) M, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc M))
(hS_good : ∀ u ∈ S, IsGood f W δ u)
(hM_le : M ≤ (r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1)))) :
S.card < 2 * r := by
-- Convert hS_sub to Finset subset
have hS_sub' : S ⊆ intIcc M := Finset.coe_subset.mp hS_sub
-- If M < 2r - 1, use short_cardinality
by_cases h_small : M < (2 * r : ℝ) - 1
· have h1 := Finset.card_le_card hS_sub'
have h2 := short_cardinality (2 * r) M (by push_cast; exact h_small)
omega
push_neg at h_small
-- Suppose for contradiction |S| ≥ 2r
by_contra h_contra; push_neg at h_contra
obtain ⟨T, hT_sub, hT_card⟩ := Finset.le_card_iff_exists_subset_card.mp h_contra
set e := Finset.orderIsoOfFin T hT_card
set u_fn := fun (i : Fin (2 * r)) => (e i : ℤ)
have h_strict : StrictMono u_fn := fun i j hij => by exact_mod_cast (e.strictMono hij)
have h_range : ∀ i, 0 ≤ u_fn i ∧ (u_fn i : ℝ) ≤ M := by
intro i; have := hS_sub' (hT_sub (Finset.coe_mem (e i)))
exact ⟨intIcc_nonneg this, intIcc_le_M this⟩
have h_good : ∀ i, IsGood f W δ (u_fn i) := by
intro i; exact hS_good _ (hT_sub (Finset.coe_mem (e i)))
choose v_fn w_fn hw_pos hw_le h_approx using h_good
have h_small' : ((2 * r : ℕ) : ℝ) - 1 ≤ M := by push_cast; exact h_small
obtain ⟨a_fn, h_moment_zero, h_moment_r, h_coeff_bound⟩ :=
hSILR r (by linarith) (2 * r) rfl M h_small' W hW
u_fn w_fn h_range h_strict hw_pos hw_le
-- Define key quantities
set I : ℤ := ∑ i, a_fn i * v_fn i
set I₁ : ℝ := iteratedDeriv r f 0 / (r.factorial : ℝ) *
∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r
set R₁ : ℝ := ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) *
(f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1),
iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j)
set R₂ : ℝ := ∑ i, (a_fn i : ℝ) * ((v_fn i : ℝ) - (w_fn i : ℝ) * f (u_fn i : ℝ))
-- I = I₁ + R₁ + R₂ (splitting the integer into three real parts)
have hI_split : (I : ℝ) = I₁ + R₁ + R₂ := by
have hI : ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j) = I₁ := by
simp +zetaDelta at *;
simp +decide [Finset.mul_sum _ _ _, mul_assoc, mul_left_comm];
rw [ Finset.sum_comm ];
simp +decide [ Finset.sum_range_succ ];
exact Finset.sum_eq_zero fun i hi => by simpa [ mul_assoc, mul_comm, mul_left_comm, Finset.mul_sum _ _ _ ] using mul_eq_zero_of_right ( iteratedDeriv i f 0 / ( i.factorial : ℝ ) ) ( h_moment_zero i ( Finset.mem_range.mp hi ) ) ;
convert congr_arg₂ ( · + · ) ( congr_arg₂ ( · + · ) hI rfl ) rfl using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
simp +zetaDelta at *;
rw [ ← Finset.sum_add_distrib, ← Finset.sum_add_distrib ] ; congr ; ext ; ring;
-- Key bounds
have hI₁_upper : |I₁| ≤ 1 / 2 := by
-- By the properties of the derivative and the bounds on the coefficients, we have:
have hI1_bound : |I₁| ≤ D_r / (r.factorial : ℝ) * (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r := by
have hI1_bound : |∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r := by
have hI1_bound : ∀ i, |(a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ (c₉ * M / r) ^ (r - 1) * W * W * M ^ r := by
intros i
have h_abs : |(a_fn i : ℝ) * (w_fn i : ℝ) * (u_fn i : ℝ) ^ r| ≤ |(a_fn i : ℝ)| * (w_fn i : ℝ) * M ^ r := by
norm_num [ abs_mul ];
exact mul_le_mul_of_nonneg_left ( pow_le_pow_left₀ ( abs_nonneg _ ) ( by rw [ abs_of_nonneg ( mod_cast h_range i |>.1 ) ] ; exact h_range i |>.2 ) _ ) ( by positivity );
exact h_abs.trans ( mul_le_mul_of_nonneg_right ( mul_le_mul ( h_coeff_bound i ) ( hw_le i ) ( by positivity ) ( by exact mul_nonneg ( pow_nonneg ( by exact div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ( by positivity ) ) ) ( by positivity ) );
exact le_trans ( Finset.abs_sum_le_sum_abs _ _ ) ( le_trans ( Finset.sum_le_sum fun _ _ => hI1_bound _ ) ( by norm_num; linarith ) );
have := hf_r_upper 0 ⟨ by norm_num, by linarith ⟩;
rw [ abs_mul, abs_div ];
rw [ abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ r.factorial ) ] ; convert mul_le_mul ( div_le_div_of_nonneg_right this ( by positivity : ( 0 : ℝ ) ≤ r.factorial ) ) hI1_bound ( by positivity ) ( by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring;
-- Using the factorial bound and the fact that $c₉ \leq K$, we can simplify the expression.
have h_factorial_bound : D_r / (r.factorial : ℝ) * (2 * r * (c₉ * M / r) ^ (r - 1) * W * W) * M ^ r ≤ D_r * 2 * r * W ^ 2 * (K_const * M / r) ^ (2 * r - 1) := by
have h_factorial_bound : M ^ r / (r.factorial : ℝ) ≤ (K_const * M / r) ^ r := by
have hM_r_bound : M ^ r / (r.factorial : ℝ) ≤ (4 * M / r) ^ r := by
have := factorial_inv_le r ( by linarith );
convert mul_le_mul_of_nonneg_left this ( pow_nonneg hM.le r ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> ring;
exact hM_r_bound.trans ( pow_le_pow_left₀ ( by positivity ) ( by rw [ div_le_div_iff_of_pos_right ( by positivity ) ] ; exact mul_le_mul_of_nonneg_right ( by exact le_max_left _ _ ) hM.le ) _ );
have h_factorial_bound : (c₉ * M / r) ^ (r - 1) * M ^ r / (r.factorial : ℝ) ≤ (K_const * M / r) ^ (2 * r - 1) := by
rw [ show 2 * r - 1 = r - 1 + r by omega, pow_add ];
rw [ mul_div_assoc ];
gcongr;
· exact pow_nonneg ( div_nonneg ( mul_nonneg ( by exact le_max_of_le_left ( by norm_num ) ) hM.le ) ( Nat.cast_nonneg _ ) ) _;
· exact div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ );
· exact le_max_right _ _;
convert mul_le_mul_of_nonneg_left h_factorial_bound ( show 0 ≤ D_r * 2 * r * W ^ 2 by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring;
refine le_trans hI1_bound <| h_factorial_bound.trans ?_;
convert constant_ineq_i r hr M hM W hW D_r hDr _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· ring;
· exact hM_le.trans ( mul_le_mul_of_nonneg_left ( min_le_left _ _ |> le_trans <| min_le_left _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact mul_nonneg ( by norm_num ) <| le_max_of_le_left <| by norm_num )
have hI₁_lower : D_r / 2 ≤ |I₁| := by
-- By definition of $Z₀$, we have $Z₀ = 1/r! \sum a_i w_i u_i^r$.
obtain ⟨Z₀, hZ₀_nonzero, hZ₀_eq⟩ : ∃ Z₀ : ℤ, Z₀ ≠ 0 ∧ (Z₀ : ℝ) = (1 : ℝ) / (r.factorial : ℝ) * ∑ i, (a_fn i : ℝ) * (w_fn i : ℝ) * u_fn i ^ r := by
convert Z0_nonzero_integer ( fun i => h_range i |>.1 ) h_moment_zero h_moment_r using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
-- By definition of $I₁$, we have $I₁ = f^{(r)}(0) \cdot Z₀$.
have hI₁_def : I₁ = iteratedDeriv r f 0 * Z₀ := by
grind;
rw [ hI₁_def, abs_mul ];
exact le_trans ( hf_r_lower 0 ⟨ by norm_num, by linarith ⟩ ) ( le_mul_of_one_le_right ( abs_nonneg _ ) ( mod_cast abs_pos.mpr hZ₀_nonzero ) )
have hR_sum : |R₁ + R₂| < D_r / 2 := by
-- We bound |R₁| using taylor_degree_r_remainder and constant_ineq_ii.
have hR₁_bound : |R₁| ≤ 2 * r * D_r1 * W ^ 2 * (K_const * M / r) ^ (2 * r) := by
have hR₁_bound : |R₁| ≤ D_r1 * (K_const * M / r) ^ (r + 1) * (∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ)) := by
have hR₁_upper : ∀ i, |(a_fn i : ℝ) * (w_fn i : ℝ) * (f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j)| ≤ |(a_fn i : ℝ)| * (w_fn i : ℝ) * D_r1 * (K_const * M / r) ^ (r + 1) := by
intros i
have h_remainder_bound : |f (u_fn i : ℝ) - ∑ j ∈ Finset.range (r + 1), iteratedDeriv j f 0 / (j.factorial : ℝ) * (u_fn i : ℝ) ^ j| ≤ D_r1 * (K_const * M / r) ^ (r + 1) := by
apply taylor_degree_r_remainder;
grind;
· linarith;
· positivity;
· exact hf_smooth;
· exact hf_r1;
· exact ⟨ mod_cast h_range i |>.1, h_range i |>.2 ⟩;
rw [ abs_mul, abs_mul, abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ w_fn i ) ] ; nlinarith [ show ( 0 : ℝ ) ≤ |↑ ( a_fn i )| * ↑ ( w_fn i ) by positivity ] ;
exact le_trans ( Finset.abs_sum_le_sum_abs _ _ ) ( by rw [ Finset.mul_sum _ _ _ ] ; exact Finset.sum_le_sum fun i _ => by convert hR₁_upper i using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; ring );
have hR₁_bound : |R₁| ≤ D_r1 * (K_const * M / r) ^ (r + 1) * (2 * r) * (c₉ * M / r) ^ (r - 1) * W ^ 2 := by
have hR₁_bound : ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) ≤ (2 * r) * (c₉ * M / r) ^ (r - 1) * W ^ 2 := by
convert coeff_sum_bound' ( show 0 ≤ ( c₉ * M / r ) ^ ( r - 1 ) * W by exact mul_nonneg ( pow_nonneg ( div_nonneg ( mul_nonneg ( by norm_num [ c₉ ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ( by positivity ) ) ( fun i => hw_le i ) ( fun i => h_coeff_bound i ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; norm_num [ mul_assoc, mul_comm, mul_left_comm ];
ring;
exact le_trans ‹_› ( by nlinarith [ show 0 ≤ D_r1 * ( K_const * M / r ) ^ ( r + 1 ) by exact mul_nonneg hDr1.le ( pow_nonneg ( div_nonneg ( mul_nonneg ( by norm_num [ K_const ] ) hM.le ) ( Nat.cast_nonneg _ ) ) _ ) ] );
refine le_trans hR₁_bound ?_;
rcases r <;> simp_all +decide [ Nat.mul_succ, pow_succ' ] ; ring_nf;
simp only [c₉, K_const]; norm_num [pow_mul]; ring_nf; norm_num;
-- We bound |R₂| using approx_error_bound' and constant_ineq_iii.
have hR₂_bound : |R₂| < 2 * r * δ * W ^ 2 * (K_const * M / r) ^ (r - 1) := by
have hR₂_bound : |R₂| < δ * ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) := by
have hR₂_bound : |R₂| ≤ ∑ i, |(a_fn i : ℝ)| * (w_fn i : ℝ) * |f (u_fn i : ℝ) - (v_fn i : ℝ) / (w_fn i : ℝ)| := by
convert Finset.abs_sum_le_sum_abs _ _ using 2 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; norm_num [ abs_mul, abs_sub_comm, mul_assoc, mul_comm, mul_left_comm, div_eq_mul_inv, ne_of_gt ( hw_pos _ ) ];
· field_simp;
exact Or.inl ( by rw [ show ( v_fn _ : ℝ ) / w_fn _ - f ( u_fn _ : ℝ ) = ( v_fn _ - w_fn _ * f ( u_fn _ : ℝ ) ) / w_fn _ by rw [ sub_div, mul_div_cancel_left₀ _ ( Nat.cast_ne_zero.mpr <| ne_of_gt <| hw_pos _ ) ] ] ; rw [ abs_div, abs_of_nonneg ( by positivity : ( 0 : ℝ ) ≤ w_fn _ ) ] ; rw [ mul_div_cancel₀ _ ( Nat.cast_ne_zero.mpr <| ne_of_gt <| hw_pos _ ) ] );
· infer_instance;
rw [ Finset.mul_sum _ _ _ ];
refine' lt_of_le_of_lt hR₂_bound ( Finset.sum_lt_sum _ _ );
· exact fun i _ => by nlinarith only [ h_approx i, show 0 ≤ |( a_fn i : ℝ )| * ( w_fn i : ℝ ) by positivity ] ;
· obtain ⟨i, hi⟩ : ∃ i, a_fn i ≠ 0 := by
exact not_forall.mp fun h => h_moment_r <| by simp +decide [ h ] ;
exact ⟨ i, Finset.mem_univ _, by nlinarith only [ show 0 < |( a_fn i : ℝ )| * w_fn i by exact mul_pos ( abs_pos.mpr ( Int.cast_ne_zero.mpr hi ) ) ( Nat.cast_pos.mpr ( hw_pos i ) ), h_approx i ] ⟩;
refine lt_of_lt_of_le hR₂_bound ?_;
refine' le_trans ( mul_le_mul_of_nonneg_left ( Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left ( hw_le i ) ( abs_nonneg _ ) ) hδ.le ) _;
refine' le_trans ( mul_le_mul_of_nonneg_left ( Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_right ( h_coeff_bound i ) ( by positivity ) ) hδ.le ) _ ; norm_num ; ring_nf ; norm_num;
simp only [c₉, K_const]; norm_num [pow_mul]; ring_nf; norm_num;
-- We use constant_ineq_ii and constant_ineq_iii to bound |R₁| and |R₂|.
have hR₁_bound' : |R₁| ≤ D_r / 4 := by
refine le_trans hR₁_bound ?_;
apply_rules [ constant_ineq_ii ];
exact hM_le.trans ( mul_le_mul_of_nonneg_left ( min_le_left _ _ |> le_trans <| min_le_right _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact le_of_lt <| by exact B_pos )
have hR₂_bound' : |R₂| < D_r / 4 := by
refine lt_of_lt_of_le hR₂_bound ?_;
convert constant_ineq_iii r hr M hM W hW δ hδ D_r hDr ( show M ≤ ( r : ℝ ) / B_const * ( D_r / ( δ * W ^ 2 ) ) ^ ( ( 1 : ℝ ) / ( r - 1 ) ) from le_trans hM_le <| mul_le_mul_of_nonneg_left ( min_le_right _ _ ) <| by exact div_nonneg ( Nat.cast_nonneg _ ) <| by exact le_of_lt <| by exact B_pos ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
exact abs_lt.mpr ⟨ by linarith [ abs_le.mp hR₁_bound', abs_lt.mp hR₂_bound' ], by linarith [ abs_le.mp hR₁_bound', abs_lt.mp hR₂_bound' ] ⟩
-- Contradiction: I ≠ 0 but |I| < 1
have hI_ne_zero : I ≠ 0 := by
intro hI_zero
have : (I : ℝ) = 0 := by exact_mod_cast hI_zero
rw [hI_split] at this
have : I₁ = -(R₁ + R₂) := by linarith
have : |I₁| = |R₁ + R₂| := by rw [this, abs_neg]
linarith
have hI_bound : |(I : ℝ)| < 1 := by
rw [hI_split]
have : |I₁ + (R₁ + R₂)| ≤ |I₁| + |R₁ + R₂| := abs_add_le _ _
linarith [show |I₁ + R₁ + R₂| = |I₁ + (R₁ + R₂)| from by ring_nf]
exact hI_ne_zero (int_abs_lt_one_imp_zero I hI_bound)
/-
For each block [kM, (k+1)M), translating f and applying short_interval gives < 2r good points.
-/
private lemma per_block_bound
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(M N : ℝ) (hM : 0 < M)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) N, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(hM_le : M ≤ (r : ℝ) / B_const * min (min
((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1)))
((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r))))
((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))))
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(hS_good : ∀ u ∈ S, IsGood f W δ u)
(k : ℕ) :
(S.filter (fun u : ℤ =>
(k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)).card < 2 * r := by
by_contra h_contra;
-- Let $a$ be the minimum element in the set $\{u \in S \mid kM \leq u < (k+1)M\}$.
obtain ⟨a, ha⟩ : ∃ a ∈ S, (k : ℝ) * M ≤ (a : ℝ) ∧ (a : ℝ) < ((k : ℝ) + 1) * M ∧ ∀ u ∈ S, (k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M → a ≤ u := by
obtain ⟨a, ha⟩ : ∃ a ∈ S, (k : ℝ) * M ≤ (a : ℝ) ∧ (a : ℝ) < ((k : ℝ) + 1) * M := by
exact Exists.elim ( Finset.card_pos.mp ( by linarith ) ) fun x hx => ⟨ x, Finset.mem_filter.mp hx |>.1, Finset.mem_filter.mp hx |>.2 ⟩;
exact ⟨ Finset.min' ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.1, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.2.1, Finset.mem_filter.mp ( Finset.min'_mem ( S.filter fun u : ℤ => ( k : ℝ ) * M ≤ u ∧ u < ( k + 1 ) * M ) ⟨ a, by aesop ⟩ ) |>.2.2, fun u hu hu' => Finset.min'_le _ _ <| by aesop ⟩;
-- Define $T = \{u - a \mid u \in S, kM \leq u < (k+1)M\}$.
set T := Finset.image (fun u => u - a) (S.filter (fun u => (k : ℝ) * M ≤ (u : ℝ) ∧ (u : ℝ) < ((k : ℝ) + 1) * M)) with hT;
-- Apply the short_interval lemma to the set $T$.
have hT_short : T.card < 2 * r := by
apply short_interval r hr hSILR (min M (N - a)) (by
have := Finset.exists_mem_ne ( by linarith ) a; obtain ⟨ u, hu, hu' ⟩ := this; simp_all +decide [ Finset.subset_iff ] ;
exact lt_of_lt_of_le ( show ( a : ℝ ) < u from mod_cast lt_of_le_of_ne ( ha.2.2.2 u hu.1 hu.2.1 hu.2.2 ) ( Ne.symm hu' ) ) ( mod_cast intIcc_le_M ( hS_sub hu.1 ) )) W hW δ hδ D_r hDr D_r1 hDr1 (fun x => f (a + x)) (by
exact hf_smooth.comp ((contDiff_const.add contDiff_id).of_le le_top)) (by
intro x hx
have h_deriv : iteratedDeriv r (fun x => f (a + x)) x = iteratedDeriv r f (a + x) := by
rw [ iteratedDeriv_comp_translate ];
convert hf_r_lower ( a + x ) ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 from mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) ; (first | rw [h_deriv] | exact congrArg abs h_deriv | simp only [iteratedDeriv_comp_translate] | rw [iteratedDeriv_comp_translate])) (by
intro x hx; rw [ iteratedDeriv_comp_translate ] ;
exact hf_r_upper _ ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 by exact_mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩) (by
intro x hx; rw [ iteratedDeriv_comp_translate ] ; norm_num;
exact hf_r1 _ ⟨ by linarith [ hx.1, show ( a : ℝ ) ≥ 0 by exact_mod_cast intIcc_nonneg ( hS_sub ha.1 ) ], by linarith [ hx.2, min_le_left M ( N - a ), min_le_right M ( N - a ) ] ⟩) T (by
simp_all +decide [ Finset.subset_iff ];
rintro _ u hu hu₁ hu₂ rfl; specialize hS_sub hu; simp_all +decide [ intIcc ] ;
exact Int.le_of_lt_add_one ( by rw [ ← @Int.cast_lt ℝ ] ; push_cast; cases min_cases M ( N - a ) <;> linarith [ Int.floor_le ( min M ( N - a ) ), Int.lt_floor_add_one ( min M ( N - a ) ), show ( u : ℝ ) ≤ ⌊N⌋ from mod_cast hS_sub.2, Int.floor_le N, Int.lt_floor_add_one N ] )) (by
simp +zetaDelta at *;
rintro u x hx hx₁ hx₂ rfl; specialize hS_good x hx; obtain ⟨ v, w, hw₁, hw₂, hw₃ ⟩ := hS_good; use v, w; aesop;) (by
exact le_trans ( min_le_left _ _ ) hM_le);
rw [ Finset.card_image_of_injective _ ( sub_left_injective ) ] at hT_short ; linarith
/-
The `λ = 1` case
-/
private theorem lambda_one_case
(r : ℕ) (hr : 2 ≤ r) (hSILR : SILRProp)
(N : ℝ) (hN : 0 < N)
(W : ℝ) (hW : 1 ≤ W)
(δ : ℝ) (hδ : 0 < δ)
(D_r : ℝ) (hDr : 0 < D_r)
(D_r1 : ℝ) (hDr1 : 0 < D_r1)
(f : ℝ → ℝ)
(hf_smooth : ContDiff ℝ (↑(r + 1) : ℕ∞) f)
(hf_r_lower : ∀ x ∈ Set.Icc (0 : ℝ) N, D_r / 2 ≤ |iteratedDeriv r f x|)
(hf_r_upper : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r)
(hf_r1 : ∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + 1) f x| ≤ D_r1)
(S : Finset ℤ)
(hS_sub : ↑S ⊆ ↑(intIcc N))
(hS_good : ∀ u ∈ S, IsGood f W δ u) :
(S.card : ℝ) < C₀_const * N *
((D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / D_r) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) +
2 * (r : ℝ) := by
-- Let $M = (r/B_const) * \min(\min(T₁, T₂), T₃)$.
set M := (r : ℝ) / B_const * min (min ((D_r * W ^ 2) ^ (-(1 : ℝ) / ((2 : ℝ) * r - 1))) ((D_r / (D_r1 * W ^ 2)) ^ ((1 : ℝ) / ((2 : ℝ) * r)))) ((D_r / (δ * W ^ 2)) ^ ((1 : ℝ) / ((r : ℝ) - 1))) with hM_def;
by_cases hM_pos : 0 < M;
· have h_card_bound : (S.card : ℝ) ≤ (N / M + 1) * (2 * r - 1) := by
convert block_subdivision_count N M hN hM_pos ( 2 * r ) ( by linarith ) S ( fun u hu => hS_sub hu ) _ using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· norm_cast;
· convert per_block_bound r hr hSILR M N hM_pos W hW δ hδ D_r hDr D_r1 hDr1 f hf_smooth _ _ _ _ S ( fun u hu => hS_sub hu ) hS_good using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· exact hf_r_lower;
· exact hf_r_upper;
· exact hf_r1;
convert block_count_to_C0_bound r hr N hN D_r D_r1 W δ hDr hDr1 hW hδ _ h_card_bound using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
· contrapose! hM_pos;
refine' mul_pos ( div_pos ( Nat.cast_pos.mpr ( by linarith ) ) ( by exact mul_pos ( by norm_num ) ( by exact lt_max_of_lt_left ( by norm_num ) ) ) ) ( lt_min ( lt_min ( Real.rpow_pos_of_pos ( by positivity ) _ ) ( Real.rpow_pos_of_pos ( by positivity ) _ ) ) ( Real.rpow_pos_of_pos ( by positivity ) _ ) )
/-- The main rpow term is positive. -/
private lemma konyagin_main_term_pos
(r : ℕ) (N W δ lam D_r D_r1 : ℝ)
(hN : 0 < N) (hW : 1 ≤ W) (hδ : 0 < δ) (hlam : 1 ≤ lam)
(hDr : 0 < D_r) (hDr1 : 0 < D_r1) :
0 < c₆ * N *
((D_r * lam ^ (r : ℕ) * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * lam * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) := by
refine' mul_pos _ ( add_pos_of_pos_of_nonneg ( add_pos_of_pos_of_nonneg _ _ ) _ )
· exact mul_pos ( c₆_pos ) hN
· positivity
· positivity
· positivity
/-- `A + 4B + C ≤ 4(A + B + C)` for nonneg reals. -/
private lemma two_rpow_le_four (r : ℕ) (hr : 2 ≤ r) :
(2 : ℝ) ^ ((r : ℝ) / ((r : ℝ) - 1)) ≤ 4 := by
exact le_trans ( Real.rpow_le_rpow_of_exponent_le ( by norm_num ) ( show ( r : ℝ ) / ( r - 1 ) ≤ 2 by rw [ div_le_iff₀ ] <;> linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ] ) ) ( by norm_num )
/-
The term `(δW²/(ℓ^r D_r))^{1/(r-1)}` is at most
`4 · (δW²/(λ^r D_r))^{1/(r-1)}` when `ℓ > λ/2` and `r ≥ 2`.
-/
private lemma term2_comparison
(r : ℕ) (hr : 2 ≤ r)
(D_r W δ : ℝ) (hDr : 0 < D_r) (hW : 1 ≤ W) (hδ : 0 < δ)
(ell : ℕ) (lam : ℝ) (hell : 0 < ell)
(hell_le : (ell : ℝ) ≤ lam) (hlam_lt : lam < 2 * (ell : ℝ)) :
(δ * W ^ 2 / ((ell : ℝ) ^ (r : ℕ) * D_r)) ^ (((r : ℝ) - 1)⁻¹) ≤
4 * (δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) := by
-- Since ℓ > λ/2, we have ℓ^r > (λ/2)^r, so 1/(ℓ^r) < 1/((λ/2)^r) = 2^r/λ^r.
have h_bound : 1 / (ell : ℝ) ^ r < (2 : ℝ) ^ r / (lam : ℝ) ^ r := by
rw [ div_lt_div_iff₀ ] <;> try positivity;
· simpa only [ one_mul, ← mul_pow ] using pow_lt_pow_left₀ hlam_lt ( by linarith ) ( by linarith );
· exact pow_pos ( by linarith [ show ( ell : ℝ ) ≥ 1 by norm_cast ] ) _;
-- Therefore, δW²/(ℓ^r D_r) < 2^r δW²/(λ^r D_r).
have h_bound' : δ * W ^ 2 / ((ell : ℝ) ^ r * D_r) < 2 ^ r * δ * W ^ 2 / (lam ^ r * D_r) := by
convert mul_lt_mul_of_pos_left h_bound ( show 0 < δ * W ^ 2 / D_r by positivity ) using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> (first | ring | (field_simp; done) | (field_simp; ring));
refine' le_trans ( Real.rpow_le_rpow ( by positivity ) h_bound'.le ( inv_nonneg.mpr ( sub_nonneg.mpr ( Nat.one_le_cast.mpr ( by linarith ) ) ) ) ) _;
rw [ show ( 2 ^ r * δ * W ^ 2 / ( lam ^ r * D_r ) ) = ( δ * W ^ 2 / ( D_r * lam ^ r ) ) * ( 2 ^ r ) by ring, Real.mul_rpow ( by exact div_nonneg ( by positivity ) ( by exact mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) ( by positivity ) ];
rw [ mul_comm ] ; gcongr;
· exact Real.rpow_nonneg ( div_nonneg ( mul_nonneg hδ.le ( sq_nonneg _ ) ) ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) _;
· convert two_rpow_le_four r hr using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl)));
rw [ ← Real.rpow_natCast, ← Real.rpow_mul ( by positivity ), mul_comm ] ; ring_nf
/-
The `C₀ · (terms with ℓ) ≤ c₆ · (terms with λ)` algebraic comparison.
-/
private lemma algebraic_comparison
(r : ℕ) (hr : 2 ≤ r)
(D_r D_r1 W δ : ℝ) (hDr : 0 < D_r) (hDr1 : 0 < D_r1)
(hW : 1 ≤ W) (hδ : 0 < δ)
(ell : ℕ) (lam : ℝ) (hell : 0 < ell)
(hell_le : (ell : ℝ) ≤ lam) (hlam_lt : lam < 2 * (ell : ℝ)) :
C₀_const *
(((ell : ℝ) ^ (r : ℕ) * D_r * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / ((ell : ℝ) ^ (r : ℕ) * D_r)) ^ (((r : ℝ) - 1)⁻¹) +
((ell : ℝ) * D_r1 * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) ≤
c₆ *
((D_r * lam ^ (r : ℕ) * W ^ 2) ^ ((2 * (r : ℝ) - 1)⁻¹) +
(δ * W ^ 2 / (D_r * lam ^ (r : ℕ))) ^ (((r : ℝ) - 1)⁻¹) +
(D_r1 * lam * W ^ 2 / D_r) ^ ((2 * (r : ℝ))⁻¹)) := by
-- Apply the term2_comparison lemma.
have h_term2 : (δ * W ^ 2 / (ell ^ r * D_r)) ^ (1 / (r - 1 : ℝ)) ≤ 4 * (δ * W ^ 2 / (D_r * lam ^ r)) ^ (1 / (r - 1 : ℝ)) := by
convert term2_comparison r hr D_r W δ hDr hW hδ ell lam hell hell_le hlam_lt using 1 <;> (try (first | with_reducible_and_instances rfl | (show (_ : LE ℝ) = _; rfl) | (show (_ : LT ℝ) = _; rfl) | (show (_ : LE ℝ) = _; with_unfolding_all rfl) | (show (_ : LT ℝ) = _; with_unfolding_all rfl))) <;> (try simp only [one_div])
-- Apply the term1_comparison lemma.
have h_term1 : (ell ^ r * D_r * W ^ 2) ^ (1 / (2 * r - 1 : ℝ)) ≤ (D_r * lam ^ r * W ^ 2) ^ (1 / (2 * r - 1 : ℝ)) := by
exact Real.rpow_le_rpow ( by positivity ) ( by nlinarith [ show ( ell : ℝ ) ^ r ≤ lam ^ r by gcongr, show ( 0 : ℝ ) < D_r * W ^ 2 by positivity ] ) ( by exact one_div_nonneg.mpr ( by linarith [ show ( r : ℝ ) ≥ 2 by norm_cast ] ) );
-- Apply the term3_comparison lemma.
have h_term3 : (ell * D_r1 * W ^ 2 / D_r) ^ (1 / (2 * r : ℝ)) ≤ (D_r1 * lam * W ^ 2 / D_r) ^ (1 / (2 * r : ℝ)) := by
exact Real.rpow_le_rpow ( by positivity ) ( by rw [ div_le_div_iff_of_pos_right ( by positivity ) ] ; nlinarith [ show 0 < D_r1 * W ^ 2 by positivity ] ) ( by positivity );
rw [ show c₆ = 4 * C₀_const by rfl ];
norm_num at *;
nlinarith [ show 0 < C₀_const by exact C₀_pos, show 0 ≤ ( D_r * lam ^ r * W ^ 2 ) ^ ( 2 * r - 1 : ℝ ) ⁻¹ by exact Real.rpow_nonneg ( by exact mul_nonneg ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ( sq_nonneg _ ) ) _, show 0 ≤ ( δ * W ^ 2 / ( D_r * lam ^ r ) ) ^ ( r - 1 : ℝ ) ⁻¹ by exact Real.rpow_nonneg ( by exact div_nonneg ( mul_nonneg hδ.le ( sq_nonneg _ ) ) ( mul_nonneg hDr.le ( pow_nonneg ( by linarith ) _ ) ) ) _, show 0 ≤ ( D_r1 * lam * W ^ 2 / D_r ) ^ ( ( r : ℝ ) ⁻¹ * ( 1 / 2 ) ) by exact Real.rpow_nonneg ( by exact div_nonneg ( mul_nonneg ( mul_nonneg hDr1.le ( by linarith ) ) ( sq_nonneg _ ) ) hDr.le ) _ ]
/-
Sum over residue classes.
-/
theorem erdos_1094__h2__h2__h2__h3__h1__h1__h1 : ∀ (r : ℕ),
(2 : ℕ) ≤ r →
∀ (N : ℝ),
(0 : ℝ) < N →
∀ (W : ℝ),
(1 : ℝ) ≤ W →
∀ (δ : ℝ),
(0 : ℝ) < δ →
∀ (lam : ℝ),
(1 : ℝ) ≤ lam →
∀ (D_r : ℝ),
(0 : ℝ) < D_r →
∀ (D_r1 : ℝ),
(0 : ℝ) < D_r1 →
∀ (f : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) f →
(∀ x ∈ Set.Icc (0 : ℝ) N, D_r / (2 : ℝ) ≤ |iteratedDeriv r f x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv r f x| ≤ D_r) →
(∀ x ∈ Set.Icc (0 : ℝ) N, |iteratedDeriv (r + (1 : ℕ)) f x| ≤ D_r1) →
∀ (S : Finset ℤ),
(∀ u ∈ S, (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋) →
(∀ u ∈ S,
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ) →
let X :=
(D_r * lam ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) / (D_r * lam ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D_r1 * lam * W ^ (2 : ℕ) / D_r) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹;
¬(1 : ℝ) ≤ (65536 : ℝ) * X →
∀ (N' : ℝ),
(0 : ℝ) < N' →
∀ (lam' : ℝ),
(1 : ℝ) ≤ lam' →
lam' < (2 : ℝ) →
∀ (D' : ℝ),
(0 : ℝ) < D' →
∀ (D1' : ℝ),
(0 : ℝ) < D1' →
∀ (g : ℝ → ℝ),
ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g →
(∀ x ∈ Set.Icc (0 : ℝ) N',
D' / (2 : ℝ) ≤ |iteratedDeriv r g x|) →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv r g x| ≤ D') →
(∀ x ∈ Set.Icc (0 : ℝ) N',
|iteratedDeriv (r + (1 : ℕ)) g x| ≤ D1') →
∀ (S' : Finset ℤ),
(∀ u ∈ S', (0 : ℤ) ≤ u ∧ u ≤ ⌊N'⌋) →
(∀ u ∈ S',
∃ (v : ℤ) (w : ℕ),
(0 : ℕ) < w ∧
(↑w : ℝ) ≤ W ∧
|g (↑u : ℝ) -
(↑v : ℝ) / (↑w : ℝ)| <
δ) →
(65536 : ℝ) *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) <
(1 : ℝ) →
(↑S'.card : ℝ) <
(65536 : ℝ) * N' *
((D' * lam' ^ r * W ^ (2 : ℕ)) ^
((2 : ℝ) * (↑r : ℝ) -
(1 : ℝ))⁻¹ +
(δ * W ^ (2 : ℕ) /
(D' * lam' ^ r)) ^
((↑r : ℝ) - (1 : ℝ))⁻¹ +
(D1' * lam' * W ^ (2 : ℕ) /
D') ^
((2 : ℝ) * (↑r : ℝ))⁻¹) +
(2 : ℝ) * (↑r : ℝ) * lam' := by
have hsilr : ∀ (r : ℕ), 1 ≤ r → ∀ (s : ℕ), s = 2 * r → ∀ (M : ℝ), (s : ℝ) - 1 ≤ M →
∀ (W : ℝ), 1 ≤ W → ∀ (u : Fin s → ℤ) (w : Fin s → ℕ),
(∀ i, 0 ≤ u i ∧ (u i : ℝ) ≤ M) → StrictMono u → (∀ i, 0 < w i) → (∀ i, (w i : ℝ) ≤ W) →
∃ a : Fin s → ℤ,
(∀ (j : ℕ), j < r → ∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ j = 0) ∧
(∑ i, (a i : ℝ) * (w i : ℝ) * ((u i : ℝ)) ^ r ≠ 0) ∧
(∀ i, |(a i : ℝ)| ≤ (256 * M / (r : ℝ)) ^ (r - 1 : ℕ) * W) := by
sorry
intro r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1 f hf h1 h2 h3 S hS hS2 X hX N' hN' lam' hl1 hl2 D' hD' D1' hD1' g hg g1 g2 g3 S' hS' hS'2 hlt
have hS'sub : ↑S' ⊆ ↑(intIcc N') := by
intro u hu
obtain ⟨a, b⟩ := hS' u hu
unfold intIcc
exact Finset.mem_Icc.mpr ⟨a, b⟩
have key := lambda_one_case r hr hsilr N' hN' W hW δ hδ D' hD' D1' hD1' g hg g1 g2 g3 S' hS'sub
(fun u hu => hS'2 u hu)
have hcmp := algebraic_comparison r hr D' D1' W δ hD' hD1' hW hδ 1 lam' one_pos
(by simpa using hl1) (by norm_num; linarith)
simp only [Nat.cast_one, one_pow, one_mul] at hcmp
have hc6 : c₆ = 65536 := by
unfold c₆ C₀_const B_const K_const c₉; norm_num
rw [hc6] at hcmp
have hr0 : (0 : ℝ) ≤ 2 * (r : ℝ) := by positivity
have h2r : 2 * (r : ℝ) ≤ 2 * (r : ℝ) * lam' := by nlinarith
nlinarith [mul_le_mul_of_nonneg_left hcmp hN'.le]