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

Commit 79df8cc

Browse files
committed
refactor(order/filter/at_top): import order.filter.bases (#3523)
This way we can use facts about `filter.has_basis` in `filter.at_top`. Also generalize `is_countably_generated_at_top_finset_nat` to `at_top` filter on any `encodable` type.
1 parent d974457 commit 79df8cc

File tree

2 files changed

+97
-110
lines changed

2 files changed

+97
-110
lines changed

src/order/filter/at_top_bot.lean

Lines changed: 91 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +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, Jeremy Avigad, Yury Kudryashov, Patrick Massot
55
-/
6-
import order.filter.basic
6+
import order.filter.bases
77

88
/-!
99
# `at_top` and `at_bot` filters on preorded sets, monoids and groups.
@@ -46,23 +46,24 @@ mem_infi_sets a $ subset.refl _
4646
lemma Iio_mem_at_bot [preorder α] [no_bot_order α] (x : α) : Iio x ∈ (at_bot : filter α) :=
4747
let ⟨z, hz⟩ := no_bot x in mem_sets_of_superset (mem_at_bot z) $ λ y h, lt_of_le_of_lt h hz
4848

49+
lemma at_top_basis [hα : nonempty α] [semilattice_sup α] :
50+
(@at_top α _).has_basis (λ _, true) Ici :=
51+
has_basis_infi_principal (directed_of_sup $ λ a b, Ici_subset_Ici.2) hα
52+
53+
lemma at_top_basis' [semilattice_sup α] (a : α) :
54+
(@at_top α _).has_basis (λ x, a ≤ x) Ici :=
55+
⟨λ t, (@at_top_basis α ⟨a⟩ _).mem_iff.trans
56+
⟨λ ⟨x, _, hx⟩, ⟨x ⊔ a, le_sup_right, λ y hy, hx (le_trans le_sup_left hy)⟩,
57+
λ ⟨x, _, hx⟩, ⟨x, trivial, hx⟩⟩⟩
58+
4959
@[instance]
5060
lemma at_top_ne_bot [nonempty α] [semilattice_sup α] : ne_bot (at_top : filter α) :=
51-
infi_ne_bot_of_directed
52-
(assume a b, ⟨a ⊔ b, by simp only [ge, le_principal_iff, forall_const, set_of_subset_set_of,
53-
mem_principal_sets, and_self, sup_le_iff, forall_true_iff] {contextual := tt}⟩)
54-
(assume a, principal_ne_bot_iff.2 nonempty_Ici)
61+
at_top_basis.forall_nonempty_iff_ne_bot.1 $ λ a _, nonempty_Ici
5562

5663
@[simp, nolint ge_or_gt]
5764
lemma mem_at_top_sets [nonempty α] [semilattice_sup α] {s : set α} :
5865
s ∈ (at_top : filter α) ↔ ∃a:α, ∀b≥a, b ∈ s :=
59-
let ⟨a⟩ := ‹nonempty α› in
60-
iff.intro
61-
(assume h, infi_sets_induct h ⟨a, by simp only [forall_const, mem_univ, forall_true_iff]⟩
62-
(assume a s₁ s₂ ha ⟨b, hb⟩, ⟨a ⊔ b,
63-
assume c hc, ⟨ha $ le_trans le_sup_left hc, hb _ $ le_trans le_sup_right hc⟩⟩)
64-
(assume s₁ s₂ h ⟨a, ha⟩, ⟨a, assume b hb, h $ ha _ hb⟩))
65-
(assume ⟨a, h⟩, mem_infi_sets a $ assume x, h x)
66+
at_top_basis.mem_iff.trans $ exists_congr $ λ _, exists_const _
6667

6768
@[simp, nolint ge_or_gt]
6869
lemma eventually_at_top [semilattice_sup α] [nonempty α] {p : α → Prop} :
@@ -71,6 +72,11 @@ mem_at_top_sets
7172

7273
lemma eventually_ge_at_top [preorder α] (a : α) : ∀ᶠ x in at_top, a ≤ x := mem_at_top a
7374

75+
lemma at_top_countable_basis [nonempty α] [semilattice_sup α] [encodable α] :
76+
has_countable_basis (at_top : filter α) (λ _, true) Ici :=
77+
{ countable := countable_encodable _,
78+
.. at_top_basis }
79+
7480
lemma order_top.at_top_eq (α) [order_top α] : (at_top : filter α) = pure ⊤ :=
7581
le_antisymm (le_pure_iff.2 $ (eventually_ge_at_top ⊤).mono $ λ b, top_unique)
7682
(le_infi $ λ b, le_principal_iff.2 le_top)
@@ -109,11 +115,7 @@ frequently_at_top.mp h
109115

110116
lemma map_at_top_eq [nonempty α] [semilattice_sup α] {f : α → β} :
111117
at_top.map f = (⨅a, 𝓟 $ f '' {a' | a ≤ a'}) :=
112-
calc map f (⨅a, 𝓟 {a' | a ≤ a'}) = (⨅a, map f $ 𝓟 {a' | a ≤ a'}) :
113-
map_infi_eq (assume a b, ⟨a ⊔ b, by simp only [ge, le_principal_iff, forall_const, set_of_subset_set_of,
114-
mem_principal_sets, and_self, sup_le_iff, forall_true_iff] {contextual := tt}⟩)
115-
(by apply_instance)
116-
... = (⨅a, 𝓟 $ f '' {a' | a ≤ a'}) : by simp only [map_principal, eq_self_iff_true]
118+
(at_top_basis.map _).eq_infi
117119

118120
lemma tendsto_at_top [preorder β] (m : α → β) (f : filter α) :
119121
tendsto m f at_top ↔ (∀b, ∀ᶠ a in f, b ≤ m a) :=
@@ -558,6 +560,78 @@ by rw [map_at_top_eq, map_at_top_eq];
558560
from (le_infi $ assume b, let ⟨v, hv⟩ := h_eq b in infi_le_of_le v $
559561
by simp [set.image_subset_iff]; exact hv)
560562

563+
lemma has_antimono_basis.tendsto [semilattice_sup ι] [nonempty ι] {l : filter α}
564+
{p : ι → Prop} {s : ι → set α} (hl : l.has_antimono_basis p s) {φ : ι → α}
565+
(h : ∀ i : ι, φ i ∈ s i) : tendsto φ at_top l :=
566+
begin
567+
rw hl.to_has_basis.tendsto_right_iff,
568+
intros i hi,
569+
rw eventually_at_top,
570+
exact ⟨i, λ j hij, hl.decreasing hi (hl.mono hij hi) hij (h j)⟩,
571+
end
572+
573+
namespace is_countably_generated
574+
575+
/-- An abstract version of continuity of sequentially continuous functions on metric spaces:
576+
if a filter `k` is countably generated then `tendsto f k l` iff for every sequence `u`
577+
converging to `k`, `f ∘ u` tends to `l`. -/
578+
lemma tendsto_iff_seq_tendsto {f : α → β} {k : filter α} {l : filter β}
579+
(hcb : k.is_countably_generated) :
580+
tendsto f k l ↔ (∀ x : ℕ → α, tendsto x at_top k → tendsto (f ∘ x) at_top l) :=
581+
suffices (∀ x : ℕ → α, tendsto x at_top k → tendsto (f ∘ x) at_top l) → tendsto f k l,
582+
fromby intros; apply tendsto.comp; assumption, by assumption⟩,
583+
begin
584+
rcases hcb.exists_antimono_seq with ⟨g, gmon, gbasis⟩,
585+
have gbasis : ∀ A, A ∈ k ↔ ∃ i, g i ⊆ A,
586+
{ intro A,
587+
subst gbasis,
588+
rw mem_infi,
589+
{ simp only [set.mem_Union, iff_self, filter.mem_principal_sets] },
590+
{ exact directed_of_sup (λ i j h, principal_mono.mpr $ gmon _ _ h) },
591+
{ apply_instance } },
592+
classical, contrapose,
593+
simp only [not_forall, not_imp, not_exists, subset_def, @tendsto_def _ _ f, gbasis],
594+
rintro ⟨B, hBl, hfBk⟩,
595+
choose x h using hfBk,
596+
use x, split,
597+
{ simp only [tendsto_at_top', gbasis],
598+
rintros A ⟨i, hgiA⟩,
599+
use i,
600+
refine (λ j hj, hgiA $ gmon _ _ hj _),
601+
simp only [h] },
602+
{ simp only [tendsto_at_top', (∘), not_forall, not_exists],
603+
use [B, hBl],
604+
intro i, use [i, (le_refl _)],
605+
apply (h i).right },
606+
end
607+
608+
lemma tendsto_of_seq_tendsto {f : α → β} {k : filter α} {l : filter β}
609+
(hcb : k.is_countably_generated) :
610+
(∀ x : ℕ → α, tendsto x at_top k → tendsto (f ∘ x) at_top l) → tendsto f k l :=
611+
hcb.tendsto_iff_seq_tendsto.2
612+
613+
lemma subseq_tendsto {f : filter α} (hf : is_countably_generated f)
614+
{u : ℕ → α}
615+
(hx : ne_bot (f ⊓ map u at_top)) :
616+
∃ (θ : ℕ → ℕ), (strict_mono θ) ∧ (tendsto (u ∘ θ) at_top f) :=
617+
begin
618+
rcases hf.has_antimono_basis with ⟨B, h⟩,
619+
have : ∀ N, ∃ n ≥ N, u n ∈ B N,
620+
from λ N, filter.inf_map_at_top_ne_bot_iff.mp hx _ (h.to_has_basis.mem_of_mem trivial) N,
621+
choose φ hφ using this,
622+
cases forall_and_distrib.mp hφ with φ_ge φ_in,
623+
have lim_uφ : tendsto (u ∘ φ) at_top f,
624+
from h.tendsto φ_in,
625+
have lim_φ : tendsto φ at_top at_top,
626+
from (tendsto_at_top_mono φ_ge tendsto_id),
627+
obtain ⟨ψ, hψ, hψφ⟩ : ∃ ψ : ℕ → ℕ, strict_mono ψ ∧ strict_mono (φ ∘ ψ),
628+
from strict_mono_subseq_of_tendsto_at_top lim_φ,
629+
exact ⟨φ ∘ ψ, hψφ, lim_uφ.comp $ strict_mono_tendsto_at_top hψ⟩,
630+
end
631+
632+
end is_countably_generated
633+
634+
561635
end filter
562636

563637
open filter finset

src/order/filter/bases.lean

Lines changed: 6 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2020 Yury Kudryashov. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Author: Yury Kudryashov, Johannes Hölzl, Mario Carneiro, Patrick Massot
55
-/
6-
import order.filter.at_top_bot
6+
import order.filter.basic
77
import data.set.countable
88

99
/-!
@@ -266,16 +266,6 @@ begin
266266
tauto }
267267
end
268268

269-
lemma at_top_basis [nonempty α] [semilattice_sup α] :
270-
(@at_top α _).has_basis (λ _, true) Ici :=
271-
⟨λ t, by simpa only [exists_prop, true_and] using @mem_at_top_sets α _ _ t⟩
272-
273-
lemma at_top_basis' [semilattice_sup α] (a : α) :
274-
(@at_top α _).has_basis (λ x, a ≤ x) Ici :=
275-
⟨λ t, (@at_top_basis α ⟨a⟩ _).mem_iff.trans
276-
⟨λ ⟨x, _, hx⟩, ⟨x ⊔ a, le_sup_right, λ y hy, hx (le_trans le_sup_left hy)⟩,
277-
λ ⟨x, _, hx⟩, ⟨x, trivial, hx⟩⟩⟩
278-
279269
theorem has_basis.ge_iff (hl' : l'.has_basis p' s') : l ≤ l' ↔ ∀ i', p' i' → s' i' ∈ l :=
280270
⟨λ h i' hi', h $ hl'.mem_of_mem hi',
281271
λ h s hs, let ⟨i', hi', hs⟩ := hl'.mem_iff.1 hs in mem_sets_of_superset (h _ hi') hs⟩
@@ -465,16 +455,6 @@ lemma has_basis.prod' {la : filter α} {lb : filter β} {ι : Type*} {p : ι →
465455
exact ⟨sa i, hla.mem_of_mem hi, sb i, hlb.mem_of_mem hi, h⟩ },
466456
end
467457

