Skip to content

[Merged by Bors] - feat(Geometry/Euclidean): volume of a simplex - #37910

Closed
wwylele wants to merge 37 commits into
leanprover-community:masterfrom
wwylele:volume-simplex-min
Closed

wwylele wants to merge 37 commits into
leanprover-community:masterfrom
wwylele:volume-simplex-min

Conversation

@wwylele

@wwylele wwylele commented Apr 10, 2026 •

Copy link
Copy Markdown
Collaborator

This defines the volume of a simplex in Euclidean geometry, and shows that it agrees with measure theory. It also adds the basic set of lemmas (base-and-height formula, reindex, positivity, map, and restrict). Further properties of the volume will be in future PRs.

Three new file s are introduced and organized in the following dependency chain:
Def.lean -> MeasureSimplex.Lean -> Basic.lean

The Def.lean file has the definition only. MeasureSimplex.lean pulls in measure theory. Basic.lean publicly imports Def.lean, and privately imports MeasureSimplex.lean. When a downstream file imports Basic.lean, the measure theory part is not exposed and all properties of the volume is provided.


Open in Gitpod

@github-actions

github-actions Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

PR summary c3ca893bb5

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Analysis.InnerProductSpace.NormDet Mathlib.Geometry.Euclidean.Volume.Measure 1
Mathlib.Geometry.Euclidean.Volume.Def (new file) 2315
Mathlib.Geometry.Euclidean.Volume.MeasureSimplex (new file) 2738
Mathlib.Geometry.Euclidean.Volume.Basic (new file) 2739

Declarations diff (regex)

+ Affine.Simplex.volume
+ EuclideanGeometry.euclideanHausdorffMeasure_eq_lintegral_of_subset
+ comap_mk'
+ comap_subtype_mk'
+ euclideanHausdorffMeasure_closedInterior
+ euclideanHausdorffMeasure_closedInterior_eq_one
+ euclideanHausdorffMeasure_closedInterior_inter_shift_aeEq
+ euclideanHausdorffMeasure_closedInterior_real_eq_one
+ euclideanHausdorffMeasure_coe_image
+ euclideanHausdorffMeasure_preimage_coe
+ euclideanHausdorffMeasure_preimage_coe_of_subset
+ euclideanHausdorffMeasure_real_closedInterior
+ measurableSet_closedInterior
+ mk'_eq_mk'_iff
+ orthogonalProjection_vadd
+ support_euclideanHausdorffMeasure_closedInterior_inter_shift_subset
+ volume_eq
+ volume_eq_dist
+ volume_eq_euclideanHausdorffMeasure_real_closedInterior
+ volume_eq_one
+ volume_eq_volume_real_closedInterior
+ volume_map
+ volume_pos
+ volume_reindex
+ volume_restrict
- AffineSubspace.euclideanHausdorffMeasure_coe_image

You can run this locally as follows
## 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>

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

Declarations diff (Lean)

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

  • +26 new declarations
  • −0 removed declarations
+Affine.Simplex.euclideanHausdorffMeasure_closedInterior
+Affine.Simplex.euclideanHausdorffMeasure_closedInterior_eq_one
+Affine.Simplex.euclideanHausdorffMeasure_closedInterior_inter_shift_aeEq
+Affine.Simplex.euclideanHausdorffMeasure_closedInterior_real_eq_one
+Affine.Simplex.euclideanHausdorffMeasure_real_closedInterior
+Affine.Simplex.evalVolume
+Affine.Simplex.measurableSet_closedInterior
+Affine.Simplex.support_euclideanHausdorffMeasure_closedInterior_inter_shift_subset
+Affine.Simplex.volume
+Affine.Simplex.volume.eq_def
+Affine.Simplex.volume_eq
+Affine.Simplex.volume_eq_dist
+Affine.Simplex.volume_eq_euclideanHausdorffMeasure_real_closedInterior
+Affine.Simplex.volume_eq_one
+Affine.Simplex.volume_eq_volume_real_closedInterior
+Affine.Simplex.volume_map
+Affine.Simplex.volume_pos
+Affine.Simplex.volume_reindex
+Affine.Simplex.volume_restrict
+AffineSubspace.comap_mk'
+AffineSubspace.comap_subtype_mk'
+AffineSubspace.euclideanHausdorffMeasure_preimage_coe
+AffineSubspace.euclideanHausdorffMeasure_preimage_coe_of_subset
+AffineSubspace.mk'_eq_mk'_iff
+EuclideanGeometry.euclideanHausdorffMeasure_eq_lintegral_of_subset
+EuclideanGeometry.orthogonalProjection_vadd

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type (weak)
exposed public sections 5074 1

