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

← queue

#44252 feat(Geometry/Euclidean): relate Simplex.volume and Orientation.volumeForm

t-euclidean-geometry CI success

+157 −1 · 3 files · 2 commits · head 584669f · updated 3 days ago · Files changed on GitHub

In plain words

Proves the determinant formula for the volume of a simplex: in a Euclidean affine space of dimension , an -simplex has volume , with the volume form of an orientation (Orientation.volumeForm). The route: Hausdorff measure scales by normDet under affine maps (extending the existing linear-map result in NormDet.lean), the corner simplex of #44462 has volume , and every simplex is the image of the corner simplex under its cornerMap.

The transcriptions were written for revision 0f09c32; the PR is now at 584669f. Check them against the code.

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

This was inspired by the definition of (signed) triangle area in formal-conjectures. To connect the definition there and the new definition in Mathlib, this PR proves the two definitions are equal in absolute values. Orientation.volumeForm can further be used to derive Matrix form formulas.


On the definition cornerSimplex (comments moved from #44462):

This is similar to the object in #40479, but I dislike the name there, ~~and that PR has gone stale due to its deprecated dependencies~~ (this is no longer true). I also intentionally made this less general (instead of the corner simplex from any orthonormal basis, this one is only defined in EuclideanSpace). This makes the formulation of "a face of cornerSimplex is another cornerSimplex" more straightforward, as it simply corresponds to the index change in EuclideanSpace

That being sad, I am open to major changes such as

Conversation on GitHub 3
github-actions[bot] · comment · 2026-09-27
PR summary 584669f4b9
Import changes for modified files

No significant changes to the import graph

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

|Files|Import difference| |-|-| |<details><summary>3 files</summary> Mathlib.Geometry.Euclidean.Volume.Basic Mathlib.Geometry.Euclidean.Volume.Incenter Mathlib.Geometry.Euclidean.Volume.Triangle</details>|1| | Mathlib.Geometry.Euclidean.CornerSimplex (new file)|2977|

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ altitudeFoot_cornerSimplex + card_cornerSimplexFacePoints + cornerMap + cornerMap_injective + cornerMap_single + cornerMap_zero + cornerSimplex + cornerSimplexFacePoints + cornerSimplexFacePoints_succAboveOrderEmb + faceOpposite_cornerSimplex + face_cornerSimplex + height_cornerSimplex + map_cornerSimplex_cornerMap + normDet_cornerMap_linear + orderEmbOfFin_cornerSimplexFacePoints + volume_cornerSimplex + volume_eq_volumeForm <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>

<details><summary>

Declarations diff (Lean)

</summary>

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

  • +19 new declarations
  • −0 removed declarations
+Affine.Simplex.altitudeFoot_cornerSimplex
+Affine.Simplex.card_cornerSimplexFacePoints
+Affine.Simplex.cornerMap
+Affine.Simplex.cornerMap_injective
+Affine.Simplex.cornerMap_single
+Affine.Simplex.cornerMap_zero
+Affine.Simplex.cornerSimplex
+Affine.Simplex.cornerSimplexFacePoints
+Affine.Simplex.cornerSimplexFacePoints_succAboveOrderEmb
+Affine.Simplex.cornerSimplex_points
+Affine.Simplex.faceOpposite_cornerSimplex
+Affine.Simplex.face_cornerSimplex
+Affine.Simplex.height_cornerSimplex
+Affine.Simplex.map_cornerSimplex_cornerMap
+Affine.Simplex.normDet_cornerMap_linear
+Affine.Simplex.orderEmbOfFin_cornerSimplexFacePoints
+Affine.Simplex.volume_cornerSimplex
+Affine.Simplex.volume_eq_volumeForm
+PiLp.single.hcongr_7

</details>


No changes to strong technical debt. <details><summary>Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)</summary>

|Current number|Change|Type (weak)| |-:|:-:|:-| |5165|1|exposed public sections| </details>

Current commit 584669f4b9 Reference commit 732c803ed5

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-merge-conflicts[bot] · comment · 2026-11-17

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

