theorem isLocalStructomorphOn_contDiffGroupoid_iff_aux {f : PartialHomeomorph M M'}
    (hf : LiftPropOn (contDiffGroupoid ⊤ I).IsLocalStructomorphWithinAt f f.source) :
    SmoothOn I I f f.source := by
  -- It suffices to show smoothness near each `x`
  apply contMDiffOn_of_locally_contMDiffOn
  intro x hx
  let c := chartAt H x
  let c' := chartAt H (f x)
  obtain ⟨-, hxf⟩ := hf x hx
  -- Since `f` is a local structomorph, it is locally equal to some transferred element `e` of
  -- the `contDiffGroupoid`.
  obtain
    ⟨e, he, he' : EqOn (c' ∘ f ∘ c.symm) e (c.symm ⁻¹' f.source ∩ e.source), hex :
      c x ∈ e.source⟩ :=
    hxf (by simp only [hx, mfld_simps])
  -- We choose a convenient set `s` in `M`.
  let s : Set M := (f.trans c').source ∩ ((c.trans e).trans c'.symm).source
  refine' ⟨s, (f.trans c').open_source.inter ((c.trans e).trans c'.symm).open_source, _, _⟩
  · simp only [mfld_simps]
    rw [← he'] <;> simp only [hx, hex, mfld_simps]
  -- We need to show `f` is `ContMDiffOn` the domain `s ∩ f.source`.  We show this in two
  -- steps: `f` is equal to `c'.symm ∘ e ∘ c` on that domain and that function is
  -- `ContMDiffOn` it.
  have H₁ : ContMDiffOn I I ⊤ (c'.symm ∘ e ∘ c) s := by
    have hc' : ContMDiffOn I I ⊤ c'.symm _ := contMDiffOn_chart_symm
    have he'' : ContMDiffOn I I ⊤ e _ := contMDiffOn_of_mem_contDiffGroupoid he
    have hc : ContMDiffOn I I ⊤ c _ := contMDiffOn_chart
    refine' (hc'.comp' (he''.comp' hc)).mono _
    mfld_set_tac
  have H₂ : EqOn f (c'.symm ∘ e ∘ c) s := by
    intro y hy
    simp only [mfld_simps] at hy
    have hy₁ : f y ∈ c'.source := by 

Proof state:
𝕜 : 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✝ : PartialHomeomorph M H
x✝ : M
m n : ℕ∞
inst✝ : ChartedSpace H M'
IsM' : SmoothManifoldWithCorners I M'
f : PartialHomeomorph M M'
hf : LiftPropOn (StructureGroupoid.IsLocalStructomorphWithinAt (contDiffGroupoid ⊤ I)) (↑f) f.source
x : M
hx : x ∈ f.source
c : PartialHomeomorph M H := chartAt H x
c' : PartialHomeomorph M' H := chartAt H (↑f x)
hxf :
  StructureGroupoid.IsLocalStructomorphWithinAt (contDiffGroupoid ⊤ I)
    (↑(chartAt H (↑f x)) ∘ ↑f ∘ ↑(PartialHomeomorph.symm (chartAt H x)))
    (↑(PartialHomeomorph.symm (chartAt H x)) ⁻¹' f.source) (↑(chartAt H x) x)
e : PartialHomeomorph H H
he : e ∈ contDiffGroupoid ⊤ I
he' : EqOn (↑c' ∘ ↑f ∘ ↑(PartialHomeomorph.symm c)) (↑e) (↑(PartialHomeomorph.symm c) ⁻¹' f.source ∩ e.source)
hex : ↑c x ∈ e.source
s : Set M := (f ≫ₕ c').toPartialEquiv.source ∩ ((c ≫ₕ e) ≫ₕ PartialHomeomorph.symm c').toPartialEquiv.source
H₁ : ContMDiffOn I I ⊤ (↑(PartialHomeomorph.symm c') ∘ ↑e ∘ ↑c) s
y : M
hy :
  (y ∈ f.source ∧ ↑f y ∈ (chartAt H (↑f x)).toPartialEquiv.source) ∧
    (y ∈ (chartAt H x).toPartialEquiv.source ∧ ↑(chartAt H x) y ∈ e.source) ∧
      ↑e (↑(chartAt H x) y) ∈ (chartAt H (↑f x)).toPartialEquiv.target
⊢ ↑f y ∈ c'.source

Next tactic:
simp only [hy, mfld_simps]