AFTD Auto-Formalizing Theoretical Domains

one_strongly_euclidean_spherical_core_extension

theoremverifiedoriginal

Let a family of points in a real inner-product space lie on a sphere of radius q/2, with q at least 1 and pairwise distances at least 1. Let r and s be positive with s²+2rs=1. Give two copies of the family any metric in which first-layer distances are the original distances and cross-layer squared distances are r² plus the corresponding original squared distances. The first-layer map extends to the entire two-layer metric with Lipschitz constant at most max(1,q/(2r+sq)).

Statement

theorem one_strongly_euclidean_spherical_core_extension (A H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]
    (u : A → H) (c : H) (q r s : ℝ)
    (hq : 1 ≤ q) (hr : 0 < r) (hs : 0 < s) (hid : s^2 + 2*r*s = 1)
    (hu : ∀ a, ‖u a - c‖^2 = q^2 / 4)
    (hsep : ∀ a b, a ≠ b → 1 ≤ dist (u a) (u b)^2)
    (M : MetricSpace (Bool × A)) :
    letI := M
    (∀ a b, dist (false,a) (false,b) = dist (u a) (u b)) →
    (∀ a b, dist (false,a) (true,b)^2 = r^2 + dist (u a) (u b)^2) →
    ∃ F : (Bool × A) → H,
      (∀ a, F (false,a) = u a) ∧
      ∀ x y, dist (F x) (F y) ≤ max 1 (q / (2*r + s*q)) * dist x y
Related work
arXiv:2611.08546, Section 6.2, whose two-layer cube is a special case.
Verified
12 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
Used by 1

Read back from the Lean

