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

← queue

#44802 feat(MeasureTheory/Lebesgue): one-dimensional Brunn–Minkowski theorem

t-measure-probability CI success

+76 −4 · 3 files · 5 commits · head a4e7c18 · updated yesterday · Files changed on GitHub

In plain words

Proves the one-dimensional Brunn–Minkowski inequality for arbitrary nonempty (no measurability needed, being an outer measure), as a special case of an order-theoretic version for monotone (additive or multiplicative) magmas whose translations do not decrease measure. Supporting lemmas: inner approximation , and generalising the instance " is countably generated in a separable order topology" to subtypes.

The transcriptions were written for revision 4a2214d; the PR is now at a4e7c18. 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 is the starting point of upstreaming github.com/hojonathanho/isoperimetric (with author's permission at github.com/hojonathanho/isoperimetric/issues/1) for the general Brunn–Minkowski theorem. The proof strategy follows terrytao.wordpress.com/2011/09/16/the-brunn-minkowski-inequality-for-nilpotent-groups/, which goes like:

1-d Brunn–Minkowski -> 1-d Prékopa-Leindler -> n-d Prékopa-Leindler -> n-d Brunn–Minkowski

Co-authored-by: Jonathan Ho <hojonathanho@gmail.com>


~~As far as I know, no AI was used (except for my request for copilot review below, which returned nothing)~~

There was a major revision to this PR. The first version was written without AI, which proved the statement MeasurableSet A -> MeasurableSet B -> nonemptiness -> volume A + volume B ≤ volume (A + B). This was then re-written using an Aristotle generated proof (see github.com/leanprover-community/mathlib4/pull/44802#issuecomment-6146960763), which removes the measurability hypothesis and generalize the theorem to partially ordered monoid + pull-back (sub-)invariant measure (so this would also work on e.g. NNReal). The AI-generated proof has been restructured by me manually.

On the topic of generalization of the μ A + μ B ≤ μ (A + B)-like inequality, there is also Kemperman's theorem which holds for locally compact connected groups, which includes Real. The proof of this is beyond my ability at the moment, plus it still generally requires measurability, plus it requires a group instead of a just a magma. So the generalization to ordered magma is an interesting one on its own, and I chose to go in that direction in this PR

Conversation on GitHub 19
github-actions[bot] · comment · 2026-10-12
PR summary a4e7c1898f

<details><summary>

Import changes for modified files

</summary>

Dependency changes

| File | Base Count | Head Count | Change | | --- | --- | --- | --- | | Mathlib.Topology.Order.Basic | 849 | 850 | +1 (+0.12%) |

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

|Files|Import difference| |-|-| |<details><summary>31 files</summary> Mathlib.Analysis.Normed.Group.Defs Mathlib.Geometry.Group.WordMetric Mathlib.MeasureTheory.OuterMeasure.Defs Mathlib.Topology.Category.Sequential Mathlib.Topology.ContinuousMap.Interval Mathlib.Topology.ContinuousMap.Ordered Mathlib.Topology.FiberBundle.Trivialization Mathlib.Topology.Instances.Discrete Mathlib.Topology.Instances.Sign Mathlib.Topology.OmegaCompletePartialOrder Mathlib.Topology.Order.Basic Mathlib.Topology.Order.Category.AlexDisc Mathlib.Topology.Order.Completion Mathlib.Topology.Order.CountableSeparating Mathlib.Topology.Order.Filter Mathlib.Topology.Order.HullKernel Mathlib.Topology.Order.LawsonTopology Mathlib.Topology.Order.LowerUpperTopology Mathlib.Topology.Order.MonotoneConvergence Mathlib.Topology.Order.NhdsSet Mathlib.Topology.Order.ProjIcc Mathlib.Topology.Order.Real Mathlib.Topology.Order.ScottTopology Mathlib.Topology.Order.Separable Mathlib.Topology.Order.SuccPred Mathlib.Topology.Order.T5 Mathlib.Topology.Order.UpperLowerSetTopology Mathlib.Topology.Order.WithTop Mathlib.Topology.Separation.LinearUpperLowerSetTopology Mathlib.Topology.Sheaves.Alexandrov Mathlib.Topology.Specialization</details>|1|

</details>

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ _root_.PartialOrder.measure_add_measure_le_measure_mul_add_iSup + instIsCountablyGenerated_atTop_subtype + measure_eq_iSup_inter_Ici + measure_eq_iSup_inter_Iic + volume_add_volume_le <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 a4e7c18).

  • +7 new declarations
  • −0 removed declarations
+MeasureTheory.measure_eq_iSup_inter_Ici
+MeasureTheory.measure_eq_iSup_inter_Iic
+PartialOrder.measure_add_measure_le_measure_add_add_iSup
+PartialOrder.measure_add_measure_le_measure_mul_add_iSup
+Real.volume_add_volume_le
+instIsCountablyGenerated_atBot_subtype
+instIsCountablyGenerated_atTop_subtype

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

Current commit a4e7c1898f Reference commit 07be4bec1b

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).
copilot-pull-request-reviewer[bot] · commented · 2026-10-12
🟢 Approval recommended

