l3lab/ntp-mathlib huggingface dataset:
theorem comap_inducing_of_surjective (hf : Surjective f) : Inducing (comap f) where
  induced := by
    simp_rw [TopologicalSpace.ext_iff, ← isClosed_compl_iff,
      ← @isClosed_compl_iff (PrimeSpectrum S)
        ((TopologicalSpace.induced (comap f) zariskiTopology)), isClosed_induced_iff,
      isClosed_iff_zeroLocus]
    refine' fun s =>
      ⟨fun ⟨F, hF⟩ =>
        ⟨zeroLocus (f ⁻¹' F), ⟨f ⁻¹' F, rfl⟩, by
          

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
s : Set (PrimeSpectrum S)
x✝ : ∃ s_1, sᶜ = zeroLocus s_1
F : Set S
hF : sᶜ = zeroLocus F
⊢ ⇑(comap f) ⁻¹' zeroLocus (⇑f ⁻¹' F) = sᶜ

Next tactic:
rw [preimage_comap_zeroLocus, Function.Surjective.image_preimage hf, hF]
theorem comap_inducing_of_surjective (hf : Surjective f) : Inducing (comap f) where
  induced := by
    simp_rw [TopologicalSpace.ext_iff, ← isClosed_compl_iff,
      ← @isClosed_compl_iff (PrimeSpectrum S)
        ((TopologicalSpace.induced (comap f) zariskiTopology)), isClosed_induced_iff,
      isClosed_iff_zeroLocus]
    refine' fun s =>
      ⟨fun ⟨F, hF⟩ =>
        ⟨zeroLocus (f ⁻¹' F), ⟨f ⁻¹' F, rfl⟩, by
          rw [preimage_comap_zeroLocus, Function.Surjective.image_preimage hf, hF]⟩,
        _⟩
    

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
s : Set (PrimeSpectrum S)
⊢ (∃ t, (∃ s, t = zeroLocus s) ∧ ⇑(comap f) ⁻¹' t = sᶜ) → ∃ s_1, sᶜ = zeroLocus s_1

Next tactic:
rintro ⟨-, ⟨F, rfl⟩, hF⟩
theorem comap_inducing_of_surjective (hf : Surjective f) : Inducing (comap f) where
  induced := by
    simp_rw [TopologicalSpace.ext_iff, ← isClosed_compl_iff,
      ← @isClosed_compl_iff (PrimeSpectrum S)
        ((TopologicalSpace.induced (comap f) zariskiTopology)), isClosed_induced_iff,
      isClosed_iff_zeroLocus]
    refine' fun s =>
      ⟨fun ⟨F, hF⟩ =>
        ⟨zeroLocus (f ⁻¹' F), ⟨f ⁻¹' F, rfl⟩, by
          rw [preimage_comap_zeroLocus, Function.Surjective.image_preimage hf, hF]⟩,
        _⟩
    rintro ⟨-, ⟨F, rfl⟩, hF⟩
    

Proof state:
case intro.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
s : Set (PrimeSpectrum S)
F : Set R
hF : ⇑(comap f) ⁻¹' zeroLocus F = sᶜ
⊢ ∃ s_1, sᶜ = zeroLocus s_1

Next tactic:
exact ⟨f '' F, hF.symm.trans (preimage_comap_zeroLocus f F)⟩
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
⊢ ⇑(comap f) '' zeroLocus ↑I = zeroLocus ↑(Ideal.comap f I)

Next tactic:
simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
⊢ ∀ (x : PrimeSpectrum R), (∃ x_1, I ≤ x_1.asIdeal ∧ (comap f) x_1 = x) ↔ Ideal.comap f I ≤ x.asIdeal

Next tactic:
refine' fun p => ⟨_, fun h_I_p => _⟩
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · 

Proof state:
case refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
⊢ (∃ x, I ≤ x.asIdeal ∧ (comap f) x = p) → Ideal.comap f I ≤ p.asIdeal

Next tactic:
rintro ⟨p, hp, rfl⟩ a ha
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    

Proof state:
case refine'_1.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum S
hp : I ≤ p.asIdeal
a : R
ha : a ∈ Ideal.comap f I
⊢ a ∈ ((comap f) p).asIdeal

Next tactic:
exact hp ha
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · 

Proof state:
case refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
⊢ ∃ x, I ≤ x.asIdeal ∧ (comap f) x = p

Next tactic:
have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    

Proof state:
case refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
⊢ ∃ x, I ≤ x.asIdeal ∧ (comap f) x = p

Next tactic:
refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · 

Proof state:
case refine'_2.refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : S
hx : x ∈ I
⊢ x ∈ { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) }.asIdeal

Next tactic:
obtain ⟨x', rfl⟩ := hf x
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      

Proof state:
case refine'_2.refine'_1.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x' : R
hx : f x' ∈ I
⊢ f x' ∈ { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) }.asIdeal

Next tactic:
exact Ideal.mem_map_of_mem f (h_I_p hx)
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · 

Proof state:
case refine'_2.refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
⊢ (comap f) { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) } = p

Next tactic:
ext x
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · ext x
      

Proof state:
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ x ∈ ((comap f) { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) }).asIdeal ↔
    x ∈ p.asIdeal