Let $A$ be a type, and let $H$ be a real inner product space. Let $u : A \to H$ be a function, $c \in H$, and $q, r, s \in \mathbb{R}$ such that: 1. $1 \le q$, 2. $0 < r$, 3. $0 < s$, 4. $s^2 + 2rs = 1$, 5. for all $a \in A$, $\|u(a) - c\|^2 = q^2 / 4$, 6. for all $a, b \in A$, if $a \neq b$ then $1 \le \mathrm{dist}(u(a), u(b))^2$. Let $M$ be a metric space structure on $\mathrm{Bool} \times A$. Assume that with respect to the metric $M$: - for all $a, b \in A$, $\mathrm{dist}((\mathrm{false}, a), (\mathrm{false}, b)) = \mathrm{dist}(u(a), u(b))$, and - for all $a, b \in A$, $\mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, b))^2 = r^2 + \mathrm{dist}(u(a), u(b))^2$. Then there exists a map $F : \mathrm{Bool} \times A \to H$ such that: 1. for all $a \in A$, $F(\mathrm{false}, a) = u(a)$, and 2. for all $x, y \in \mathrm{Bool} \times A$, $$\mathrm{dist}(F(x), F(y)) \le \max\left(1, \frac{q}{2r + sq}\right) \cdot \mathrm{dist}(x, y).$$

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The theorem is proved by explicitly extending the first-layer embedding to the second layer by radially contracting each point toward the sphere center $c$: $F(\mathrm{true}, a) = c + t \cdot (u(a) - c)$ with scale factor $t = sL$, where $L = q / (2r + sq)$. The Lipschitz constant $\max(1, L)$ is then checked across all four layer configurations. On the first layer, distances are preserved isometric to $u$; between layers, inner product expansion of the vector difference matches the cross-layer metric bound via algebraic identities from `one_strongly_euclidean_sphere_extension_scalar_bounds`; and on the second layer, the contraction $t = sL$ is controlled by the metric triangle inequality combined with `one_strongly_euclidean_sphere_radial_bound`.

  1. The scaling parameters $L = q / (2r + sq)$ and $t = sL$ are well-defined and non-negative, and satisfy the key algebraic scalar bounds $q^2(1-t)^2 = 4L^2 r^2$ and $t \le L^2$.

    Assuming the metric space conditions on the first layer and cross layers, we define the target Lipschitz bound $L = q / (2r + sq)$ and the radial contraction factor $t = sL$. Since $r, s > 0$ and $q \ge 1$, the denominator $2r + sq$ is strictly positive, giving $L \ge 0$, $L(2r+sq) = q$, and $t \ge 0$. We then invoke the scalar bounds lemma `one_strongly_euclidean_sphere_extension_scalar_bounds` to obtain the identity $q^2(1-t)^2 = 4L^2 r^2$ and the bound $t \le L^2$.

    lines 13–21

    uses div_nonneg, le_of_lt, div_mul_cancel₀, ne_of_gt, mul_nonneg, one_strongly_euclidean_sphere_extension_scalar_bounds

      intro hfalse hcross
      let L := q / (2*r + s*q)
      let t := s * L
      have hpos_denom : 0 < 2*r + s*q := by positivity
      have hq_pos : 0 ≤ q := by linarith
      have hL : 0 ≤ L := div_nonneg hq_pos (le_of_lt hpos_denom)
      have hLdef : L * (2*r + s*q) = q := div_mul_cancel₀ q (ne_of_gt hpos_denom)
      have ht_nonneg : 0 ≤ t := mul_nonneg (le_of_lt hs) hL
      have hscal := one_strongly_euclidean_sphere_extension_scalar_bounds r s q L hr hs hq hid hL hLdef
  2. The candidate extension $F : \mathrm{Bool} \times A \to H$ is defined by $F(\mathrm{false}, a) = u(a)$ and $F(\mathrm{true}, a) = c + t \cdot (u(a) - c)$, extending $u$ on the first layer.

    We define $F$ by leaving points on the first layer unchanged and radially scaling points on the second layer toward the sphere center $c$ by the factor $t$. The extension property $F(\mathrm{false}, a) = u(a)$ holds definitionally, leaving only the Lipschitz inequality $\mathrm{dist}(F x, F y) \le \max(1, L) \cdot \mathrm{dist}(x, y)$ to be verified for all pairs $x, y \in \mathrm{Bool} \times A$.

    lines 22–29

      let F : Bool × A → H := fun (b, a) =>
        if b = false then u a else c + t • (u a - c)
      use F
      have hF_false : ∀ a, F (false, a) = u a := by
        intro a; rfl
      have hF_true : ∀ a, F (true, a) = c + t • (u a - c) := by
        intro a; rfl
      refine ⟨hF_false, ?_⟩
  3. The Lipschitz bound holds for any pair of points in the first layer: $\mathrm{dist}(F(\mathrm{false}, a), F(\mathrm{false}, b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{false}, a), (\mathrm{false}, b))$.

    We split the Lipschitz condition by the layers of the two points. When both points belong to the first layer, $F$ evaluates to $u(a)$ and $u(b)$, between which the distance in $M$ is $\mathrm{dist}(u(a), u(b))$. Since $1 \le \max(1, L)$, the distance inequality $\mathrm{dist}(u(a), u(b)) = 1 \cdot \mathrm{dist}(u(a), u(b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{false}, a), (\mathrm{false}, b))$ holds immediately.

    lines 30–36

    uses one_mul, mul_le_mul_of_nonneg_right, le_max_left, dist_nonneg

      rintro ⟨_ | _, a⟩ ⟨_ | _, b⟩
      · -- false, false
        rw [hF_false, hF_false]
        calc dist (u a) (u b) = 1 * dist (u a) (u b) := (one_mul _).symm
          _ ≤ max 1 L * dist (u a) (u b) :=
            mul_le_mul_of_nonneg_right (le_max_left 1 L) dist_nonneg
          _ = max 1 (q / (2*r + s*q)) * dist (false, a) (false, b) := by rw [hfalse]
  4. The Lipschitz bound holds across layers from the first layer to the second layer: $\mathrm{dist}(F(\mathrm{false}, a), F(\mathrm{true}, b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, b))$.

    Writing $v_a = u(a) - c$ and $v_b = u(b) - c$, the difference vector is $F(\mathrm{false}, a) - F(\mathrm{true}, b) = v_a - t \cdot v_b$. Since both points lie on the sphere of radius $q/2$, $\|v_a\|^2 = \|v_b\|^2 = q^2/4$. Expanding the squared norm $\|v_a - t \cdot v_b\|^2$ and using the polarization identity $2 \langle v_a, v_b \rangle = \|v_a\|^2 + \|v_b\|^2 - \|v_a - v_b\|^2$ expresses the squared distance as $q^2(1-t)^2/4 + t \cdot \mathrm{dist}(u(a), u(b))^2$. The algebraic identities from Step 1 bound this by $L^2(r^2 + \mathrm{dist}(u(a), u(b))^2) = L^2 \cdot \mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, b))^2$, and taking square roots gives the bound $\mathrm{dist}(F(\mathrm{false}, a), F(\mathrm{true}, b)) \le L \cdot \mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, b))$.

    lines 37–70

    uses sub_add_eq_sub_sub, dist_eq_norm, dist_sub_right, norm_sub_sq_real, real_inner_smul_right, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs, sq_nonneg, mul_nonneg, dist_nonneg, norm_nonneg, mul_le_mul_of_nonneg_right, le_max_right

      · -- false, true
        rw [hF_false, hF_true]
        let va := u a - c
        let vb := u b - c
        have hdiff : u a - (c + t • (u b - c)) = va - t • vb := by
          dsimp [va, vb]; rw [sub_add_eq_sub_sub]
        have hdist : dist (u a) (c + t • (u b - c)) = ‖va - t • vb‖ := by
          rw [dist_eq_norm, hdiff]
        have h_va : ‖va‖^2 = q^2 / 4 := hu a
        have h_vb : ‖vb‖^2 = q^2 / 4 := hu b
        have h_sub : ‖va - vb‖^2 = dist (u a) (u b)^2 := by
          rw [← dist_eq_norm, show va = u a - c by rfl, show vb = u b - c by rfl, dist_sub_right]
        have h2inner : 2 * inner ℝ va vb = ‖va‖^2 + ‖vb‖^2 - ‖va - vb‖^2 := by
          have h := norm_sub_sq_real va vb
          linarith
        have hnorm_sq : ‖va - t • vb‖^2 = ‖va‖^2 - t * (2 * inner ℝ va vb) + t^2 * ‖vb‖^2 := by
          have h := norm_sub_sq_real va (t • vb)
          rw [real_inner_smul_right, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] at h
          linarith
        have h_alg : ‖va - t • vb‖^2 = q^2 * (1 - t)^2 / 4 + t * dist (u a) (u b)^2 := by
          nlinarith [h_va, h_vb, h_sub, h2inner, hnorm_sq]
        have h_le : ‖va - t • vb‖^2 ≤ L^2 * dist (false, a) (true, b)^2 := by
          have : 0 ≤ dist (u a) (u b)^2 := sq_nonneg _
          nlinarith [h_alg, hscal.1, hscal.2.1, hcross a b]
        have hL_dist : dist (u a) (c + t • (u b - c)) ≤ L * dist (false, a) (true, b) := by
          rw [hdist]
          have hLd : 0 ≤ L * dist (false, a) (true, b) := mul_nonneg hL dist_nonneg
          have hnorm_nonneg : 0 ≤ ‖va - t • vb‖ := norm_nonneg _
          nlinarith
        calc dist (u a) (c + t • (u b - c))
          _ ≤ L * dist (false, a) (true, b) := hL_dist
          _ ≤ max 1 L * dist (false, a) (true, b) :=
            mul_le_mul_of_nonneg_right (le_max_right 1 L) dist_nonneg
      · -- true, false
  5. The Lipschitz bound holds across layers from the second layer to the first layer: $\mathrm{dist}(F(\mathrm{true}, a), F(\mathrm{false}, b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{true}, a), (\mathrm{false}, b))$.

    Using metric symmetry (`dist_comm`), the distance $\mathrm{dist}(F(\mathrm{true}, a), F(\mathrm{false}, b))$ equals $\mathrm{dist}(F(\mathrm{false}, b), F(\mathrm{true}, a))$. The identical norm expansion and algebraic bounding from the previous step applies with $a$ and $b$ exchanged, completing this cross-layer case.

    lines 71–104

    uses dist_comm, sub_add_eq_sub_sub, dist_eq_norm, dist_sub_right, norm_sub_sq_real, real_inner_smul_right, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs, sq_nonneg, mul_nonneg, dist_nonneg, norm_nonneg, mul_le_mul_of_nonneg_right, le_max_right

        rw [dist_comm (F (true, a)) (F (false, b)), dist_comm (true, a) (false, b)]
        rw [hF_false, hF_true]
        let va := u b - c
        let vb := u a - c
        have hdiff : u b - (c + t • (u a - c)) = va - t • vb := by
          dsimp [va, vb]; rw [sub_add_eq_sub_sub]
        have hdist : dist (u b) (c + t • (u a - c)) = ‖va - t • vb‖ := by
          rw [dist_eq_norm, hdiff]
        have h_va : ‖va‖^2 = q^2 / 4 := hu b
        have h_vb : ‖vb‖^2 = q^2 / 4 := hu a
        have h_sub : ‖va - vb‖^2 = dist (u b) (u a)^2 := by
          rw [← dist_eq_norm, show va = u b - c by rfl, show vb = u a - c by rfl, dist_sub_right]
        have h2inner : 2 * inner ℝ va vb = ‖va‖^2 + ‖vb‖^2 - ‖va - vb‖^2 := by
          have h := norm_sub_sq_real va vb
          linarith
        have hnorm_sq : ‖va - t • vb‖^2 = ‖va‖^2 - t * (2 * inner ℝ va vb) + t^2 * ‖vb‖^2 := by
          have h := norm_sub_sq_real va (t • vb)
          rw [real_inner_smul_right, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] at h
          linarith
        have h_alg : ‖va - t • vb‖^2 = q^2 * (1 - t)^2 / 4 + t * dist (u b) (u a)^2 := by
          nlinarith [h_va, h_vb, h_sub, h2inner, hnorm_sq]
        have h_le : ‖va - t • vb‖^2 ≤ L^2 * dist (false, b) (true, a)^2 := by
          have : 0 ≤ dist (u b) (u a)^2 := sq_nonneg _
          nlinarith [h_alg, hscal.1, hscal.2.1, hcross b a]
        have hL_dist : dist (u b) (c + t • (u a - c)) ≤ L * dist (false, b) (true, a) := by
          rw [hdist]
          have hLd : 0 ≤ L * dist (false, b) (true, a) := mul_nonneg hL dist_nonneg
          have hnorm_nonneg : 0 ≤ ‖va - t • vb‖ := norm_nonneg _
          nlinarith
        calc dist (u b) (c + t • (u a - c))
          _ ≤ L * dist (false, b) (true, a) := hL_dist
          _ ≤ max 1 L * dist (false, b) (true, a) :=
            mul_le_mul_of_nonneg_right (le_max_right 1 L) dist_nonneg
      · -- true, true
  6. The Lipschitz bound holds for any pair of points in the second layer: $\mathrm{dist}(F(\mathrm{true}, a), F(\mathrm{true}, b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{true}, a), (\mathrm{true}, b))$.

    On the second layer, vector subtraction gives $F(\mathrm{true}, a) - F(\mathrm{true}, b) = t \cdot (u(a) - u(b))$, so the image distance is $t \cdot \mathrm{dist}(u(a), u(b))$. When $a = b$, both sides vanish. When $a \ne b$, point separation ensures $\mathrm{dist}(u(a), u(b)) \ge 1$. The metric triangle inequality on $(\mathrm{false}, a)$, $(\mathrm{true}, a)$, and $(\mathrm{true}, b)$ gives $\mathrm{dist}((\mathrm{true}, a), (\mathrm{true}, b)) \ge \mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, b)) - \mathrm{dist}((\mathrm{false}, a), (\mathrm{true}, a)) = \sqrt{r^2 + \mathrm{dist}(u(a), u(b))^2} - r$. By `one_strongly_euclidean_sphere_radial_bound`, this difference is at least $s \cdot \mathrm{dist}(u(a), u(b))$. Multiplying by $L$ gives $t \cdot \mathrm{dist}(u(a), u(b)) \le L \cdot \mathrm{dist}((\mathrm{true}, a), (\mathrm{true}, b)) \le \max(1, L) \cdot \mathrm{dist}((\mathrm{true}, a), (\mathrm{true}, b))$.

    lines 105–140

    uses dist_eq_norm, smul_sub, sub_sub_sub_cancel_right, norm_smul, Real.norm_eq_abs, abs_of_nonneg, dist_self, mul_zero, dist_nonneg, one_strongly_euclidean_sphere_radial_bound, dist_triangle, Real.sqrt_sq, le_trans, mul_le_mul_of_nonneg_left, mul_le_mul_of_nonneg_right, le_max_right

        rw [hF_true, hF_true]
        have hdist_eq : dist (c + t • (u a - c)) (c + t • (u b - c)) = t * dist (u a) (u b) := by
          rw [dist_eq_norm, dist_eq_norm]
          have : (c + t • (u a - c)) - (c + t • (u b - c)) = t • (u a - u b) := by
            calc (c + t • (u a - c)) - (c + t • (u b - c))
              _ = t • (u a - c) - t • (u b - c) := by abel
              _ = t • ((u a - c) - (u b - c)) := (smul_sub t (u a - c) (u b - c)).symm
              _ = t • (u a - u b) := by rw [sub_sub_sub_cancel_right]
          rw [this, norm_smul, Real.norm_eq_abs, abs_of_nonneg ht_nonneg]
        by_cases hab : a = b
        · rw [hab, dist_self, dist_self, mul_zero]
        · have hd_sq : 1 ≤ dist (u a) (u b)^2 := hsep a b hab
          have hd_pos : 0 ≤ dist (u a) (u b) := dist_nonneg
          have hd_one : 1 ≤ dist (u a) (u b) := by nlinarith
          have hrad := one_strongly_euclidean_sphere_radial_bound r s (dist (u a) (u b)) hr hs hid hd_one
          have htri : dist (false, a) (true, b) ≤ dist (false, a) (true, a) + dist (true, a) (true, b) :=
            dist_triangle (false, a) (true, a) (true, b)
          have haa : dist (false, a) (true, a) = r := by
            have h1 := hcross a a
            have h2 : dist (u a) (u a) = 0 := dist_self (u a)
            have hpos : 0 ≤ dist (false, a) (true, a) := dist_nonneg
            nlinarith
          have hab_cross : dist (false, a) (true, b) = Real.sqrt (r^2 + dist (u a) (u b)^2) := by
            have h2 := hcross a b
            rw [← h2, Real.sqrt_sq dist_nonneg]
          have hdiff : Real.sqrt (r^2 + dist (u a) (u b)^2) - r ≤ dist (true, a) (true, b) := by
            linarith [htri, haa, hab_cross]
          have hs_dist : s * dist (u a) (u b) ≤ dist (true, a) (true, b) := le_trans hrad hdiff
          rw [hdist_eq]
          calc t * dist (u a) (u b)
            _ = L * (s * dist (u a) (u b)) := by
              show s * L * dist (u a) (u b) = L * (s * dist (u a) (u b))
              ring
            _ ≤ L * dist (true, a) (true, b) := mul_le_mul_of_nonneg_left hs_dist hL
            _ ≤ max 1 L * dist (true, a) (true, b) :=
              mul_le_mul_of_nonneg_right (le_max_right 1 L) dist_nonneg