Current commit c3ca893bb5
Reference commit fd634dd297

This script lives in the mathlib-ci 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-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Apr 10, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Apr 27, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@wwylele
wwylele force-pushed the volume-simplex-min branch from 774f433 to 58c0f07 Compare May 28, 2026 01:17
@github-actions github-actions Bot added large-import Automatically added label for PRs with a significant increase in transitive imports and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels May 28, 2026
@wwylele
wwylele force-pushed the volume-simplex-min branch 3 times, most recently from 6f2f6d2 to b74fc24 Compare May 28, 2026 03:32
@wwylele
wwylele requested a review from Copilot May 28, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a formal definition of simplex volume in Euclidean geometry and proves it agrees with the appropriate measure-theoretic volume; also introduces supporting lemmas about simplex closed interiors and affine subspace shifts.

Changes:

  • Add Affine.Simplex.volume and prove it matches Euclidean Hausdorff / Lebesgue volume of closedInterior.
  • Add lemmas relating barycentric coordinates to AffineSubspace.shift and derive simplex cross-section/intersection results.
  • Add a convenience lemma nonempty_closedInterior and wire new volume modules into Mathlib.lean.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Mathlib/LinearAlgebra/AffineSpace/Simplex/Basic.lean Adds nonempty_closedInterior for simplices.
Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Shift.lean Adds shift/barycentric coordinate lemmas and simplex cross-section results; changes imports.
Mathlib/Geometry/Euclidean/Volume/MeasureSimplex.lean New file proving Simplex.volume equals measure-theoretic volume of closedInterior.
Mathlib/Geometry/Euclidean/Volume/Def.lean New file defining Affine.Simplex.volume.
Mathlib/Geometry/Euclidean/Volume/Basic.lean New file adding derived volume lemmas (volume_eq, invariances, positivity, positivity extension).
Mathlib.lean Exposes new volume modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Mathlib.lean Resolved
@wwylele
wwylele force-pushed the volume-simplex-min branch 4 times, most recently from 1bdefb3 to 6b48fc3 Compare May 30, 2026 12:46
@wwylele
wwylele force-pushed the volume-simplex-min branch 2 times, most recently from 3efd5d5 to 0a53dcc Compare June 21, 2026 03:24
mathlib-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
…36018)

This shows that the intersection of `AffineSubspace.shift` of the base of a simplex and the interior of the simplex is a smaller simplex. This is preparing to calculate the volume of a simplex by integrating this cross-section. Part of #37910.