Next tactic:
rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · ext x
      rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
      

Proof state:
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ (∃ x_1 ∈ p.asIdeal, f x_1 = f x) ↔ x ∈ p.asIdeal

Next tactic:
refine' ⟨_, fun hx => ⟨x, hx, rfl⟩⟩
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · ext x
      rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
      refine' ⟨_, fun hx => ⟨x, hx, rfl⟩⟩
      

Proof state:
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ (∃ x_1 ∈ p.asIdeal, f x_1 = f x) → x ∈ p.asIdeal

Next tactic:
rintro ⟨x', hx', heq⟩
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · ext x
      rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
      refine' ⟨_, fun hx => ⟨x, hx, rfl⟩⟩
      rintro ⟨x', hx', heq⟩
      

Proof state:
case refine'_2.refine'_2.asIdeal.h.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x x' : R
hx' : x' ∈ p.asIdeal
heq : f x' = f x
⊢ x ∈ p.asIdeal

Next tactic:
rw [← sub_sub_cancel x' x]
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · ext x
      rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
      refine' ⟨_, fun hx => ⟨x, hx, rfl⟩⟩
      rintro ⟨x', hx', heq⟩
      rw [← sub_sub_cancel x' x]
      

Proof state:
case refine'_2.refine'_2.asIdeal.h.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x x' : R
hx' : x' ∈ p.asIdeal
heq : f x' = f x
⊢ x' - (x' - x) ∈ p.asIdeal

Next tactic:
refine' p.asIdeal.sub_mem hx' (hp _)
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
    comap f '' zeroLocus I = zeroLocus (I.comap f) := by
  simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
  refine' fun p => ⟨_, fun h_I_p => _⟩
  · rintro ⟨p, hp, rfl⟩ a ha
    exact hp ha
  · have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
    refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
    · obtain ⟨x', rfl⟩ := hf x
      exact Ideal.mem_map_of_mem f (h_I_p hx)
    · ext x
      rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
      refine' ⟨_, fun hx => ⟨x, hx, rfl⟩⟩
      rintro ⟨x', hx', heq⟩
      rw [← sub_sub_cancel x' x]
      refine' p.asIdeal.sub_mem hx' (hp _)
      

Proof state:
case refine'_2.refine'_2.asIdeal.h.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x x' : R
hx' : x' ∈ p.asIdeal
heq : f x' = f x
⊢ x' - x ∈ ker f

Next tactic:
rwa [mem_ker, map_sub, sub_eq_zero]
theorem range_comap_of_surjective (hf : Surjective f) :
    Set.range (comap f) = zeroLocus (ker f) := by
  

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
⊢ Set.range ⇑(comap f) = zeroLocus ↑(ker f)

Next tactic:
rw [← Set.image_univ]
theorem range_comap_of_surjective (hf : Surjective f) :
    Set.range (comap f) = zeroLocus (ker f) := by
  rw [← Set.image_univ]
  

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
⊢ ⇑(comap f) '' Set.univ = zeroLocus ↑(ker f)

Next tactic:
convert image_comap_zeroLocus_eq_zeroLocus_comap _ _ hf _
theorem range_comap_of_surjective (hf : Surjective f) :
    Set.range (comap f) = zeroLocus (ker f) := by
  rw [← Set.image_univ]
  convert image_comap_zeroLocus_eq_zeroLocus_comap _ _ hf _
  

Proof state:
case h.e'_2.h.e'_4
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
⊢ Set.univ = zeroLocus ↑⊥

Next tactic:
rw [zeroLocus_bot]
theorem isClosed_range_comap_of_surjective (hf : Surjective f) :
    IsClosed (Set.range (comap f)) := by
  

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
⊢ IsClosed (Set.range ⇑(comap f))

Next tactic:
rw [range_comap_of_surjective _ f hf]
theorem isClosed_range_comap_of_surjective (hf : Surjective f) :
    IsClosed (Set.range (comap f)) := by
  rw [range_comap_of_surjective _ f hf]
  

Proof state:
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ⇑f
⊢ IsClosed (zeroLocus ↑(ker f))

Next tactic:
exact isClosed_zeroLocus _
@[simp]
theorem basicOpen_eq_zeroLocus_compl (r : R) :
    (basicOpen r : Set (PrimeSpectrum R)) = (zeroLocus {r})ᶜ :=
  Set.ext fun x => by 

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
r : R
x : PrimeSpectrum R
⊢ x ∈ ↑(basicOpen r) ↔ x ∈ (zeroLocus {r})ᶜ

Next tactic:
simp only [SetLike.mem_coe, mem_basicOpen, Set.mem_compl_iff, mem_zeroLocus,
    Set.singleton_subset_iff]
@[simp]
theorem basicOpen_one : basicOpen (1 : R) = ⊤ :=
  TopologicalSpace.Opens.ext <| by 

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ↑(basicOpen 1) = ↑⊤

Next tactic:
simp
@[simp]
theorem basicOpen_zero : basicOpen (0 : R) = ⊥ :=
  TopologicalSpace.Opens.ext <| by 

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ↑(basicOpen 0) = ↑⊥

Next tactic:
simp
theorem basicOpen_le_basicOpen_iff (f g : R) :
    basicOpen f ≤ basicOpen g ↔ f ∈ (Ideal.span ({g} : Set R)).radical := by
  

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen f ≤ basicOpen g ↔ f ∈ Ideal.radical (Ideal.span {g})

Next tactic:
rw [← SetLike.coe_subset_coe, basicOpen_eq_zeroLocus_compl, basicOpen_eq_zeroLocus_compl,
    Set.compl_subset_compl, zeroLocus_subset_zeroLocus_singleton_iff]
theorem basicOpen_mul (f g : R) : basicOpen (f * g) = basicOpen f ⊓ basicOpen g :=
  TopologicalSpace.Opens.ext <| by 

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ ↑(basicOpen (f * g)) = ↑(basicOpen f ⊓ basicOpen g)

Next tactic:
simp [zeroLocus_singleton_mul]
theorem basicOpen_mul_le_left (f g : R) : basicOpen (f * g) ≤ basicOpen f := by
  

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen (f * g) ≤ basicOpen f

Next tactic:
rw [basicOpen_mul f g]
theorem basicOpen_mul_le_left (f g : R) : basicOpen (f * g) ≤ basicOpen f := by
  rw [basicOpen_mul f g]
  

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen f ⊓ basicOpen g ≤ basicOpen f

Next tactic:
exact inf_le_left
theorem basicOpen_mul_le_right (f g : R) : basicOpen (f * g) ≤ basicOpen g := by
  

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen (f * g) ≤ basicOpen g

Next tactic:
rw [basicOpen_mul f g]
theorem basicOpen_mul_le_right (f g : R) : basicOpen (f * g) ≤ basicOpen g := by
  rw [basicOpen_mul f g]
  

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen f ⊓ basicOpen g ≤ basicOpen g

Next tactic:
exact inf_le_right
@[simp]
theorem basicOpen_pow (f : R) (n : ℕ) (hn : 0 < n) : basicOpen (f ^ n) = basicOpen f :=
  TopologicalSpace.Opens.ext <| by 

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
n : ℕ
hn : 0 < n
⊢ ↑(basicOpen (f ^ n)) = ↑(basicOpen f)

Next tactic:
simpa using zeroLocus_singleton_pow f n hn
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  

Proof state:
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ TopologicalSpace.IsTopologicalBasis (Set.range fun r => ↑(basicOpen r))

Next tactic:
apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · 

Proof state:
case h_open
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ u ∈ Set.range fun r => ↑(basicOpen r), IsOpen u

Next tactic:
rintro _ ⟨r, rfl⟩
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨r, rfl⟩
    

Proof state:
case h_open.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
r : R
⊢ IsOpen ((fun r => ↑(basicOpen r)) r)

Next tactic:
exact isOpen_basicOpen
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨r, rfl⟩
    exact isOpen_basicOpen
  · 

Proof state:
case h_nhds
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (a : PrimeSpectrum R) (u : Set (PrimeSpectrum R)),
    a ∈ u → IsOpen u → ∃ v ∈ Set.range fun r => ↑(basicOpen r), a ∈ v ∧ v ⊆ u

Next tactic:
rintro p U hp ⟨s, hs⟩
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨r, rfl⟩
    exact isOpen_basicOpen
  · rintro p U hp ⟨s, hs⟩
    

Proof state:
case h_nhds.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
hp : p ∈ U
s : Set R
hs : zeroLocus s = Uᶜ
⊢ ∃ v ∈ Set.range fun r => ↑(basicOpen r), p ∈ v ∧ v ⊆ U

Next tactic:
rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨r, rfl⟩
    exact isOpen_basicOpen
  · rintro p U hp ⟨s, hs⟩
    rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
    

Proof state:
case h_nhds.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
s : Set R
hp : ∃ a ∈ s, a ∉ ↑p.asIdeal
hs : zeroLocus s = Uᶜ
⊢ ∃ v ∈ Set.range fun r => ↑(basicOpen r), p ∈ v ∧ v ⊆ U

Next tactic:
obtain ⟨f, hfs, hfp⟩ := hp
theorem isTopologicalBasis_basic_opens :
    TopologicalSpace.IsTopologicalBasis
      (Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨r, rfl⟩
    exact isOpen_basicOpen
  · rintro p U hp ⟨s, hs⟩
    rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
    obtain ⟨f, hfs, hfp⟩ := hp
    

Proof state:
case h_nhds.intro.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
s : Set R
hs : zeroLocus s = Uᶜ
f : R
hfs : f ∈ s
hfp : f ∉ ↑p.asIdeal
⊢ ∃ v ∈ Set.range fun r => ↑(basicOpen r), p ∈ v ∧ v ⊆ U

Next tactic:
refine' ⟨basicOpen f, ⟨f, rfl⟩, hfp, _⟩