l3lab/ntp-mathlib huggingface dataset:
/-- If two nonzero squares are negatives of each other in `ZMod p`, then `p % 4 ≠ 3`. -/
theorem mod_four_ne_three_of_sq_eq_neg_sq' {x y : ZMod p} (hy : y ≠ 0) (hxy : x ^ 2 = -y ^ 2) :
    p % 4 ≠ 3 :=
  @mod_four_ne_three_of_sq_eq_neg_one p _ (x / y)
    (by
      apply_fun fun z => z / y ^ 2 at hxy
      

Proof state:
p : ℕ
inst✝ : Fact (Nat.Prime p)
x y : ZMod p
hy : y ≠ 0
hxy : x ^ 2 / y ^ 2 = -y ^ 2 / y ^ 2
⊢ (x / y) ^ 2 = -1

Next tactic:
rwa [neg_div, ← div_pow, ← div_pow, div_self hy, one_pow] at hxy
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
⊢ (Iso.refl ↑X).hom _* X.presheaf ≅ (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf

Next tactic:
symm
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
⊢ (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf ≅ (Iso.refl ↑X).hom _* X.presheaf

Next tactic:
fapply NatIso.ofComponents
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · 

Proof state:
case app
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
⊢ (X_1 : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ) →
    (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf.obj X_1 ≅ ((Iso.refl ↑X).hom _* X.presheaf).obj X_1

Next tactic:
intro U
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      

Proof state:
case app
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ
⊢ (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf.obj U ≅ ((Iso.refl ↑X).hom _* X.presheaf).obj U

Next tactic:
refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · 

Proof state:
case app
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ
⊢ (Opens.map f.base).op.obj (op ((openFunctor H).obj U.unop)) = U

Next tactic:
induction U using Opposite.rec' with | h U => ?_
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        

Proof state:
case app.h
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base))
⊢ (Opens.map f.base).op.obj (op ((openFunctor H).obj (op U).unop)) = op U

Next tactic:
cases U
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        

Proof state:
case app.h.mk
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
carrier✝ : Set ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base))
is_open'✝ : IsOpen carrier✝
⊢ (Opens.map f.base).op.obj (op ((openFunctor H).obj (op { carrier := carrier✝, is_open' := is_open'✝ }).unop)) =
    op { carrier := carrier✝, is_open' := is_open'✝ }

Next tactic:
dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        

Proof state:
case app.h.mk
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
carrier✝ : Set ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base))
is_open'✝ : IsOpen carrier✝
⊢ op
      {
        carrier :=
          ⇑f.base ⁻¹' ↑(op ((openFunctor H).obj (op { carrier := carrier✝, is_open' := is_open'✝ }).unop)).unop,
        is_open' :=
          (_ :
            IsOpen
              (⇑f.base ⁻¹'
                ↑(op ((openFunctor H).obj (op { carrier := carrier✝, is_open' := is_open'✝ }).unop)).unop)) } =
    op { carrier := carrier✝, is_open' := is_open'✝ }

Next tactic:
congr 2
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        congr 2
        

Proof state:
case app.h.mk.e_x.e_carrier
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
carrier✝ : Set ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base))
is_open'✝ : IsOpen carrier✝
⊢ ⇑f.base ⁻¹' ↑(op ((openFunctor H).obj (op { carrier := carrier✝, is_open' := is_open'✝ }).unop)).unop = carrier✝

Next tactic:
erw [Set.preimage_image_eq _ H.base_open.inj]
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        congr 2
        erw [Set.preimage_image_eq _ H.base_open.inj]
        

Proof state:
case app.h.mk.e_x.e_carrier
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
carrier✝ : Set ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base))
is_open'✝ : IsOpen carrier✝
⊢ ↑(op { carrier := carrier✝, is_open' := is_open'✝ }).unop = carrier✝

Next tactic:
rfl
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        congr 2
        erw [Set.preimage_image_eq _ H.base_open.inj]
        rfl
    · 

