l3lab/ntp-mathlib huggingface dataset:
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        

Proof state:
case h.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy1 : y ∈ ↑(ModelWithCorners.symm I) ⁻¹' u
hy2 : y ∈ range ↑I
⊢ ∃ u_1,
    IsOpen u_1 ∧
      y ∈ u_1 ∧ ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
rcases mem_range.1 hy2 with ⟨x, hx⟩
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        

Proof state:
case h.intro.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy1 : y ∈ ↑(ModelWithCorners.symm I) ⁻¹' u
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
⊢ ∃ u_1,
    IsOpen u_1 ∧
      y ∈ u_1 ∧ ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
rw [← hx] at hy1 ⊢
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        

Proof state:
case h.intro.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hy1 : ↑I x ∈ ↑(ModelWithCorners.symm I) ⁻¹' u
hx : ↑I x = y
⊢ ∃ u_1,
    IsOpen u_1 ∧
      ↑I x ∈ u_1 ∧
        ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
simp only [mfld_simps] at hy1 ⊢
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        

Proof state:
case h.intro.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
⊢ ∃ u_1,
    IsOpen u_1 ∧
      ↑I x ∈ u_1 ∧
        ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
rcases H x hy1 with ⟨v, v_open, xv, hv⟩
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        

Proof state:
case h.intro.intro.intro.intro.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv : ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I)
⊢ ∃ u_1,
    IsOpen u_1 ∧
      ↑I x ∈ u_1 ∧
        ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          rw [preimage_inter, inter_assoc, inter_assoc]
          congr 1
          rw [inter_comm]
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          

Proof state:
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv : ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I)
⊢ ↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I =
    ↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v

Next tactic:
rw [preimage_inter, inter_assoc, inter_assoc]
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          rw [preimage_inter, inter_assoc, inter_assoc]
          

Proof state:
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv : ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I)
⊢ ↑(ModelWithCorners.symm I) ⁻¹' u ∩ (↑(ModelWithCorners.symm I) ⁻¹' v ∩ range ↑I) =
    ↑(ModelWithCorners.symm I) ⁻¹' u ∩ (range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v)

Next tactic:
congr 1
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          rw [preimage_inter, inter_assoc, inter_assoc]
          congr 1
          

Proof state:
case e_a
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv : ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I)
⊢ ↑(ModelWithCorners.symm I) ⁻¹' v ∩ range ↑I = range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v

Next tactic:
rw [inter_comm]
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          rw [preimage_inter, inter_assoc, inter_assoc]
          congr 1
          rw [inter_comm]
        

Proof state:
case h.intro.intro.intro.intro.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv : ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I)
this :
  ↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I =
    ↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v
⊢ ∃ u_1,
    IsOpen u_1 ∧
      ↑I x ∈ u_1 ∧
        ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
rw [this] at hv
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          rw [preimage_inter, inter_assoc, inter_assoc]
          congr 1
          rw [inter_comm]
        rw [this] at hv
        

Proof state:
case h.intro.intro.intro.intro.intro
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv :
  ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I))
    (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v)
this :
  ↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I =
    ↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v
⊢ ∃ u_1,
    IsOpen u_1 ∧
      ↑I x ∈ u_1 ∧
        ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ u_1)

Next tactic:
exact ⟨I.symm ⁻¹' v, v_open.preimage I.continuous_symm, by simpa, hv⟩
/-- Given a model with corners `(E, H)`, we define the groupoid of `C^n` transformations of `H` as
the maps that are `C^n` when read in `E` through `I`. -/
def contDiffGroupoid : StructureGroupoid H :=
  Pregroupoid.groupoid
    { property := fun f s => ContDiffOn 𝕜 n (I ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
      comp := fun {f g u v} hf hg _ _ _ => by
        have : I ∘ (g ∘ f) ∘ I.symm = (I ∘ g ∘ I.symm) ∘ I ∘ f ∘ I.symm := by ext x; simp
        simp only [this]
        refine hg.comp (hf.mono ?_) ?_
        · rintro x ⟨hx1, hx2⟩
          exact ⟨hx1.1, hx2⟩
        · rintro x ⟨hx1, _⟩
          simp only [mfld_simps] at hx1 ⊢
          exact hx1.2
      id_mem := by
        apply ContDiffOn.congr contDiff_id.contDiffOn
        rintro x ⟨_, hx2⟩
        rcases mem_range.1 hx2 with ⟨y, hy⟩
        rw [← hy]
        simp only [mfld_simps]
      locality := fun {f u} _ H => by
        apply contDiffOn_of_locally_contDiffOn
        rintro y ⟨hy1, hy2⟩
        rcases mem_range.1 hy2 with ⟨x, hx⟩
        rw [← hx] at hy1 ⊢
        simp only [mfld_simps] at hy1 ⊢
        rcases H x hy1 with ⟨v, v_open, xv, hv⟩
        have : I.symm ⁻¹' (u ∩ v) ∩ range I = I.symm ⁻¹' u ∩ range I ∩ I.symm ⁻¹' v := by
          rw [preimage_inter, inter_assoc, inter_assoc]
          congr 1
          rw [inter_comm]
        rw [this] at hv
        exact ⟨I.symm ⁻¹' v, v_open.preimage I.continuous_symm, by 

Proof state:
m n : ℕ∞
𝕜 : 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 : H✝ → H✝
u : Set H✝
x✝ : IsOpen u
H :
  ∀ x ∈ u,
    ∃ v,
      IsOpen v ∧
        x ∈ v ∧
          (fun f s =>
              ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I)) (↑(ModelWithCorners.symm I) ⁻¹' s ∩ range ↑I))
            f (u ∩ v)
y : E
hy2 : y ∈ range ↑I
x : H✝
hx : ↑I x = y
hy1 : x ∈ u
v : Set H✝
v_open : IsOpen v
xv : x ∈ v
hv :
  ContDiffOn 𝕜 n (↑I ∘ f ∘ ↑(ModelWithCorners.symm I))
    (↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v)
this :
  ↑(ModelWithCorners.symm I) ⁻¹' (u ∩ v) ∩ range ↑I =
    ↑(ModelWithCorners.symm I) ⁻¹' u ∩ range ↑I ∩ ↑(ModelWithCorners.symm I) ⁻¹' v
⊢ ↑I x ∈ ↑(ModelWithCorners.symm I) ⁻¹' v

Next tactic:
simpa