AFTD Auto-Formalizing Theoretical Domains

one_strongly_euclidean_spherical_core_variable_height_extension

theoremverifiedoriginal

Let A and B be types, H a real inner-product space, u:A→H, p:B→A, c∈H, q≥1, and h:B→ℝ with h(b)>0 for every b. Assume ‖u(a)−c‖²=q²/4 for every a, and dist(u(a),u(a′))²≥1 whenever a≠a′. Let M be any metric structure on the disjoint union A⊕B. Assume dist(inl(a),inl(a′))=dist(u(a),u(a′)) and dist(inl(a),inr(b))²=h(b)²+dist(u(a),u(p(b)))² for every a,a′,b. Then there exists F:A⊕B→H with F(inl(a))=u(a) for every a, and dist(F(x),F(y))≤2√q·dist(x,y) for every x,y in A⊕B.

Statement

theorem one_strongly_euclidean_spherical_core_variable_height_extension (A B H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]
    (u : A → H) (p : B → A) (c : H) (q : ℝ) (h : B → ℝ)
    (hq : 1 ≤ q) (hh : ∀ b, 0 < h b)
    (hu : ∀ a, ‖u a - c‖^2 = q^2 / 4)
    (hsep : ∀ a a', a ≠ a' → 1 ≤ dist (u a) (u a')^2)
    (M : MetricSpace (Sum A B)) :
    letI := M
    (∀ a a', dist (Sum.inl a : Sum A B) (Sum.inl a') = dist (u a) (u a')) →
    (∀ a b, dist (Sum.inl a) (Sum.inr b)^2 = (h b)^2 + dist (u a) (u (p b))^2) →
    ∃ F : Sum A B → H,
      (∀ a, F (Sum.inl a) = u a) ∧
      ∀ x y, dist (F x) (F y) ≤ (2 * Real.sqrt q) * dist x y
Related work
arXiv:2611.08546, Section 6.2: the cited cube has equal cross-layer heights; this allows arbitrary positive heights for any spherical Euclidean core.
Verified
12 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3

Read back from the Lean

Given: - Types $A$ and $B$, and a real inner product space $H$ (with its induced norm and metric), - Maps $u : A \to H$, $p : B \to A$, and $h : B \to \mathbb{R}$, - A center $c \in H$ and a real number $q \ge 1$, - Assuming that: 1. For all $b \in B$, $h(b) > 0$, 2. For all $a \in A$, $\|u(a) - c\|^2 = q^2 / 4$ (i.e., all points $u(a)$ lie on a sphere of radius $q/2$ centered at $c$), 3. For all $a, a' \in A$ with $a \ne a'$, $\operatorname{dist}(u(a), u(a'))^2 \ge 1$, 4. $M$ is a metric space structure on the disjoint union $A \oplus B$ (Sum A B), 5. For all $a, a' \in A$, the distance in $M$ satisfies $\operatorname{dist}(\operatorname{inl} a, \operatorname{inl} a') = \operatorname{dist}(u(a), u(a'))$, 6. For all $a \in A$ and $b \in B$, the distance in $M$ satisfies $\operatorname{dist}(\operatorname{inl} a, \operatorname{inr} b)^2 = (h(b))^2 + \operatorname{dist}(u(a), u(p(b)))^2$, then there exists an extension $F : A \oplus B \to H$ such that: - For all $a \in A$, $F(\operatorname{inl} a) = u(a)$, and - $F$ is Lipschitz with constant $2\sqrt{q}$, meaning for all $x, y \in A \oplus B$, $\operatorname{dist}(F(x), F(y)) \le 2\sqrt{q} \cdot \operatorname{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 extends the isometric embedding u : A → H to the disjoint union A ⊕ B with Lipschitz constant 2√q by mapping each point b ∈ B to a radial contraction F(inr(b)) = c + t(h(b))(u(p(b)) - c) toward the sphere center c, using the scaling factor t(z) = q / (q + 2z + 2z²). The Lipschitz bound is verified by splitting into four cases on (A ⊕ B)². For pairs in A × A the bound holds because 2√q ≥ 1; for cross-pairs in A × B an exact spherical squared-distance identity bounds the distance by √q ≤ 2√q; and for pairs in B × B the distance decomposes into an radial height difference and an angular distance, each bounded by √q · dist via a difference quotient bound and a radial geometric estimate.

  1. The denominator D = q + 2z + 2z² is strictly positive, and t = q/D satisfies t ≤ 1 and t ≤ q.

    Since q ≥ 1 and z ≥ 0, all terms of D = q + 2z + 2z² are non-negative with q ≥ 1, so D > 0. Because 2z + 2z² ≥ 0, we have q ≤ D, which implies t = q/D ≤ 1. Since 1 ≤ q, it follows that t ≤ q. This closes the second conjunct t ≤ q and reduces the goal to the first conjunct.

    lines 5–18

    uses div_le_iff₀

      intro D t
      have hD_pos : 0 < D := by
        dsimp [D]
        have : 0 ≤ 2 * z := by linarith
        have : 0 ≤ 2 * z^2 := by positivity
        linarith
      have ht_le : t ≤ 1 := by
        dsimp [t, D]
        rw [div_le_iff₀ hD_pos]
        have : 0 ≤ 2 * z := by linarith
        have : 0 ≤ 2 * z^2 := by positivity
        linarith
      have ht_q : t ≤ q := by linarith
      refine ⟨?_, ht_q⟩
  2. (1 - t)² · (q² / 4) ≤ q · z² holds for t = q / D.

    Rewriting 1 - t = (D - q)/D = (2z + 2z²)/D, the quantity (1 - t)²(q²/4) becomes (q z (1 + z) / D)². By the variable-height scalar bound q(1 + 2z) ≤ √q · D, we have q(1 + z) ≤ √q · D. Multiplying by z ≥ 0 and dividing by D > 0 gives q z (1 + z) / D ≤ √q · z. Squaring both sides yields the desired inequality (q z (1 + z)/D)² ≤ q z².

    lines 19–49

    uses div_self, ne_of_gt, sub_div, one_strongly_euclidean_variable_height_scalar_bound, mul_le_mul_of_nonneg_left, div_le_iff₀, div_nonneg, le_of_lt, mul_pow, Real.sq_sqrt

      have h1 : 1 - t = (2 * z + 2 * z^2) / D := by
        dsimp [t]
        rw [← div_self (ne_of_gt hD_pos), ← sub_div]
        dsimp [D]
        ring
      have h2 : (1 - t)^2 * (q^2 / 4) = (q * z * (1 + z) / D)^2 := by
        rw [h1]
        ring
      rw [h2]
      have h_bound := one_strongly_euclidean_variable_height_scalar_bound q z hq hz
      have h_lin : q * (1 + z) ≤ Real.sqrt q * D := by
        have : q * (1 + z) ≤ q * (1 + 2 * z) := by nlinarith
        linarith [h_bound]
      have h_mul : q * z * (1 + z) ≤ (Real.sqrt q * z) * D := by
        calc q * z * (1 + z) = z * (q * (1 + z)) := by ring
          _ ≤ z * (Real.sqrt q * D) := mul_le_mul_of_nonneg_left h_lin hz
          _ = (Real.sqrt q * z) * D := by ring
      have h_div : q * z * (1 + z) / D ≤ Real.sqrt q * z := by
        rw [div_le_iff₀ hD_pos]
        exact h_mul
      have h_nonneg : 0 ≤ q * z * (1 + z) / D := by
        apply div_nonneg _ (le_of_lt hD_pos)
        have : 0 ≤ q := by linarith
        have : 0 ≤ 1 + z := by linarith
        positivity
      have h_sq : (q * z * (1 + z) / D)^2 ≤ (Real.sqrt q * z)^2 := by
        nlinarith [h_div, h_nonneg]
      have h_rt : (Real.sqrt q * z)^2 = q * z^2 := by
        have : 0 ≤ q := by linarith
        rw [mul_pow, Real.sq_sqrt this]
      linarith
  3. (q / 2) · (t(a) - t(b)) = (q² (b - a)(1 + a + b)) / (D(a) D(b)) for 0 < a ≤ b.

    Since a, b > 0, the denominators D(a) and D(b) are strictly positive and at least q. The algebraic difference of the denominators is D(b) - D(a) = 2(b - a)(1 + a + b). Using the common denominator identity t(a) - t(b) = q(D(b) - D(a)) / (D(a) D(b)) and multiplying by q/2 yields the claimed expression.

    lines 55–81

    uses le_trans, le_of_lt, div_sub_div, ne_of_gt

      intro D t
      have hb_nonneg : 0 ≤ b := le_trans (le_of_lt ha) hab
      have hDa_pos : 0 < D a := by
        dsimp [D]
        have : 0 ≤ 2 * a := by linarith
        have : 0 ≤ 2 * a^2 := by positivity
        linarith
      have hDb_pos : 0 < D b := by
        dsimp [D]
        have : 0 ≤ 2 * b := by linarith
        have : 0 ≤ 2 * b^2 := by positivity
        linarith
      have hDa_ge_q : q ≤ D a := by
        dsimp [D]
        have : 0 ≤ 2 * a := by linarith
        have : 0 ≤ 2 * a^2 := by positivity
        linarith
      have h_diff : D b - D a = 2 * (b - a) * (1 + a + b) := by
        dsimp [D]
        ring
      have h_sub : t a - t b = q * (D b - D a) / (D a * D b) := by
        dsimp [t]
        rw [div_sub_div _ _ (ne_of_gt hDa_pos) (ne_of_gt hDb_pos)]
        ring
      have h_mul : (q / 2) * (t a - t b) = (q^2 * (b - a) * (1 + a + b)) / (D a * D b) := by
        rw [h_sub, h_diff]
        ring
  4. (q / 2) · (t(a) - t(b)) ≤ √q · (b - a) holds for 0 < a ≤ b.

    From a ≤ b, we have 1 + a + b ≤ 1 + 2b. The variable-height scalar bound on b gives q(1 + a + b) ≤ q(1 + 2b) ≤ √q · D(b). Multiplying by q(b - a) ≥ 0 gives q²(b - a)(1 + a + b) ≤ (√q(b - a))(q D(b)). Since q ≤ D(a), this product is bounded by (√q(b - a))(D(a) D(b)). Clearing the positive denominator D(a) D(b) proves the inequality.

    lines 82–101

    uses one_strongly_euclidean_variable_height_scalar_bound, le_trans, mul_le_mul_of_nonneg_left, mul_le_mul_of_nonneg_right, le_of_lt, Real.sqrt_nonneg, div_le_iff₀

      have h_bound := one_strongly_euclidean_variable_height_scalar_bound q b hq hb_nonneg
      have h_lin : 1 + a + b ≤ 1 + 2 * b := by linarith
      have h_prod : q^2 * (b - a) * (1 + a + b) ≤ (Real.sqrt q * (b - a)) * (D a * D b) := by
        have h1 : q * (1 + a + b) ≤ q * (1 + 2 * b) := by nlinarith
        have h2 : q * (1 + a + b) ≤ Real.sqrt q * D b := le_trans h1 h_bound
        have h3 : q * (b - a) * (q * (1 + a + b)) ≤ q * (b - a) * (Real.sqrt q * D b) :=
          mul_le_mul_of_nonneg_left h2 (by nlinarith)
        have h4 : q * (b - a) * (Real.sqrt q * D b) ≤ (Real.sqrt q * (b - a)) * (D a * D b) := by
          calc q * (b - a) * (Real.sqrt q * D b) = (Real.sqrt q * (b - a)) * (q * D b) := by ring
            _ ≤ (Real.sqrt q * (b - a)) * (D a * D b) := by
              apply mul_le_mul_of_nonneg_left
              · exact mul_le_mul_of_nonneg_right hDa_ge_q (le_of_lt hDb_pos)
              · have : 0 ≤ Real.sqrt q := Real.sqrt_nonneg q
                positivity
        calc q^2 * (b - a) * (1 + a + b) = q * (b - a) * (q * (1 + a + b)) := by ring
          _ ≤ (Real.sqrt q * (b - a)) * (D a * D b) := le_trans h3 h4
      rw [h_mul]
      rw [div_le_iff₀]
      · exact h_prod
      · positivity
  5. For b > 0, the parameter s = √(b² + 1) - b satisfies s > 0, s² + 2bs = 1, and 1 ≤ s(1 + 2b).

    Since b² < b² + 1, strict monotonicity of the square root implies b < √(b² + 1), so s > 0. Expanding s² + 2bs gives (√(b² + 1) - b)² + 2b(√(b² + 1) - b) = (√(b² + 1))² - b² = 1. Factoring also shows s(√(b² + 1) + b) = 1. Since b² + 1 ≤ (b + 1)², we have √(b² + 1) ≤ b + 1, which implies √(b² + 1) + b ≤ 1 + 2b and therefore 1 ≤ s(1 + 2b).

    lines 106–137

    uses Real.sq_sqrt, le_of_lt, Real.sqrt_lt_sqrt, sq_nonneg, Real.sqrt_sq, Real.sqrt_le_sqrt, mul_le_mul_of_nonneg_left

      intro s
      have hb2 : 0 < b^2 + 1 := by positivity
      have hsq_rt : (Real.sqrt (b^2 + 1))^2 = b^2 + 1 := Real.sq_sqrt (le_of_lt hb2)
      have hrt_gt_b : b < Real.sqrt (b^2 + 1) := by
        have h1 : b^2 < b^2 + 1 := by linarith
        have h2 := Real.sqrt_lt_sqrt (sq_nonneg b) h1
        rwa [Real.sqrt_sq (le_of_lt hb)] at h2
      have hs_pos : 0 < s := by
        dsimp [s]; linarith
      have h_id : s^2 + 2 * b * s = 1 := by
        dsimp [s]
        have : (Real.sqrt (b^2 + 1) - b)^2 + 2 * b * (Real.sqrt (b^2 + 1) - b) =
          (Real.sqrt (b^2 + 1))^2 - b^2 := by ring
        rw [this, hsq_rt]
        ring
      have h_prod : s * (Real.sqrt (b^2 + 1) + b) = 1 := by
        dsimp [s]
        have : (Real.sqrt (b^2 + 1) - b) * (Real.sqrt (b^2 + 1) + b) =
          (Real.sqrt (b^2 + 1))^2 - b^2 := by ring
        rw [this, hsq_rt]
        ring
      have h_le : 1 ≤ s * (1 + 2 * b) := by
        have h_sqrt_le : Real.sqrt (b^2 + 1) ≤ b + 1 := by
          have h2 : 0 ≤ b + 1 := by linarith
          have h3 : b^2 + 1 ≤ (b + 1)^2 := by nlinarith
          rw [← Real.sqrt_sq h2]
          exact Real.sqrt_le_sqrt h3
        rw [← h_prod]
        apply mul_le_mul_of_nonneg_left _ (le_of_lt hs_pos)
        linarith
      exact ⟨hs_pos, h_id, h_le⟩
    
  6. t · d ≤ √q · Δ where t = q / D(b), given s · d ≤ Δ and 1 ≤ s(1 + 2b).

    Using 1 ≤ s(1 + 2b), we have td ≤ td(s(1 + 2b)) = (t(1 + 2b))(sd). The variable-height scalar bound q(1 + 2b) ≤ √q · D(b) implies t(1 + 2b) ≤ √q upon dividing by D(b) > 0. Combining this with sd ≤ Δ yields td ≤ √q · Δ.

    lines 145–164

    uses one_strongly_euclidean_variable_height_scalar_bound, le_of_lt, div_nonneg, mul_nonneg, mul_one, mul_le_mul_of_nonneg_left, div_mul_eq_mul_div, div_le_iff₀, mul_le_mul, Real.sqrt_nonneg

      intro D t
      have h_scalar := one_strongly_euclidean_variable_height_scalar_bound q b hq (le_of_lt hb)
      have hD_pos : 0 < D := by
        dsimp [D]
        have : 0 ≤ 2 * b := by linarith
        have : 0 ≤ 2 * b^2 := by positivity
        linarith
      have h1 : t * d ≤ t * d * (s * (1 + 2 * b)) := by
        have ht_nonneg : 0 ≤ t := div_nonneg (by linarith) (le_of_lt hD_pos)
        have : 0 ≤ t * d := mul_nonneg ht_nonneg hd
        calc t * d = t * d * 1 := (mul_one _).symm
          _ ≤ t * d * (s * (1 + 2 * b)) := mul_le_mul_of_nonneg_left h_s_le this
      have h2 : t * d * (s * (1 + 2 * b)) = (t * (1 + 2 * b)) * (s * d) := by ring
      have h3 : t * (1 + 2 * b) ≤ Real.sqrt q := by
        dsimp [t]
        rw [div_mul_eq_mul_div, div_le_iff₀ hD_pos]
        exact h_scalar
      have h5 : (t * (1 + 2 * b)) * (s * d) ≤ Real.sqrt q * Δ :=
        mul_le_mul h3 h_sd (mul_nonneg hs hd) (Real.sqrt_nonneg q)
      linarith
  7. √(h(b₂)² + d²) - h(b₁) ≤ dist(inr(b₁), inr(b₂)) where d = dist(u(p(b₁)), u(p(b₂))).

    By the cross-distance formula, dist(inl(p(b₁)), inr(b₁)) = h(b₁) because dist(u(p(b₁)), u(p(b₁))) = 0, and dist(inl(p(b₁)), inr(b₂)) = √(h(b₂)² + d²). The triangle inequality in A ⊕ B gives dist(inl(p(b₁)), inr(b₂)) ≤ dist(inl(p(b₁)), inr(b₁)) + dist(inr(b₁), inr(b₂)), which rearranges directly to the claim.

    lines 175–190

    uses dist_self, zero_pow, two_ne_zero, add_zero, dist_nonneg, le_of_lt, Real.sqrt_sq, dist_triangle

      intro d
      have h1 : dist (Sum.inl (p b1) : Sum A B) (Sum.inr b1) = h b1 := by
        have hsq := hcross (p b1) b1
        rw [dist_self, zero_pow two_ne_zero, add_zero] at hsq
        have h_nonneg : 0 ≤ dist (Sum.inl (p b1) : Sum A B) (Sum.inr b1) := dist_nonneg
        have hh_nonneg : 0 ≤ h b1 := le_of_lt (hh b1)
        nlinarith
      have h2 : dist (Sum.inl (p b1) : Sum A B) (Sum.inr b2) = Real.sqrt ((h b2)^2 + d^2) := by
        have hsq := hcross (p b1) b2
        have h_nonneg : 0 ≤ dist (Sum.inl (p b1) : Sum A B) (Sum.inr b2) := dist_nonneg
        rw [← hsq]
        exact (Real.sqrt_sq h_nonneg).symm
      have htri : dist (Sum.inl (p b1) : Sum A B) (Sum.inr b2) ≤
        dist (Sum.inl (p b1)) (Sum.inr b1) + dist (Sum.inr b1) (Sum.inr b2) :=
        dist_triangle (Sum.inl (p b1)) (Sum.inr b1) (Sum.inr b2)
      linarith
  8. ‖(c + t₁ v₁) - (c + t₂ v₂)‖ ≤ (q / 2)(t₁ - t₂) + t₂ d for 0 ≤ t₂ ≤ t₁, ‖v₁‖ = q/2, and ‖v₁ - v₂‖ = d.

    We decompose the difference as (c + t₁ v₁) - (c + t₂ v₂) = (t₁ - t₂) v₁ + t₂ (v₁ - v₂). The triangle inequality and norm scaling give ‖(c + t₁ v₁) - (c + t₂ v₂)‖ ≤ |t₁ - t₂| ‖v₁‖ + |t₂| ‖v₁ - v₂‖. Since 0 ≤ t₂ ≤ t₁, ‖v₁‖ = q/2, and ‖v₁ - v₂‖ = d, this simplifies to (q/2)(t₁ - t₂) + t₂ d.

    lines 197–207

    uses sub_smul, smul_sub, norm_add_le, norm_smul, Real.norm_eq_abs, abs_of_nonneg

      have h_id : (c + t1 • v1) - (c + t2 • v2) = (t1 - t2) • v1 + t2 • (v1 - v2) := by
        calc (c + t1 • v1) - (c + t2 • v2) = t1 • v1 - t2 • v2 := by abel
          _ = (t1 - t2) • v1 + t2 • (v1 - v2) := by
            rw [sub_smul, smul_sub]
            abel
      rw [h_id]
      have h_tri := norm_add_le ((t1 - t2) • v1) (t2 • (v1 - v2))
      rw [norm_smul, norm_smul, Real.norm_eq_abs, Real.norm_eq_abs,
          abs_of_nonneg (by linarith : 0 ≤ t1 - t2), abs_of_nonneg ht2,
          hv1, hsub] at h_tri
      linarith
  9. t(b) ≤ t(a) holds for 0 < a ≤ b.

    The denominator D(z) = q + 2z + 2z² is weakly increasing for non-negative z, so D(a) ≤ D(b). Because D(a) > 0 and q ≥ 1 > 0, taking reciprocals reverses the inequality, yielding t(b) = q / D(b) ≤ q / D(a) = t(a).

    lines 213–225

    uses div_le_div_of_nonneg_left

      intro D t
      have hDa_pos : 0 < D a := by
        dsimp [D]
        have : 0 ≤ 2 * a := by linarith
        have : 0 ≤ 2 * a^2 := by positivity
        linarith
      have h_le : D a ≤ D b := by
        dsimp [D]
        have : 2 * a ≤ 2 * b := by linarith
        have : 2 * a^2 ≤ 2 * b^2 := by nlinarith
        linarith
      dsimp [t]
      exact div_le_div_of_nonneg_left (by linarith) hDa_pos h_le
  10. For b₁, b₂ ∈ B with a = h(b₁) ≤ b = h(b₂), both (q/2)(t(a) - t(b)) ≤ √q · Δ and t(b) · d ≤ √q · Δ hold, where d = dist(u(p(b₁)), u(p(b₂))) and Δ = dist(inr(b₁), inr(b₂)).

    The lower bound on second-layer distance gives √(b² + d²) - a ≤ Δ. Since a ≤ b ≤ √(b² + d²), this implies both b - a ≤ Δ and √(b² + d²) - b ≤ Δ. Applying the difference quotient bound gives (q/2)(t(a) - t(b)) ≤ √q(b - a) ≤ √q · Δ. For t(b)d, if p(b₁) = p(b₂), then d = 0 and the bound is trivial. If p(b₁) ≠ p(b₂), the separation assumption gives d ≥ 1. Taking s = √(b² + 1) - b, the sphere radial bound gives sd ≤ √(b² + d²) - b ≤ Δ, from which the radial product lemma gives t(b)d ≤ √q · Δ.

    lines 240–277

    uses dist_nonneg, one_strongly_euclidean_spherical_core_variable_height_extension_dist_inr_ge, Real.sqrt_sq, le_of_lt, Real.sqrt_le_sqrt, sq_nonneg, one_strongly_euclidean_spherical_core_variable_height_extension_diff_quotient, mul_le_mul_of_nonneg_left, Real.sqrt_nonneg, dist_self, mul_zero, mul_nonneg, one_strongly_euclidean_spherical_core_variable_height_extension_radial_s, one_strongly_euclidean_sphere_radial_bound, le_trans, one_strongly_euclidean_spherical_core_variable_height_extension_radial_prod

      intro D t F2
      let a := h b1
      let b := h b2
      let d := dist (u (p b1)) (u (p b2))
      let Δ := dist (Sum.inr b1 : Sum A B) (Sum.inr b2)
      have ha_pos : 0 < a := hh b1
      have hb_pos : 0 < b := hh b2
      have hd_nonneg : 0 ≤ d := dist_nonneg
      have hΔ_nonneg : 0 ≤ Δ := dist_nonneg
      have h_inr_ge := one_strongly_euclidean_spherical_core_variable_height_extension_dist_inr_ge A B M H u p h hh hcross b1 b2
      have hb_le_rt : b ≤ Real.sqrt (b^2 + d^2) := by
        have : b = Real.sqrt (b^2) := (Real.sqrt_sq (le_of_lt hb_pos)).symm
        nth_rw 1 [this]
        apply Real.sqrt_le_sqrt
        have : 0 ≤ d^2 := sq_nonneg d
        linarith
      have h_ba_le_Δ : b - a ≤ Δ := by linarith [h_inr_ge, hb_le_rt]
      have h_rt_b_le_Δ : Real.sqrt (b^2 + d^2) - b ≤ Δ := by linarith [h_inr_ge, hle]
      have ht_diff := one_strongly_euclidean_spherical_core_variable_height_extension_diff_quotient q a b hq ha_pos hle
      have ht_diff_Δ : (q / 2) * (t a - t b) ≤ Real.sqrt q * Δ := by
        have h1 : Real.sqrt q * (b - a) ≤ Real.sqrt q * Δ :=
          mul_le_mul_of_nonneg_left h_ba_le_Δ (Real.sqrt_nonneg q)
        linarith [ht_diff, h1]
      have ht_d_Δ : t b * d ≤ Real.sqrt q * Δ := by
        by_cases h_eq : p b1 = p b2
        · have : d = 0 := by
            dsimp [d]
            rw [h_eq, dist_self]
          rw [this, mul_zero]
          have : 0 ≤ Real.sqrt q * Δ := mul_nonneg (Real.sqrt_nonneg q) hΔ_nonneg
          linarith
        · have hd_sq : 1 ≤ dist (u (p b1)) (u (p b2))^2 := hsep (p b1) (p b2) h_eq
          have hd_one : 1 ≤ d := by nlinarith [hd_sq, hd_nonneg]
          have hs_prop := one_strongly_euclidean_spherical_core_variable_height_extension_radial_s b hb_pos
          let s := Real.sqrt (b^2 + 1) - b
          have hrad := one_strongly_euclidean_sphere_radial_bound b s d hb_pos hs_prop.1 hs_prop.2.1 hd_one
          have h_sd_le_Δ : s * d ≤ Δ := le_trans hrad h_rt_b_le_Δ
          exact one_strongly_euclidean_spherical_core_variable_height_extension_radial_prod q b d Δ s hq hb_pos hd_nonneg (le_of_lt hs_prop.1) h_sd_le_Δ hs_prop.2.2
  11. dist(F₂(b₁), F₂(b₂)) ≤ 2√q · dist(inr(b₁), inr(b₂)) for h(b₁) ≤ h(b₂).

    The vectors u(p(b₁)) - c and u(p(b₂)) - c lie on the sphere of radius q/2, with difference norm d. Since h(b₁) ≤ h(b₂), we have t(b) ≤ t(a). The norm decomposition bounds dist(F₂(b₁), F₂(b₂)) by (q/2)(t(a) - t(b)) + t(b) d. Summing the two √q · Δ bounds from the previous step yields 2√q · Δ.

    lines 278–298

    uses norm_nonneg, sub_sub_sub_cancel_right, dist_eq_norm, one_strongly_euclidean_spherical_core_variable_height_extension_t_antitone, div_nonneg, le_of_lt, one_strongly_euclidean_spherical_core_variable_height_extension_norm_decomp

      have h_norm1 : ‖u (p b1) - c‖ = q / 2 := by
        have hu1 := hu (p b1)
        have : 0 ≤ q / 2 := by linarith
        have : 0 ≤ ‖u (p b1) - c‖ := norm_nonneg _
        nlinarith
      have h_sub_d : ‖(u (p b1) - c) - (u (p b2) - c)‖ = d := by
        dsimp [d]
        rw [sub_sub_sub_cancel_right, dist_eq_norm]
      have ht_anti := one_strongly_euclidean_spherical_core_variable_height_extension_t_antitone q a b hq ha_pos hle
      have ht2_nonneg : 0 ≤ t b := by
        dsimp [t]
        have : 0 < q + 2 * b + 2 * b^2 := by
          have : 0 ≤ 2 * b := by linarith
          have : 0 ≤ 2 * b^2 := by positivity
          linarith
        exact div_nonneg (by linarith) (le_of_lt this)
      have h_decomp := one_strongly_euclidean_spherical_core_variable_height_extension_norm_decomp H c (u (p b1) - c) (u (p b2) - c) (t a) (t b) q d
        ht2_nonneg ht_anti h_norm1 h_sub_d
      dsimp [F2]
      rw [dist_eq_norm]
      linarith
  12. Define the extension F on A ⊕ B and observe that F(inl(a)) = u(a) by definition.

    We define F on A ⊕ B by setting F(inl(a)) = u(a) and F(inr(b)) = c + t(h(b))(u(p(b)) - c). The equality F(inl(a)) = u(a) holds definitionally, so F extends u. It remains to verify the Lipschitz bound dist(F(x), F(y)) ≤ 2√q · dist(x, y) for all x, y ∈ A ⊕ B.

    lines 312–320

      intro hinl hcross
      let D : ℝ → ℝ := fun z => q + 2 * z + 2 * z^2
      let t : ℝ → ℝ := fun z => q / D z
      let F : Sum A B → H := fun x =>
        match x with
        | Sum.inl a => u a
        | Sum.inr b => c + t (h b) • (u (p b) - c)
      use F
      refine ⟨fun a => rfl, ?_⟩
  13. The Lipschitz bound holds when both points lie in A: dist(F(inl(a₁)), F(inl(a₂))) ≤ 2√q · dist(inl(a₁), inl(a₂)).

    On A, F(inl(aᵢ)) = u(aᵢ). Since q ≥ 1, we have √q ≥ 1 and therefore 2√q ≥ 2 ≥ 1. Thus dist(u(a₁), u(a₂)) ≤ 2√q · dist(u(a₁), u(a₂)). Since dist(inl(a₁), inl(a₂)) = dist(u(a₁), u(a₂)) by hypothesis, the Lipschitz bound holds.

    lines 321–330

    uses Real.one_le_sqrt.mpr, one_mul, mul_le_mul_of_nonneg_right, dist_nonneg

      rintro (a1 | b1) (a2 | b2)
      · -- inl a1, inl a2
        dsimp [F]
        have hq1 : 1 ≤ Real.sqrt q := Real.one_le_sqrt.mpr hq
        have h2q : 1 ≤ 2 * Real.sqrt q := by linarith
        have h_d : dist (u a1) (u a2) ≤ (2 * Real.sqrt q) * dist (u a1) (u a2) := by
          calc dist (u a1) (u a2) = 1 * dist (u a1) (u a2) := (one_mul _).symm
            _ ≤ (2 * Real.sqrt q) * dist (u a1) (u a2) :=
              mul_le_mul_of_nonneg_right h2q dist_nonneg
        rwa [hinl a1 a2]
  14. The Lipschitz bound holds for cross-pairs with first point in A and second in B: dist(F(inl(a₁)), F(inr(b₂))) ≤ 2√q · dist(inl(a₁), inr(b₂)).

    Setting x = u(a₁) - c and y = u(p(b₂)) - c, we have ‖x‖² = ‖y‖² = q²/4. The spherical squared-distance identity gives ‖x - t y‖² = (1 - t)²(q²/4) + t ‖x - y‖². By the cross-scalar lemma, (1 - t)²(q²/4) ≤ q · h(b₂)² and t ≤ q, so ‖x - t y‖² ≤ q(h(b₂)² + dist(u(a₁), u(p(b₂)))²) = q · dist(inl(a₁), inr(b₂))². Since q ≤ 4q = (2√q)², taking square roots yields the 2√q bound.

    lines 331–361

    uses dist_eq_norm, one_strongly_euclidean_sphere_squared_distance_identity, one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar, le_of_lt, sq_nonneg, dist_nonneg, mul_pow, Real.sq_sqrt, norm_nonneg, Real.sqrt_nonneg

      · -- inl a1, inr b2
        rw [dist_eq_norm]
        let x := u a1 - c
        let y := u (p b2) - c
        have h_diff : F (Sum.inl a1) - F (Sum.inr b2) = x - t (h b2) • y := by
          dsimp [F, x, y]
          abel
        rw [h_diff]
        have h_id := one_strongly_euclidean_sphere_squared_distance_identity H x y (t (h b2)) q (hu a1) (hu (p b2))
        have h_scal := one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar q (h b2) hq (le_of_lt (hh b2))
        have h_sq : ‖x - t (h b2) • y‖^2 ≤ q * dist (Sum.inl a1 : Sum A B) (Sum.inr b2)^2 := by
          rw [h_id, hcross a1 b2]
          have h_xy : ‖x - y‖^2 = dist (u a1) (u (p b2))^2 := by
            have : x - y = u a1 - u (p b2) := by dsimp [x, y]; abel
            rw [this, ← dist_eq_norm]
          rw [h_xy]
          have h1 := h_scal.1
          have h2 := h_scal.2
          have : 0 ≤ dist (u a1) (u (p b2))^2 := sq_nonneg _
          nlinarith
        have hq_pos : 0 ≤ q := by linarith
        have h_d_nonneg : 0 ≤ dist (Sum.inl a1 : Sum A B) (Sum.inr b2) := dist_nonneg
        have h_4q : q * dist (Sum.inl a1 : Sum A B) (Sum.inr b2)^2 ≤
            ((2 * Real.sqrt q) * dist (Sum.inl a1) (Sum.inr b2))^2 := by
          rw [mul_pow, mul_pow, Real.sq_sqrt hq_pos]
          nlinarith
        have h_norm_nonneg : 0 ≤ ‖x - t (h b2) • y‖ := norm_nonneg _
        have h_rhs_nonneg : 0 ≤ (2 * Real.sqrt q) * dist (Sum.inl a1 : Sum A B) (Sum.inr b2) := by
          have : 0 ≤ Real.sqrt q := Real.sqrt_nonneg q
          positivity
        nlinarith
  15. The Lipschitz bound holds for cross-pairs with first point in B and second in A: dist(F(inr(b₁)), F(inl(a₂))) ≤ 2√q · dist(inr(b₁), inl(a₂)).

    By symmetry of the metric distance on H and on A ⊕ B, this case is identical to the previous cross-pair case with the roles of the two points swapped.

    lines 362–393

    uses dist_comm, dist_eq_norm, one_strongly_euclidean_sphere_squared_distance_identity, one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar, le_of_lt, sq_nonneg, dist_nonneg, mul_pow, Real.sq_sqrt, norm_nonneg, Real.sqrt_nonneg

      · -- inr b1, inl a2
        rw [dist_comm (F (Sum.inr b1)) (F (Sum.inl a2)), dist_comm (Sum.inr b1 : Sum A B) (Sum.inl a2)]
        rw [dist_eq_norm]
        let x := u a2 - c
        let y := u (p b1) - c
        have h_diff : F (Sum.inl a2) - F (Sum.inr b1) = x - t (h b1) • y := by
          dsimp [F, x, y]
          abel
        rw [h_diff]
        have h_id := one_strongly_euclidean_sphere_squared_distance_identity H x y (t (h b1)) q (hu a2) (hu (p b1))
        have h_scal := one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar q (h b1) hq (le_of_lt (hh b1))
        have h_sq : ‖x - t (h b1) • y‖^2 ≤ q * dist (Sum.inl a2 : Sum A B) (Sum.inr b1)^2 := by
          rw [h_id, hcross a2 b1]
          have h_xy : ‖x - y‖^2 = dist (u a2) (u (p b1))^2 := by
            have : x - y = u a2 - u (p b1) := by dsimp [x, y]; abel
            rw [this, ← dist_eq_norm]
          rw [h_xy]
          have h1 := h_scal.1
          have h2 := h_scal.2
          have : 0 ≤ dist (u a2) (u (p b1))^2 := sq_nonneg _
          nlinarith
        have hq_pos : 0 ≤ q := by linarith
        have h_d_nonneg : 0 ≤ dist (Sum.inl a2 : Sum A B) (Sum.inr b1) := dist_nonneg
        have h_4q : q * dist (Sum.inl a2 : Sum A B) (Sum.inr b1)^2 ≤
            ((2 * Real.sqrt q) * dist (Sum.inl a2) (Sum.inr b1))^2 := by
          rw [mul_pow, mul_pow, Real.sq_sqrt hq_pos]
          nlinarith
        have h_norm_nonneg : 0 ≤ ‖x - t (h b1) • y‖ := norm_nonneg _
        have h_rhs_nonneg : 0 ≤ (2 * Real.sqrt q) * dist (Sum.inl a2 : Sum A B) (Sum.inr b1) := by
          have : 0 ≤ Real.sqrt q := Real.sqrt_nonneg q
          positivity
        nlinarith
  16. The Lipschitz bound holds when both points lie in B: dist(F(inr(b₁)), F(inr(b₂))) ≤ 2√q · dist(inr(b₁), inr(b₂)).

    By totality of the order on ℝ, either h(b₁) ≤ h(b₂) or h(b₂) ≤ h(b₁). When h(b₁) ≤ h(b₂), the second-layer lemma applies directly. When h(b₂) ≤ h(b₁), we swap the arguments using symmetry of distance and apply the same lemma.

    lines 394–398

    uses le_total, one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le, dist_comm

      · -- inr b1, inr b2
        rcases le_total (h b1) (h b2) with hle | hle
        · exact one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le A B H u p c q h hq hh hu hsep M hcross b1 b2 hle
        · rw [dist_comm (F (Sum.inr b1)) (F (Sum.inr b2)), dist_comm (Sum.inr b1 : Sum A B) (Sum.inr b2)]
          exact one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le A B H u p c q h hq hh hu hsep M hcross b2 b1 hle
div_le_iff₀
For a positive divisor c, b / c ≤ a if and only if b ≤ a · c.
div_self
Any non-zero element divided by itself equals 1.
ne_of_gt
If b < a, then a ≠ b.
sub_div
Subtraction in the numerator distributes over division: (a - b) / c = a / c - b / c.
one_strongly_euclidean_variable_height_scalar_bound
For q ≥ 1 and z ≥ 0, q(1 + 2z) ≤ √q(q + 2z + 2z²).
mul_le_mul_of_nonneg_left
Multiplying an inequality on the left by a non-negative number preserves the inequality.
div_nonneg
The quotient of two non-negative numbers is non-negative.
le_of_lt
A strict inequality implies the corresponding non-strict inequality.
mul_pow
Power of a product is the product of powers: (a · b)ⁿ = aⁿ · bⁿ.
Real.sq_sqrt
For non-negative x, (√x)² = x.
le_trans
Inequality is transitive: if a ≤ b and b ≤ c, then a ≤ c.
div_sub_div
Subtraction of fractions: a/b - c/d = (a·d - b·c)/(b·d) for non-zero denominators.
mul_le_mul_of_nonneg_right
Multiplying an inequality on the right by a non-negative number preserves the inequality.
Real.sqrt_nonneg
The square root of any real number is non-negative.
Real.sqrt_lt_sqrt
The square root function strictly preserves order on non-negative reals: 0 ≤ x < y implies √x < √y.
sq_nonneg
The square of any real number is non-negative.
Real.sqrt_sq
For non-negative x, √(x²) = x.
Real.sqrt_le_sqrt
The square root function preserves non-strict order: x ≤ y implies √x ≤ √y.
mul_nonneg
The product of two non-negative numbers is non-negative.
mul_one
Multiplying by 1 leaves an element unchanged: a · 1 = a.
div_mul_eq_mul_div
Associativity of division and multiplication: (a / b) · c = (a · c) / b.
mul_le_mul
Term-by-term multiplication of non-negative inequalities: if a ≤ b, c ≤ d with c, b ≥ 0, then a·c ≤ b·d.
dist_self
The distance from any point to itself is zero.
zero_pow
Zero raised to any non-zero power is zero.
two_ne_zero
The integer 2 is not equal to 0.
add_zero
Adding zero leaves an element unchanged: a + 0 = a.
dist_nonneg
The distance between any two points in a pseudo-metric space is non-negative.
dist_triangle
The triangle inequality for a metric: dist(x, z) ≤ dist(x, y) + dist(y, z).
sub_smul
Scalar subtraction distributes over vector scaling: (r - s) • y = r • y - s • y.
smul_sub
Scalar multiplication distributes over vector subtraction: r • (x - y) = r • x - r • y.
norm_add_le
The triangle inequality for the norm: ‖a + b‖ ≤ ‖a‖ + ‖b‖.
norm_smul
The norm of a scaled vector equals the product of absolute value and norm: ‖r • x‖ = |r| · ‖x‖.
Real.norm_eq_abs
The norm of a real number is its absolute value.
abs_of_nonneg
The absolute value of a non-negative real equals itself: |a| = a.
div_le_div_of_nonneg_left
For non-negative numerator and 0 < c ≤ b, a / b ≤ a / c.
one_strongly_euclidean_spherical_core_variable_height_extension_dist_inr_ge
Lower bound on the distance between points in the second layer: √(h(b₂)² + d²) - h(b₁) ≤ dist(inr(b₁), inr(b₂)).
one_strongly_euclidean_spherical_core_variable_height_extension_diff_quotient
Difference quotient bound for t(z): (q/2)(t(a) - t(b)) ≤ √q(b - a) for 0 < a ≤ b.
mul_zero
Multiplying any element by zero yields zero.
one_strongly_euclidean_spherical_core_variable_height_extension_radial_s
For b > 0, s = √(b² + 1) - b satisfies s > 0, s² + 2bs = 1, and 1 ≤ s(1 + 2b).
one_strongly_euclidean_sphere_radial_bound
Radial bound for a sphere: s · d ≤ √(r² + d²) - r for r > 0, s > 0, s² + 2rs = 1, and d ≥ 1.
one_strongly_euclidean_spherical_core_variable_height_extension_radial_prod
Radial product bound: t · d ≤ √q · Δ when t = q/D(b), s · d ≤ Δ, and 1 ≤ s(1 + 2b).
norm_nonneg
The norm of any vector is non-negative: 0 ≤ ‖a‖.
sub_sub_sub_cancel_right
Vector subtraction identity: (a - c) - (b - c) = a - b.
dist_eq_norm
The metric distance in a normed space equals the norm of the difference: dist(a, b) = ‖a - b‖.
one_strongly_euclidean_spherical_core_variable_height_extension_t_antitone
The function t(z) = q / (q + 2z + 2z²) is weakly decreasing for z > 0: t(b) ≤ t(a) when a ≤ b.
one_strongly_euclidean_spherical_core_variable_height_extension_norm_decomp
Norm decomposition bound: ‖(c + t₁ v₁) - (c + t₂ v₂)‖ ≤ (q/2)(t₁ - t₂) + t₂ d for 0 ≤ t₂ ≤ t₁ and ‖v₁‖ = q/2, ‖v₁ - v₂‖ = d.
Real.one_le_sqrt.mpr
If 1 ≤ q, then 1 ≤ √q.
one_mul
1 is the multiplicative identity: 1 · a = a.
one_strongly_euclidean_sphere_squared_distance_identity
Identity for the squared distance of scaled spherical vectors: ‖x - t y‖² = (1 - t)² (q²/4) + t ‖x - y‖² when ‖x‖² = ‖y‖² = q²/4.
one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar
Cross-term scalar bound: (1 - t)²(q²/4) ≤ q z² and t ≤ q for t = q/(q + 2z + 2z²).
dist_comm
Symmetry of metric distance: dist(x, y) = dist(y, x).
le_total
Linear order totality: for any real numbers a and b, a ≤ b or b ≤ a.
one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le
Distance bound on the second layer B when h(b₁) ≤ h(b₂): dist(F(inr(b₁)), F(inr(b₂))) ≤ 2√q · dist(inr(b₁), inr(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

lemma one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar (q z : ℝ) (hq : 1 ≤ q) (hz : 0 ≤ z) :    let D := q + 2 * z + 2 * z^2    let t := q / D    (1 - t)^2 * (q^2 / 4) ≤ q * z^2 ∧ t ≤ q := by  intro D t  have hD_pos : 0 < D := by    dsimp [D]    have : 0 ≤ 2 * z := by linarith    have : 0 ≤ 2 * z^2 := by positivity    linarith  have ht_le : t ≤ 1 := by    dsimp [t, D]    rw [div_le_iff₀ hD_pos]    have : 0 ≤ 2 * z := by linarith    have : 0 ≤ 2 * z^2 := by positivity    linarith  have ht_q : t ≤ q := by linarith  refine ⟨?_, ht_q⟩  have h1 : 1 - t = (2 * z + 2 * z^2) / D := by    dsimp [t]    rw [← div_self (ne_of_gt hD_pos), ← sub_div]    dsimp [D]    ring  have h2 : (1 - t)^2 * (q^2 / 4) = (q * z * (1 + z) / D)^2 := by    rw [h1]    ring  rw [h2]  have h_bound := one_strongly_euclidean_variable_height_scalar_bound q z hq hz  have h_lin : q * (1 + z) ≤ Real.sqrt q * D := by    have : q * (1 + z) ≤ q * (1 + 2 * z) := by nlinarith    linarith [h_bound]  have h_mul : q * z * (1 + z) ≤ (Real.sqrt q * z) * D := by    calc q * z * (1 + z) = z * (q * (1 + z)) := by ring      _ ≤ z * (Real.sqrt q * D) := mul_le_mul_of_nonneg_left h_lin hz      _ = (Real.sqrt q * z) * D := by ring  have h_div : q * z * (1 + z) / D ≤ Real.sqrt q * z := by    rw [div_le_iff₀ hD_pos]    exact h_mul  have h_nonneg : 0 ≤ q * z * (1 + z) / D := by    apply div_nonneg _ (le_of_lt hD_pos)    have : 0 ≤ q := by linarith    have : 0 ≤ 1 + z := by linarith    positivity  have h_sq : (q * z * (1 + z) / D)^2 ≤ (Real.sqrt q * z)^2 := by    nlinarith [h_div, h_nonneg]  have h_rt : (Real.sqrt q * z)^2 = q * z^2 := by    have : 0 ≤ q := by linarith    rw [mul_pow, Real.sq_sqrt this]  linarithlemma one_strongly_euclidean_spherical_core_variable_height_extension_diff_quotient (q a b : ℝ) (hq : 1 ≤ q) (ha : 0 < a) (hab : a ≤ b) :    let D := fun z => q + 2 * z + 2 * z^2    let t := fun z => q / D z    (q / 2) * (t a - t b) ≤ Real.sqrt q * (b - a) := by  intro D t  have hb_nonneg : 0 ≤ b := le_trans (le_of_lt ha) hab  have hDa_pos : 0 < D a := by    dsimp [D]    have : 0 ≤ 2 * a := by linarith    have : 0 ≤ 2 * a^2 := by positivity    linarith  have hDb_pos : 0 < D b := by    dsimp [D]    have : 0 ≤ 2 * b := by linarith    have : 0 ≤ 2 * b^2 := by positivity    linarith  have hDa_ge_q : q ≤ D a := by    dsimp [D]    have : 0 ≤ 2 * a := by linarith    have : 0 ≤ 2 * a^2 := by positivity    linarith  have h_diff : D b - D a = 2 * (b - a) * (1 + a + b) := by    dsimp [D]    ring  have h_sub : t a - t b = q * (D b - D a) / (D a * D b) := by    dsimp [t]    rw [div_sub_div _ _ (ne_of_gt hDa_pos) (ne_of_gt hDb_pos)]    ring  have h_mul : (q / 2) * (t a - t b) = (q^2 * (b - a) * (1 + a + b)) / (D a * D b) := by    rw [h_sub, h_diff]    ring  have h_bound := one_strongly_euclidean_variable_height_scalar_bound q b hq hb_nonneg  have h_lin : 1 + a + b ≤ 1 + 2 * b := by linarith  have h_prod : q^2 * (b - a) * (1 + a + b) ≤ (Real.sqrt q * (b - a)) * (D a * D b) := by    have h1 : q * (1 + a + b) ≤ q * (1 + 2 * b) := by nlinarith    have h2 : q * (1 + a + b) ≤ Real.sqrt q * D b := le_trans h1 h_bound    have h3 : q * (b - a) * (q * (1 + a + b)) ≤ q * (b - a) * (Real.sqrt q * D b) :=      mul_le_mul_of_nonneg_left h2 (by nlinarith)    have h4 : q * (b - a) * (Real.sqrt q * D b) ≤ (Real.sqrt q * (b - a)) * (D a * D b) := by      calc q * (b - a) * (Real.sqrt q * D b) = (Real.sqrt q * (b - a)) * (q * D b) := by ring        _ ≤ (Real.sqrt q * (b - a)) * (D a * D b) := by          apply mul_le_mul_of_nonneg_left          · exact mul_le_mul_of_nonneg_right hDa_ge_q (le_of_lt hDb_pos)          · have : 0 ≤ Real.sqrt q := Real.sqrt_nonneg q            positivity    calc q^2 * (b - a) * (1 + a + b) = q * (b - a) * (q * (1 + a + b)) := by ring      _ ≤ (Real.sqrt q * (b - a)) * (D a * D b) := le_trans h3 h4  rw [h_mul]  rw [div_le_iff₀]  · exact h_prod  · positivitylemma one_strongly_euclidean_spherical_core_variable_height_extension_radial_s (b : ℝ) (hb : 0 < b) :    let s := Real.sqrt (b^2 + 1) - b    0 < s ∧ s^2 + 2 * b * s = 1 ∧ 1 ≤ s * (1 + 2 * b) := by  intro s  have hb2 : 0 < b^2 + 1 := by positivity  have hsq_rt : (Real.sqrt (b^2 + 1))^2 = b^2 + 1 := Real.sq_sqrt (le_of_lt hb2)  have hrt_gt_b : b < Real.sqrt (b^2 + 1) := by    have h1 : b^2 < b^2 + 1 := by linarith    have h2 := Real.sqrt_lt_sqrt (sq_nonneg b) h1    rwa [Real.sqrt_sq (le_of_lt hb)] at h2  have hs_pos : 0 < s := by    dsimp [s]; linarith  have h_id : s^2 + 2 * b * s = 1 := by    dsimp [s]    have : (Real.sqrt (b^2 + 1) - b)^2 + 2 * b * (Real.sqrt (b^2 + 1) - b) =      (Real.sqrt (b^2 + 1))^2 - b^2 := by ring    rw [this, hsq_rt]    ring  have h_prod : s * (Real.sqrt (b^2 + 1) + b) = 1 := by    dsimp [s]    have : (Real.sqrt (b^2 + 1) - b) * (Real.sqrt (b^2 + 1) + b) =      (Real.sqrt (b^2 + 1))^2 - b^2 := by ring    rw [this, hsq_rt]    ring  have h_le : 1 ≤ s * (1 + 2 * b) := by    have h_sqrt_le : Real.sqrt (b^2 + 1) ≤ b + 1 := by      have h2 : 0 ≤ b + 1 := by linarith      have h3 : b^2 + 1 ≤ (b + 1)^2 := by nlinarith      rw [← Real.sqrt_sq h2]      exact Real.sqrt_le_sqrt h3    rw [← h_prod]    apply mul_le_mul_of_nonneg_left _ (le_of_lt hs_pos)    linarith  exact ⟨hs_pos, h_id, h_le⟩lemma one_strongly_euclidean_spherical_core_variable_height_extension_radial_prod (q b d Δ s : ℝ)    (hq : 1 ≤ q) (hb : 0 < b) (hd : 0 ≤ d) (hs : 0 ≤ s)    (h_sd : s * d ≤ Δ)    (h_s_le : 1 ≤ s * (1 + 2 * b)) :    let D := q + 2 * b + 2 * b^2    let t := q / D    t * d ≤ Real.sqrt q * Δ := by  intro D t  have h_scalar := one_strongly_euclidean_variable_height_scalar_bound q b hq (le_of_lt hb)  have hD_pos : 0 < D := by    dsimp [D]    have : 0 ≤ 2 * b := by linarith    have : 0 ≤ 2 * b^2 := by positivity    linarith  have h1 : t * d ≤ t * d * (s * (1 + 2 * b)) := by    have ht_nonneg : 0 ≤ t := div_nonneg (by linarith) (le_of_lt hD_pos)    have : 0 ≤ t * d := mul_nonneg ht_nonneg hd    calc t * d = t * d * 1 := (mul_one _).symm      _ ≤ t * d * (s * (1 + 2 * b)) := mul_le_mul_of_nonneg_left h_s_le this  have h2 : t * d * (s * (1 + 2 * b)) = (t * (1 + 2 * b)) * (s * d) := by ring  have h3 : t * (1 + 2 * b) ≤ Real.sqrt q := by    dsimp [t]    rw [div_mul_eq_mul_div, div_le_iff₀ hD_pos]    exact h_scalar  have h5 : (t * (1 + 2 * b)) * (s * d) ≤ Real.sqrt q * Δ :=    mul_le_mul h3 h_sd (mul_nonneg hs hd) (Real.sqrt_nonneg q)  linarithlemma one_strongly_euclidean_spherical_core_variable_height_extension_dist_inr_ge (A B : Type) (M : MetricSpace (Sum A B))    (H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]    (u : A → H) (p : B → A) (h : B → ℝ)    (hh : ∀ b, 0 < h b)    (hcross : ∀ a b, (dist (Sum.inl a : Sum A B) (Sum.inr b))^2 = (h b)^2 + (dist (u a) (u (p b)))^2)    (b1 b2 : B) :    letI := M    let d := dist (u (p b1)) (u (p b2))    Real.sqrt ((h b2)^2 + d^2) - h b1 ≤ dist (Sum.inr b1 : Sum A B) (Sum.inr b2) := by  intro d  have h1 : dist (Sum.inl (p b1) : Sum A B) (Sum.inr b1) = h b1 := by    have hsq := hcross (p b1) b1    rw [dist_self, zero_pow two_ne_zero, add_zero] at hsq    have h_nonneg : 0 ≤ dist (Sum.inl (p b1) : Sum A B) (Sum.inr b1) := dist_nonneg    have hh_nonneg : 0 ≤ h b1 := le_of_lt (hh b1)    nlinarith  have h2 : dist (Sum.inl (p b1) : Sum A B) (Sum.inr b2) = Real.sqrt ((h b2)^2 + d^2) := by    have hsq := hcross (p b1) b2    have h_nonneg : 0 ≤ dist (Sum.inl (p b1) : Sum A B) (Sum.inr b2) := dist_nonneg    rw [← hsq]    exact (Real.sqrt_sq h_nonneg).symm  have htri : dist (Sum.inl (p b1) : Sum A B) (Sum.inr b2) ≤    dist (Sum.inl (p b1)) (Sum.inr b1) + dist (Sum.inr b1) (Sum.inr b2) :=    dist_triangle (Sum.inl (p b1)) (Sum.inr b1) (Sum.inr b2)  linarithlemma one_strongly_euclidean_spherical_core_variable_height_extension_norm_decomp (H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]    (c : H) (v1 v2 : H) (t1 t2 q d : ℝ)    (ht2 : 0 ≤ t2) (ht12 : t2 ≤ t1)    (hv1 : ‖v1‖ = q / 2) (hsub : ‖v1 - v2‖ = d) :    ‖(c + t1 • v1) - (c + t2 • v2)‖ ≤ (q / 2) * (t1 - t2) + t2 * d := by  have h_id : (c + t1 • v1) - (c + t2 • v2) = (t1 - t2) • v1 + t2 • (v1 - v2) := by    calc (c + t1 • v1) - (c + t2 • v2) = t1 • v1 - t2 • v2 := by abel      _ = (t1 - t2) • v1 + t2 • (v1 - v2) := by        rw [sub_smul, smul_sub]        abel  rw [h_id]  have h_tri := norm_add_le ((t1 - t2) • v1) (t2 • (v1 - v2))  rw [norm_smul, norm_smul, Real.norm_eq_abs, Real.norm_eq_abs,      abs_of_nonneg (by linarith : 0 ≤ t1 - t2), abs_of_nonneg ht2,      hv1, hsub] at h_tri  linarithlemma one_strongly_euclidean_spherical_core_variable_height_extension_t_antitone (q a b : ℝ) (hq : 1 ≤ q) (ha : 0 < a) (hab : a ≤ b) :    let D := fun z => q + 2 * z + 2 * z^2    let t := fun z => q / D z    t b ≤ t a := by  intro D t  have hDa_pos : 0 < D a := by    dsimp [D]    have : 0 ≤ 2 * a := by linarith    have : 0 ≤ 2 * a^2 := by positivity    linarith  have h_le : D a ≤ D b := by    dsimp [D]    have : 2 * a ≤ 2 * b := by linarith    have : 2 * a^2 ≤ 2 * b^2 := by nlinarith    linarith  dsimp [t]  exact div_le_div_of_nonneg_left (by linarith) hDa_pos h_lelemma one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le (A B H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]    (u : A → H) (p : B → A) (c : H) (q : ℝ) (h : B → ℝ)    (hq : 1 ≤ q) (hh : ∀ b, 0 < h b)    (hu : ∀ a, ‖u a - c‖^2 = q^2 / 4)    (hsep : ∀ a a', a ≠ a' → 1 ≤ dist (u a) (u a')^2)    (M : MetricSpace (Sum A B))    (hcross : ∀ a b, dist (Sum.inl a) (Sum.inr b)^2 = (h b)^2 + dist (u a) (u (p b))^2)    (b1 b2 : B) (hle : h b1 ≤ h b2) :    letI := M    let D := fun z => q + 2 * z + 2 * z^2    let t := fun z => q / D z    let F2 := fun b => c + t (h b) • (u (p b) - c)    dist (F2 b1) (F2 b2) ≤ (2 * Real.sqrt q) * dist (Sum.inr b1 : Sum A B) (Sum.inr b2) := by  intro D t F2  let a := h b1  let b := h b2  let d := dist (u (p b1)) (u (p b2))  let Δ := dist (Sum.inr b1 : Sum A B) (Sum.inr b2)  have ha_pos : 0 < a := hh b1  have hb_pos : 0 < b := hh b2  have hd_nonneg : 0 ≤ d := dist_nonneg  have hΔ_nonneg : 0 ≤ Δ := dist_nonneg  have h_inr_ge := one_strongly_euclidean_spherical_core_variable_height_extension_dist_inr_ge A B M H u p h hh hcross b1 b2  have hb_le_rt : b ≤ Real.sqrt (b^2 + d^2) := by    have : b = Real.sqrt (b^2) := (Real.sqrt_sq (le_of_lt hb_pos)).symm    nth_rw 1 [this]    apply Real.sqrt_le_sqrt    have : 0 ≤ d^2 := sq_nonneg d    linarith  have h_ba_le_Δ : b - a ≤ Δ := by linarith [h_inr_ge, hb_le_rt]  have h_rt_b_le_Δ : Real.sqrt (b^2 + d^2) - b ≤ Δ := by linarith [h_inr_ge, hle]  have ht_diff := one_strongly_euclidean_spherical_core_variable_height_extension_diff_quotient q a b hq ha_pos hle  have ht_diff_Δ : (q / 2) * (t a - t b) ≤ Real.sqrt q * Δ := by    have h1 : Real.sqrt q * (b - a) ≤ Real.sqrt q * Δ :=      mul_le_mul_of_nonneg_left h_ba_le_Δ (Real.sqrt_nonneg q)    linarith [ht_diff, h1]  have ht_d_Δ : t b * d ≤ Real.sqrt q * Δ := by    by_cases h_eq : p b1 = p b2    · have : d = 0 := by        dsimp [d]        rw [h_eq, dist_self]      rw [this, mul_zero]      have : 0 ≤ Real.sqrt q * Δ := mul_nonneg (Real.sqrt_nonneg q) hΔ_nonneg      linarith    · have hd_sq : 1 ≤ dist (u (p b1)) (u (p b2))^2 := hsep (p b1) (p b2) h_eq      have hd_one : 1 ≤ d := by nlinarith [hd_sq, hd_nonneg]      have hs_prop := one_strongly_euclidean_spherical_core_variable_height_extension_radial_s b hb_pos      let s := Real.sqrt (b^2 + 1) - b      have hrad := one_strongly_euclidean_sphere_radial_bound b s d hb_pos hs_prop.1 hs_prop.2.1 hd_one      have h_sd_le_Δ : s * d ≤ Δ := le_trans hrad h_rt_b_le_Δ      exact one_strongly_euclidean_spherical_core_variable_height_extension_radial_prod q b d Δ s hq hb_pos hd_nonneg (le_of_lt hs_prop.1) h_sd_le_Δ hs_prop.2.2  have h_norm1 : ‖u (p b1) - c‖ = q / 2 := by    have hu1 := hu (p b1)    have : 0 ≤ q / 2 := by linarith    have : 0 ≤ ‖u (p b1) - c‖ := norm_nonneg _    nlinarith  have h_sub_d : ‖(u (p b1) - c) - (u (p b2) - c)‖ = d := by    dsimp [d]    rw [sub_sub_sub_cancel_right, dist_eq_norm]  have ht_anti := one_strongly_euclidean_spherical_core_variable_height_extension_t_antitone q a b hq ha_pos hle  have ht2_nonneg : 0 ≤ t b := by    dsimp [t]    have : 0 < q + 2 * b + 2 * b^2 := by      have : 0 ≤ 2 * b := by linarith      have : 0 ≤ 2 * b^2 := by positivity      linarith    exact div_nonneg (by linarith) (le_of_lt this)  have h_decomp := one_strongly_euclidean_spherical_core_variable_height_extension_norm_decomp H c (u (p b1) - c) (u (p b2) - c) (t a) (t b) q d    ht2_nonneg ht_anti h_norm1 h_sub_d  dsimp [F2]  rw [dist_eq_norm]  linariththeorem one_strongly_euclidean_spherical_core_variable_height_extension (A B H : Type) [NormedAddCommGroup H] [InnerProductSpace ℝ H]    (u : A → H) (p : B → A) (c : H) (q : ℝ) (h : B → ℝ)    (hq : 1 ≤ q) (hh : ∀ b, 0 < h b)    (hu : ∀ a, ‖u a - c‖^2 = q^2 / 4)    (hsep : ∀ a a', a ≠ a' → 1 ≤ dist (u a) (u a')^2)    (M : MetricSpace (Sum A B)) :    letI := M    (∀ a a', dist (Sum.inl a : Sum A B) (Sum.inl a') = dist (u a) (u a')) →    (∀ a b, dist (Sum.inl a) (Sum.inr b)^2 = (h b)^2 + dist (u a) (u (p b))^2) →    ∃ F : Sum A B → H,      (∀ a, F (Sum.inl a) = u a) ∧      ∀ x y, dist (F x) (F y) ≤ (2 * Real.sqrt q) * dist x y := by  intro hinl hcross  let D : ℝ → ℝ := fun z => q + 2 * z + 2 * z^2  let t : ℝ → ℝ := fun z => q / D z  let F : Sum A B → H := fun x =>    match x with    | Sum.inl a => u a    | Sum.inr b => c + t (h b) • (u (p b) - c)  use F  refine ⟨fun a => rfl, ?_⟩  rintro (a1 | b1) (a2 | b2)  · -- inl a1, inl a2    dsimp [F]    have hq1 : 1 ≤ Real.sqrt q := Real.one_le_sqrt.mpr hq    have h2q : 1 ≤ 2 * Real.sqrt q := by linarith    have h_d : dist (u a1) (u a2) ≤ (2 * Real.sqrt q) * dist (u a1) (u a2) := by      calc dist (u a1) (u a2) = 1 * dist (u a1) (u a2) := (one_mul _).symm        _ ≤ (2 * Real.sqrt q) * dist (u a1) (u a2) :=          mul_le_mul_of_nonneg_right h2q dist_nonneg    rwa [hinl a1 a2]  · -- inl a1, inr b2    rw [dist_eq_norm]    let x := u a1 - c    let y := u (p b2) - c    have h_diff : F (Sum.inl a1) - F (Sum.inr b2) = x - t (h b2) • y := by      dsimp [F, x, y]      abel    rw [h_diff]    have h_id := one_strongly_euclidean_sphere_squared_distance_identity H x y (t (h b2)) q (hu a1) (hu (p b2))    have h_scal := one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar q (h b2) hq (le_of_lt (hh b2))    have h_sq : ‖x - t (h b2) • y‖^2 ≤ q * dist (Sum.inl a1 : Sum A B) (Sum.inr b2)^2 := by      rw [h_id, hcross a1 b2]      have h_xy : ‖x - y‖^2 = dist (u a1) (u (p b2))^2 := by        have : x - y = u a1 - u (p b2) := by dsimp [x, y]; abel        rw [this, ← dist_eq_norm]      rw [h_xy]      have h1 := h_scal.1      have h2 := h_scal.2      have : 0 ≤ dist (u a1) (u (p b2))^2 := sq_nonneg _      nlinarith    have hq_pos : 0 ≤ q := by linarith    have h_d_nonneg : 0 ≤ dist (Sum.inl a1 : Sum A B) (Sum.inr b2) := dist_nonneg    have h_4q : q * dist (Sum.inl a1 : Sum A B) (Sum.inr b2)^2 ≤        ((2 * Real.sqrt q) * dist (Sum.inl a1) (Sum.inr b2))^2 := by      rw [mul_pow, mul_pow, Real.sq_sqrt hq_pos]      nlinarith    have h_norm_nonneg : 0 ≤ ‖x - t (h b2) • y‖ := norm_nonneg _    have h_rhs_nonneg : 0 ≤ (2 * Real.sqrt q) * dist (Sum.inl a1 : Sum A B) (Sum.inr b2) := by      have : 0 ≤ Real.sqrt q := Real.sqrt_nonneg q      positivity    nlinarith  · -- inr b1, inl a2    rw [dist_comm (F (Sum.inr b1)) (F (Sum.inl a2)), dist_comm (Sum.inr b1 : Sum A B) (Sum.inl a2)]    rw [dist_eq_norm]    let x := u a2 - c    let y := u (p b1) - c    have h_diff : F (Sum.inl a2) - F (Sum.inr b1) = x - t (h b1) • y := by      dsimp [F, x, y]      abel    rw [h_diff]    have h_id := one_strongly_euclidean_sphere_squared_distance_identity H x y (t (h b1)) q (hu a2) (hu (p b1))    have h_scal := one_strongly_euclidean_spherical_core_variable_height_extension_cross_scalar q (h b1) hq (le_of_lt (hh b1))    have h_sq : ‖x - t (h b1) • y‖^2 ≤ q * dist (Sum.inl a2 : Sum A B) (Sum.inr b1)^2 := by      rw [h_id, hcross a2 b1]      have h_xy : ‖x - y‖^2 = dist (u a2) (u (p b1))^2 := by        have : x - y = u a2 - u (p b1) := by dsimp [x, y]; abel        rw [this, ← dist_eq_norm]      rw [h_xy]      have h1 := h_scal.1      have h2 := h_scal.2      have : 0 ≤ dist (u a2) (u (p b1))^2 := sq_nonneg _      nlinarith    have hq_pos : 0 ≤ q := by linarith    have h_d_nonneg : 0 ≤ dist (Sum.inl a2 : Sum A B) (Sum.inr b1) := dist_nonneg    have h_4q : q * dist (Sum.inl a2 : Sum A B) (Sum.inr b1)^2 ≤        ((2 * Real.sqrt q) * dist (Sum.inl a2) (Sum.inr b1))^2 := by      rw [mul_pow, mul_pow, Real.sq_sqrt hq_pos]      nlinarith    have h_norm_nonneg : 0 ≤ ‖x - t (h b1) • y‖ := norm_nonneg _    have h_rhs_nonneg : 0 ≤ (2 * Real.sqrt q) * dist (Sum.inl a2 : Sum A B) (Sum.inr b1) := by      have : 0 ≤ Real.sqrt q := Real.sqrt_nonneg q      positivity    nlinarith  · -- inr b1, inr b2    rcases le_total (h b1) (h b2) with hle | hle    · exact one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le A B H u p c q h hq hh hu hsep M hcross b1 b2 hle    · rw [dist_comm (F (Sum.inr b1)) (F (Sum.inr b2)), dist_comm (Sum.inr b1 : Sum A B) (Sum.inr b2)]      exact one_strongly_euclidean_spherical_core_variable_height_extension_second_layer_le A B H u p c q h hq hh hu hsep M hcross b2 b1 hle
See it in the graphDiscuss this resultChallenge it