AFTD Auto-Formalizing Theoretical Domains

helical_dist_sq

theoremverified

For any natural number n and indices i, j : Fin n, the squared Euclidean distance dist (helical_point n i) (helical_point n j) ^ 2 in EuclideanSpace ℝ (Fin 3) equals 2 - 2 * Real.cos (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) + 4 * (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) ^ 2.

Statement

theorem helical_dist_sq (n : ℕ) (i j : Fin n) :
    dist (helical_point n i) (helical_point n j) ^ 2 =
      2 - 2 * Real.cos (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) +
        4 * (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) ^ 2
Source
arXiv:2610.38368, Section 2
Verified
02 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • helical_pointFor a natural number n and an index j : Fin n, helical_point n j is the vector in EuclideanSpace ℝ (Fin 3) with coordinates cos((j : ℝ) /…

Read back from the Lean

For every natural number $n$ and all indices $i, j : \text{Fin } n$, the squared Euclidean distance between $\text{helical\_point}(n, i)$ and $\text{helical\_point}(n, j)$ is equal to $2 - 2 \cos\left(\frac{|(i : \mathbb{R}) - (j : \mathbb{R})|}{n}\right) + 4 \left(\frac{|(i : \mathbb{R}) - (j : \mathbb{R})|}{n}\right)^2$.

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 proof computes the squared Euclidean distance between two helical points by decomposing it into the sum of squares of their coordinate differences: two horizontal components and one vertical component. Using the cosine difference formula and the Pythagorean identity cos² θ + sin² θ = 1, the sum of the horizontal squared differences simplifies to 2 - 2 cos(i/n - j/n). Finally, the differences are matched to the theorem statement using the evenness of cosine (cos(-x) = cos x), the identity |x|² = x², and scaling the vertical term to 4((i - j)/n)².

  1. The squared Euclidean distance expands coordinate-wise to (cos(i/n) - cos(j/n))^2 + (sin(i/n) - sin(j/n))^2 + (2i/n - 2j/n)^2.

    By EuclideanSpace.dist_sq_eq and Fin.sum_univ_three, the squared distance in ℝ³ is the sum of the squared coordinate distances along the three axes. Unfolding the definition of helical_point and rewriting the 1D real distances via Real.dist_eq yields the sum of squared coordinate differences.

    lines 6–12

    uses EuclideanSpace.dist_sq_eq, Fin.sum_univ_three, Real.dist_eq

      have hdist : dist (helical_point n i) (helical_point n j) ^ 2 =
          (Real.cos ((i : ℝ) / n) - Real.cos ((j : ℝ) / n)) ^ 2 +
          (Real.sin ((i : ℝ) / n) - Real.sin ((j : ℝ) / n)) ^ 2 +
          (2 * (i : ℝ) / n - 2 * (j : ℝ) / n) ^ 2 := by
        rw [EuclideanSpace.dist_sq_eq, Fin.sum_univ_three]
        dsimp [helical_point]
        simp [Real.dist_eq]
  2. The absolute value inside the cosine can be dropped: cos(|i - j| / n) = cos(i/n - j/n).

    Writing (i - j)/n as i/n - j/n via sub_div, le_total gives a case split on the sign of i - j. If 0 ≤ i - j, abs_of_nonneg removes the absolute value directly. If i - j ≤ 0, abs_of_nonpos replaces |i - j| with -(i - j); moving the negative sign outside the fraction via neg_div, Real.cos_neg removes it because cosine is an even function.

    lines 13–17

    uses sub_div, le_total, abs_of_nonneg, abs_of_nonpos, neg_div, Real.cos_neg

      have hcos : Real.cos (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) = Real.cos ((i : ℝ) / n - (j : ℝ) / n) := by
        rw [← sub_div]
        rcases le_total 0 ((i : ℝ) - (j : ℝ)) with h | h
        · rw [abs_of_nonneg h]
        · rw [abs_of_nonpos h, neg_div, Real.cos_neg]
  3. The squared absolute ratio equals the squared difference: (|i - j| / n)^2 = (i/n - j/n)^2.

    Using sub_div, div_pow, and sq_abs, the fraction (|i - j| / n)^2 simplifies to |i - j|^2 / n^2 = (i - j)^2 / n^2 = (i/n - j/n)^2.

    lines 18–19

    uses sub_div, div_pow, sq_abs

      have hsq : (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) ^ 2 = ((i : ℝ) / n - (j : ℝ) / n) ^ 2 := by
        rw [← sub_div, div_pow, div_pow, sq_abs]
  4. The goal reduces to proving (cos u - cos v)^2 + (sin u - sin v)^2 + (2i/n - 2j/n)^2 = 2 - 2 * cos(u - v) + 4 * (u - v)^2, with u = i/n and v = j/n.

    Substituting the coordinate expansion (hdist) and the identities eliminating the absolute values (hcos and hsq) into the main goal eliminates all absolute values, after which u and v are introduced as shorthand for i/n and j/n.

    lines 20–22

      rw [hdist, hcos, hsq]
      set u : ℝ := (i : ℝ) / n
      set v : ℝ := (j : ℝ) / n
  5. The horizontal trigonometric terms simplify: (cos u - cos v)^2 + (sin u - sin v)^2 = 2 - 2 * cos(u - v).

    Expanding cos(u - v) with Real.cos_sub gives cos u * cos v + sin u * sin v. Expanding the squares on the left and invoking the Pythagorean identity Real.cos_sq_add_sin_sq for both u and v, linear_combination cancels the squared terms to produce 1 + 1 - 2 * cos(u - v) = 2 - 2 * cos(u - v).

    lines 23–28

    uses Real.cos_sub, Real.cos_sq_add_sin_sq

      have h1 : (Real.cos u - Real.cos v) ^ 2 + (Real.sin u - Real.sin v) ^ 2 =
          2 - 2 * Real.cos (u - v) := by
        rw [Real.cos_sub]
        have h2 := Real.cos_sq_add_sin_sq u
        have h3 := Real.cos_sq_add_sin_sq v
        linear_combination h2 + h3
  6. The vertical difference (2i/n - 2j/n)^2 simplifies to 4 * (u - v)^2, and combining this with the horizontal contribution completes the equality.

    Ring arithmetic shows that (2u - 2v)^2 = 4 * (u - v)^2 (h4) and that 2i/n - 2j/n equals 2u - 2v (h5). Rewriting the remaining goal with h5, h4, and the trigonometric identity h1 makes both sides identical, closing the proof.

    lines 29–34

      have h4 : (2 * u - 2 * v) ^ 2 = 4 * (u - v) ^ 2 := by
        ring
      have h5 : (2 * (i : ℝ) / n - 2 * (j : ℝ) / n) = 2 * u - 2 * v := by
        dsimp [u, v]
        ring
      rw [h5, h4, h1]
EuclideanSpace.dist_sq_eq
In a Euclidean space, the squared distance between two points equals the sum of the squared distances between their coordinates.
Fin.sum_univ_three
A sum of values indexed over Fin 3 equals the sum of the values at indices 0, 1, and 2.
Real.dist_eq
The Euclidean distance between two real numbers equals the absolute value of their difference.
sub_div
Division distributes over subtraction: (a - b) / c = a / c - b / c.
le_total
In a linearly ordered type, any two elements are comparable: a ≤ b or b ≤ a.
abs_of_nonneg
The absolute value of a non-negative number is the number itself: if 0 ≤ a then |a| = a.
abs_of_nonpos
The absolute value of a non-positive number is its negation: if a ≤ 0 then |a| = -a.
neg_div
Negating the numerator negates the quotient: -b / a = -(b / a).
Real.cos_neg
The cosine function is even: cos(-x) = cos x.
div_pow
A quotient raised to a power distributes the exponent to numerator and denominator: (a / b) ^ n = a ^ n / b ^ n.
sq_abs
The square of the absolute value of a number equals the square of the number: |a| ^ 2 = a ^ 2.
Real.cos_sub
The cosine difference formula: cos(x - y) = cos x * cos y + sin x * sin y.
Real.cos_sq_add_sin_sq
The fundamental Pythagorean trigonometric identity: cos x ^ 2 + sin x ^ 2 = 1.

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

/-- The squared distance between helical points P_i and P_j depends only on |i - j|. -/theorem helical_dist_sq (n : ℕ) (i j : Fin n) :    dist (helical_point n i) (helical_point n j) ^ 2 =      2 - 2 * Real.cos (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) +        4 * (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) ^ 2 := by  have hdist : dist (helical_point n i) (helical_point n j) ^ 2 =      (Real.cos ((i : ℝ) / n) - Real.cos ((j : ℝ) / n)) ^ 2 +      (Real.sin ((i : ℝ) / n) - Real.sin ((j : ℝ) / n)) ^ 2 +      (2 * (i : ℝ) / n - 2 * (j : ℝ) / n) ^ 2 := by    rw [EuclideanSpace.dist_sq_eq, Fin.sum_univ_three]    dsimp [helical_point]    simp [Real.dist_eq]  have hcos : Real.cos (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) = Real.cos ((i : ℝ) / n - (j : ℝ) / n) := by    rw [← sub_div]    rcases le_total 0 ((i : ℝ) - (j : ℝ)) with h | h    · rw [abs_of_nonneg h]    · rw [abs_of_nonpos h, neg_div, Real.cos_neg]  have hsq : (((|((i : ℝ) - (j : ℝ))|) : ℝ) / n) ^ 2 = ((i : ℝ) / n - (j : ℝ) / n) ^ 2 := by    rw [← sub_div, div_pow, div_pow, sq_abs]  rw [hdist, hcos, hsq]  set u : ℝ := (i : ℝ) / n  set v : ℝ := (j : ℝ) / n  have h1 : (Real.cos u - Real.cos v) ^ 2 + (Real.sin u - Real.sin v) ^ 2 =      2 - 2 * Real.cos (u - v) := by    rw [Real.cos_sub]    have h2 := Real.cos_sq_add_sin_sq u    have h3 := Real.cos_sq_add_sin_sq v    linear_combination h2 + h3  have h4 : (2 * u - 2 * v) ^ 2 = 4 * (u - v) ^ 2 := by    ring  have h5 : (2 * (i : ℝ) / n - 2 * (j : ℝ) / n) = 2 * u - 2 * v := by    dsimp [u, v]    ring  rw [h5, h4, h1]
See it in the graphDiscuss this resultChallenge it