Skip to content

Commit ac65b24

Browse files
committed
Add subtype lemmas
1 parent 05ac9d3 commit ac65b24

8 files changed

Lines changed: 280 additions & 13 deletions

File tree

Munkres/Defs.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ import Munkres.Defs.Conversions
44
import Munkres.Defs.IsBasisAt
55
import Munkres.Defs.Metric.Basic
66
import Munkres.Defs.OpenCover
7+
import Munkres.Defs.Subspace
8+
import Munkres.Defs.Subtype
79
-- WARNING: THIS FILE IS AUTO-GENERATED.

Munkres/Defs/Subspace.lean

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Munkres.Subtype.Induced
2+
3+
import Munkres.Defs.Subtype
4+
5+
open Set
6+
7+
universe u
8+
9+
variable {α : Type u} {X Y : Set α} [tY : TopologicalSpace Y]
10+
11+
def Topology.Subspace (h : X ⊆ Y) : TopologicalSpace X
12+
:= by --
13+
let X' := { y : Y | ↑y ∈ X }
14+
let φ : X ≃ X' := {
15+
toFun := fun ⟨x, hx⟩ ↦ ⟨⟨x, h hx⟩, hx⟩
16+
invFun := fun ⟨⟨x, _⟩, hx⟩ ↦ ⟨x, hx⟩
17+
left_inv := Function.leftInverse_iff_comp.mpr rfl
18+
right_inv := Function.rightInverse_iff_comp.mpr rfl
19+
}
20+
let tX : TopologicalSpace X' := instTopologicalSpaceSubtype (p := fun x : Y ↦ ↑x ∈ X)
21+
refine {
22+
IsOpen U := IsOpen (φ '' U)
23+
isOpen_univ := by
24+
rw [image_univ, EquivLike.range_eq_univ]
25+
exact isOpen_univ
26+
isOpen_inter s t hs ht := by
27+
rw [image_inter φ.injective]
28+
exact hs.inter ht
29+
isOpen_sUnion s hs := by
30+
rw [sUnion_eq_biUnion]
31+
rw [image_iUnion₂]
32+
exact isOpen_biUnion hs
33+
} -- ∎

Munkres/Defs/Subtype.lean

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Mathlib.Topology.Separation.Hausdorff
2+
3+
namespace Munkres
4+
5+
universe u
6+
7+
variable {α : Type u}
8+
9+
-- Conforms to Munkres' idea of a set being open in a subspace.
10+
structure IsOpenIn (A X : Set α) [TopologicalSpace X] : Prop where
11+
isOpen' : @IsOpen X _ (Subtype.val ⁻¹' A)
12+
subset' : A ⊆ X
13+
14+
-- Conforms to Munkres' idea of a set being closed in a subspace.
15+
structure IsClosedIn (A X : Set α) [TopologicalSpace X] : Prop where
16+
isClosed' : @IsClosed X _ (Subtype.val ⁻¹' A)
17+
subset' : A ⊆ X
18+
19+
-- Conforms to Munkres' idea of a set being compact in a subspace.
20+
structure IsCompactIn (A X : Set α) [TopologicalSpace X] : Prop where
21+
isCompact' : @IsCompact X _ (Subtype.val ⁻¹' A)
22+
subset' : A ⊆ X
23+
24+
end Munkres