Co-authored-by: Junyan Xu <[email protected]>
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jun 30, 2026
@wwylele
wwylele force-pushed the volume-simplex-min branch from 0a53dcc to d23ab7b Compare June 30, 2026 17:36
@github-actions github-actions Bot removed the large-import Automatically added label for PRs with a significant increase in transitive imports label Jun 30, 2026
@wwylele wwylele added t-euclidean-geometry Affine and axiomatic geometry t-measure-probability Measure theory / Probability theory labels Jun 30, 2026
@wwylele
wwylele force-pushed the volume-simplex-min branch from d23ab7b to 9cc4c89 Compare June 30, 2026 20:29
@wwylele
wwylele requested a review from CoolRmal August 31, 2026 13:20
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Sep 5, 2026
… of the simplex (leanprover-community#43054)

Extracted from leanprover-community#37910. This sets up affine geometry lemma for calculating the volume. The leaf lemma in this PR is `Affine.Simplex.closedInterior_inter_affineSubspaceMk'_lineMap_altitudeFoot`, which says that {cross section parallel to the base} and {cross section perpendicular to the altitude} is the same

@bjbraams bjbraams left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR #37910 is a valuable contribution to Mathlib and I strongly support its adoption. Pending adoption I am already relying on one of the key theorems of the PR: the euclideanHausdorffMeasure_eq_lintegral. (This is in a project that involves measures on the standard simplex; see the code https://github.com/bjbraams/lean-codes/blob/main/StdSimplexMeasure/EuclideanCrossSection.lean.) I could use the code from #37910 without any change.

@CoolRmal CoolRmal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to add the following lemmas to finishEuclideanGeometry.euclideanHausdorffMeasure_eq_lintegral_of_subset.

/-- Two affine subspaces constructed from points and the same direction are equal if and only if
the difference of the points lies in that direction. -/
theorem mk'_eq_mk'_iff {p q : P} {s : Submodule k V} :
    mk' p s = mk' q s ↔ p -ᵥ q ∈ s := sorry

lemma comap_mk' (f : P₁ →ᵃ[k] P₂) (p : P₁) (s : Submodule k V₂) :
    (mk' (f p) s).comap f = mk' p (s.comap f.linear) := by
  aesop

/-- The preimage of `mk' p K` under the inclusion of an affine subspace `s`, for a submodule `K`
containing `s.directionᗮ`, is `mk'` of the orthogonal projection of `p` and the preimage of `K`. -/
theorem comap_subtype_mk' (s : AffineSubspace 𝕜 P) [Nonempty s]
    [s.direction.HasOrthogonalProjection] (p : P) {K : Submodule 𝕜 V} (hK : s.directionᗮ ≤ K) :
    comap s.subtype (mk' p K) = mk' (orthogonalProjection s p) (K.comap s.direction.subtype) := sorry

/-- The orthogonal projection of `w +ᵥ p`, for `w` in the direction of the subspace, is `w +ᵥ` the
orthogonal projection of `p`. -/
theorem orthogonalProjection_vadd (s : AffineSubspace 𝕜 P) [Nonempty s]
    [s.direction.HasOrthogonalProjection] (w : s.direction) (p : P) :
    orthogonalProjection s ((w : V) +ᵥ p) = w +ᵥ orthogonalProjection s p := sorry

I think they can then be used to give a better proof of euclideanHausdorffMeasure_eq_lintegral_of_subset. The theorem is proved by pulling t ⊆ s back to s along the inclusion and applying the ambient-space formula euclideanHausdorffMeasure_eq_lintegral inside s, with base point orthogonalProjection s p and direction vector ⟨v, hvs⟩. The integrand this produces is the measure of t ∩ H' where H' is a hyperplane in s, while the target integrand uses the hyperplane H = mk' (x • v +ᵥ p) (ℝ ∙ v)ᗮ of the ambient space. So the whole proof reduces to one geometric identity: H' = comap s.subtype H, i.e. H meets s exactly in H'.

comap_subtype_mk' applies with K = (ℝ ∙ v)ᗮ, whose hypothesis s.directionᗮ ≤ (ℝ ∙ v)ᗮ follows from v ∈ s.direction by Submodule.orthogonal_le. This turns comap s.subtype H into an mk' in s.

theorem EuclideanGeometry.euclideanHausdorffMeasure_eq_lintegral_of_subset (p : P) {v : V}
    (hv : v ≠ 0) {t : Set P} (ht : MeasurableSet t) {s : AffineSubspace ℝ P} (hvs : v ∈ s.direction)
    (hts : t ⊆ s) [FiniteDimensional ℝ s.direction] :
    μHE[finrank ℝ s.direction] t = ‖v‖ₑ * ∫⁻ (x : ℝ),
      μHE[finrank ℝ s.direction - 1] (t ∩ mk' (x • v +ᵥ p) (ℝ ∙ v)ᗮ) := by
  have : Nonempty s := (s.nonempty_iff_ne_bot.mpr fun h ↦ hv (by simpa [h] using hvs)).to_subtype
  let v' : s.direction := ⟨v, hvs⟩
  rw [← s.euclideanHausdorffMeasure_preimage_coe_of_subset _ hts,
    euclideanHausdorffMeasure_eq_lintegral (orthogonalProjection s p)
      (show v' ≠ 0 by simpa [v'] using hv) (ht.preimage measurable_subtype_coe)]
  congr 1
  refine lintegral_congr fun x ↦ ?_
  suffices mk' (x • v' +ᵥ orthogonalProjection s p) (ℝ ∙ v')ᗮ
    = comap s.subtype (mk' (x • v +ᵥ p) (ℝ ∙ v)ᗮ) from by
    simp [this, ← Set.preimage_inter,
      s.euclideanHausdorffMeasure_preimage_coe_of_subset _ (Set.inter_subset_left.trans hts)]
  rw [comap_subtype_mk' s _
    (Submodule.orthogonal_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hvs))]
  congr 1
  · exact (orthogonalProjection_vadd s (x • v') p).symm
  · ext w
    simp [Submodule.mem_orthogonal_singleton_iff_inner_right, v']

@wwylele

wwylele commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the suggestions! I have applied them

@CoolRmal

Copy link
Copy Markdown
Contributor

maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by CoolRmal.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 14, 2026
s.isClosed_closedInterior.measurableSet

/-- The volume of the cross-section is scaled from the base because of homothety -/
private theorem measure_cross_section (s : Simplex ℝ P (n + 1)) (i : Fin (n + 2)) :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these cross sections show up elsewhere? Should there be a dedicated definition, and should the result be public instead of private?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can turn this theorem public (originally a lot of things in this PR were private and this one is more like a left over). As for a new definition, I think a proper definition, if we want one, should promote this cross section object to an Affine.Simplex. I am not very motivated to write another set of API at the moment... how about I leave a TODO note here in the code comment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the doc & theorem visibility. Let me know what you think. If there is a push for a new definition, I can do it in the following days

-awaiting-author

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and if the new definition is needed, maybe we can slice off other parts from the PR and merge those first? The following files are unaffecrted

  • Mathlib/Geometry/Euclidean/Projection.lean
  • Mathlib/Geometry/Euclidean/Volume/Measure.lean
  • Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Basic.lean
  • Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Defs.lean

Not sure if the slice bot support multiple files. If not, I can manually make one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wwylele Thanks for the updates! This looks good to me now. If cross sections are added later, then we can refactor.

Thanks again 🎉

bors merge

@jcommelin jcommelin added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 16, 2026
@wwylele

wwylele commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 16, 2026
@YanYablonovskiy

Copy link
Copy Markdown
Contributor

I find it very strange the level of difficulty this PR has in getting merged. Is everything okay ?? Like it's a bit bizarre to me this is happening , as valuable as my exiled opinion is to you all..lovely people.

@wwylele
wwylele requested a review from jcommelin September 17, 2026 12:13
@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Sep 21, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 21, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
This defines the volume of a simplex in Euclidean geometry, and shows that it agrees with measure theory. It also adds the basic set of lemmas (base-and-height formula, reindex, positivity, map, and restrict). Further properties of the volume will be in future PRs.

Three new file s are introduced and organized in the following dependency chain:
Def.lean -> MeasureSimplex.Lean -> Basic.lean

The Def.lean file has the definition only. MeasureSimplex.lean pulls in measure theory. Basic.lean publicly imports Def.lean, and privately imports MeasureSimplex.lean. When a downstream file imports Basic.lean, the measure theory part is not exposed and all properties of the volume is provided.
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Sep 21, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat(Geometry/Euclidean): volume of a simplex [Merged by Bors] - feat(Geometry/Euclidean): volume of a simplex Sep 21, 2026
@mathlib-bors mathlib-bors Bot closed this Sep 21, 2026
grunweg pushed a commit to grunweg/mathlib4 that referenced this pull request Sep 22, 2026
…7910)

This defines the volume of a simplex in Euclidean geometry, and shows that it agrees with measure theory. It also adds the basic set of lemmas (base-and-height formula, reindex, positivity, map, and restrict). Further properties of the volume will be in future PRs.

Three new file s are introduced and organized in the following dependency chain:
Def.lean -> MeasureSimplex.Lean -> Basic.lean

The Def.lean file has the definition only. MeasureSimplex.lean pulls in measure theory. Basic.lean publicly imports Def.lean, and privately imports MeasureSimplex.lean. When a downstream file imports Basic.lean, the measure theory part is not exposed and all properties of the volume is provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. ready-to-merge This PR has been sent to bors. t-euclidean-geometry Affine and axiomatic geometry t-measure-probability Measure theory / Probability theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants