/-- If a function is `C^n` with `1 ≤ n` on a domain with unique derivatives, then its bundled
derivative is continuous. In this auxiliary lemma, we prove this fact when the source and target
space are model spaces in models with corners. The general fact is proved in
`ContMDiffOn.continuousOn_tangentMapWithin`-/
theorem ContMDiffOn.continuousOn_tangentMapWithin_aux {f : H → H'} {s : Set H}
    (hf : ContMDiffOn I I' n f s) (hn : 1 ≤ n) (hs : UniqueMDiffOn I s) :
    ContinuousOn (tangentMapWithin I I' f s) (π E (TangentSpace I) ⁻¹' s) := by
  suffices h :
    ContinuousOn
      (fun p : H × E =>
        (f p.fst,
          (fderivWithin 𝕜 (writtenInExtChartAt I I' p.fst f) (I.symm ⁻¹' s ∩ range I)
                ((extChartAt I p.fst) p.fst) : E →L[𝕜] E') p.snd)) (Prod.fst ⁻¹' s)
  · have A := (tangentBundleModelSpaceHomeomorph H I).continuous
    rw [continuous_iff_continuousOn_univ] at A
    have B :=
      ((tangentBundleModelSpaceHomeomorph H' I').symm.continuous.comp_continuousOn h).comp' A
    have :
      univ ∩ tangentBundleModelSpaceHomeomorph H I ⁻¹' (Prod.fst ⁻¹' s) =
        π E (TangentSpace I) ⁻¹' s :=
      by ext ⟨x, v⟩; simp only [mfld_simps]
    rw [this] at B
    apply B.congr
    rintro ⟨x, v⟩ hx
    dsimp [tangentMapWithin]
    ext; · rfl
    

Proof state:
case mk.snd
𝕜 : 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
Is : 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'
I's : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹³ : NormedAddCommGroup F
inst✝¹² : NormedSpace 𝕜 F
G : Type u_9
inst✝¹¹ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁰ : TopologicalSpace N
inst✝⁹ : ChartedSpace G N
Js : SmoothManifoldWithCorners J N
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'
J's : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝³ : NormedAddCommGroup F₁
inst✝² : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝¹ : NormedAddCommGroup F₂
inst✝ : NormedSpace 𝕜 F₂
f✝ f₁ : M → M'
s✝ s₁ t : Set M
x✝ : M
m n : ℕ∞
f : H → H'
s : Set H
hf : ContMDiffOn I I' n f s
hn : 1 ≤ n
hs : UniqueMDiffOn I s
h :
  ContinuousOn
    (fun p =>
      (f p.1,
        (fderivWithin 𝕜 (writtenInExtChartAt I I' p.1 f) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I)
            (↑(extChartAt I p.1) p.1))
          p.2))
    (Prod.fst ⁻¹' s)
A : ContinuousOn (⇑(tangentBundleModelSpaceHomeomorph H I)) univ
B :
  ContinuousOn
    ((⇑(Homeomorph.symm (tangentBundleModelSpaceHomeomorph H' I')) ∘ fun p =>
        (f p.1,
          (fderivWithin 𝕜 (writtenInExtChartAt I I' p.1 f) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I)
              (↑(extChartAt I p.1) p.1))
            p.2)) ∘
      ⇑(tangentBundleModelSpaceHomeomorph H I))
    (TotalSpace.proj ⁻¹' s)
this : univ ∩ ⇑(tangentBundleModelSpaceHomeomorph H I) ⁻¹' (Prod.fst ⁻¹' s) = TotalSpace.proj ⁻¹' s
x : H
v : TangentSpace I x
hx : { proj := x, snd := v } ∈ TotalSpace.proj ⁻¹' s
⊢ HEq { proj := f x, snd := (mfderivWithin I I' f s x) v }.snd
    ((TotalSpace.toProd H' E').symm
        (f x,
          (fderivWithin 𝕜
              ((↑I' ∘ ↑(chartAt H' (f x))) ∘ f ∘ ↑(PartialHomeomorph.symm (chartAt H x)) ∘ ↑(ModelWithCorners.symm I))
              (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I) (↑I (↑(chartAt H x) x)))
            v)).snd

Next tactic:
simp only [mfld_simps]