Open Proof Network

Problems / erdos-1094 / erdos-1094--h2--h2--h2--h3--h1--h1

Konyagin's theorem: points where f is near a rational

erdos-1094--h2--h2--h2--h3--h1--h1

proved

Hole h_thm of erdos-1094--h2--h2--h2--h3--h1 (split by 20261015T023339Z-t1015-r-partial.lean).

$\displaystyle |S|<65536\,N\Bigl[(D_r\lambda^rW^2)^{\frac{1}{2r-1}}+\Bigl(\frac{\delta W^2}{D_r\lambda^r}\Bigr)^{\frac{1}{r-1}}+\Bigl(\frac{D_{r+1}\lambda W^2}{D_r}\Bigr)^{\frac{1}{2r}}\Bigr]+2r\lambda$

For every $r\ge 2$, $N>0$, $W\ge 1$, $\delta>0$, $\lambda\ge 1$, $D_r>0$, $D_{r+1}>0$ and every $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$ satisfies the displayed bound: Konyagin's theorem on the integer points at which a function with controlled $r$-th and $(r+1)$-th derivatives is close to a rational of bounded denominator. The Lean names $\lambda$ lam, $D_{r+1}$ D_r1 and the derivatives iteratedDeriv; $|S|$ is cast to $\mathbb{R}$, the exponents $\tfrac{1}{2r-1}$, $\tfrac{1}{r-1}$, $\tfrac{1}{2r}$ are real powers and $W^2$ a natural one.

unverified · history

Lean
theorem erdos_1094__h2__h2__h2__h3__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 : ℝ)| < δ) →
                                            (↑S.card : ℝ) <
                                              (65536 : ℝ) * 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 : ℝ))⁻¹) +
                                                (2 : ℝ) * (↑r : ℝ) * lam := by
  sorry
Why does it end in sorry?

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

How it was proved

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

