Skip to content

Commit ca91ff1

Browse files
committed
refactor(PartialHomeomorph): make [Nonempty s] explicit (#9894)
Subsets aren't going to have `Nonempty` instances on them, typically, so one would have to manually construct a term of `[Nonempty s]` whenever `PartialHomeomorph.subtypeRestr` is used. Turning this instance argument explicit, `(hs : Nonempty s)` would help us avoid `@PartialHomeomorph.subtypeRestr _ _ _ _` constructions or `haveI : Nonempty ...`. Its only downstream effect currently is in `ChartedSpace.lean`.
1 parent a1bc0ac commit ca91ff1

2 files changed

Lines changed: 39 additions & 42 deletions

File tree

Mathlib/Geometry/Manifold/ChartedSpace.lean

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,8 @@ variable (s : Opens M)
11461146

11471147
/-- An open subset of a charted space is naturally a charted space. -/
11481148
protected instance instChartedSpace : ChartedSpace H s where
1149-
atlas := ⋃ x : s, {@PartialHomeomorph.subtypeRestr _ _ _ _ (chartAt H x.1) s ⟨x⟩}
1150-
chartAt x := @PartialHomeomorph.subtypeRestr _ _ _ _ (chartAt H x.1) s ⟨x⟩
1149+
atlas := ⋃ x : s, {(chartAt H x.1).subtypeRestr s ⟨x⟩}
1150+
chartAt x := (chartAt H x.1).subtypeRestr s ⟨x⟩
11511151
mem_chart_source x := ⟨trivial, mem_chart_source H x.1
11521152
chart_mem_atlas x := by
11531153
simp only [mem_iUnion, mem_singleton_iff]
@@ -1159,42 +1159,35 @@ protected instance instChartedSpace : ChartedSpace H s where
11591159
protected instance instHasGroupoid [ClosedUnderRestriction G] : HasGroupoid s G where
11601160
compatible := by
11611161
rintro e e' ⟨_, ⟨x, hc⟩, he⟩ ⟨_, ⟨x', hc'⟩, he'⟩
1162-
haveI : Nonempty s := ⟨x⟩
11631162
rw [hc.symm, mem_singleton_iff] at he
11641163
rw [hc'.symm, mem_singleton_iff] at he'
11651164
rw [he, he']
11661165
refine' G.mem_of_eqOnSource _
1167-
(subtypeRestr_symm_trans_subtypeRestr s (chartAt H x) (chartAt H x'))
1166+
(subtypeRestr_symm_trans_subtypeRestr s _ (chartAt H x) (chartAt H x'))
11681167
apply closedUnderRestriction'
11691168
· exact G.compatible (chart_mem_atlas _ _) (chart_mem_atlas _ _)
11701169
· exact isOpen_inter_preimage_symm (chartAt _ _) s.2
11711170
#align topological_space.opens.has_groupoid TopologicalSpace.Opens.instHasGroupoid
11721171

11731172
theorem chartAt_subtype_val_symm_eventuallyEq (U : Opens M) {x : U} :
11741173
(chartAt H x.val).symm =ᶠ[𝓝 (chartAt H x.val x.val)] Subtype.val ∘ (chartAt H x).symm := by
1175-
set i : U → M := Subtype.val
11761174
set e := chartAt H x.val
1177-
haveI : Nonempty U := ⟨x⟩
1178-
haveI : Nonempty M := ⟨i x⟩
1179-
have heUx_nhds : (e.subtypeRestr U).target ∈ 𝓝 (e x) := by
1180-
apply (e.subtypeRestr U).open_target.mem_nhds
1181-
exact e.map_subtype_source (mem_chart_source _ _)
1182-
exact Filter.eventuallyEq_of_mem heUx_nhds (e.subtypeRestr_symm_eqOn U)
1175+
have heUx_nhds : (e.subtypeRestr U ⟨x⟩).target ∈ 𝓝 (e x) := by
1176+
apply (e.subtypeRestr U ⟨x⟩).open_target.mem_nhds
1177+
exact e.map_subtype_source ⟨x⟩ (mem_chart_source _ _)
1178+
exact Filter.eventuallyEq_of_mem heUx_nhds (e.subtypeRestr_symm_eqOn U ⟨x⟩)
11831179

11841180
theorem chartAt_inclusion_symm_eventuallyEq {U V : Opens M} (hUV : U ≤ V) {x : U} :
11851181
(chartAt H (Set.inclusion hUV x)).symm
11861182
=ᶠ[𝓝 (chartAt H (Set.inclusion hUV x) (Set.inclusion hUV x))]
11871183
Set.inclusion hUV ∘ (chartAt H x).symm := by
1188-
set i := Set.inclusion hUV
11891184
set e := chartAt H (x : M)
1190-
haveI : Nonempty U := ⟨x⟩
1191-
haveI : Nonempty V := ⟨i x⟩
1192-
have heUx_nhds : (e.subtypeRestr U).target ∈ 𝓝 (e x) := by
1193-
apply (e.subtypeRestr U).open_target.mem_nhds
1194-
exact e.map_subtype_source (mem_chart_source _ _)
1195-
exact Filter.eventuallyEq_of_mem heUx_nhds (e.subtypeRestr_symm_eqOn_of_le hUV)
1185+
have heUx_nhds : (e.subtypeRestr U ⟨x⟩).target ∈ 𝓝 (e x) := by
1186+
apply (e.subtypeRestr U ⟨x⟩).open_target.mem_nhds
1187+
exact e.map_subtype_source ⟨x⟩ (mem_chart_source _ _)
1188+
exact Filter.eventuallyEq_of_mem heUx_nhds <| e.subtypeRestr_symm_eqOn_of_le ⟨x⟩
1189+
⟨Set.inclusion hUV x⟩ hUV
11961190
#align topological_space.opens.chart_at_inclusion_symm_eventually_eq TopologicalSpace.Opens.chartAt_inclusion_symm_eventuallyEq
1197-
11981191
end TopologicalSpace.Opens
11991192

12001193
/-! ### Structomorphisms -/

Mathlib/Topology/PartialHomeomorph.lean

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,10 @@ end OpenEmbedding
13931393
/- inclusion of an open set in a topological space -/
13941394
namespace TopologicalSpace.Opens
13951395

1396-
variable (s : Opens α) [Nonempty s]
1396+
/- `Nonempty s` is not a type class argument because `s`, being a subset, rarely comes with a type
1397+
class instance. Then we'd have to manually provide the instance every time we use the following
1398+
lemmas, tediously using `haveI := ...` or `@foobar _ _ _ ...`. -/
1399+
variable (s : Opens α) (hs : Nonempty s)
13971400

13981401
/-- The inclusion of an open subset `s` of a space `α` into `α` is a partial homeomorphism from the
13991402
subtype `s` to `α`. -/
@@ -1402,17 +1405,17 @@ noncomputable def partialHomeomorphSubtypeCoe : PartialHomeomorph s α :=
14021405
#align topological_space.opens.local_homeomorph_subtype_coe TopologicalSpace.Opens.partialHomeomorphSubtypeCoe
14031406

14041407
@[simp, mfld_simps]
1405-
theorem partialHomeomorphSubtypeCoe_coe : (s.partialHomeomorphSubtypeCoe : s → α) = (↑) :=
1408+
theorem partialHomeomorphSubtypeCoe_coe : (s.partialHomeomorphSubtypeCoe hs : s → α) = (↑) :=
14061409
rfl
14071410
#align topological_space.opens.local_homeomorph_subtype_coe_coe TopologicalSpace.Opens.partialHomeomorphSubtypeCoe_coe
14081411

14091412
@[simp, mfld_simps]
1410-
theorem partialHomeomorphSubtypeCoe_source : s.partialHomeomorphSubtypeCoe.source = Set.univ :=
1413+
theorem partialHomeomorphSubtypeCoe_source : (s.partialHomeomorphSubtypeCoe hs).source = Set.univ :=
14111414
rfl
14121415
#align topological_space.opens.local_homeomorph_subtype_coe_source TopologicalSpace.Opens.partialHomeomorphSubtypeCoe_source
14131416

14141417
@[simp, mfld_simps]
1415-
theorem partialHomeomorphSubtypeCoe_target : s.partialHomeomorphSubtypeCoe.target = s := by
1418+
theorem partialHomeomorphSubtypeCoe_target : (s.partialHomeomorphSubtypeCoe hs).target = s := by
14161419
simp only [partialHomeomorphSubtypeCoe, Subtype.range_coe_subtype, mfld_simps]
14171420
rfl
14181421
#align topological_space.opens.local_homeomorph_subtype_coe_target TopologicalSpace.Opens.partialHomeomorphSubtypeCoe_target
@@ -1459,31 +1462,32 @@ open TopologicalSpace
14591462

14601463
variable (e : PartialHomeomorph α β)
14611464

1462-
variable (s : Opens α) [Nonempty s]
1465+
variable (s : Opens α) (hs : Nonempty s)
14631466

14641467
/-- The restriction of a partial homeomorphism `e` to an open subset `s` of the domain type
14651468
produces a partial homeomorphism whose domain is the subtype `s`. -/
14661469
noncomputable def subtypeRestr : PartialHomeomorph s β :=
1467-
s.partialHomeomorphSubtypeCoe.trans e
1470+
(s.partialHomeomorphSubtypeCoe hs).trans e
14681471
#align local_homeomorph.subtype_restr PartialHomeomorph.subtypeRestr
14691472

1470-
theorem subtypeRestr_def : e.subtypeRestr s = s.partialHomeomorphSubtypeCoe.trans e :=
1473+
theorem subtypeRestr_def : e.subtypeRestr s hs = (s.partialHomeomorphSubtypeCoe hs).trans e :=
14711474
rfl
14721475
#align local_homeomorph.subtype_restr_def PartialHomeomorph.subtypeRestr_def
14731476

14741477
@[simp, mfld_simps]
14751478
theorem subtypeRestr_coe :
1476-
((e.subtypeRestr s : PartialHomeomorph s β) : s → β) = Set.restrict ↑s (e : α → β) :=
1479+
((e.subtypeRestr s hs : PartialHomeomorph s β) : s → β) = Set.restrict ↑s (e : α → β) :=
14771480
rfl
14781481
#align local_homeomorph.subtype_restr_coe PartialHomeomorph.subtypeRestr_coe
14791482

14801483
@[simp, mfld_simps]
1481-
theorem subtypeRestr_source : (e.subtypeRestr s).source = (↑) ⁻¹' e.source := by
1484+
theorem subtypeRestr_source : (e.subtypeRestr s hs).source = (↑) ⁻¹' e.source := by
14821485
simp only [subtypeRestr_def, mfld_simps]
14831486
#align local_homeomorph.subtype_restr_source PartialHomeomorph.subtypeRestr_source
14841487

14851488
variable {s} in
1486-
theorem map_subtype_source {x : s} (hxe : (x : α) ∈ e.source): e x ∈ (e.subtypeRestr s).target := by
1489+
theorem map_subtype_source {x : s} (hxe : (x : α) ∈ e.source) :
1490+
e x ∈ (e.subtypeRestr s hs).target := by
14871491
refine' ⟨e.map_source hxe, _⟩
14881492
rw [s.partialHomeomorphSubtypeCoe_target, mem_preimage, e.leftInvOn hxe]
14891493
exact x.prop
@@ -1492,7 +1496,7 @@ theorem map_subtype_source {x : s} (hxe : (x : α) ∈ e.source): e x ∈ (e.sub
14921496
/- This lemma characterizes the transition functions of an open subset in terms of the transition
14931497
functions of the original space. -/
14941498
theorem subtypeRestr_symm_trans_subtypeRestr (f f' : PartialHomeomorph α β) :
1495-
(f.subtypeRestr s).symm.trans (f'.subtypeRestr s) ≈
1499+
(f.subtypeRestr s hs).symm.trans (f'.subtypeRestr s hs) ≈
14961500
(f.symm.trans f').restr (f.target ∩ f.symm ⁻¹' s) := by
14971501
simp only [subtypeRestr_def, trans_symm_eq_symm_trans_symm]
14981502
have openness₁ : IsOpen (f.target ∩ f.symm ⁻¹' s) := f.isOpen_inter_preimage_symm s.2
@@ -1505,35 +1509,35 @@ theorem subtypeRestr_symm_trans_subtypeRestr (f f' : PartialHomeomorph α β) :
15051509
rw [ofSet_trans', sets_identity, ← trans_of_set' _ openness₂, trans_assoc]
15061510
refine' EqOnSource.trans' (eqOnSource_refl _) _
15071511
-- f has been eliminated !!!
1508-
refine' Setoid.trans (symm_trans_self s.partialHomeomorphSubtypeCoe) _
1512+
refine' Setoid.trans (symm_trans_self (s.partialHomeomorphSubtypeCoe hs)) _
15091513
simp only [mfld_simps, Setoid.refl]
15101514
#align local_homeomorph.subtype_restr_symm_trans_subtype_restr PartialHomeomorph.subtypeRestr_symm_trans_subtypeRestr
15111515

1512-
theorem subtypeRestr_symm_eqOn (U : Opens α) [Nonempty U] :
1513-
EqOn e.symm (Subtype.val ∘ (e.subtypeRestr U).symm) (e.subtypeRestr U).target := by
1516+
theorem subtypeRestr_symm_eqOn (U : Opens α) (hU : Nonempty U) :
1517+
EqOn e.symm (Subtype.val ∘ (e.subtypeRestr U hU).symm) (e.subtypeRestr U hU).target := by
15141518
intro y hy
15151519
rw [eq_comm, eq_symm_apply _ _ hy.1]
15161520
· change restrict _ e _ = _
1517-
rw [← subtypeRestr_coe, (e.subtypeRestr U).right_inv hy]
1521+
rw [← subtypeRestr_coe, (e.subtypeRestr U hU).right_inv hy]
15181522
· have := map_target _ hy; rwa [subtypeRestr_source] at this
15191523

1520-
theorem subtypeRestr_symm_eqOn_of_le {U V : Opens α} [Nonempty U] [Nonempty V] (hUV : U ≤ V) :
1521-
EqOn (e.subtypeRestr V).symm (Set.inclusion hUV ∘ (e.subtypeRestr U).symm)
1522-
(e.subtypeRestr U).target := by
1524+
theorem subtypeRestr_symm_eqOn_of_le {U V : Opens α} (hU : Nonempty U) (hV : Nonempty V)
1525+
(hUV : U ≤ V) : EqOn (e.subtypeRestr V hV).symm (Set.inclusion hUV ∘ (e.subtypeRestr U hU).symm)
1526+
(e.subtypeRestr U hU).target := by
15231527
set i := Set.inclusion hUV
15241528
intro y hy
15251529
dsimp [PartialHomeomorph.subtypeRestr_def] at hy ⊢
1526-
have hyV : e.symm y ∈ V.partialHomeomorphSubtypeCoe.target := by
1530+
have hyV : e.symm y ∈ (V.partialHomeomorphSubtypeCoe hV).target := by
15271531
rw [Opens.partialHomeomorphSubtypeCoe_target] at hy ⊢
15281532
exact hUV hy.2
1529-
refine' V.partialHomeomorphSubtypeCoe.injOn _ trivial _
1533+
refine' (V.partialHomeomorphSubtypeCoe hV).injOn _ trivial _
15301534
· rw [← PartialHomeomorph.symm_target]
15311535
apply PartialHomeomorph.map_source
15321536
rw [PartialHomeomorph.symm_source]
15331537
exact hyV
1534-
· rw [V.partialHomeomorphSubtypeCoe.right_inv hyV]
1535-
show _ = U.partialHomeomorphSubtypeCoe _
1536-
rw [U.partialHomeomorphSubtypeCoe.right_inv hy.2]
1538+
· rw [(V.partialHomeomorphSubtypeCoe hV).right_inv hyV]
1539+
show _ = U.partialHomeomorphSubtypeCoe hU _
1540+
rw [(U.partialHomeomorphSubtypeCoe hU).right_inv hy.2]
15371541
#align local_homeomorph.subtype_restr_symm_eq_on_of_le PartialHomeomorph.subtypeRestr_symm_eqOn_of_le
15381542

15391543
end subtypeRestr

0 commit comments

Comments
 (0)