l3lab/ntp-mathlib huggingface dataset:
/-- An element of the atlas in a charted space without topology becomes a local homeomorphism
for the topology constructed from this atlas. The `localHomeomorph` version is given in this
definition. -/
protected def localHomeomorph (e : PartialEquiv M H) (he : e ∈ c.atlas) :
    @PartialHomeomorph M H c.toTopologicalSpace _ :=
  { c.toTopologicalSpace, e with
    open_source := by convert c.open_source' he
    open_target := by convert c.open_target he
    continuousOn_toFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      rw [continuousOn_open_iff (c.open_source' he)]
      intro s s_open
      rw [inter_comm]
      apply TopologicalSpace.GenerateOpen.basic
      simp only [exists_prop, mem_iUnion, mem_singleton_iff]
      exact ⟨e, he, ⟨s, s_open, rfl⟩⟩
    continuousOn_invFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      apply continuousOn_isOpen_of_generateFrom
      intro t ht
      simp only [exists_prop, mem_iUnion, mem_singleton_iff] at ht
      rcases ht with ⟨e', e'_atlas, s, s_open, ts⟩
      rw [ts]
      let f := e.symm.trans e'
      have : IsOpen (f ⁻¹' s ∩ f.source) := by
        simpa [inter_comm] using (continuousOn_open_iff (c.open_source e e' he e'_atlas)).1
          (c.continuousOn_toFun e e' he e'_atlas) s s_open
      

Proof state:
case h.intro.intro.intro.intro
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝ : TopologicalSpace H
c : ChartedSpaceCore H M
e✝ e : PartialEquiv M H
he : e ∈ c.atlas
src✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
this✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
t : Set M
e' : PartialEquiv M H
e'_atlas : e' ∈ c.atlas
s : Set H
s_open : IsOpen s
ts : t = ↑e' ⁻¹' s ∩ e'.source
f : PartialEquiv H H := PartialEquiv.symm e ≫ e'
this : IsOpen (↑f ⁻¹' s ∩ f.source)
⊢ IsOpen
    ({ toFun := ↑e, invFun := e.invFun, source := e.source, target := e.target,
          map_source' := (_ : ∀ ⦃x : M⦄, x ∈ e.source → ↑e x ∈ e.target),
          map_target' := (_ : ∀ ⦃x : H⦄, x ∈ e.target → PartialEquiv.invFun e x ∈ e.source),
          left_inv' := (_ : ∀ ⦃x : M⦄, x ∈ e.source → PartialEquiv.invFun e (↑e x) = x),
          right_inv' := (_ : ∀ ⦃x : H⦄, x ∈ e.target → ↑e (PartialEquiv.invFun e x) = x) }.target ∩
      { toFun := ↑e, invFun := e.invFun, source := e.source, target := e.target,
            map_source' := (_ : ∀ ⦃x : M⦄, x ∈ e.source → ↑e x ∈ e.target),
            map_target' := (_ : ∀ ⦃x : H⦄, x ∈ e.target → PartialEquiv.invFun e x ∈ e.source),
            left_inv' := (_ : ∀ ⦃x : M⦄, x ∈ e.source → PartialEquiv.invFun e (↑e x) = x),
            right_inv' := (_ : ∀ ⦃x : H⦄, x ∈ e.target → ↑e (PartialEquiv.invFun e x) = x) }.invFun ⁻¹'
        (↑e' ⁻¹' s ∩ e'.source))

Next tactic:
have A : e' ∘ e.symm ⁻¹' s ∩ (e.target ∩ e.symm ⁻¹' e'.source) =
          e.target ∩ (e' ∘ e.symm ⁻¹' s ∩ e.symm ⁻¹' e'.source) := by
        rw [← inter_assoc, ← inter_assoc]
        congr 1
        exact inter_comm _ _
/-- An element of the atlas in a charted space without topology becomes a local homeomorphism
for the topology constructed from this atlas. The `localHomeomorph` version is given in this
definition. -/
protected def localHomeomorph (e : PartialEquiv M H) (he : e ∈ c.atlas) :
    @PartialHomeomorph M H c.toTopologicalSpace _ :=
  { c.toTopologicalSpace, e with
    open_source := by convert c.open_source' he
    open_target := by convert c.open_target he
    continuousOn_toFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      rw [continuousOn_open_iff (c.open_source' he)]
      intro s s_open
      rw [inter_comm]
      apply TopologicalSpace.GenerateOpen.basic
      simp only [exists_prop, mem_iUnion, mem_singleton_iff]
      exact ⟨e, he, ⟨s, s_open, rfl⟩⟩
    continuousOn_invFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      apply continuousOn_isOpen_of_generateFrom
      intro t ht
      simp only [exists_prop, mem_iUnion, mem_singleton_iff] at ht
      rcases ht with ⟨e', e'_atlas, s, s_open, ts⟩
      rw [ts]
      let f := e.symm.trans e'
      have : IsOpen (f ⁻¹' s ∩ f.source) := by
        simpa [inter_comm] using (continuousOn_open_iff (c.open_source e e' he e'_atlas)).1
          (c.continuousOn_toFun e e' he e'_atlas) s s_open
      have A : e' ∘ e.symm ⁻¹' s ∩ (e.target ∩ e.symm ⁻¹' e'.source) =
          e.target ∩ (e' ∘ e.symm ⁻¹' s ∩ e.symm ⁻¹' e'.source) := by
        

Proof state:
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝ : TopologicalSpace H
c : ChartedSpaceCore H M
e✝ e : PartialEquiv M H
he : e ∈ c.atlas
src✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
this✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
t : Set M
e' : PartialEquiv M H
e'_atlas : e' ∈ c.atlas
s : Set H
s_open : IsOpen s
ts : t = ↑e' ⁻¹' s ∩ e'.source
f : PartialEquiv H H := PartialEquiv.symm e ≫ e'
this : IsOpen (↑f ⁻¹' s ∩ f.source)
⊢ ↑e' ∘ ↑(PartialEquiv.symm e) ⁻¹' s ∩ (e.target ∩ ↑(PartialEquiv.symm e) ⁻¹' e'.source) =
    e.target ∩ (↑e' ∘ ↑(PartialEquiv.symm e) ⁻¹' s ∩ ↑(PartialEquiv.symm e) ⁻¹' e'.source)

Next tactic:
rw [← inter_assoc, ← inter_assoc]
/-- An element of the atlas in a charted space without topology becomes a local homeomorphism
for the topology constructed from this atlas. The `localHomeomorph` version is given in this
definition. -/
protected def localHomeomorph (e : PartialEquiv M H) (he : e ∈ c.atlas) :
    @PartialHomeomorph M H c.toTopologicalSpace _ :=
  { c.toTopologicalSpace, e with
    open_source := by convert c.open_source' he
    open_target := by convert c.open_target he
    continuousOn_toFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      rw [continuousOn_open_iff (c.open_source' he)]
      intro s s_open
      rw [inter_comm]
      apply TopologicalSpace.GenerateOpen.basic
      simp only [exists_prop, mem_iUnion, mem_singleton_iff]
      exact ⟨e, he, ⟨s, s_open, rfl⟩⟩
    continuousOn_invFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      apply continuousOn_isOpen_of_generateFrom
      intro t ht
      simp only [exists_prop, mem_iUnion, mem_singleton_iff] at ht
      rcases ht with ⟨e', e'_atlas, s, s_open, ts⟩
      rw [ts]
      let f := e.symm.trans e'
      have : IsOpen (f ⁻¹' s ∩ f.source) := by
        simpa [inter_comm] using (continuousOn_open_iff (c.open_source e e' he e'_atlas)).1
          (c.continuousOn_toFun e e' he e'_atlas) s s_open
      have A : e' ∘ e.symm ⁻¹' s ∩ (e.target ∩ e.symm ⁻¹' e'.source) =
          e.target ∩ (e' ∘ e.symm ⁻¹' s ∩ e.symm ⁻¹' e'.source) := by
        rw [← inter_assoc, ← inter_assoc]
        

Proof state:
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝ : TopologicalSpace H
c : ChartedSpaceCore H M
e✝ e : PartialEquiv M H
he : e ∈ c.atlas
src✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
this✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
t : Set M
e' : PartialEquiv M H
e'_atlas : e' ∈ c.atlas
s : Set H
s_open : IsOpen s
ts : t = ↑e' ⁻¹' s ∩ e'.source
f : PartialEquiv H H := PartialEquiv.symm e ≫ e'
this : IsOpen (↑f ⁻¹' s ∩ f.source)
⊢ ↑e' ∘ ↑(PartialEquiv.symm e) ⁻¹' s ∩ e.target ∩ ↑(PartialEquiv.symm e) ⁻¹' e'.source =
    e.target ∩ ↑e' ∘ ↑(PartialEquiv.symm e) ⁻¹' s ∩ ↑(PartialEquiv.symm e) ⁻¹' e'.source

Next tactic:
congr 1
/-- An element of the atlas in a charted space without topology becomes a local homeomorphism
for the topology constructed from this atlas. The `localHomeomorph` version is given in this
definition. -/
protected def localHomeomorph (e : PartialEquiv M H) (he : e ∈ c.atlas) :
    @PartialHomeomorph M H c.toTopologicalSpace _ :=
  { c.toTopologicalSpace, e with
    open_source := by convert c.open_source' he
    open_target := by convert c.open_target he
    continuousOn_toFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      rw [continuousOn_open_iff (c.open_source' he)]
      intro s s_open
      rw [inter_comm]
      apply TopologicalSpace.GenerateOpen.basic
      simp only [exists_prop, mem_iUnion, mem_singleton_iff]
      exact ⟨e, he, ⟨s, s_open, rfl⟩⟩
    continuousOn_invFun := by
      letI : TopologicalSpace M := c.toTopologicalSpace
      apply continuousOn_isOpen_of_generateFrom
      intro t ht
      simp only [exists_prop, mem_iUnion, mem_singleton_iff] at ht
      rcases ht with ⟨e', e'_atlas, s, s_open, ts⟩
      rw [ts]
      let f := e.symm.trans e'
      have : IsOpen (f ⁻¹' s ∩ f.source) := by
        simpa [inter_comm] using (continuousOn_open_iff (c.open_source e e' he e'_atlas)).1
          (c.continuousOn_toFun e e' he e'_atlas) s s_open
      have A : e' ∘ e.symm ⁻¹' s ∩ (e.target ∩ e.symm ⁻¹' e'.source) =
          e.target ∩ (e' ∘ e.symm ⁻¹' s ∩ e.symm ⁻¹' e'.source) := by
        rw [← inter_assoc, ← inter_assoc]
        congr 1
        

Proof state:
case e_a
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝ : TopologicalSpace H
c : ChartedSpaceCore H M
e✝ e : PartialEquiv M H
he : e ∈ c.atlas
src✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
this✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
t : Set M
e' : PartialEquiv M H
e'_atlas : e' ∈ c.atlas
s : Set H
s_open : IsOpen s
ts : t = ↑e' ⁻¹' s ∩ e'.source
f : PartialEquiv H H := PartialEquiv.symm e ≫ e'
this : IsOpen (↑f ⁻¹' s ∩ f.source)
⊢ ↑e' ∘ ↑(PartialEquiv.symm e) ⁻¹' s ∩ e.target = e.target ∩ ↑e' ∘ ↑(PartialEquiv.symm e) ⁻¹' s

Next tactic:
exact inter_comm _ _
/-- Given a charted space without topology, endow it with a genuine charted space structure with
respect to the topology constructed from the atlas. -/
def toChartedSpace : @ChartedSpace H _ M c.toTopologicalSpace :=
  { c.toTopologicalSpace with
    atlas := ⋃ (e : PartialEquiv M H) (he : e ∈ c.atlas), {c.localHomeomorph e he}
    chartAt := fun x ↦ c.localHomeomorph (c.chartAt x) (c.chart_mem_atlas x)
    mem_chart_source := fun x ↦ c.mem_chart_source x
    chart_mem_atlas := fun x ↦ by
      

Proof state:
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝ : TopologicalSpace H
c : ChartedSpaceCore H M
e : PartialEquiv M H
src✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
x : M
⊢ (fun x => ChartedSpaceCore.localHomeomorph c (chartAt c x) (_ : chartAt c x ∈ c.atlas)) x ∈
    ⋃ e, ⋃ (he : e ∈ c.atlas), {ChartedSpaceCore.localHomeomorph c e he}

Next tactic:
simp only [mem_iUnion, mem_singleton_iff]
/-- Given a charted space without topology, endow it with a genuine charted space structure with
respect to the topology constructed from the atlas. -/
def toChartedSpace : @ChartedSpace H _ M c.toTopologicalSpace :=
  { c.toTopologicalSpace with
    atlas := ⋃ (e : PartialEquiv M H) (he : e ∈ c.atlas), {c.localHomeomorph e he}
    chartAt := fun x ↦ c.localHomeomorph (c.chartAt x) (c.chart_mem_atlas x)
    mem_chart_source := fun x ↦ c.mem_chart_source x
    chart_mem_atlas := fun x ↦ by
      simp only [mem_iUnion, mem_singleton_iff]
      

Proof state:
H : Type u
H' : Type u_1
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝ : TopologicalSpace H
c : ChartedSpaceCore H M
e : PartialEquiv M H
src✝ : TopologicalSpace M := ChartedSpaceCore.toTopologicalSpace c
x : M
⊢ ∃ i,
    ∃ (h : i ∈ c.atlas),
      ChartedSpaceCore.localHomeomorph c (chartAt c x) (_ : chartAt c x ∈ c.atlas) =
        ChartedSpaceCore.localHomeomorph c i (_ : i ∈ c.atlas)

Next tactic:
exact ⟨c.chartAt x, c.chart_mem_atlas x, rfl⟩
/-- The trivial charted space structure on the model space is compatible with any groupoid. -/
instance hasGroupoid_model_space (H : Type*) [TopologicalSpace H] (G : StructureGroupoid H) :
    HasGroupoid H G where
  compatible {e e'} he he' := by
    

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
H : Type u_5
inst✝ : TopologicalSpace H
G : StructureGroupoid H
e e' : PartialHomeomorph H H
he : e ∈ atlas H H
he' : e' ∈ atlas H H
⊢ PartialHomeomorph.symm e ≫ₕ e' ∈ G

Next tactic:
rw [chartedSpaceSelf_atlas] at he he'
/-- The trivial charted space structure on the model space is compatible with any groupoid. -/
instance hasGroupoid_model_space (H : Type*) [TopologicalSpace H] (G : StructureGroupoid H) :
    HasGroupoid H G where
  compatible {e e'} he he' := by
    rw [chartedSpaceSelf_atlas] at he he'
    

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
H : Type u_5
inst✝ : TopologicalSpace H
G : StructureGroupoid H
e e' : PartialHomeomorph H H
he : e = PartialHomeomorph.refl H
he' : e' = PartialHomeomorph.refl H
⊢ PartialHomeomorph.symm e ≫ₕ e' ∈ G

Next tactic:
simp [he, he', StructureGroupoid.id_mem]
/-- Any charted space structure is compatible with the groupoid of all local homeomorphisms. -/
instance hasGroupoid_continuousGroupoid : HasGroupoid M (continuousGroupoid H) := by
  

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
⊢ HasGroupoid M (continuousGroupoid H)

Next tactic:
refine' ⟨fun _ _ ↦ _⟩
/-- Any charted space structure is compatible with the groupoid of all local homeomorphisms. -/
instance hasGroupoid_continuousGroupoid : HasGroupoid M (continuousGroupoid H) := by
  refine' ⟨fun _ _ ↦ _⟩
  

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
e✝ e'✝ : PartialHomeomorph M H
x✝¹ : e✝ ∈ atlas H M
x✝ : e'✝ ∈ atlas H M
⊢ PartialHomeomorph.symm e✝ ≫ₕ e'✝ ∈ continuousGroupoid H

Next tactic:
rw [continuousGroupoid, mem_groupoid_of_pregroupoid]
/-- Any charted space structure is compatible with the groupoid of all local homeomorphisms. -/
instance hasGroupoid_continuousGroupoid : HasGroupoid M (continuousGroupoid H) := by
  refine' ⟨fun _ _ ↦ _⟩
  rw [continuousGroupoid, mem_groupoid_of_pregroupoid]
  

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
e✝ e'✝ : PartialHomeomorph M H
x✝¹ : e✝ ∈ atlas H M
x✝ : e'✝ ∈ atlas H M
⊢ Pregroupoid.property (continuousPregroupoid H) (↑(PartialHomeomorph.symm e✝ ≫ₕ e'✝))
      (PartialHomeomorph.symm e✝ ≫ₕ e'✝).toPartialEquiv.source ∧
    Pregroupoid.property (continuousPregroupoid H) (↑(PartialHomeomorph.symm (PartialHomeomorph.symm e✝ ≫ₕ e'✝)))
      (PartialHomeomorph.symm e✝ ≫ₕ e'✝).toPartialEquiv.target

Next tactic:
simp only [and_self_iff]
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
⊢ PartialHomeomorph.symm e ≫ₕ e' ∈ G

Next tactic:
refine' G.locality fun x hx ↦ _
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
⊢ ∃ s, IsOpen s ∧ x ∈ s ∧ PartialHomeomorph.restr (PartialHomeomorph.symm e ≫ₕ e') s ∈ G

Next tactic:
set f := chartAt (H := H) (e.symm x)
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
⊢ ∃ s, IsOpen s ∧ x ∈ s ∧ PartialHomeomorph.restr (PartialHomeomorph.symm e ≫ₕ e') s ∈ G

Next tactic:
let s := e.target ∩ e.symm ⁻¹' f.source
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  let s := e.target ∩ e.symm ⁻¹' f.source
  

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
s : Set H := e.target ∩ ↑(PartialHomeomorph.symm e) ⁻¹' f.source
⊢ ∃ s, IsOpen s ∧ x ∈ s ∧ PartialHomeomorph.restr (PartialHomeomorph.symm e ≫ₕ e') s ∈ G

Next tactic:
have hs : IsOpen s := by
    apply e.symm.continuousOn_toFun.isOpen_inter_preimage <;> apply open_source
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  let s := e.target ∩ e.symm ⁻¹' f.source
  have hs : IsOpen s := by
    

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
s : Set H := e.target ∩ ↑(PartialHomeomorph.symm e) ⁻¹' f.source
⊢ IsOpen s

Next tactic:
apply e.symm.continuousOn_toFun.isOpen_inter_preimage
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  let s := e.target ∩ e.symm ⁻¹' f.source
  have hs : IsOpen s := by
    apply e.symm.continuousOn_toFun.isOpen_inter_preimage <;> 

Proof state:
case hs
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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
s : Set H := e.target ∩ ↑(PartialHomeomorph.symm e) ⁻¹' f.source
⊢ IsOpen (PartialHomeomorph.symm e).toPartialEquiv.source

Next tactic:
apply open_source
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  let s := e.target ∩ e.symm ⁻¹' f.source
  have hs : IsOpen s := by
    apply e.symm.continuousOn_toFun.isOpen_inter_preimage <;> 

Proof state:
case ht
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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
s : Set H := e.target ∩ ↑(PartialHomeomorph.symm e) ⁻¹' f.source
⊢ IsOpen f.source

Next tactic:
apply open_source
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  let s := e.target ∩ e.symm ⁻¹' f.source
  have hs : IsOpen s := by
    apply e.symm.continuousOn_toFun.isOpen_inter_preimage <;> apply open_source
  

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
s : Set H := e.target ∩ ↑(PartialHomeomorph.symm e) ⁻¹' f.source
hs : IsOpen s
⊢ ∃ s, IsOpen s ∧ x ∈ s ∧ PartialHomeomorph.restr (PartialHomeomorph.symm e ≫ₕ e') s ∈ G

Next tactic:
have xs : x ∈ s := by
    simp only [mem_inter_iff, mem_preimage, mem_chart_source, and_true]
    exact ((mem_inter_iff _ _ _).1 hx).1
/-- Changing coordinates between two elements of the maximal atlas gives rise to an element
of the structure groupoid. -/
theorem StructureGroupoid.compatible_of_mem_maximalAtlas {e e' : PartialHomeomorph M H}
    (he : e ∈ G.maximalAtlas M) (he' : e' ∈ G.maximalAtlas M) : e.symm ≫ₕ e' ∈ G := by
  refine' G.locality fun x hx ↦ _
  set f := chartAt (H := H) (e.symm x)
  let s := e.target ∩ e.symm ⁻¹' f.source
  have hs : IsOpen s := by
    apply e.symm.continuousOn_toFun.isOpen_inter_preimage <;> apply open_source
  have xs : x ∈ s := by
    

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
G : StructureGroupoid H
e e' : PartialHomeomorph M H
he : e ∈ maximalAtlas M G
he' : e' ∈ maximalAtlas M G
x : H
hx : x ∈ (PartialHomeomorph.symm e ≫ₕ e').toPartialEquiv.source
f : PartialHomeomorph M H := chartAt H (↑(PartialHomeomorph.symm e) x)
s : Set H := e.target ∩ ↑(PartialHomeomorph.symm e) ⁻¹' f.source
hs : IsOpen s
⊢ x ∈ s

Next tactic:
simp only [mem_inter_iff, mem_preimage, mem_chart_source, and_true]