Skip to content

Commit 11d5cd7

Browse files
committed
Feat: add lemmas about Set.diagonal (#1438)
This is a partial forward-port of leanprover-community/mathlib3#18111
1 parent 26d0adf commit 11d5cd7

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

Mathlib/Data/Set/Function.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Andrew Zipperer, Haitao Zhang, Minchao Wu, Yury Kudryashov
55
66
! This file was ported from Lean 3 source module data.set.function
7-
! leanprover-community/mathlib commit b86832321b586c6ac23ef8cdef6a7a27e42b13bd
7+
! leanprover-community/mathlib commit 996b0ff959da753a555053a480f36e5f264d4207
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -384,6 +384,10 @@ theorem mapsTo' : MapsTo f s t ↔ f '' s ⊆ t :=
384384
image_subset_iff.symm
385385
#align set.maps_to' Set.mapsTo'
386386

387+
theorem mapsTo_prod_map_diagonal : MapsTo (Prod.map f f) (diagonal α) (diagonal β) :=
388+
diagonal_subset_iff.2 <| fun _ => rfl
389+
#align set.maps_to_prod_map_diagonal Set.mapsTo_prod_map_diagonal
390+
387391
theorem MapsTo.subset_preimage {f : α → β} {s : Set α} {t : Set β} (hf : MapsTo f s t) :
388392
s ⊆ f ⁻¹' t :=
389393
hf

Mathlib/Data/Set/Prod.lean

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Mario Carneiro, Johannes Hölzl, Patrick Massot
55
66
! This file was ported from Lean 3 source module data.set.prod
7-
! leanprover-community/mathlib commit 2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c
7+
! leanprover-community/mathlib commit 996b0ff959da753a555053a480f36e5f264d4207
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -476,6 +476,10 @@ theorem mem_diagonal_iff {x : α × α} : x ∈ diagonal α ↔ x.1 = x.2 :=
476476
Iff.rfl
477477
#align set.mem_diagonal_iff Set.mem_diagonal_iff
478478

479+
lemma diagonal_nonempty [Nonempty α] : (diagonal α).Nonempty :=
480+
Nonempty.elim ‹_› <| fun x => ⟨_, mem_diagonal x⟩
481+
#align set.diagonal_nonempty Set.diagonal_nonempty
482+
479483
instance decidableMemDiagonal [h : DecidableEq α] (x : α × α) : Decidable (x ∈ diagonal α) :=
480484
h x.1 x.2
481485
#align set.decidable_mem_diagonal Set.decidableMemDiagonal
@@ -492,11 +496,13 @@ theorem range_diag : (range fun x => (x, x)) = diagonal α := by
492496
simp [diagonal, eq_comm]
493497
#align set.range_diag Set.range_diag
494498

499+
theorem diagonal_subset_iff {s} : diagonal α ⊆ s ↔ ∀ x, (x, x) ∈ s := by
500+
rw [← range_diag, range_subset_iff]
501+
#align set.diagonal_subset_iff Set.diagonal_subset_iff
502+
495503
@[simp]
496504
theorem prod_subset_compl_diagonal_iff_disjoint : s ×ˢ t ⊆ diagonal αᶜ ↔ Disjoint s t :=
497-
subset_compl_comm.trans <| by
498-
simp_rw [← range_diag, range_subset_iff, disjoint_left, mem_compl_iff, prod_mk_mem_set_prod_eq,
499-
not_and]
505+
prod_subset_iff.trans disjoint_iff_forall_ne.symm
500506
#align set.prod_subset_compl_diagonal_iff_disjoint Set.prod_subset_compl_diagonal_iff_disjoint
501507

502508
@[simp]

Mathlib/Order/Filter/Bases.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yury Kudryashov, Johannes Hölzl, Mario Carneiro, Patrick Massot
55
66
! This file was ported from Lean 3 source module order.filter.bases
7-
! leanprover-community/mathlib commit d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce
7+
! leanprover-community/mathlib commit 996b0ff959da753a555053a480f36e5f264d4207
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -419,13 +419,13 @@ theorem hasBasis_self {l : Filter α} {P : Set α → Prop} :
419419
fun h => h.1, fun h => ⟨h, fun ⟨t, hl, _, hts⟩ => mem_of_superset hl hts⟩⟩
420420
#align filter.has_basis_self Filter.hasBasis_self
421421

422-
theorem HasBasis.comp_of_surjective (h : l.HasBasis p s) {g : ι' → ι} (hg : Function.Surjective g) :
422+
theorem HasBasis.comp_surjective (h : l.HasBasis p s) {g : ι' → ι} (hg : Function.Surjective g) :
423423
l.HasBasis (p ∘ g) (s ∘ g) :=
424424
fun _ => h.mem_iff.trans hg.exists⟩
425-
#align filter.has_basis.comp_of_surjective Filter.HasBasis.comp_of_surjective
425+
#align filter.has_basis.comp_surjective Filter.HasBasis.comp_surjective
426426

427427
theorem HasBasis.comp_equiv (h : l.HasBasis p s) (e : ι' ≃ ι) : l.HasBasis (p ∘ e) (s ∘ e) :=
428-
h.comp_of_surjective e.surjective
428+
h.comp_surjective e.surjective
429429
#align filter.has_basis.comp_equiv Filter.HasBasis.comp_equiv
430430

431431
/-- If `{s i | p i}` is a basis of a filter `l` and each `s i` includes `s j` such that

Mathlib/Order/Filter/Basic.lean

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Jeremy Avigad
55
66
! This file was ported from Lean 3 source module order.filter.basic
7-
! leanprover-community/mathlib commit 1126441d6bccf98c81214a0780c73d499f6721fe
7+
! leanprover-community/mathlib commit 996b0ff959da753a555053a480f36e5f264d4207
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -986,6 +986,9 @@ theorem principal_neBot_iff {s : Set α} : NeBot (𝓟 s) ↔ s.Nonempty :=
986986
neBot_iff.trans <| (not_congr principal_eq_bot_iff).trans nonempty_iff_ne_empty.symm
987987
#align filter.principal_ne_bot_iff Filter.principal_neBot_iff
988988

989+
alias principal_neBot_iff ↔ _ _root_.Set.Nonempty.principal_neBot
990+
#align set.nonempty.principal_ne_bot Set.Nonempty.principal_neBot
991+
989992
theorem isCompl_principal (s : Set α) : IsCompl (𝓟 s) (𝓟 (sᶜ)) :=
990993
IsCompl.of_eq (by rw [inf_principal, inter_compl_self, principal_empty]) <| by
991994
rw [sup_principal, union_compl_self, principal_univ]
@@ -1885,6 +1888,12 @@ theorem mem_comap' : s ∈ comap f l ↔ { y | ∀ ⦃x⦄, f x = y → x ∈ s
18851888
fun h => ⟨_, h, fun x hx => hx rfl⟩⟩
18861889
#align filter.mem_comap' Filter.mem_comap'
18871890

1891+
/-- RHS form is used, e.g., in the definition of `UniformSpace`. -/
1892+
lemma mem_comap_prod_mk {x : α} {s : Set β} {F : Filter (α × β)} :
1893+
s ∈ comap (Prod.mk x) F ↔ {p : α × β | p.fst = x → p.snd ∈ s} ∈ F :=
1894+
by simp_rw [mem_comap', Prod.ext_iff, and_imp, @forall_swap β (_ = _), forall_eq, eq_comm]
1895+
#align filter.mem_comap_prod_mk Filter.mem_comap_prod_mk
1896+
18881897
@[simp]
18891898
theorem eventually_comap : (∀ᶠ a in comap f l, p a) ↔ ∀ᶠ b in l, ∀ a, f a = b → p a :=
18901899
mem_comap'
@@ -2041,6 +2050,9 @@ theorem comap_id : comap id f = f :=
20412050
le_antisymm (fun _ => preimage_mem_comap) fun _ ⟨_, ht, hst⟩ => mem_of_superset ht hst
20422051
#align filter.comap_id Filter.comap_id
20432052

2053+
theorem comap_id' : comap (fun x => x) f = f := comap_id
2054+
#align filter.comap_id' Filter.comap_id'
2055+
20442056
theorem comap_const_of_not_mem {x : β} (ht : t ∈ g) (hx : x ∉ t) : comap (fun _ : α => x) g = ⊥ :=
20452057
empty_mem_iff_bot.1 <| mem_comap'.2 <| mem_of_superset ht fun _ hx' _ h => hx <| h.symm ▸ hx'
20462058
#align filter.comap_const_of_not_mem Filter.comap_const_of_not_mem

0 commit comments

Comments
 (0)