Proof state:
case naturality
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
⊢ autoParam
    (∀ {X_1 Y_1 : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ} (f_1 : X_1 ⟶ Y_1),
      (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf.map f_1 ≫
          (asIso (f.c.app (op ((openFunctor H).obj Y_1.unop))) ≪≫
              X.presheaf.mapIso
                (eqToIso (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj Y_1.unop)) = Y_1))).hom =
        (asIso (f.c.app (op ((openFunctor H).obj X_1.unop))) ≪≫
              X.presheaf.mapIso
                (eqToIso (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj X_1.unop)) = X_1))).hom ≫
          ((Iso.refl ↑X).hom _* X.presheaf).map f_1)
    _auto✝

Next tactic:
intro U V i
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        congr 2
        erw [Set.preimage_image_eq _ H.base_open.inj]
        rfl
    · intro U V i
      

Proof state:
case naturality
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U V : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ
i : U ⟶ V
⊢ (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf.map i ≫
      (asIso (f.c.app (op ((openFunctor H).obj V.unop))) ≪≫
          X.presheaf.mapIso (eqToIso (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj V.unop)) = V))).hom =
    (asIso (f.c.app (op ((openFunctor H).obj U.unop))) ≪≫
          X.presheaf.mapIso (eqToIso (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj U.unop)) = U))).hom ≫
      ((Iso.refl ↑X).hom _* X.presheaf).map i

Next tactic:
simp only [CategoryTheory.eqToIso.hom, TopCat.Presheaf.pushforwardObj_map, Category.assoc,
        Functor.op_map, Iso.trans_hom, asIso_hom, Functor.mapIso_hom, ← X.presheaf.map_comp]
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        congr 2
        erw [Set.preimage_image_eq _ H.base_open.inj]
        rfl
    · intro U V i
      simp only [CategoryTheory.eqToIso.hom, TopCat.Presheaf.pushforwardObj_map, Category.assoc,
        Functor.op_map, Iso.trans_hom, asIso_hom, Functor.mapIso_hom, ← X.presheaf.map_comp]
      

Proof state:
case naturality
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U V : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ
i : U ⟶ V
⊢ (restrict Y (_ : OpenEmbedding ⇑f.base)).presheaf.map i ≫
      f.c.app (op ((openFunctor H).obj V.unop)) ≫
        X.presheaf.map (eqToHom (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj V.unop)) = V)) =
    f.c.app (op ((openFunctor H).obj U.unop)) ≫
      X.presheaf.map
        (eqToHom (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj U.unop)) = U) ≫
          ((Opens.map (Iso.refl ↑X).hom).map i.unop).op)

Next tactic:
erw [f.c.naturality_assoc, ← X.presheaf.map_comp]
/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/
@[simps! hom_c_app]
noncomputable def isoRestrict : X ≅ Y.restrict H.base_open :=
  PresheafedSpace.isoOfComponents (Iso.refl _) <| by
    symm
    fapply NatIso.ofComponents
    · intro U
      refine' asIso (f.c.app (op (H.openFunctor.obj (unop U)))) ≪≫ X.presheaf.mapIso (eqToIso _)
      · induction U using Opposite.rec' with | h U => ?_
        cases U
        dsimp only [IsOpenMap.functor, Functor.op, Opens.map]
        congr 2
        erw [Set.preimage_image_eq _ H.base_open.inj]
        rfl
    · intro U V i
      simp only [CategoryTheory.eqToIso.hom, TopCat.Presheaf.pushforwardObj_map, Category.assoc,
        Functor.op_map, Iso.trans_hom, asIso_hom, Functor.mapIso_hom, ← X.presheaf.map_comp]
      erw [f.c.naturality_assoc, ← X.presheaf.map_comp]
      

Proof state:
case naturality
C : Type u_1
inst✝ : Category.{?u.9170, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U V : (Opens ↑↑(restrict Y (_ : OpenEmbedding ⇑f.base)))ᵒᵖ
i : U ⟶ V
⊢ f.c.app ((IsOpenMap.functor (_ : IsOpenMap ⇑f.base)).op.obj U) ≫
      X.presheaf.map
        ((Opens.map f.base).op.map ((IsOpenMap.functor (_ : IsOpenMap ⇑f.base)).op.map i) ≫
          eqToHom (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj V.unop)) = V)) =
    f.c.app (op ((openFunctor H).obj U.unop)) ≫
      X.presheaf.map
        (eqToHom (_ : (Opens.map f.base).op.obj (op ((openFunctor H).obj U.unop)) = U) ≫
          ((Opens.map (Iso.refl ↑X).hom).map i.unop).op)

