l3lab/ntp-mathlib huggingface dataset:
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 

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)
⊢ ↑(chartAt H x) x ∈ ↑(PartialHomeomorph.symm (chartAt H x)) ⁻¹' f.source

Next tactic:
simp only [hx, mfld_simps]
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`.
  

Proof state:
case h.intro.intro.intro.intro
𝕜 : 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
⊢ ∃ u, IsOpen u ∧ x ∈ u ∧ ContMDiffOn I I ⊤ (↑f) (f.source ∩ u)

Next tactic:
let s : Set M := (f.trans c').source ∩ ((c.trans e).trans c'.symm).source
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
  

Proof state:
case h.intro.intro.intro.intro
𝕜 : 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
⊢ ∃ u, IsOpen u ∧ x ∈ u ∧ ContMDiffOn I I ⊤ (↑f) (f.source ∩ u)

Next tactic:
refine' ⟨s, (f.trans c').open_source.inter ((c.trans e).trans c'.symm).open_source, _, _⟩
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, _, _⟩
  · 

Proof state:
case h.intro.intro.intro.intro.refine'_1
𝕜 : 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
⊢ x ∈ s

Next tactic:
simp only [mfld_simps]
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]
    

Proof state:
case h.intro.intro.intro.intro.refine'_1
𝕜 : 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
⊢ x ∈ f.source ∧ ↑(chartAt H x) x ∈ e.source ∧ ↑e (↑(chartAt H x) x) ∈ (chartAt H (↑f x)).toPartialEquiv.target

Next tactic:
rw [← he']
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'] <;> 

Proof state:
case h.intro.intro.intro.intro.refine'_1
𝕜 : 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
⊢ x ∈ f.source ∧
    ↑(chartAt H x) x ∈ e.source ∧
      (↑c' ∘ ↑f ∘ ↑(PartialHomeomorph.symm c)) (↑(chartAt H x) x) ∈ (chartAt H (↑f x)).toPartialEquiv.target

Next tactic:
simp only [hx, hex, mfld_simps]
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'] <;> 

Proof state:
case h.intro.intro.intro.intro.refine'_1.a
𝕜 : 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
⊢ ↑(chartAt H x) x ∈ ↑(PartialHomeomorph.symm c) ⁻¹' f.source ∩ e.source

Next tactic:
simp only [hx, hex, mfld_simps]
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.
  

Proof state:
case h.intro.intro.intro.intro.refine'_2
𝕜 : 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
⊢ ContMDiffOn I I ⊤ (↑f) (f.source ∩ s)

Next tactic:
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
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
    

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
⊢ ContMDiffOn I I ⊤ (↑(PartialHomeomorph.symm c') ∘ ↑e ∘ ↑c) s

Next tactic:
have hc' : ContMDiffOn I I ⊤ c'.symm _ := contMDiffOn_chart_symm