468-
lemma has_antimono_basis.tendsto [semilattice_sup ι] [nonempty ι] {l : filter α}
469-
{p : ι → Prop} {s : ι → set α} (hl : l.has_antimono_basis p s) {φ : ι → α}
470-
(h : ∀ i : ι, φ i ∈ s i) : tendsto φ at_top l :=
471-
begin
472-
rw hl.to_has_basis.tendsto_right_iff,
473-
intros i hi,
474-
rw eventually_at_top,
475-
exact ⟨i, λ j hij, hl.decreasing hi (hl.mono hij hi) hij (h j)⟩,
476-
end
477-
478458
end two_types
479459

480460
/-- `is_countably_generated f` means `f = generate s` for some countable `s`. -/
@@ -612,6 +592,11 @@ end
612592

613593
end is_countably_generated
614594

595+
lemma has_countable_basis.is_countably_generated {f : filter α} {p : ι → Prop} {s : ι → set α}
596+
(h : f.has_countable_basis p s) :
597+
f.is_countably_generated :=
598+
⟨{t | ∃ i, p i ∧ s i = t}, h.countable.image s, h.to_has_basis.eq_generate⟩
599+
615600
lemma is_countably_generated_seq (x : ℕ → set α) : is_countably_generated (⨅ i, 𝓟 $ x i) :=
616601
begin
617602
rcases antimono_seq_of_seq x with ⟨y, am, h⟩,
@@ -660,78 +645,6 @@ begin
660645
... = (⨅ i, comap f $ 𝓟 $ x i) : comap_infi
661646
... = (⨅ i, 𝓟 $ f ⁻¹' x i) : by simp_rw comap_principal,
662647
end
663-
664-
/-- An abstract version of continuity of sequentially continuous functions on metric spaces:
665-
if a filter `k` is countably generated then `tendsto f k l` iff for every sequence `u`
666-
converging to `k`, `f ∘ u` tends to `l`. -/
667-
lemma tendsto_iff_seq_tendsto {f : α → β} {k : filter α} {l : filter β}
668-
(hcb : k.is_countably_generated) :
669-
tendsto f k l ↔ (∀ x : ℕ → α, tendsto x at_top k → tendsto (f ∘ x) at_top l) :=
670-
suffices (∀ x : ℕ → α, tendsto x at_top k → tendsto (f ∘ x) at_top l) → tendsto f k l,
671-
fromby intros; apply tendsto.comp; assumption, by assumption⟩,
672-
begin
673-
rcases hcb.exists_antimono_seq with ⟨g, gmon, gbasis⟩,
674-
have gbasis : ∀ A, A ∈ k ↔ ∃ i, g i ⊆ A,
675-
{ intro A,
676-
subst gbasis,
677-
rw mem_infi,
678-
{ simp only [set.mem_Union, iff_self, filter.mem_principal_sets] },
679-
{ exact directed_of_sup (λ i j h, principal_mono.mpr $ gmon _ _ h) },
680-
{ apply_instance } },
681-
classical, contrapose,
682-
simp only [not_forall, not_imp, not_exists, subset_def, @tendsto_def _ _ f, gbasis],
683-
rintro ⟨B, hBl, hfBk⟩,
684-
choose x h using hfBk,
685-
use x, split,
686-
{ simp only [tendsto_at_top', gbasis],
687-
rintros A ⟨i, hgiA⟩,
688-
use i,
689-
refine (λ j hj, hgiA $ gmon _ _ hj _),
690-
simp only [h] },
691-
{ simp only [tendsto_at_top', (∘), not_forall, not_exists],
692-
use [B, hBl],
693-
intro i, use [i, (le_refl _)],
694-
apply (h i).right },
695-
end
696-
697-
lemma tendsto_of_seq_tendsto {f : α → β} {k : filter α} {l : filter β}
698-
(hcb : k.is_countably_generated) :
699-
(∀ x : ℕ → α, tendsto x at_top k → tendsto (f ∘ x) at_top l) → tendsto f k l :=
700-
hcb.tendsto_iff_seq_tendsto.2
701-
702-
lemma subseq_tendsto {f : filter α} (hf : is_countably_generated f)
703-
{u : ℕ → α}
704-
(hx : ne_bot (f ⊓ map u at_top)) :
705-
∃ (θ : ℕ → ℕ), (strict_mono θ) ∧ (tendsto (u ∘ θ) at_top f) :=
706-
begin
707-
rcases hf.has_antimono_basis with ⟨B, h⟩,
708-
have : ∀ N, ∃ n ≥ N, u n ∈ B N,
709-
from λ N, filter.inf_map_at_top_ne_bot_iff.mp hx _ (h.to_has_basis.mem_of_mem trivial) N,
710-
choose φ hφ using this,
711-
cases forall_and_distrib.mp hφ with φ_ge φ_in,
712-
have lim_uφ : tendsto (u ∘ φ) at_top f,
713-
from h.tendsto φ_in,
714-
have lim_φ : tendsto φ at_top at_top,
715-
from (tendsto_at_top_mono φ_ge tendsto_id),
716-
obtain ⟨ψ, hψ, hψφ⟩ : ∃ ψ : ℕ → ℕ, strict_mono ψ ∧ strict_mono (φ ∘ ψ),
717-
from strict_mono_subseq_of_tendsto_at_top lim_φ,
718-
exact ⟨φ ∘ ψ, hψφ, lim_uφ.comp $ strict_mono_tendsto_at_top hψ⟩,
719-
end
720-
721648
end is_countably_generated
722649

723-
-- TODO : prove this for a encodable type
724-
lemma is_countably_generated_at_top_finset_nat : (at_top : filter $ finset ℕ).is_countably_generated :=
725-
begin
726-
apply is_countably_generated_of_seq,
727-
use λ N, Ici (finset.range N),
728-
apply eq_infi_of_mem_sets_iff_exists_mem,
729-
assume s,
730-
rw mem_at_top_sets,
731-
refine ⟨_, λ ⟨N, hN⟩, ⟨finset.range N, hN⟩⟩,
732-
rintros ⟨t, ht⟩,
733-
rcases mem_at_top_sets.1 (tendsto_finset_range (mem_at_top t)) with ⟨N, hN⟩,
734-
simp only [preimage, mem_set_of_eq] at hN,
735-
exact ⟨N, mem_principal_sets.2 $ λ t' ht', ht t' $ le_trans (hN _ $ le_refl N) ht'⟩
736-
end
737650
end filter

0 commit comments

Comments
 (0)