Next tactic:
congr 1
@[simp]
theorem isoRestrict_hom_ofRestrict : H.isoRestrict.hom ≫ Y.ofRestrict _ = f := by
  -- Porting note : `ext` did not pick up `NatTrans.ext`
  

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
⊢ (isoRestrict H).hom ≫ ofRestrict Y (_ : OpenEmbedding ⇑f.base) = f

Next tactic:
refine PresheafedSpace.Hom.ext _ _ rfl <| NatTrans.ext _ _ <| funext fun x => ?_
@[simp]
theorem isoRestrict_hom_ofRestrict : H.isoRestrict.hom ≫ Y.ofRestrict _ = f := by
  -- Porting note : `ext` did not pick up `NatTrans.ext`
  refine PresheafedSpace.Hom.ext _ _ rfl <| NatTrans.ext _ _ <| funext fun x => ?_
  · 

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
x : (Opens ↑↑Y)ᵒᵖ
⊢ (((isoRestrict H).hom ≫ ofRestrict Y (_ : OpenEmbedding ⇑f.base)).c ≫
          whiskerRight
            (eqToHom
              (_ :
                (Opens.map ((isoRestrict H).hom ≫ ofRestrict Y (_ : OpenEmbedding ⇑f.base)).base).op =
                  (Opens.map f.base).op))
            X.presheaf).app
      x =
    f.c.app x

