mathlib4 review helperopen PRs by @themathqueen on leanprover-community/mathlib4

← queue

#33554 chore(Analysis/Normed/Module/Normalize): allow for RCLike instead of just the reals

awaiting-author merge-conflict t-analysis CI none merge conflict

+67 −60 · 5 files · 8 commits · head 6d74c84 · updated 333 days ago · Files changed on GitHub

In plain words

Generalises NormedSpace.normalize (the unit vector , with ) from real normed spaces to normed spaces over any RCLike field : now normalize 𝕜 x , with the scalar field passed explicitly. The basic API follows. normalize_smul_of_pos/_of_neg now take a scalar with or in the ComplexOrder partial order (positive or negative real). normalize_smul (real scalar) is renamed normalize_real_smul. All Euclidean-geometry uses (angles, triangle inequality, signedDist) now write normalize ℝ.

Transcriptions are drafted with an LLM from the diff and are a reading aid, not a verified statement: the Lean code is the reference.

PR description

Only the last lemma normalize_smul needs ℝ, which we rename to normalize_real_smul.

This also makes 𝕜 explicit in half of the results.


![Open in Gitpod](gitpod.io/from-referrer/)

Conversation on GitHub 3
github-actions[bot] · comment · 2026-01-04
PR summary 50b8949c2f
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-|

</details>


<details><summary>

Declarations diff

</summary>

+ normalize + normalize_real_smul - NormedSpace.normalize <details> <summary>You can run this locally as follows</summary>

## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

</details>

The doc-module for script/declarations_diff.sh contains some details about this script.

</details>


<details><summary>No changes to technical debt.</summary>

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

</details>

j-loreaux · comment · 2026-01-06

@themathqueen if you look at the PR which introduced this #26308 we had the discussion there, and we eventually opted for ℝ-only.

I think this PR should be closed, or else modified to do something entirely different, like add an explanation of the choice to be ℝ-specific to the module documentation.

mathlib4-merge-conflict-bot · comment · 2026-01-07

This pull request has conflicts, please merge master and resolve them.

Mathlib/Analysis/CStarAlgebra/Unitary/Span.lean +1 −1

