Skip to content

Commit 1d24f3c

Browse files
loefflerdjcommelinurkud
committed
refactor(Order/Disjointed): allow arbitrary partial orders as domain (#20545)
Co-authored-by: Johan Commelin <johan@commelin.net> Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
1 parent 114805c commit 1d24f3c

File tree

6 files changed

+355
-125
lines changed

6 files changed

+355
-125
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ import Mathlib.Algebra.Order.CauSeq.BigOperators
680680
import Mathlib.Algebra.Order.CauSeq.Completion
681681
import Mathlib.Algebra.Order.Chebyshev
682682
import Mathlib.Algebra.Order.CompleteField
683+
import Mathlib.Algebra.Order.Disjointed
683684
import Mathlib.Algebra.Order.Field.Basic
684685
import Mathlib.Algebra.Order.Field.Canonical
685686
import Mathlib.Algebra.Order.Field.Defs
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/-
2+
Copyright (c) 2025 David Loeffler. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: David Loeffler
5+
-/
6+
import Mathlib.Algebra.Order.PartialSups
7+
import Mathlib.Data.Nat.SuccPred
8+
import Mathlib.Order.Disjointed
9+
10+
/-!
11+
# `Disjointed` for functions on a `SuccAddOrder`
12+
13+
This file contains material excised from `Mathlib.Order.Disjointed` to avoid import dependencies
14+
from `Mathlib.Algebra.Order` into `Mathlib.Order`.
15+
16+
## TODO
17+
18+
Find a useful statement of `disjointedRec_succ`.
19+
-/
20+
21+
open Order
22+
23+
variable {α ι : Type*} [GeneralizedBooleanAlgebra α]
24+
25+
section SuccAddOrder
26+
27+
variable [LinearOrder ι] [LocallyFiniteOrderBot ι] [Add ι] [One ι] [SuccAddOrder ι]
28+
29+
theorem disjointed_add_one [NoMaxOrder ι] (f : ι → α) (i : ι) :
30+
disjointed f (i + 1) = f (i + 1) \ partialSups f i := by
31+
simpa only [succ_eq_add_one] using disjointed_succ f (not_isMax i)
32+
33+
protected lemma Monotone.disjointed_add_one_sup {f : ι → α} (hf : Monotone f) (i : ι) :
34+
disjointed f (i + 1) ⊔ f i = f (i + 1) := by
35+
simpa only [succ_eq_add_one i] using hf.disjointed_succ_sup i
36+
37+
protected lemma Monotone.disjointed_add_one [NoMaxOrder ι] {f : ι → α} (hf : Monotone f) (i : ι) :
38+
disjointed f (i + 1) = f (i + 1) \ f i := by
39+
rw [← succ_eq_add_one, hf.disjointed_succ]
40+
exact not_isMax i
41+
42+
end SuccAddOrder
43+
44+
section Nat
45+
46+
/-- A recursion principle for `disjointed`. To construct / define something for `disjointed f i`,
47+
it's enough to construct / define it for `f n` and to able to extend through diffs.
48+
49+
Note that this version allows an arbitrary `Sort*`, but requires the domain to be `Nat`, while
50+
the root-level `disjointedRec` allows more general domains but requires `p` to be `Prop`-valued. -/
51+
def Nat.disjointedRec {f : ℕ → α} {p : α → Sort*} (hdiff : ∀ ⦃t i⦄, p t → p (t \ f i)) :
52+
∀ ⦃n⦄, p (f n) → p (disjointed f n)
53+
| 0 => fun h₀ ↦ disjointed_zero f ▸ h₀
54+
| n + 1 => fun h => by
55+
suffices H : ∀ k, p (f (n + 1) \ partialSups f k) from disjointed_add_one f n ▸ H n
56+
intro k
57+
induction k with
58+
| zero => exact hdiff h
59+
| succ k ih => simpa only [partialSups_add_one, ← sdiff_sdiff_left] using hdiff ih
60+
61+
@[simp]
62+
theorem disjointedRec_zero {f : ℕ → α} {p : α → Sort*}
63+
(hdiff : ∀ ⦃t i⦄, p t → p (t \ f i)) (h₀ : p (f 0)) :
64+
Nat.disjointedRec hdiff h₀ = (disjointed_zero f ▸ h₀) :=
65+
rfl
66+
67+
-- TODO: Find a useful statement of `disjointedRec_succ`.
68+
69+
end Nat

Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ theorem isCaratheodory_union (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodo
7272
union_diff_left, h₂ (t ∩ s₁)]
7373
simp [diff_eq, add_assoc]
7474

75+
variable {m} in
76+
lemma IsCaratheodory.biUnion_of_finite {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
77+
(h : ∀ i ∈ t, m.IsCaratheodory (s i)) :
78+
m.IsCaratheodory (⋃ i ∈ t, s i) := by
79+
classical
80+
lift t to Finset ι using ht
81+
induction t using Finset.induction_on with
82+
| empty => simp
83+
| @insert i t hi IH =>
84+
simp only [Finset.mem_coe, Finset.mem_insert, iUnion_iUnion_eq_or_left] at h ⊢
85+
exact m.isCaratheodory_union (h _ <| Or.inl rfl) (IH fun _ hj ↦ h _ <| Or.inr hj)
86+
7587
theorem measure_inter_union (h : s₁ ∩ s₂ ⊆ ∅) (h₁ : IsCaratheodory m s₁) {t : Set α} :
7688
m (t ∩ (s₁ ∪ s₂)) = m (t ∩ s₁) + m (t ∩ s₂) := by
7789
rw [h₁, Set.inter_assoc, Set.union_inter_cancel_left, inter_diff_assoc, union_diff_cancel_left h]
@@ -93,17 +105,16 @@ theorem isCaratheodory_inter (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodo
93105
lemma isCaratheodory_diff (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) :
94106
IsCaratheodory m (s₁ \ s₂) := m.isCaratheodory_inter h₁ (m.isCaratheodory_compl h₂)
95107

96-
lemma isCaratheodory_partialSups {s : ℕ → Set α} (h : ∀ i, m.IsCaratheodory (s i)) (i : ℕ) :
108+
lemma isCaratheodory_partialSups {ι : Type*} [PartialOrder ι] [LocallyFiniteOrderBot ι]
109+
{s : ι → Set α} (h : ∀ i, m.IsCaratheodory (s i)) (i : ι) :
97110
m.IsCaratheodory (partialSups s i) := by
98-
induction i with
99-
| zero => exact h 0
100-
| succ i hi => exact partialSups_add_one s i ▸ m.isCaratheodory_union hi (h (i + 1))
101-
102-
lemma isCaratheodory_disjointed {s : ℕ → Set α} (h : ∀ i, m.IsCaratheodory (s i)) (i : ℕ) :
103-
m.IsCaratheodory (disjointed s i) := by
104-
induction i with
105-
| zero => exact h 0
106-
| succ i _ => exact m.isCaratheodory_diff (h (i + 1)) (m.isCaratheodory_partialSups h i)
111+
simpa only [partialSups_apply, Finset.sup'_eq_sup, Finset.sup_set_eq_biUnion, ← Finset.mem_coe,
112+
Finset.coe_Iic] using .biUnion_of_finite (finite_Iic _) (fun j _ ↦ h j)
113+
114+
lemma isCaratheodory_disjointed {ι : Type*} [PartialOrder ι] [LocallyFiniteOrderBot ι]
115+
{s : ι → Set α} (h : ∀ i, m.IsCaratheodory (s i)) (i : ι) :
116+
m.IsCaratheodory (disjointed s i) :=
117+
disjointedRec (fun _ j ht ↦ m.isCaratheodory_diff ht <| h j) (h i)
107118

108119
theorem isCaratheodory_sum {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i))
109120
(hd : Pairwise (Disjoint on s)) {t : Set α} :

Mathlib/MeasureTheory/SetSemiring.lean

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,25 @@ lemma biInter_mem {ι : Type*} (hC : IsSetRing C) {s : ι → Set α}
321321
refine hC.inter_mem hs.1 ?_
322322
exact h (fun n hnS ↦ hs.2 n hnS)
323323

324-
lemma partialSups_mem (hC : IsSetRing C) {s : ℕ → Set α} (hs : ∀ n, s n ∈ C) (n : ℕ) :
324+
lemma finsetSup_mem (hC : IsSetRing C) {ι : Type*} {s : ι → Set α} {t : Finset ι}
325+
(hs : ∀ i ∈ t, s i ∈ C) :
326+
t.sup s ∈ C := by
327+
classical
328+
induction t using Finset.induction_on with
329+
| empty => exact hC.empty_mem
330+
| @insert m t hm ih =>
331+
simpa only [sup_insert] using
332+
hC.union_mem (hs m <| mem_insert_self m t) (ih <| fun i hi ↦ hs _ <| mem_insert_of_mem hi)
333+
334+
lemma partialSups_mem {ι : Type*} [Preorder ι] [LocallyFiniteOrderBot ι]
335+
(hC : IsSetRing C) {s : ι → Set α} (hs : ∀ n, s n ∈ C) (n : ι) :
325336
partialSups s n ∈ C := by
326-
rw [partialSups_eq_biUnion_range]
327-
exact hC.biUnion_mem _ (fun n _ ↦ hs n)
328-
329-
lemma disjointed_mem (hC : IsSetRing C) {s : ℕ → Set α} (hs : ∀ n, s n ∈ C) (n : ℕ) :
330-
disjointed s n ∈ C := by
331-
cases n with
332-
| zero => exact hs 0
333-
| succ n => exact hC.diff_mem (hs n.succ) (hC.partialSups_mem hs n)
337+
simpa only [partialSups_apply, sup'_eq_sup] using hC.finsetSup_mem (fun i hi ↦ hs i)
338+
339+
lemma disjointed_mem {ι : Type*} [Preorder ι] [LocallyFiniteOrderBot ι]
340+
(hC : IsSetRing C) {s : ι → Set α} (hs : ∀ j, s j ∈ C) (i : ι) :
341+
disjointed s i ∈ C :=
342+
disjointedRec (fun _ j ht ↦ hC.diff_mem ht <| hs j) (hs i)
334343

335344
end IsSetRing
336345

0 commit comments

Comments
 (0)