Next tactic:
simp only [isoRestrict_hom_c_app, NatTrans.comp_app, eqToHom_refl,
      ofRestrict_c_app, Category.assoc, whiskerRight_id']
@[simp]
theorem isoRestrict_hom_ofRestrict : H.isoRestrict.hom ≫ Y.ofRestrict _ = f := by
  -- Porting note : `ext` did not pick up `NatTrans.ext`
  refine PresheafedSpace.Hom.ext _ _ rfl <| NatTrans.ext _ _ <| funext fun x => ?_
  · simp only [isoRestrict_hom_c_app, NatTrans.comp_app, eqToHom_refl,
      ofRestrict_c_app, Category.assoc, whiskerRight_id']
    

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
x : (Opens ↑↑Y)ᵒᵖ
⊢ (((isoRestrict H).hom ≫ ofRestrict Y (_ : OpenEmbedding ⇑f.base)).c ≫
          𝟙 ((Opens.map ((isoRestrict H).hom ≫ ofRestrict Y (_ : OpenEmbedding ⇑f.base)).base).op ⋙ X.presheaf)).app
      x =
    f.c.app x

Next tactic:
erw [Category.comp_id, comp_c_app, f.c.naturality_assoc, ← X.presheaf.map_comp]
@[simp]
theorem isoRestrict_hom_ofRestrict : H.isoRestrict.hom ≫ Y.ofRestrict _ = f := by
  -- Porting note : `ext` did not pick up `NatTrans.ext`
  refine PresheafedSpace.Hom.ext _ _ rfl <| NatTrans.ext _ _ <| funext fun x => ?_
  · simp only [isoRestrict_hom_c_app, NatTrans.comp_app, eqToHom_refl,
      ofRestrict_c_app, Category.assoc, whiskerRight_id']
    erw [Category.comp_id, comp_c_app, f.c.naturality_assoc, ← X.presheaf.map_comp]
    

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
x : (Opens ↑↑Y)ᵒᵖ
⊢ f.c.app x ≫
      X.presheaf.map
        ((Opens.map f.base).op.map ((IsOpenMap.adjunction (_ : IsOpenMap ⇑f.base)).counit.app x.unop).op ≫
          (eqToIso
              (_ :
                (Opens.map f.base).op.obj
                    (op
                      ((openFunctor H).obj
                        (op ((Opens.map (ofRestrict Y (_ : OpenEmbedding ⇑f.base)).base).obj x.unop)).unop)) =
                  op ((Opens.map (ofRestrict Y (_ : OpenEmbedding ⇑f.base)).base).obj x.unop))).hom) =
    f.c.app x

Next tactic:
trans f.c.app x ≫ X.presheaf.map (𝟙 _)
@[simp]
theorem isoRestrict_hom_ofRestrict : H.isoRestrict.hom ≫ Y.ofRestrict _ = f := by
  -- Porting note : `ext` did not pick up `NatTrans.ext`
  refine PresheafedSpace.Hom.ext _ _ rfl <| NatTrans.ext _ _ <| funext fun x => ?_
  · simp only [isoRestrict_hom_c_app, NatTrans.comp_app, eqToHom_refl,
      ofRestrict_c_app, Category.assoc, whiskerRight_id']
    erw [Category.comp_id, comp_c_app, f.c.naturality_assoc, ← X.presheaf.map_comp]
    trans f.c.app x ≫ X.presheaf.map (𝟙 _)
    · 

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
x : (Opens ↑↑Y)ᵒᵖ
⊢ f.c.app x ≫
      X.presheaf.map
        ((Opens.map f.base).op.map ((IsOpenMap.adjunction (_ : IsOpenMap ⇑f.base)).counit.app x.unop).op ≫
          (eqToIso
              (_ :
                (Opens.map f.base).op.obj
                    (op
                      ((openFunctor H).obj
                        (op ((Opens.map (ofRestrict Y (_ : OpenEmbedding ⇑f.base)).base).obj x.unop)).unop)) =
                  op ((Opens.map (ofRestrict Y (_ : OpenEmbedding ⇑f.base)).base).obj x.unop))).hom) =
    f.c.app x ≫ X.presheaf.map (𝟙 ((Opens.map f.base).op.obj x))

Next tactic:
congr 1
@[simp]
theorem isoRestrict_hom_ofRestrict : H.isoRestrict.hom ≫ Y.ofRestrict _ = f := by
  -- Porting note : `ext` did not pick up `NatTrans.ext`
  refine PresheafedSpace.Hom.ext _ _ rfl <| NatTrans.ext _ _ <| funext fun x => ?_
  · simp only [isoRestrict_hom_c_app, NatTrans.comp_app, eqToHom_refl,
      ofRestrict_c_app, Category.assoc, whiskerRight_id']
    erw [Category.comp_id, comp_c_app, f.c.naturality_assoc, ← X.presheaf.map_comp]
    trans f.c.app x ≫ X.presheaf.map (𝟙 _)
    · congr 1
    · 

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
x : (Opens ↑↑Y)ᵒᵖ
⊢ f.c.app x ≫ X.presheaf.map (𝟙 ((Opens.map f.base).op.obj x)) = f.c.app x

Next tactic:
erw [X.presheaf.map_id, Category.comp_id]
@[simp]
theorem isoRestrict_inv_ofRestrict : H.isoRestrict.inv ≫ f = Y.ofRestrict _ := by
  

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
⊢ (isoRestrict H).inv ≫ f = ofRestrict Y (_ : OpenEmbedding ⇑f.base)

Next tactic:
rw [Iso.inv_comp_eq, isoRestrict_hom_ofRestrict]
instance mono [H : IsOpenImmersion f] : Mono f := by
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.20071, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H✝ H : IsOpenImmersion f
⊢ Mono f

Next tactic:
rw [← H.isoRestrict_hom_ofRestrict]
instance mono [H : IsOpenImmersion f] : Mono f := by
  rw [← H.isoRestrict_hom_ofRestrict]; 

Proof state:
C : Type u_1
inst✝ : Category.{?u.20071, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H✝ H : IsOpenImmersion f
⊢ Mono ((isoRestrict H).hom ≫ ofRestrict Y (_ : OpenEmbedding ⇑f.base))

Next tactic:
apply mono_comp
/-- The composition of two open immersions is an open immersion. -/
instance comp {Z : PresheafedSpace C} (f : X ⟶ Y) [hf : IsOpenImmersion f] (g : Y ⟶ Z)
    [hg : IsOpenImmersion g] : IsOpenImmersion (f ≫ g) where
  base_open := hg.base_open.comp hf.base_open
  c_iso U := by
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.21081, u_1} C
X Y : PresheafedSpace C
f✝ : X ⟶ Y
H : IsOpenImmersion f✝
Z : PresheafedSpace C
f : X ⟶ Y
hf : IsOpenImmersion f
g : Y ⟶ Z
hg : IsOpenImmersion g
U : Opens ↑↑X
⊢ IsIso ((f ≫ g).c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(f ≫ g).base)).obj U)))

Next tactic:
generalize_proofs h
/-- The composition of two open immersions is an open immersion. -/
instance comp {Z : PresheafedSpace C} (f : X ⟶ Y) [hf : IsOpenImmersion f] (g : Y ⟶ Z)
    [hg : IsOpenImmersion g] : IsOpenImmersion (f ≫ g) where
  base_open := hg.base_open.comp hf.base_open
  c_iso U := by
    generalize_proofs h
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.21081, u_1} C
X Y : PresheafedSpace C
f✝ : X ⟶ Y
H : IsOpenImmersion f✝
Z : PresheafedSpace C
f : X ⟶ Y
hf : IsOpenImmersion f
g : Y ⟶ Z
hg : IsOpenImmersion g
U : Opens ↑↑X
h : IsOpenMap ⇑(f ≫ g).base
⊢ IsIso ((f ≫ g).c.app (op ((IsOpenMap.functor h).obj U)))

