theorem HasGroupoid.comp
    (H : ∀ e ∈ G₂, LiftPropOn (IsLocalStructomorphWithinAt G₁) (e : H₂ → H₂) e.source) :
    @HasGroupoid H₁ _ H₃ _ (ChartedSpace.comp H₁ H₂ H₃) G₁ :=
  let _ := ChartedSpace.comp H₁ H₂ H₃ -- Porting note: need this to synthesize `ChartedSpace H₁ H₃`
  { compatible := by
      rintro _ _ ⟨e, f, he, hf, rfl⟩ ⟨e', f', he', hf', rfl⟩
      apply G₁.locality
      intro x hx
      simp only [mfld_simps] at hx
      have hxs : x ∈ f.symm ⁻¹' (e.symm ≫ₕ e').source := by simp only [hx, mfld_simps]
      have hxs' : x ∈ f.target ∩ f.symm ⁻¹' ((e.symm ≫ₕ e').source ∩ e.symm ≫ₕ e' ⁻¹' f'.source) :=
        by simp only [hx, mfld_simps]
      obtain ⟨φ, hφG₁, hφ, hφ_dom⟩ := LocalInvariantProp.liftPropOn_indep_chart
        (isLocalStructomorphWithinAt_localInvariantProp G₁) (G₁.subset_maximalAtlas hf)
        (G₁.subset_maximalAtlas hf') (H _ (G₂.compatible he he')) hxs' hxs
      simp_rw [← PartialHomeomorph.coe_trans, PartialHomeomorph.trans_assoc] at hφ
      simp_rw [PartialHomeomorph.trans_symm_eq_symm_trans_symm, PartialHomeomorph.trans_assoc]
      have hs : IsOpen (f.symm ≫ₕ e.symm ≫ₕ e' ≫ₕ f').source :=
        (f.symm ≫ₕ e.symm ≫ₕ e' ≫ₕ f').open_source
      refine' ⟨_, hs.inter φ.open_source, _, _⟩
      · simp only [hx, hφ_dom, mfld_simps]
      · refine' G₁.eq_on_source (closedUnderRestriction' hφG₁ hs) _
        

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.refine'_2
H✝ : Type u_1
M : Type u_2
H' : Type u_3
M' : Type u_4
X : Type u_5
inst✝¹⁴ : TopologicalSpace H✝
inst✝¹³ : TopologicalSpace M
inst✝¹² : ChartedSpace H✝ M
inst✝¹¹ : TopologicalSpace H'
inst✝¹⁰ : TopologicalSpace M'
inst✝⁹ : ChartedSpace H' M'
inst✝⁸ : TopologicalSpace X
G : StructureGroupoid H✝
G' : StructureGroupoid H'
e✝ e'✝ : PartialHomeomorph M H✝
f✝ f'✝ : PartialHomeomorph M' H'
P : (H✝ → H') → Set H✝ → H✝ → Prop
g g' : M → M'
s t : Set M
x✝¹ : M
Q : (H✝ → H✝) → Set H✝ → H✝ → Prop
H₁ : Type u_6
inst✝⁷ : TopologicalSpace H₁
H₂ : Type u_7
inst✝⁶ : TopologicalSpace H₂
H₃ : Type u_8
inst✝⁵ : TopologicalSpace H₃
inst✝⁴ : ChartedSpace H₁ H₂
inst✝³ : ChartedSpace H₂ H₃
G₁ : StructureGroupoid H₁
inst✝² : HasGroupoid H₂ G₁
inst✝¹ : ClosedUnderRestriction G₁
G₂ : StructureGroupoid H₂
inst✝ : HasGroupoid H₃ G₂
H : ∀ e ∈ G₂, LiftPropOn (IsLocalStructomorphWithinAt G₁) (↑e) e.source
x✝ : ChartedSpace H₁ H₃ := ChartedSpace.comp H₁ H₂ H₃
e : PartialHomeomorph H₃ H₂
f : PartialHomeomorph H₂ H₁
he : e ∈ atlas H₂ H₃
hf : f ∈ atlas H₁ H₂
e' : PartialHomeomorph H₃ H₂
f' : PartialHomeomorph H₂ H₁
he' : e' ∈ atlas H₂ H₃
hf' : f' ∈ atlas H₁ H₂
x : H₁
hx :
  (x ∈ f.target ∧ ↑(PartialHomeomorph.symm f) x ∈ e.target) ∧
    ↑(PartialHomeomorph.symm e) (↑(PartialHomeomorph.symm f) x) ∈ e'.source ∧
      ↑e' (↑(PartialHomeomorph.symm e) (↑(PartialHomeomorph.symm f) x)) ∈ f'.source
hxs : x ∈ ↑(PartialHomeomorph.symm f) ⁻¹' (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
hxs' :
  x ∈
    f.target ∩
      ↑(PartialHomeomorph.symm f) ⁻¹'
        ((PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source ∩ ↑(PartialHomeomorph.symm e ≫ₕ e') ⁻¹' f'.source)
φ : PartialHomeomorph H₁ H₁
hφG₁ : φ ∈ G₁
hφ_dom : x ∈ φ.source
hφ :
  EqOn (↑(PartialHomeomorph.symm f ≫ₕ PartialHomeomorph.symm e ≫ₕ e' ≫ₕ f')) (↑φ.toPartialEquiv)
    (↑(PartialHomeomorph.symm f) ⁻¹' (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source ∩ φ.source)
hs : IsOpen (PartialHomeomorph.symm f ≫ₕ PartialHomeomorph.symm e ≫ₕ e' ≫ₕ f').toPartialEquiv.source
⊢ PartialHomeomorph.restr (PartialHomeomorph.symm f ≫ₕ PartialHomeomorph.symm e ≫ₕ e' ≫ₕ f')
      ((PartialHomeomorph.symm f ≫ₕ PartialHomeomorph.symm e ≫ₕ e' ≫ₕ f').toPartialEquiv.source ∩ φ.source) ≈
    PartialHomeomorph.restr φ (PartialHomeomorph.symm f ≫ₕ PartialHomeomorph.symm e ≫ₕ e' ≫ₕ f').toPartialEquiv.source

Next tactic:
rw [PartialHomeomorph.restr_source_inter]