Documentation

LeanPool.DistinctDistances.ChordBoxBound

The sharp same-side chord bound on an (apex distance, radius) box #

Formalizes Lemma C and Lemma C′ of docs/results/explicit-constant-gain-5-239-2026-10-20.md (§2), the chord evaluator chord_sq_box / Chords._adapt of scripts/verify_constant_gain_5_239.py, which scripts/verify_constant_gain_1_40.py uses for the chord side conditions C(I, t). All lengths carry the scale ρ; thresholds are squared.

Setting. Let c be a centre, ρ > 0, and let three points q i lie in the annulus σ²ρ² ≤ |x - c|² ≤ ρ², all at the same distance r = Rρ from an apex p with |p - c| = Aρ. In the frame with p - c on the positive first axis, a point of the circle is q = p + (X, Y) with X² + Y² = r² and |q - c|² = (A² + R²)ρ² + 2AρX, so the annulus condition reads X / r ∈ [L, L + w] with

L = (σ² - A² - R²) / (2AR), w = (1 - σ²) / (2AR).

Two of the three points lie on the same side of the axis (three_has_same_transverse_side).

The cosine window #

theorem Esgk.same_side_inner_ge_of_mem_cosine_window {X Y X' Y' r u v : ℝ} (hr : 0 < r) (h1 : X ^ 2 + Y ^ 2 = r ^ 2) (h2 : X' ^ 2 + Y' ^ 2 = r ^ 2) (hside : 0 ≤ Y * Y') (hu : -1 ≤ u) (hv : v ≤ 1) (hX : r * u ≤ X ∧ X ≤ r * v) (hX' : r * u ≤ X' ∧ X' ≤ r * v) :
r ^ 2 * (u * v + √(1 - u ^ 2) * √(1 - v ^ 2)) ≤ X * X' + Y * Y'