The proofs correctly handle compact approximation and infinite-volume cases with no unresolved issues found.

0 open findings

<details> <summary><strong>What changed in this PR</strong></summary>

Adds the one-dimensional Brunn–Minkowski inequality for Lebesgue measure.

Changes:

  • Proves the result for nonempty compact subsets of ℝ.
  • Extends it to nonempty measurable subsets via compact approximation.

| File | Description | | ---- | ----------- | | Mathlib/​MeasureTheory/​Measure/​Lebesgue/​Basic.lean | Adds compact and measurable one-dimensional Brunn–Minkowski theorems. | </details>

🧠 Review effort: Balanced


💡 <a href="/leanprover-community/mathlib4/new/master?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:442 (outdated) · 2026-10-13
open scoped Pointwise in
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:468 (outdated) · 2026-10-13
open scoped Pointwise in
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:446 (outdated) · 2026-10-13
    (hBn : B.Nonempty) (hBc : IsCompact B) : volume A + volume B ≤ volume (A + B) :=
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:472 (outdated) · 2026-10-13
    (hBn : B.Nonempty) (hBm : MeasurableSet B) : volume A + volume B ≤ volume (A + B) := by
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:495 (outdated) · 2026-10-13

Instead of 1 + 2 + 1 + 2 you can do 2 + 2 + 2

      refine iSup₂_le fun K hKA ↦ iSup₂_le fun hK L ↦ iSup₂_le fun hLB hL ↦ ?_
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:448 (outdated) · 2026-10-13
    _ = volume (A + {-sSup A}) + volume (B + {-sInf B}) := by simp
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:466 (outdated) · 2026-10-13
    _ = _ := by simp
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:465 (outdated) · 2026-10-13
    _ = volume (A + B + {-sSup A} + {-sInf B}) := by abel_nf

or

    _ = volume (A + B + {-sSup A} + {-sInf B}) := by congr 1; abel
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:453 (outdated) · 2026-10-13
      suffices (A + {-sSup A}) ∩ (B + {-sInf B}) ⊆ {0} by
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:460 (outdated) · 2026-10-13
      refine fun x ⟨hA, hB⟩ ↦ le_antisymm ?_ ?_
      · exact nonpos_of_add_le_left <| le_csSup hAc.bddAbove <| by simpa using hA
      · exact nonneg_of_le_add_left <| csInf_le hBc.bddBelow <| by simpa using hB
SnirBroshi · on Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean:466 (outdated) · 2026-10-13

These two steps can become

    _ = _ := by rw [add_add_add_comm]; simp

and maybe there's some simp [foo] that can solve it without rw.

SnirBroshi · comment · 2026-10-13

