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

Commit 396a66a

Browse files
committed
chore(order/filter/*): use [nonempty _] instead of (_ : nonempty _) (#3526)
In most cases Lean can find an instance automatically.
1 parent b9beca0 commit 396a66a

File tree

8 files changed

+51
-48
lines changed

8 files changed

+51
-48
lines changed

src/order/basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ class no_top_order (α : Type u) [preorder α] : Prop :=
362362
lemma no_top [preorder α] [no_top_order α] : ∀a:α, ∃a', a < a' :=
363363
no_top_order.no_top
364364

365+
instance nonempty_gt {α : Type u} [preorder α] [no_top_order α] (a : α) :
366+
nonempty {x // a < x} :=
367+
nonempty_subtype.2 (no_top a)
368+
365369
/-- order without a bottom element; somtimes called coinitial or dense -/
366370
class no_bot_order (α : Type u) [preorder α] : Prop :=
367371
(no_bot : ∀a:α, ∃a', a' < a)
@@ -377,6 +381,10 @@ instance order_dual.no_bot_order (α : Type u) [preorder α] [no_top_order α] :
377381
no_bot_order (order_dual α) :=
378382
⟨λ a, @no_top α _ _ a⟩
379383

384+
instance nonempty_lt {α : Type u} [preorder α] [no_bot_order α] (a : α) :
385+
nonempty {x // x < a} :=
386+
nonempty_subtype.2 (no_bot a)
387+
380388
/-- An order is dense if there is an element between any pair of distinct elements. -/
381389
class densely_ordered (α : Type u) [preorder α] : Prop :=
382390
(dense : ∀a₁ a₂:α, a₁ < a₂ → ∃a, a₁ < a ∧ a < a₂)

src/order/filter/at_top_bot.lean

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ 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 α] :
49+
lemma at_top_basis [nonempty α] [semilattice_sup α] :
5050
(@at_top α _).has_basis (λ _, true) Ici :=
51-
has_basis_infi_principal (directed_of_sup $ λ a b, Ici_subset_Ici.2)
51+
has_basis_infi_principal (directed_of_sup $ λ a b, Ici_subset_Ici.2)
5252

5353
lemma at_top_basis' [semilattice_sup α] (a : α) :
5454
(@at_top α _).has_basis (λ x, a ≤ x) Ici :=
@@ -587,17 +587,16 @@ begin
587587
subst gbasis,
588588
rw mem_infi,
589589
{ 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,
590+
{ exact directed_of_sup (λ i j h, principal_mono.mpr $ gmon h) } },
591+
contrapose,
593592
simp only [not_forall, not_imp, not_exists, subset_def, @tendsto_def _ _ f, gbasis],
594593
rintro ⟨B, hBl, hfBk⟩,
595594
choose x h using hfBk,
596595
use x, split,
597596
{ simp only [tendsto_at_top', gbasis],
598597
rintros A ⟨i, hgiA⟩,
599598
use i,
600-
refine (λ j hj, hgiA $ gmon _ _ hj _),
599+
refine (λ j hj, hgiA $ gmon hj _),
601600
simp only [h] },
602601
{ simp only [tendsto_at_top', (∘), not_forall, not_exists],
603602
use [B, hBl],

src/order/filter/bases.lean

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ structure filter_basis (α : Type*) :=
7777
(nonempty : sets.nonempty)
7878
(inter_sets {x y} : x ∈ sets → y ∈ sets → ∃ z ∈ sets, z ⊆ x ∩ y)
7979

80+
instance filter_basis.nonempty_sets (B : filter_basis α) : nonempty B.sets := B.nonempty.to_subtype
81+
8082
/-- If `B` is a filter basis on `α`, and `U` a subset of `α` then we can write `U ∈ B` as on paper. -/
8183
@[reducible]
8284
instance {α : Type*}: has_mem (set α) (filter_basis α) := ⟨λ U B, U ∈ B.sets⟩
@@ -136,15 +138,13 @@ lemma mem_filter_of_mem (B : filter_basis α) {U : set α} : U ∈ B → U ∈ B
136138

137139
lemma eq_infi_principal (B : filter_basis α) : B.filter = ⨅ s : B.sets, 𝓟 s :=
138140
begin
139-
ext U,
140-
rw [mem_filter_iff, mem_infi],
141-
{ simp },
141+
have : directed (≥) (λ (s : B.sets), 𝓟 (s : set α)),
142142
{ rintros ⟨U, U_in⟩ ⟨V, V_in⟩,
143143
rcases B.inter_sets U_in V_in with ⟨W, W_in, W_sub⟩,
144144
use [W, W_in],
145145
finish },
146-
cases B.nonempty with U U_in,
147-
exact ⟨⟨U, U_in⟩⟩,
146+
ext U,
147+
simp [mem_filter_iff, mem_infi this]
148148
end
149149

150150
protected lemma generate (B : filter_basis α) : generate B.sets = B.filter :=
@@ -190,7 +190,8 @@ section same_type
190190
variables {l l' : filter α} {p : ι → Prop} {s : ι → set α} {t : set α} {i : ι}
191191
{p' : ι' → Prop} {s' : ι' → set α} {i' : ι'}
192192

193-
lemma has_basis_generate (s : set (set α)) : (generate s).has_basis (λ t, finite t ∧ t ⊆ s) (λ t, ⋂₀ t) :=
193+
lemma has_basis_generate (s : set (set α)) :
194+
(generate s).has_basis (λ t, finite t ∧ t ⊆ s) (λ t, ⋂₀ t) :=
194195
begin
195196
intro U,
196197
rw mem_generate_iff,
@@ -303,10 +304,10 @@ lemma has_basis.eq_infi (h : l.has_basis (λ _, true) s) :
303304
by simpa only [infi_true] using h.eq_binfi
304305

305306
@[nolint ge_or_gt] -- see Note [nolint_ge]
306-
lemma has_basis_infi_principal {s : ι → set α} (h : directed (≥) s) (ne : nonempty ι) :
307+
lemma has_basis_infi_principal {s : ι → set α} (h : directed (≥) s) [nonempty ι] :
307308
(⨅ i, 𝓟 (s i)).has_basis (λ _, true) s :=
308309
begin
309-
refine λ t, (mem_infi (h.mono_comp _ _) ne t).trans $
310+
refine λ t, (mem_infi (h.mono_comp _ _) t).trans $
310311
by simp only [exists_prop, true_and, mem_principal_sets],
311312
exact λ _ _, principal_mono.2
312313
end
@@ -570,7 +571,7 @@ begin
570571
end
571572

572573
lemma exists_antimono_seq {f : filter α} (cblb : f.is_countably_generated) :
573-
∃ x : ℕ → set α, (∀ i j, i ≤ j → x j ⊆ x i) ∧ f = ⨅ i, 𝓟 (x i) :=
574+
∃ x : ℕ → set α, (∀ i j, i ≤ j → x j ⊆ x i) ∧ f = ⨅ i, 𝓟 (x i) :=
574575
begin
575576
rcases cblb.exists_seq with ⟨x', hx'⟩,
576577
let x := λ n, ⋂ m ≤ n, x' m,
@@ -586,8 +587,8 @@ lemma has_antimono_basis {f : filter α} (h : f.is_countably_generated) :
586587
∃ x : ℕ → set α, f.has_antimono_basis (λ _, true) x :=
587588
begin
588589
rcases h.exists_antimono_seq with ⟨x, x_dec, rfl⟩,
589-
refine ⟨x, has_basis_infi_principal _0, _, monotone_const⟩,
590-
exacts [directed_of_sup x_dec, λ i j _ _, x_dec i j]
590+
refine ⟨x, has_basis_infi_principal _, _, monotone_const⟩,
591+
exacts [directed_of_sup x_dec, λ i j _ _ h, x_dec h]
591592
end
592593

593594
end is_countably_generated
@@ -602,7 +603,7 @@ begin
602603
rcases antimono_seq_of_seq x with ⟨y, am, h⟩,
603604
rw h,
604605
use [range y, countable_range _],
605-
rw (has_basis_infi_principal _ _).eq_generate,
606+
rw (has_basis_infi_principal _).eq_generate,
606607
{ simp [range] },
607608
{ exact directed_of_sup am },
608609
{ use 0 },
@@ -645,6 +646,7 @@ begin
645646
... = (⨅ i, comap f $ 𝓟 $ x i) : comap_infi
646647
... = (⨅ i, 𝓟 $ f ⁻¹' x i) : by simp_rw comap_principal,
647648
end
649+
648650
end is_countably_generated
649651

650652
end filter

src/order/filter/basic.lean

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ iff.intro
253253
(assume x y _ hxy hx, mem_sets_of_superset hx hxy)
254254
(assume x y _ _ hx hy, inter_mem_sets hx hy))
255255

256-
257256
lemma mem_generate_iff (s : set $ set α) {U : set α} : U ∈ generate s ↔ ∃ t ⊆ s, finite t ∧ ⋂₀ t ⊆ U :=
258257
begin
259258
split ; intro h,
@@ -563,7 +562,7 @@ begin
563562
exact h.trans ⟨λ ⟨i, pi, si⟩, ⟨⟨i, pi⟩, si⟩, λ ⟨⟨i, pi⟩, si⟩, ⟨i, pi, si⟩⟩
564563
end
565564

566-
lemma infi_sets_eq {f : ι → filter α} (h : directed (≥) f) (ne : nonempty ι) :
565+
lemma infi_sets_eq {f : ι → filter α} (h : directed (≥) f) [ne : nonempty ι] :
567566
(infi f).sets = (⋃ i, (f i).sets) :=
568567
let ⟨i⟩ := ne, u := { filter .
569568
sets := (⋃ i, (f i).sets),
@@ -580,20 +579,18 @@ let ⟨i⟩ := ne, u := { filter .
580579
have u = infi f, from eq_infi_of_mem_sets_iff_exists_mem (λ s, by simp only [mem_Union]),
581580
congr_arg filter.sets this.symm
582581

583-
lemma mem_infi {f : ι → filter α} (h : directed (≥) f) (ne : nonempty ι) (s) :
582+
lemma mem_infi {f : ι → filter α} (h : directed (≥) f) [nonempty ι] (s) :
584583
s ∈ infi f ↔ ∃ i, s ∈ f i :=
585-
by simp only [infi_sets_eq h ne, mem_Union]
584+
by simp only [infi_sets_eq h, mem_Union]
586585

587586
@[nolint ge_or_gt] -- Intentional use of `≥`
588587
lemma binfi_sets_eq {f : β → filter α} {s : set β}
589588
(h : directed_on (f ⁻¹'o (≥)) s) (ne : s.nonempty) :
590589
(⨅ i∈s, f i).sets = (⋃ i ∈ s, (f i).sets) :=
591-
let ⟨i, hi⟩ := ne in
590+
by haveI := ne.to_subtype;
592591
calc (⨅ i ∈ s, f i).sets = (⨅ t : {t // t ∈ s}, (f t.val)).sets : by rw [infi_subtype]; refl
593-
... = (⨆ t : {t // t ∈ s}, (f t.val).sets) : infi_sets_eq
594-
(assume ⟨x, hx⟩ ⟨y, hy⟩, match h x hx y hy with ⟨z, h₁, h₂, h₃⟩ := ⟨⟨z, h₁⟩, h₂, h₃⟩ end)
595-
⟨⟨i, hi⟩⟩
596-
... = (⨆ t ∈ {t | t ∈ s}, (f t).sets) : by rw [supr_subtype]; refl
592+
... = (⨆ t : {t // t ∈ s}, (f t.val).sets) : infi_sets_eq h.directed_coe
593+
... = (⨆ t ∈ s, (f t).sets) : by rw [supr_subtype]; refl
597594

598595
@[nolint ge_or_gt] -- Intentional use of `≥`
599596
lemma mem_binfi {f : β → filter α} {s : set β}
@@ -606,7 +603,6 @@ lemma infi_sets_eq_finite (f : ι → filter α) :
606603
begin
607604
rw [infi_eq_infi_finset, infi_sets_eq],
608605
exact (directed_of_sup $ λs₁ s₂ hs, infi_le_infi $ λi, infi_le_infi_const $ λh, hs h),
609-
apply_instance
610606
end
611607

612608
lemma mem_infi_finite {f : ι → filter α} (s) :
@@ -684,13 +680,13 @@ end
684680

685681
/-- If `f : ι → filter α` is directed, `ι` is not empty, and `∀ i, f i ≠ ⊥`, then `infi f ≠ ⊥`.
686682
See also `infi_ne_bot_of_directed` for a version assuming `nonempty α` instead of `nonempty ι`. -/
687-
lemma infi_ne_bot_of_directed' {f : ι → filter α} [hn : nonempty ι]
683+
lemma infi_ne_bot_of_directed' {f : ι → filter α} [nonempty ι]
688684
(hd : directed (≥) f) (hb : ∀i, ne_bot (f i)) : ne_bot (infi f) :=
689685
begin
690686
intro h,
691687
have he: ∅ ∈ (infi f), from h.symm ▸ (mem_bot_sets : ∅ ∈ (⊥ : filter α)),
692688
obtain ⟨i, hi⟩ : ∃i, ∅ ∈ f i,
693-
from (mem_infi hd hn ∅).1 he,
689+
from (mem_infi hd ∅).1 he,
694690
exact hb i (empty_in_sets_eq_bot.1 hi)
695691
end
696692

@@ -1639,13 +1635,13 @@ lemma map_infi_le {f : ι → filter α} {m : α → β} :
16391635
map m (infi f) ≤ (⨅ i, map m (f i)) :=
16401636
le_infi $ assume i, map_mono $ infi_le _ _
16411637

1642-
lemma map_infi_eq {f : ι → filter α} {m : α → β} (hf : directed (≥) f) (hι : nonempty ι) :
1638+
lemma map_infi_eq {f : ι → filter α} {m : α → β} (hf : directed (≥) f) [nonempty ι] :
16431639
map m (infi f) = (⨅ i, map m (f i)) :=
16441640
le_antisymm
16451641
map_infi_le
16461642
(assume s (hs : preimage m s ∈ infi f),
16471643
have ∃i, preimage m s ∈ f i,
1648-
by simp only [infi_sets_eq hf, mem_Union] at hs; assumption,
1644+
by simp only [infi_sets_eq hf, mem_Union] at hs; assumption,
16491645
let ⟨i, hi⟩ := this in
16501646
have (⨅ i, map m (f i)) ≤ 𝓟 s, from
16511647
infi_le_of_le i $ by simp only [le_principal_iff, mem_map]; assumption,
@@ -1654,12 +1650,11 @@ le_antisymm
16541650
lemma map_binfi_eq {ι : Type w} {f : ι → filter α} {m : α → β} {p : ι → Prop}
16551651
(h : directed_on (f ⁻¹'o (≥)) {x | p x}) (ne : ∃i, p i) :
16561652
map m (⨅i (h : p i), f i) = (⨅i (h: p i), map m (f i)) :=
1657-
let ⟨i, hi⟩ := ne in
1658-
calc map m (⨅i (h : p i), f i) = map m (⨅i:subtype p, f i.val) : by simp only [infi_subtype, eq_self_iff_true]
1659-
... = (⨅i:subtype p, map m (f i.val)) : map_infi_eq
1660-
(assume ⟨x, hx⟩ ⟨y, hy⟩, match h x hx y hy with ⟨z, h₁, h₂, h₃⟩ := ⟨⟨z, h₁⟩, h₂, h₃⟩ end)
1661-
⟨⟨i, hi⟩⟩
1662-
... = (⨅i (h : p i), map m (f i)) : by simp only [infi_subtype, eq_self_iff_true]
1653+
begin
1654+
haveI := nonempty_subtype.2 ne,
1655+
simp only [infi_subtype'],
1656+
exact map_infi_eq h.directed_coe
1657+
end
16631658

16641659
lemma map_inf_le {f g : filter α} {m : α → β} : map m (f ⊓ g) ≤ map m f ⊓ map m g :=
16651660
(@map_mono _ _ m).map_inf_le f g

src/order/filter/lift.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ le_antisymm
149149
(le_infi $ assume s, le_infi $ assume hs, by simp only [hs, le_principal_iff])
150150

151151
lemma lift_infi {f : ι → filter α} {g : set α → filter β}
152-
(hι : nonempty ι) (hg : ∀{s t}, g s ⊓ g t = g (s ∩ t)) : (infi f).lift g = (⨅i, (f i).lift g) :=
152+
[hι : nonempty ι] (hg : ∀{s t}, g s ⊓ g t = g (s ∩ t)) : (infi f).lift g = (⨅i, (f i).lift g) :=
153153
le_antisymm
154154
(le_infi $ assume i, lift_mono (infi_le _ _) (le_refl _))
155155
(assume s,
@@ -281,19 +281,19 @@ lemma le_lift' {f : filter α} {h : set α → set β} {g : filter β}
281281
le_infi $ assume s, le_infi $ assume hs, by simp only [h_le, le_principal_iff, function.comp_app]; exact h_le s hs
282282

283283
lemma lift_infi' {f : ι → filter α} {g : set α → filter β}
284-
(hι : nonempty ι) (hf : directed (≥) f) (hg : monotone g) : (infi f).lift g = (⨅i, (f i).lift g) :=
284+
[nonempty ι] (hf : directed (≥) f) (hg : monotone g) : (infi f).lift g = (⨅i, (f i).lift g) :=
285285
le_antisymm
286286
(le_infi $ assume i, lift_mono (infi_le _ _) (le_refl _))
287287
(assume s,
288288
begin
289289
rw mem_lift_sets hg,
290-
simp only [exists_imp_distrib, mem_infi hf],
290+
simp only [exists_imp_distrib, mem_infi hf],
291291
exact assume t i ht hs, mem_infi_sets i $ mem_lift ht hs
292292
end)
293293

294294
lemma lift'_infi {f : ι → filter α} {g : set α → set β}
295-
(hι : nonempty ι) (hg : ∀{s t}, g s ∩ g t = g (s ∩ t)) : (infi f).lift' g = (⨅i, (f i).lift' g) :=
296-
lift_infi $ by simp only [principal_eq_iff_eq, inf_principal, function.comp_app]; apply assume s t, hg
295+
[nonempty ι] (hg : ∀{s t}, g s ∩ g t = g (s ∩ t)) : (infi f).lift' g = (⨅i, (f i).lift' g) :=
296+
lift_infi $ by simp only [principal_eq_iff_eq, inf_principal, function.comp_app]; apply assume s t, hg
297297

298298
theorem comap_eq_lift' {f : filter β} {m : α → β} :
299299
comap m f = f.lift' (preimage m) :=

src/topology/metric_space/completion.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ begin
159159
ext s, rw mem_infi,
160160
{ simp [completion.mem_uniformity_dist, subset_def] },
161161
{ rintro ⟨r, hr⟩ ⟨p, hp⟩, use ⟨min r p, lt_min hr hp⟩,
162-
simp [lt_min_iff, (≥)] {contextual := tt} },
163-
{ exact ⟨⟨1, zero_lt_one⟩⟩ }
162+
simp [lt_min_iff, (≥)] {contextual := tt} }
164163
end
165164

166165
@[nolint ge_or_gt] -- see Note [nolint_ge]

src/topology/uniform_space/absolute_value.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ begin
7070
rw mem_infi,
7171
{ simp [subset_def] },
7272
{ exact assume ⟨r, hr⟩ ⟨p, hp⟩, ⟨⟨min r p, lt_min hr hp⟩, by simp [lt_min_iff, (≥)] {contextual := tt}⟩, },
73-
{ exact ⟨⟨1, zero_lt_one⟩⟩ }
7473
end
7574

7675
end is_absolute_value

src/topology/uniform_space/basic.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,11 @@ lemma to_topological_space_infi {ι : Sort*} {u : ι → uniform_space α} :
10681068
(infi u).to_topological_space = ⨅i, (u i).to_topological_space :=
10691069
begin
10701070
by_cases h : nonempty ι,
1071-
{refine (eq_of_nhds_eq_nhds $ assume a, _),
1071+
{ resetI,
1072+
refine (eq_of_nhds_eq_nhds $ assume a, _),
10721073
rw [nhds_infi, nhds_eq_uniformity],
10731074
change (infi u).uniformity.lift' (preimage $ prod.mk a) = _,
1074-
rw [infi_uniformity, lift'_infi h],
1075+
rw [infi_uniformity, lift'_infi],
10751076
{ simp only [nhds_eq_uniformity], refl },
10761077
{ exact assume a b, rfl } },
10771078
{ rw [infi_of_empty h, infi_of_empty h, to_topological_space_top] }

0 commit comments

Comments
 (0)