Cosine window (Lemma C, inner-product form). Two points (X, Y), (X', Y') of the circle of radius r > 0 about the origin on the same side of the first axis (0 ≤ Y Y'), whose first coordinates lie in the window [r u, r v] with -1 ≤ u and v ≤ 1, have inner product at least r² (u v + √(1 - u²) √(1 - v²)), the value at the two ends of the window.

theorem Esgk.same_side_chord_sq_le_of_mem_cosine_window {X Y X' Y' r u v : ℝ} (hr : 0 < r) (h1 : X ^ 2 + Y ^ 2 = r ^ 2) (h2 : X' ^ 2 + Y' ^ 2 = r ^ 2) (hside : 0 ≤ Y * Y') (hu : -1 ≤ u) (hv : v ≤ 1) (hX : r * u ≤ X ∧ X ≤ r * v) (hX' : r * u ≤ X' ∧ X' ≤ r * v) :
(X - X') ^ 2 + (Y - Y') ^ 2 ≤ 2 * r ^ 2 * (1 - (u * v + √(1 - u ^ 2) * √(1 - v ^ 2)))

Cosine window (Lemma C, chord form). Two points of the circle of radius r > 0 about the origin on the same side of the first axis, with first coordinates in [r u, r v] (-1 ≤ u, v ≤ 1), are at squared distance at most 2 r² (1 - (u v + √(1 - u²) √(1 - v²))).

The arc window #

The clamp of a real number to [-1, 1], max (-1) (min 1 x) (cl of Lemma C).

Equations
Instances For

    The square-root-free form of β ≤ u v + √((1 - u²)(1 - v²)) at the clamped window u = cl L, v = cl (L + w) of Lemma C′: either β ≤ u v, or (β - u v)² ≤ (1 - u²)(1 - v²). It says that β is at most the cosine of the arc arccos (cl L) - arccos (cl (L + w)).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The box lemma #

      theorem Esgk.exists_dist_sq_le_of_mem_chord_box (c p : Point) (q : Fin 3 → Point) {ρ σ a0 a1 r0 r1 Llo Lhi w β : ℝ} (hρ : 0 < ρ) (ha0 : 0 < a0) (hr0 : 0 < r0) (hσa : σ ^ 2 ≤ a0 ^ 2 + r0 ^ 2) (hLlo : Llo * (2 * a0 * r0) ≤ σ ^ 2 - a1 ^ 2 - r1 ^ 2) (hLhi : σ ^ 2 - a0 ^ 2 - r0 ^ 2 ≤ Lhi * (2 * a1 * r1)) (hw : 1 - σ ^ 2 ≤ w * (2 * a0 * r0)) (hβlo : WindowCosineBound β Llo w) (hβhi : WindowCosineBound β Lhi w) (hβm : Llo ≤ -1 → -1 ≤ Lhi → WindowCosineBound β (-1) w) (hβw : Llo ≤ 1 - w → 1 - w ≤ Lhi → WindowCosineBound β (1 - w) w) (hlo : ∀ (i : Fin 3), σ ^ 2 * ρ ^ 2 ≤ dist (q i) c ^ 2) (hhi : ∀ (i : Fin 3), dist (q i) c ^ 2 ≤ ρ ^ 2) (heq : ∀ (i j : Fin 3), dist p (q i) = dist p (q j)) (hpa0 : a0 * ρ ≤ dist p c) (hpa1 : dist p c ≤ a1 * ρ) (hpr0 : r0 * ρ ≤ dist p (q 0)) (hpr1 : dist p (q 0) ≤ r1 * ρ) :
      ∃ (i : Fin 3) (j : Fin 3), i ≠ j ∧ dist (q i) (q j) ^ 2 ≤ 2 * r1 ^ 2 * (1 - β) * ρ ^ 2

      Lemma C′ (box lemma). Let three points q i lie in the annulus σ²ρ² ≤ |q i - c|² ≤ ρ², all at the same distance r from an apex p, with a0 ρ ≤ |p - c| ≤ a1 ρ and r0 ρ ≤ r ≤ r1 ρ, 0 < a0, 0 < r0 and σ² ≤ a0² + r0² (for instance σ ≤ a0). Let Llo, Lhi, w bound the window of the box, Llo ≤ (σ² - a1² - r1²)/(2 a0 r0), (σ² - a0² - r0²)/(2 a1 r1) ≤ Lhi, (1 - σ²)/(2 a0 r0) ≤ w (stated multiplied out), and let β satisfy the square-root-free candidate condition WindowCosineBound β L w at L = Llo, L = Lhi, L = -1 when -1 ∈ [Llo, Lhi] and L = 1 - w when 1 - w ∈ [Llo, Lhi]. Then two of the three points are at squared distance at most 2 r1² (1 - β) ρ². This is chord_sq_box of scripts/verify_constant_gain_5_239.py with β its worst_cos, in units of ρ.

      theorem Esgk.exists_dist_sq_le_four_mul_sq (p : Point) (q : Fin 3 → Point) {ρ r1 : ℝ} (heq : ∀ (i j : Fin 3), dist p (q i) = dist p (q j)) (hpr1 : dist p (q 0) ≤ r1 * ρ) :
      ∃ (i : Fin 3) (j : Fin 3), i ≠ j ∧ dist (q i) (q j) ^ 2 ≤ 4 * r1 ^ 2 * ρ ^ 2

      The trivial cell of Lemma C′. Three points at the same distance r ≤ r1 ρ from an apex contain a pair at squared distance at most 4 r1² ρ² (the chord is at most 2r). This is the r0 = 0 cell 4 r1² of scripts/verify_constant_gain_5_239.py.

      The box tree over the rationals #

      The clamp to [-1, 1] on rationals; its cast to ℝ is unitClamp.

      Equations
      Instances For

        The rational check of WindowCosineBound β L w, with products in place of squares.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          def Esgk.chordBoxCheck (σ T a0 a1 r0 r1 β : ℚ) :

          The rational check of one box [a0, a1] × [r0, r1] of Lemma C′ with cosine bound β against the squared target T: 0 < a0, 0 < r0, σ² ≤ a0² + r0², the candidate conditions at the exact window ends Llo = (σ² - a1² - r1²)/(2 a0 r0), Lhi = (σ² - a0² - r0²)/(2 a1 r1) and width w = (1 - σ²)/(2 a0 r0), and 2 r1² (1 - β) ≤ T. This is chord_sq_box ≤ target of scripts/verify_constant_gain_5_239.py.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            A refinement tree of a rational (apex distance, radius) box [a0, a1] × [r0, r1], as the adaptive refinement Chords._adapt of scripts/verify_constant_gain_5_239.py: leaves carry the bound of Lemma C′ or the trivial bound, inner nodes halve the box at midpoints.

            • cert (β : ℚ) : ChordBoxTree

              A leaf certified by Lemma C′ with the rational cosine bound β (chordBoxCheck).

            • disk : ChordBoxTree

              A leaf certified by the trivial bound 4 r1² (any box, in particular r0 = 0).

            • split (t₁ t₂ t₃ t₄ : ChordBoxTree) : ChordBoxTree

              Quartering at the midpoints am, rm: the children are the boxes [a0, am] × [r0, rm], [a0, am] × [rm, r1], [am, a1] × [r0, rm] and [am, a1] × [rm, r1].

            • splitApex (t₁ t₂ : ChordBoxTree) : ChordBoxTree

              Halving the apex interval: [a0, am] × [r0, r1] and [am, a1] × [r0, r1].

            • splitRadius (t₁ t₂ : ChordBoxTree) : ChordBoxTree

              Halving the radius interval: [a0, a1] × [r0, rm] and [a0, a1] × [rm, r1].

            Instances For
              def Esgk.ChordBoxTree.check (σ T : ℚ) :
              ChordBoxTree → ℚ → ℚ → ℚ → ℚ → Bool

              The structurally recursive check of a box tree on the box [a0, a1] × [r0, r1] for the annulus parameter σ and the squared target T: every cert leaf passes chordBoxCheck and every disk leaf has 4 r1² ≤ T. Rational arithmetic only, for decide +kernel.

              Equations
              Instances For
                theorem Esgk.ChordBoxTree.exists_dist_sq_le_of_check (c p : Point) (q : Fin 3 → Point) {ρ : ℝ} {σ T : ℚ} (hρ : 0 < ρ) (hlo : ∀ (i : Fin 3), ↑σ ^ 2 * ρ ^ 2 ≤ dist (q i) c ^ 2) (hhi : ∀ (i : Fin 3), dist (q i) c ^ 2 ≤ ρ ^ 2) (heq : ∀ (i j : Fin 3), dist p (q i) = dist p (q j)) (t : ChordBoxTree) {a0 a1 r0 r1 : ℚ} :
                check σ T t a0 a1 r0 r1 = true → ↑a0 * ρ ≤ dist p c → dist p c ≤ ↑a1 * ρ → ↑r0 * ρ ≤ dist p (q 0) → dist p (q 0) ≤ ↑r1 * ρ → ∃ (i : Fin 3) (j : Fin 3), i ≠ j ∧ dist (q i) (q j) ^ 2 ≤ ↑T * ρ ^ 2

                Soundness of the box tree. If t.check σ T a0 a1 r0 r1 = true, then for every configuration of three points q i of the annulus σ²ρ² ≤ |q i - c|² ≤ ρ² at a common distance r from an apex p with a0 ρ ≤ |p - c| ≤ a1 ρ and r0 ρ ≤ r ≤ r1 ρ, two of the points are at squared distance at most T ρ². This is Chords._adapt of scripts/verify_constant_gain_5_239.py returning True on the box, in units of ρ.

                def Esgk.chordApexCellsCheck (σ T r0 r1 : ℚ) :

                The check of the apex cells [a, a₁], [a₁, a₂], …, [a_{k-1}, a_k] with a_k ≥ 1 (the list holds the pairs (a_m, tree_m)), all for the radius cell [r0, r1]: every tree passes ChordBoxTree.check on its cell. Started at a = σ it is the 32 apex cells of Chords.holds_on of scripts/verify_constant_gain_5_239.py for one radius cell.

                Equations
                Instances For
                  theorem Esgk.exists_dist_sq_le_of_chordApexCellsCheck (c p : Point) (q : Fin 3 → Point) {ρ : ℝ} {σ T r0 r1 : ℚ} (hρ : 0 < ρ) (hlo : ∀ (i : Fin 3), ↑σ ^ 2 * ρ ^ 2 ≤ dist (q i) c ^ 2) (hhi : ∀ (i : Fin 3), dist (q i) c ^ 2 ≤ ρ ^ 2) (heq : ∀ (i j : Fin 3), dist p (q i) = dist p (q j)) (hpc : dist p c ≤ ρ) (hpr0 : ↑r0 * ρ ≤ dist p (q 0)) (hpr1 : dist p (q 0) ≤ ↑r1 * ρ) (cells : List (ℚ × ChordBoxTree)) {a : ℚ} :
                  chordApexCellsCheck σ T r0 r1 a cells = true → ↑a * ρ ≤ dist p c → ∃ (i : Fin 3) (j : Fin 3), i ≠ j ∧ dist (q i) (q j) ^ 2 ≤ ↑T * ρ ^ 2

                  Soundness of the apex cells. If chordApexCellsCheck σ T r0 r1 a cells = true, then for every configuration of three points q i of the annulus σ²ρ² ≤ |q i - c|² ≤ ρ² at a common distance r from an apex p with a ρ ≤ |p - c| ≤ ρ and r0 ρ ≤ r ≤ r1 ρ, two of the points are at squared distance at most T ρ².

                  The check of the radius cells [lo, r₁], [r₁, r₂], …, [r_{k-1}, r_k] with r_k ≥ hi (the list holds the pairs (r_m, apex cells_m)): the apex cells of each radius cell, started at σ, pass chordApexCellsCheck. This is Chords.holds_on lo hi T of scripts/verify_constant_gain_5_239.py with the cells clipped to [lo, hi].

                  Equations
                  Instances For
                    theorem Esgk.exists_dist_sq_le_of_chordRadiusCellsCheck (c p : Point) (q : Fin 3 → Point) {ρ : ℝ} {σ T lo hi : ℚ} (cells : List (ℚ × List (ℚ × ChordBoxTree))) (hcheck : chordRadiusCellsCheck σ T hi lo cells = true) (hhi0 : 0 ≤ hi) (hρ : 0 < ρ) (hp : ↑σ ^ 2 * ρ ^ 2 ≤ dist p c ^ 2) (hp1 : dist p c ^ 2 ≤ ρ ^ 2) (hlo : ∀ (i : Fin 3), ↑σ ^ 2 * ρ ^ 2 ≤ dist (q i) c ^ 2) (hhi : ∀ (i : Fin 3), dist (q i) c ^ 2 ≤ ρ ^ 2) (heq : ∀ (i j : Fin 3), dist p (q i) = dist p (q j)) (hr0 : ↑lo ^ 2 * ρ ^ 2 ≤ dist p (q 0) ^ 2) (hr1 : dist p (q 0) ^ 2 ≤ ↑hi ^ 2 * ρ ^ 2) :
                    ∃ (i : Fin 3) (j : Fin 3), i ≠ j ∧ dist (q i) (q j) ^ 2 ≤ ↑T * ρ ^ 2

                    The chord condition from radius cells. If chordRadiusCellsCheck σ T hi lo cells = true and 0 ≤ hi, then for every apex p of the annulus σ²ρ² ≤ |p - c|² ≤ ρ² and three points q i of the annulus at a common distance r from p with lo² ρ² ≤ r² ≤ hi² ρ², two of the points are at squared distance at most T ρ². This is the chord side condition C([lo, hi], √T) of scripts/verify_constant_gain_1_40.py (which uses (lo, hi]) in units of ρ; all hypotheses on the configuration are on squared distances.

                    The check of a chord table: radius cells [lo, r₁], [r₁, r₂], …, [r_{k-1}, r_k] with r_k ≥ hi, the entry (r_m, T_m, apex cells_m) carrying its own squared bound T_m, as the table Chords.tab of scripts/verify_constant_gain_5_239.py. Proved once by decide +kernel, it serves every range through the cheap chordTableBoundCheck.

                    Equations
                    Instances For

                      The bound check of a chord table on the radius range (x, y]: every table cell [r_{m-1}, r_m] with x < r_m and r_{m-1} ≤ y has T_m ≤ τ. It reads only the cell ends and bounds, not the trees (Chords.max_on x y ≤ τ of scripts/verify_constant_gain_5_239.py).

                      Equations
                      Instances For
                        theorem Esgk.exists_dist_sq_le_of_chordTableCheck (c p : Point) (q : Fin 3 → Point) {ρ : ℝ} {σ τ lo hi x y : ℚ} (table : List (ℚ × ℚ × List (ℚ × ChordBoxTree))) (htable : chordTableCheck σ hi lo table = true) (hbound : chordTableBoundCheck τ x y lo table = true) (hhi0 : 0 ≤ hi) (hy0 : 0 ≤ y) (hρ : 0 < ρ) (hp : ↑σ ^ 2 * ρ ^ 2 ≤ dist p c ^ 2) (hp1 : dist p c ^ 2 ≤ ρ ^ 2) (hlo : ∀ (i : Fin 3), ↑σ ^ 2 * ρ ^ 2 ≤ dist (q i) c ^ 2) (hhi : ∀ (i : Fin 3), dist (q i) c ^ 2 ≤ ρ ^ 2) (heq : ∀ (i j : Fin 3), dist p (q i) = dist p (q j)) (hr0 : ↑lo ^ 2 * ρ ^ 2 ≤ dist p (q 0) ^ 2) (hr1 : dist p (q 0) ^ 2 ≤ ↑hi ^ 2 * ρ ^ 2) (hx : ↑x ^ 2 * ρ ^ 2 < dist p (q 0) ^ 2) (hy : dist p (q 0) ^ 2 ≤ ↑y ^ 2 * ρ ^ 2) :
                        ∃ (i : Fin 3) (j : Fin 3), i ≠ j ∧ dist (q i) (q j) ^ 2 ≤ ↑τ * ρ ^ 2

                        The chord condition from a chord table. If chordTableCheck σ hi lo table = true and chordTableBoundCheck τ x y lo table = true, with 0 ≤ hi and 0 ≤ y, then for every apex p of the annulus σ²ρ² ≤ |p - c|² ≤ ρ² and three points q i of the annulus at a common distance r from p with lo² ρ² ≤ r² ≤ hi² ρ² and x² ρ² < r² ≤ y² ρ², two of the points are at squared distance at most τ ρ². This is the chord side condition C((x, y], √τ) of scripts/verify_constant_gain_1_40.py from the table, in units of ρ.