/-- The composition of structomorphisms is a structomorphism. -/
def Structomorph.trans (e : Structomorph G M M') (e' : Structomorph G M' M'') :
    Structomorph G M M'' :=
  { Homeomorph.trans e.toHomeomorph e'.toHomeomorph with
    mem_groupoid := by
      /- Let c and c' be two charts in M and M''. We want to show that e' ∘ e is smooth in these
      charts, around any point x. For this, let y = e (c⁻¹ x), and consider a chart g around y.
      Then g ∘ e ∘ c⁻¹ and c' ∘ e' ∘ g⁻¹ are both smooth as e and e' are structomorphisms, so
      their composition is smooth, and it coincides with c' ∘ e' ∘ e ∘ c⁻¹ around x. -/
      intro c c' hc hc'
      refine' G.locality fun x hx ↦ _
      let f₁ := e.toHomeomorph.toPartialHomeomorph
      let f₂ := e'.toHomeomorph.toPartialHomeomorph
      let f := (e.toHomeomorph.trans e'.toHomeomorph).toPartialHomeomorph
      have feq : f = f₁ ≫ₕ f₂ := Homeomorph.trans_toPartialHomeomorph _ _
      -- define the atlas g around y
      let y := (c.symm ≫ₕ f₁) x
      let g := chartAt (H := H) y
      have hg₁ := chart_mem_atlas (H := H) y
      have hg₂ := mem_chart_source (H := H) y
      let s := (c.symm ≫ₕ f₁).source ∩ c.symm ≫ₕ f₁ ⁻¹' g.source
      have open_s : IsOpen s := by
        apply (c.symm ≫ₕ f₁).continuousOn_toFun.isOpen_inter_preimage <;> apply open_source
      have : x ∈ s := by
        constructor
        · simp only [trans_source, preimage_univ, inter_univ, Homeomorph.toPartialHomeomorph_source]
          rw [trans_source] at hx
          exact hx.1
        · exact hg₂
      refine' ⟨s, open_s, this, _⟩
      let F₁ := (c.symm ≫ₕ f₁ ≫ₕ g) ≫ₕ g.symm ≫ₕ f₂ ≫ₕ c'
      have A : F₁ ∈ G := G.trans (e.mem_groupoid c g hc hg₁) (e'.mem_groupoid g c' hg₁ hc')
      

Proof state:
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : TopologicalSpace H
inst✝⁵ : TopologicalSpace M
inst✝⁴ : ChartedSpace H M
inst✝³ : TopologicalSpace M'
inst✝² : TopologicalSpace M''
G : StructureGroupoid H
inst✝¹ : ChartedSpace H M'
inst✝ : ChartedSpace H M''
e : Structomorph G M M'
e' : Structomorph G M' M''
src✝ : M ≃ₜ M'' := Homeomorph.trans e.toHomeomorph e'.toHomeomorph
c : PartialHomeomorph M H
c' : PartialHomeomorph M'' H
hc : c ∈ atlas H M
hc' : c' ∈ atlas H M''
x : H
hx :
  x ∈
    (PartialHomeomorph.symm c ≫ₕ
          Homeomorph.toPartialHomeomorph (Homeomorph.mk src✝.toEquiv) ≫ₕ c').toPartialEquiv.source
f₁ : PartialHomeomorph M M' := Homeomorph.toPartialHomeomorph e.toHomeomorph
f₂ : PartialHomeomorph M' M'' := Homeomorph.toPartialHomeomorph e'.toHomeomorph
f : PartialHomeomorph M M'' := Homeomorph.toPartialHomeomorph (Homeomorph.trans e.toHomeomorph e'.toHomeomorph)
feq : f = f₁ ≫ₕ f₂
y : M' := ↑(PartialHomeomorph.symm c ≫ₕ f₁) x
g : PartialHomeomorph M' H := chartAt H y
hg₁ : chartAt H y ∈ atlas H M'
hg₂ : y ∈ (chartAt H y).toPartialEquiv.source
s : Set H := (PartialHomeomorph.symm c ≫ₕ f₁).toPartialEquiv.source ∩ ↑(PartialHomeomorph.symm c ≫ₕ f₁) ⁻¹' g.source
open_s : IsOpen s
this : x ∈ s
F₁ : PartialHomeomorph H H := (PartialHomeomorph.symm c ≫ₕ f₁ ≫ₕ g) ≫ₕ PartialHomeomorph.symm g ≫ₕ f₂ ≫ₕ c'
A : F₁ ∈ G
⊢ PartialHomeomorph.restr
      (PartialHomeomorph.symm c ≫ₕ Homeomorph.toPartialHomeomorph (Homeomorph.mk src✝.toEquiv) ≫ₕ c') s ∈
    G

Next tactic:
let F₂ := (c.symm ≫ₕ f ≫ₕ c').restr s