Skip to content

Commit 376f05e

Browse files
committed
chore: make AffineSubspace.toAddTorsor and AffineSubspace.nonempty_map instances (#28467)
The loops with the `Nonempty` instances are no longer an issue in Lean 4.
1 parent 0414281 commit 376f05e

File tree

8 files changed

+3
-34
lines changed

8 files changed

+3
-34
lines changed

Mathlib/Analysis/Convex/Intrinsic.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ variable [NormedField 𝕜] [SeminormedAddCommGroup V] [SeminormedAddCommGroup W
215215
[NormedSpace 𝕜 W] [MetricSpace P] [PseudoMetricSpace Q] [NormedAddTorsor V P]
216216
[NormedAddTorsor W Q]
217217

218-
attribute [local instance] AffineSubspace.toNormedAddTorsor AffineSubspace.nonempty_map
219-
220218
@[simp]
221219
theorem image_intrinsicInterior (φ : P →ᵃⁱ[𝕜] Q) (s : Set P) :
222220
intrinsicInterior 𝕜 (φ '' s) = φ '' intrinsicInterior 𝕜 s := by

Mathlib/Analysis/Normed/Affine/Isometry.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,6 @@ theorem AffineMap.isOpenMap_linear_iff {f : P →ᵃ[𝕜] P₂} : IsOpenMap f.l
767767
rw [this]
768768
simp only [Homeomorph.comp_isOpenMap_iff, Homeomorph.comp_isOpenMap_iff']
769769

770-
attribute [local instance] AffineSubspace.nonempty_map
771-
772770
namespace AffineSubspace
773771

774772
/-- An affine subspace is isomorphic to its image under an injective affine map.

Mathlib/Geometry/Euclidean/Circumcenter.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@ theorem circumcenter_reindex {m n : ℕ} (s : Simplex ℝ P m) (e : Fin (m + 1)
335335
theorem circumradius_reindex {m n : ℕ} (s : Simplex ℝ P m) (e : Fin (m + 1) ≃ Fin (n + 1)) :
336336
(s.reindex e).circumradius = s.circumradius := by simp_rw [circumradius, circumsphere_reindex]
337337

338-
attribute [local instance] AffineSubspace.toAddTorsor
339-
340338
theorem dist_circumcenter_sq_eq_sq_sub_circumradius {n : ℕ} {r : ℝ} (s : Simplex ℝ P n) {p₁ : P}
341339
(h₁ : ∀ i : Fin (n + 1), dist (s.points i) p₁ = r)
342340
(h₁' : ↑(s.orthogonalProjectionSpan p₁) = s.circumcenter)

Mathlib/Geometry/Euclidean/Projection.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ theorem orthogonalProjectionFn_vsub_mem_direction_orthogonal {s : AffineSubspace
9292
direction_mk' p s.directionᗮ ▸
9393
vsub_mem_direction (orthogonalProjectionFn_mem_orthogonal p) (self_mem_mk' _ _)
9494

95-
attribute [local instance] AffineSubspace.toAddTorsor
96-
9795
/-- Auxiliary definition for setting up the orthogonal projection. This one is a bundled affine
9896
map; the final `orthogonalProjection` is a continuous affine map. -/
9997
nonrec def orthogonalProjectionAux (s : AffineSubspace ℝ P) [Nonempty s]

Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Basic.lean

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ theorem vsub_left_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p
5959
rw [mem_direction_iff_eq_vsub_left hp]
6060
simp
6161

62-
-- See note [reducible non instances]
63-
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
64-
abbrev toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
62+
instance toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
6563
vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2
6664
zero_vadd := fun a => by
6765
ext
@@ -77,8 +75,6 @@ abbrev toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction
7775
ext
7876
apply AddTorsor.vadd_vsub'
7977

80-
attribute [local instance] toAddTorsor
81-
8278
@[simp, norm_cast]
8379
theorem coe_vsub (s : AffineSubspace k P) [Nonempty s] (a b : s) : ↑(a -ᵥ b) = (a : P) -ᵥ (b : P) :=
8480
rfl
@@ -151,8 +147,6 @@ theorem preimage_coe_affineSpan_singleton (x : P) :
151147

152148
variable (P)
153149

154-
attribute [local instance] toAddTorsor
155-
156150
/-- The top affine subspace is linearly equivalent to the affine space.
157151
This is the affine version of `Submodule.topEquiv`. -/
158152
@[simps! linear apply symm_apply_coe]
@@ -312,10 +306,6 @@ theorem vectorSpan_range_eq_span_range_vsub_right_ne (p : ι → P) (i₀ : ι)
312306

313307
variable {k}
314308

315-
section WithLocalInstance
316-
317-
attribute [local instance] AffineSubspace.toAddTorsor
318-
319309
/-- A set, considered as a subset of its spanned affine subspace, spans the whole subspace. -/
320310
@[simp]
321311
theorem affineSpan_coe_preimage_eq_top (A : Set P) [Nonempty A] :
@@ -326,8 +316,6 @@ theorem affineSpan_coe_preimage_eq_top (A : Set P) [Nonempty A] :
326316
· exact subset_affineSpan _ _ hy
327317
· exact AffineSubspace.smul_vsub_vadd_mem _ _
328318

329-
end WithLocalInstance
330-
331319
/-- Suppose a set of vectors spans `V`. Then a point `p`, together with those vectors added to `p`,
332320
spans `P`. -/
333321
theorem affineSpan_singleton_union_vadd_eq_top_of_span_eq_top {s : Set V} (p : P)
@@ -575,8 +563,6 @@ theorem map_mono {s₁ s₂ : AffineSubspace k P₁} (h : s₁ ≤ s₂) : s₁.
575563
section inclusion
576564
variable {S₁ S₂ : AffineSubspace k P₁} [Nonempty S₁]
577565

578-
attribute [local instance] AffineSubspace.toAddTorsor
579-
580566
/-- Affine map from a smaller to a larger subspace of the same space.
581567
582568
This is the affine version of `Submodule.inclusion`. -/
@@ -618,8 +604,6 @@ namespace AffineEquiv
618604
section ofEq
619605
variable (S₁ S₂ : AffineSubspace k P₁) [Nonempty S₁] [Nonempty S₂]
620606

621-
attribute [local instance] AffineSubspace.toAddTorsor
622-
623607
/-- Affine equivalence between two equal affine subspace.
624608
625609
This is the affine version of `LinearEquiv.ofEq`. -/

Mathlib/LinearAlgebra/AffineSpace/Restrict.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ This file defines restrictions of affine maps.
2727
variable {k V₁ P₁ V₂ P₂ : Type*} [Ring k] [AddCommGroup V₁] [AddCommGroup V₂] [Module k V₁]
2828
[Module k V₂] [AddTorsor V₁ P₁] [AddTorsor V₂ P₂]
2929

30-
-- not an instance because it loops with `Nonempty`
31-
theorem AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E] {φ : P₁ →ᵃ[k] P₂} :
32-
Nonempty (E.map φ) := by
30+
instance AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E]
31+
{φ : P₁ →ᵃ[k] P₂} : Nonempty (E.map φ) := by
3332
obtain ⟨x, hx⟩ := id Ene
3433
exact ⟨⟨φ x, AffineSubspace.mem_map.mpr ⟨x, hx, rfl⟩⟩⟩
3534

36-
attribute [local instance] AffineSubspace.nonempty_map AffineSubspace.toAddTorsor
37-
3835
/-- Restrict domain and codomain of an affine map to the given subspaces. -/
3936
def AffineMap.restrict (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂}
4037
[Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : E →ᵃ[k] F := by

Mathlib/LinearAlgebra/AffineSpace/Simplex/Basic.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ theorem reindex_map {m n : ℕ} (s : Simplex k P m) (e : Fin (m + 1) ≃ Fin (n
235235
rfl
236236

237237
section restrict
238-
attribute [local instance] AffineSubspace.toAddTorsor
239238

240239
/-- Restrict an affine simplex to an affine subspace that contains it. -/
241240
@[simps]
@@ -271,7 +270,6 @@ theorem restrict_map_restrict
271270
(S₁ : AffineSubspace k P) (S₂ : AffineSubspace k P₂)
272271
(hS₁ : affineSpan k (Set.range s.points) ≤ S₁) (hfS : AffineSubspace.map f S₁ ≤ S₂) :
273272
letI := Nonempty.map (AffineSubspace.inclusion hS₁) inferInstance
274-
letI : Nonempty (S₁.map f) := AffineSubspace.nonempty_map
275273
letI := Nonempty.map (AffineSubspace.inclusion hfS) inferInstance
276274
(s.restrict S₁ hS₁).map (f.restrict hfS) (AffineMap.restrict.injective hf _) =
277275
(s.map f hf).restrict S₂ (

Mathlib/Topology/Algebra/AffineSubspace.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ namespace AffineSubspace
2424
variable {R V P : Type*} [Ring R] [AddCommGroup V] [Module R V] [TopologicalSpace P]
2525
[AddTorsor V P]
2626

27-
attribute [local instance] toAddTorsor
28-
2927
/-- Embedding of an affine subspace to the ambient space, as a continuous affine map. -/
3028
def subtypeA (s : AffineSubspace R P) [Nonempty s] : s →ᴬ[R] P where
3129
toAffineMap := s.subtype

0 commit comments

Comments
 (0)