rat_plane_point_dist
The distance between the plane points of rational pairs p and q is sqrt((p1-q1)^2 + (p2-q2)^2).
Statement
theorem rat_plane_point_dist (p q : ℚ × ℚ) :
dist (rat_plane_point p) (rat_plane_point q) =
Real.sqrt (((p.1 : ℝ) - q.1) ^ 2 + ((p.2 : ℝ) - q.2) ^ 2)- Source
- Sanity check of rat_plane_point: Euclidean distance formula.
- Verified
- 23 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- rat_plane_pointThe point of the Euclidean plane EuclideanSpace ℝ (Fin 2) with coordinates (x, y), for a pair (x, y) of rationals.
The proof, explained
The proof rewrites the distance between the two points into the standard Euclidean coordinate formula using `EuclideanSpace.dist_eq`. It then unfolds the definition of `rat_plane_point`, expands the sum over the two coordinates with `Fin.sum_univ_two`, and simplifies the squared absolute coordinate differences to ordinary squares.
Express the distance between the two points in Euclidean space ℝ² as the square root of the sum of squared coordinate distances.
We rewrite the distance using `EuclideanSpace.dist_eq`, which expands the distance between vectors in Euclidean space into the square root of the sum over all coordinates of the squared distances between their components.
uses
EuclideanSpace.dist_eqrw [EuclideanSpace.dist_eq]The distance between rat_plane_point p and rat_plane_point q is √((p.1 - q.1)² + (p.2 - q.2)²).
We unfold the definition of `rat_plane_point`, expand the sum over the two coordinates `Fin 2` into the term at 0 plus the term at 1 using `Fin.sum_univ_two`, express the one-dimensional real distance as an absolute difference using `Real.dist_eq`, and simplify |x - y|² to (x - y)² using `sq_abs`.
uses
rat_plane_point,Fin.sum_univ_two,Real.dist_eq,sq_abssimp [rat_plane_point, Fin.sum_univ_two, Real.dist_eq, sq_abs]
EuclideanSpace.dist_eq- The distance between two vectors in Euclidean space is the square root of the sum of the squared distances between their corresponding coordinates: dist(x, y) = √(∑ i, dist(xᵢ, yᵢ)²).
rat_plane_point- The embedding of a rational pair p = (p₁, p₂) into Euclidean space ℝ² as the vector !₂[p₁, p₂].
Fin.sum_univ_two- The sum of a function over the two-element index type Fin 2 is the sum of its values at 0 and 1: ∑ i, f(i) = f(0) + f(1).
Real.dist_eq- The distance between two real numbers is the absolute value of their difference: dist(x, y) = |x - y|.
sq_abs- The square of an absolute value equals the square of the original value: |a|² = a².
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem rat_plane_point_dist (p q : ℚ × ℚ) : dist (rat_plane_point p) (rat_plane_point q) = Real.sqrt (((p.1 : ℝ) - q.1) ^ 2 + ((p.2 : ℝ) - q.2) ^ 2) := by rw [EuclideanSpace.dist_eq] simp [rat_plane_point, Fin.sum_univ_two, Real.dist_eq, sq_abs]