import geometry.manifold.cont_mdiff import global.indexing import to_mathlib.topology.paracompact import to_mathlib.topology.local_homeomorph import to_mathlib.geometry.manifold.charted_space noncomputable theory open set equiv open_locale manifold topological_space section general variables {π•œ : Type*} [nontrivially_normed_field π•œ] {E : Type*} [normed_add_comm_group E] [normed_space π•œ E] {H : Type*} [topological_space H] (I : model_with_corners π•œ E H) (M : Type*) [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {E' : Type*} [normed_add_comm_group E'] [normed_space π•œ E'] {H' : Type*} [topological_space H'] (I' : model_with_corners π•œ E' H') (M' : Type*) [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] structure open_smooth_embedding := (to_fun : M β†’ M') (inv_fun : M' β†’ M) (left_inv' : βˆ€{x}, inv_fun (to_fun x) = x) (right_inv' : βˆ€{x}, x ∈ range to_fun β†’ to_fun (inv_fun x) = x) (open_map : is_open_map to_fun) (smooth_to : smooth I I' to_fun) (smooth_inv : smooth_on I' I inv_fun (range to_fun)) instance : has_coe_to_fun (open_smooth_embedding I M I' M') (Ξ» _, M β†’ M') := ⟨open_smooth_embedding.to_fun⟩ namespace open_smooth_embedding variables {I I' M M'} (f : open_smooth_embedding I M I' M') @[simp] lemma left_inv (x : M) : f.inv_fun (f x) = x := by apply f.left_inv' @[simp] lemma inv_fun_comp_coe : f.inv_fun ∘ f = id := funext f.left_inv @[simp] lemma right_inv {y : M'} (hy : y ∈ range f) : f (f.inv_fun y) = y := f.right_inv' hy lemma coe_comp_inv_fun_eventually_eq (x : M) : f ∘ f.inv_fun =αΆ [𝓝 (f x)] id := filter.eventually_of_mem (f.open_map.range_mem_nhds x) $ Ξ» y hy, f.right_inv' hy lemma is_open_range : is_open (range f) := f.open_map.is_open_range lemma smooth_at_inv {y : M'} (hy : y ∈ range f) : smooth_at I' I f.inv_fun y := (f.smooth_inv y hy).cont_mdiff_at $ f.is_open_range.mem_nhds hy /- Note that we are slightly abusing the fact that `tangent_space I x` and `tangent_space I (f.inv_fun (f x))` are both definitionally `E` below. -/ def fderiv (x : M) : tangent_space I x ≃L[π•œ] tangent_space I' (f x) := have h₁ : mdifferentiable_at I' I f.inv_fun (f x) := ((f.smooth_inv (f x) (mem_range_self x) ).mdifferentiable_within_at le_top).mdifferentiable_at (f.open_map.range_mem_nhds x), have hβ‚‚ : mdifferentiable_at I I' f x := f.smooth_to.cont_mdiff.mdifferentiable le_top _, continuous_linear_equiv.equiv_of_inverse (mfderiv I I' f x) (mfderiv I' I f.inv_fun (f x)) begin intros v, rw [← continuous_linear_map.comp_apply, ← mfderiv_comp x h₁ hβ‚‚, f.inv_fun_comp_coe, mfderiv_id, continuous_linear_map.coe_id', id.def], end begin intros v, have hx : x = f.inv_fun (f x), { rw f.left_inv, }, have hx' : f (f.inv_fun (f x)) = f x, { rw f.left_inv, }, rw hx at hβ‚‚, rw [hx, hx', ← continuous_linear_map.comp_apply, ← mfderiv_comp (f x) hβ‚‚ h₁, ((has_mfderiv_at_id I' (f x)).congr_of_eventually_eq (f.coe_comp_inv_fun_eventually_eq x)).mfderiv, continuous_linear_map.coe_id', id.def], end @[simp] lemma fderiv_coe (x : M) : (f.fderiv x : tangent_space I x β†’L[π•œ] tangent_space I' (f x)) = mfderiv I I' f x := by { ext, refl } @[simp] lemma fderiv_symm_coe (x : M) : ((f.fderiv x).symm : tangent_space I' (f x) β†’L[π•œ] tangent_space I x) = mfderiv I' I f.inv_fun (f x) := by { ext, refl } lemma fderiv_symm_coe' {x : M'} (hx : x ∈ range f) : ((f.fderiv (f.inv_fun x)).symm : tangent_space I' (f (f.inv_fun x)) β†’L[π•œ] tangent_space I (f.inv_fun x)) = (mfderiv I' I f.inv_fun x : tangent_space I' x β†’L[π•œ] tangent_space I (f.inv_fun x)) := by rw [fderiv_symm_coe, f.right_inv hx] end open_smooth_embedding end general section without_boundary open metric (hiding mem_nhds_iff) function universe u variables {π•œ : Type*} [nontrivially_normed_field π•œ] {E : Type*} [normed_add_comm_group E] [normed_space π•œ E] (M : Type u) [topological_space M] [charted_space E M] [smooth_manifold_with_corners π“˜(π•œ, E) M] [t2_space M] [locally_compact_space M] [sigma_compact_space M] /- Clearly should be generalised. Maybe what we really want is a theory of local diffeomorphisms. -/ def open_smooth_embedding_of_subset_chart_target {x : M} {f : open_smooth_embedding π“˜(π•œ, E) E π“˜(π•œ, E) E} (hf : range f βŠ† (chart_at E x).target) : open_smooth_embedding π“˜(π•œ, E) E π“˜(π•œ, E) M := { to_fun := (chart_at E x).symm ∘ f, inv_fun := f.inv_fun ∘ (chart_at E x), left_inv' := Ξ» y, by simp [hf (mem_range_self y)], right_inv' := by { rintros - ⟨y, rfl⟩, simp [hf (mem_range_self y)], }, open_map := Ξ» u hu, begin rw image_comp, apply local_homeomorph.image_open_of_open _ (f.open_map _ hu), rw ← image_univ at hf, exact (monotone_image (subset_univ u)).trans hf, end, smooth_to := cont_mdiff_on_chart_symm.comp_cont_mdiff f.smooth_to (range_subset_iff.mp hf), smooth_inv := begin have hf' : range ((chart_at E x).symm ∘ f) βŠ† (chart_at E x) ⁻¹' range f, { rw [range_comp, ← image_subset_iff], exact (local_equiv.image_symm_image_of_subset_target _ hf).subset }, refine f.smooth_inv.comp _ hf', have hf'' : range ((chart_at E x).symm ∘ f) βŠ† (chart_at E x).source, { rw [range_comp, ← local_equiv.symm_image_target_eq_source], exact (monotone_image hf).trans subset.rfl, }, exact cont_mdiff_on_chart.mono hf'', end } @[simp] lemma coe_open_smooth_embedding_of_subset_chart_target {x : M} {f : open_smooth_embedding π“˜(π•œ, E) E π“˜(π•œ, E) E} (hf : range f βŠ† (chart_at E x).target) : (open_smooth_embedding_of_subset_chart_target M hf : E β†’ M) = (chart_at E x).symm ∘ f := rfl variables (π•œ) /-- Provided `0 < r`, this is a diffeomorphism from `E` onto the open ball of radius `r` in `E` centred at a point `c` and sending `0` to `c`. The values for `r ≀ 0` are junk. -/ def open_smooth_embedding_to_ball (c : E) (r : ℝ) : open_smooth_embedding π“˜(π•œ, E) E π“˜(π•œ, E) E := sorry @[simp] lemma open_smooth_embedding_to_ball_apply_zero (c : E) {r : ℝ} (h : 0 < r) : open_smooth_embedding_to_ball π•œ c r 0 = c := sorry @[simp] lemma range_open_smooth_embedding_to_ball (c : E) {r : ℝ} (h : 0 < r) : range (open_smooth_embedding_to_ball π•œ c r) = ball c r := sorry variables (E) {M} lemma nice_atlas' {ΞΉ : Type*} {s : ΞΉ β†’ set M} (s_op : βˆ€ j, is_open $ s j) (cov : (⋃ j, s j) = univ) : βˆƒ (ΞΉ' : Type u) (t : set ΞΉ') (Ο† : t β†’ open_smooth_embedding π“˜(π•œ, E) E π“˜(π•œ, E) M), t.countable ∧ (βˆ€ i, βˆƒ j, range (Ο† i) βŠ† s j) ∧ locally_finite (Ξ» i, range (Ο† i)) ∧ (⋃ i, Ο† i '' ball 0 1) = univ := begin let W : M β†’ ℝ β†’ set M := Ξ» x r, (chart_at E x).symm ∘ open_smooth_embedding_to_ball π•œ (chart_at E x x) r '' (ball 0 1), let B : M β†’ ℝ β†’ set M := charted_space.ball E, let p : M β†’ ℝ β†’ Prop := Ξ» x r, 0 < r ∧ ball (chart_at E x x) r βŠ† (chart_at E x).target ∧ βˆƒ j, B x r βŠ† s j, have hWβ‚€ : βˆ€ x r, p x r β†’ x ∈ W x r := Ξ» x r h, ⟨0, by simp, by simp [h.1]⟩, have hW₁ : βˆ€ x r, p x r β†’ is_open (W x r), { rintros x r ⟨h₁, hβ‚‚, -, -⟩, simp only [W], have aux : open_smooth_embedding_to_ball π•œ (chart_at E x x) r '' ball 0 1 βŠ† (chart_at E x).target := subset.trans ((image_subset_range _ _).trans (by simp [h₁])) hβ‚‚, rw [image_comp, local_homeomorph.is_open_symm_image_iff_of_subset_target _ aux], exact open_smooth_embedding.open_map _ _ is_open_ball, }, have hB : βˆ€ x, (𝓝 x).has_basis (p x) (B x) := Ξ» x, charted_space.nhds_has_basis_balls_of_open_cov E x s_op cov, have hp : βˆ€ i r, p i r β†’ 0 < r := Ξ» i r h, h.1, obtain ⟨t, ht₁, htβ‚‚, ht₃, htβ‚„βŸ© := exists_countable_locally_finite_cover surjective_id hp hWβ‚€ hW₁ hB, refine ⟨M Γ— ℝ, t, Ξ» z, _, ht₁, Ξ» z, _, _, _⟩, { have h : range (open_smooth_embedding_to_ball π•œ (chart_at E z.1.1 z.1.1) z.1.2) βŠ† (chart_at E z.1.1).target, { have aux : 0 < z.val.snd := hp _ _ (htβ‚‚ _ z.2), simpa only [range_open_smooth_embedding_to_ball, aux] using (htβ‚‚ _ z.2).2.1, }, exact open_smooth_embedding_of_subset_chart_target M h, }, { have aux : 0 < (z : M Γ— ℝ).snd := hp _ _ (htβ‚‚ _ z.2), simp only [subtype.val_eq_coe, coe_open_smooth_embedding_of_subset_chart_target], simp only [range_comp, range_open_smooth_embedding_to_ball, aux], exact (htβ‚‚ z.1 z.2).2.2, }, { convert htβ‚„, ext1 z, have aux : 0 < (z : M Γ— ℝ).snd := hp _ _ (htβ‚‚ _ z.2), simp only [subtype.val_eq_coe, coe_open_smooth_embedding_of_subset_chart_target], simpa only [range_comp, range_open_smooth_embedding_to_ball, aux], }, { simpa only [Union_coe_set] using ht₃, }, end variables [nonempty M] lemma nice_atlas {ΞΉ : Type*} {s : ΞΉ β†’ set M} (s_op : βˆ€ j, is_open $ s j) (cov : (⋃ j, s j) = univ) : βˆƒ n, βˆƒ Ο† : index_type n β†’ open_smooth_embedding π“˜(π•œ, E) E π“˜(π•œ, E) M, (βˆ€ i, βˆƒ j, range (Ο† i) βŠ† s j) ∧ locally_finite (Ξ» i, range (Ο† i)) ∧ (⋃ i, Ο† i '' ball 0 1) = univ := begin obtain ⟨ι', t, Ο†, h₁, hβ‚‚, h₃, hβ‚„βŸ© := nice_atlas' π•œ E s_op cov, have htne : t.nonempty, { by_contra contra, simp only [not_nonempty_iff_eq_empty.mp contra, Union_false, Union_coe_set, Union_empty, @eq_comm _ _ univ, univ_eq_empty_iff] at hβ‚„, exact not_is_empty_of_nonempty M hβ‚„, }, obtain ⟨n, ⟨fn⟩⟩ := (set.countable_iff_exists_nonempty_index_type_equiv htne).mp h₁, refine ⟨n, Ο† ∘ fn, Ξ» i, hβ‚‚ (fn i), h₃.comp_injective fn.injective, _⟩, rwa fn.surjective.Union_comp (Ξ» i, Ο† i '' ball 0 1), end end without_boundary