The proof step by step (outline)

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

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

  1. hfl have (0 : ℤ) ≤ ⌊N⌋

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hfl : (0 : ℤ) ≤ ⌊N⌋.

    Uses library Int.floor_nonneg.

    Lean, line 43
      have hfl : (0 : ℤ) ≤ ⌊N⌋ := Int.floor_nonneg.mpr hN.le

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 43 at 3e4a866f1f30 ↗

  2. hsub have S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋.

    Uses library Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Finset.mem_Icc, And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. .

    Lean, lines 44–46
      have hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋ := fun u hu => by
        obtain ⟨a, b⟩ := hS u hu
        exact Finset.mem_Icc.mpr ⟨a, b⟩

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 44–46 at 3e4a866f1f30 ↗

    1. hsub.s1 obtain (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋

      Leaves u ∈ Finset.Icc (0 : ℤ) ⌊N⌋, with a : (0 : ℤ) ≤ u, b : u ≤ ⌊N⌋.

      Lean, line 45
          obtain ⟨a, b⟩ := hS u hu

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 45 at 3e4a866f1f30 ↗

  3. hcardZ have (↑S.card : ℤ) ≤ ⌊N⌋ + (1 : ℤ)

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hcardZ : (↑S.card : ℤ) ≤ ⌊N⌋ + (1 : ℤ).

    Uses library Int.card_Icc.

    Lean, lines 47–50
      have hcardZ : (S.card : ℤ) ≤ ⌊N⌋ + 1 := by
        have := Finset.card_le_card hsub
        rw [Int.card_Icc] at this
        omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 47–50 at 3e4a866f1f30 ↗

    1. hcardZ.this have S.card ≤ (Finset.Icc (0 : ℤ) ⌊N⌋).card

      Leaves (↑S.card : ℤ) ≤ ⌊N⌋ + (1 : ℤ), with this : S.card ≤ (Finset.Icc (0 : ℤ) ⌊N⌋).card.

      Uses library Finset.card_le_card.

      Lean, line 48
          have := Finset.card_le_card hsub

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 48 at 3e4a866f1f30 ↗

  4. hcard have (↑S.card : ℝ) ≤ N + (1 : ℝ)

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hcard : (↑S.card : ℝ) ≤ N + (1 : ℝ).

    Uses library Int.floor_le.

    Lean, lines 51–54
      have hcard : (S.card : ℝ) ≤ N + 1 := by
        have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ
        push_cast at h'
        linarith [Int.floor_le N]

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 51–54 at 3e4a866f1f30 ↗

    1. hcard.h' have (↑(↑S.card : ℤ) : ℝ) ≤ (↑(⌊N⌋ + (1 : ℤ)) : ℝ)

      Leaves (↑S.card : ℝ) ≤ N + (1 : ℝ), with h' : (↑(↑S.card : ℤ) : ℝ) ≤ (↑(⌊N⌋ + (1 : ℤ)) : ℝ).

      Lean, line 52
          have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 52 at 3e4a866f1f30 ↗

  5. hr2 have (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hr2 : (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam.

    Lean, lines 55–57
      have hr2 : (4 : ℝ) ≤ 2 * (r : ℝ) * lam := by
        have : (2 : ℝ) ≤ r := by exact_mod_cast hr
        nlinarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 55–57 at 3e4a866f1f30 ↗

    1. hr2.this have (2 : ℝ) ≤ (↑r : ℝ)

      Leaves (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam, with this : (2 : ℝ) ≤ (↑r : ℝ).

      Lean, line 56
          have : (2 : ℝ) ≤ r := by exact_mod_cast hr

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 56 at 3e4a866f1f30 ↗

  6. s6 case

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hX : (1 : ℝ) ≤ (65536 : ℝ) * X.

    Lean, lines 59–60
      · have : N ≤ 65536 * N * X := by nlinarith
        linarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 59–60 at 3e4a866f1f30 ↗

    1. s6.this have N ≤ (65536 : ℝ) * N * X routine: nlinarith

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with this : N ≤ (65536 : ℝ) * N * X.

      Lean, line 59
        · have : N ≤ 65536 * N * X := by nlinarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 59 at 3e4a866f1f30 ↗

  7. s7 case

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hX : ¬(1 : ℝ) ≤ (65536 : ℝ) * X.

    Uses library Finset.sum_const, Finset.card_range, nsmul_eq_mul.

    Lean, lines 61–261
      · push_neg at hX
        -- the remaining (hard) case, for a scale parameter in `[1, 2)`
        have core : ∀ (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
          intro N' hN' lam' hl1' hl2' D' hD' D1' hD1' g hg g1 g2 g3 S' hS' hS2' hlt
          exact erdos_1094__h2__h2__h2__h3__h1__h1__h1 r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1
            f hf h1 h2 h3 S hS hS2 (not_le.mpr hX) N' hN' lam' hl1' hl2' D' hD' D1' hD1' g hg g1 g2 g3
            S' hS' hS2' hlt
        -- reduction of a general scale `lam` to a scale in `[1, 2)` via residue classes
        set q : ℕ := ⌊lam⌋₊ with hqdef
        have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)
        have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1
        have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)
        have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam
        set lam' : ℝ := lam / q with hlam'
        have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith
        have hl2 : lam' < 2 := by
          rw [hlam', div_lt_iff₀ hqpos]
          have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
          linarith
        have hX0 : 0 ≤ X := by
          rw [hXdef]
          have := hDr.le; have := hDr1.le; have := hδ.le
          have hl0 : 0 ≤ lam := by linarith
          positivity
        have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
            (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
            (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
            = X := by
          have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
            rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
          have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
              = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
            rw [hlam']; field_simp; ring
          rw [hXdef, e2, mul_assoc D_r, e1]
        have hclass : ∀ c ∈ Finset.range q,
            ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
              < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
          intro c hc
          have hcq : c < q := Finset.mem_range.mp hc
          set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
          have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
          have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
            intro u hu
            rw [hT, Finset.mem_filter] at hu
            refine ⟨hu.1, ?_⟩
            have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
            omega
          have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
            intro u hu
            have := Int.emod_add_mul_ediv u q
            rw [(hmem u hu).2] at this
            omega
          set T' := T.image (fun u => u / (q : ℤ)) with hT'
          have hcardT : T'.card = T.card := by
            apply Finset.card_image_of_injOn
            intro u hu u' hu' huu
            simp only at huu
            rw [hdecomp u hu, hdecomp u' hu', huu]
          have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
            have : (2 : ℝ) ≤ r := by exact_mod_cast hr
            nlinarith
          have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
          by_cases hNc : (c : ℝ) < N
          · set N' : ℝ := (N - c) / q with hN'
            have hN'pos : 0 < N' := div_pos (by linarith) hqpos
            set g : ℝ → ℝ := fun t => f (c + q * t) with hg
            have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
              intro k hk t
              have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                exact this.comp (contDiff_const.add contDiff_id)
              have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
              have h2 := congrFun this t
              try simp only at h2
              rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                iteratedDeriv_comp_const_add]
            have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
              hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
            have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
              intro x hx
              obtain ⟨hx0, hx1⟩ := hx
              constructor
              · positivity
              · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                linarith
            have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
            have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
              (D_r1 * q ^ (r + 1)) (by positivity) g hgC
              (by
                intro x hx
                rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                have := h1 _ (hIcc x hx)
                nlinarith)
              (by
                intro x hx
                rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                have := h2 _ (hIcc x hx)
                nlinarith)
              (by
                intro x hx
                rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                have := h3 _ (hIcc x hx)
                have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                nlinarith)
              T'
              (by
                intro t ht
                rw [hT', Finset.mem_image] at ht
                obtain ⟨u, hu, rfl⟩ := ht
                have huS := (hmem u hu).1
                obtain ⟨hu0, hu1⟩ := hS u huS
                refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                apply Int.le_floor.mpr
                rw [hN', le_div_iff₀ hqpos]
                have hdu := hdecomp u hu
                have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                  have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                  push_cast at this
                  exact this
                have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                linarith)
              (by
                intro t ht
                rw [hT', Finset.mem_image] at ht
                obtain ⟨u, hu, rfl⟩ := ht
                obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                refine ⟨v, w, hw0, hwW, ?_⟩
                have hdu := hdecomp u hu
                have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                  have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                  push_cast at this
                  exact this.symm
                simp only [hg, hreal]
                exact hvw)
              (by rw [hXinv]; exact hX)
            rw [hXinv, hcardT] at key
            have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
              apply mul_le_mul_of_nonneg_right _ hX0
              apply mul_le_mul_of_nonneg_left _ (by norm_num)
              rw [hN']
              apply div_le_div_of_nonneg_right _ hqpos.le
              have : (0 : ℝ) ≤ c := by positivity
              linarith
            linarith
          · push_neg at hNc
            -- the class contains at most the single point `c`
            have hle : T.card ≤ 1 := by
              rw [Finset.card_le_one]
              intro u hu u' hu'
              have key : ∀ x ∈ T, x = c := by
                intro x hx
                have hxS := (hmem x hx).1
                obtain ⟨hx0, hx1⟩ := hS x hxS
                have hdx := hdecomp x hx
                have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                have hxc : x ≤ c := by
                  have : (x : ℝ) ≤ c := le_trans hxN hNc
                  exact_mod_cast this
                have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                omega
              rw [key u hu, key u' hu']
            have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
            linarith
        have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
            ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
          rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
            (t := Finset.range q)]
          · push_cast; rfl
          · intro u _
            simp only [Finset.coe_range, Set.mem_Iio]
            have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
            have h1 := Int.emod_nonneg u hqZ.ne'
            have h2 := Int.emod_lt_of_pos u hqZ
            omega
        have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass
        rw [← hsum, Finset.sum_const, Finset.card_range, nsmul_eq_mul] at hlt
        have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
            = 65536 * N * X + 2 * (r : ℝ) * lam := by
          rw [hlam']; field_simp
        linarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 61–261 at 3e4a866f1f30 ↗

    1. s7.core have ∀ (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'

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with core : ∀ (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'.

      Uses statements erdos-1094--h2--h2--h2--h3--h1--h1--h1; library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. , WithTop Attach ⊤ to a type. , Set.Icc Icc a b is the left-closed right-closed interval $[a, b]$. , iteratedDeriv The n-th iterated derivative of a function from 𝕜 to F, as a function from 𝕜 to F. , Finset Finset α is the type of finite sets of elements of α. , not_le.

      Lean, lines 63–83
          have core : ∀ (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
            intro N' hN' lam' hl1' hl2' D' hD' D1' hD1' g hg g1 g2 g3 S' hS' hS2' hlt
            exact erdos_1094__h2__h2__h2__h3__h1__h1__h1 r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1
              f hf h1 h2 h3 S hS hS2 (not_le.mpr hX) N' hN' lam' hl1' hl2' D' hD' D1' hD1' g hg g1 g2 g3
              S' hS' hS2' hlt

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 63–83 at 3e4a866f1f30 ↗

    2. s7.hq1 have (1 : ℕ) ≤ q

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hq1 : (1 : ℕ) ≤ q.

      Uses library Nat.le_floor.

      Lean, line 86
          have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 86 at 3e4a866f1f30 ↗

    3. s7.hqpos have (0 : ℝ) < (↑q : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hqpos : (0 : ℝ) < (↑q : ℝ).

      Lean, line 87
          have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 87 at 3e4a866f1f30 ↗

    4. s7.hqle have (↑q : ℝ) ≤ lam

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hqle : (↑q : ℝ) ≤ lam.

      Uses library Nat.floor_le.

      Lean, line 88
          have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 88 at 3e4a866f1f30 ↗

    5. s7.hqlt have lam < (↑q : ℝ) + (1 : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hqlt : lam < (↑q : ℝ) + (1 : ℝ).

      Uses library Nat.lt_floor_add_one.

      Lean, line 89
          have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 89 at 3e4a866f1f30 ↗

    6. s7.hl1 have (1 : ℝ) ≤ lam'

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hl1 : (1 : ℝ) ≤ lam'.

      Uses library le_div_iff₀ See le_div_iff₀' for a version with multiplication on the other side. .

      Lean, line 91
          have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 91 at 3e4a866f1f30 ↗

    7. s7.hl2 have lam' < (2 : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hl2 : lam' < (2 : ℝ).

      Uses library div_lt_iff₀ See div_lt_iff₀' for a version with multiplication on the other side. .

      Lean, lines 92–95
          have hl2 : lam' < 2 := by
            rw [hlam', div_lt_iff₀ hqpos]
            have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
            linarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 92–95 at 3e4a866f1f30 ↗

      1. s7.hl2.this have (1 : ℝ) ≤ (↑q : ℝ)

        Leaves lam < (2 : ℝ) * (↑q : ℝ), with this : (1 : ℝ) ≤ (↑q : ℝ).

        Lean, line 94
              have : (1 : ℝ) ≤ q := by exact_mod_cast hq1

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 94 at 3e4a866f1f30 ↗

    8. s7.hX0 have (0 : ℝ) ≤ X

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hX0 : (0 : ℝ) ≤ X.

      Lean, lines 96–100
          have hX0 : 0 ≤ X := by
            rw [hXdef]
            have := hDr.le; have := hDr1.le; have := hδ.le
            have hl0 : 0 ≤ lam := by linarith
            positivity

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 96–100 at 3e4a866f1f30 ↗

      1. s7.hX0.s1 have (0 : ℝ) ≤ D_r

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with this : (0 : ℝ) ≤ D_r.

        Lean, line 98
              have := hDr.le; have := hDr1.le; have := hδ.le

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 98 at 3e4a866f1f30 ↗

      2. s7.hX0.s2 have (0 : ℝ) ≤ D_r1

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with this : (0 : ℝ) ≤ D_r1.

        Lean, line 98
              have := hDr.le; have := hDr1.le; have := hδ.le

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 98 at 3e4a866f1f30 ↗

      3. s7.hX0.s3 have (0 : ℝ) ≤ δ

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with this : (0 : ℝ) ≤ δ.

        Lean, line 98
              have := hDr.le; have := hDr1.le; have := hδ.le

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 98 at 3e4a866f1f30 ↗

      4. s7.hX0.hl0 have (0 : ℝ) ≤ lam routine: linarith

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with hl0 : (0 : ℝ) ≤ lam.

        Lean, line 99
              have hl0 : 0 ≤ lam := by linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 99 at 3e4a866f1f30 ↗

    9. s7.hXinv have (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hXinv : (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X.

      Uses library mul_assoc.

      Lean, lines 101–110
          have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
              (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
              (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
              = X := by
            have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
              rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
            have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
                = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
              rw [hlam']; field_simp; ring
            rw [hXdef, e2, mul_assoc D_r, e1]

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 101–110 at 3e4a866f1f30 ↗

      1. s7.hXinv.e1 have (↑q : ℝ) ^ r * lam' ^ r = lam ^ r

        Leaves (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X, with e1 : (↑q : ℝ) ^ r * lam' ^ r = lam ^ r.

        Uses library mul_pow, mul_div_cancel₀.

        Lean, lines 105–106
              have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
                rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 105–106 at 3e4a866f1f30 ↗

      2. s7.hXinv.e2 have D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r) = D_r1 * lam * W ^ (2 : ℕ) / D_r

        Leaves (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X, with e2 : D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r) = D_r1 * lam * W ^ (2 : ℕ) / D_r.

        Lean, lines 107–109
              have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
                  = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
                rw [hlam']; field_simp; ring

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 107–109 at 3e4a866f1f30 ↗

    10. s7.hclass have ∀ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam'

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hclass : ∀ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam'.

      Uses library Finset.range range n is the set of natural numbers less than n. .

      Lean, lines 111–244
          have hclass : ∀ c ∈ Finset.range q,
              ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
                < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
            intro c hc
            have hcq : c < q := Finset.mem_range.mp hc
            set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
            have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
            have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
              intro u hu
              rw [hT, Finset.mem_filter] at hu
              refine ⟨hu.1, ?_⟩
              have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
              omega
            have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
              intro u hu
              have := Int.emod_add_mul_ediv u q
              rw [(hmem u hu).2] at this
              omega
            set T' := T.image (fun u => u / (q : ℤ)) with hT'
            have hcardT : T'.card = T.card := by
              apply Finset.card_image_of_injOn
              intro u hu u' hu' huu
              simp only at huu
              rw [hdecomp u hu, hdecomp u' hu', huu]
            have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
              have : (2 : ℝ) ≤ r := by exact_mod_cast hr
              nlinarith
            have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
            by_cases hNc : (c : ℝ) < N
            · set N' : ℝ := (N - c) / q with hN'
              have hN'pos : 0 < N' := div_pos (by linarith) hqpos
              set g : ℝ → ℝ := fun t => f (c + q * t) with hg
              have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                  = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
                intro k hk t
                have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                  have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                  exact this.comp (contDiff_const.add contDiff_id)
                have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
                have h2 := congrFun this t
                try simp only at h2
                rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                  iteratedDeriv_comp_const_add]
              have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
                hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
              have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
                intro x hx
                obtain ⟨hx0, hx1⟩ := hx
                constructor
                · positivity
                · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                  rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                  linarith
              have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
              have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
                (D_r1 * q ^ (r + 1)) (by positivity) g hgC
                (by
                  intro x hx
                  rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                  have := h1 _ (hIcc x hx)
                  nlinarith)
                (by
                  intro x hx
                  rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                  have := h2 _ (hIcc x hx)
                  nlinarith)
                (by
                  intro x hx
                  rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                  have := h3 _ (hIcc x hx)
                  have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                  nlinarith)
                T'
                (by
                  intro t ht
                  rw [hT', Finset.mem_image] at ht
                  obtain ⟨u, hu, rfl⟩ := ht
                  have huS := (hmem u hu).1
                  obtain ⟨hu0, hu1⟩ := hS u huS
                  refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                  apply Int.le_floor.mpr
                  rw [hN', le_div_iff₀ hqpos]
                  have hdu := hdecomp u hu
                  have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                    have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                    push_cast at this
                    exact this
                  have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                  linarith)
                (by
                  intro t ht
                  rw [hT', Finset.mem_image] at ht
                  obtain ⟨u, hu, rfl⟩ := ht
                  obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                  refine ⟨v, w, hw0, hwW, ?_⟩
                  have hdu := hdecomp u hu
                  have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                    have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                    push_cast at this
                    exact this.symm
                  simp only [hg, hreal]
                  exact hvw)
                (by rw [hXinv]; exact hX)
              rw [hXinv, hcardT] at key
              have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
                apply mul_le_mul_of_nonneg_right _ hX0
                apply mul_le_mul_of_nonneg_left _ (by norm_num)
                rw [hN']
                apply div_le_div_of_nonneg_right _ hqpos.le
                have : (0 : ℝ) ≤ c := by positivity
                linarith
              linarith
            · push_neg at hNc
              -- the class contains at most the single point `c`
              have hle : T.card ≤ 1 := by
                rw [Finset.card_le_one]
                intro u hu u' hu'
                have key : ∀ x ∈ T, x = c := by
                  intro x hx
                  have hxS := (hmem x hx).1
                  obtain ⟨hx0, hx1⟩ := hS x hxS
                  have hdx := hdecomp x hx
                  have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                  have hxc : x ≤ c := by
                    have : (x : ℝ) ≤ c := le_trans hxN hNc
                    exact_mod_cast this
                  have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                  have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                  have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                  have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                  omega
                rw [key u hu, key u' hu']
              have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
              linarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 111–244 at 3e4a866f1f30 ↗

      1. s7.hclass.hcq have c < q

        Leaves (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hcq : c < q.

        Uses library Finset.mem_range.

        Lean, line 115
              have hcq : c < q := Finset.mem_range.mp hc

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 115 at 3e4a866f1f30 ↗

      2. s7.hclass.hqZ have (0 : ℤ) < (↑q : ℤ)

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hqZ : (0 : ℤ) < (↑q : ℤ).

        Lean, line 117
              have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 117 at 3e4a866f1f30 ↗

      3. s7.hclass.hmem have ∀ u ∈ T, u ∈ S ∧ u % (↑q : ℤ) = (↑c : ℤ)

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hmem : ∀ u ∈ T, u ∈ S ∧ u % (↑q : ℤ) = (↑c : ℤ).

        Uses library Finset.mem_filter, And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. .

        Lean, lines 118–123
              have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
                intro u hu
                rw [hT, Finset.mem_filter] at hu
                refine ⟨hu.1, ?_⟩
                have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
                omega

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 118–123 at 3e4a866f1f30 ↗

        1. s7.hclass.hmem.h0 have (0 : ℤ) ≤ u % (↑q : ℤ)

          Leaves u % (↑q : ℤ) = (↑c : ℤ), with h0 : (0 : ℤ) ≤ u % (↑q : ℤ).

          Uses library Int.emod_nonneg.

          Lean, line 122
                  have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 122 at 3e4a866f1f30 ↗

      4. s7.hclass.hdecomp have ∀ u ∈ T, u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hdecomp : ∀ u ∈ T, u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)).

        Lean, lines 124–128
              have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
                intro u hu
                have := Int.emod_add_mul_ediv u q
                rw [(hmem u hu).2] at this
                omega

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 124–128 at 3e4a866f1f30 ↗

        1. s7.hclass.hdecomp.this have u % (↑q : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)) = u

          Leaves u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)), with this : u % (↑q : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)) = u.

          Uses library Int.emod_add_mul_ediv.

          Lean, line 126
                  have := Int.emod_add_mul_ediv u q

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 126 at 3e4a866f1f30 ↗

      5. s7.hclass.hcardT have T'.card = T.card

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hcardT : T'.card = T.card.

        Uses library Finset.card_image_of_injOn.

        Lean, lines 130–134
              have hcardT : T'.card = T.card := by
                apply Finset.card_image_of_injOn
                intro u hu u' hu' huu
                simp only at huu
                rw [hdecomp u hu, hdecomp u' hu', huu]

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 130–134 at 3e4a866f1f30 ↗

      6. s7.hclass.hlam'pos have (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hlam'pos : (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'.

        Lean, lines 135–137
              have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
                have : (2 : ℝ) ≤ r := by exact_mod_cast hr
                nlinarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 135–137 at 3e4a866f1f30 ↗

        1. s7.hclass.hlam'pos.this have (2 : ℝ) ≤ (↑r : ℝ)

          Leaves (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam', with this : (2 : ℝ) ≤ (↑r : ℝ).

          Lean, line 136
                  have : (2 : ℝ) ≤ r := by exact_mod_cast hr

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 136 at 3e4a866f1f30 ↗

      7. s7.hclass.hNq have (0 : ℝ) ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X routine: positivity

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hNq : (0 : ℝ) ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X.

        Lean, line 138
              have hNq : 0 ≤ 65536 * (N / q) * X := by positivity

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 138 at 3e4a866f1f30 ↗

      8. s7.hclass.s8 case

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hNc : (↑c : ℝ) < N.

        Lean, lines 140–222
              · set N' : ℝ := (N - c) / q with hN'
                have hN'pos : 0 < N' := div_pos (by linarith) hqpos
                set g : ℝ → ℝ := fun t => f (c + q * t) with hg
                have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                    = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
                  intro k hk t
                  have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                    have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                    exact this.comp (contDiff_const.add contDiff_id)
                  have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
                  have h2 := congrFun this t
                  try simp only at h2
                  rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                    iteratedDeriv_comp_const_add]
                have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
                  hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
                have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
                  intro x hx
                  obtain ⟨hx0, hx1⟩ := hx
                  constructor
                  · positivity
                  · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                    rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                    linarith
                have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
                have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
                  (D_r1 * q ^ (r + 1)) (by positivity) g hgC
                  (by
                    intro x hx
                    rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                    have := h1 _ (hIcc x hx)
                    nlinarith)
                  (by
                    intro x hx
                    rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                    have := h2 _ (hIcc x hx)
                    nlinarith)
                  (by
                    intro x hx
                    rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                    have := h3 _ (hIcc x hx)
                    have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                    nlinarith)
                  T'
                  (by
                    intro t ht
                    rw [hT', Finset.mem_image] at ht
                    obtain ⟨u, hu, rfl⟩ := ht
                    have huS := (hmem u hu).1
                    obtain ⟨hu0, hu1⟩ := hS u huS
                    refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                    apply Int.le_floor.mpr
                    rw [hN', le_div_iff₀ hqpos]
                    have hdu := hdecomp u hu
                    have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                      have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                      push_cast at this
                      exact this
                    have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                    linarith)
                  (by
                    intro t ht
                    rw [hT', Finset.mem_image] at ht
                    obtain ⟨u, hu, rfl⟩ := ht
                    obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                    refine ⟨v, w, hw0, hwW, ?_⟩
                    have hdu := hdecomp u hu
                    have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                      have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                      push_cast at this
                      exact this.symm
                    simp only [hg, hreal]
                    exact hvw)
                  (by rw [hXinv]; exact hX)
                rw [hXinv, hcardT] at key
                have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
                  apply mul_le_mul_of_nonneg_right _ hX0
                  apply mul_le_mul_of_nonneg_left _ (by norm_num)
                  rw [hN']
                  apply div_le_div_of_nonneg_right _ hqpos.le
                  have : (0 : ℝ) ≤ c := by positivity
                  linarith
                linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 140–222 at 3e4a866f1f30 ↗

        1. s7.hclass.s8.hN'pos have (0 : ℝ) < N'

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hN'pos : (0 : ℝ) < N'.

          Uses library div_pos.

          Lean, line 141
                  have hN'pos : 0 < N' := div_pos (by linarith) hqpos

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 141 at 3e4a866f1f30 ↗

        2. s7.hclass.s8.hgfun have ∀ k ≤ r + (1 : ℕ), ∀ (t : ℝ), iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t)

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hgfun : ∀ k ≤ r + (1 : ℕ), ∀ (t : ℝ), iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t).

          Uses library iteratedDeriv The n-th iterated derivative of a function from 𝕜 to F, as a function from 𝕜 to F. , rfl rfl : a = a is the unique constructor of the equality type. , iteratedDeriv_comp_const_add The iterated derivative commutes with shifting the function by a constant on the left. .

          Lean, lines 143–153
                  have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                      = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
                    intro k hk t
                    have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                      have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                      exact this.comp (contDiff_const.add contDiff_id)
                    have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
                    have h2 := congrFun this t
                    try simp only at h2
                    rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                      iteratedDeriv_comp_const_add]

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 143–153 at 3e4a866f1f30 ↗

          1. s7.hclass.s8.hgfun.hf1 have ContDiff ℝ (↑k : WithTop ℕ∞) fun (z : ℝ) => f ((↑c : ℝ) + z)

            Leaves iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t), with hf1 : ContDiff ℝ (↑k : WithTop ℕ∞) fun (z : ℝ) => f ((↑c : ℝ) + z).

            Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. , contDiff_const Constants are C^∞. , contDiff_id The identity is C^n. .

            Lean, lines 146–148
                      have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                        have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                        exact this.comp (contDiff_const.add contDiff_id)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 146–148 at 3e4a866f1f30 ↗

            1. s7.hclass.s8.hgfun.hf1.this have ContDiff ℝ (↑k : WithTop ℕ∞) f

              Leaves ContDiff ℝ (↑k : WithTop ℕ∞) fun (z : ℝ) => f ((↑c : ℝ) + z), with this : ContDiff ℝ (↑k : WithTop ℕ∞) f.

              Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. .

              Lean, line 147
                          have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 147 at 3e4a866f1f30 ↗

          2. s7.hclass.s8.hgfun.this have (iteratedDeriv k fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) = fun (x : ℝ) => (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * x)

            Leaves iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t), with this : (iteratedDeriv k fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) = fun (x : ℝ) => (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * x).

            Uses library iteratedDeriv_comp_const_mul.

            Lean, line 149
                      have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 149 at 3e4a866f1f30 ↗

          3. s7.hclass.s8.hgfun.h2 have iteratedDeriv k (fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) t = (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * t)

            Leaves iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t), with h2 : iteratedDeriv k (fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) t = (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * t).

            Uses library congrFun Congruence in the function part of an application: If f = g then f a = g a. .

            Lean, line 150
                      have h2 := congrFun this t

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 150 at 3e4a866f1f30 ↗

        3. s7.hclass.s8.hgC have ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g.

          Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. , WithTop Attach ⊤ to a type. , contDiff_const Constants are C^∞. , contDiff_id The identity is C^n. .

          Lean, lines 154–155
                  have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
                    hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 154–155 at 3e4a866f1f30 ↗

        4. s7.hclass.s8.hIcc have ∀ x ∈ Set.Icc (0 : ℝ) N', (↑c : ℝ) + (↑q : ℝ) * x ∈ Set.Icc (0 : ℝ) N

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (↑c : ℝ) + (↑q : ℝ) * x ∈ Set.Icc (0 : ℝ) N.

          Uses library Set.Icc Icc a b is the left-closed right-closed interval $[a, b]$. .

          Lean, lines 156–163
                  have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
                    intro x hx
                    obtain ⟨hx0, hx1⟩ := hx
                    constructor
                    · positivity
                    · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                      rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                      linarith

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 156–163 at 3e4a866f1f30 ↗

          1. s7.hclass.s8.hIcc.s1 obtain x ∈ Set.Icc (0 : ℝ) N'

            Leaves (↑c : ℝ) + (↑q : ℝ) * x ∈ Set.Icc (0 : ℝ) N, with hx0 : (0 : ℝ) ≤ x, hx1 : x ≤ N'.

            Lean, line 158
                      obtain ⟨hx0, hx1⟩ := hx

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 158 at 3e4a866f1f30 ↗

          2. s7.hclass.s8.hIcc.s2 case routine: positivity

            Leaves (0 : ℝ) ≤ (↑c : ℝ) + (↑q : ℝ) * x.

            Lean, line 160
                      · positivity

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 160 at 3e4a866f1f30 ↗

          3. s7.hclass.s8.hIcc.s3 case

            Leaves (↑c : ℝ) + (↑q : ℝ) * x ≤ N.

            Uses library mul_div_cancel₀.

            Lean, lines 161–163
                      · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                        rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                        linarith

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 161–163 at 3e4a866f1f30 ↗

            1. s7.hclass.s8.hIcc.s3.this have (↑q : ℝ) * x ≤ (↑q : ℝ) * N'

              Leaves (↑c : ℝ) + (↑q : ℝ) * x ≤ N, with this : (↑q : ℝ) * x ≤ (↑q : ℝ) * N'.

              Uses library mul_le_mul_of_nonneg_left.

              Lean, line 161
                        · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 161 at 3e4a866f1f30 ↗

        5. s7.hclass.s8.hqr have (0 : ℝ) < (↑q : ℝ) ^ r

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hqr : (0 : ℝ) < (↑q : ℝ) ^ r.

          Uses library pow_pos.

          Lean, line 164
                  have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 164 at 3e4a866f1f30 ↗

        6. s7.hclass.s8.key have (↑T'.card : ℝ) < (65536 : ℝ) * N' * ((D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam'

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with key : (↑T'.card : ℝ) < (65536 : ℝ) * N' * ((D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam'.

          Uses library abs_mul, abs_of_pos, le_rfl A version of le_refl where the argument is implicit , pow_pos, Finset.mem_image, And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. , Int.ediv_nonneg, Int.le_floor, le_div_iff₀ See le_div_iff₀' for a version with multiplication on the other side. , Exists.intro Existential introduction. .

          Lean, lines 165–213
                  have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
                    (D_r1 * q ^ (r + 1)) (by positivity) g hgC
                    (by
                      intro x hx
                      rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                      have := h1 _ (hIcc x hx)
                      nlinarith)
                    (by
                      intro x hx
                      rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                      have := h2 _ (hIcc x hx)
                      nlinarith)
                    (by
                      intro x hx
                      rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                      have := h3 _ (hIcc x hx)
                      have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                      nlinarith)
                    T'
                    (by
                      intro t ht
                      rw [hT', Finset.mem_image] at ht
                      obtain ⟨u, hu, rfl⟩ := ht
                      have huS := (hmem u hu).1
                      obtain ⟨hu0, hu1⟩ := hS u huS
                      refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                      apply Int.le_floor.mpr
                      rw [hN', le_div_iff₀ hqpos]
                      have hdu := hdecomp u hu
                      have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                        have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                        push_cast at this
                        exact this
                      have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                      linarith)
                    (by
                      intro t ht
                      rw [hT', Finset.mem_image] at ht
                      obtain ⟨u, hu, rfl⟩ := ht
                      obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                      refine ⟨v, w, hw0, hwW, ?_⟩
                      have hdu := hdecomp u hu
                      have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                        have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                        push_cast at this
                        exact this.symm
                      simp only [hg, hreal]
                      exact hvw)
                    (by rw [hXinv]; exact hX)

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 165–213 at 3e4a866f1f30 ↗

          1. s7.hclass.s8.key.s1 have D_r / (2 : ℝ) ≤ |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)|

            Leaves D_r * (↑q : ℝ) ^ r / (2 : ℝ) ≤ (↑q : ℝ) ^ r * |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)|, with this : D_r / (2 : ℝ) ≤ |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)|.

            Lean, line 170
                        have := h1 _ (hIcc x hx)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 170 at 3e4a866f1f30 ↗

          2. s7.hclass.s8.key.s2 have |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r

            Leaves (↑q : ℝ) ^ r * |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r * (↑q : ℝ) ^ r, with this : |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r.

            Lean, line 175
                        have := h2 _ (hIcc x hx)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 175 at 3e4a866f1f30 ↗

          3. s7.hclass.s8.key.s3 have |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1

            Leaves (↑q : ℝ) ^ (r + (1 : ℕ)) * |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)), with this : |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1.

            Lean, line 180
                        have := h3 _ (hIcc x hx)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 180 at 3e4a866f1f30 ↗

          4. s7.hclass.s8.key.s4 have (0 : ℝ) < (↑q : ℝ) ^ (r + (1 : ℕ))

            Leaves (↑q : ℝ) ^ (r + (1 : ℕ)) * |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)), with this : (0 : ℝ) < (↑q : ℝ) ^ (r + (1 : ℕ)).

            Uses library pow_pos.

            Lean, line 181
                        have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 181 at 3e4a866f1f30 ↗

          5. s7.hclass.s8.key.s5 obtain ∃ a ∈ T, a / (↑q : ℤ) = t

            Leaves (0 : ℤ) ≤ u / (↑q : ℤ) ∧ u / (↑q : ℤ) ≤ ⌊N'⌋, with u : ℤ, hu : u ∈ T.

            Lean, line 187
                        obtain ⟨u, hu, rfl⟩ := ht

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 187 at 3e4a866f1f30 ↗

          6. s7.hclass.s8.key.huS have u ∈ S

            Leaves (0 : ℤ) ≤ u / (↑q : ℤ) ∧ u / (↑q : ℤ) ≤ ⌊N'⌋, with huS : u ∈ S.

            Lean, line 188
                        have huS := (hmem u hu).1

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 188 at 3e4a866f1f30 ↗

          7. s7.hclass.s8.key.s7 obtain (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋

            Leaves (0 : ℤ) ≤ u / (↑q : ℤ) ∧ u / (↑q : ℤ) ≤ ⌊N'⌋, with hu0 : (0 : ℤ) ≤ u, hu1 : u ≤ ⌊N⌋.

            Lean, line 189
                        obtain ⟨hu0, hu1⟩ := hS u huS

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 189 at 3e4a866f1f30 ↗

          8. s7.hclass.s8.key.s8 have u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))

            Leaves (↑(u / (↑q : ℤ)) : ℝ) * (↑q : ℝ) ≤ N - (↑c : ℝ), with hdu : u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)).

            Lean, line 193
                        have hdu := hdecomp u hu

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 193 at 3e4a866f1f30 ↗

          9. s7.hclass.s8.key.s9 have (↑u : ℝ) = (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ)

            Leaves (↑(u / (↑q : ℤ)) : ℝ) * (↑q : ℝ) ≤ N - (↑c : ℝ), with hreal : (↑u : ℝ) = (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ).

            Lean, lines 194–197
                        have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                          have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                          push_cast at this
                          exact this

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 194–197 at 3e4a866f1f30 ↗

            1. s7.hclass.s8.key.s9.this have (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ)

              Leaves (↑u : ℝ) = (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ), with this : (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ).

              Uses library congrArg Congruence in the function argument: if a₁ = a₂ then f a₁ = f a₂ for any (nondependent) function f. .

              Lean, line 195
                            have := congrArg (fun z : ℤ => (z : ℝ)) hdu

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 195 at 3e4a866f1f30 ↗

          10. s7.hclass.s8.key.s10 have (↑u : ℝ) ≤ N

            Leaves (↑(u / (↑q : ℤ)) : ℝ) * (↑q : ℝ) ≤ N - (↑c : ℝ), with this : (↑u : ℝ) ≤ N.

            Uses library le_trans The relation ≤ on a preorder is transitive. , Int.floor_le.

            Lean, line 198
                        have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 198 at 3e4a866f1f30 ↗

          11. s7.hclass.s8.key.s11 obtain ∃ a ∈ T, a / (↑q : ℤ) = t

            Leaves ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with u : ℤ, hu : u ∈ T.

            Lean, line 203
                        obtain ⟨u, hu, rfl⟩ := ht

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 203 at 3e4a866f1f30 ↗

          12. s7.hclass.s8.key.s12 obtain ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ

            Leaves ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with v : ℤ, w : ℕ, hw0 : (0 : ℕ) < w, hwW : (↑w : ℝ) ≤ W, hvw : |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ.

            Lean, line 204
                        obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 204 at 3e4a866f1f30 ↗

          13. s7.hclass.s8.key.s13 have u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))

            Leaves |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with hdu : u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)).

            Lean, line 206
                        have hdu := hdecomp u hu

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 206 at 3e4a866f1f30 ↗

          14. s7.hclass.s8.key.s14 have (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ) = (↑u : ℝ)

            Leaves |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with hreal : (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ) = (↑u : ℝ).

            Lean, lines 207–210
                        have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                          have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                          push_cast at this
                          exact this.symm

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 207–210 at 3e4a866f1f30 ↗

            1. s7.hclass.s8.key.s14.this have (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ)

              Leaves (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ) = (↑u : ℝ), with this : (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ).

              Uses library congrArg Congruence in the function argument: if a₁ = a₂ then f a₁ = f a₂ for any (nondependent) function f. .

              Lean, line 208
                            have := congrArg (fun z : ℤ => (z : ℝ)) hdu

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 208 at 3e4a866f1f30 ↗

        7. s7.hclass.s8.this have (65536 : ℝ) * N' * X ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with this : (65536 : ℝ) * N' * X ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X.

          Uses library mul_le_mul_of_nonneg_right, mul_le_mul_of_nonneg_left, div_le_div_of_nonneg_right.

          Lean, lines 215–221
                  have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
                    apply mul_le_mul_of_nonneg_right _ hX0
                    apply mul_le_mul_of_nonneg_left _ (by norm_num)
                    rw [hN']
                    apply div_le_div_of_nonneg_right _ hqpos.le
                    have : (0 : ℝ) ≤ c := by positivity
                    linarith

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 215–221 at 3e4a866f1f30 ↗

          1. s7.hclass.s8.this.this have (0 : ℝ) ≤ (↑c : ℝ) routine: positivity

            Leaves N - (↑c : ℝ) ≤ N, with this : (0 : ℝ) ≤ (↑c : ℝ).

            Lean, line 220
                      have : (0 : ℝ) ≤ c := by positivity

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 220 at 3e4a866f1f30 ↗

      9. s7.hclass.s9 case

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hNc : ¬(↑c : ℝ) < N.

        Lean, lines 223–244
              · push_neg at hNc
                -- the class contains at most the single point `c`
                have hle : T.card ≤ 1 := by
                  rw [Finset.card_le_one]
                  intro u hu u' hu'
                  have key : ∀ x ∈ T, x = c := by
                    intro x hx
                    have hxS := (hmem x hx).1
                    obtain ⟨hx0, hx1⟩ := hS x hxS
                    have hdx := hdecomp x hx
                    have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                    have hxc : x ≤ c := by
                      have : (x : ℝ) ≤ c := le_trans hxN hNc
                      exact_mod_cast this
                    have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                    have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                    have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                    have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                    omega
                  rw [key u hu, key u' hu']
                have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
                linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 223–244 at 3e4a866f1f30 ↗

        1. s7.hclass.s9.hle have T.card ≤ (1 : ℕ)

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hle : T.card ≤ (1 : ℕ).

          Uses library Finset.card_le_one.

          Lean, lines 225–242
                  have hle : T.card ≤ 1 := by
                    rw [Finset.card_le_one]
                    intro u hu u' hu'
                    have key : ∀ x ∈ T, x = c := by
                      intro x hx
                      have hxS := (hmem x hx).1
                      obtain ⟨hx0, hx1⟩ := hS x hxS
                      have hdx := hdecomp x hx
                      have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                      have hxc : x ≤ c := by
                        have : (x : ℝ) ≤ c := le_trans hxN hNc
                        exact_mod_cast this
                      have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                      have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                      have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                      have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                      omega
                    rw [key u hu, key u' hu']

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 225–242 at 3e4a866f1f30 ↗

          1. s7.hclass.s9.hle.key have ∀ x ∈ T, x = (↑c : ℤ)

            Leaves u = u', with key : ∀ x ∈ T, x = (↑c : ℤ).

            Lean, lines 228–241
                      have key : ∀ x ∈ T, x = c := by
                        intro x hx
                        have hxS := (hmem x hx).1
                        obtain ⟨hx0, hx1⟩ := hS x hxS
                        have hdx := hdecomp x hx
                        have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                        have hxc : x ≤ c := by
                          have : (x : ℝ) ≤ c := le_trans hxN hNc
                          exact_mod_cast this
                        have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                        have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                        have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                        have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                        omega

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 228–241 at 3e4a866f1f30 ↗

            1. s7.hclass.s9.hle.key.hxS have x ∈ S

              Leaves x = (↑c : ℤ), with hxS : x ∈ S.

              Lean, line 230
                          have hxS := (hmem x hx).1

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 230 at 3e4a866f1f30 ↗

            2. s7.hclass.s9.hle.key.s2 obtain (0 : ℤ) ≤ x ∧ x ≤ ⌊N⌋

              Leaves x = (↑c : ℤ), with hx0 : (0 : ℤ) ≤ x, hx1 : x ≤ ⌊N⌋.

              Lean, line 231
                          obtain ⟨hx0, hx1⟩ := hS x hxS

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 231 at 3e4a866f1f30 ↗

            3. s7.hclass.s9.hle.key.hdx have x = (↑c : ℤ) + (↑q : ℤ) * (x / (↑q : ℤ))

              Leaves x = (↑c : ℤ), with hdx : x = (↑c : ℤ) + (↑q : ℤ) * (x / (↑q : ℤ)).

              Lean, line 232
                          have hdx := hdecomp x hx

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 232 at 3e4a866f1f30 ↗

            4. s7.hclass.s9.hle.key.hxN have (↑x : ℝ) ≤ N

              Leaves x = (↑c : ℤ), with hxN : (↑x : ℝ) ≤ N.

              Uses library le_trans The relation ≤ on a preorder is transitive. , Int.floor_le.

              Lean, line 233
                          have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 233 at 3e4a866f1f30 ↗

            5. s7.hclass.s9.hle.key.hxc have x ≤ (↑c : ℤ)

              Leaves x = (↑c : ℤ), with hxc : x ≤ (↑c : ℤ).

              Lean, lines 234–236
                          have hxc : x ≤ c := by
                            have : (x : ℝ) ≤ c := le_trans hxN hNc
                            exact_mod_cast this

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 234–236 at 3e4a866f1f30 ↗

              1. s7.hclass.s9.hle.key.hxc.this have (↑x : ℝ) ≤ (↑c : ℝ)

                Leaves x ≤ (↑c : ℤ), with this : (↑x : ℝ) ≤ (↑c : ℝ).

                Uses library le_trans The relation ≤ on a preorder is transitive. .

                Lean, line 235
                              have : (x : ℝ) ≤ c := le_trans hxN hNc

                targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 235 at 3e4a866f1f30 ↗

            6. s7.hclass.s9.hle.key.hcq' have (↑c : ℤ) < (↑q : ℤ)

              Leaves x = (↑c : ℤ), with hcq' : (↑c : ℤ) < (↑q : ℤ).

              Lean, line 237
                          have hcq' : (c : ℤ) < q := by exact_mod_cast hcq

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 237 at 3e4a866f1f30 ↗

            7. s7.hclass.s9.hle.key.hdvd have (↑q : ℤ) ∣ x - (↑c : ℤ)

              Leaves x = (↑c : ℤ), with hdvd : (↑q : ℤ) ∣ x - (↑c : ℤ).

              Uses library Exists.intro Existential introduction. .

              Lean, line 238
                          have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 238 at 3e4a866f1f30 ↗

            8. s7.hclass.s9.hle.key.habs have |x - (↑c : ℤ)| < (↑q : ℤ)

              Leaves x = (↑c : ℤ), with habs : |x - (↑c : ℤ)| < (↑q : ℤ).

              Uses library abs_lt.

              Lean, line 239
                          have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 239 at 3e4a866f1f30 ↗

            9. s7.hclass.s9.hle.key.this have x - (↑c : ℤ) = (0 : ℤ)

              Leaves x = (↑c : ℤ), with this : x - (↑c : ℤ) = (0 : ℤ).

              Uses library Int.eq_zero_of_abs_lt_dvd.

              Lean, line 240
                          have := Int.eq_zero_of_abs_lt_dvd hdvd habs

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 240 at 3e4a866f1f30 ↗

        2. s7.hclass.s9.this have (↑T.card : ℝ) ≤ (1 : ℝ)

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with this : (↑T.card : ℝ) ≤ (1 : ℝ).

          Lean, line 243
                  have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 243 at 3e4a866f1f30 ↗

    11. s7.hsum have (↑S.card : ℝ) = ∑ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hsum : (↑S.card : ℝ) = ∑ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ).

      Uses library Finset.range range n is the set of natural numbers less than n. , Finset.card_eq_sum_card_fiberwise.

      Lean, lines 245–255
          have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
              ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
            rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
              (t := Finset.range q)]
            · push_cast; rfl
            · intro u _
              simp only [Finset.coe_range, Set.mem_Iio]
              have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
              have h1 := Int.emod_nonneg u hqZ.ne'
              have h2 := Int.emod_lt_of_pos u hqZ
              omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 245–255 at 3e4a866f1f30 ↗

      1. s7.hsum.s1 case

        Leaves (↑(∑ b ∈ Finset.range q, {a ∈ S | (a % (↑q : ℤ)).toNat = b}.card) : ℝ) = ∑ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ).

        Lean, line 249
              · push_cast; rfl

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 249 at 3e4a866f1f30 ↗

      2. s7.hsum.s2 case

        Leaves Set.MapsTo (fun (u : ℤ) => (u % (↑q : ℤ)).toNat) (↑S : Set ℤ) (↑(Finset.range q) : Set ℕ).

        Uses library Finset.coe_range, Set.mem_Iio.

        Lean, lines 250–255
              · intro u _
                simp only [Finset.coe_range, Set.mem_Iio]
                have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
                have h1 := Int.emod_nonneg u hqZ.ne'
                have h2 := Int.emod_lt_of_pos u hqZ
                omega

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 250–255 at 3e4a866f1f30 ↗

        1. s7.hsum.s2.hqZ have (0 : ℤ) < (↑q : ℤ)

          Leaves (u % (↑q : ℤ)).toNat < q, with hqZ : (0 : ℤ) < (↑q : ℤ).

          Lean, line 252
                  have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 252 at 3e4a866f1f30 ↗

        2. s7.hsum.s2.h1 have (0 : ℤ) ≤ u % (↑q : ℤ)

          Leaves (u % (↑q : ℤ)).toNat < q, with h1 : (0 : ℤ) ≤ u % (↑q : ℤ).

          Uses library Int.emod_nonneg.

          Lean, line 253
                  have h1 := Int.emod_nonneg u hqZ.ne'

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 253 at 3e4a866f1f30 ↗

        3. s7.hsum.s2.h2 have u % (↑q : ℤ) < (↑q : ℤ)

          Leaves (u % (↑q : ℤ)).toNat < q, with h2 : u % (↑q : ℤ) < (↑q : ℤ).

          Uses library Int.emod_lt_of_pos.

          Lean, line 254
                  have h2 := Int.emod_lt_of_pos u hqZ

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 254 at 3e4a866f1f30 ↗

    12. s7.hlt have ∑ i ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = i}.card : ℝ) < ∑ i ∈ Finset.range q, ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam')

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hlt : ∑ i ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = i}.card : ℝ) < ∑ i ∈ Finset.range q, ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam').

      Uses library Finset.sum_lt_sum_of_nonempty In an ordered additive commutative monoid, if each summand f i of one nontrivial finite sum is strictly less than the corresponding summand g i of another nontrivial finite sum, then s.sum f < s.sum g. , Finset.nonempty_range_iff.

      Lean, line 256
          have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, line 256 at 3e4a866f1f30 ↗

    13. s7.this have (↑q : ℝ) * ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam') = (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with this : (↑q : ℝ) * ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam') = (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam.

      Lean, lines 258–260
          have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
              = 65536 * N * X + 2 * (r : ℝ) * lam := by
            rw [hlam']; field_simp

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Proof.lean, lines 258–260 at 3e4a866f1f30 ↗

The proof in Lean (Proof.lean)

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

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

open scoped Nat

/-! Hole `h_thm` 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 : ∀ (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 : ℝ)| < δ) →
                                            (↑S.card : ℝ) <
                                              (65536 : ℝ) * 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 : ℝ))⁻¹) +
                                                (2 : ℝ) * (↑r : ℝ) * lam := by
  intro r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1 f hf h1 h2 h3 S hS hS2
  set 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 : ℝ))⁻¹ with hXdef
  have hfl : (0 : ℤ) ≤ ⌊N⌋ := Int.floor_nonneg.mpr hN.le
  have hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋ := fun u hu => by
    obtain ⟨a, b⟩ := hS u hu
    exact Finset.mem_Icc.mpr ⟨a, b⟩
  have hcardZ : (S.card : ℤ) ≤ ⌊N⌋ + 1 := by
    have := Finset.card_le_card hsub
    rw [Int.card_Icc] at this
    omega
  have hcard : (S.card : ℝ) ≤ N + 1 := by
    have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ
    push_cast at h'
    linarith [Int.floor_le N]
  have hr2 : (4 : ℝ) ≤ 2 * (r : ℝ) * lam := by
    have : (2 : ℝ) ≤ r := by exact_mod_cast hr
    nlinarith
  by_cases hX : 1 ≤ 65536 * X
  · have : N ≤ 65536 * N * X := by nlinarith
    linarith
  · push_neg at hX
    -- the remaining (hard) case, for a scale parameter in `[1, 2)`
    have core : ∀ (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
      intro N' hN' lam' hl1' hl2' D' hD' D1' hD1' g hg g1 g2 g3 S' hS' hS2' hlt
      exact erdos_1094__h2__h2__h2__h3__h1__h1__h1 r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1
        f hf h1 h2 h3 S hS hS2 (not_le.mpr hX) N' hN' lam' hl1' hl2' D' hD' D1' hD1' g hg g1 g2 g3
        S' hS' hS2' hlt
    -- reduction of a general scale `lam` to a scale in `[1, 2)` via residue classes
    set q : ℕ := ⌊lam⌋₊ with hqdef
    have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)
    have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1
    have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)
    have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam
    set lam' : ℝ := lam / q with hlam'
    have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith
    have hl2 : lam' < 2 := by
      rw [hlam', div_lt_iff₀ hqpos]
      have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
      linarith
    have hX0 : 0 ≤ X := by
      rw [hXdef]
      have := hDr.le; have := hDr1.le; have := hδ.le
      have hl0 : 0 ≤ lam := by linarith
      positivity
    have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
        (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
        (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
        = X := by
      have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
        rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
      have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
          = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
        rw [hlam']; field_simp; ring
      rw [hXdef, e2, mul_assoc D_r, e1]
    have hclass : ∀ c ∈ Finset.range q,
        ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
          < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
      intro c hc
      have hcq : c < q := Finset.mem_range.mp hc
      set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
      have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
      have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
        intro u hu
        rw [hT, Finset.mem_filter] at hu
        refine ⟨hu.1, ?_⟩
        have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
        omega
      have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
        intro u hu
        have := Int.emod_add_mul_ediv u q
        rw [(hmem u hu).2] at this
        omega
      set T' := T.image (fun u => u / (q : ℤ)) with hT'
      have hcardT : T'.card = T.card := by
        apply Finset.card_image_of_injOn
        intro u hu u' hu' huu
        simp only at huu
        rw [hdecomp u hu, hdecomp u' hu', huu]
      have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
        have : (2 : ℝ) ≤ r := by exact_mod_cast hr
        nlinarith
      have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
      by_cases hNc : (c : ℝ) < N
      · set N' : ℝ := (N - c) / q with hN'
        have hN'pos : 0 < N' := div_pos (by linarith) hqpos
        set g : ℝ → ℝ := fun t => f (c + q * t) with hg
        have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
            = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
          intro k hk t
          have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
            have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
            exact this.comp (contDiff_const.add contDiff_id)
          have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
          have h2 := congrFun this t
          try simp only at h2
          rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
            iteratedDeriv_comp_const_add]
        have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
          hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
        have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
          intro x hx
          obtain ⟨hx0, hx1⟩ := hx
          constructor
          · positivity
          · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
            rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
            linarith
        have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
        have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
          (D_r1 * q ^ (r + 1)) (by positivity) g hgC
          (by
            intro x hx
            rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
            have := h1 _ (hIcc x hx)
            nlinarith)
          (by
            intro x hx
            rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
            have := h2 _ (hIcc x hx)
            nlinarith)
          (by
            intro x hx
            rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
            have := h3 _ (hIcc x hx)
            have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
            nlinarith)
          T'
          (by
            intro t ht
            rw [hT', Finset.mem_image] at ht
            obtain ⟨u, hu, rfl⟩ := ht
            have huS := (hmem u hu).1
            obtain ⟨hu0, hu1⟩ := hS u huS
            refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
            apply Int.le_floor.mpr
            rw [hN', le_div_iff₀ hqpos]
            have hdu := hdecomp u hu
            have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
              have := congrArg (fun z : ℤ => (z : ℝ)) hdu
              push_cast at this
              exact this
            have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
            linarith)
          (by
            intro t ht
            rw [hT', Finset.mem_image] at ht
            obtain ⟨u, hu, rfl⟩ := ht
            obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
            refine ⟨v, w, hw0, hwW, ?_⟩
            have hdu := hdecomp u hu
            have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
              have := congrArg (fun z : ℤ => (z : ℝ)) hdu
              push_cast at this
              exact this.symm
            simp only [hg, hreal]
            exact hvw)
          (by rw [hXinv]; exact hX)
        rw [hXinv, hcardT] at key
        have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
          apply mul_le_mul_of_nonneg_right _ hX0
          apply mul_le_mul_of_nonneg_left _ (by norm_num)
          rw [hN']
          apply div_le_div_of_nonneg_right _ hqpos.le
          have : (0 : ℝ) ≤ c := by positivity
          linarith
        linarith
      · push_neg at hNc
        -- the class contains at most the single point `c`
        have hle : T.card ≤ 1 := by
          rw [Finset.card_le_one]
          intro u hu u' hu'
          have key : ∀ x ∈ T, x = c := by
            intro x hx
            have hxS := (hmem x hx).1
            obtain ⟨hx0, hx1⟩ := hS x hxS
            have hdx := hdecomp x hx
            have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
            have hxc : x ≤ c := by
              have : (x : ℝ) ≤ c := le_trans hxN hNc
              exact_mod_cast this
            have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
            have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
            have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
            have := Int.eq_zero_of_abs_lt_dvd hdvd habs
            omega
          rw [key u hu, key u' hu']
        have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
        linarith
    have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
        ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
      rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
        (t := Finset.range q)]
      · push_cast; rfl
      · intro u _
        simp only [Finset.coe_range, Set.mem_Iio]
        have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
        have h1 := Int.emod_nonneg u hqZ.ne'
        have h2 := Int.emod_lt_of_pos u hqZ
        omega
    have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass
    rw [← hsum, Finset.sum_const, Finset.card_range, nsmul_eq_mul] at hlt
    have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
        = 65536 * N * X + 2 * (r : ℝ) * lam := by
      rw [hlam']; field_simp
    linarith
How it was split
Split into

Proved from this hole by 20261015T063320Z-opn-prove-aristotle-1015-partial.lean (merged in 56c054dd0646, attestation 000534).

  • core → erdos-1094--h2--h2--h2--h3--h1--h1--h1 (proved)

    $\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}}$

Read the partial proof (Lean)
theorem erdos_1094__h2__h2__h2__h3__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 : ℝ)| < δ) →
                                            (↑S.card : ℝ) <
                                              (65536 : ℝ) * 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 : ℝ))⁻¹) +
                                                (2 : ℝ) * (↑r : ℝ) * lam := by
  intro r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1 f hf h1 h2 h3 S hS hS2
  set 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 : ℝ))⁻¹ with hXdef
  have hfl : (0 : ℤ) ≤ ⌊N⌋ := Int.floor_nonneg.mpr hN.le
  have hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋ := fun u hu => by
    obtain ⟨a, b⟩ := hS u hu
    exact Finset.mem_Icc.mpr ⟨a, b⟩
  have hcardZ : (S.card : ℤ) ≤ ⌊N⌋ + 1 := by
    have := Finset.card_le_card hsub
    rw [Int.card_Icc] at this
    omega
  have hcard : (S.card : ℝ) ≤ N + 1 := by
    have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ
    push_cast at h'
    linarith [Int.floor_le N]
  have hr2 : (4 : ℝ) ≤ 2 * (r : ℝ) * lam := by
    have : (2 : ℝ) ≤ r := by exact_mod_cast hr
    nlinarith
  by_cases hX : 1 ≤ 65536 * X
  · have : N ≤ 65536 * N * X := by nlinarith
    linarith
  · push_neg at hX
    -- the remaining (hard) case, for a scale parameter in `[1, 2)`
    have core : ∀ (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
      sorry
    -- reduction of a general scale `lam` to a scale in `[1, 2)` via residue classes
    set q : ℕ := ⌊lam⌋₊ with hqdef
    have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)
    have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1
    have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)
    have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam
    set lam' : ℝ := lam / q with hlam'
    have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith
    have hl2 : lam' < 2 := by
      rw [hlam', div_lt_iff₀ hqpos]
      have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
      linarith
    have hX0 : 0 ≤ X := by
      rw [hXdef]
      have := hDr.le; have := hDr1.le; have := hδ.le
      have hl0 : 0 ≤ lam := by linarith
      positivity
    have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
        (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
        (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
        = X := by
      have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
        rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
      have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
          = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
        rw [hlam']; field_simp; ring
      rw [hXdef, e2, mul_assoc D_r, e1]
    have hclass : ∀ c ∈ Finset.range q,
        ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
          < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
      intro c hc
      have hcq : c < q := Finset.mem_range.mp hc
      set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
      have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
      have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
        intro u hu
        rw [hT, Finset.mem_filter] at hu
        refine ⟨hu.1, ?_⟩
        have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
        omega
      have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
        intro u hu
        have := Int.emod_add_mul_ediv u q
        rw [(hmem u hu).2] at this
        omega
      set T' := T.image (fun u => u / (q : ℤ)) with hT'
      have hcardT : T'.card = T.card := by
        apply Finset.card_image_of_injOn
        intro u hu u' hu' huu
        simp only at huu
        rw [hdecomp u hu, hdecomp u' hu', huu]
      have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
        have : (2 : ℝ) ≤ r := by exact_mod_cast hr
        nlinarith
      have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
      by_cases hNc : (c : ℝ) < N
      · set N' : ℝ := (N - c) / q with hN'
        have hN'pos : 0 < N' := div_pos (by linarith) hqpos
        set g : ℝ → ℝ := fun t => f (c + q * t) with hg
        have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
            = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
          intro k hk t
          have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
            have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
            exact this.comp (contDiff_const.add contDiff_id)
          have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
          have h2 := congrFun this t
          try simp only at h2
          rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
            iteratedDeriv_comp_const_add]
        have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
          hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
        have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
          intro x hx
          obtain ⟨hx0, hx1⟩ := hx
          constructor
          · positivity
          · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
            rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
            linarith
        have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
        have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
          (D_r1 * q ^ (r + 1)) (by positivity) g hgC
          (by
            intro x hx
            rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
            have := h1 _ (hIcc x hx)
            nlinarith)
          (by
            intro x hx
            rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
            have := h2 _ (hIcc x hx)
            nlinarith)
          (by
            intro x hx
            rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
            have := h3 _ (hIcc x hx)
            have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
            nlinarith)
          T'
          (by
            intro t ht
            rw [hT', Finset.mem_image] at ht
            obtain ⟨u, hu, rfl⟩ := ht
            have huS := (hmem u hu).1
            obtain ⟨hu0, hu1⟩ := hS u huS
            refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
            apply Int.le_floor.mpr
            rw [hN', le_div_iff₀ hqpos]
            have hdu := hdecomp u hu
            have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
              have := congrArg (fun z : ℤ => (z : ℝ)) hdu
              push_cast at this
              exact this
            have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
            linarith)
          (by
            intro t ht
            rw [hT', Finset.mem_image] at ht
            obtain ⟨u, hu, rfl⟩ := ht
            obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
            refine ⟨v, w, hw0, hwW, ?_⟩
            have hdu := hdecomp u hu
            have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
              have := congrArg (fun z : ℤ => (z : ℝ)) hdu
              push_cast at this
              exact this.symm
            simp only [hg, hreal]
            exact hvw)
          (by rw [hXinv]; exact hX)
        rw [hXinv, hcardT] at key
        have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
          apply mul_le_mul_of_nonneg_right _ hX0
          apply mul_le_mul_of_nonneg_left _ (by norm_num)
          rw [hN']
          apply div_le_div_of_nonneg_right _ hqpos.le
          have : (0 : ℝ) ≤ c := by positivity
          linarith
        linarith
      · push_neg at hNc
        -- the class contains at most the single point `c`
        have hle : T.card ≤ 1 := by
          rw [Finset.card_le_one]
          intro u hu u' hu'
          have key : ∀ x ∈ T, x = c := by
            intro x hx
            have hxS := (hmem x hx).1
            obtain ⟨hx0, hx1⟩ := hS x hxS
            have hdx := hdecomp x hx
            have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
            have hxc : x ≤ c := by
              have : (x : ℝ) ≤ c := le_trans hxN hNc
              exact_mod_cast this
            have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
            have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
            have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
            have := Int.eq_zero_of_abs_lt_dvd hdvd habs
            omega
          rw [key u hu, key u' hu']
        have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
        linarith
    have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
        ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
      rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
        (t := Finset.range q)]
      · push_cast; rfl
      · intro u _
        simp only [Finset.coe_range, Set.mem_Iio]
        have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
        have h1 := Int.emod_nonneg u hqZ.ne'
        have h2 := Int.emod_lt_of_pos u hqZ
        omega
    have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass
    rw [← hsum, Finset.sum_const, Finset.card_range, nsmul_eq_mul] at hlt
    have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
        = 65536 * N * X + 2 * (r : ℝ) * lam := by
      rw [hlam']; field_simp
    linarith

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).

Write the explainer →

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».Context

open scoped Nat

/-! Hole `h_thm` 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 : ∀ (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 : ℝ)| < δ) →
                                            (↑S.card : ℝ) <
                                              (65536 : ℝ) * 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 : ℝ))⁻¹) +
                                                (2 : ℝ) * (↑r : ℝ) * lam := by
  sorry

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

In words, unverified — what this statement says; written by 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 |S|<65536\,N\Bigl[(D_r\lambda^rW^2)^{\frac{1}{2r-1}}+\Bigl(\frac{\delta W^2}{D_r\lambda^r}\Bigr)^{\frac{1}{r-1}}+\Bigl(\frac{D_{r+1}\lambda W^2}{D_r}\Bigr)^{\frac{1}{2r}}\Bigr]+2r\lambda$

For every $r\ge 2$, $N>0$, $W\ge 1$, $\delta>0$, $\lambda\ge 1$, $D_r>0$, $D_{r+1}>0$ and every $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$ satisfies the displayed bound: Konyagin's theorem on the integer points at which a function with controlled $r$-th and $(r+1)$-th derivatives is close to a rational of bounded denominator. The Lean names $\lambda$ lam, $D_{r+1}$ D_r1 and the derivatives iteratedDeriv; $|S|$ is cast to $\mathbb{R}$, the exponents $\tfrac{1}{2r-1}$, $\tfrac{1}{r-1}$, $\tfrac{1}{2r}$ are real powers and $W^2$ a natural one.

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

Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--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: $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}}$ · used by the proof
Attestation: pass, 7 of 7 checks

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