Munkres/Mathlib/Subtype.lean

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import Mathlib.Data.Set.Image
2+
import Mathlib.Data.Set.Notation
3+
4+
universe u
5+
6+
variable {α : Type u}
7+
8+
section Examples
9+
open Subtype
10+
variable {X U : Set α}
11+
12+
/-- Reminder of other forms that `Subtype.val ⁻¹' U` might take! -/
13+
example : Subtype.val⁻¹' U = { x : X | ↑x ∈ U } := rfl
14+
example : (↑) '' ((↑) ⁻¹' U : Set X) = X ∩ U := image_preimage_val X U
15+
example : (↑) '' ((↑) ⁻¹' U : Set X) = X ∩ U := image_preimage_coe X U
16+
example : val '' (val ⁻¹' U : Set X) = X ∩ U := image_preimage_val X U
17+
example : val '' (val ⁻¹' U : Set X) = X ∩ U := image_preimage_coe X U
18+
19+
example (h : U ⊆ X) : val '' { x : X | ↑x ∈ U } = U := coe_image_of_subset h
20+
21+
end Examples
22+
23+
section Lemmas
24+
variable {X U : Set α}
25+
26+
theorem Subtype.preimage_val_eq_iff (A : Set X)
27+
: val ⁻¹' U = A ↔ val '' A = X ∩ U
28+
:= by --
29+
constructor
30+
· intro h
31+
subst h
32+
exact image_preimage_val X U
33+
· intro h
34+
rw [<-preimage_coe_self_inter, <-h, Set.preimage_image_eq]
35+
exact val_injective -- ∎
36+
37+
theorem Subtype.preimage_coe_eq_iff (A : Set X)
38+
: (↑) ⁻¹' U = A ↔ (↑) '' A = X ∩ U
39+
:= by --
40+
exact preimage_val_eq_iff A -- ∎
41+
42+
theorem Subtype.eq_inter : { x : X | ↑x ∈ U } = X ∩ U
43+
:= by --
44+
exact (preimage_val_eq_iff _).mp rfl -- ∎
45+
46+
theorem Subtype.mem_iff (A : Set X) (x : X) : x ∈ A ↔ x.val ∈ (↑) '' A
47+
:= by --
48+
refine ⟨(⟨x, ·, rfl⟩), ?_⟩
49+
intro ⟨y, hy, heq⟩
50+
rw [SetCoe.ext heq] at hy
51+
exact hy -- ∎
52+
53+
theorem Subtype.set_eq (A : Set X) : { x : X | ↑x ∈ (A : Set α) } = A
54+
:= by --
55+
refine le_antisymm ?_ (⟨·, ·, rfl⟩)
56+
intro x ⟨y, hy, heq⟩
57+
rw [SetCoe.ext heq] at hy
58+
exact hy -- ∎
59+
60+
theorem Subtype.compl : (val ⁻¹' U : Set X)ᶜ = val ⁻¹' (X \ U)
61+
:= by --
62+
rw [Set.preimage_diff, coe_preimage_self]
63+
exact Set.compl_eq_univ_diff (val ⁻¹' U) -- ∎
64+
65+
end Lemmas

Munkres/Subtype/Induced.lean

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Mathlib.Topology.Order
2+
3+
import Munkres.Mathlib.Subtype
4+
5+
universe u
6+
7+
variable {α : Type u} [TopologicalSpace α]
8+
9+
section Induced
10+
11+
variable (X : Set α) {A : Set α}
12+
13+
/-- Matches Munkres' definition of a set being open in a topological subspace. -/
14+
theorem isOpen_induced_iff₂ (A : Set X) : @IsOpen X _ A ↔ ∃ U, IsOpen U ∧ A = X ∩ U
15+
:= by --
16+
rw [isOpen_induced_iff]
17+
simp only [Subtype.preimage_val_eq_iff] -- ∎
18+
19+
/-- Matches Munkres' definition of a set being closed in a topological subspace. -/
20+
theorem isClosed_induced_iff₂ (A : Set X) : @IsClosed X _ A ↔ ∃ U, IsClosed U ∧ A = X ∩ U
21+
:= by --
22+
rw [isClosed_induced_iff]
23+
simp only [Subtype.preimage_val_eq_iff] -- ∎
24+
25+
theorem isOpen_induced_iff₃ :
26+
@IsOpen X _ (Subtype.val ⁻¹' A) ↔ ∃ U, IsOpen U ∧ X ∩ A = X ∩ U
27+
:= by --
28+
rw [isOpen_induced_iff]
29+
simp only [Subtype.preimage_val_eq_iff, Subtype.image_preimage_coe] -- ∎
30+
31+
theorem isClosed_induced_iff₃ :
32+
@IsClosed X _ (Subtype.val ⁻¹' A) ↔ ∃ U, IsClosed U ∧ X ∩ A = X ∩ U
33+
:= by --
34+
rw [isClosed_induced_iff]
35+
simp only [Subtype.preimage_val_eq_iff, Subtype.image_preimage_coe] -- ∎
36+
37+
end Induced

Munkres/Subtype/Topology.lean

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import Munkres.Subtype.Induced
2+
3+
import Munkres.Defs.Subtype
4+
5+
open Set
6+
7+
namespace Munkres
8+
9+
universe u
10+
11+
variable {α : Type u}
12+
13+
section SimpleCases
14+
variable {X A : Set α} [TopologicalSpace X]
15+
16+
-- Empty and univ lemmas.
17+
18+
lemma isOpenIn_empty : IsOpenIn ∅ X
19+
:= by --
20+
exact { isOpen' := isOpen_const, subset' := empty_subset X } -- ∎
21+
lemma isOpenIn_univ : IsOpenIn X X
22+
:= by --
23+
refine { isOpen' := ?_, subset' := le_rfl }
24+
rw [Subtype.coe_preimage_self]
25+
exact isOpen_univ -- ∎
26+
27+
lemma isClosedIn_empty : IsClosedIn ∅ X
28+
:= by --
29+
exact { isClosed' := isClosed_const, subset' := empty_subset X } -- ∎
30+
lemma isClosedIn_univ : IsClosedIn X X
31+
:= by --
32+
refine { isClosed' := ?_, subset' := le_rfl }
33+
rw [Subtype.coe_preimage_self]
34+
exact isClosed_univ -- ∎
35+
36+
lemma isCompactIn_empty : IsCompactIn ∅ X
37+
:= by --
38+
refine { isCompact' := ?_, subset' := empty_subset X }
39+
rw [preimage_empty]
40+
exact isCompact_empty -- ∎
41+
42+
-- Complement lemmas.
43+
44+
lemma IsClosedIn.isOpen_compl (h : IsClosedIn A X) : IsOpenIn (X \ A) X
45+
:= by --
46+
refine { isOpen' := ?_, subset' := diff_subset }
47+
rw [<-Subtype.compl]
48+
exact h.isClosed'.isOpen_compl -- ∎
49+
lemma IsOpenIn.isClosed_compl (h : IsOpenIn A X) : IsClosedIn (X \ A) X
50+
:= by --
51+
refine { isClosed' := ?_, subset' := diff_subset }
52+
rw [<-Subtype.compl]
53+
exact h.isOpen'.isClosed_compl -- ∎
54+
55+
lemma IsClosedIn.iff_compl : IsClosedIn A X ↔ IsOpenIn (X \ A) X ∧ A ⊆ X
56+
:= by --
57+
refine ⟨fun h ↦ ⟨h.isOpen_compl, h.subset'⟩, ?_⟩
58+
intro ⟨h, subset'⟩
59+
rw [<-Set.diff_diff_cancel_left subset']
60+
exact h.isClosed_compl -- ∎
61+
lemma IsOpenIn.iff_compl : IsOpenIn A X ↔ IsClosedIn (X \ A) X ∧ A ⊆ X
62+
:= by --
63+
refine ⟨fun h ↦ ⟨h.isClosed_compl, h.subset'⟩, ?_⟩
64+
intro ⟨h, subset'⟩
65+
rw [<-Set.diff_diff_cancel_left subset']
66+
exact h.isOpen_compl -- ∎
67+
68+
end SimpleCases
69+
70+
example [TopologicalSpace α] {A X : Set α}
71+
: IsOpenIn A X → IsOpen X → IsOpen A
72+
:= by
73+
intro hAX hX
74+
have hA := hAX.isOpen'
75+
rw [isOpen_induced_iff₂] at hA
76+
obtain ⟨U, hU, hA⟩ := hA
77+
rw [Subtype.image_preimage_val] at hA
78+
-- have : X ∩ A = A := inter_eq_self_of_subset_right hAX.subset'
79+
rw [inter_eq_self_of_subset_right hAX.subset'] at hA
80+
subst hA
81+
refine hX.inter hU
82+
83+
section IsOpenIn
84+
variable {X Y A : Set α}
85+
86+
theorem IsOpenIn.lift [TopologicalSpace α]
87+
: IsOpenIn A X → IsOpen X → IsOpen A
88+
:= by --
89+
intro hAX hX
90+
have hA := hAX.isOpen'
91+
rw [isOpen_induced_iff₂] at hA
92+
obtain ⟨U, hU, hA⟩ := hA
93+
rw [Subtype.image_preimage_val] at hA
94+
rw [inter_eq_self_of_subset_right hAX.subset'] at hA
95+
subst hA
96+
exact hX.inter hU -- ∎
97+
98+
end IsOpenIn
99+
section IsClosedIn
100+
variable {X Y A : Set α}
101+
102+
theorem IsClosedIn.lift [TopologicalSpace α]
103+
: IsClosedIn A X → IsClosed X → IsClosed A
104+
:= by --
105+
intro hAX hX
106+
have hA := hAX.isClosed'
107+
rw [isClosed_induced_iff₂] at hA
108+
obtain ⟨U, hU, hA⟩ := hA
109+
rw [Subtype.image_preimage_val] at hA
110+
rw [inter_eq_self_of_subset_right hAX.subset'] at hA
111+
subst hA
112+
exact hX.inter hU -- ∎
113+
114+
end IsClosedIn
115+
end Munkres

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
# topology
1+
# Munkres
22

3-
## GitHub configuration
4-
5-
To set up your new GitHub repository, follow these steps:
6-
7-
* Under your repository name, click **Settings**.
8-
* In the **Actions** section of the sidebar, click "General".
9-
* Check the box **Allow GitHub Actions to create and approve pull requests**.
10-
* Click the **Pages** section of the settings sidebar.
11-
* In the **Source** dropdown menu, select "GitHub Actions".
12-
13-
After following the steps above, you can remove this section from the README file.
3+
Note: the import order goes: `import`, `open`, `namespace`, `universe`,
4+
`variable`.

lakefile.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defaultTargets = ["Munkres"]
55

66
[leanOptions]
77
pp.unicode.fun = true # pretty-prints `fun a ↦ b`
8-
relaxedAutoImplicit = false
8+
autoImplicit = false
99
weak.linter.mathlibStandardSet = true
1010
maxSynthPendingDepth = 3
1111

0 commit comments

Comments
 (0)