mathlib-merge-conflicts[bot] · comment · 2026-12-02

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

Mathlib.lean +1 −0

public import Mathlib.Geometry.Euclidean.Basic
4841public import Mathlib.Geometry.Euclidean.BritishFlag
4842public import Mathlib.Geometry.Euclidean.Circumcenter
4843public import Mathlib.Geometry.Euclidean.Congruence
4844public import Mathlib.Geometry.Euclidean.CornerSimplex
4845public import Mathlib.Geometry.Euclidean.EulerQuadrilateral
4846public import Mathlib.Geometry.Euclidean.Incenter
4847public import Mathlib.Geometry.Euclidean.Incenter.Basic

Mathlib/Geometry/Euclidean/CornerSimplex.lean +138 −0 new file

1/-
2Copyright (c) 2026 Weiyi Wang. All rights reserved.
3Released under Apache 2.0 license as described in the file LICENSE.
4Authors: Weiyi Wang
5-/
6module
7
8public import Mathlib.Analysis.InnerProductSpace.NormDet
9public import Mathlib.Analysis.InnerProductSpace.Orientation
10public import Mathlib.Geometry.Euclidean.Altitude
12/-!
13# Corner simplex
15This file introduces `Affine.Simplex.cornerSimplex` which is useful for volume calculation.
17-/
19@[expose] public section
21namespace Affine.Simplex
23open EuclideanGeometry AffineMap EuclideanSpace Module Submodule Finset
def cornerSimplex newL25–36
25/-- The corner simplex in a standard Euclidean space, where the 0-th vertex is at the origin, and
26the rest are at the unit vector in each direction. All but one of the altitudes of this simplex has
27unit length. -/
28@[simps]
29noncomputable def cornerSimplex (n : ℕ) : Simplex ℝ (EuclideanSpace ℝ (Fin n)) n where
30 points i := if h : i = 0 then 0 else single (Fin.pred i h) 1
31 independent := by
32 rw [affineIndependent_iff_linearIndependent_vsub ℝ _ 0]
33 convert_to LinearIndependent ℝ ((fun i : Fin n ↦ single i (1 : ℝ)) ∘
34 (fun i : { x : Fin (n + 1) // x ≠ 0 } ↦ Fin.pred i.val i.prop))
35 · grind [vsub_eq_sub]
36 exact (PiLp.linearIndependent_single_one 2 ℝ).comp _ fun i j ↦ by grind
def cornerSimplexFacePoints newL38–42
38/-- Given an embedding from the `m`-dimensional Euclidean space into
39the `n`-deminsional one represented by `f`, this returns the index set to use in
40`Affine.Simplex.face` for the induced mapping of `Affine.Simplex.cornerSimplex`. -/
41def cornerSimplexFacePoints {m n : ℕ} (f : Fin m ↪o Fin n) : Finset (Fin (n + 1)) :=
42 insert 0 ((univ.map f.toEmbedding).map (Fin.succEmb n))
theorem card_cornerSimplexFacePoints newL44–47
44@[simp]
45theorem card_cornerSimplexFacePoints {m n : ℕ} (f : Fin m ↪o Fin n) :
46 #(cornerSimplexFacePoints f) = m + 1 := by
47 simp [cornerSimplexFacePoints]
theorem cornerSimplexFacePoints_succAboveOrderEmb newL49–55
49@[simp]
50theorem cornerSimplexFacePoints_succAboveOrderEmb {n : ℕ} (i : Fin (n + 1)) :
51 cornerSimplexFacePoints i.succAboveOrderEmb = {i.succ}ᶜ := by
52 ext j
53 cases j using Fin.cases
54 · simp [cornerSimplexFacePoints, (Fin.succ_ne_zero _).symm]
55 · simp [cornerSimplexFacePoints]
theorem orderEmbOfFin_cornerSimplexFacePoints newL57–63
57@[simp]
58theorem orderEmbOfFin_cornerSimplexFacePoints {m n : ℕ} (f : Fin m ↪o Fin n) :
59 ⇑((cornerSimplexFacePoints f).orderEmbOfFin (card_cornerSimplexFacePoints f)) =
60 Fin.cons 0 fun i ↦ (f i).succ := by
61 refine (orderEmbOfFin_unique _ ?_ ?_).symm
62 · apply Fin.cases <;> simp [cornerSimplexFacePoints]
63 · simpa [Fin.strictMono_cons] using! Fin.strictMono_succ.comp f.strictMono
theorem face_cornerSimplex newL65–72
65/-- A face of an `Affine.Simplex.cornerSimplex` that includes the origin is another
66`Affine.Simplex.cornerSimplex` mapped from lower dimensions by an isometry. -/
67theorem face_cornerSimplex {m n : ℕ} (f : Fin m ↪o Fin n) :
68 let g := (LinearIsometry.piLpExtendByZero 2 ℝ ℝ f.toEmbedding).toAffineIsometry
69 (cornerSimplex n).face (card_cornerSimplexFacePoints f) =
70 (cornerSimplex m).map g.toAffineMap g.injective := by
71 ext i : 1
72 cases i using Fin.cases <;> simp [face_points]
theorem faceOpposite_cornerSimplex newL74–78
74theorem faceOpposite_cornerSimplex {n : ℕ} (i : Fin (n + 1)) :
75 let g := (LinearIsometry.piLpExtendByZero 2 ℝ ℝ i.succAboveEmb).toAffineIsometry
76 (cornerSimplex (n + 1)).faceOpposite i.succ =
77 (cornerSimplex n).map g.toAffineMap g.injective := by
78 simpa [faceOpposite] using face_cornerSimplex i.succAboveOrderEmb
theorem altitudeFoot_cornerSimplex newL80–87
80@[simp]
81theorem altitudeFoot_cornerSimplex {n : ℕ} [NeZero n] {i : Fin (n + 1)} (hi : i ≠ 0) :
82 (cornerSimplex n).altitudeFoot i = 0 := by
83 rw [altitudeFoot, orthogonalProjectionSpan, coe_orthogonalProjection_eq_iff_mem]
84 refine ⟨mem_affineSpan _ (by simp [hi.symm]), ?_⟩
85 rw [← span_singleton_le_iff_mem, ← isOrtho_iff_le, direction_affineSpan,
86 vectorSpan_eq_span_vsub_set_right ℝ (p := 0) (by simp [hi.symm])]
87 aesop (add simp [inner_single_left])
theorem height_cornerSimplex newL89–92
89@[simp]
90theorem height_cornerSimplex {n : ℕ} [NeZero n] {i : Fin (n + 1)} (hi : i ≠ 0) :
91 (cornerSimplex n).height i = 1 := by
92 simp [height, hi]
94variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
95 [NormedAddTorsor V P]
def cornerMap newL97–101
97/-- The `AffineMap` from `Affine.Simplex.cornerSimplex` to an arbitrary `Affine.Simplex`. -/
98noncomputable def cornerMap {n : ℕ} (s : Simplex ℝ P n) :
99 EuclideanSpace ℝ (Fin n) →ᵃ[ℝ] P :=
100 ((basisFun (Fin n) ℝ).toBasis.constr ℝ fun i ↦ s.points i.succ -ᵥ s.points 0).toAffineMap +ᵥ
101 AffineMap.const ℝ (EuclideanSpace ℝ (Fin n)) (s.points 0)
theorem cornerMap_zero newL103–106
103@[simp]
104theorem cornerMap_zero {n : ℕ} (s : Simplex ℝ P n) :
105 s.cornerMap 0 = s.points 0 := by
106 simp [cornerMap]
theorem cornerMap_single newL108–111
108@[simp]
109theorem cornerMap_single {n : ℕ} (s : Simplex ℝ P n) (i : Fin n) :
110 s.cornerMap (single i 1) = s.points i.succ := by
111 simp [cornerMap]
theorem cornerMap_injective newL113–120
113theorem cornerMap_injective {n : ℕ} (s : Simplex ℝ P n) :
114 Function.Injective s.cornerMap := by
115 intro x y h
116 simp_rw [cornerMap, AffineMap.vadd_apply, const_apply, vadd_right_cancel_iff] at h
117 refine Basis.injective_constr_of_linearIndependent (R₂ := ℝ) _ ?_ h
118 convert ((affineIndependent_iff_linearIndependent_vsub ℝ _ 0).mp s.independent).comp
119 (fun i : Fin n ↦ ⟨i.succ, by simp⟩) fun i j ↦ by simp
120 simp
theorem map_cornerSimplex_cornerMap newL122–126
122@[simp]
123theorem map_cornerSimplex_cornerMap {n : ℕ} (s : Simplex ℝ P n) :
124 (cornerSimplex n).map s.cornerMap s.cornerMap_injective = s := by
125 ext i
126 by_cases hi : i = 0 <;> simp [hi]
theorem normDet_cornerMap_linear newL128–136
128theorem normDet_cornerMap_linear {n : ℕ} [FiniteDimensional ℝ V] [Fact (finrank ℝ V = n)]
129 (s : Simplex ℝ P n) (o : Orientation ℝ V (Fin n)) :
130 s.cornerMap.linear.normDet = |o.volumeForm fun i ↦ s.points i.succ -ᵥ s.points 0| := by
131 simp_rw [← cornerMap_single, ← cornerMap_zero, ← linear_apply_vsub, vsub_eq_sub, sub_zero]
132 let b : OrthonormalBasis (Fin n) ℝ V :=
133 (stdOrthonormalBasis ℝ V).reindex (finCongr ‹Fact (finrank ℝ V = n)›.out)
134 rw [s.cornerMap.linear.normDet_eq_norm_det_toMatrix (basisFun (Fin n) ℝ) b, Real.norm_eq_abs,
135 o.volumeForm_robust' b]
136 rfl
138end Affine.Simplex

Mathlib/Geometry/Euclidean/Volume/Basic.lean +18 −1

Authors: Weiyi Wang
6module
7
8public import Mathlib.Analysis.InnerProductSpace.NormDet
9public import Mathlib.Geometry.Euclidean.CornerSimplex
10public import Mathlib.Geometry.Euclidean.Volume.Def
12import Mathlib.Geometry.Euclidean.Volume.MeasureSimplex
This file provides lemmas related to the volume of a simplex.
21* `Affine.Simplex.volume_eq`: The volume of a $n$-simplex is equal to $h * b / n$, where $h$ is the
22 height and $b$ is the volume of the face.
23* `Affine.Simplex.volume_eq_volumeForm`: The volume of a $n$-simplex is the absolute value of
24 `Orientation.volumeForm` divided by $n!$.
25-/
27public section
−open MeasureTheory Measure Module
29open MeasureTheory Measure Module Nat
31namespace Affine.Simplex
meta def evalVolume : PositivityExt where eval {u α} _ pα? e :=
99 return .positive q(volume_pos $s)
100 | _, _, _ => throwError "not Simplex.volume"
theorem volume_cornerSimplex newL102–108
102@[simp]
103theorem volume_cornerSimplex (n : ℕ) : (cornerSimplex n).volume = (↑(n !))⁻¹ := by
104 induction n with
105 | zero => simp
106 | succ n ih =>
107 rw [volume_eq _ (0 : Fin (n + 1)).succ, faceOpposite_cornerSimplex, volume_map, ih]
108 simp [Nat.factorial_succ, mul_comm]
theorem volume_eq_volumeForm newL110–114
110theorem volume_eq_volumeForm {n : ℕ} [FiniteDimensional ℝ V] [Fact (finrank ℝ V = n)]
111 (o : Orientation ℝ V (Fin n)) (s : Simplex ℝ P n) :
112 s.volume = (↑(n !))⁻¹ * |o.volumeForm fun i ↦ s.points i.succ -ᵥ s.points 0| := by
113 conv_lhs => rw [← s.map_cornerSimplex_cornerMap, volume_map_of_finrank_eq (by simp),
114 volume_cornerSimplex, mul_comm s.cornerMap.linear.normDet, s.normDet_cornerMap_linear o]
116end Affine.Simplex
0/17 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.