Skip to content

Commit 561e9af

Browse files
JADekkerurkud
andcommitted
feat(Order/Filter) : add 2 constructors (#9200)
Add two constructors to create filters from a property on sets: - `Filter.comk` if the property is stable under finite unions and set shrinking. - `Filter.ofCountableUnion` if the property is stable under countable unions and set shrinking `Filter.comk` is the key ingredient in `IsCompact.induction_on` but may be convenient to have as individual building block. A `Filter` generated by `Filter.ofCountableUnion` is a `CountableInterFilter`, which is given by the instance `Filter.countableInter_ofCountableUnion`. ### Other changes - Use `Filter.comk` for `Filter.cofinite`, `Bornology.ofBounded` and `MeasureTheory.Measure.cofinite`. - Use `Filter.ofCountableUnion` for `MeasureTheory.Measure.ae`. - Use `{_ : Bornology _}` instead of `[Bornology _]` in some lemmas so that `rw/simp` work with non-instance bornologies. Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
1 parent 95f91f8 commit 561e9af

File tree

7 files changed

+70
-51
lines changed

7 files changed

+70
-51
lines changed

Mathlib/MeasureTheory/Measure/MeasureSpace.lean

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,15 +1878,9 @@ end Pointwise
18781878
/-! ### The `cofinite` filter -/
18791879

18801880
/-- The filter of sets `s` such that `sᶜ` has finite measure. -/
1881-
def cofinite {m0 : MeasurableSpace α} (μ : Measure α) : Filter α where
1882-
sets := { s | μ sᶜ < ∞ }
1883-
univ_sets := by simp
1884-
inter_sets {s t} hs ht := by
1885-
simp only [compl_inter, mem_setOf_eq]
1886-
calc
1887-
μ (sᶜ ∪ tᶜ) ≤ μ sᶜ + μ tᶜ := measure_union_le _ _
1888-
_ < ∞ := ENNReal.add_lt_top.2 ⟨hs, ht⟩
1889-
sets_of_superset {s t} hs hst := lt_of_le_of_lt (measure_mono <| compl_subset_compl.2 hst) hs
1881+
def cofinite {m0 : MeasurableSpace α} (μ : Measure α) : Filter α :=
1882+
comk (μ · < ∞) (by simp) (fun t ht s hs ↦ (measure_mono hs).trans_lt ht) fun s hs t ht ↦
1883+
(measure_union_le s t).trans_lt <| ENNReal.add_lt_top.2 ⟨hs, ht⟩
18901884
#align measure_theory.measure.cofinite MeasureTheory.Measure.cofinite
18911885

18921886
theorem mem_cofinite : s ∈ μ.cofinite ↔ μ sᶜ < ∞ :=

Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,10 @@ theorem measure_inter_null_of_null_left {S : Set α} (T : Set α) (h : μ S = 0)
363363

364364
/-! ### The almost everywhere filter -/
365365

366-
367366
/-- The “almost everywhere” filter of co-null sets. -/
368-
def Measure.ae {α} {m : MeasurableSpace α} (μ : Measure α) : Filter α where
369-
sets := { s | μ sᶜ = 0 }
370-
univ_sets := by simp
371-
inter_sets hs ht := by simp only [compl_inter, mem_setOf_eq]; exact measure_union_null hs ht
372-
sets_of_superset hs hst := measure_mono_null (Set.compl_subset_compl.2 hst) hs
367+
def Measure.ae {α : Type*} {_m : MeasurableSpace α} (μ : Measure α) : Filter α :=
368+
ofCountableUnion (μ · = 0) (fun _S hSc ↦ (measure_sUnion_null_iff hSc).2) fun _t ht _s hs ↦
369+
measure_mono_null hs ht
373370
#align measure_theory.measure.ae MeasureTheory.Measure.ae
374371

375372
-- mathport name: «expr∀ᵐ ∂ , »
@@ -415,11 +412,8 @@ theorem ae_of_all {p : α → Prop} (μ : Measure α) : (∀ a, p a) → ∀ᵐ
415412
-- ⟨fun s hs => let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs;
416413
-- ⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
417414

418-
instance instCountableInterFilter : CountableInterFilter μ.ae :=
419-
by
420-
intro S hSc hS
421-
rw [mem_ae_iff, compl_sInter, sUnion_image]
422-
exact (measure_biUnion_null_iff hSc).2 hS⟩
415+
instance instCountableInterFilter : CountableInterFilter μ.ae := by
416+
unfold Measure.ae; infer_instance
423417
#align measure_theory.measure.ae.countable_Inter_filter MeasureTheory.instCountableInterFilter
424418

425419
theorem ae_all_iff {ι : Sort*} [Countable ι] {p : α → ι → Prop} :

Mathlib/Order/Filter/Basic.lean

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,3 +3325,26 @@ theorem Set.MapsTo.tendsto {α β} {s : Set α} {t : Set β} {f : α → β} (h
33253325
Filter.Tendsto f (𝓟 s) (𝓟 t) :=
33263326
Filter.tendsto_principal_principal.2 h
33273327
#align set.maps_to.tendsto Set.MapsTo.tendsto
3328+
3329+
namespace Filter
3330+
3331+
/-- Construct a filter from a property that is stable under finite unions.
3332+
A set `s` belongs to `Filter.comk p _ _ _` iff its complement satisfies the predicate `p`.
3333+
This constructor is useful to define filters like `Filter.cofinite`. -/
3334+
def comk (p : Set α → Prop) (he : p ∅) (hmono : ∀ t, p t → ∀ s ⊆ t, p s)
3335+
(hunion : ∀ s, p s → ∀ t, p t → p (s ∪ t)) : Filter α where
3336+
sets := {t | p tᶜ}
3337+
univ_sets := by simpa
3338+
sets_of_superset := fun ht₁ ht => hmono _ ht₁ _ (compl_subset_compl.2 ht)
3339+
inter_sets := fun ht₁ ht₂ => by simp [compl_inter, hunion _ ht₁ _ ht₂]
3340+
3341+
@[simp]
3342+
lemma mem_comk {p : Set α → Prop} {he hmono hunion s} :
3343+
s ∈ comk p he hmono hunion ↔ p sᶜ :=
3344+
.rfl
3345+
3346+
lemma compl_mem_comk {p : Set α → Prop} {he hmono hunion s} :
3347+
sᶜ ∈ comk p he hmono hunion ↔ p s := by
3348+
simp
3349+
3350+
end Filter

Mathlib/Order/Filter/Cofinite.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ variable {ι α β : Type*} {l : Filter α}
2929
namespace Filter
3030

3131
/-- The cofinite filter is the filter of subsets whose complements are finite. -/
32-
def cofinite : Filter α where
33-
sets := { s | sᶜ.Finite }
34-
univ_sets := by simp only [compl_univ, finite_empty, mem_setOf_eq]
35-
sets_of_superset hs st := hs.subset <| compl_subset_compl.2 st
36-
inter_sets hs ht := by simpa only [compl_inter, mem_setOf_eq] using hs.union ht
32+
def cofinite : Filter α :=
33+
comk Set.Finite finite_empty (fun _t ht _s hsub ↦ ht.subset hsub) fun _ h _ ↦ h.union
3734
#align filter.cofinite Filter.cofinite
3835

3936
@[simp]

Mathlib/Order/Filter/CountableInter.lean

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,31 @@ theorem Filter.mem_ofCountableInter {l : Set (Set α)}
150150
Iff.rfl
151151
#align filter.mem_of_countable_Inter Filter.mem_ofCountableInter
152152

153+
/-- Construct a filter with countable intersection property.
154+
Similarly to `Filter.comk`, a set belongs to this filter if its complement satisfies the property.
155+
Similarly to `Filter.ofCountableInter`,
156+
this constructor deduces some properties from the countable intersection property
157+
which becomes the countable union property because we take complements of all sets.
158+
159+
Another small difference from `Filter.ofCountableInter`
160+
is that this definition takes `p : Set α → Prop` instead of `Set (Set α)`. -/
161+
def Filter.ofCountableUnion (p : Set α → Prop)
162+
(hUnion : ∀ S : Set (Set α), S.Countable → (∀ s ∈ S, p s) → p (⋃₀ S))
163+
(hmono : ∀ t, p t → ∀ s ⊆ t, p s) : Filter α := by
164+
refine .ofCountableInter {s | p sᶜ} (fun S hSc hSp ↦ ?_) fun s t ht hsub ↦ ?_
165+
· rw [mem_setOf_eq, compl_sInter]
166+
exact hUnion _ (hSc.image _) (ball_image_iff.2 hSp)
167+
· exact hmono _ ht _ (compl_subset_compl.2 hsub)
168+
169+
instance Filter.countableInter_ofCountableUnion (p : Set α → Prop) (h₁ h₂) :
170+
CountableInterFilter (Filter.ofCountableUnion p h₁ h₂) :=
171+
countableInter_ofCountableInter ..
172+
173+
@[simp]
174+
theorem Filter.mem_ofCountableUnion {p : Set α → Prop} {hunion hmono s} :
175+
s ∈ ofCountableUnion p hunion hmono ↔ p sᶜ :=
176+
Iff.rfl
177+
153178
instance countableInterFilter_principal (s : Set α) : CountableInterFilter (𝓟 s) :=
154179
fun _ _ hS => subset_sInter hS⟩
155180
#align countable_Inter_filter_principal countableInterFilter_principal

Mathlib/Topology/Bornology/Basic.lean

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,14 @@ def Bornology.ofBounded {α : Type*} (B : Set (Set α))
9494
(subset_mem : ∀ s₁ ∈ B, ∀ s₂ ⊆ s₁, s₂ ∈ B)
9595
(union_mem : ∀ s₁ ∈ B, ∀ s₂ ∈ B, s₁ ∪ s₂ ∈ B)
9696
(singleton_mem : ∀ x, {x} ∈ B) : Bornology α where
97-
cobounded' :=
98-
{ sets := { s : Set α | sᶜ ∈ B }
99-
univ_sets := by rwa [← compl_univ] at empty_mem
100-
sets_of_superset := fun hx hy => subset_mem _ hx _ (compl_subset_compl.mpr hy)
101-
inter_sets := fun hx hy => by simpa [compl_inter] using union_mem _ hx _ hy }
102-
le_cofinite' := by
103-
rw [le_cofinite_iff_compl_singleton_mem]
104-
intro x
105-
change {x}ᶜᶜ ∈ B
106-
rw [compl_compl]
107-
exact singleton_mem x
97+
cobounded' := comk (· ∈ B) empty_mem subset_mem union_mem
98+
le_cofinite' := by simpa [le_cofinite_iff_compl_singleton_mem]
10899
#align bornology.of_bounded Bornology.ofBounded
109-
#align bornology.of_bounded_cobounded_sets Bornology.ofBounded_cobounded_sets
100+
#align bornology.of_bounded_cobounded_sets Bornology.ofBounded_cobounded
110101

111102
/-- A constructor for bornologies by specifying the bounded sets,
112103
and showing that they satisfy the appropriate conditions. -/
113-
@[simps!]
104+
@[simps! cobounded]
114105
def Bornology.ofBounded' {α : Type*} (B : Set (Set α))
115106
(empty_mem : ∅ ∈ B)
116107
(subset_mem : ∀ s₁ ∈ B, ∀ s₂ ⊆ s₁, s₂ ∈ B)
@@ -122,24 +113,24 @@ def Bornology.ofBounded' {α : Type*} (B : Set (Set α))
122113
rcases sUnion_univ x with ⟨s, hs, hxs⟩
123114
exact subset_mem s hs {x} (singleton_subset_iff.mpr hxs)
124115
#align bornology.of_bounded' Bornology.ofBounded'
125-
#align bornology.of_bounded'_cobounded_sets Bornology.ofBounded'_cobounded_sets
116+
#align bornology.of_bounded'_cobounded_sets Bornology.ofBounded'_cobounded
126117
namespace Bornology
127118

128119
section
129120

130-
variable [Bornology α] {s t : Set α} {x : α}
131-
132121
/-- `IsCobounded` is the predicate that `s` is in the filter of cobounded sets in the ambient
133122
bornology on `α` -/
134-
def IsCobounded (s : Set α) : Prop :=
123+
def IsCobounded [Bornology α] (s : Set α) : Prop :=
135124
s ∈ cobounded α
136125
#align bornology.is_cobounded Bornology.IsCobounded
137126

138127
/-- `IsBounded` is the predicate that `s` is bounded relative to the ambient bornology on `α`. -/
139-
def IsBounded (s : Set α) : Prop :=
128+
def IsBounded [Bornology α] (s : Set α) : Prop :=
140129
IsCobounded sᶜ
141130
#align bornology.is_bounded Bornology.IsBounded
142131

132+
variable {_ : Bornology α} {s t : Set α} {x : α}
133+
143134
theorem isCobounded_def {s : Set α} : IsCobounded s ↔ s ∈ cobounded α :=
144135
Iff.rfl
145136
#align bornology.is_cobounded_def Bornology.isCobounded_def
@@ -263,9 +254,7 @@ theorem isCobounded_ofBounded_iff (B : Set (Set α)) {empty_mem subset_mem union
263254

264255
theorem isBounded_ofBounded_iff (B : Set (Set α)) {empty_mem subset_mem union_mem sUnion_univ} :
265256
@IsBounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s ↔ s ∈ B := by
266-
rw [@isBounded_def _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ), ← Filter.mem_sets,
267-
ofBounded_cobounded_sets, Set.mem_setOf_eq, compl_compl]
268-
-- porting note: again had to use `@isBounded_def _` and feed Lean the instance
257+
rw [isBounded_def, ofBounded_cobounded, compl_mem_comk]
269258
#align bornology.is_bounded_of_bounded_iff Bornology.isBounded_ofBounded_iff
270259

271260
variable [Bornology α]

Mathlib/Topology/Compactness/Compact.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Copyright (c) 2017 Johannes Hölzl. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov
55
-/
6+
import Mathlib.Order.Filter.Basic
67
import Mathlib.Topology.Bases
78
import Mathlib.Data.Set.Accumulate
89
import Mathlib.Topology.Bornology.Basic
@@ -69,11 +70,7 @@ theorem IsCompact.compl_mem_sets_of_nhdsWithin (hs : IsCompact s) {f : Filter X}
6970
theorem IsCompact.induction_on (hs : IsCompact s) {p : Set X → Prop} (he : p ∅)
7071
(hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hunion : ∀ ⦃s t⦄, p s → p t → p (s ∪ t))
7172
(hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by
72-
let f : Filter X :=
73-
{ sets := { t | p tᶜ }
74-
univ_sets := by simpa
75-
sets_of_superset := fun ht₁ ht => hmono (compl_subset_compl.2 ht) ht₁
76-
inter_sets := fun ht₁ ht₂ => by simp [compl_inter, hunion ht₁ ht₂] }
73+
let f : Filter X := comk p he (fun _t ht _s hsub ↦ hmono hsub ht) (fun _s hs _t ht ↦ hunion hs ht)
7774
have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa using hnhds)
7875
rwa [← compl_compl s]
7976
#align is_compact.induction_on IsCompact.induction_on

0 commit comments

Comments
 (0)