lemma CStarAlgebra.norm_smul_two_inv_smul_add_four_unitary (x : A) (hx : x ≠ 0
lemma CStarAlgebra.norm_smul_two_inv_smul_add_four_unitary body changedL77–81
77 rw [smul_add, smul_comm _ I, Unitary.coe_star, Unitary.coe_star,
78 ← realPart_apply_coe (u₁ : A), ← realPart_apply_coe (u₂ : A)]
79 simpa only [u₁, u₂, selfAdjoint.realPart_unitarySelfAddISMul, realPart_add_I_smul_imaginaryPart]
− using Eq.symm <| NormedSpace.norm_smul_normalize x
80 using Eq.symm <| NormedSpace.norm_smul_normalize ℝ x
82end Ordered

Mathlib/Analysis/Normed/Module/Normalize.lean +30 −21

Function that returns unit length vector that points in the same direction
19@[expose] public section
−variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V]
21variable (𝕜 : Type*) {V : Type*} [RCLike 𝕜] [NormedAddCommGroup V] [NormedSpace 𝕜 V]
23namespace NormedSpace
def NormedSpace.normalize changedL25–26
25/-- For a nonzero vector `x`, `normalize x` is the unit-length vector that points
26in the same direction as `x`. If `x = 0`, then `normalize x = 0`. -/
−noncomputable def NormedSpace.normalize (x : V) : V := ‖x‖⁻¹ • x
−namespace NormedSpace
def normalize newL27–27
27def normalize (x : V) : V := (‖x‖⁻¹ : 𝕜) • x
theorem normalize_zero_eq_zero changedL29–31
29@[simp]
−theorem normalize_zero_eq_zero : normalize (0 : V) = 0 := by
30theorem normalize_zero_eq_zero : normalize 𝕜 (0 : V) = 0 := by
31 simp [normalize]
theorem normalize_eq_zero_iff changedL33–35
33@[simp]
−theorem normalize_eq_zero_iff (x : V) : normalize x = 0 ↔ x = 0 := by
34theorem normalize_eq_zero_iff (x : V) : normalize 𝕜 x = 0 ↔ x = 0 := by
35 by_cases hx : x = 0 <;> simp [normalize, hx]
theorem norm_smul_normalize changedL37–39
37@[simp]
−theorem norm_smul_normalize (x : V) : ‖x‖ • normalize x = x := by
38theorem norm_smul_normalize (x : V) : (‖x‖ : 𝕜) • normalize 𝕜 x = x := by
39 by_cases hx : x = 0 <;> simp [normalize, hx]
lemma norm_normalize_eq_one_iff changedL41–43
41@[simp]
−lemma norm_normalize_eq_one_iff {x : V} : ‖normalize x‖ = 1 ↔ x ≠ 0 := by
42lemma norm_normalize_eq_one_iff {x : V} : ‖normalize 𝕜 x‖ = 1 ↔ x ≠ 0 := by
43 by_cases hx : x = 0 <;> simp [normalize, hx, norm_smul]
45alias ⟨_, norm_normalize⟩ := norm_normalize_eq_one_iff
lemma normalize_eq_self_of_norm_eq_one changedL47–48
−lemma normalize_eq_self_of_norm_eq_one {x : V} (h : ‖x‖ = 1) : normalize x = x := by
47lemma normalize_eq_self_of_norm_eq_one {x : V} (h : ‖x‖ = 1) : normalize 𝕜 x = x := by
48 simp [normalize, h]
50variable {𝕜} in
theorem normalize_normalize changedL51–55
51@[simp]
−theorem normalize_normalize (x : V) : normalize (normalize x) = normalize x := by
52theorem normalize_normalize (x : V) : normalize 𝕜 (normalize 𝕜 x) = normalize 𝕜 x := by
53 by_cases hx : x = 0
54 · simp [hx]
55 · simp [normalize_eq_self_of_norm_eq_one, hx]
57variable {𝕜} in
theorem normalize_neg changedL58–60
58@[simp]
−theorem normalize_neg (x : V) : normalize (-x) = - normalize x := by
59theorem normalize_neg (x : V) : normalize 𝕜 (-x) = -normalize 𝕜 x := by
60 simp [normalize]
theorem normalize_smul_of_pos removedLundefined–undefined
−theorem normalize_smul_of_pos {r : ℝ} (hr : 0 < r) (x : V) :
− normalize (r • x) = normalize x := by
− simp [normalize, norm_smul, smul_smul, abs_of_pos hr, hr.ne']
theorem normalize_smul_of_neg removedLundefined–undefined
−theorem normalize_smul_of_neg {r : ℝ} (hr : r < 0) (x : V) :
− normalize (r • x) = - normalize x := by
− simpa using normalize_smul_of_pos (show 0 < -r by linarith) (-x)
theorem normalize_smul removedLundefined–undefined
−theorem normalize_smul (r : ℝ) (x : V) :
− normalize (r • x) = (SignType.sign r : ℝ) • normalize x := by
62open scoped ComplexOrder in
63variable {𝕜} in
theorem normalize_smul_of_pos newL64–66
64theorem normalize_smul_of_pos {r : 𝕜} (hr : 0 < r) (x : V) :
65 normalize 𝕜 (r • x) = normalize 𝕜 x := by
66 simp [normalize, norm_smul, smul_smul, RCLike.norm_of_nonneg' hr.le, hr.ne']
68open scoped ComplexOrder in
69variable {𝕜} in
theorem normalize_smul_of_neg newL70–72
70theorem normalize_smul_of_neg {r : 𝕜} (hr : r < 0) (x : V) :
71 normalize 𝕜 (r • x) = -normalize 𝕜 x := by
72 simpa using normalize_smul_of_pos (show 0 < -r by grind) (-x)
74variable {𝕜} in
theorem normalize_real_smul changedL75–80
75theorem normalize_real_smul (r : ℝ) (x : V) :
76 normalize 𝕜 ((r : 𝕜) • x) = (SignType.sign r : 𝕜) • normalize 𝕜 x := by
themathqueen · 2026-01-04

maybe add another version for real spaces? to allow for better rewriting:

theorem normalize_real_smul' {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V]
    (r : ℝ) (x : V) :
    normalize ℝ (r • x) = (SignType.sign r : ℝ) • normalize ℝ x := by
77 rcases lt_trichotomy 0 r with (h_pos | rfl | h_neg)
78 · simp [normalize_smul_of_pos, h_pos]
79 · simp
80 · simp [normalize_smul_of_neg, h_neg]
82@[deprecated (since := "2026-01-04")] alias normalize_smul := normalize_real_smul
84end NormedSpace

Mathlib/Geometry/Euclidean/Angle/Unoriented/Basic.lean +2 −2

lemma eq_of_angle_eq_zero_of_norm_eq {x y : V} (hxy : angle x y = 0) (h : ‖x
341between the original vectors. -/
lemma angle_normalize_left changedL342–347
342@[simp]
343lemma angle_normalize_left (x y : V) :
− angle (NormedSpace.normalize x) y = angle x y := by
344 angle (NormedSpace.normalize ℝ x) y = angle x y := by
345 by_cases hx : x = 0
346 · simp [hx]
347 · rw [NormedSpace.normalize, angle_smul_left_of_pos _ _ (by positivity)]
lemma angle_normalize_left (x y : V) :
350between the original vectors. -/
lemma angle_normalize_right changedL351–356
351@[simp]
352lemma angle_normalize_right (x y : V) :
− angle x (NormedSpace.normalize y) = angle x y := by
353 angle x (NormedSpace.normalize ℝ y) = angle x y := by
354 rw [angle_comm, angle_normalize_left, angle_comm]
356/-- The inner product of two unit vectors is equal to the cosine of the angle between them. -/

Mathlib/Geometry/Euclidean/Angle/Unoriented/TriangleInequality.lean +18 −19

lemma inner_ortho_nonneg {x y : V} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : 0 ≤
38 inner_self_eq_one_of_norm_eq_one hx, real_inner_smul_right, real_inner_comm, sub_nonneg]
39 grw [← sq, sq_le_one_iff_abs_le_one, abs_real_inner_le_norm, hx, hy, one_mul]
lemma inner_normalize_ortho changedL41–44
−lemma inner_normalize_ortho (x y : V) : ⟪y, normalize (ortho y x)⟫ = 0 := by
− simp only [NormedSpace.normalize, real_inner_smul_right, mul_eq_zero, inv_eq_zero, norm_eq_zero]
41lemma inner_normalize_ortho (x y : V) : ⟪y, normalize ℝ (ortho y x)⟫ = 0 := by
42 simp only [NormedSpace.normalize, real_inner_smul_right, mul_eq_zero]
43 right; rw [ortho, real_inner_comm, Submodule.starProjection_inner_eq_zero]
44 exact Submodule.mem_span_singleton_self y
variable (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) (hz : ‖z‖ = 1)
49include hx hy
lemma inner_normalized_ortho_sq_add_inner_sq_eq_one changedL50–54
50lemma inner_normalized_ortho_sq_add_inner_sq_eq_one :
− ⟪x, normalize (ortho y x)⟫ ^ 2 + ⟪x, y⟫ ^ 2 = 1 := by
51 ⟪x, normalize ℝ (ortho y x)⟫ ^ 2 + ⟪x, y⟫ ^ 2 = 1 := by
52 rw [NormedSpace.normalize, real_inner_smul_right, ortho_eq_sub_inner _ hy, inner_sub_right,
53 real_inner_smul_right]
54 by_cases h₁ : x = y
lemma inner_normalized_ortho_sq_add_inner_sq_eq_one :
70 ring
71 field_simp; exact H2
lemma inner_ortho_right_eq_sin_angle changedL73–82
−lemma inner_ortho_right_eq_sin_angle : ⟪x, normalize (ortho y x)⟫ = Real.sin (angle x y) := by
− have H : ⟪x, normalize (ortho y x)⟫ ^ 2 = Real.sin (angle x y) ^ 2 := by
73lemma inner_ortho_right_eq_sin_angle : ⟪x, normalize ℝ (ortho y x)⟫ = Real.sin (angle x y) := by
74 have H : ⟪x, normalize ℝ (ortho y x)⟫ ^ 2 = Real.sin (angle x y) ^ 2 := by
75 simp [Real.sin_sq, ← inner_eq_cos_angle_of_norm_eq_one hx hy,
76 ← inner_normalized_ortho_sq_add_inner_sq_eq_one hx hy]
77 rw [sq_eq_sq_iff_abs_eq_abs, abs_of_nonneg (sin_angle_nonneg x y)] at H
− have H0 : 0 ≤ ⟪x, normalize (ortho y x)⟫ := by
78 have H0 : 0 ≤ ⟪x, normalize ℝ (ortho y x)⟫ := by
79 rw [NormedSpace.normalize, real_inner_smul_right]
80 exact Left.mul_nonneg (inv_nonneg_of_nonneg (norm_nonneg (ortho y x)))
81 (inner_ortho_nonneg hx hy)
82 simp_all [abs_of_nonneg H0]
lemma angle_le_angle_add_angle_aux changedL84–88
84lemma angle_le_angle_add_angle_aux :
− x = Real.cos (angle x y) • y + Real.sin (angle x y) • normalize (ortho y x) := by
85 x = Real.cos (angle x y) • y + Real.sin (angle x y) • normalize ℝ (ortho y x) := by
86 rw [← inner_ortho_right_eq_sin_angle hx hy, ← inner_eq_cos_angle_of_norm_eq_one hx hy,
87 ortho_eq_sub_inner _ hy]
88 by_cases hxy : x - ⟪x, y⟫ • y = 0
lemma angle_le_angle_add_angle_of_norm_eq_one : angle x z ≤ angle x y + angle
lemma angle_le_angle_add_angle_of_norm_eq_one body changedL119–135
119 have H1 : ⟪x, z⟫ = ⟪x, z⟫ := rfl
120 nth_rw 2 [angle_le_angle_add_angle_aux hx hy, angle_le_angle_add_angle_aux hz hy] at H1
121 simp only [inner_add_left, inner_add_right, real_inner_smul_left, real_inner_smul_right,
− real_inner_comm y (normalize _), real_inner_self_eq_norm_sq, hy, angle_comm z y,
122 real_inner_comm y (normalize ℝ _), real_inner_self_eq_norm_sq, hy, angle_comm z y,
123 inner_normalize_ortho] at H1
124 norm_num at H1
125 rw [mul_comm (Real.cos (angle y z))] at H1
126 rw [Real.cos_add, ← inner_eq_cos_angle_of_norm_eq_one hx hz, H1]
− have H2 : -1 ≤ ⟪normalize (ortho y x), normalize (ortho y z)⟫ := by
127 have H2 : -1 ≤ ⟪normalize ℝ (ortho y x), normalize ℝ (ortho y z)⟫ := by
128 by_cases H3 : ortho y x = 0
129 · simp [*]
130 by_cases H4 : ortho y z = 0
131 · simp [*]
− exact neg_one_le_real_inner_of_norm_eq_one
− (norm_normalize_eq_one_iff.mpr H3) (norm_normalize_eq_one_iff.mpr H4)
132 exact neg_one_le_real_inner_of_norm_eq_one (norm_normalize ℝ H3) (norm_normalize ℝ H4)
133 have := sin_angle_nonneg x y; have := sin_angle_nonneg y z
134 grw [← H2]
135 apply le_of_eq
lemma angle_expression_of_angle_eq_angle_sum :
lemma angle_expression_of_angle_eq_angle_sum body changedL164–184
164 have H6 : ⟪x, z⟫ = ⟪x, z⟫ := rfl
165 nth_rw 2 [angle_le_angle_add_angle_aux hx hy, angle_le_angle_add_angle_aux hz hy] at H6
166 simp only [inner_add_left, inner_add_right, real_inner_smul_left, real_inner_smul_right,
− real_inner_comm y (normalize _), real_inner_self_eq_norm_sq, hy, angle_comm z y,
167 real_inner_comm y (normalize ℝ _), real_inner_self_eq_norm_sq, hy, angle_comm z y,
168 inner_normalize_ortho] at H6
169 norm_num at H6
170 rw [inner_eq_cos_angle_of_norm_eq_one hx hz, H0, Real.cos_add] at H6
171 ring_nf at H6
172 have Hw : Real.sin (angle x y) * Real.sin (angle y z) ≠ 0 := by
173 grind [sin_eq_zero_iff_angle_eq_zero_or_angle_eq_pi]
− have H8 : ⟪normalize (ortho y x), normalize (ortho y z)⟫ = - 1 := by
174 have H8 : ⟪normalize ℝ (ortho y x), normalize ℝ (ortho y z)⟫ = - 1 := by
175 grind
176 have H9 : ortho y x ≠ 0 := by
177 grind [ortho_ne_zero_of_not_collinear, angle_comm]
178 have H10 : ortho y z ≠ 0 := by
179 grind [ortho_ne_zero_of_not_collinear]
− have H11 : ‖normalize (ortho y x)‖ = 1 := norm_normalize_eq_one_iff.mpr H9
− have H12 : ‖normalize (ortho y z)‖ = 1 := norm_normalize_eq_one_iff.mpr H10
180 have H11 : ‖normalize ℝ (ortho y x)‖ = 1 := norm_normalize _ H9
181 have H12 : ‖normalize ℝ (ortho y z)‖ = 1 := norm_normalize _ H10
182 rw [inner_eq_neg_one_iff_of_norm_eq_one H11 H12] at H8
183 nth_rw 2 [angle_le_angle_add_angle_aux hx hy]
184 nth_rw 3 [angle_le_angle_add_angle_aux hz hy]
public theorem angle_le_angle_add_angle (x y z : V) :
theorem angle_le_angle_add_angle body changedL196–203
196 · simpa [hy] using angle_le_pi x z
197 by_cases hz : z = 0
198 · simpa [hz] using angle_nonneg x y
− simpa using angle_le_angle_add_angle_of_norm_eq_one (norm_normalize_eq_one_iff.mpr hx)
− (norm_normalize_eq_one_iff.mpr hy) (norm_normalize_eq_one_iff.mpr hz)
199 simpa using angle_le_angle_add_angle_of_norm_eq_one (norm_normalize ℝ hx)
200 (norm_normalize ℝ hy) (norm_normalize ℝ hz)
202/-- The triangle inequality is an equality if the middle vector is a nonnegative linear combination
203of the other two vectors. See `angle_add_angle_eq_pi_of_angle_eq_pi` for the other equality case. -/
public theorem angle_eq_angle_add_angle_iff {x y z : V} (hy : y ≠ 0) :
theorem angle_eq_angle_add_angle_iff body changedL263–270
263 grind [sin_angle_nonneg, norm_nonneg, div_nonneg_iff, mul_nonneg_iff]
264 have hnonzero : (⟨Real.sin (angle x z) / ‖y‖, hnneg₃⟩ : ℝ≥0) ≠ 0 := by
265 simp; grind
− have h₁ := angle_expression_of_angle_eq_angle_sum (norm_normalize_eq_one_iff.mpr hx)
− (norm_normalize_eq_one_iff.mpr hy) (norm_normalize_eq_one_iff.mpr hz)
266 have h₁ := angle_expression_of_angle_eq_angle_sum (norm_normalize ℝ hx)
267 (norm_normalize ℝ hy) (norm_normalize ℝ hz)
268 simp only [angle_normalize_right, angle_normalize_left] at h₁
269 have h₂ := h₁ hxz₁ h
270 have h₃ : (⟨_, hnneg₃⟩ : ℝ≥0) • y = (⟨_, hnneg₁⟩ : ℝ≥0) • x + (⟨_, hnneg₂⟩ : ℝ≥0) • z := by

Mathlib/Geometry/Euclidean/SignedDist.lean +16 −17

section signedDist
42set_option backward.privateInPublic true in
def signedDistLinear changedL43–47
43/-- Auxiliary definition for `signedDist`. It is the underlying linear map of `signedDist`. -/
44private noncomputable def signedDistLinear (v : V) : V →ₗ[ℝ] P →ᴬ[ℝ] ℝ where
− toFun w := .const ℝ P ⟪-normalize v, w⟫
45 toFun w := .const ℝ P ⟪-normalize ℝ v, w⟫
46 map_add' x y := by ext; simp [inner_add_right]
47 map_smul' r x := by ext; simp [inner_smul_right]
lemma signedDistLinear_apply changedL49–50
49private lemma signedDistLinear_apply (v w : V) :
− signedDistLinear v w = .const ℝ P ⟪-normalize v, w⟫ := rfl
50 signedDistLinear v w = .const ℝ P ⟪-normalize ℝ v, w⟫ := rfl
52set_option backward.privateInPublic true in
53set_option backward.privateInPublic.warn false in
In the degenerate case `v = 0`, it returns `0`.
59TODO: once we have a topology on `P →ᴬ[ℝ] ℝ`, the type should be `P →ᴬ[ℝ] P →ᴬ[ℝ] ℝ`.
60-/
def signedDist changedL61–65
61noncomputable def signedDist (v : V) : P →ᵃ[ℝ] P →ᴬ[ℝ] ℝ where
− toFun p := (innerSL ℝ (normalize v)).toContinuousAffineMap.comp
62 toFun p := (innerSL ℝ (normalize ℝ v)).toContinuousAffineMap.comp
63 (ContinuousAffineMap.id ℝ P -ᵥ .const ℝ P p)
64 linear := signedDistLinear v
65 map_vadd' p v' := by
variable (v w : V) (p q r : P)
72-- Lemmas about the definition of `signedDist`
lemma signedDist_apply changedL74–76
−lemma signedDist_apply : signedDist v p = (innerSL ℝ (normalize v)).toContinuousAffineMap.comp
74lemma signedDist_apply : signedDist v p = (innerSL ℝ (normalize ℝ v)).toContinuousAffineMap.comp
75 (ContinuousAffineMap.id ℝ P -ᵥ .const ℝ P p) :=
76 rfl
lemma signedDist_apply_apply changedL78–79
−lemma signedDist_apply_apply : signedDist v p q = ⟪normalize v, q -ᵥ p⟫ :=
78lemma signedDist_apply_apply : signedDist v p q = ⟪normalize ℝ v, q -ᵥ p⟫ :=
79 rfl
lemma signedDist_apply_linear changedL81–83
−lemma signedDist_apply_linear : (signedDist v p).linear = innerₗ V (normalize v) := by
− change (innerₗ V (normalize v)).comp (LinearMap.id - 0) = _
81lemma signedDist_apply_linear : (signedDist v p).linear = innerₗ V (normalize ℝ v) := by
82 change (innerₗ V (normalize ℝ v)).comp (LinearMap.id - 0) = _
83 simp
lemma signedDist_apply_linear_apply changedL85–86
−lemma signedDist_apply_linear_apply : (signedDist v p).linear w = ⟪normalize v, w⟫ := by
85lemma signedDist_apply_linear_apply : (signedDist v p).linear w = ⟪normalize ℝ v, w⟫ := by
86 simp [signedDist_apply_linear]
lemma signedDist_linear_apply changedL88–89
−lemma signedDist_linear_apply : (signedDist v).linear w = .const ℝ P ⟪-normalize v, w⟫ :=
88lemma signedDist_linear_apply : (signedDist v).linear w = .const ℝ P ⟪-normalize ℝ v, w⟫ :=
89 rfl
lemma signedDist_linear_apply_apply changedL91–92
−lemma signedDist_linear_apply_apply : (signedDist v).linear w p = ⟪-normalize v, w⟫ :=
91lemma signedDist_linear_apply_apply : (signedDist v).linear w p = ⟪-normalize ℝ v, w⟫ :=
92 rfl
94-- Lemmas about the vector argument of `signedDist`
lemma signedDist_smul changedL96–97
96lemma signedDist_smul (r : ℝ) : signedDist (r • v) p q = SignType.sign r * signedDist v p q := by
− simp only [signedDist_apply_apply]
− rw [normalize_smul, real_inner_smul_left]
97 simp [signedDist_apply_apply, ← real_inner_smul_left, ← normalize_real_smul]
99lemma signedDist_smul_of_pos {r : ℝ} (h : 0 < r) : signedDist (r • v) p q = signedDist v p q := by
100 simp [signedDist_smul, h]
lemma signedDist_triangle_right : signedDist v p r - signedDist v q r = signedDi
137-- Lemmas about offsetting the point arguments of `signedDist` (with `+ᵥ` or `-ᵥ`)
lemma signedDist_vadd_left changedL139–140
−lemma signedDist_vadd_left : signedDist v (w +ᵥ p) q = -⟪normalize v, w⟫ + signedDist v p q := by
139lemma signedDist_vadd_left : signedDist v (w +ᵥ p) q = -⟪normalize ℝ v, w⟫ + signedDist v p q := by
140 simp [signedDist_linear_apply_apply]
lemma signedDist_vadd_right changedL142–143
−lemma signedDist_vadd_right : signedDist v p (w +ᵥ q) = ⟪normalize v, w⟫ + signedDist v p q := by
142lemma signedDist_vadd_right : signedDist v p (w +ᵥ q) = ⟪normalize ℝ v, w⟫ + signedDist v p q := by
143 simp [signedDist_apply_linear_apply]
145-- TODO: find a better name for these 2 lemmas
lemma abs_signedDist_le_dist : |signedDist v p q| ≤ dist p q := by
lemma abs_signedDist_le_dist body changedL172–176
172 by_cases h : v = 0
173 · simp [h]
174 · grw [abs_real_inner_le_norm]
− simp [norm_normalize h, dist_eq_norm_vsub']
175 simp [norm_normalize ℝ h, dist_eq_norm_vsub']
177lemma signedDist_le_dist : signedDist v p q ≤ dist p q :=
178 le_trans (le_abs_self _) (abs_signedDist_le_dist _ _ _)
lemma abs_signedDist_eq_dist_iff_vsub_mem_span :
lemma abs_signedDist_eq_dist_iff_vsub_mem_span body changedL181–187
181 |signedDist v p q| = dist p q ↔ q -ᵥ p ∈ ℝ ∙ v := by
182 rw [Submodule.mem_span_singleton]
183 rw [signedDist_apply_apply, dist_eq_norm_vsub', NormedSpace.normalize, real_inner_smul_left,
− abs_mul, abs_inv, abs_norm]
184 abs_mul, abs_inv, RCLike.ofReal_real_eq_id, id_eq, abs_norm]
185 by_cases h : v = 0
186 · simp [h, eq_comm (a := (0 : ℝ)), eq_comm (a := (0 : V))]
187 rw [inv_mul_eq_iff_eq_mul₀ (by positivity)]
lemma signedDist_eq_dist_iff_vsub_mem_span : signedDist v p q = dist p q ↔ q -
lemma signedDist_eq_dist_iff_vsub_mem_span body changedL194–200
194 rw [signedDist_apply_apply, dist_eq_norm_vsub', NormedSpace.normalize, real_inner_smul_left]
195 by_cases h : v = 0
196 · simp [h, eq_comm (a := (0 : ℝ)), eq_comm (a := (0 : V))]
− rw [inv_mul_eq_iff_eq_mul₀ (by positivity)]
197 rw [inv_mul_eq_iff_eq_mul₀ (by positivity), RCLike.ofReal_real_eq_id, id_eq]
198 rw [inner_eq_norm_mul_iff_real]
199 simp only [smul_def]
200 refine ⟨fun h => ?_, fun ⟨c, h⟩ => ?_⟩
0/41 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.