Skip to content

Commit 8992742

Browse files
committed
feat: port Order.Filter.CountableInter (#1803)
1 parent 03bffb6 commit 8992742

File tree

2 files changed

+203
-0
lines changed

2 files changed

+203
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ import Mathlib.Order.Directed
654654
import Mathlib.Order.Disjoint
655655
import Mathlib.Order.Extension.Linear
656656
import Mathlib.Order.Filter.Basic
657+
import Mathlib.Order.Filter.CountableInter
657658
import Mathlib.Order.Filter.Curry
658659
import Mathlib.Order.Filter.Extr
659660
import Mathlib.Order.Filter.Prod
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/-
2+
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yury G. Kudryashov
5+
6+
! This file was ported from Lean 3 source module order.filter.countable_Inter
7+
! leanprover-community/mathlib commit 8631e2d5ea77f6c13054d9151d82b83069680cb1
8+
! Please do not edit these lines, except to modify the commit id
9+
! if you have ported upstream changes.
10+
-/
11+
import Mathlib.Order.Filter.Basic
12+
import Mathlib.Data.Set.Countable
13+
14+
/-!
15+
# Filters with countable intersection property
16+
17+
In this file we define `CountableInterFilter` to be the class of filters with the following
18+
property: for any countable collection of sets `s ∈ l` their intersection belongs to `l` as well.
19+
20+
Two main examples are the `residual` filter defined in `Mathlib.Topology.MetricSpace.Baire` and
21+
the `measure.ae` filter defined in `measure_theory.measure_space`.
22+
23+
We reformulate the definition in terms of indexed intersection and in terms of `filter.eventually`
24+
and provide instances for some basic constructions (`⊥`, `⊤`, `Filter.principal`, `Filter.map`,
25+
`Filter.comap`, `HasInf.inf`). We also provide a custom constructor `Filter.ofCountableInter`
26+
that deduces two axioms of a `Filter` from the countable intersection property.
27+
28+
## Tags
29+
filter, countable
30+
-/
31+
32+
33+
open Set Filter
34+
35+
open Filter
36+
37+
variable {ι : Sort _} {α β : Type _}
38+
39+
/-- A filter `l` has the countable intersection property if for any countable collection
40+
of sets `s ∈ l` their intersection belongs to `l` as well. -/
41+
class CountableInterFilter (l : Filter α) : Prop where
42+
/-- For a countable collection of sets `s ∈ l`, their intersection belongs to `l` as well. -/
43+
countable_interₛ_mem : ∀ S : Set (Set α), S.Countable → (∀ s ∈ S, s ∈ l) → ⋂₀ S ∈ l
44+
#align countable_Inter_filter CountableInterFilter
45+
46+
variable {l : Filter α} [CountableInterFilter l]
47+
48+
theorem countable_interₛ_mem {S : Set (Set α)} (hSc : S.Countable) : ⋂₀ S ∈ l ↔ ∀ s ∈ S, s ∈ l :=
49+
fun hS _s hs => mem_of_superset hS (interₛ_subset_of_mem hs),
50+
CountableInterFilter.countable_interₛ_mem _ hSc⟩
51+
#align countable_sInter_mem countable_interₛ_mem
52+
53+
theorem countable_interᵢ_mem [Countable ι] {s : ι → Set α} : (⋂ i, s i) ∈ l ↔ ∀ i, s i ∈ l :=
54+
interₛ_range s ▸ (countable_interₛ_mem (countable_range _)).trans forall_range_iff
55+
#align countable_Inter_mem countable_interᵢ_mem
56+
57+
theorem countable_bInter_mem {ι : Type _} {S : Set ι} (hS : S.Countable) {s : ∀ i ∈ S, Set α} :
58+
(⋂ i, ⋂ hi : i ∈ S, s i ‹_›) ∈ l ↔ ∀ i, ∀ hi : i ∈ S, s i ‹_› ∈ l := by
59+
rw [binterᵢ_eq_interᵢ]
60+
haveI := hS.toEncodable
61+
exact countable_interᵢ_mem.trans Subtype.forall
62+
#align countable_bInter_mem countable_bInter_mem
63+
64+
theorem eventually_countable_forall [Countable ι] {p : α → ι → Prop} :
65+
(∀ᶠ x in l, ∀ i, p x i) ↔ ∀ i, ∀ᶠ x in l, p x i := by
66+
simpa only [Filter.Eventually, setOf_forall] using
67+
@countable_interᵢ_mem _ _ l _ _ fun i => { x | p x i }
68+
#align eventually_countable_forall eventually_countable_forall
69+
70+
theorem eventually_countable_ball {ι : Type _} {S : Set ι} (hS : S.Countable)
71+
{p : α → ∀ i ∈ S, Prop} :
72+
(∀ᶠ x in l, ∀ i hi, p x i hi) ↔ ∀ i hi, ∀ᶠ x in l, p x i hi := by
73+
simpa only [Filter.Eventually, setOf_forall] using
74+
@countable_bInter_mem _ l _ _ _ hS fun i hi => { x | p x i hi }
75+
#align eventually_countable_ball eventually_countable_ball
76+
77+
theorem EventuallyLe.countable_unionᵢ [Countable ι] {s t : ι → Set α} (h : ∀ i, s i ≤ᶠ[l] t i) :
78+
(⋃ i, s i) ≤ᶠ[l] ⋃ i, t i :=
79+
(eventually_countable_forall.2 h).mono fun _ hst hs => mem_unionᵢ.2 <| (mem_unionᵢ.1 hs).imp hst
80+
#align eventually_le.countable_Union EventuallyLe.countable_unionᵢ
81+
82+
theorem EventuallyEq.countable_unionᵢ [Countable ι] {s t : ι → Set α} (h : ∀ i, s i =ᶠ[l] t i) :
83+
(⋃ i, s i) =ᶠ[l] ⋃ i, t i :=
84+
(EventuallyLe.countable_unionᵢ fun i => (h i).le).antisymm
85+
(EventuallyLe.countable_unionᵢ fun i => (h i).symm.le)
86+
#align eventually_eq.countable_Union EventuallyEq.countable_unionᵢ
87+
88+
theorem EventuallyLe.countable_bUnion {ι : Type _} {S : Set ι} (hS : S.Countable)
89+
{s t : ∀ i ∈ S, Set α} (h : ∀ i hi, s i hi ≤ᶠ[l] t i hi) :
90+
(⋃ i ∈ S, s i ‹_›) ≤ᶠ[l] ⋃ i ∈ S, t i ‹_› := by
91+
simp only [bunionᵢ_eq_unionᵢ]
92+
haveI := hS.toEncodable
93+
exact EventuallyLe.countable_unionᵢ fun i => h i i.2
94+
#align eventually_le.countable_bUnion EventuallyLe.countable_bUnion
95+
96+
theorem EventuallyEq.countable_bUnion {ι : Type _} {S : Set ι} (hS : S.Countable)
97+
{s t : ∀ i ∈ S, Set α} (h : ∀ i hi, s i hi =ᶠ[l] t i hi) :
98+
(⋃ i ∈ S, s i ‹_›) =ᶠ[l] ⋃ i ∈ S, t i ‹_› :=
99+
(EventuallyLe.countable_bUnion hS fun i hi => (h i hi).le).antisymm
100+
(EventuallyLe.countable_bUnion hS fun i hi => (h i hi).symm.le)
101+
#align eventually_eq.countable_bUnion EventuallyEq.countable_bUnion
102+
103+
theorem EventuallyLe.countable_interᵢ [Countable ι] {s t : ι → Set α} (h : ∀ i, s i ≤ᶠ[l] t i) :
104+
(⋂ i, s i) ≤ᶠ[l] ⋂ i, t i :=
105+
(eventually_countable_forall.2 h).mono fun _ hst hs =>
106+
mem_interᵢ.2 fun i => hst _ (mem_interᵢ.1 hs i)
107+
#align eventually_le.countable_Inter EventuallyLe.countable_interᵢ
108+
109+
theorem EventuallyEq.countable_interᵢ [Countable ι] {s t : ι → Set α} (h : ∀ i, s i =ᶠ[l] t i) :
110+
(⋂ i, s i) =ᶠ[l] ⋂ i, t i :=
111+
(EventuallyLe.countable_interᵢ fun i => (h i).le).antisymm
112+
(EventuallyLe.countable_interᵢ fun i => (h i).symm.le)
113+
#align eventually_eq.countable_Inter EventuallyEq.countable_interᵢ
114+
115+
theorem EventuallyLe.countable_bInter {ι : Type _} {S : Set ι} (hS : S.Countable)
116+
{s t : ∀ i ∈ S, Set α} (h : ∀ i hi, s i hi ≤ᶠ[l] t i hi) :
117+
(⋂ i ∈ S, s i ‹_›) ≤ᶠ[l] ⋂ i ∈ S, t i ‹_› := by
118+
simp only [binterᵢ_eq_interᵢ]
119+
haveI := hS.toEncodable
120+
exact EventuallyLe.countable_interᵢ fun i => h i i.2
121+
#align eventually_le.countable_bInter EventuallyLe.countable_bInter
122+
123+
theorem EventuallyEq.countable_bInter {ι : Type _} {S : Set ι} (hS : S.Countable)
124+
{s t : ∀ i ∈ S, Set α} (h : ∀ i hi, s i hi =ᶠ[l] t i hi) :
125+
(⋂ i ∈ S, s i ‹_›) =ᶠ[l] ⋂ i ∈ S, t i ‹_› :=
126+
(EventuallyLe.countable_bInter hS fun i hi => (h i hi).le).antisymm
127+
(EventuallyLe.countable_bInter hS fun i hi => (h i hi).symm.le)
128+
#align eventually_eq.countable_bInter EventuallyEq.countable_bInter
129+
130+
/-- Construct a filter with countable intersection property. This constructor deduces
131+
`Filter.univ_sets` and `Filter.inter_sets` from the countable intersection property. -/
132+
def Filter.ofCountableInter (l : Set (Set α))
133+
(hp : ∀ S : Set (Set α), S.Countable → S ⊆ l → ⋂₀ S ∈ l)
134+
(h_mono : ∀ s t, s ∈ l → s ⊆ t → t ∈ l) : Filter α
135+
where
136+
sets := l
137+
univ_sets := @interₛ_empty α ▸ hp _ countable_empty (empty_subset _)
138+
sets_of_superset := h_mono _ _
139+
inter_sets {s t} hs ht := interₛ_pair s t ▸
140+
hp _ ((countable_singleton _).insert _) (insert_subset.2 ⟨hs, singleton_subset_iff.2 ht⟩)
141+
#align filter.of_countable_Inter Filter.ofCountableInter
142+
143+
instance Filter.countable_Inter_ofCountableInter (l : Set (Set α))
144+
(hp : ∀ S : Set (Set α), S.Countable → S ⊆ l → ⋂₀ S ∈ l)
145+
(h_mono : ∀ s t, s ∈ l → s ⊆ t → t ∈ l) :
146+
CountableInterFilter (Filter.ofCountableInter l hp h_mono) :=
147+
⟨hp⟩
148+
#align filter.countable_Inter_of_countable_Inter Filter.countable_Inter_ofCountableInter
149+
150+
@[simp]
151+
theorem Filter.mem_ofCountableInter {l : Set (Set α)}
152+
(hp : ∀ S : Set (Set α), S.Countable → S ⊆ l → ⋂₀ S ∈ l) (h_mono : ∀ s t, s ∈ l → s ⊆ t → t ∈ l)
153+
{s : Set α} : s ∈ Filter.ofCountableInter l hp h_mono ↔ s ∈ l :=
154+
Iff.rfl
155+
#align filter.mem_of_countable_Inter Filter.mem_ofCountableInter
156+
157+
instance countableInterFilter_principal (s : Set α) : CountableInterFilter (𝓟 s) :=
158+
fun _ _ hS => subset_interₛ hS⟩
159+
#align countable_Inter_filter_principal countableInterFilter_principal
160+
161+
instance countableInterFilter_bot : CountableInterFilter (⊥ : Filter α) := by
162+
rw [← principal_empty]
163+
apply countableInterFilter_principal
164+
#align countable_Inter_filter_bot countableInterFilter_bot
165+
166+
instance countableInterFilter_top : CountableInterFilter (⊤ : Filter α) := by
167+
rw [← principal_univ]
168+
apply countableInterFilter_principal
169+
#align countable_Inter_filter_top countableInterFilter_top
170+
171+
instance (l : Filter β) [CountableInterFilter l] (f : α → β) :
172+
CountableInterFilter (comap f l) := by
173+
refine' ⟨fun S hSc hS => _⟩
174+
choose! t htl ht using hS
175+
have : (⋂ s ∈ S, t s) ∈ l := (countable_bInter_mem hSc).2 htl
176+
refine' ⟨_, this, _⟩
177+
simpa [preimage_interᵢ] using interᵢ₂_mono ht
178+
179+
instance (l : Filter α) [CountableInterFilter l] (f : α → β) : CountableInterFilter (map f l) := by
180+
refine' ⟨fun S hSc hS => _⟩
181+
simp only [mem_map, interₛ_eq_binterᵢ, preimage_interᵢ₂] at hS⊢
182+
exact (countable_bInter_mem hSc).2 hS
183+
184+
/-- Infimum of two `countable_Inter_filter`s is a `countable_Inter_filter`. This is useful, e.g.,
185+
to automatically get an instance for `residual α ⊓ 𝓟 s`. -/
186+
instance countableInterFilter_inf (l₁ l₂ : Filter α) [CountableInterFilter l₁]
187+
[CountableInterFilter l₂] : CountableInterFilter (l₁ ⊓ l₂) := by
188+
refine' ⟨fun S hSc hS => _⟩
189+
choose s hs t ht hst using hS
190+
replace hs : (⋂ i ∈ S, s i ‹_›) ∈ l₁ := (countable_bInter_mem hSc).2 hs
191+
replace ht : (⋂ i ∈ S, t i ‹_›) ∈ l₂ := (countable_bInter_mem hSc).2 ht
192+
refine' mem_of_superset (inter_mem_inf hs ht) (subset_interₛ fun i hi => _)
193+
rw [hst i hi]
194+
apply inter_subset_inter <;> exact interᵢ_subset_of_subset i (interᵢ_subset _ _)
195+
#align countable_Inter_filter_inf countableInterFilter_inf
196+
197+
/-- Supremum of two `countable_Inter_filter`s is a `countable_Inter_filter`. -/
198+
instance countableInterFilter_sup (l₁ l₂ : Filter α) [CountableInterFilter l₁]
199+
[CountableInterFilter l₂] : CountableInterFilter (l₁ ⊔ l₂) := by
200+
refine' ⟨fun S hSc hS => ⟨_, _⟩⟩ <;> refine' (countable_interₛ_mem hSc).2 fun s hs => _
201+
exacts[(hS s hs).1, (hS s hs).2]
202+
#align countable_Inter_filter_sup countableInterFilter_sup

0 commit comments

Comments
 (0)