I like the IsCompact proof here (haven't read the MeasurableSet one yet), but it turns out that this 1d theorem is true for any nonempty sets without any extra hypotheses (live, by Aristotle with edits and comments by me; ignore the proofs, the statements are the interesting bit).

I don't know if the IsCompact argument can be generalized, but I think it's worth generalizing rather than having two special cases, given that we know the general version has a relatively short proof. Wdyt?

wwylele · comment · 2026-10-13

That's pretty nice, and I'll definitely take a deeper look and incorporate that in the proof.

This also makes me second guessing the general proof strategy, though. Can the measurability also be removed from the general Brunn–Minkowski? (and do we care?)

awaiting-author


Follow up: Based on en.wikipedia.org/wiki/Brunn%E2%80%93Minkowski_theorem, as well as its linked source Gardner's survey on Brunn–Minkowski, it seems that the measurability for higher dimension is required. I didn't carefully read through the entire paper, but skimmed through by searching for keyword "measura". It looks like there are ways to extend beyond measurable set, but it requires modifying definitions in the statement, such as using Lebesgure inner measure, or changing the pointwise sum to "essential sum". For the simple statement with volume and pointwise sum, looks like the measurability is needed and the proof strategy is still good

SnirBroshi · comment · 2026-10-13

Thanks for looking into it!

IMO avoiding MeasurableSet is nice if it's not too hard, to make it easier for users of the theorem, but probably not very important. I care more about generalizing beyond the reals if possible, as the example above does (which btw seems broken now that Set is a structure, not sure why).

But also apparently:

every Archimedean group is isomorphic (as an ordered group) to a subgroup of the real numbers

so maybe generalizing beyond the reals also doesn't matter? Although we don't have this in Mathlib yet.

wwylele · comment · 2026-10-13

every Archimedean group is isomorphic (as an ordered group) to a subgroup of the real numbers

Haha I PR'd that Archimedean.exists_orderAddMonoidHom_real_injective

copilot-pull-request-reviewer[bot] · commented · 2026-10-15
🔵 Needs a closer look

The generalized mathematical proof and foundational typeclass changes warrant final Lean-aware human review.

0 open findings

🧠 Review effort: Balanced

wwylele · comment · 2026-10-15

I have updated the code with the new proof. Also see updated PR description for some related info

-awaiting-author

Mathlib/MeasureTheory/Measure/Interval.lean +57 −0

theorem tendsto_measure_Ici_atBot [(atBot : Filter α).IsCountablyGenerated]
66 (μ : Measure α) : Tendsto (fun x => μ (Ici x)) atBot (𝓝 (μ univ)) :=
67 tendsto_measure_Iic_atTop (α := αᵒᵈ) μ
theorem measure_eq_iSup_inter_Iic newL69–79
69theorem measure_eq_iSup_inter_Iic (μ : Measure α) (S : Set α) [IsDirectedOrder S]
70 [(atTop : Filter S).IsCountablyGenerated] :
71 μ S = ⨆ x ∈ S, μ (S ∩ Iic x) := by
72 refine le_antisymm ?_ <| iSup₂_le fun _ _ ↦ measure_mono inter_subset_left
73 rcases isEmpty_or_nonempty S with h | h
74 · simp [isEmpty_coe_sort.mp h]
75 have : Tendsto (fun x : S ↦ μ (S ∩ Iic x)) atTop (𝓝 (μ (⋃ x : S, S ∩ Iic x))) :=
76 tendsto_measure_iUnion_atTop fun _ _ h ↦ inter_subset_inter_right _ <| Iic_subset_Iic.mpr h
77 rw [le_antisymm (iUnion_subset fun _ ↦ inter_subset_left)
78 fun x hx ↦ mem_iUnion.mpr ⟨⟨x, hx⟩, hx, le_rfl⟩] at this
79 exact le_of_tendsto' this (le_biSup (μ <| S ∩ Iic ·) ·.property)
81-- TODO: generate this using `@[to_dual]` once Monotone <-> Antitone is tagged with `@[to_dual]`
theorem measure_eq_iSup_inter_Ici newL82–93
82@[to_dual existing measure_eq_iSup_inter_Iic]
83theorem measure_eq_iSup_inter_Ici (μ : Measure α) (S : Set α) [IsCodirectedOrder S]
84 [(atBot : Filter S).IsCountablyGenerated] :
85 μ S = ⨆ x ∈ S, μ (S ∩ Ici x) := by
86 refine le_antisymm ?_ <| iSup₂_le fun _ _ ↦ measure_mono inter_subset_left
87 rcases isEmpty_or_nonempty S with h | h
88 · simp [isEmpty_coe_sort.mp h]
89 have : Tendsto (fun x : S ↦ μ (S ∩ Ici x)) atBot (𝓝 (μ (⋃ x : S, S ∩ Ici x))) :=
90 tendsto_measure_iUnion_atBot fun _ _ h ↦ inter_subset_inter_right _ <| Ici_subset_Ici.mpr h
91 rw [le_antisymm (iUnion_subset fun _ ↦ inter_subset_left)
92 fun x hx ↦ mem_iUnion.mpr ⟨⟨x, hx⟩, hx, le_rfl⟩] at this
93 exact le_of_tendsto' this (le_biSup (μ <| S ∩ Ici ·) ·.property)
95end Preorder
97section PartialOrder
theorem Ico_ae_eq_Icc' (hb : μ {b} = 0) : Ico a b =ᵐ[μ] Icc a b :=
122theorem Ico_ae_eq_Ioc' (ha : μ {a} = 0) (hb : μ {b} = 0) : Ico a b =ᵐ[μ] Ioc a b :=
123 (Ioo_ae_eq_Ico' ha).symm.trans (Ioo_ae_eq_Ioc' hb)
125open scoped Pointwise in
126/-- `μ A + μ B ≤ μ (A * B) + μ singleton` for ordered magma. -/
127@[to_additive /-- `μ A + μ B ≤ μ (A + B) + μ singleton` for ordered add magma.
128This is used to prove `Real.volume_add_volume_le` -/]
theorem _root_.PartialOrder.measure_add_measure_le_measure_mul_add_iSup newL129–154
129theorem _root_.PartialOrder.measure_add_measure_le_measure_mul_add_iSup [Mul α] [MulLeftMono α]
130 [MulRightMono α] (hIic : ∀ x : α, MeasurableSet (Iic x))
131 (hl : ∀ a s, μ s ≤ μ ((a * ·) '' s)) (hr : ∀ b s, μ s ≤ μ ((· * b) '' s))
132 {A B : Set α} [IsDirectedOrder A] [(atTop : Filter A).IsCountablyGenerated]
133 [IsCodirectedOrder B] [(atBot : Filter B).IsCountablyGenerated] (hA : A.Nonempty)
134 (hB : B.Nonempty) :
135 μ A + μ B ≤ μ (A * B) + ⨆ x ∈ A * B, μ {x} := by
136 rw [measure_eq_iSup_inter_Iic μ A, measure_eq_iSup_inter_Ici μ B]
137 refine ENNReal.biSup_add_biSup_le hA hB fun a ha b hb ↦ ?_
138 calc
139 _ ≤ μ ((· * b) '' (A ∩ Iic a)) + μ ((a * ·) '' (B ∩ Ici b)) := by
140 gcongr 1
141 · apply hr b
142 · apply hl a
143 _ ≤ μ (A * B ∩ Iic (a * b)) + μ ((A * B) \ Iio (a * b)) := by
144 gcongr
145 · rintro _ ⟨x, ⟨hx, hxa⟩, rfl⟩
146 exact ⟨mul_mem_mul hx hb, mul_le_mul_left hxa b⟩
147 · rintro _ ⟨y, ⟨hy, hyb⟩, rfl⟩
148 refine ⟨mul_mem_mul ha hy, (mul_le_mul_right hyb a).not_gt⟩
149 _ ≤ μ (A * B ∩ Iic (a * b)) + μ ((A * B) \ Iic (a * b)) + μ {a * b} := by
150 grw [add_assoc, ← measure_union_le _ {a * b}, ← Set.sdiff_sdiff_eq_sdiff_union ?_,
151 Set.Iic_sdiff_right]
152 simpa using Set.mul_mem_mul ha hb
153 _ ≤ _ := by
154 grw [measure_inter_add_sdiff _ (hIic _), le_biSup (μ {·}) (Set.mul_mem_mul ha hb)]
156end PartialOrder
158end MeasureTheory

Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean +7 −0

theorem map_linearMap_volume_pi_eq_smul_volume_pi {f : (ι → ℝ) →ₗ[ℝ]
432 apply map_matrix_volume_pi_eq_smul_volume_pi
433 rwa [A] at hf
435open scoped Pointwise in
theorem volume_add_volume_le newL436–440
436/-- One-dimensional **Brunn–Minkowski theorem**. -/
437theorem volume_add_volume_le {A B : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) :
438 volume A + volume B ≤ volume (A + B) := by
439 grw [PartialOrder.measure_add_measure_le_measure_add_add_iSup (by simp) (by simp) (by simp) hA hB]
440 simp
442end Real
444section regionBetween

Mathlib/Topology/Order/Basic.lean +12 −4

public import Mathlib.Order.Interval.Set.Pi
10public import Mathlib.Order.OrdContinuous
11public import Mathlib.Topology.Order.OrderClosed
13import Mathlib.Order.Filter.AtTopBot.Map
15/-!
16# Theory of topology on ordered spaces
theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α)
701 countable_image_lt_image_Ioi (α := αᵒᵈ) f
instance instIsCountablyGenerated_atTop changedL703–703
703@[to_dual]
−instance instIsCountablyGenerated_atTop [SeparableSpace α] :
− IsCountablyGenerated (atTop : Filter α) := by
− obtain (h | ⟨x, hx⟩) := Set.eq_empty_or_nonempty {x : α | IsTop x}
− · obtain ⟨s, s_count, hs⟩ := exists_countable_dense α
instance instIsCountablyGenerated_atTop_subtype changedL704–710
704instance instIsCountablyGenerated_atTop_subtype {P : α → Prop} [SeparableSpace (Subtype P)] :
705 IsCountablyGenerated (atTop : Filter (Subtype P)) := by
706 obtain (h | ⟨x, hx⟩) := Set.eq_empty_or_nonempty {x : (Subtype P) | IsTop x}
707 · obtain ⟨s, s_count, hs⟩ := exists_countable_dense (Subtype P)
708 have : atTop = generate (Ici '' s) := by
709 refine atTop_eq_generate_of_not_bddAbove fun ⟨x, hx⟩ ↦ ?_
710 simp only [eq_empty_iff_forall_notMem, IsTop, mem_ofPred_eq, not_forall, not_le] at h
instance instIsCountablyGenerated_atTop [SeparableSpace α] :
715 · rw [atTop_eq_pure_of_isTop hx]
716 exact isCountablyGenerated_pure x
instance instIsCountablyGenerated_atTop newL718–722
718@[to_dual]
719instance instIsCountablyGenerated_atTop [SeparableSpace α] :
720 IsCountablyGenerated (atTop : Filter α) := by
721 rw [← OrderIso.Set.univ.map_atTop]
722 apply Filter.map.isCountablyGenerated
724end OrderTopology
726section Pi
0/7 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.