/-- Given a model with corners `(E, H)`, we define the groupoid of analytic transformations of `H`
as the maps that are analytic and map interior to interior when read in `E` through `I`. We also
explicitly define that they are `C^∞` on the whole domain, since we are only requiring
analyticity on the interior of the domain. -/
def analyticGroupoid : StructureGroupoid H :=
  (contDiffGroupoid ∞ I) ⊓ Pregroupoid.groupoid
    { property := fun f s => AnalyticOn 𝕜 (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ interior (range I)) ∧
        (I.symm ⁻¹' s ∩ interior (range I)).image (I ∘ f ∘ I.symm) ⊆ interior (range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        simp only [] at hf hg ⊢
        have comp : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        apply And.intro
        · simp only [comp, preimage_inter]
          refine hg.left.comp (hf.left.mono ?_) ?_
          · simp only [subset_inter_iff, inter_subset_right]
            rw [inter_assoc]
            simp
          · intro x hx
            apply And.intro
            · rw [mem_preimage, comp_apply, I.left_inv]
              exact hx.left.right
            · apply hf.right
              rw [mem_image]
              exact ⟨x, ⟨⟨hx.left.left, hx.right⟩, rfl⟩⟩
        · simp only [comp]
          rw [image_comp]
          intro x hx
          rw [mem_image] at hx
          rcases hx with ⟨x', hx'⟩
          refine hg.right ⟨x', And.intro ?_ hx'.right⟩
          apply And.intro
          · have hx'1 : x' ∈ ((v.preimage f).preimage (I.symm)).image (I ∘ f ∘ I.symm) := by
              refine image_subset (I ∘ f ∘ I.symm) ?_ hx'.left
              rw [preimage_inter]
              refine Subset.trans ?_ (inter_subset_right (u.preimage I.symm)
                ((v.preimage f).preimage I.symm))
              apply inter_subset_left
            rcases hx'1 with ⟨x'', hx''⟩
            rw [hx''.right.symm]
            

Proof state:
case right.intro.left.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
f g : H → H
u v : Set H
hf :
  AnalyticOn 𝕜 (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ interior (range ↑I)) ∧
    ↑I ∘ f ∘ ↑(ModelWithCorners.symm I) '' (↑(ModelWithCorners.symm I) ⁻¹' u ∩ interior (range ↑I)) ⊆
      interior (range ↑I)
hg :
  AnalyticOn 𝕜 (↑I ∘ g ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' v ∩ interior (range ↑I)) ∧
    ↑I ∘ g ∘ ↑(ModelWithCorners.symm I) '' (↑(ModelWithCorners.symm I) ⁻¹' v ∩ interior (range ↑I)) ⊆
      interior (range ↑I)
x✝² : IsOpen u
x✝¹ : IsOpen v
x✝ : IsOpen (u ∩ f ⁻¹' v)
comp :
  ↑I ∘ (g ∘ f) ∘ ↑(ModelWithCorners.symm I) =
    (↑I ∘ g ∘ ↑(ModelWithCorners.symm I)) ∘ ↑I ∘ f ∘ ↑(ModelWithCorners.symm I)
x x' : E
hx' :
  x' ∈ ↑I ∘ f ∘ ↑(ModelWithCorners.symm I) '' (↑(ModelWithCorners.symm I) ⁻¹' (u ∩ f ⁻¹' v) ∩ interior (range ↑I)) ∧
    (↑I ∘ g ∘ ↑(ModelWithCorners.symm I)) x' = x
x'' : E
hx'' : x'' ∈ ↑(ModelWithCorners.symm I) ⁻¹' (f ⁻¹' v) ∧ (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) x'' = x'
⊢ (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) x'' ∈ ↑(ModelWithCorners.symm I) ⁻¹' v

Next tactic:
simp only [comp_apply, mem_preimage, I.left_inv]