Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 027ff1e

Browse files
committed
chore(geometry/euclidean/sphere/basic): generalize typeclasses (#18605)
`cospherical_empty` asks for `P` to be a real inner product space when all it needs is `nonempty P`. The motivation for this PR is that it fixes a linter error in #18583; lean complains that we are carrying around the type `V` for no reason. The alternative here would be to force all these typeclass arguments to be present in the constructor for `euclidean_space.sphere` and use `no_lint unused_arguments`
1 parent 9328723 commit 027ff1e

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

src/geometry/euclidean/sphere/basic.lean

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ open_locale real_inner_product_space
2929

3030
namespace euclidean_geometry
3131

32-
variables {V : Type*} (P : Type*) [inner_product_space ℝ V] [metric_space P] [normed_add_torsor V P]
32+
variables {V : Type*} (P : Type*)
3333

3434
open finite_dimensional
3535

3636
/-- A `sphere P` bundles a `center` and `radius`. This definition does not require the radius to
3737
be positive; that should be given as a hypothesis to lemmas that require it. -/
38-
@[ext] structure sphere :=
38+
@[ext] structure sphere [metric_space P] :=
3939
(center : P)
4040
(radius : ℝ)
4141

4242
variables {P}
4343

44+
section metric_space
45+
variables [metric_space P]
46+
4447
instance [nonempty P] : nonempty (sphere P) := ⟨⟨classical.arbitrary P, 0⟩⟩
4548

4649
instance : has_coe (sphere P) (set P) := ⟨λ s, metric.sphere s.center s.radius⟩
@@ -132,16 +135,9 @@ begin
132135
exact ⟨c, r, λ p hp, hcr p (hs hp)⟩
133136
end
134137

135-
include V
136-
137138
/-- The empty set is cospherical. -/
138-
lemma cospherical_empty : cospherical (∅ : set P) :=
139-
begin
140-
use add_torsor.nonempty.some,
141-
simp,
142-
end
143-
144-
omit V
139+
lemma cospherical_empty [nonempty P] : cospherical (∅ : set P) :=
140+
let ⟨p⟩ := ‹nonempty P› in ⟨p, 0, λ p, false.elim⟩
145141

146142
/-- A single point is cospherical. -/
147143
lemma cospherical_singleton (p : P) : cospherical ({p} : set P) :=
@@ -150,23 +146,47 @@ begin
150146
simp
151147
end
152148

149+
end metric_space
150+
151+
section normed_space
152+
variables [normed_add_comm_group V] [normed_space ℝ V] [metric_space P] [normed_add_torsor V P]
153153
include V
154154

155155
/-- Two points are cospherical. -/
156156
lemma cospherical_pair (p₁ p₂ : P) : cospherical ({p₁, p₂} : set P) :=
157-
begin
158-
use [(2⁻¹ : ℝ) • (p₂ -ᵥ p₁) +ᵥ p₁, (2⁻¹ : ℝ) * (dist p₂ p₁)],
159-
intro p,
160-
rw [set.mem_insert_iff, set.mem_singleton_iff],
161-
rintro ⟨_|_⟩,
162-
{ rw [dist_eq_norm_vsub V p₁, vsub_vadd_eq_vsub_sub, vsub_self, zero_sub, norm_neg, norm_smul,
163-
dist_eq_norm_vsub V p₂],
164-
simp },
165-
{ rw [H, dist_eq_norm_vsub V p₂, vsub_vadd_eq_vsub_sub, dist_eq_norm_vsub V p₂],
166-
conv_lhs { congr, congr, rw ←one_smul ℝ (p₂ -ᵥ p₁ : V) },
167-
rw [←sub_smul, norm_smul],
168-
norm_num }
169-
end
157+
⟨midpoint ℝ p₁ p₂, ‖(2 : ℝ)‖⁻¹ * dist p₁ p₂, begin
158+
rintros p (rfl | rfl | _),
159+
{ rw [dist_comm, dist_midpoint_left] },
160+
{ rw [dist_comm, dist_midpoint_right] }
161+
end
162+
163+
/-- A set of points is concyclic if it is cospherical and coplanar. (Most results are stated
164+
directly in terms of `cospherical` instead of using `concyclic`.) -/
165+
structure concyclic (ps : set P) : Prop :=
166+
(cospherical : cospherical ps)
167+
(coplanar : coplanar ℝ ps)
168+
169+
/-- A subset of a concyclic set is concyclic. -/
170+
lemma concyclic.subset {ps₁ ps₂ : set P} (hs : ps₁ ⊆ ps₂) (h : concyclic ps₂) : concyclic ps₁ :=
171+
⟨h.1.subset hs, h.2.subset hs⟩
172+
173+
/-- The empty set is concyclic. -/
174+
lemma concyclic_empty : concyclic (∅ : set P) :=
175+
⟨cospherical_empty, coplanar_empty ℝ P⟩
176+
177+
/-- A single point is concyclic. -/
178+
lemma concyclic_singleton (p : P) : concyclic ({p} : set P) :=
179+
⟨cospherical_singleton p, coplanar_singleton ℝ p⟩
180+
181+
/-- Two points are concyclic. -/
182+
lemma concyclic_pair (p₁ p₂ : P) : concyclic ({p₁, p₂} : set P) :=
183+
⟨cospherical_pair p₁ p₂, coplanar_pair ℝ p₁ p₂⟩
184+
185+
end normed_space
186+
187+
section euclidean_space
188+
variables [inner_product_space ℝ V] [metric_space P] [normed_add_torsor V P]
189+
include V
170190

171191
/-- Any three points in a cospherical set are affinely independent. -/
172192
lemma cospherical.affine_independent {s : set P} (hs : cospherical s) {p : fin 3 → P}
@@ -324,26 +344,6 @@ lemma sbtw_of_collinear_of_dist_center_lt_radius {s : sphere P} {p₁ p₂ p₃
324344
(hp₃ : p₃ ∈ s) (hp₁p₃ : p₁ ≠ p₃) : sbtw ℝ p₁ p₂ p₃ :=
325345
h.sbtw_of_dist_eq_of_dist_lt hp₁ hp₂ hp₃ hp₁p₃
326346

327-
/-- A set of points is concyclic if it is cospherical and coplanar. (Most results are stated
328-
directly in terms of `cospherical` instead of using `concyclic`.) -/
329-
structure concyclic (ps : set P) : Prop :=
330-
(cospherical : cospherical ps)
331-
(coplanar : coplanar ℝ ps)
332-
333-
/-- A subset of a concyclic set is concyclic. -/
334-
lemma concyclic.subset {ps₁ ps₂ : set P} (hs : ps₁ ⊆ ps₂) (h : concyclic ps₂) : concyclic ps₁ :=
335-
⟨h.1.subset hs, h.2.subset hs⟩
336-
337-
/-- The empty set is concyclic. -/
338-
lemma concyclic_empty : concyclic (∅ : set P) :=
339-
⟨cospherical_empty, coplanar_empty ℝ P⟩
340-
341-
/-- A single point is concyclic. -/
342-
lemma concyclic_singleton (p : P) : concyclic ({p} : set P) :=
343-
⟨cospherical_singleton p, coplanar_singleton ℝ p⟩
344-
345-
/-- Two points are concyclic. -/
346-
lemma concyclic_pair (p₁ p₂ : P) : concyclic ({p₁, p₂} : set P) :=
347-
⟨cospherical_pair p₁ p₂, coplanar_pair ℝ p₁ p₂⟩
347+
end euclidean_space
348348

349349
end euclidean_geometry

0 commit comments

Comments
 (0)