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

← queue

#47025 chore(LinearAlgebra/AffineSpace): deprecate spanPoints

t-algebra CI success

+93 −94 · 1 file · 1 commit · head 8f63fdb · updated today · Files changed on GitHub

PR description

As the TODO suggested.


Conversation on GitHub 1
github-actions[bot] · comment · 2026-12-06
PR summary 8f63fdbde0
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 (regex)

</summary>

+ AffineSubspace.spanPoints_subset_coe_of_subset_coe - spanPoints_subset_coe_of_subset_coe <details> <summary>You can run this locally as follows</summary>

## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

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

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

</details>

The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.

</details>

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 8f63fdb).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt. No changes to weak technical debt.

Current commit 8f63fdbde0 Reference commit c2eaf80729

This script lives in the undefined repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py 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).

Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Defs.lean +93 −94

This file defines affine subspaces (over modules) and the affine span of a set o
23 in an `AffineSubspace`. There are various lemmas relating to the set of vectors in the
24 `direction`, and relating the lattice structure on affine subspaces to that on their directions.
25* `affineSpan` gives the affine subspace spanned by a set of points, with `vectorSpan` giving its
− direction. The `affineSpan` is defined in terms of `spanPoints`, which gives an explicit
− description of the points contained in the affine span; `spanPoints` itself should generally only
− be used when that description is required, with `affineSpan` being the main definition for other
− purposes. Two other descriptions of the affine span are proved equivalent: it is the `sInf` of
− affine subspaces containing the points, and (if `[Nontrivial k]`) it contains exactly those points
− that are affine combinations of points in the given set.
26 direction. `mem_affineSpan_iff_exists` gives an explicit description of the points contained in
27 the affine span. Two other descriptions of the affine span are proved equivalent: it is the `sInf`
28 of affine subspaces containing the points, and (if `[Nontrivial k]`) it contains exactly those
29 points that are affine combinations of points in the given set.
31## Implementation notes
topology are defined elsewhere; see `Analysis.Normed.Affine.AddTorsor` and
43* https://en.wikipedia.org/wiki/Affine_space
44* https://en.wikipedia.org/wiki/Principal_homogeneous_space
−
−## TODO
−
−* Delete `spanPoints`
45-/
47@[expose] public section
lemma vectorSpan_eq_bot_iff_subsingleton {s : Set P} : vectorSpan k s = ⊥ ↔
100 have hpq' := vsub_mem_vectorSpan k hp hq
101 simp_all
def spanPoints removedLundefined–undefined
−/-- The points in the affine span of a (possibly empty) set of points. Use `affineSpan` instead to
−get an `AffineSubspace k P`. -/
−def spanPoints (s : Set P) : Set P :=
− { p | ∃ p₁ ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p₁ }
theorem mem_spanPoints removedLundefined–undefined
−/-- A point in a set is in its affine span. -/
−theorem mem_spanPoints (p : P) (s : Set P) : p ∈ s → p ∈ spanPoints k s
− | hp => ⟨p, hp, 0, Submodule.zero_mem _, (zero_vadd V p).symm⟩
theorem subset_spanPoints removedLundefined–undefined
−/-- A set is contained in its `spanPoints`. -/
−theorem subset_spanPoints (s : Set P) : s ⊆ spanPoints k s := fun p => mem_spanPoints k p s
theorem spanPoints_nonempty removedLundefined–undefined
−/-- The `spanPoints` of a set is nonempty if and only if that set is. -/
−@[simp]
−theorem spanPoints_nonempty (s : Set P) : (spanPoints k s).Nonempty ↔ s.Nonempty := by
− constructor
− · contrapose
− rw [Set.not_nonempty_iff_eq_empty, Set.not_nonempty_iff_eq_empty]
− intro h
− simp [h, spanPoints]
− · exact fun h => h.mono (subset_spanPoints _ _)
theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan removedLundefined–undefined
−/-- Adding a point in the affine span and a vector in the spanning submodule produces a point in the
−affine span. -/
−theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan {s : Set P} {p : P} {v : V}
− (hp : p ∈ spanPoints k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ spanPoints k s := by
− rcases hp with ⟨p₂, ⟨hp₂, ⟨v₂, ⟨hv₂, hv₂p⟩⟩⟩⟩
− rw [hv₂p, vadd_vadd]
− exact ⟨p₂, hp₂, v + v₂, (vectorSpan k s).add_mem hv hv₂, rfl⟩
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints removedLundefined–undefined
−/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
−theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p₁ p₂ : P}
− (hp₁ : p₁ ∈ spanPoints k s) (hp₂ : p₂ ∈ spanPoints k s) : p₁ -ᵥ p₂ ∈ vectorSpan k s := by
− rcases hp₁ with ⟨p₁a, ⟨hp₁a, ⟨v₁, ⟨hv₁, hv₁p⟩⟩⟩⟩
− rcases hp₂ with ⟨p₂a, ⟨hp₂a, ⟨v₂, ⟨hv₂, hv₂p⟩⟩⟩⟩
− rw [hv₁p, hv₂p, vsub_vadd_eq_vsub_sub (v₁ +ᵥ p₁a), vadd_vsub_assoc, add_comm, add_sub_assoc]
− have hv₁v₂ : v₁ - v₂ ∈ vectorSpan k s := (vectorSpan k s).sub_mem hv₁ hv₂
− refine (vectorSpan k s).add_mem ?_ hv₁v₂
− exact vsub_mem_vectorSpan k hp₁a hp₂a
103end
105/-- An `AffineSubspace k P` is a subset of an `AffineSpace V P` that, if not empty, has an affine
yields the original subspace. -/
457theorem mk'_eq {s : AffineSubspace k P} {p : P} (hp : p ∈ s) : mk' p s.direction = s :=
458 ext_of_direction_eq (direction_mk' p s.direction) ⟨p, Set.mem_inter (self_mem_mk' _ _) hp⟩
theorem spanPoints_subset_coe_of_subset_coe removedLundefined–undefined
−/-- If an affine subspace contains a set of points, it contains the `spanPoints` of that set. -/
−theorem spanPoints_subset_coe_of_subset_coe {s : Set P} {s₁ : AffineSubspace k P} (h : s ⊆ s₁) :
− spanPoints k s ⊆ s₁ := by
− rintro p ⟨p₁, hp₁, v, hv, hp⟩
− rw [hp]
− have hp₁s₁ : p₁ ∈ (s₁ : Set P) := Set.mem_of_mem_of_subset hp₁ h
− refine vadd_mem_of_mem_direction ?_ hp₁s₁
− have hs : vectorSpan k s ≤ s₁.direction := vectorSpan_mono k h
− rw [le_iff_mem_imp_mem] at hs
− rw [← SetLike.mem_coe]
− exact Set.mem_of_mem_of_subset hv hs
460end AffineSubspace
462namespace Submodule
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k
def affineSpan changedL477–479
477/-- The affine span of a set of points is the smallest affine subspace containing those points.
478(Actually defined here in terms of spans in modules.) -/
479def affineSpan (s : Set P) : AffineSubspace k P where
− carrier := spanPoints k s
− smul_vsub_vadd_mem' c _ _ _ hp₁ hp₂ hp₃ :=
− vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan k hp₃
− ((vectorSpan k s).smul_mem c
− (vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints k hp₁ hp₂))
theorem coe_affineSpan newL480–489
−/-- The affine span, converted to a set, is `spanPoints`. -/
−theorem coe_affineSpan (s : Set P) : (affineSpan k s : Set P) = spanPoints k s :=
− rfl
480 carrier := { p | ∃ p₁ ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p₁ }
481 smul_vsub_vadd_mem' c _ _ _ hp₁ hp₂ hp₃ := by
482 obtain ⟨p₁, hp₁, v₁, hv₁, rfl⟩ := hp₁
483 obtain ⟨p₂, hp₂, v₂, hv₂, rfl⟩ := hp₂
484 obtain ⟨p₃, hp₃, v₃, hv₃, rfl⟩ := hp₃
485 refine ⟨p₃, hp₃, c • ((v₁ +ᵥ p₁) -ᵥ (v₂ +ᵥ p₂)) + v₃,
486 (vectorSpan k s).add_mem ((vectorSpan k s).smul_mem c ?_) hv₃, vadd_vadd _ _ _⟩
487 rw [vsub_vadd_eq_vsub_sub, vadd_vsub_assoc]
488 exact (vectorSpan k s).sub_mem
489 ((vectorSpan k s).add_mem hv₁ (vsub_mem_vectorSpan k hp₁ hp₂)) hv₂
491/-- The condition for a point to be in the affine span, in terms of `vectorSpan`. -/
492lemma mem_affineSpan_iff_exists {p : P} {s : Set P} : p ∈ affineSpan k s ↔
493 ∃ p₁ ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p₁ :=
494 Iff.rfl
theorem mem_affineSpan newL496–498
496/-- A point in a set is in its affine span. -/
497theorem mem_affineSpan {p : P} {s : Set P} (hp : p ∈ s) : p ∈ affineSpan k s :=
498 ⟨p, hp, 0, Submodule.zero_mem _, (zero_vadd V p).symm⟩
theorem subset_affineSpan changedL500–502
500/-- A set is contained in its affine span. -/
501theorem subset_affineSpan (s : Set P) : s ⊆ affineSpan k s :=
− subset_spanPoints k s
502 fun _ hp ↦ mem_affineSpan k hp
504/-- The direction of the affine span is the `vectorSpan`. -/
505theorem direction_affineSpan (s : Set P) : (affineSpan k s).direction = vectorSpan k s := by
theorem direction_affineSpan (s : Set P) : (affineSpan k s).direction = vectorSp
theorem direction_affineSpan body changedL510–512
510 rw [hp₁, hp₃, vsub_vadd_eq_vsub_sub, vadd_vsub_assoc]
511 exact
512 (vectorSpan k s).sub_mem ((vectorSpan k s).add_mem hv₁ (vsub_mem_vectorSpan k hp₂ hp₄)) hv₂
− · exact vectorSpan_mono k (subset_spanPoints k s)
−
theorem mem_affineSpan newL513–513
−/-- A point in a set is in its affine span. -/
−theorem mem_affineSpan {p : P} {s : Set P} (hp : p ∈ s) : p ∈ affineSpan k s :=
− mem_spanPoints k p s hp
513 · exact vectorSpan_mono k (subset_affineSpan k s)
lemma vectorSpan_add_self changedL515–519
515@[simp]
516lemma vectorSpan_add_self (s : Set V) : (vectorSpan k s : Set V) + s = affineSpan k s := by
517 ext
− simp [mem_add, coe_affineSpan, spanPoints]
518 simp [mem_add, mem_affineSpan_iff_exists]
519 grind
521variable {k}
theorem vadd_mem_affineSpan_of_mem_affineSpan_of_mem_vectorSpan changedL523–528
523/-- Adding a point in the affine span and a vector in the spanning submodule produces a point in the
524affine span. -/
525theorem vadd_mem_affineSpan_of_mem_affineSpan_of_mem_vectorSpan {s : Set P} {p : P} {v : V}
− (hp : p ∈ affineSpan k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ affineSpan k s :=
− vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan k hp hv
526 (hp : p ∈ affineSpan k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ affineSpan k s := by
527 obtain ⟨p₁, hp₁, v₁, hv₁, rfl⟩ := hp
528 exact ⟨p₁, hp₁, v + v₁, (vectorSpan k s).add_mem hv hv₁, vadd_vadd _ _ _⟩
theorem vsub_mem_vectorSpan_of_mem_affineSpan_of_mem_affineSpan changedL530–536
530/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
531theorem vsub_mem_vectorSpan_of_mem_affineSpan_of_mem_affineSpan {s : Set P} {p₁ p₂ : P}
− (hp₁ : p₁ ∈ affineSpan k s) (hp₂ : p₂ ∈ affineSpan k s) : p₁ -ᵥ p₂ ∈ vectorSpan k s :=
− vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints k hp₁ hp₂
532 (hp₁ : p₁ ∈ affineSpan k s) (hp₂ : p₂ ∈ affineSpan k s) : p₁ -ᵥ p₂ ∈ vectorSpan k s := by
533 obtain ⟨p₁, hp₁, v₁, hv₁, rfl⟩ := hp₁
534 obtain ⟨p₂, hp₂, v₂, hv₂, rfl⟩ := hp₂
535 rw [vsub_vadd_eq_vsub_sub, vadd_vsub_assoc]
536 exact (vectorSpan k s).sub_mem ((vectorSpan k s).add_mem hv₁ (vsub_mem_vectorSpan k hp₁ hp₂)) hv₂
theorem affineSpan_le_of_subset_coe changedL538–542
538/-- If an affine subspace contains a set of points, it contains the affine span of that set. -/
539theorem affineSpan_le_of_subset_coe {s : Set P} {s₁ : AffineSubspace k P} (h : s ⊆ s₁) :
− affineSpan k s ≤ s₁ :=
− AffineSubspace.spanPoints_subset_coe_of_subset_coe h
540 affineSpan k s ≤ s₁ := by
541 rintro p ⟨p₁, hp₁, v, hv, rfl⟩
542 exact AffineSubspace.vadd_mem_of_mem_direction (vectorSpan_mono k h hv) (h hp₁)
544end affineSpan
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k
instance (anonymous instance) changedL551–560
551instance : CompleteLattice (AffineSubspace k P) where
552 sup := fun s₁ s₂ => affineSpan k (s₁ ∪ s₂)
553 le_sup_left := fun _ _ =>
− Set.Subset.trans Set.subset_union_left (subset_spanPoints k _)
554 Set.Subset.trans Set.subset_union_left (subset_affineSpan k _)
555 le_sup_right := fun _ _ =>
− Set.Subset.trans Set.subset_union_right (subset_spanPoints k _)
− sup_le := fun _ _ _ hs₁ hs₂ => spanPoints_subset_coe_of_subset_coe (Set.union_subset hs₁ hs₂)
556 Set.Subset.trans Set.subset_union_right (subset_affineSpan k _)
557 sup_le := fun _ _ _ hs₁ hs₂ => affineSpan_le_of_subset_coe (Set.union_subset hs₁ hs₂)
558 inf := fun s₁ s₂ =>
559 mk (s₁ ∩ s₂) fun c _ _ _ hp₁ hp₂ hp₃ =>
560 ⟨s₁.smul_vsub_vadd_mem c hp₁.1 hp₂.1 hp₃.1, s₂.smul_vsub_vadd_mem c hp₁.2 hp₂.2 hp₃.2⟩
instance : CompleteLattice (AffineSubspace k P) where
575 rw [Set.mem_iInter₂] at *
576 exact s₂.smul_vsub_vadd_mem c (hp₁ s₂ hs₂) (hp₂ s₂ hs₂) (hp₃ s₂ hs₂)
577 isLUB_sSup _ :=
− ⟨fun _ h => Set.Subset.trans (Set.subset_biUnion_of_mem h) (subset_spanPoints k _),
− fun _ h => spanPoints_subset_coe_of_subset_coe (Set.iUnion₂_subset h)⟩
578 ⟨fun _ h => Set.Subset.trans (Set.subset_biUnion_of_mem h) (subset_affineSpan k _),
579 fun _ h => affineSpan_le_of_subset_coe (Set.iUnion₂_subset h)⟩
580 isGLB_sInf _ := .of_image SetLike.coe_subset_coe isGLB_biInf
581 le_inf := fun _ _ _ => Set.subset_inter
  • L578 Mathlib writes fun x ↦ … rather than fun x => …. guide
  • L579 Mathlib writes fun x ↦ … rather than fun x => …. guide
variable (k V)
theorem affineSpan_eq_sInf changedL632–635
632theorem affineSpan_eq_sInf (s : Set P) :
633 affineSpan k s = sInf { s' : AffineSubspace k P | s ⊆ s' } :=
634 le_antisymm (affineSpan_le_of_subset_coe <| Set.subset_iInter₂ fun _ => id)
− (sInf_le (subset_spanPoints k _))
635 (sInf_le (subset_affineSpan k _))
637variable (P)
def gi changedL639–647
639/-- The Galois insertion formed by `affineSpan` and coercion back to a set. -/
640protected def gi : GaloisInsertion (affineSpan k) ((↑) : AffineSubspace k P → Set P) where
641 choice s _ := affineSpan k s
642 gc s₁ _s₂ :=
− ⟨fun h => Set.Subset.trans (subset_spanPoints k s₁) h, affineSpan_le_of_subset_coe⟩
− le_l_u _ := subset_spanPoints k _
643 ⟨fun h => Set.Subset.trans (subset_affineSpan k s₁) h, affineSpan_le_of_subset_coe⟩
644 le_l_u _ := subset_affineSpan k _
645 choice_eq _ _ := rfl
647/-- The span of the empty set is `⊥`. -/
section
988variable {s : Set P}
theorem affineSpan_nonempty changedL990–997
990/-- The affine span of a set is nonempty if and only if that set is. -/
−theorem affineSpan_nonempty : (affineSpan k s : Set P).Nonempty ↔ s.Nonempty :=
− spanPoints_nonempty k s
991theorem affineSpan_nonempty : (affineSpan k s : Set P).Nonempty ↔ s.Nonempty := by
992 constructor
993 · contrapose
994 rw [Set.not_nonempty_iff_eq_empty, Set.not_nonempty_iff_eq_empty]
995 intro h
996 simp [h]
997 · exact fun h ↦ h.mono (subset_affineSpan _ _)
999alias ⟨_, _root_.Set.Nonempty.affineSpan⟩ := affineSpan_nonempty
theorem toAffineSubspace_sup (p q : Submodule k V) :
1220 simp_rw [sup_eq_iSup, toAffineSubspace_iSup, Bool.apply_cond]
1222end Submodule
1224section Deprecated
1226variable (k : Type*) {V P : Type*} [Ring k] [AddCommGroup V] [Module k V] [AffineSpace V P]
def spanPoints newL1228–1232
1228/-- The points in the affine span of a (possibly empty) set of points. Use `affineSpan` instead to
1229get an `AffineSubspace k P`. -/
1230@[deprecated affineSpan +typeChanged (since := "2026-12-07")]
1231def spanPoints (s : Set P) : Set P :=
1232 { p | ∃ p₁ ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p₁ }
theorem coe_affineSpan newL1234–1236
1234@[deprecated mem_affineSpan_iff_exists +typeChanged (since := "2026-12-07")]
1235theorem coe_affineSpan (s : Set P) : (affineSpan k s : Set P) = spanPoints k s :=
1236 rfl
theorem mem_spanPoints newL1238–1240
1238@[deprecated mem_affineSpan +typeChanged (since := "2026-12-07")]
1239theorem mem_spanPoints (p : P) (s : Set P) : p ∈ s → p ∈ spanPoints k s :=
1240 mem_affineSpan k
theorem subset_spanPoints newL1242–1244
1242@[deprecated subset_affineSpan +typeChanged (since := "2026-12-07")]
1243theorem subset_spanPoints (s : Set P) : s ⊆ spanPoints k s :=
1244 subset_affineSpan k s
theorem spanPoints_nonempty newL1246–1248
1246@[deprecated affineSpan_nonempty +typeChanged (since := "2026-12-07")]
1247theorem spanPoints_nonempty (s : Set P) : (spanPoints k s).Nonempty ↔ s.Nonempty :=
1248 affineSpan_nonempty k
1250@[deprecated vadd_mem_affineSpan_of_mem_affineSpan_of_mem_vectorSpan +typeChanged
1251 (since := "2026-12-07")]
  • L1250 Deprecation without (since := "YYYY-MM-DD"). guide
theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan newL1252–1254
1252theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan {s : Set P} {p : P} {v : V}
1253 (hp : p ∈ spanPoints k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ spanPoints k s :=
1254 vadd_mem_affineSpan_of_mem_affineSpan_of_mem_vectorSpan hp hv
1256@[deprecated vsub_mem_vectorSpan_of_mem_affineSpan_of_mem_affineSpan +typeChanged
1257 (since := "2026-12-07")]
  • L1256 Deprecation without (since := "YYYY-MM-DD"). guide
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints newL1258–1260
1258theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p₁ p₂ : P}
1259 (hp₁ : p₁ ∈ spanPoints k s) (hp₂ : p₂ ∈ spanPoints k s) : p₁ -ᵥ p₂ ∈ vectorSpan k s :=
1260 vsub_mem_vectorSpan_of_mem_affineSpan_of_mem_affineSpan hp₁ hp₂
1262variable {k} in
theorem AffineSubspace.spanPoints_subset_coe_of_subset_coe newL1263–1266
1263@[deprecated affineSpan_le_of_subset_coe +typeChanged (since := "2026-12-07")]
1264theorem AffineSubspace.spanPoints_subset_coe_of_subset_coe {s : Set P} {s₁ : AffineSubspace k P}
1265 (h : s ⊆ s₁) : spanPoints k s ⊆ s₁ :=
1266 affineSpan_le_of_subset_coe h
1268end Deprecated
0/29 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.