Next tactic:
dsimp only [AlgebraicGeometry.PresheafedSpace.comp_c_app, unop_op, Functor.op, comp_base,
      TopCat.Presheaf.pushforwardObj_obj, Opens.map_comp_obj]
/-- The composition of two open immersions is an open immersion. -/
instance comp {Z : PresheafedSpace C} (f : X ⟶ Y) [hf : IsOpenImmersion f] (g : Y ⟶ Z)
    [hg : IsOpenImmersion g] : IsOpenImmersion (f ≫ g) where
  base_open := hg.base_open.comp hf.base_open
  c_iso U := by
    generalize_proofs h
    dsimp only [AlgebraicGeometry.PresheafedSpace.comp_c_app, unop_op, Functor.op, comp_base,
      TopCat.Presheaf.pushforwardObj_obj, Opens.map_comp_obj]
    -- Porting note : was `apply (config := { instances := False }) ...`
    -- See https://github.com/leanprover/lean4/issues/2273
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.21081, u_1} C
X Y : PresheafedSpace C
f✝ : X ⟶ Y
H : IsOpenImmersion f✝
Z : PresheafedSpace C
f : X ⟶ Y
hf : IsOpenImmersion f
g : Y ⟶ Z
hg : IsOpenImmersion g
U : Opens ↑↑X
h : IsOpenMap ⇑(f ≫ g).base
⊢ IsIso
    (g.c.app (op ((IsOpenMap.functor h).obj U)) ≫ f.c.app (op ((Opens.map g.base).obj ((IsOpenMap.functor h).obj U))))

Next tactic:
have : IsIso (g.c.app (op <| (h.functor).obj U))
/-- The composition of two open immersions is an open immersion. -/
instance comp {Z : PresheafedSpace C} (f : X ⟶ Y) [hf : IsOpenImmersion f] (g : Y ⟶ Z)
    [hg : IsOpenImmersion g] : IsOpenImmersion (f ≫ g) where
  base_open := hg.base_open.comp hf.base_open
  c_iso U := by
    generalize_proofs h
    dsimp only [AlgebraicGeometry.PresheafedSpace.comp_c_app, unop_op, Functor.op, comp_base,
      TopCat.Presheaf.pushforwardObj_obj, Opens.map_comp_obj]
    -- Porting note : was `apply (config := { instances := False }) ...`
    -- See https://github.com/leanprover/lean4/issues/2273
    have : IsIso (g.c.app (op <| (h.functor).obj U))
    · 

Proof state:
case this
C : Type u_1
inst✝ : Category.{?u.21081, u_1} C
X Y : PresheafedSpace C
f✝ : X ⟶ Y
H : IsOpenImmersion f✝
Z : PresheafedSpace C
f : X ⟶ Y
hf : IsOpenImmersion f
g : Y ⟶ Z
hg : IsOpenImmersion g
U : Opens ↑↑X
h : IsOpenMap ⇑(f ≫ g).base
⊢ IsIso (g.c.app (op ((IsOpenMap.functor h).obj U)))

Next tactic:
have : h.functor.obj U = hg.openFunctor.obj (hf.openFunctor.obj U) := by
        ext1
        dsimp only [IsOpenMap.functor_obj_coe]
        -- Porting note : slightly more hand holding here: `g ∘ f` and `fun x => g (f x)`
        rw [comp_base, coe_comp, show g.base ∘ f.base = fun x => g.base (f.base x) from rfl,
          ← Set.image_image]