Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 78ea75a

Browse files
committed
feat(order/filter/cofinite): add lemmas, golf (#13394)
* add `filter.comap_le_cofinite`, `function.injective.comap_cofinite_eq`, and `filter.has_basis.coprod`; * rename `at_top_le_cofinite` to `filter.at_top_le_cofinite`; * golf `filter.coprod_cofinite` and `filter.Coprod_cofinite`, move them below `filter.comap_cofinite_le`;
1 parent da4ec7e commit 78ea75a

File tree

2 files changed

+64
-63
lines changed

2 files changed

+64
-63
lines changed

src/order/filter/bases.lean

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,16 @@ begin
702702
{ intros i j,
703703
simp only [true_and, forall_true_left],
704704
exact ⟨max i j, hf.antitone (le_max_left _ _), hg.antitone (le_max_right _ _)⟩, },
705-
refine ⟨h, λ n m hn_le_m, _⟩,
706-
intros x hx,
707-
rw mem_prod at hx ⊢,
708-
exact ⟨hf.antitone hn_le_m hx.1, hg.antitone hn_le_m hx.2⟩,
705+
refine ⟨h, λ n m hn_le_m, set.prod_mono _ _⟩,
706+
exacts [hf.antitone hn_le_m, hg.antitone hn_le_m]
709707
end
710708

709+
lemma has_basis.coprod {ι ι' : Type*} {pa : ι → Prop} {sa : ι → set α} {pb : ι' → Prop}
710+
{sb : ι' → set β} (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :
711+
(la.coprod lb).has_basis (λ i : ι × ι', pa i.1 ∧ pb i.2)
712+
(λ i, prod.fst ⁻¹' sa i.1 ∪ prod.snd ⁻¹' sb i.2) :=
713+
(hla.comap prod.fst).sup (hlb.comap prod.snd)
714+
711715
end two_types
712716

713717
open equiv

src/order/filter/cofinite.lean

Lines changed: 56 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Define filters for other cardinalities of the complement.
2323
open set function
2424
open_locale classical
2525

26-
variables {α : Type*}
26+
variables {ι α β : Type*}
2727

2828
namespace filter
2929

@@ -52,76 +52,67 @@ lemma frequently_cofinite_iff_infinite {p : α → Prop} :
5252
by simp only [filter.frequently, filter.eventually, mem_cofinite, compl_set_of, not_not,
5353
set.infinite]
5454

55-
/-- The coproduct of the cofinite filters on two types is the cofinite filter on their product. -/
56-
lemma coprod_cofinite {β : Type*} :
57-
(cofinite : filter α).coprod (cofinite : filter β) = cofinite :=
58-
begin
59-
ext S,
60-
simp only [mem_coprod_iff, exists_prop, mem_comap, mem_cofinite],
61-
split,
62-
{ rintro ⟨⟨A, hAf, hAS⟩, B, hBf, hBS⟩,
63-
rw [← compl_subset_compl, ← preimage_compl] at hAS hBS,
64-
exact (hAf.prod hBf).subset (subset_inter hAS hBS) },
65-
{ intro hS,
66-
refine ⟨⟨(prod.fst '' Sᶜ)ᶜ, _, _⟩, ⟨(prod.snd '' Sᶜ)ᶜ, _, _⟩⟩,
67-
{ simpa using hS.image prod.fst },
68-
{ simpa [compl_subset_comm] using subset_preimage_image prod.fst Sᶜ },
69-
{ simpa using hS.image prod.snd },
70-
{ simpa [compl_subset_comm] using subset_preimage_image prod.snd Sᶜ } },
71-
end
72-
73-
/-- Finite product of finite sets is finite -/
74-
lemma Coprod_cofinite {δ : Type*} {κ : δ → Type*} [fintype δ] :
75-
filter.Coprod (λ d, (cofinite : filter (κ d))) = cofinite :=
76-
begin
77-
ext S,
78-
rcases compl_surjective S with ⟨S, rfl⟩,
79-
simp_rw [compl_mem_Coprod_iff, mem_cofinite, compl_compl],
80-
split,
81-
{ rintro ⟨t, htf, hsub⟩,
82-
exact (finite.pi htf).subset hsub },
83-
{ exact λ hS, ⟨λ i, eval i '' S, λ i, hS.image _, subset_pi_eval_image _ _⟩ }
84-
end
85-
86-
end filter
87-
88-
open filter
89-
90-
lemma set.finite.compl_mem_cofinite {s : set α} (hs : s.finite) : sᶜ ∈ (@cofinite α) :=
55+
lemma _root_.set.finite.compl_mem_cofinite {s : set α} (hs : s.finite) : sᶜ ∈ (@cofinite α) :=
9156
mem_cofinite.2 $ (compl_compl s).symm ▸ hs
9257

93-
lemma set.finite.eventually_cofinite_nmem {s : set α} (hs : s.finite) : ∀ᶠ x in cofinite, x ∉ s :=
58+
lemma _root_.set.finite.eventually_cofinite_nmem {s : set α} (hs : s.finite) :
59+
∀ᶠ x in cofinite, x ∉ s :=
9460
hs.compl_mem_cofinite
9561

96-
lemma finset.eventually_cofinite_nmem (s : finset α) : ∀ᶠ x in cofinite, x ∉ s :=
62+
lemma _root_.finset.eventually_cofinite_nmem (s : finset α) : ∀ᶠ x in cofinite, x ∉ s :=
9763
s.finite_to_set.eventually_cofinite_nmem
9864

99-
lemma set.infinite_iff_frequently_cofinite {s : set α} :
65+
lemma _root_.set.infinite_iff_frequently_cofinite {s : set α} :
10066
set.infinite s ↔ (∃ᶠ x in cofinite, x ∈ s) :=
10167
frequently_cofinite_iff_infinite.symm
10268

103-
lemma filter.eventually_cofinite_ne (x : α) : ∀ᶠ a in cofinite, a ≠ x :=
69+
lemma eventually_cofinite_ne (x : α) : ∀ᶠ a in cofinite, a ≠ x :=
10470
(set.finite_singleton x).eventually_cofinite_nmem
10571

106-
lemma filter.le_cofinite_iff_compl_singleton_mem {l : filter α} :
72+
lemma le_cofinite_iff_compl_singleton_mem {l : filter α} :
10773
l ≤ cofinite ↔ ∀ x, {x}ᶜ ∈ l :=
10874
begin
10975
refine ⟨λ h x, h (finite_singleton x).compl_mem_cofinite, λ h s (hs : sᶜ.finite), _⟩,
11076
rw [← compl_compl s, ← bUnion_of_singleton sᶜ, compl_Union₂,filter.bInter_mem hs],
11177
exact λ x _, h x
11278
end
11379

114-
/-- If `α` is a sup-semilattice with no maximal element, then `at_top ≤ cofinite`. -/
115-
lemma at_top_le_cofinite [semilattice_sup α] [no_max_order α] : (at_top : filter α) ≤ cofinite :=
80+
lemma le_cofinite_iff_eventually_ne {l : filter α} :
81+
l ≤ cofinite ↔ ∀ x, ∀ᶠ y in l, y ≠ x :=
82+
le_cofinite_iff_compl_singleton_mem
83+
84+
/-- If `α` is a preorder with no maximal element, then `at_top ≤ cofinite`. -/
85+
lemma at_top_le_cofinite [preorder α] [no_max_order α] : (at_top : filter α) ≤ cofinite :=
86+
le_cofinite_iff_eventually_ne.mpr eventually_ne_at_top
87+
88+
lemma comap_cofinite_le (f : α → β) : comap f cofinite ≤ cofinite :=
89+
le_cofinite_iff_eventually_ne.mpr $ λ x,
90+
mem_comap.2 ⟨{f x}ᶜ, (finite_singleton _).compl_mem_cofinite, λ y, ne_of_apply_ne f⟩
91+
92+
/-- The coproduct of the cofinite filters on two types is the cofinite filter on their product. -/
93+
lemma coprod_cofinite : (cofinite : filter α).coprod (cofinite : filter β) = cofinite :=
94+
begin
95+
refine le_antisymm (sup_le (comap_cofinite_le _) (comap_cofinite_le _)) (λ S, _),
96+
simp only [mem_coprod_iff, exists_prop, mem_comap, mem_cofinite],
97+
rintro ⟨⟨A, hAf, hAS⟩, B, hBf, hBS⟩,
98+
rw [← compl_subset_compl, ← preimage_compl] at hAS hBS,
99+
exact (hAf.prod hBf).subset (subset_inter hAS hBS)
100+
end
101+
102+
/-- Finite product of finite sets is finite -/
103+
lemma Coprod_cofinite {α : ι → Type*} [fintype ι] :
104+
filter.Coprod (λ i, (cofinite : filter (α i))) = cofinite :=
116105
begin
117-
refine compl_surjective.forall.2 (λ s hs, _),
118-
rcases eq_empty_or_nonempty s with rfl|hne, { simp only [compl_empty, univ_mem] },
119-
rw [mem_cofinite, compl_compl] at hs, lift s to finset α using hs,
120-
rcases exists_gt (s.sup' hne id) with ⟨y, hy⟩,
121-
filter_upwards [mem_at_top y] with x hx hxs,
122-
exact (finset.le_sup' id hxs).not_lt (hy.trans_le hx)
106+
refine le_antisymm (supr_le $ λ i, comap_cofinite_le _) (compl_surjective.forall.2 $ λ S, _),
107+
simp_rw [compl_mem_Coprod_iff, mem_cofinite, compl_compl],
108+
rintro ⟨t, htf, hsub⟩,
109+
exact (finite.pi htf).subset hsub
123110
end
124111

112+
end filter
113+
114+
open filter
115+
125116
/-- For natural numbers the filters `cofinite` and `at_top` coincide. -/
126117
lemma nat.cofinite_eq_at_top : @cofinite ℕ = at_top :=
127118
begin
@@ -132,7 +123,7 @@ end
132123

133124
lemma nat.frequently_at_top_iff_infinite {p : ℕ → Prop} :
134125
(∃ᶠ n in at_top, p n) ↔ set.infinite {n | p n} :=
135-
by simp only [← nat.cofinite_eq_at_top, frequently_cofinite_iff_infinite]
126+
by rw [← nat.cofinite_eq_at_top, frequently_cofinite_iff_infinite]
136127

137128
lemma filter.tendsto.exists_within_forall_le {α β : Type*} [linear_order β] {s : set α}
138129
(hs : s.nonempty)
@@ -153,27 +144,33 @@ begin
153144
exact ⟨a₀, ha₀s, λ a ha, not_all_top a ha (f a₀)⟩ }
154145
end
155146

156-
lemma filter.tendsto.exists_forall_le {α β : Type*} [nonempty α] [linear_order β]
157-
{f : α → β} (hf : tendsto f cofinite at_top) :
147+
lemma filter.tendsto.exists_forall_le [nonempty α] [linear_order β] {f : α → β}
148+
(hf : tendsto f cofinite at_top) :
158149
∃ a₀, ∀ a, f a₀ ≤ f a :=
159150
let ⟨a₀, _, ha₀⟩ := hf.exists_within_forall_le univ_nonempty in ⟨a₀, λ a, ha₀ a (mem_univ _)⟩
160151

161-
lemma filter.tendsto.exists_within_forall_ge {α β : Type*} [linear_order β] {s : set α}
162-
(hs : s.nonempty)
152+
lemma filter.tendsto.exists_within_forall_ge [linear_order β] {s : set α} (hs : s.nonempty)
163153
{f : α → β} (hf : filter.tendsto f filter.cofinite filter.at_bot) :
164154
∃ a₀ ∈ s, ∀ a ∈ s, f a ≤ f a₀ :=
165155
@filter.tendsto.exists_within_forall_le _ (order_dual β) _ _ hs _ hf
166156

167-
lemma filter.tendsto.exists_forall_ge {α β : Type*} [nonempty α] [linear_order β]
168-
{f : α → β} (hf : tendsto f cofinite at_bot) :
157+
lemma filter.tendsto.exists_forall_ge [nonempty α] [linear_order β] {f : α → β}
158+
(hf : tendsto f cofinite at_bot) :
169159
∃ a₀, ∀ a, f a ≤ f a₀ :=
170160
@filter.tendsto.exists_forall_le _ (order_dual β) _ _ _ hf
171161

172-
/-- For an injective function `f`, inverse images of finite sets are finite. -/
173-
lemma function.injective.tendsto_cofinite {α β : Type*} {f : α → β} (hf : injective f) :
162+
/-- For an injective function `f`, inverse images of finite sets are finite. See also
163+
`filter.comap_cofinite_le` and `function.injective.comap_cofinite_eq`. -/
164+
lemma function.injective.tendsto_cofinite {f : α → β} (hf : injective f) :
174165
tendsto f cofinite cofinite :=
175166
λ s h, h.preimage (hf.inj_on _)
176167

168+
/-- The pullback of the `filter.cofinite` under an injective function is equal to `filter.cofinite`.
169+
See also `filter.comap_cofinite_le` and `function.injective.tendsto_cofinite`. -/
170+
lemma function.injective.comap_cofinite_eq {f : α → β} (hf : injective f) :
171+
comap f cofinite = cofinite :=
172+
(comap_cofinite_le f).antisymm hf.tendsto_cofinite.le_comap
173+
177174
/-- An injective sequence `f : ℕ → ℕ` tends to infinity at infinity. -/
178175
lemma function.injective.nat_tendsto_at_top {f : ℕ → ℕ} (hf : injective f) :
179176
tendsto f at_top at_top :=

0 commit comments

Comments
 (0)