Verdict pass, from attestations/000568.json.

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

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

Witness.lean — checked at step 7 of the run recorded below: pass. Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/Witness.lean, sha256 61709288f2d1.
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
  have t1 : deriv (fun x : ℝ => x ^ 2) = fun x => 2 * x := by
    funext x; simp
  have t2 : deriv (fun x : ℝ => 2 * x) = fun _ => 2 := by
    funext x; simp
  have t3 : deriv (fun _ : ℝ => (2:ℝ)) = fun _ => 0 := by
    funext x; simp
  have d2 : iteratedDeriv 2 (fun x : ℝ => x ^ 2) = fun _ => 2 := by
    rw [iteratedDeriv_succ, iteratedDeriv_one, t1, t2]
  have d3 : iteratedDeriv (2 + 1) (fun x : ℝ => x ^ 2) = fun _ => 0 := by
    rw [iteratedDeriv_succ, d2, t3]
  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, by fun_prop, ?_, ?_, ?_, by simp, by simp⟩
  · intro x _; rw [d2]; norm_num
  · intro x _; rw [d2]; norm_num
  · intro x _; rw [d3]; norm_num

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

Attempts (1)

1 recorded. Routes refuted: none. Failure classes: none.

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 opn-prove-aristotle-1015; merged in 56c054dd0646 under attestations/000534.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/attempts/20261015T063320Z-opn-prove-aristotle-1015-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 20261015T063320Z-opn-prove-aristotle-1015-partial.lean, extracted by the gate at 7e153a12f0ce from the proof’s elaboration: each step is a claim the proof establishes and the goal it leaves. Open a step for what it uses and its Lean lines.

  1. hfl have (0 : ℤ) ≤ ⌊N⌋

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hfl : (0 : ℤ) ≤ ⌊N⌋.

    Uses library Int.floor_nonneg.

    Lean, line 43
      have hfl : (0 : ℤ) ≤ ⌊N⌋ := Int.floor_nonneg.mpr hN.le

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 43 at f0dfc93f9827 ↗

  2. hsub have S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋.

    Uses library Finset.Icc The finset $[a, b]$ of elements x such that a ≤ x and x ≤ b. , Finset.mem_Icc, And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. .

    Lean, lines 44–46
      have hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋ := fun u hu => by
        obtain ⟨a, b⟩ := hS u hu
        exact Finset.mem_Icc.mpr ⟨a, b⟩

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 44–46 at f0dfc93f9827 ↗

    1. hsub.s1 obtain (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋

      Leaves u ∈ Finset.Icc (0 : ℤ) ⌊N⌋, with a : (0 : ℤ) ≤ u, b : u ≤ ⌊N⌋.

      Lean, line 45
          obtain ⟨a, b⟩ := hS u hu

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 45 at f0dfc93f9827 ↗

  3. hcardZ have (↑S.card : ℤ) ≤ ⌊N⌋ + (1 : ℤ)

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hcardZ : (↑S.card : ℤ) ≤ ⌊N⌋ + (1 : ℤ).

    Uses library Int.card_Icc.

    Lean, lines 47–50
      have hcardZ : (S.card : ℤ) ≤ ⌊N⌋ + 1 := by
        have := Finset.card_le_card hsub
        rw [Int.card_Icc] at this
        omega

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 47–50 at f0dfc93f9827 ↗

    1. hcardZ.this have S.card ≤ (Finset.Icc (0 : ℤ) ⌊N⌋).card

      Leaves (↑S.card : ℤ) ≤ ⌊N⌋ + (1 : ℤ), with this : S.card ≤ (Finset.Icc (0 : ℤ) ⌊N⌋).card.

      Uses library Finset.card_le_card.

      Lean, line 48
          have := Finset.card_le_card hsub

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 48 at f0dfc93f9827 ↗

  4. hcard have (↑S.card : ℝ) ≤ N + (1 : ℝ)

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hcard : (↑S.card : ℝ) ≤ N + (1 : ℝ).

    Uses library Int.floor_le.

    Lean, lines 51–54
      have hcard : (S.card : ℝ) ≤ N + 1 := by
        have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ
        push_cast at h'
        linarith [Int.floor_le N]

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 51–54 at f0dfc93f9827 ↗

    1. hcard.h' have (↑(↑S.card : ℤ) : ℝ) ≤ (↑(⌊N⌋ + (1 : ℤ)) : ℝ)

      Leaves (↑S.card : ℝ) ≤ N + (1 : ℝ), with h' : (↑(↑S.card : ℤ) : ℝ) ≤ (↑(⌊N⌋ + (1 : ℤ)) : ℝ).

      Lean, line 52
          have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 52 at f0dfc93f9827 ↗

  5. hr2 have (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hr2 : (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam.

    Lean, lines 55–57
      have hr2 : (4 : ℝ) ≤ 2 * (r : ℝ) * lam := by
        have : (2 : ℝ) ≤ r := by exact_mod_cast hr
        nlinarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 55–57 at f0dfc93f9827 ↗

    1. hr2.this have (2 : ℝ) ≤ (↑r : ℝ)

      Leaves (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam, with this : (2 : ℝ) ≤ (↑r : ℝ).

      Lean, line 56
          have : (2 : ℝ) ≤ r := by exact_mod_cast hr

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 56 at f0dfc93f9827 ↗

  6. s6 case

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hX : (1 : ℝ) ≤ (65536 : ℝ) * X.

    Lean, lines 59–60
      · have : N ≤ 65536 * N * X := by nlinarith
        linarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 59–60 at f0dfc93f9827 ↗

    1. s6.this have N ≤ (65536 : ℝ) * N * X routine: nlinarith

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with this : N ≤ (65536 : ℝ) * N * X.

      Lean, line 59
        · have : N ≤ 65536 * N * X := by nlinarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 59 at f0dfc93f9827 ↗

  7. s7 case

    Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hX : ¬(1 : ℝ) ≤ (65536 : ℝ) * X.

    Uses library Finset.sum_const, Finset.card_range, nsmul_eq_mul.

    Lean, lines 61–258
      · push_neg at hX
        -- the remaining (hard) case, for a scale parameter in `[1, 2)`
        have core : ∀ (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
          sorry
        -- reduction of a general scale `lam` to a scale in `[1, 2)` via residue classes
        set q : ℕ := ⌊lam⌋₊ with hqdef
        have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)
        have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1
        have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)
        have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam
        set lam' : ℝ := lam / q with hlam'
        have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith
        have hl2 : lam' < 2 := by
          rw [hlam', div_lt_iff₀ hqpos]
          have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
          linarith
        have hX0 : 0 ≤ X := by
          rw [hXdef]
          have := hDr.le; have := hDr1.le; have := hδ.le
          have hl0 : 0 ≤ lam := by linarith
          positivity
        have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
            (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
            (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
            = X := by
          have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
            rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
          have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
              = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
            rw [hlam']; field_simp; ring
          rw [hXdef, e2, mul_assoc D_r, e1]
        have hclass : ∀ c ∈ Finset.range q,
            ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
              < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
          intro c hc
          have hcq : c < q := Finset.mem_range.mp hc
          set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
          have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
          have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
            intro u hu
            rw [hT, Finset.mem_filter] at hu
            refine ⟨hu.1, ?_⟩
            have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
            omega
          have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
            intro u hu
            have := Int.emod_add_mul_ediv u q
            rw [(hmem u hu).2] at this
            omega
          set T' := T.image (fun u => u / (q : ℤ)) with hT'
          have hcardT : T'.card = T.card := by
            apply Finset.card_image_of_injOn
            intro u hu u' hu' huu
            simp only at huu
            rw [hdecomp u hu, hdecomp u' hu', huu]
          have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
            have : (2 : ℝ) ≤ r := by exact_mod_cast hr
            nlinarith
          have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
          by_cases hNc : (c : ℝ) < N
          · set N' : ℝ := (N - c) / q with hN'
            have hN'pos : 0 < N' := div_pos (by linarith) hqpos
            set g : ℝ → ℝ := fun t => f (c + q * t) with hg
            have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
              intro k hk t
              have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                exact this.comp (contDiff_const.add contDiff_id)
              have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
              have h2 := congrFun this t
              try simp only at h2
              rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                iteratedDeriv_comp_const_add]
            have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
              hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
            have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
              intro x hx
              obtain ⟨hx0, hx1⟩ := hx
              constructor
              · positivity
              · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                linarith
            have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
            have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
              (D_r1 * q ^ (r + 1)) (by positivity) g hgC
              (by
                intro x hx
                rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                have := h1 _ (hIcc x hx)
                nlinarith)
              (by
                intro x hx
                rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                have := h2 _ (hIcc x hx)
                nlinarith)
              (by
                intro x hx
                rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                have := h3 _ (hIcc x hx)
                have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                nlinarith)
              T'
              (by
                intro t ht
                rw [hT', Finset.mem_image] at ht
                obtain ⟨u, hu, rfl⟩ := ht
                have huS := (hmem u hu).1
                obtain ⟨hu0, hu1⟩ := hS u huS
                refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                apply Int.le_floor.mpr
                rw [hN', le_div_iff₀ hqpos]
                have hdu := hdecomp u hu
                have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                  have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                  push_cast at this
                  exact this
                have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                linarith)
              (by
                intro t ht
                rw [hT', Finset.mem_image] at ht
                obtain ⟨u, hu, rfl⟩ := ht
                obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                refine ⟨v, w, hw0, hwW, ?_⟩
                have hdu := hdecomp u hu
                have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                  have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                  push_cast at this
                  exact this.symm
                simp only [hg, hreal]
                exact hvw)
              (by rw [hXinv]; exact hX)
            rw [hXinv, hcardT] at key
            have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
              apply mul_le_mul_of_nonneg_right _ hX0
              apply mul_le_mul_of_nonneg_left _ (by norm_num)
              rw [hN']
              apply div_le_div_of_nonneg_right _ hqpos.le
              have : (0 : ℝ) ≤ c := by positivity
              linarith
            linarith
          · push_neg at hNc
            -- the class contains at most the single point `c`
            have hle : T.card ≤ 1 := by
              rw [Finset.card_le_one]
              intro u hu u' hu'
              have key : ∀ x ∈ T, x = c := by
                intro x hx
                have hxS := (hmem x hx).1
                obtain ⟨hx0, hx1⟩ := hS x hxS
                have hdx := hdecomp x hx
                have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                have hxc : x ≤ c := by
                  have : (x : ℝ) ≤ c := le_trans hxN hNc
                  exact_mod_cast this
                have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                omega
              rw [key u hu, key u' hu']
            have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
            linarith
        have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
            ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
          rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
            (t := Finset.range q)]
          · push_cast; rfl
          · intro u _
            simp only [Finset.coe_range, Set.mem_Iio]
            have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
            have h1 := Int.emod_nonneg u hqZ.ne'
            have h2 := Int.emod_lt_of_pos u hqZ
            omega
        have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass
        rw [← hsum, Finset.sum_const, Finset.card_range, nsmul_eq_mul] at hlt
        have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
            = 65536 * N * X + 2 * (r : ℝ) * lam := by
          rw [hlam']; field_simp
        linarith

    targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 61–258 at f0dfc93f9827 ↗

    1. s7.core hole ∀ (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' hole

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with core : ∀ (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'.

      Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. , WithTop Attach ⊤ to a type. , Set.Icc Icc a b is the left-closed right-closed interval $[a, b]$. , iteratedDeriv The n-th iterated derivative of a function from 𝕜 to F, as a function from 𝕜 to F. , Finset Finset α is the type of finite sets of elements of α. .

      Left open as a hole; its statement is erdos-1094--h2--h2--h2--h3--h1--h1--h1 (proved).

      Lean, lines 63–80
          have core : ∀ (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
            sorry

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 63–80 at f0dfc93f9827 ↗

    2. s7.hq1 have (1 : ℕ) ≤ q

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hq1 : (1 : ℕ) ≤ q.

      Uses library Nat.le_floor.

      Lean, line 83
          have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 83 at f0dfc93f9827 ↗

    3. s7.hqpos have (0 : ℝ) < (↑q : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hqpos : (0 : ℝ) < (↑q : ℝ).

      Lean, line 84
          have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 84 at f0dfc93f9827 ↗

    4. s7.hqle have (↑q : ℝ) ≤ lam

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hqle : (↑q : ℝ) ≤ lam.

      Uses library Nat.floor_le.

      Lean, line 85
          have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 85 at f0dfc93f9827 ↗

    5. s7.hqlt have lam < (↑q : ℝ) + (1 : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hqlt : lam < (↑q : ℝ) + (1 : ℝ).

      Uses library Nat.lt_floor_add_one.

      Lean, line 86
          have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 86 at f0dfc93f9827 ↗

    6. s7.hl1 have (1 : ℝ) ≤ lam'

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hl1 : (1 : ℝ) ≤ lam'.

      Uses library le_div_iff₀ See le_div_iff₀' for a version with multiplication on the other side. .

      Lean, line 88
          have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 88 at f0dfc93f9827 ↗

    7. s7.hl2 have lam' < (2 : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hl2 : lam' < (2 : ℝ).

      Uses library div_lt_iff₀ See div_lt_iff₀' for a version with multiplication on the other side. .

      Lean, lines 89–92
          have hl2 : lam' < 2 := by
            rw [hlam', div_lt_iff₀ hqpos]
            have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
            linarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 89–92 at f0dfc93f9827 ↗

      1. s7.hl2.this have (1 : ℝ) ≤ (↑q : ℝ)

        Leaves lam < (2 : ℝ) * (↑q : ℝ), with this : (1 : ℝ) ≤ (↑q : ℝ).

        Lean, line 91
              have : (1 : ℝ) ≤ q := by exact_mod_cast hq1

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 91 at f0dfc93f9827 ↗

    8. s7.hX0 have (0 : ℝ) ≤ X

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hX0 : (0 : ℝ) ≤ X.

      Lean, lines 93–97
          have hX0 : 0 ≤ X := by
            rw [hXdef]
            have := hDr.le; have := hDr1.le; have := hδ.le
            have hl0 : 0 ≤ lam := by linarith
            positivity

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 93–97 at f0dfc93f9827 ↗

      1. s7.hX0.s1 have (0 : ℝ) ≤ D_r

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with this : (0 : ℝ) ≤ D_r.

        Lean, line 95
              have := hDr.le; have := hDr1.le; have := hδ.le

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 95 at f0dfc93f9827 ↗

      2. s7.hX0.s2 have (0 : ℝ) ≤ D_r1

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with this : (0 : ℝ) ≤ D_r1.

        Lean, line 95
              have := hDr.le; have := hDr1.le; have := hδ.le

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 95 at f0dfc93f9827 ↗

      3. s7.hX0.s3 have (0 : ℝ) ≤ δ

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with this : (0 : ℝ) ≤ δ.

        Lean, line 95
              have := hDr.le; have := hDr1.le; have := hδ.le

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 95 at f0dfc93f9827 ↗

      4. s7.hX0.hl0 have (0 : ℝ) ≤ lam routine: linarith

        Leaves (0 : ℝ) ≤ (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 : ℝ))⁻¹, with hl0 : (0 : ℝ) ≤ lam.

        Lean, line 96
              have hl0 : 0 ≤ lam := by linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 96 at f0dfc93f9827 ↗

    9. s7.hXinv have (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hXinv : (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X.

      Uses library mul_assoc.

      Lean, lines 98–107
          have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
              (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
              (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
              = X := by
            have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
              rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
            have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
                = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
              rw [hlam']; field_simp; ring
            rw [hXdef, e2, mul_assoc D_r, e1]

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 98–107 at f0dfc93f9827 ↗

      1. s7.hXinv.e1 have (↑q : ℝ) ^ r * lam' ^ r = lam ^ r

        Leaves (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X, with e1 : (↑q : ℝ) ^ r * lam' ^ r = lam ^ r.

        Uses library mul_pow, mul_div_cancel₀.

        Lean, lines 102–103
              have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
                rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 102–103 at f0dfc93f9827 ↗

      2. s7.hXinv.e2 have D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r) = D_r1 * lam * W ^ (2 : ℕ) / D_r

        Leaves (D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹ = X, with e2 : D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r) = D_r1 * lam * W ^ (2 : ℕ) / D_r.

        Lean, lines 104–106
              have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
                  = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
                rw [hlam']; field_simp; ring

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 104–106 at f0dfc93f9827 ↗

    10. s7.hclass have ∀ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam'

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hclass : ∀ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam'.

      Uses library Finset.range range n is the set of natural numbers less than n. .

      Lean, lines 108–241
          have hclass : ∀ c ∈ Finset.range q,
              ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
                < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
            intro c hc
            have hcq : c < q := Finset.mem_range.mp hc
            set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
            have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
            have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
              intro u hu
              rw [hT, Finset.mem_filter] at hu
              refine ⟨hu.1, ?_⟩
              have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
              omega
            have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
              intro u hu
              have := Int.emod_add_mul_ediv u q
              rw [(hmem u hu).2] at this
              omega
            set T' := T.image (fun u => u / (q : ℤ)) with hT'
            have hcardT : T'.card = T.card := by
              apply Finset.card_image_of_injOn
              intro u hu u' hu' huu
              simp only at huu
              rw [hdecomp u hu, hdecomp u' hu', huu]
            have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
              have : (2 : ℝ) ≤ r := by exact_mod_cast hr
              nlinarith
            have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
            by_cases hNc : (c : ℝ) < N
            · set N' : ℝ := (N - c) / q with hN'
              have hN'pos : 0 < N' := div_pos (by linarith) hqpos
              set g : ℝ → ℝ := fun t => f (c + q * t) with hg
              have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                  = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
                intro k hk t
                have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                  have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                  exact this.comp (contDiff_const.add contDiff_id)
                have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
                have h2 := congrFun this t
                try simp only at h2
                rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                  iteratedDeriv_comp_const_add]
              have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
                hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
              have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
                intro x hx
                obtain ⟨hx0, hx1⟩ := hx
                constructor
                · positivity
                · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                  rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                  linarith
              have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
              have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
                (D_r1 * q ^ (r + 1)) (by positivity) g hgC
                (by
                  intro x hx
                  rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                  have := h1 _ (hIcc x hx)
                  nlinarith)
                (by
                  intro x hx
                  rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                  have := h2 _ (hIcc x hx)
                  nlinarith)
                (by
                  intro x hx
                  rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                  have := h3 _ (hIcc x hx)
                  have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                  nlinarith)
                T'
                (by
                  intro t ht
                  rw [hT', Finset.mem_image] at ht
                  obtain ⟨u, hu, rfl⟩ := ht
                  have huS := (hmem u hu).1
                  obtain ⟨hu0, hu1⟩ := hS u huS
                  refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                  apply Int.le_floor.mpr
                  rw [hN', le_div_iff₀ hqpos]
                  have hdu := hdecomp u hu
                  have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                    have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                    push_cast at this
                    exact this
                  have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                  linarith)
                (by
                  intro t ht
                  rw [hT', Finset.mem_image] at ht
                  obtain ⟨u, hu, rfl⟩ := ht
                  obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                  refine ⟨v, w, hw0, hwW, ?_⟩
                  have hdu := hdecomp u hu
                  have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                    have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                    push_cast at this
                    exact this.symm
                  simp only [hg, hreal]
                  exact hvw)
                (by rw [hXinv]; exact hX)
              rw [hXinv, hcardT] at key
              have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
                apply mul_le_mul_of_nonneg_right _ hX0
                apply mul_le_mul_of_nonneg_left _ (by norm_num)
                rw [hN']
                apply div_le_div_of_nonneg_right _ hqpos.le
                have : (0 : ℝ) ≤ c := by positivity
                linarith
              linarith
            · push_neg at hNc
              -- the class contains at most the single point `c`
              have hle : T.card ≤ 1 := by
                rw [Finset.card_le_one]
                intro u hu u' hu'
                have key : ∀ x ∈ T, x = c := by
                  intro x hx
                  have hxS := (hmem x hx).1
                  obtain ⟨hx0, hx1⟩ := hS x hxS
                  have hdx := hdecomp x hx
                  have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                  have hxc : x ≤ c := by
                    have : (x : ℝ) ≤ c := le_trans hxN hNc
                    exact_mod_cast this
                  have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                  have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                  have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                  have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                  omega
                rw [key u hu, key u' hu']
              have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
              linarith

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 108–241 at f0dfc93f9827 ↗

      1. s7.hclass.hcq have c < q

        Leaves (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hcq : c < q.

        Uses library Finset.mem_range.

        Lean, line 112
              have hcq : c < q := Finset.mem_range.mp hc

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 112 at f0dfc93f9827 ↗

      2. s7.hclass.hqZ have (0 : ℤ) < (↑q : ℤ)

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hqZ : (0 : ℤ) < (↑q : ℤ).

        Lean, line 114
              have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 114 at f0dfc93f9827 ↗

      3. s7.hclass.hmem have ∀ u ∈ T, u ∈ S ∧ u % (↑q : ℤ) = (↑c : ℤ)

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hmem : ∀ u ∈ T, u ∈ S ∧ u % (↑q : ℤ) = (↑c : ℤ).

        Uses library Finset.mem_filter, And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. .

        Lean, lines 115–120
              have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
                intro u hu
                rw [hT, Finset.mem_filter] at hu
                refine ⟨hu.1, ?_⟩
                have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
                omega

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 115–120 at f0dfc93f9827 ↗

        1. s7.hclass.hmem.h0 have (0 : ℤ) ≤ u % (↑q : ℤ)

          Leaves u % (↑q : ℤ) = (↑c : ℤ), with h0 : (0 : ℤ) ≤ u % (↑q : ℤ).

          Uses library Int.emod_nonneg.

          Lean, line 119
                  have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 119 at f0dfc93f9827 ↗

      4. s7.hclass.hdecomp have ∀ u ∈ T, u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hdecomp : ∀ u ∈ T, u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)).

        Lean, lines 121–125
              have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
                intro u hu
                have := Int.emod_add_mul_ediv u q
                rw [(hmem u hu).2] at this
                omega

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 121–125 at f0dfc93f9827 ↗

        1. s7.hclass.hdecomp.this have u % (↑q : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)) = u

          Leaves u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)), with this : u % (↑q : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)) = u.

          Uses library Int.emod_add_mul_ediv.

          Lean, line 123
                  have := Int.emod_add_mul_ediv u q

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 123 at f0dfc93f9827 ↗

      5. s7.hclass.hcardT have T'.card = T.card

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hcardT : T'.card = T.card.

        Uses library Finset.card_image_of_injOn.

        Lean, lines 127–131
              have hcardT : T'.card = T.card := by
                apply Finset.card_image_of_injOn
                intro u hu u' hu' huu
                simp only at huu
                rw [hdecomp u hu, hdecomp u' hu', huu]

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 127–131 at f0dfc93f9827 ↗

      6. s7.hclass.hlam'pos have (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hlam'pos : (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam'.

        Lean, lines 132–134
              have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
                have : (2 : ℝ) ≤ r := by exact_mod_cast hr
                nlinarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 132–134 at f0dfc93f9827 ↗

        1. s7.hclass.hlam'pos.this have (2 : ℝ) ≤ (↑r : ℝ)

          Leaves (4 : ℝ) ≤ (2 : ℝ) * (↑r : ℝ) * lam', with this : (2 : ℝ) ≤ (↑r : ℝ).

          Lean, line 133
                  have : (2 : ℝ) ≤ r := by exact_mod_cast hr

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 133 at f0dfc93f9827 ↗

      7. s7.hclass.hNq have (0 : ℝ) ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X routine: positivity

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hNq : (0 : ℝ) ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X.

        Lean, line 135
              have hNq : 0 ≤ 65536 * (N / q) * X := by positivity

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 135 at f0dfc93f9827 ↗

      8. s7.hclass.s8 case

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hNc : (↑c : ℝ) < N.

        Lean, lines 137–219
              · set N' : ℝ := (N - c) / q with hN'
                have hN'pos : 0 < N' := div_pos (by linarith) hqpos
                set g : ℝ → ℝ := fun t => f (c + q * t) with hg
                have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                    = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
                  intro k hk t
                  have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                    have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                    exact this.comp (contDiff_const.add contDiff_id)
                  have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
                  have h2 := congrFun this t
                  try simp only at h2
                  rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                    iteratedDeriv_comp_const_add]
                have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
                  hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
                have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
                  intro x hx
                  obtain ⟨hx0, hx1⟩ := hx
                  constructor
                  · positivity
                  · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                    rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                    linarith
                have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
                have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
                  (D_r1 * q ^ (r + 1)) (by positivity) g hgC
                  (by
                    intro x hx
                    rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                    have := h1 _ (hIcc x hx)
                    nlinarith)
                  (by
                    intro x hx
                    rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                    have := h2 _ (hIcc x hx)
                    nlinarith)
                  (by
                    intro x hx
                    rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                    have := h3 _ (hIcc x hx)
                    have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                    nlinarith)
                  T'
                  (by
                    intro t ht
                    rw [hT', Finset.mem_image] at ht
                    obtain ⟨u, hu, rfl⟩ := ht
                    have huS := (hmem u hu).1
                    obtain ⟨hu0, hu1⟩ := hS u huS
                    refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                    apply Int.le_floor.mpr
                    rw [hN', le_div_iff₀ hqpos]
                    have hdu := hdecomp u hu
                    have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                      have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                      push_cast at this
                      exact this
                    have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                    linarith)
                  (by
                    intro t ht
                    rw [hT', Finset.mem_image] at ht
                    obtain ⟨u, hu, rfl⟩ := ht
                    obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                    refine ⟨v, w, hw0, hwW, ?_⟩
                    have hdu := hdecomp u hu
                    have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                      have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                      push_cast at this
                      exact this.symm
                    simp only [hg, hreal]
                    exact hvw)
                  (by rw [hXinv]; exact hX)
                rw [hXinv, hcardT] at key
                have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
                  apply mul_le_mul_of_nonneg_right _ hX0
                  apply mul_le_mul_of_nonneg_left _ (by norm_num)
                  rw [hN']
                  apply div_le_div_of_nonneg_right _ hqpos.le
                  have : (0 : ℝ) ≤ c := by positivity
                  linarith
                linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 137–219 at f0dfc93f9827 ↗

        1. s7.hclass.s8.hN'pos have (0 : ℝ) < N'

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hN'pos : (0 : ℝ) < N'.

          Uses library div_pos.

          Lean, line 138
                  have hN'pos : 0 < N' := div_pos (by linarith) hqpos

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 138 at f0dfc93f9827 ↗

        2. s7.hclass.s8.hgfun have ∀ k ≤ r + (1 : ℕ), ∀ (t : ℝ), iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t)

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hgfun : ∀ k ≤ r + (1 : ℕ), ∀ (t : ℝ), iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t).

          Uses library iteratedDeriv The n-th iterated derivative of a function from 𝕜 to F, as a function from 𝕜 to F. , rfl rfl : a = a is the unique constructor of the equality type. , iteratedDeriv_comp_const_add The iterated derivative commutes with shifting the function by a constant on the left. .

          Lean, lines 140–150
                  have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
                      = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
                    intro k hk t
                    have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                      have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                      exact this.comp (contDiff_const.add contDiff_id)
                    have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
                    have h2 := congrFun this t
                    try simp only at h2
                    rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
                      iteratedDeriv_comp_const_add]

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 140–150 at f0dfc93f9827 ↗

          1. s7.hclass.s8.hgfun.hf1 have ContDiff ℝ (↑k : WithTop ℕ∞) fun (z : ℝ) => f ((↑c : ℝ) + z)

            Leaves iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t), with hf1 : ContDiff ℝ (↑k : WithTop ℕ∞) fun (z : ℝ) => f ((↑c : ℝ) + z).

            Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. , contDiff_const Constants are C^∞. , contDiff_id The identity is C^n. .

            Lean, lines 143–145
                      have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
                        have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
                        exact this.comp (contDiff_const.add contDiff_id)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 143–145 at f0dfc93f9827 ↗

            1. s7.hclass.s8.hgfun.hf1.this have ContDiff ℝ (↑k : WithTop ℕ∞) f

              Leaves ContDiff ℝ (↑k : WithTop ℕ∞) fun (z : ℝ) => f ((↑c : ℝ) + z), with this : ContDiff ℝ (↑k : WithTop ℕ∞) f.

              Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. .

              Lean, line 144
                          have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 144 at f0dfc93f9827 ↗

          2. s7.hclass.s8.hgfun.this have (iteratedDeriv k fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) = fun (x : ℝ) => (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * x)

            Leaves iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t), with this : (iteratedDeriv k fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) = fun (x : ℝ) => (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * x).

            Uses library iteratedDeriv_comp_const_mul.

            Lean, line 146
                      have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 146 at f0dfc93f9827 ↗

          3. s7.hclass.s8.hgfun.h2 have iteratedDeriv k (fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) t = (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * t)

            Leaves iteratedDeriv k g t = (↑q : ℝ) ^ k * iteratedDeriv k f ((↑c : ℝ) + (↑q : ℝ) * t), with h2 : iteratedDeriv k (fun (x : ℝ) => f ((↑c : ℝ) + (↑q : ℝ) * x)) t = (↑q : ℝ) ^ k * iteratedDeriv k (fun (z : ℝ) => f ((↑c : ℝ) + z)) ((↑q : ℝ) * t).

            Uses library congrFun Congruence in the function part of an application: If f = g then f a = g a. .

            Lean, line 147
                      have h2 := congrFun this t

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 147 at f0dfc93f9827 ↗

        3. s7.hclass.s8.hgC have ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g.

          Uses library ContDiff A function is continuously differentiable up to n if it admits derivatives up to order n, which are continuous. , WithTop Attach ⊤ to a type. , contDiff_const Constants are C^∞. , contDiff_id The identity is C^n. .

          Lean, lines 151–152
                  have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
                    hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 151–152 at f0dfc93f9827 ↗

        4. s7.hclass.s8.hIcc have ∀ x ∈ Set.Icc (0 : ℝ) N', (↑c : ℝ) + (↑q : ℝ) * x ∈ Set.Icc (0 : ℝ) N

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (↑c : ℝ) + (↑q : ℝ) * x ∈ Set.Icc (0 : ℝ) N.

          Uses library Set.Icc Icc a b is the left-closed right-closed interval $[a, b]$. .

          Lean, lines 153–160
                  have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
                    intro x hx
                    obtain ⟨hx0, hx1⟩ := hx
                    constructor
                    · positivity
                    · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                      rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                      linarith

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 153–160 at f0dfc93f9827 ↗

          1. s7.hclass.s8.hIcc.s1 obtain x ∈ Set.Icc (0 : ℝ) N'

            Leaves (↑c : ℝ) + (↑q : ℝ) * x ∈ Set.Icc (0 : ℝ) N, with hx0 : (0 : ℝ) ≤ x, hx1 : x ≤ N'.

            Lean, line 155
                      obtain ⟨hx0, hx1⟩ := hx

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 155 at f0dfc93f9827 ↗

          2. s7.hclass.s8.hIcc.s2 case routine: positivity
          3. s7.hclass.s8.hIcc.s3 case

            Leaves (↑c : ℝ) + (↑q : ℝ) * x ≤ N.

            Uses library mul_div_cancel₀.

            Lean, lines 158–160
                      · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
                        rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
                        linarith

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 158–160 at f0dfc93f9827 ↗

            1. s7.hclass.s8.hIcc.s3.this have (↑q : ℝ) * x ≤ (↑q : ℝ) * N'

              Leaves (↑c : ℝ) + (↑q : ℝ) * x ≤ N, with this : (↑q : ℝ) * x ≤ (↑q : ℝ) * N'.

              Uses library mul_le_mul_of_nonneg_left.

              Lean, line 158
                        · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 158 at f0dfc93f9827 ↗

        5. s7.hclass.s8.hqr have (0 : ℝ) < (↑q : ℝ) ^ r

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hqr : (0 : ℝ) < (↑q : ℝ) ^ r.

          Uses library pow_pos.

          Lean, line 161
                  have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 161 at f0dfc93f9827 ↗

        6. s7.hclass.s8.key have (↑T'.card : ℝ) < (65536 : ℝ) * N' * ((D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam'

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with key : (↑T'.card : ℝ) < (65536 : ℝ) * N' * ((D_r * (↑q : ℝ) ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ + (δ * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ + (D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)) * lam' * W ^ (2 : ℕ) / (D_r * (↑q : ℝ) ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹) + (2 : ℝ) * (↑r : ℝ) * lam'.

          Uses library abs_mul, abs_of_pos, le_rfl A version of le_refl where the argument is implicit , pow_pos, Finset.mem_image, And.intro And.intro : a → b → a ∧ b is the constructor for the And operation. , Int.ediv_nonneg, Int.le_floor, le_div_iff₀ See le_div_iff₀' for a version with multiplication on the other side. , Exists.intro Existential introduction. .

          Lean, lines 162–210
                  have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
                    (D_r1 * q ^ (r + 1)) (by positivity) g hgC
                    (by
                      intro x hx
                      rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                      have := h1 _ (hIcc x hx)
                      nlinarith)
                    (by
                      intro x hx
                      rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
                      have := h2 _ (hIcc x hx)
                      nlinarith)
                    (by
                      intro x hx
                      rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
                      have := h3 _ (hIcc x hx)
                      have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
                      nlinarith)
                    T'
                    (by
                      intro t ht
                      rw [hT', Finset.mem_image] at ht
                      obtain ⟨u, hu, rfl⟩ := ht
                      have huS := (hmem u hu).1
                      obtain ⟨hu0, hu1⟩ := hS u huS
                      refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
                      apply Int.le_floor.mpr
                      rw [hN', le_div_iff₀ hqpos]
                      have hdu := hdecomp u hu
                      have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                        have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                        push_cast at this
                        exact this
                      have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
                      linarith)
                    (by
                      intro t ht
                      rw [hT', Finset.mem_image] at ht
                      obtain ⟨u, hu, rfl⟩ := ht
                      obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
                      refine ⟨v, w, hw0, hwW, ?_⟩
                      have hdu := hdecomp u hu
                      have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                        have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                        push_cast at this
                        exact this.symm
                      simp only [hg, hreal]
                      exact hvw)
                    (by rw [hXinv]; exact hX)

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 162–210 at f0dfc93f9827 ↗

          1. s7.hclass.s8.key.s1 have D_r / (2 : ℝ) ≤ |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)|

            Leaves D_r * (↑q : ℝ) ^ r / (2 : ℝ) ≤ (↑q : ℝ) ^ r * |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)|, with this : D_r / (2 : ℝ) ≤ |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)|.

            Lean, line 167
                        have := h1 _ (hIcc x hx)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 167 at f0dfc93f9827 ↗

          2. s7.hclass.s8.key.s2 have |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r

            Leaves (↑q : ℝ) ^ r * |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r * (↑q : ℝ) ^ r, with this : |iteratedDeriv r f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r.

            Lean, line 172
                        have := h2 _ (hIcc x hx)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 172 at f0dfc93f9827 ↗

          3. s7.hclass.s8.key.s3 have |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1

            Leaves (↑q : ℝ) ^ (r + (1 : ℕ)) * |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)), with this : |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1.

            Lean, line 177
                        have := h3 _ (hIcc x hx)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 177 at f0dfc93f9827 ↗

          4. s7.hclass.s8.key.s4 have (0 : ℝ) < (↑q : ℝ) ^ (r + (1 : ℕ))

            Leaves (↑q : ℝ) ^ (r + (1 : ℕ)) * |iteratedDeriv (r + (1 : ℕ)) f ((↑c : ℝ) + (↑q : ℝ) * x)| ≤ D_r1 * (↑q : ℝ) ^ (r + (1 : ℕ)), with this : (0 : ℝ) < (↑q : ℝ) ^ (r + (1 : ℕ)).

            Uses library pow_pos.

            Lean, line 178
                        have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 178 at f0dfc93f9827 ↗

          5. s7.hclass.s8.key.s5 obtain ∃ a ∈ T, a / (↑q : ℤ) = t

            Leaves (0 : ℤ) ≤ u / (↑q : ℤ) ∧ u / (↑q : ℤ) ≤ ⌊N'⌋, with u : ℤ, hu : u ∈ T.

            Lean, line 184
                        obtain ⟨u, hu, rfl⟩ := ht

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 184 at f0dfc93f9827 ↗

          6. s7.hclass.s8.key.huS have u ∈ S

            Leaves (0 : ℤ) ≤ u / (↑q : ℤ) ∧ u / (↑q : ℤ) ≤ ⌊N'⌋, with huS : u ∈ S.

            Lean, line 185
                        have huS := (hmem u hu).1

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 185 at f0dfc93f9827 ↗

          7. s7.hclass.s8.key.s7 obtain (0 : ℤ) ≤ u ∧ u ≤ ⌊N⌋

            Leaves (0 : ℤ) ≤ u / (↑q : ℤ) ∧ u / (↑q : ℤ) ≤ ⌊N'⌋, with hu0 : (0 : ℤ) ≤ u, hu1 : u ≤ ⌊N⌋.

            Lean, line 186
                        obtain ⟨hu0, hu1⟩ := hS u huS

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 186 at f0dfc93f9827 ↗

          8. s7.hclass.s8.key.s8 have u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))

            Leaves (↑(u / (↑q : ℤ)) : ℝ) * (↑q : ℝ) ≤ N - (↑c : ℝ), with hdu : u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)).

            Lean, line 190
                        have hdu := hdecomp u hu

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 190 at f0dfc93f9827 ↗

          9. s7.hclass.s8.key.s9 have (↑u : ℝ) = (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ)

            Leaves (↑(u / (↑q : ℤ)) : ℝ) * (↑q : ℝ) ≤ N - (↑c : ℝ), with hreal : (↑u : ℝ) = (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ).

            Lean, lines 191–194
                        have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
                          have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                          push_cast at this
                          exact this

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 191–194 at f0dfc93f9827 ↗

            1. s7.hclass.s8.key.s9.this have (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ)

              Leaves (↑u : ℝ) = (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ), with this : (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ).

              Uses library congrArg Congruence in the function argument: if a₁ = a₂ then f a₁ = f a₂ for any (nondependent) function f. .

              Lean, line 192
                            have := congrArg (fun z : ℤ => (z : ℝ)) hdu

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 192 at f0dfc93f9827 ↗

          10. s7.hclass.s8.key.s10 have (↑u : ℝ) ≤ N

            Leaves (↑(u / (↑q : ℤ)) : ℝ) * (↑q : ℝ) ≤ N - (↑c : ℝ), with this : (↑u : ℝ) ≤ N.

            Uses library le_trans The relation ≤ on a preorder is transitive. , Int.floor_le.

            Lean, line 195
                        have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 195 at f0dfc93f9827 ↗

          11. s7.hclass.s8.key.s11 obtain ∃ a ∈ T, a / (↑q : ℤ) = t

            Leaves ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with u : ℤ, hu : u ∈ T.

            Lean, line 200
                        obtain ⟨u, hu, rfl⟩ := ht

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 200 at f0dfc93f9827 ↗

          12. s7.hclass.s8.key.s12 obtain ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ

            Leaves ∃ (v : ℤ) (w : ℕ), (0 : ℕ) < w ∧ (↑w : ℝ) ≤ W ∧ |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with v : ℤ, w : ℕ, hw0 : (0 : ℕ) < w, hwW : (↑w : ℝ) ≤ W, hvw : |f (↑u : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ.

            Lean, line 201
                        obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 201 at f0dfc93f9827 ↗

          13. s7.hclass.s8.key.s13 have u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))

            Leaves |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with hdu : u = (↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ)).

            Lean, line 203
                        have hdu := hdecomp u hu

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 203 at f0dfc93f9827 ↗

          14. s7.hclass.s8.key.s14 have (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ) = (↑u : ℝ)

            Leaves |g (↑(u / (↑q : ℤ)) : ℝ) - (↑v : ℝ) / (↑w : ℝ)| < δ, with hreal : (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ) = (↑u : ℝ).

            Lean, lines 204–207
                        have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
                          have := congrArg (fun z : ℤ => (z : ℝ)) hdu
                          push_cast at this
                          exact this.symm

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 204–207 at f0dfc93f9827 ↗

            1. s7.hclass.s8.key.s14.this have (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ)

              Leaves (↑c : ℝ) + (↑q : ℝ) * (↑(u / (↑q : ℤ)) : ℝ) = (↑u : ℝ), with this : (↑u : ℝ) = (↑((↑c : ℤ) + (↑q : ℤ) * (u / (↑q : ℤ))) : ℝ).

              Uses library congrArg Congruence in the function argument: if a₁ = a₂ then f a₁ = f a₂ for any (nondependent) function f. .

              Lean, line 205
                            have := congrArg (fun z : ℤ => (z : ℝ)) hdu

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 205 at f0dfc93f9827 ↗

        7. s7.hclass.s8.this have (65536 : ℝ) * N' * X ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with this : (65536 : ℝ) * N' * X ≤ (65536 : ℝ) * (N / (↑q : ℝ)) * X.

          Uses library mul_le_mul_of_nonneg_right, mul_le_mul_of_nonneg_left, div_le_div_of_nonneg_right.

          Lean, lines 212–218
                  have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
                    apply mul_le_mul_of_nonneg_right _ hX0
                    apply mul_le_mul_of_nonneg_left _ (by norm_num)
                    rw [hN']
                    apply div_le_div_of_nonneg_right _ hqpos.le
                    have : (0 : ℝ) ≤ c := by positivity
                    linarith

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 212–218 at f0dfc93f9827 ↗

          1. s7.hclass.s8.this.this have (0 : ℝ) ≤ (↑c : ℝ) routine: positivity

            Leaves N - (↑c : ℝ) ≤ N, with this : (0 : ℝ) ≤ (↑c : ℝ).

            Lean, line 217
                      have : (0 : ℝ) ≤ c := by positivity

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 217 at f0dfc93f9827 ↗

      9. s7.hclass.s9 case

        Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hNc : ¬(↑c : ℝ) < N.

        Lean, lines 220–241
              · push_neg at hNc
                -- the class contains at most the single point `c`
                have hle : T.card ≤ 1 := by
                  rw [Finset.card_le_one]
                  intro u hu u' hu'
                  have key : ∀ x ∈ T, x = c := by
                    intro x hx
                    have hxS := (hmem x hx).1
                    obtain ⟨hx0, hx1⟩ := hS x hxS
                    have hdx := hdecomp x hx
                    have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                    have hxc : x ≤ c := by
                      have : (x : ℝ) ≤ c := le_trans hxN hNc
                      exact_mod_cast this
                    have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                    have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                    have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                    have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                    omega
                  rw [key u hu, key u' hu']
                have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
                linarith

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 220–241 at f0dfc93f9827 ↗

        1. s7.hclass.s9.hle have T.card ≤ (1 : ℕ)

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with hle : T.card ≤ (1 : ℕ).

          Uses library Finset.card_le_one.

          Lean, lines 222–239
                  have hle : T.card ≤ 1 := by
                    rw [Finset.card_le_one]
                    intro u hu u' hu'
                    have key : ∀ x ∈ T, x = c := by
                      intro x hx
                      have hxS := (hmem x hx).1
                      obtain ⟨hx0, hx1⟩ := hS x hxS
                      have hdx := hdecomp x hx
                      have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                      have hxc : x ≤ c := by
                        have : (x : ℝ) ≤ c := le_trans hxN hNc
                        exact_mod_cast this
                      have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                      have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                      have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                      have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                      omega
                    rw [key u hu, key u' hu']

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 222–239 at f0dfc93f9827 ↗

          1. s7.hclass.s9.hle.key have ∀ x ∈ T, x = (↑c : ℤ)

            Leaves u = u', with key : ∀ x ∈ T, x = (↑c : ℤ).

            Lean, lines 225–238
                      have key : ∀ x ∈ T, x = c := by
                        intro x hx
                        have hxS := (hmem x hx).1
                        obtain ⟨hx0, hx1⟩ := hS x hxS
                        have hdx := hdecomp x hx
                        have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
                        have hxc : x ≤ c := by
                          have : (x : ℝ) ≤ c := le_trans hxN hNc
                          exact_mod_cast this
                        have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
                        have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
                        have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
                        have := Int.eq_zero_of_abs_lt_dvd hdvd habs
                        omega

            targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 225–238 at f0dfc93f9827 ↗

            1. s7.hclass.s9.hle.key.hxS have x ∈ S
            2. s7.hclass.s9.hle.key.s2 obtain (0 : ℤ) ≤ x ∧ x ≤ ⌊N⌋

              Leaves x = (↑c : ℤ), with hx0 : (0 : ℤ) ≤ x, hx1 : x ≤ ⌊N⌋.

              Lean, line 228
                          obtain ⟨hx0, hx1⟩ := hS x hxS

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 228 at f0dfc93f9827 ↗

            3. s7.hclass.s9.hle.key.hdx have x = (↑c : ℤ) + (↑q : ℤ) * (x / (↑q : ℤ))

              Leaves x = (↑c : ℤ), with hdx : x = (↑c : ℤ) + (↑q : ℤ) * (x / (↑q : ℤ)).

              Lean, line 229
                          have hdx := hdecomp x hx

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 229 at f0dfc93f9827 ↗

            4. s7.hclass.s9.hle.key.hxN have (↑x : ℝ) ≤ N

              Leaves x = (↑c : ℤ), with hxN : (↑x : ℝ) ≤ N.

              Uses library le_trans The relation ≤ on a preorder is transitive. , Int.floor_le.

              Lean, line 230
                          have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 230 at f0dfc93f9827 ↗

            5. s7.hclass.s9.hle.key.hxc have x ≤ (↑c : ℤ)

              Leaves x = (↑c : ℤ), with hxc : x ≤ (↑c : ℤ).

              Lean, lines 231–233
                          have hxc : x ≤ c := by
                            have : (x : ℝ) ≤ c := le_trans hxN hNc
                            exact_mod_cast this

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 231–233 at f0dfc93f9827 ↗

              1. s7.hclass.s9.hle.key.hxc.this have (↑x : ℝ) ≤ (↑c : ℝ)

                Leaves x ≤ (↑c : ℤ), with this : (↑x : ℝ) ≤ (↑c : ℝ).

                Uses library le_trans The relation ≤ on a preorder is transitive. .

                Lean, line 232
                              have : (x : ℝ) ≤ c := le_trans hxN hNc

                targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 232 at f0dfc93f9827 ↗

            6. s7.hclass.s9.hle.key.hcq' have (↑c : ℤ) < (↑q : ℤ)

              Leaves x = (↑c : ℤ), with hcq' : (↑c : ℤ) < (↑q : ℤ).

              Lean, line 234
                          have hcq' : (c : ℤ) < q := by exact_mod_cast hcq

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 234 at f0dfc93f9827 ↗

            7. s7.hclass.s9.hle.key.hdvd have (↑q : ℤ) ∣ x - (↑c : ℤ)

              Leaves x = (↑c : ℤ), with hdvd : (↑q : ℤ) ∣ x - (↑c : ℤ).

              Uses library Exists.intro Existential introduction. .

              Lean, line 235
                          have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 235 at f0dfc93f9827 ↗

            8. s7.hclass.s9.hle.key.habs have |x - (↑c : ℤ)| < (↑q : ℤ)

              Leaves x = (↑c : ℤ), with habs : |x - (↑c : ℤ)| < (↑q : ℤ).

              Uses library abs_lt.

              Lean, line 236
                          have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 236 at f0dfc93f9827 ↗

            9. s7.hclass.s9.hle.key.this have x - (↑c : ℤ) = (0 : ℤ)

              Leaves x = (↑c : ℤ), with this : x - (↑c : ℤ) = (0 : ℤ).

              Uses library Int.eq_zero_of_abs_lt_dvd.

              Lean, line 237
                          have := Int.eq_zero_of_abs_lt_dvd hdvd habs

              targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 237 at f0dfc93f9827 ↗

        2. s7.hclass.s9.this have (↑T.card : ℝ) ≤ (1 : ℝ)

          Leaves (↑T.card : ℝ) < (65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam', with this : (↑T.card : ℝ) ≤ (1 : ℝ).

          Lean, line 240
                  have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 240 at f0dfc93f9827 ↗

    11. s7.hsum have (↑S.card : ℝ) = ∑ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ)

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hsum : (↑S.card : ℝ) = ∑ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ).

      Uses library Finset.range range n is the set of natural numbers less than n. , Finset.card_eq_sum_card_fiberwise.

      Lean, lines 242–252
          have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
              ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
            rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
              (t := Finset.range q)]
            · push_cast; rfl
            · intro u _
              simp only [Finset.coe_range, Set.mem_Iio]
              have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
              have h1 := Int.emod_nonneg u hqZ.ne'
              have h2 := Int.emod_lt_of_pos u hqZ
              omega

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 242–252 at f0dfc93f9827 ↗

      1. s7.hsum.s1 case

        Leaves (↑(∑ b ∈ Finset.range q, {a ∈ S | (a % (↑q : ℤ)).toNat = b}.card) : ℝ) = ∑ c ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = c}.card : ℝ).

        Lean, line 246
              · push_cast; rfl

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 246 at f0dfc93f9827 ↗

      2. s7.hsum.s2 case

        Leaves Set.MapsTo (fun (u : ℤ) => (u % (↑q : ℤ)).toNat) (↑S : Set ℤ) (↑(Finset.range q) : Set ℕ).

        Uses library Finset.coe_range, Set.mem_Iio.

        Lean, lines 247–252
              · intro u _
                simp only [Finset.coe_range, Set.mem_Iio]
                have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
                have h1 := Int.emod_nonneg u hqZ.ne'
                have h2 := Int.emod_lt_of_pos u hqZ
                omega

        targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 247–252 at f0dfc93f9827 ↗

        1. s7.hsum.s2.hqZ have (0 : ℤ) < (↑q : ℤ)

          Leaves (u % (↑q : ℤ)).toNat < q, with hqZ : (0 : ℤ) < (↑q : ℤ).

          Lean, line 249
                  have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 249 at f0dfc93f9827 ↗

        2. s7.hsum.s2.h1 have (0 : ℤ) ≤ u % (↑q : ℤ)

          Leaves (u % (↑q : ℤ)).toNat < q, with h1 : (0 : ℤ) ≤ u % (↑q : ℤ).

          Uses library Int.emod_nonneg.

          Lean, line 250
                  have h1 := Int.emod_nonneg u hqZ.ne'

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 250 at f0dfc93f9827 ↗

        3. s7.hsum.s2.h2 have u % (↑q : ℤ) < (↑q : ℤ)

          Leaves (u % (↑q : ℤ)).toNat < q, with h2 : u % (↑q : ℤ) < (↑q : ℤ).

          Uses library Int.emod_lt_of_pos.

          Lean, line 251
                  have h2 := Int.emod_lt_of_pos u hqZ

          targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 251 at f0dfc93f9827 ↗

    12. s7.hlt have ∑ i ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = i}.card : ℝ) < ∑ i ∈ Finset.range q, ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam')

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with hlt : ∑ i ∈ Finset.range q, (↑{u ∈ S | (u % (↑q : ℤ)).toNat = i}.card : ℝ) < ∑ i ∈ Finset.range q, ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam').

      Uses library Finset.sum_lt_sum_of_nonempty In an ordered additive commutative monoid, if each summand f i of one nontrivial finite sum is strictly less than the corresponding summand g i of another nontrivial finite sum, then s.sum f < s.sum g. , Finset.nonempty_range_iff.

      Lean, line 253
          have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, line 253 at f0dfc93f9827 ↗

    13. s7.this have (↑q : ℝ) * ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam') = (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam

      Leaves (↑S.card : ℝ) < (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam, with this : (↑q : ℝ) * ((65536 : ℝ) * (N / (↑q : ℝ)) * X + (2 : ℝ) * (↑r : ℝ) * lam') = (65536 : ℝ) * N * X + (2 : ℝ) * (↑r : ℝ) * lam.

      Lean, lines 255–257
          have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
              = 65536 * N * X + 2 * (r : ℝ) * lam := by
            rw [hlam']; field_simp

      targets/erdos-1094/nodes/erdos-1094--h2--h2--h2--h3--h1--h1/attempts/20261015T063320Z-opn-prove-aristotle-1015-partial.lean, lines 255–257 at f0dfc93f9827 ↗

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

open scoped Nat

/-! Hole `h_thm` 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 : ∀ (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 : ℝ)| < δ) →
                                            (↑S.card : ℝ) <
                                              (65536 : ℝ) * 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 : ℝ))⁻¹) +
                                                (2 : ℝ) * (↑r : ℝ) * lam := by
  intro r hr N hN W hW δ hδ lam hlam D_r hDr D_r1 hDr1 f hf h1 h2 h3 S hS hS2
  set 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 : ℝ))⁻¹ with hXdef
  have hfl : (0 : ℤ) ≤ ⌊N⌋ := Int.floor_nonneg.mpr hN.le
  have hsub : S ⊆ Finset.Icc (0 : ℤ) ⌊N⌋ := fun u hu => by
    obtain ⟨a, b⟩ := hS u hu
    exact Finset.mem_Icc.mpr ⟨a, b⟩
  have hcardZ : (S.card : ℤ) ≤ ⌊N⌋ + 1 := by
    have := Finset.card_le_card hsub
    rw [Int.card_Icc] at this
    omega
  have hcard : (S.card : ℝ) ≤ N + 1 := by
    have h' : ((S.card : ℤ) : ℝ) ≤ ((⌊N⌋ + 1 : ℤ) : ℝ) := by exact_mod_cast hcardZ
    push_cast at h'
    linarith [Int.floor_le N]
  have hr2 : (4 : ℝ) ≤ 2 * (r : ℝ) * lam := by
    have : (2 : ℝ) ≤ r := by exact_mod_cast hr
    nlinarith
  by_cases hX : 1 ≤ 65536 * X
  · have : N ≤ 65536 * N * X := by nlinarith
    linarith
  · push_neg at hX
    -- the remaining (hard) case, for a scale parameter in `[1, 2)`
    have core : ∀ (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
      sorry
    -- reduction of a general scale `lam` to a scale in `[1, 2)` via residue classes
    set q : ℕ := ⌊lam⌋₊ with hqdef
    have hq1 : 1 ≤ q := Nat.le_floor (by exact_mod_cast hlam)
    have hqpos : (0 : ℝ) < q := by exact_mod_cast hq1
    have hqle : (q : ℝ) ≤ lam := Nat.floor_le (by linarith)
    have hqlt : lam < q + 1 := Nat.lt_floor_add_one lam
    set lam' : ℝ := lam / q with hlam'
    have hl1 : 1 ≤ lam' := by rw [hlam', le_div_iff₀ hqpos]; linarith
    have hl2 : lam' < 2 := by
      rw [hlam', div_lt_iff₀ hqpos]
      have : (1 : ℝ) ≤ q := by exact_mod_cast hq1
      linarith
    have hX0 : 0 ≤ X := by
      rw [hXdef]
      have := hDr.le; have := hDr1.le; have := hδ.le
      have hl0 : 0 ≤ lam := by linarith
      positivity
    have hXinv : (D_r * q ^ r * lam' ^ r * W ^ (2 : ℕ)) ^ ((2 : ℝ) * (↑r : ℝ) - (1 : ℝ))⁻¹ +
        (δ * W ^ (2 : ℕ) / (D_r * q ^ r * lam' ^ r)) ^ ((↑r : ℝ) - (1 : ℝ))⁻¹ +
        (D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)) ^ ((2 : ℝ) * (↑r : ℝ))⁻¹
        = X := by
      have e1 : (q : ℝ) ^ r * lam' ^ r = lam ^ r := by
        rw [← mul_pow, hlam', mul_div_cancel₀ _ hqpos.ne']
      have e2 : D_r1 * q ^ (r + 1) * lam' * W ^ (2 : ℕ) / (D_r * q ^ r)
          = D_r1 * lam * W ^ (2 : ℕ) / D_r := by
        rw [hlam']; field_simp; ring
      rw [hXdef, e2, mul_assoc D_r, e1]
    have hclass : ∀ c ∈ Finset.range q,
        ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ)
          < 65536 * (N / q) * X + 2 * (r : ℝ) * lam' := by
      intro c hc
      have hcq : c < q := Finset.mem_range.mp hc
      set T := S.filter (fun u => (u % (q : ℤ)).toNat = c) with hT
      have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
      have hmem : ∀ u ∈ T, u ∈ S ∧ u % (q : ℤ) = c := by
        intro u hu
        rw [hT, Finset.mem_filter] at hu
        refine ⟨hu.1, ?_⟩
        have h0 : 0 ≤ u % (q : ℤ) := Int.emod_nonneg _ hqZ.ne'
        omega
      have hdecomp : ∀ u ∈ T, u = c + q * (u / q) := by
        intro u hu
        have := Int.emod_add_mul_ediv u q
        rw [(hmem u hu).2] at this
        omega
      set T' := T.image (fun u => u / (q : ℤ)) with hT'
      have hcardT : T'.card = T.card := by
        apply Finset.card_image_of_injOn
        intro u hu u' hu' huu
        simp only at huu
        rw [hdecomp u hu, hdecomp u' hu', huu]
      have hlam'pos : (4 : ℝ) ≤ 2 * (r : ℝ) * lam' := by
        have : (2 : ℝ) ≤ r := by exact_mod_cast hr
        nlinarith
      have hNq : 0 ≤ 65536 * (N / q) * X := by positivity
      by_cases hNc : (c : ℝ) < N
      · set N' : ℝ := (N - c) / q with hN'
        have hN'pos : 0 < N' := div_pos (by linarith) hqpos
        set g : ℝ → ℝ := fun t => f (c + q * t) with hg
        have hgfun : ∀ k : ℕ, k ≤ r + 1 → ∀ t, iteratedDeriv k g t
            = (q : ℝ) ^ k * iteratedDeriv k f (c + q * t) := by
          intro k hk t
          have hf1 : ContDiff ℝ k (fun z => f (c + z)) := by
            have : ContDiff ℝ k f := hf.of_le (by exact_mod_cast hk)
            exact this.comp (contDiff_const.add contDiff_id)
          have := iteratedDeriv_comp_const_mul hf1 (q : ℝ)
          have h2 := congrFun this t
          try simp only at h2
          rw [show g = fun x => (fun z => f (c + z)) (q * x) from rfl, h2,
            iteratedDeriv_comp_const_add]
        have hgC : ContDiff ℝ (↑(↑(r + (1 : ℕ)) : ℕ∞) : WithTop ℕ∞) g :=
          hf.comp (contDiff_const.add (contDiff_const.mul contDiff_id))
        have hIcc : ∀ x ∈ Set.Icc (0 : ℝ) N', (c : ℝ) + q * x ∈ Set.Icc (0 : ℝ) N := by
          intro x hx
          obtain ⟨hx0, hx1⟩ := hx
          constructor
          · positivity
          · have : (q : ℝ) * x ≤ q * N' := mul_le_mul_of_nonneg_left hx1 hqpos.le
            rw [hN', mul_div_cancel₀ _ hqpos.ne'] at this
            linarith
        have hqr : (0 : ℝ) < (q : ℝ) ^ r := pow_pos hqpos r
        have key := core N' hN'pos lam' hl1 hl2 (D_r * q ^ r) (by positivity)
          (D_r1 * q ^ (r + 1)) (by positivity) g hgC
          (by
            intro x hx
            rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
            have := h1 _ (hIcc x hx)
            nlinarith)
          (by
            intro x hx
            rw [hgfun r (by omega), abs_mul, abs_of_pos hqr]
            have := h2 _ (hIcc x hx)
            nlinarith)
          (by
            intro x hx
            rw [hgfun (r + 1) le_rfl, abs_mul, abs_of_pos (pow_pos hqpos _)]
            have := h3 _ (hIcc x hx)
            have : (0 : ℝ) < (q : ℝ) ^ (r + 1) := pow_pos hqpos _
            nlinarith)
          T'
          (by
            intro t ht
            rw [hT', Finset.mem_image] at ht
            obtain ⟨u, hu, rfl⟩ := ht
            have huS := (hmem u hu).1
            obtain ⟨hu0, hu1⟩ := hS u huS
            refine ⟨Int.ediv_nonneg hu0 hqZ.le, ?_⟩
            apply Int.le_floor.mpr
            rw [hN', le_div_iff₀ hqpos]
            have hdu := hdecomp u hu
            have hreal : (u : ℝ) = c + q * ((u / q : ℤ) : ℝ) := by
              have := congrArg (fun z : ℤ => (z : ℝ)) hdu
              push_cast at this
              exact this
            have : (u : ℝ) ≤ N := le_trans (by exact_mod_cast hu1) (Int.floor_le N)
            linarith)
          (by
            intro t ht
            rw [hT', Finset.mem_image] at ht
            obtain ⟨u, hu, rfl⟩ := ht
            obtain ⟨v, w, hw0, hwW, hvw⟩ := hS2 u (hmem u hu).1
            refine ⟨v, w, hw0, hwW, ?_⟩
            have hdu := hdecomp u hu
            have hreal : (c : ℝ) + q * ((u / q : ℤ) : ℝ) = u := by
              have := congrArg (fun z : ℤ => (z : ℝ)) hdu
              push_cast at this
              exact this.symm
            simp only [hg, hreal]
            exact hvw)
          (by rw [hXinv]; exact hX)
        rw [hXinv, hcardT] at key
        have : 65536 * N' * X ≤ 65536 * (N / q) * X := by
          apply mul_le_mul_of_nonneg_right _ hX0
          apply mul_le_mul_of_nonneg_left _ (by norm_num)
          rw [hN']
          apply div_le_div_of_nonneg_right _ hqpos.le
          have : (0 : ℝ) ≤ c := by positivity
          linarith
        linarith
      · push_neg at hNc
        -- the class contains at most the single point `c`
        have hle : T.card ≤ 1 := by
          rw [Finset.card_le_one]
          intro u hu u' hu'
          have key : ∀ x ∈ T, x = c := by
            intro x hx
            have hxS := (hmem x hx).1
            obtain ⟨hx0, hx1⟩ := hS x hxS
            have hdx := hdecomp x hx
            have hxN : (x : ℝ) ≤ N := le_trans (by exact_mod_cast hx1) (Int.floor_le N)
            have hxc : x ≤ c := by
              have : (x : ℝ) ≤ c := le_trans hxN hNc
              exact_mod_cast this
            have hcq' : (c : ℤ) < q := by exact_mod_cast hcq
            have hdvd : (q : ℤ) ∣ x - c := ⟨x / q, by omega⟩
            have habs : |x - (c : ℤ)| < q := by rw [abs_lt]; constructor <;> omega
            have := Int.eq_zero_of_abs_lt_dvd hdvd habs
            omega
          rw [key u hu, key u' hu']
        have : (T.card : ℝ) ≤ 1 := by exact_mod_cast hle
        linarith
    have hsum : (S.card : ℝ) = ∑ c ∈ Finset.range q,
        ((S.filter (fun u => (u % (q : ℤ)).toNat = c)).card : ℝ) := by
      rw [Finset.card_eq_sum_card_fiberwise (f := fun u => (u % (q : ℤ)).toNat)
        (t := Finset.range q)]
      · push_cast; rfl
      · intro u _
        simp only [Finset.coe_range, Set.mem_Iio]
        have hqZ : (0 : ℤ) < q := by exact_mod_cast hq1
        have h1 := Int.emod_nonneg u hqZ.ne'
        have h2 := Int.emod_lt_of_pos u hqZ
        omega
    have hlt := Finset.sum_lt_sum_of_nonempty (Finset.nonempty_range_iff.mpr (by omega)) hclass
    rw [← hsum, Finset.sum_const, Finset.card_range, nsmul_eq_mul] at hlt
    have : (q : ℝ) * (65536 * (N / q) * X + 2 * (r : ℝ) * lam')
        = 65536 * N * X + 2 * (r : ℝ) * lam := by
      rw [hlam']; field_simp
    linarith
How to read this page