abs_of_nonneg
The absolute value of a non-negative real number is the number itself ($0 \le a \implies |a| = a$).
dist_comm
Metric distance is symmetric ($\mathrm{dist}(x, y) = \mathrm{dist}(y, x)$).
dist_eq_norm
Distance in a normed space equals the norm of the difference ($\mathrm{dist}(a, b) = \|a - b\|$).
dist_nonneg
Metric distance is always non-negative ($0 \le \mathrm{dist}(x, y)$).
dist_self
The distance from a point to itself is zero ($\mathrm{dist}(x, x) = 0$).
dist_sub_right
Translating both arguments by subtracting the same vector preserves distance ($\mathrm{dist}(a - c, b - c) = \mathrm{dist}(a, b)$).
dist_triangle
The triangle inequality in a metric space ($\mathrm{dist}(x, z) \le \mathrm{dist}(x, y) + \mathrm{dist}(y, z)$).
div_mul_cancel₀
Dividing by a non-zero element and multiplying cancels ($b \ne 0 \implies (a / b) \cdot b = a$).
div_nonneg
The quotient of two non-negative numbers is non-negative ($0 \le a \implies 0 \le b \implies 0 \le a / b$).
le_max_left
Any number is at most the maximum of itself and another ($a \le \max(a, b)$).
le_max_right
Any number is at most the maximum of another and itself ($b \le \max(a, b)$).
le_of_lt
A strict inequality implies the corresponding non-strict inequality ($a < b \implies a \le b$).
le_trans
Transitivity of inequality ($a \le b \implies b \le c \implies a \le c$).
mul_le_mul_of_nonneg_left
Multiplying an inequality on the left by a non-negative number preserves the inequality ($b \le c \implies 0 \le a \implies a b \le a c$).
mul_le_mul_of_nonneg_right
Multiplying an inequality on the right by a non-negative number preserves the inequality ($b \le c \implies 0 \le a \implies b a \le c a$).
mul_nonneg
The product of two non-negative numbers is non-negative ($0 \le a \implies 0 \le b \implies 0 \le a b$).
mul_pow
A power of a product is the product of the powers ($(a b)^n = a^n b^n$).
mul_zero
Multiplying any number by zero yields zero ($a \cdot 0 = 0$).
ne_of_gt
A strictly greater element is not equal ($b < a \implies a \ne b$).
norm_nonneg
The norm of any vector is non-negative ($0 \le \|a\|$).
norm_smul
The norm of a scalar multiple is the product of the absolute value of the scalar and the norm of the vector ($\|r \cdot x\| = \|r\| \cdot \|x\|$).
norm_sub_sq_real
Expansion of the squared norm of a difference in a real inner product space ($\|x - y\|^2 = \|x\|^2 - 2 \langle x, y \rangle + \|y\|^2$).
one_mul
Multiplying by one on the left leaves an element unchanged ($1 \cdot a = a$).
one_strongly_euclidean_sphere_extension_scalar_bounds
For parameters with $r, s > 0$, $q \ge 1$, $s^2 + 2rs = 1$, $L \ge 0$, and $L(2r+sq) = q$, setting $t = sL$ yields $q^2(1-t)^2 = 4L^2 r^2$, $t \le L^2$, and $t^2 h \le L^2 \min(s^2 h^2, h)$ for all $h \ge 1$.
one_strongly_euclidean_sphere_radial_bound
For positive $r, s$ with $s^2 + 2rs = 1$ and distance $d \ge 1$, the radial inequality $s d \le \sqrt{r^2 + d^2} - r$ holds.
real_inner_smul_right
Linearity of the real inner product in the second argument under scalar multiplication ($\langle x, r \cdot y \rangle = r \langle x, y \rangle$).
Real.norm_eq_abs
The norm of a real number equals its absolute value ($\|r\| = |r|$).
Real.sqrt_sq
The square root of a squared non-negative real number is the number itself ($0 \le x \implies \sqrt{x^2} = x$).
smul_sub
Scalar multiplication distributes over subtraction ($r \cdot (x - y) = r \cdot x - r \cdot y$).
sq_abs
The square of the absolute value of a real number equals its square ($|a|^2 = a^2$).
sq_nonneg
The square of any real number is non-negative ($0 \le a^2$).
sub_add_eq_sub_sub
Subtracting a sum is equivalent to subtracting each term successively ($a - (b + c) = a - b - c$).
sub_sub_sub_cancel_right
Cancelling a common subtracted term on the right ($a - c - (b - c) = a - b$).

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem one_strongly_euclidean_spherical_core_extension (A H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]    (u : A → H) (c : H) (q r s : ℝ)    (hq : 1 ≤ q) (hr : 0 < r) (hs : 0 < s) (hid : s^2 + 2*r*s = 1)    (hu : ∀ a, ‖u a - c‖^2 = q^2 / 4)    (hsep : ∀ a b, a ≠ b → 1 ≤ dist (u a) (u b)^2)    (M : MetricSpace (Bool × A)) :    letI := M    (∀ a b, dist (false,a) (false,b) = dist (u a) (u b)) →    (∀ a b, dist (false,a) (true,b)^2 = r^2 + dist (u a) (u b)^2) →    ∃ F : (Bool × A) → H,      (∀ a, F (false,a) = u a) ∧      ∀ x y, dist (F x) (F y) ≤ max 1 (q / (2*r + s*q)) * dist x y := by  intro hfalse hcross  let L := q / (2*r + s*q)  let t := s * L  have hpos_denom : 0 < 2*r + s*q := by positivity  have hq_pos : 0 ≤ q := by linarith  have hL : 0 ≤ L := div_nonneg hq_pos (le_of_lt hpos_denom)  have hLdef : L * (2*r + s*q) = q := div_mul_cancel₀ q (ne_of_gt hpos_denom)  have ht_nonneg : 0 ≤ t := mul_nonneg (le_of_lt hs) hL  have hscal := one_strongly_euclidean_sphere_extension_scalar_bounds r s q L hr hs hq hid hL hLdef  let F : Bool × A → H := fun (b, a) =>    if b = false then u a else c + t • (u a - c)  use F  have hF_false : ∀ a, F (false, a) = u a := by    intro a; rfl  have hF_true : ∀ a, F (true, a) = c + t • (u a - c) := by    intro a; rfl  refine ⟨hF_false, ?_⟩  rintro ⟨_ | _, a⟩ ⟨_ | _, b⟩  · -- false, false    rw [hF_false, hF_false]    calc dist (u a) (u b) = 1 * dist (u a) (u b) := (one_mul _).symm      _ ≤ max 1 L * dist (u a) (u b) :=        mul_le_mul_of_nonneg_right (le_max_left 1 L) dist_nonneg      _ = max 1 (q / (2*r + s*q)) * dist (false, a) (false, b) := by rw [hfalse]  · -- false, true    rw [hF_false, hF_true]    let va := u a - c    let vb := u b - c    have hdiff : u a - (c + t • (u b - c)) = va - t • vb := by      dsimp [va, vb]; rw [sub_add_eq_sub_sub]    have hdist : dist (u a) (c + t • (u b - c)) = ‖va - t • vb‖ := by      rw [dist_eq_norm, hdiff]    have h_va : ‖va‖^2 = q^2 / 4 := hu a    have h_vb : ‖vb‖^2 = q^2 / 4 := hu b    have h_sub : ‖va - vb‖^2 = dist (u a) (u b)^2 := by      rw [← dist_eq_norm, show va = u a - c by rfl, show vb = u b - c by rfl, dist_sub_right]    have h2inner : 2 * inner ℝ va vb = ‖va‖^2 + ‖vb‖^2 - ‖va - vb‖^2 := by      have h := norm_sub_sq_real va vb      linarith    have hnorm_sq : ‖va - t • vb‖^2 = ‖va‖^2 - t * (2 * inner ℝ va vb) + t^2 * ‖vb‖^2 := by      have h := norm_sub_sq_real va (t • vb)      rw [real_inner_smul_right, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] at h      linarith    have h_alg : ‖va - t • vb‖^2 = q^2 * (1 - t)^2 / 4 + t * dist (u a) (u b)^2 := by      nlinarith [h_va, h_vb, h_sub, h2inner, hnorm_sq]    have h_le : ‖va - t • vb‖^2 ≤ L^2 * dist (false, a) (true, b)^2 := by      have : 0 ≤ dist (u a) (u b)^2 := sq_nonneg _      nlinarith [h_alg, hscal.1, hscal.2.1, hcross a b]    have hL_dist : dist (u a) (c + t • (u b - c)) ≤ L * dist (false, a) (true, b) := by      rw [hdist]      have hLd : 0 ≤ L * dist (false, a) (true, b) := mul_nonneg hL dist_nonneg      have hnorm_nonneg : 0 ≤ ‖va - t • vb‖ := norm_nonneg _      nlinarith    calc dist (u a) (c + t • (u b - c))      _ ≤ L * dist (false, a) (true, b) := hL_dist      _ ≤ max 1 L * dist (false, a) (true, b) :=        mul_le_mul_of_nonneg_right (le_max_right 1 L) dist_nonneg  · -- true, false    rw [dist_comm (F (true, a)) (F (false, b)), dist_comm (true, a) (false, b)]    rw [hF_false, hF_true]    let va := u b - c    let vb := u a - c    have hdiff : u b - (c + t • (u a - c)) = va - t • vb := by      dsimp [va, vb]; rw [sub_add_eq_sub_sub]    have hdist : dist (u b) (c + t • (u a - c)) = ‖va - t • vb‖ := by      rw [dist_eq_norm, hdiff]    have h_va : ‖va‖^2 = q^2 / 4 := hu b    have h_vb : ‖vb‖^2 = q^2 / 4 := hu a    have h_sub : ‖va - vb‖^2 = dist (u b) (u a)^2 := by      rw [← dist_eq_norm, show va = u b - c by rfl, show vb = u a - c by rfl, dist_sub_right]    have h2inner : 2 * inner ℝ va vb = ‖va‖^2 + ‖vb‖^2 - ‖va - vb‖^2 := by      have h := norm_sub_sq_real va vb      linarith    have hnorm_sq : ‖va - t • vb‖^2 = ‖va‖^2 - t * (2 * inner ℝ va vb) + t^2 * ‖vb‖^2 := by      have h := norm_sub_sq_real va (t • vb)      rw [real_inner_smul_right, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] at h      linarith    have h_alg : ‖va - t • vb‖^2 = q^2 * (1 - t)^2 / 4 + t * dist (u b) (u a)^2 := by      nlinarith [h_va, h_vb, h_sub, h2inner, hnorm_sq]    have h_le : ‖va - t • vb‖^2 ≤ L^2 * dist (false, b) (true, a)^2 := by      have : 0 ≤ dist (u b) (u a)^2 := sq_nonneg _      nlinarith [h_alg, hscal.1, hscal.2.1, hcross b a]    have hL_dist : dist (u b) (c + t • (u a - c)) ≤ L * dist (false, b) (true, a) := by      rw [hdist]      have hLd : 0 ≤ L * dist (false, b) (true, a) := mul_nonneg hL dist_nonneg      have hnorm_nonneg : 0 ≤ ‖va - t • vb‖ := norm_nonneg _      nlinarith    calc dist (u b) (c + t • (u a - c))      _ ≤ L * dist (false, b) (true, a) := hL_dist      _ ≤ max 1 L * dist (false, b) (true, a) :=        mul_le_mul_of_nonneg_right (le_max_right 1 L) dist_nonneg  · -- true, true    rw [hF_true, hF_true]    have hdist_eq : dist (c + t • (u a - c)) (c + t • (u b - c)) = t * dist (u a) (u b) := by      rw [dist_eq_norm, dist_eq_norm]      have : (c + t • (u a - c)) - (c + t • (u b - c)) = t • (u a - u b) := by        calc (c + t • (u a - c)) - (c + t • (u b - c))          _ = t • (u a - c) - t • (u b - c) := by abel          _ = t • ((u a - c) - (u b - c)) := (smul_sub t (u a - c) (u b - c)).symm          _ = t • (u a - u b) := by rw [sub_sub_sub_cancel_right]      rw [this, norm_smul, Real.norm_eq_abs, abs_of_nonneg ht_nonneg]    by_cases hab : a = b    · rw [hab, dist_self, dist_self, mul_zero]    · have hd_sq : 1 ≤ dist (u a) (u b)^2 := hsep a b hab      have hd_pos : 0 ≤ dist (u a) (u b) := dist_nonneg      have hd_one : 1 ≤ dist (u a) (u b) := by nlinarith      have hrad := one_strongly_euclidean_sphere_radial_bound r s (dist (u a) (u b)) hr hs hid hd_one      have htri : dist (false, a) (true, b) ≤ dist (false, a) (true, a) + dist (true, a) (true, b) :=        dist_triangle (false, a) (true, a) (true, b)      have haa : dist (false, a) (true, a) = r := by        have h1 := hcross a a        have h2 : dist (u a) (u a) = 0 := dist_self (u a)        have hpos : 0 ≤ dist (false, a) (true, a) := dist_nonneg        nlinarith      have hab_cross : dist (false, a) (true, b) = Real.sqrt (r^2 + dist (u a) (u b)^2) := by        have h2 := hcross a b        rw [← h2, Real.sqrt_sq dist_nonneg]      have hdiff : Real.sqrt (r^2 + dist (u a) (u b)^2) - r ≤ dist (true, a) (true, b) := by        linarith [htri, haa, hab_cross]      have hs_dist : s * dist (u a) (u b) ≤ dist (true, a) (true, b) := le_trans hrad hdiff      rw [hdist_eq]      calc t * dist (u a) (u b)        _ = L * (s * dist (u a) (u b)) := by          show s * L * dist (u a) (u b) = L * (s * dist (u a) (u b))          ring        _ ≤ L * dist (true, a) (true, b) := mul_le_mul_of_nonneg_left hs_dist hL        _ ≤ max 1 L * dist (true, a) (true, b) :=          mul_le_mul_of_nonneg_right (le_max_right 1 L) dist_nonneg
See it in the graphDiscuss this resultChallenge it