/-- If the `ChartedSpace` structure on a manifold `M` is given by an open embedding `e : M → H`,
then `e` is smooth. -/
lemma contMDiff_openEmbedding :
    haveI := h.singletonChartedSpace; ContMDiff I I n e := by
  haveI := h.singleton_smoothManifoldWithCorners I
  rw [@contMDiff_iff _ _ _ _ _ _ _ _ _ _ h.singletonChartedSpace]
  use h.continuous
  intros x y
  -- show the function is actually the identity on the range of I ∘ e
  apply contDiffOn_id.congr
  intros z hz
  -- factorise into the chart `e` and the model `id`
  simp only [mfld_simps]
  rw [h.toPartialHomeomorph_right_inv]
  · rw [I.right_inv]
    apply mem_of_subset_of_mem _ hz.1
    exact haveI := h.singletonChartedSpace; extChartAt_target_subset_range I x
  · -- `hz` implies that `z ∈ range (I ∘ e)`
    have := hz.1
    rw [@extChartAt_target _ _ _ _ _ _ _ _ _ _ h.singletonChartedSpace] at this
    have := this.1
    

Proof state:
case right
𝕜 : Type u_1
inst✝³⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³⁸ : NormedAddCommGroup E
inst✝³⁷ : NormedSpace 𝕜 E
H : Type u_3
inst✝³⁶ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝³⁵ : TopologicalSpace M
inst✝³⁴ : ChartedSpace H M
inst✝³³ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝³² : NormedAddCommGroup E'
inst✝³¹ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝³⁰ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²⁹ : TopologicalSpace M'
inst✝²⁸ : ChartedSpace H' M'
inst✝²⁷ : SmoothManifoldWithCorners I' M'
E'' : Type u_8
inst✝²⁶ : NormedAddCommGroup E''
inst✝²⁵ : NormedSpace 𝕜 E''
H'' : Type u_9
inst✝²⁴ : TopologicalSpace H''
I'' : ModelWithCorners 𝕜 E'' H''
M'' : Type u_10
inst✝²³ : TopologicalSpace M''
inst✝²² : ChartedSpace H'' M''
F : Type u_11
inst✝²¹ : NormedAddCommGroup F
inst✝²⁰ : NormedSpace 𝕜 F
G : Type u_12
inst✝¹⁹ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_13
inst✝¹⁸ : TopologicalSpace N
inst✝¹⁷ : ChartedSpace G N
inst✝¹⁶ : SmoothManifoldWithCorners J N
F' : Type u_14
inst✝¹⁵ : NormedAddCommGroup F'
inst✝¹⁴ : NormedSpace 𝕜 F'
G' : Type u_15
inst✝¹³ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_16
inst✝¹² : TopologicalSpace N'
inst✝¹¹ : ChartedSpace G' N'
inst✝¹⁰ : SmoothManifoldWithCorners J' N'
F₁ : Type u_17
inst✝⁹ : NormedAddCommGroup F₁
inst✝⁸ : NormedSpace 𝕜 F₁
F₂ : Type u_18
inst✝⁷ : NormedAddCommGroup F₂
inst✝⁶ : NormedSpace 𝕜 F₂
F₃ : Type u_19
inst✝⁵ : NormedAddCommGroup F₃
inst✝⁴ : NormedSpace 𝕜 F₃
F₄ : Type u_20
inst✝³ : NormedAddCommGroup F₄
inst✝² : NormedSpace 𝕜 F₄
e✝ : PartialHomeomorph M H
e'✝ : PartialHomeomorph M' H'
f f₁ : M → M'
s s₁ t : Set M
x✝ : M
m n✝ : ℕ∞
inst✝¹ : Nonempty M
e : M → H
h : OpenEmbedding e
inst✝ : Nonempty M'
e' : M' → H'
h' : OpenEmbedding e'
n : WithTop ℕ
this✝¹ : SmoothManifoldWithCorners I M
x : M
y : H
z : E
hz : z ∈ (extChartAt I x).target ∩ ↑(PartialEquiv.symm (extChartAt I x)) ⁻¹' (e ⁻¹' (extChartAt I y).source)
this✝ : z ∈ ↑(ModelWithCorners.symm I) ⁻¹' (chartAt H x).toPartialEquiv.target ∩ range ↑I
this : z ∈ ↑(ModelWithCorners.symm I) ⁻¹' (chartAt H x).toPartialEquiv.target
⊢ ↑(ModelWithCorners.symm I) z ∈ range e

Next tactic:
rw [mem_preimage, PartialHomeomorph.singletonChartedSpace_chartAt_eq,
      h.toPartialHomeomorph_target] at this