l3lab/ntp-mathlib huggingface dataset:
set_option maxHeartbeats 500000 in
/-- The category of internal monoid objects in `ModuleCat R`
is equivalent to the category of "native" bundled `R`-algebras.
-/
def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where
  functor := functor
  inverse := inverse
  unitIso :=
    NatIso.ofComponents
      (fun A =>
        { hom :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; 

Proof state:
case h
R : Type u
inst✝ : CommRing R
A : Mon_ (ModuleCat R)
x✝ : ↑(𝟙_ (ModuleCat R))
⊢ (((𝟭 (Mon_ (ModuleCat R))).obj A).one ≫
        {
          toAddHom :=
            { toFun := _root_.id,
              map_add' := (_ : ∀ (x y : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X), _root_.id (x + y) = _root_.id (x + y)) },
          map_smul' :=
            (_ :
              ∀ (r : R) (a : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X),
                AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ : ∀ (x y : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X), _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a) =
                  AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ : ∀ (x y : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X), _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a)) })
      x✝ =
    ((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).one x✝

Next tactic:
rfl
set_option maxHeartbeats 500000 in
/-- The category of internal monoid objects in `ModuleCat R`
is equivalent to the category of "native" bundled `R`-algebras.
-/
def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where
  functor := functor
  inverse := inverse
  unitIso :=
    NatIso.ofComponents
      (fun A =>
        { hom :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                

Proof state:
R : Type u
inst✝ : CommRing R
A : Mon_ (ModuleCat R)
⊢ compr₂ (TensorProduct.mk R ↑A.X ↑A.X)
      (A.mul ≫
        { toAddHom := { toFun := _root_.id, map_add' := (_ : ∀ (x y : ↑A.X), x + y = x + y) },
          map_smul' := (_ : ∀ (r : R) (a : ↑A.X), r • a = r • a) }) =
    compr₂ (TensorProduct.mk R ↑A.X ↑A.X)
      (CategoryTheory.MonoidalCategory.tensorHom
          { toAddHom := { toFun := _root_.id, map_add' := (_ : ∀ (x y : ↑A.X), x + y = x + y) },
            map_smul' := (_ : ∀ (r : R) (a : ↑A.X), r • a = r • a) }
          { toAddHom := { toFun := _root_.id, map_add' := (_ : ∀ (x y : ↑A.X), x + y = x + y) },
            map_smul' := (_ : ∀ (r : R) (a : ↑A.X), r • a = r • a) } ≫
        mul' R ↑A.X)

Next tactic:
rfl
set_option maxHeartbeats 500000 in
/-- The category of internal monoid objects in `ModuleCat R`
is equivalent to the category of "native" bundled `R`-algebras.
-/
def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where
  functor := functor
  inverse := inverse
  unitIso :=
    NatIso.ofComponents
      (fun A =>
        { hom :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; rfl }
          inv :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by 

Proof state:
R : Type u
inst✝ : CommRing R
A : Mon_ (ModuleCat R)
⊢ ((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).one ≫
      {
        toAddHom :=
          { toFun := _root_.id,
            map_add' :=
              (_ :
                ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                  _root_.id (x + y) = _root_.id (x + y)) },
        map_smul' :=
          (_ :
            ∀ (r : R) (a : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
              AddHom.toFun
                  { toFun := _root_.id,
                    map_add' :=
                      (_ :
                        ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                          _root_.id (x + y) = _root_.id (x + y)) }
                  (r • a) =
                AddHom.toFun
                  { toFun := _root_.id,
                    map_add' :=
                      (_ :
                        ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                          _root_.id (x + y) = _root_.id (x + y)) }
                  (r • a)) } =
    ((𝟭 (Mon_ (ModuleCat R))).obj A).one

Next tactic:
ext
set_option maxHeartbeats 500000 in
/-- The category of internal monoid objects in `ModuleCat R`
is equivalent to the category of "native" bundled `R`-algebras.
-/
def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where
  functor := functor
  inverse := inverse
  unitIso :=
    NatIso.ofComponents
      (fun A =>
        { hom :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; rfl }
          inv :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; 

Proof state:
case h
R : Type u
inst✝ : CommRing R
A : Mon_ (ModuleCat R)
x✝ : ↑(𝟙_ (ModuleCat R))
⊢ (((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).one ≫
        {
          toAddHom :=
            { toFun := _root_.id,
              map_add' :=
                (_ :
                  ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                    _root_.id (x + y) = _root_.id (x + y)) },
          map_smul' :=
            (_ :
              ∀ (r : R) (a : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ :
                          ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                            _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a) =
                  AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ :
                          ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                            _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a)) })
      x✝ =
    ((𝟭 (Mon_ (ModuleCat R))).obj A).one x✝

Next tactic:
rfl
set_option maxHeartbeats 500000 in
/-- The category of internal monoid objects in `ModuleCat R`
is equivalent to the category of "native" bundled `R`-algebras.
-/
def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where
  functor := functor
  inverse := inverse
  unitIso :=
    NatIso.ofComponents
      (fun A =>
        { hom :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; rfl }
          inv :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                

Proof state:
R : Type u
inst✝ : CommRing R
A : Mon_ (ModuleCat R)
⊢ compr₂ (TensorProduct.mk R ↑(of R ↑A.X) ↑(of R ↑A.X))
      (mul' R ↑A.X ≫
        { toAddHom := { toFun := _root_.id, map_add' := (_ : ∀ (x y : ↑(of R ↑A.X)), x + y = x + y) },
          map_smul' := (_ : ∀ (r : R) (a : ↑(of R ↑A.X)), r • a = r • a) }) =
    compr₂ (TensorProduct.mk R ↑(of R ↑A.X) ↑(of R ↑A.X))
      (CategoryTheory.MonoidalCategory.tensorHom
          { toAddHom := { toFun := _root_.id, map_add' := (_ : ∀ (x y : ↑(of R ↑A.X)), x + y = x + y) },
            map_smul' := (_ : ∀ (r : R) (a : ↑(of R ↑A.X)), r • a = r • a) }
          { toAddHom := { toFun := _root_.id, map_add' := (_ : ∀ (x y : ↑(of R ↑A.X)), x + y = x + y) },
            map_smul' := (_ : ∀ (r : R) (a : ↑(of R ↑A.X)), r • a = r • a) } ≫
        A.mul)

Next tactic:
rfl
set_option maxHeartbeats 500000 in
/-- The category of internal monoid objects in `ModuleCat R`
is equivalent to the category of "native" bundled `R`-algebras.
-/
def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where
  functor := functor
  inverse := inverse
  unitIso :=
    NatIso.ofComponents
      (fun A =>
        { hom :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; rfl }
          inv :=
            { hom :=
                { toFun := _root_.id
                  map_add' := fun x y => rfl
                  map_smul' := fun r a => rfl }
              mul_hom := by
                -- Porting note : `ext` did not pick up `TensorProduct.ext`
                refine TensorProduct.ext ?_
                dsimp at *
                rfl
              one_hom := by ext; rfl }
          hom_inv_id := by 

Proof state:
R : Type u
inst✝ : CommRing R
A : Mon_ (ModuleCat R)
⊢ Mon_.Hom.mk
        {
          toAddHom :=
            { toFun := _root_.id,
              map_add' := (_ : ∀ (x y : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X), _root_.id (x + y) = _root_.id (x + y)) },
          map_smul' :=
            (_ :
              ∀ (r : R) (a : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X),
                AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ : ∀ (x y : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X), _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a) =
                  AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ : ∀ (x y : ↑((𝟭 (Mon_ (ModuleCat R))).obj A).X), _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a)) } ≫
      Mon_.Hom.mk
        {
          toAddHom :=
            { toFun := _root_.id,
              map_add' :=
                (_ :
                  ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                    _root_.id (x + y) = _root_.id (x + y)) },
          map_smul' :=
            (_ :
              ∀ (r : R) (a : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ :
                          ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                            _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a) =
                  AddHom.toFun
                    { toFun := _root_.id,
                      map_add' :=
                        (_ :
                          ∀ (x y : ↑((functor ⋙ MonModuleEquivalenceAlgebra.inverse).obj A).X),
                            _root_.id (x + y) = _root_.id (x + y)) }
                    (r • a)) } =
    𝟙 ((𝟭 (Mon_ (ModuleCat R))).obj A)

Next tactic:
ext
theorem isOpen_imageOfDf : IsOpen (imageOfDf f) := by
  

Proof state:
R : Type u_1
inst✝ : CommRing R
f : R[X]
⊢ IsOpen (imageOfDf f)

Next tactic:
rw [imageOfDf, setOf_exists fun i (x : PrimeSpectrum R) => coeff f i ∉ x.asIdeal]
theorem isOpen_imageOfDf : IsOpen (imageOfDf f) := by
  rw [imageOfDf, setOf_exists fun i (x : PrimeSpectrum R) => coeff f i ∉ x.asIdeal]
  

Proof state:
R : Type u_1
inst✝ : CommRing R
f : R[X]
⊢ IsOpen (⋃ i, {x | coeff f i ∉ x.asIdeal})

Next tactic:
exact isOpen_iUnion fun i => isOpen_basicOpen
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  

Proof state:
R : Type u_1
inst✝ : CommRing R
f : R[X]
⊢ imageOfDf f = ⇑(PrimeSpectrum.comap C) '' (zeroLocus {f})ᶜ

Next tactic:
ext x
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  

Proof state:
case h
R : Type u_1
inst✝ : CommRing R
f : R[X]
x : PrimeSpectrum R
⊢ x ∈ imageOfDf f ↔ x ∈ ⇑(PrimeSpectrum.comap C) '' (zeroLocus {f})ᶜ

Next tactic:
refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · 

Proof state:
case h.refine'_1
R : Type u_1
inst✝ : CommRing R
f : R[X]
x : PrimeSpectrum R
hx : x ∈ imageOfDf f
⊢ { asIdeal := Ideal.map C x.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x.asIdeal)) } ∈ (zeroLocus {f})ᶜ

Next tactic:
rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    

Proof state:
case h.refine'_1
R : Type u_1
inst✝ : CommRing R
f : R[X]
x : PrimeSpectrum R
hx : x ∈ imageOfDf f
⊢ f ∉ ↑{ asIdeal := Ideal.map C x.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x.asIdeal)) }.asIdeal

Next tactic:
cases' hx with i hi
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    

Proof state:
case h.refine'_1.intro
R : Type u_1
inst✝ : CommRing R
f : R[X]
x : PrimeSpectrum R
i : ℕ
hi : coeff f i ∉ x.asIdeal
⊢ f ∉ ↑{ asIdeal := Ideal.map C x.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x.asIdeal)) }.asIdeal

Next tactic:
exact fun a => hi (mem_map_C_iff.mp a i)
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    exact fun a => hi (mem_map_C_iff.mp a i)
  · 

Proof state:
case h.refine'_2
R : Type u_1
inst✝ : CommRing R
f : R[X]
x : PrimeSpectrum R
hx : x ∈ imageOfDf f
⊢ (PrimeSpectrum.comap C) { asIdeal := Ideal.map C x.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x.asIdeal)) } =
    x

Next tactic:
ext x
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    exact fun a => hi (mem_map_C_iff.mp a i)
  · ext x
    

Proof state:
case h.refine'_2.asIdeal.h
R : Type u_1
inst✝ : CommRing R
f : R[X]
x✝ : PrimeSpectrum R
hx : x✝ ∈ imageOfDf f
x : R
⊢ x ∈
      ((PrimeSpectrum.comap C)
          { asIdeal := Ideal.map C x✝.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x✝.asIdeal)) }).asIdeal ↔
    x ∈ x✝.asIdeal

Next tactic:
refine' ⟨fun h => _, fun h => subset_span (mem_image_of_mem C.1 h)⟩
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    exact fun a => hi (mem_map_C_iff.mp a i)
  · ext x
    refine' ⟨fun h => _, fun h => subset_span (mem_image_of_mem C.1 h)⟩
    

Proof state:
case h.refine'_2.asIdeal.h
R : Type u_1
inst✝ : CommRing R
f : R[X]
x✝ : PrimeSpectrum R
hx : x✝ ∈ imageOfDf f
x : R
h :
  x ∈
    ((PrimeSpectrum.comap C)
        { asIdeal := Ideal.map C x✝.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x✝.asIdeal)) }).asIdeal
⊢ x ∈ x✝.asIdeal

Next tactic:
rw [← @coeff_C_zero R x _]
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    exact fun a => hi (mem_map_C_iff.mp a i)
  · ext x
    refine' ⟨fun h => _, fun h => subset_span (mem_image_of_mem C.1 h)⟩
    rw [← @coeff_C_zero R x _]
    

Proof state:
case h.refine'_2.asIdeal.h
R : Type u_1
inst✝ : CommRing R
f : R[X]
x✝ : PrimeSpectrum R
hx : x✝ ∈ imageOfDf f
x : R
h :
  x ∈
    ((PrimeSpectrum.comap C)
        { asIdeal := Ideal.map C x✝.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map C x✝.asIdeal)) }).asIdeal
⊢ coeff (C x) 0 ∈ x✝.asIdeal

Next tactic:
exact mem_map_C_iff.mp h 0
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    exact fun a => hi (mem_map_C_iff.mp a i)
  · ext x
    refine' ⟨fun h => _, fun h => subset_span (mem_image_of_mem C.1 h)⟩
    rw [← @coeff_C_zero R x _]
    exact mem_map_C_iff.mp h 0
  · 

Proof state:
case h.refine'_3
R : Type u_1
inst✝ : CommRing R
f : R[X]
x : PrimeSpectrum R
⊢ x ∈ ⇑(PrimeSpectrum.comap C) '' (zeroLocus {f})ᶜ → x ∈ imageOfDf f

Next tactic:
rintro ⟨xli, complement, rfl⟩
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
    imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
  ext x
  refine' ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.IsPrime⟩, ⟨_, _⟩⟩, _⟩
  · rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
    cases' hx with i hi
    exact fun a => hi (mem_map_C_iff.mp a i)
  · ext x
    refine' ⟨fun h => _, fun h => subset_span (mem_image_of_mem C.1 h)⟩
    rw [← @coeff_C_zero R x _]
    exact mem_map_C_iff.mp h 0
  · rintro ⟨xli, complement, rfl⟩
    

Proof state:
case h.refine'_3.intro.intro
R : Type u_1
inst✝ : CommRing R
f : R[X]
xli : PrimeSpectrum R[X]
complement : xli ∈ (zeroLocus {f})ᶜ
⊢ (PrimeSpectrum.comap C) xli ∈ imageOfDf f

Next tactic:
exact comap_C_mem_imageOfDf complement
/-- The morphism `C⁺ : Spec R[x] → Spec R` is open.
Stacks Project "Lemma 00FB", first part.

https://stacks.math.columbia.edu/tag/00FB
-/
theorem isOpenMap_comap_C : IsOpenMap (PrimeSpectrum.comap (C : R →+* R[X])) := by
  

Proof state:
R : Type u_1
inst✝ : CommRing R
f : R[X]
⊢ IsOpenMap ⇑(PrimeSpectrum.comap C)

Next tactic:
rintro U ⟨s, z⟩
/-- The morphism `C⁺ : Spec R[x] → Spec R` is open.
Stacks Project "Lemma 00FB", first part.

https://stacks.math.columbia.edu/tag/00FB
-/
theorem isOpenMap_comap_C : IsOpenMap (PrimeSpectrum.comap (C : R →+* R[X])) := by
  rintro U ⟨s, z⟩
  

Proof state:
case intro
R : Type u_1
inst✝ : CommRing R
f : R[X]
U : Set (PrimeSpectrum R[X])
s : Set R[X]
z : zeroLocus s = Uᶜ
⊢ IsOpen (⇑(PrimeSpectrum.comap C) '' U)

Next tactic:
rw [← compl_compl U, ← z, ← iUnion_of_singleton_coe s, zeroLocus_iUnion, compl_iInter,
    image_iUnion]
/-- The morphism `C⁺ : Spec R[x] → Spec R` is open.
Stacks Project "Lemma 00FB", first part.

https://stacks.math.columbia.edu/tag/00FB
-/
theorem isOpenMap_comap_C : IsOpenMap (PrimeSpectrum.comap (C : R →+* R[X])) := by
  rintro U ⟨s, z⟩
  rw [← compl_compl U, ← z, ← iUnion_of_singleton_coe s, zeroLocus_iUnion, compl_iInter,
    image_iUnion]
  

Proof state:
case intro
R : Type u_1
inst✝ : CommRing R
f : R[X]
U : Set (PrimeSpectrum R[X])
s : Set R[X]
z : zeroLocus s = Uᶜ
⊢ IsOpen (⋃ i, ⇑(PrimeSpectrum.comap C) '' (zeroLocus {↑i})ᶜ)

Next tactic:
simp_rw [← imageOfDf_eq_comap_C_compl_zeroLocus]
/-- The morphism `C⁺ : Spec R[x] → Spec R` is open.
Stacks Project "Lemma 00FB", first part.

https://stacks.math.columbia.edu/tag/00FB
-/
theorem isOpenMap_comap_C : IsOpenMap (PrimeSpectrum.comap (C : R →+* R[X])) := by
  rintro U ⟨s, z⟩
  rw [← compl_compl U, ← z, ← iUnion_of_singleton_coe s, zeroLocus_iUnion, compl_iInter,
    image_iUnion]
  simp_rw [← imageOfDf_eq_comap_C_compl_zeroLocus]
  

Proof state:
case intro
R : Type u_1
inst✝ : CommRing R
f : R[X]
U : Set (PrimeSpectrum R[X])
s : Set R[X]
z : zeroLocus s = Uᶜ
⊢ IsOpen (⋃ i, imageOfDf ↑i)

Next tactic:
exact isOpen_iUnion fun f => isOpen_imageOfDf
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
    o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by
  

Proof state:
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
hd2 : Fact (finrank ℝ V = 2)
o : Orientation ℝ V (Fin 2)
x y : V
h : oangle o x y = ↑(π / 2)
⊢ oangle o x (x + y) = ↑(Real.arccos (‖x‖ / ‖x + y‖))

Next tactic:
have hs : (o.oangle x (x + y)).sign = 1 := by
    rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]