l3lab/ntp-mathlib huggingface dataset:
/-- Prime avoidance. Atiyah-Macdonald 1.11, Eisenbud 3.3, Stacks 00DS, Matsumura Ex.1.6. -/
theorem subset_union_prime {R : Type u} [CommRing R] {s : Finset ι} {f : ι → Ideal R} (a b : ι)
    (hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)) {I : Ideal R} :
    ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) ↔ ∃ i ∈ s, I ≤ f i :=
  suffices ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) → ∃ i, i ∈ s ∧ I ≤ f i by
    have aux := fun h => (bex_def.2 <| this h)
    simp_rw [exists_prop] at aux
    refine ⟨aux, fun ⟨i, his, hi⟩ ↦ Set.Subset.trans hi ?_⟩
    apply Set.subset_biUnion_of_mem (show i ∈ (↑s : Set ι) from his)
  fun h : (I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i => by
  classical
    by_cases has : a ∈ s
    · obtain ⟨t, hat, rfl⟩ : ∃ t, a ∉ t ∧ insert a t = s :=
        ⟨s.erase a, Finset.not_mem_erase a s, Finset.insert_erase has⟩
      by_cases hbt : b ∈ t
      · obtain ⟨u, hbu, rfl⟩ : ∃ u, b ∉ u ∧ insert b u = t :=
          ⟨t.erase b, Finset.not_mem_erase b t, Finset.insert_erase hbt⟩
        have hp' : ∀ i ∈ u, IsPrime (f i) := by
          intro i hiu
          refine' hp i (Finset.mem_insert_of_mem (Finset.mem_insert_of_mem hiu)) _ _ <;>
              rintro rfl <;>
            solve_by_elim only [Finset.mem_insert_of_mem, *]
        rw [Finset.coe_insert, Finset.coe_insert, Set.biUnion_insert, Set.biUnion_insert, ←
          Set.union_assoc, subset_union_prime' hp'] at h
        rwa [Finset.exists_mem_insert, Finset.exists_mem_insert]
      · have hp' : ∀ j ∈ t, IsPrime (f j) := by
          intro j hj
          refine' hp j (Finset.mem_insert_of_mem hj) _ _ <;> rintro rfl <;>
            solve_by_elim only [Finset.mem_insert_of_mem, *]
        rw [Finset.coe_insert, Set.biUnion_insert, ← Set.union_self (f a : Set R),
          subset_union_prime' hp', ← or_assoc, or_self_iff] at h
        rwa [Finset.exists_mem_insert]
    · by_cases hbs : b ∈ s
      · obtain ⟨t, hbt, rfl⟩ : ∃ t, b ∉ t ∧ insert b t = s :=
          ⟨s.erase b, Finset.not_mem_erase b s, Finset.insert_erase hbs⟩
        have hp' : ∀ j ∈ t, IsPrime (f j) := by
          intro j hj
          refine' hp j (Finset.mem_insert_of_mem hj) _ _ <;> rintro rfl <;>
            solve_by_elim only [Finset.mem_insert_of_mem, *]
        rw [Finset.coe_insert, Set.biUnion_insert, ← Set.union_self (f b : Set R),
          subset_union_prime' hp', ← or_assoc, or_self_iff] at h
        rwa [Finset.exists_mem_insert]
      rcases s.eq_empty_or_nonempty with hse | hsne
      · subst hse
        rw [Finset.coe_empty, Set.biUnion_empty, Set.subset_empty_iff] at h
        have : (I : Set R) ≠ ∅ := Set.Nonempty.ne_empty (Set.nonempty_of_mem I.zero_mem)
        exact absurd h this
      · cases' hsne.bex with i his
        

Proof state:
case neg.inr.intro
R✝ : Type u
ι : Type u_1
inst✝¹ : CommSemiring R✝
I✝ J K L : Ideal R✝
R : Type u
inst✝ : CommRing R
s : Finset ι
f : ι → Ideal R
a b : ι
hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)
I : Ideal R
h : ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i)
has : a ∉ s
hbs : b ∉ s
hsne : Finset.Nonempty s
i : ι
his : i ∈ s
⊢ ∃ i ∈ s, I ≤ f i

Next tactic:
obtain ⟨t, _, rfl⟩ : ∃ t, i ∉ t ∧ insert i t = s :=
          ⟨s.erase i, Finset.not_mem_erase i s, Finset.insert_erase his⟩
/-- Prime avoidance. Atiyah-Macdonald 1.11, Eisenbud 3.3, Stacks 00DS, Matsumura Ex.1.6. -/
theorem subset_union_prime {R : Type u} [CommRing R] {s : Finset ι} {f : ι → Ideal R} (a b : ι)
    (hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)) {I : Ideal R} :
    ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) ↔ ∃ i ∈ s, I ≤ f i :=
  suffices ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) → ∃ i, i ∈ s ∧ I ≤ f i by
    

Proof state:
R✝ : Type u
ι : Type u_1
inst✝¹ : CommSemiring R✝
I✝ J K L : Ideal R✝
R : Type u
inst✝ : CommRing R
s : Finset ι
f : ι → Ideal R
a b : ι
hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)
I : Ideal R
this : ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) → ∃ i ∈ s, I ≤ f i
⊢ ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) ↔ ∃ i ∈ s, I ≤ f i

Next tactic:
have aux := fun h => (bex_def.2 <| this h)
/-- Prime avoidance. Atiyah-Macdonald 1.11, Eisenbud 3.3, Stacks 00DS, Matsumura Ex.1.6. -/
theorem subset_union_prime {R : Type u} [CommRing R] {s : Finset ι} {f : ι → Ideal R} (a b : ι)
    (hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)) {I : Ideal R} :
    ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) ↔ ∃ i ∈ s, I ≤ f i :=
  suffices ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) → ∃ i, i ∈ s ∧ I ≤ f i by
    have aux := fun h => (bex_def.2 <| this h)
    

Proof state:
R✝ : Type u
ι : Type u_1
inst✝¹ : CommSemiring R✝
I✝ J K L : Ideal R✝
R : Type u
inst✝ : CommRing R
s : Finset ι
f : ι → Ideal R
a b : ι
hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)
I : Ideal R
this : ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) → ∃ i ∈ s, I ≤ f i
aux : ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) → ∃ x, ∃ (_ : x ∈ s), I ≤ f x
⊢ ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) ↔ ∃ i ∈ s, I ≤ f i

Next tactic:
simp_rw [exists_prop] at aux
/-- Prime avoidance. Atiyah-Macdonald 1.11, Eisenbud 3.3, Stacks 00DS, Matsumura Ex.1.6. -/
theorem subset_union_prime {R : Type u} [CommRing R] {s : Finset ι} {f : ι → Ideal R} (a b : ι)
    (hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)) {I : Ideal R} :
    ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) ↔ ∃ i ∈ s, I ≤ f i :=
  suffices ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) → ∃ i, i ∈ s ∧ I ≤ f i by
    have aux := fun h => (bex_def.2 <| this h)
    simp_rw [exists_prop] at aux
    

Proof state:
R✝ : Type u
ι : Type u_1
inst✝¹ : CommSemiring R✝
I✝ J K L : Ideal R✝
R : Type u
inst✝ : CommRing R
s : Finset ι
f : ι → Ideal R
a b : ι
hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)
I : Ideal R
this aux : ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) → ∃ x ∈ s, I ≤ f x
⊢ ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) ↔ ∃ i ∈ s, I ≤ f i

Next tactic:
refine ⟨aux, fun ⟨i, his, hi⟩ ↦ Set.Subset.trans hi ?_⟩
/-- Prime avoidance. Atiyah-Macdonald 1.11, Eisenbud 3.3, Stacks 00DS, Matsumura Ex.1.6. -/
theorem subset_union_prime {R : Type u} [CommRing R] {s : Finset ι} {f : ι → Ideal R} (a b : ι)
    (hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)) {I : Ideal R} :
    ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) ↔ ∃ i ∈ s, I ≤ f i :=
  suffices ((I : Set R) ⊆ ⋃ i ∈ (↑s : Set ι), f i) → ∃ i, i ∈ s ∧ I ≤ f i by
    have aux := fun h => (bex_def.2 <| this h)
    simp_rw [exists_prop] at aux
    refine ⟨aux, fun ⟨i, his, hi⟩ ↦ Set.Subset.trans hi ?_⟩
    

Proof state:
R✝ : Type u
ι : Type u_1
inst✝¹ : CommSemiring R✝
I✝ J K L : Ideal R✝
R : Type u
inst✝ : CommRing R
s : Finset ι
f : ι → Ideal R
a b : ι
hp : ∀ i ∈ s, i ≠ a → i ≠ b → IsPrime (f i)
I : Ideal R
this aux : ↑I ⊆ ⋃ i ∈ ↑s, ↑(f i) → ∃ x ∈ s, I ≤ f x
x✝ : ∃ i ∈ s, I ≤ f i
i : ι
his : i ∈ s
hi : I ≤ f i
⊢ ↑(f i) ⊆ ⋃ i ∈ ↑s, ↑(f i)

Next tactic:
apply Set.subset_biUnion_of_mem (show i ∈ (↑s : Set ι) from his)
theorem isUnit_iff {I : Ideal R} : IsUnit I ↔ I = ⊤ :=
  isUnit_iff_dvd_one.trans
    ((@one_eq_top R _).symm ▸
      ⟨fun h => eq_top_iff.mpr (Ideal.le_of_dvd h), fun h => ⟨⊤, by 

Proof state:
R : Type u
ι : Type u_1
inst✝ : CommSemiring R
I✝ J K L I : Ideal R
h : I = ⊤
⊢ ⊤ = I * ⊤

Next tactic:
rw [mul_top, h]
instance uniqueUnits : Unique (Ideal R)ˣ where
  default := 1
  uniq u := Units.ext (show (u : Ideal R) = 1 by 

Proof state:
R : Type u
ι : Type u_1
inst✝ : CommSemiring R
I J K L : Ideal R
u : (Ideal R)ˣ
⊢ ↑u = 1

Next tactic:
rw [isUnit_iff.mp u.isUnit, one_eq_top]
/-- `I.comap f` is the preimage of `I` under `f`. -/
def comap (I : Ideal S) : Ideal R where
  carrier := f ⁻¹' I
  add_mem' {x y} hx hy := by
    

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L I : Ideal S
x y : R
hx : x ∈ ⇑f ⁻¹' ↑I
hy : y ∈ ⇑f ⁻¹' ↑I
⊢ x + y ∈ ⇑f ⁻¹' ↑I

Next tactic:
simp only [Set.mem_preimage, SetLike.mem_coe, map_add] at hx hy ⊢
/-- `I.comap f` is the preimage of `I` under `f`. -/
def comap (I : Ideal S) : Ideal R where
  carrier := f ⁻¹' I
  add_mem' {x y} hx hy := by
    simp only [Set.mem_preimage, SetLike.mem_coe, map_add] at hx hy ⊢
    

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L I : Ideal S
x y : R
hx : f x ∈ I
hy : f y ∈ I
⊢ f x + f y ∈ I

Next tactic:
exact add_mem hx hy
/-- `I.comap f` is the preimage of `I` under `f`. -/
def comap (I : Ideal S) : Ideal R where
  carrier := f ⁻¹' I
  add_mem' {x y} hx hy := by
    simp only [Set.mem_preimage, SetLike.mem_coe, map_add] at hx hy ⊢
    exact add_mem hx hy
  zero_mem' := by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L I : Ideal S
⊢ 0 ∈ { carrier := ⇑f ⁻¹' ↑I, add_mem' := (_ : ∀ {x y : R}, x ∈ ⇑f ⁻¹' ↑I → y ∈ ⇑f ⁻¹' ↑I → x + y ∈ ⇑f ⁻¹' ↑I) }.carrier

Next tactic:
simp only [Set.mem_preimage, map_zero, SetLike.mem_coe, Submodule.zero_mem]
/-- `I.comap f` is the preimage of `I` under `f`. -/
def comap (I : Ideal S) : Ideal R where
  carrier := f ⁻¹' I
  add_mem' {x y} hx hy := by
    simp only [Set.mem_preimage, SetLike.mem_coe, map_add] at hx hy ⊢
    exact add_mem hx hy
  zero_mem' := by simp only [Set.mem_preimage, map_zero, SetLike.mem_coe, Submodule.zero_mem]
  smul_mem' c x hx := by
    

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L I : Ideal S
c x : R
hx :
  x ∈
    {
          toAddSubsemigroup :=
            { carrier := ⇑f ⁻¹' ↑I, add_mem' := (_ : ∀ {x y : R}, x ∈ ⇑f ⁻¹' ↑I → y ∈ ⇑f ⁻¹' ↑I → x + y ∈ ⇑f ⁻¹' ↑I) },
          zero_mem' := (_ : 0 ∈ ⇑f ⁻¹' ↑I) }.toAddSubsemigroup.carrier
⊢ c • x ∈
    {
          toAddSubsemigroup :=
            { carrier := ⇑f ⁻¹' ↑I, add_mem' := (_ : ∀ {x y : R}, x ∈ ⇑f ⁻¹' ↑I → y ∈ ⇑f ⁻¹' ↑I → x + y ∈ ⇑f ⁻¹' ↑I) },
          zero_mem' := (_ : 0 ∈ ⇑f ⁻¹' ↑I) }.toAddSubsemigroup.carrier

Next tactic:
simp only [smul_eq_mul, Set.mem_preimage, map_mul, SetLike.mem_coe] at *
/-- `I.comap f` is the preimage of `I` under `f`. -/
def comap (I : Ideal S) : Ideal R where
  carrier := f ⁻¹' I
  add_mem' {x y} hx hy := by
    simp only [Set.mem_preimage, SetLike.mem_coe, map_add] at hx hy ⊢
    exact add_mem hx hy
  zero_mem' := by simp only [Set.mem_preimage, map_zero, SetLike.mem_coe, Submodule.zero_mem]
  smul_mem' c x hx := by
    simp only [smul_eq_mul, Set.mem_preimage, map_mul, SetLike.mem_coe] at *
    

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L I : Ideal S
c x : R
hx : f x ∈ I
⊢ f c * f x ∈ I

Next tactic:
exact mul_mem_left I _ hx
theorem comap_ne_top (hK : K ≠ ⊤) : comap f K ≠ ⊤ :=
  (ne_top_iff_one _).2 <| by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
hK : K ≠ ⊤
⊢ 1 ∉ comap f K

Next tactic:
rw [mem_comap, map_one]
theorem comap_ne_top (hK : K ≠ ⊤) : comap f K ≠ ⊤ :=
  (ne_top_iff_one _).2 <| by rw [mem_comap, map_one]; 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
hK : K ≠ ⊤
⊢ 1 ∉ K

Next tactic:
exact (ne_top_iff_one _).1 hK
theorem map_le_comap_of_inv_on (g : G) (I : Ideal R) (hf : Set.LeftInvOn g f I) :
    I.map f ≤ I.comap g := by
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
g : G
I : Ideal R
hf : Set.LeftInvOn ⇑g ⇑f ↑I
⊢ map f I ≤ comap g I

Next tactic:
refine' Ideal.span_le.2 _
theorem map_le_comap_of_inv_on (g : G) (I : Ideal R) (hf : Set.LeftInvOn g f I) :
    I.map f ≤ I.comap g := by
  refine' Ideal.span_le.2 _
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
g : G
I : Ideal R
hf : Set.LeftInvOn ⇑g ⇑f ↑I
⊢ ⇑f '' ↑I ⊆ ↑(comap g I)

Next tactic:
rintro x ⟨x, hx, rfl⟩
theorem map_le_comap_of_inv_on (g : G) (I : Ideal R) (hf : Set.LeftInvOn g f I) :
    I.map f ≤ I.comap g := by
  refine' Ideal.span_le.2 _
  rintro x ⟨x, hx, rfl⟩
  

Proof state:
case intro.intro
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
g : G
I : Ideal R
hf : Set.LeftInvOn ⇑g ⇑f ↑I
x : R
hx : x ∈ ↑I
⊢ f x ∈ ↑(comap g I)

Next tactic:
rw [SetLike.mem_coe, mem_comap, hf hx]
theorem map_le_comap_of_inv_on (g : G) (I : Ideal R) (hf : Set.LeftInvOn g f I) :
    I.map f ≤ I.comap g := by
  refine' Ideal.span_le.2 _
  rintro x ⟨x, hx, rfl⟩
  rw [SetLike.mem_coe, mem_comap, hf hx]
  

Proof state:
case intro.intro
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
g : G
I : Ideal R
hf : Set.LeftInvOn ⇑g ⇑f ↑I
x : R
hx : x ∈ ↑I
⊢ x ∈ I

Next tactic:
exact hx
instance IsPrime.comap [hK : K.IsPrime] : (comap f K).IsPrime :=
  ⟨comap_ne_top _ hK.1, fun {x y} => by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
hK : IsPrime K
x y : R
⊢ x * y ∈ Ideal.comap f K → x ∈ Ideal.comap f K ∨ y ∈ Ideal.comap f K

Next tactic:
simp only [mem_comap, map_mul]
instance IsPrime.comap [hK : K.IsPrime] : (comap f K).IsPrime :=
  ⟨comap_ne_top _ hK.1, fun {x y} => by simp only [mem_comap, map_mul]; 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
hK : IsPrime K
x y : R
⊢ f x * f y ∈ K → f x ∈ K ∨ f y ∈ K

Next tactic:
apply hK.2
theorem map_span (f : F) (s : Set R) : map f (span s) = span (f '' s) := by
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f✝ : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
f : F
s : Set R
⊢ map f (span s) = span (⇑f '' s)

Next tactic:
refine (Submodule.span_eq_of_le _ ?_ ?_).symm
theorem map_span (f : F) (s : Set R) : map f (span s) = span (f '' s) := by
  refine (Submodule.span_eq_of_le _ ?_ ?_).symm
  · 

Proof state:
case refine_1
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f✝ : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
f : F
s : Set R
⊢ ⇑f '' s ⊆ ↑(map f (span s))

Next tactic:
rintro _ ⟨x, hx, rfl⟩
theorem map_span (f : F) (s : Set R) : map f (span s) = span (f '' s) := by
  refine (Submodule.span_eq_of_le _ ?_ ?_).symm
  · rintro _ ⟨x, hx, rfl⟩; 

Proof state:
case refine_1.intro.intro
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f✝ : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
f : F
s : Set R
x : R
hx : x ∈ s
⊢ f x ∈ ↑(map f (span s))

Next tactic:
exact mem_map_of_mem f (subset_span hx)
theorem map_span (f : F) (s : Set R) : map f (span s) = span (f '' s) := by
  refine (Submodule.span_eq_of_le _ ?_ ?_).symm
  · rintro _ ⟨x, hx, rfl⟩; exact mem_map_of_mem f (subset_span hx)
  · 

Proof state:
case refine_2
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f✝ : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
f : F
s : Set R
⊢ map f (span s) ≤ Submodule.span S (⇑f '' s)

Next tactic:
rw [map_le_iff_le_comap, span_le, coe_comap, ← Set.image_subset_iff]
theorem map_span (f : F) (s : Set R) : map f (span s) = span (f '' s) := by
  refine (Submodule.span_eq_of_le _ ?_ ?_).symm
  · rintro _ ⟨x, hx, rfl⟩; exact mem_map_of_mem f (subset_span hx)
  · rw [map_le_iff_le_comap, span_le, coe_comap, ← Set.image_subset_iff]
    

Proof state:
case refine_2
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f✝ : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
f : F
s : Set R
⊢ ⇑f '' s ⊆ ↑(Submodule.span S (⇑f '' s))

Next tactic:
exact subset_span
@[simp]
theorem comap_eq_top_iff {I : Ideal S} : I.comap f = ⊤ ↔ I = ⊤ :=
  ⟨fun h => I.eq_top_iff_one.mpr (map_one f ▸ mem_comap.mp ((I.comap f).eq_top_iff_one.mp h)),
    fun h => by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I✝ J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
I : Ideal S
h : I = ⊤
⊢ comap f I = ⊤

Next tactic:
rw [h, comap_top]
theorem comap_sInf' (s : Set (Ideal S)) : (sInf s).comap f = ⨅ I ∈ comap f '' s, I :=
  _root_.trans (comap_sInf f s) (by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
ι : Sort u_3
s : Set (Ideal S)
⊢ ⨅ I ∈ s, comap f I = ⨅ I ∈ comap f '' s, I

Next tactic:
rw [iInf_image]
theorem comap_isPrime [H : IsPrime K] : IsPrime (comap f K) :=
  ⟨comap_ne_top f H.ne_top, fun {x y} h => H.mem_or_mem <| by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : Semiring R
inst✝ : Semiring S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
G : Type u_2
rcg : RingHomClass G S R
ι : Sort u_3
H : IsPrime K
x y : R
h : x * y ∈ comap f K
⊢ f x * f y ∈ K

Next tactic:
rwa [mem_comap, map_mul] at h
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  

Proof state:
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
⊢ I • ⊤ = Submodule.restrictScalars R (map (algebraMap R S) I)

Next tactic:
refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
  · 

Proof state:
case refine'_1
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
r : R
hr : r ∈ I
y : S
x✝ : y ∈ ⊤
⊢ r • y ∈ Submodule.restrictScalars R (map (algebraMap R S) I)

Next tactic:
rw [Algebra.smul_def]
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
  · rw [Algebra.smul_def]
    

Proof state:
case refine'_1
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
r : R
hr : r ∈ I
y : S
x✝ : y ∈ ⊤
⊢ (algebraMap R S) r * y ∈ Submodule.restrictScalars R (map (algebraMap R S) I)

Next tactic:
exact mul_mem_right _ _ (mem_map_of_mem _ hr)
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
  · rw [Algebra.smul_def]
    exact mul_mem_right _ _ (mem_map_of_mem _ hr)
  · 

Proof state:
case refine'_2
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
x : S
hx : x ∈ Submodule.restrictScalars R (map (algebraMap R S) I)
⊢ ∀ x ∈ ⇑(algebraMap R S) '' ↑I, x ∈ I • ⊤

Next tactic:
rintro _ ⟨x, hx, rfl⟩
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
  · rw [Algebra.smul_def]
    exact mul_mem_right _ _ (mem_map_of_mem _ hr)
  · rintro _ ⟨x, hx, rfl⟩
    

Proof state:
case refine'_2.intro.intro
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
x✝ : S
hx✝ : x✝ ∈ Submodule.restrictScalars R (map (algebraMap R S) I)
x : R
hx : x ∈ ↑I
⊢ (algebraMap R S) x ∈ I • ⊤

Next tactic:
rw [← mul_one (algebraMap R S x), ← Algebra.smul_def]
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
  · rw [Algebra.smul_def]
    exact mul_mem_right _ _ (mem_map_of_mem _ hr)
  · rintro _ ⟨x, hx, rfl⟩
    rw [← mul_one (algebraMap R S x), ← Algebra.smul_def]
    

Proof state:
case refine'_2.intro.intro
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
x✝ : S
hx✝ : x✝ ∈ Submodule.restrictScalars R (map (algebraMap R S) I)
x : R
hx : x ∈ ↑I
⊢ x • 1 ∈ I • ⊤

Next tactic:
exact Submodule.smul_mem_smul hx Submodule.mem_top
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
    (I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R := by
  refine'
    le_antisymm (Submodule.smul_le.mpr fun r hr y _ => _) fun x hx =>
      Submodule.span_induction hx _ _ _ _
  · rw [Algebra.smul_def]
    exact mul_mem_right _ _ (mem_map_of_mem _ hr)
  · rintro _ ⟨x, hx, rfl⟩
    rw [← mul_one (algebraMap R S x), ← Algebra.smul_def]
    exact Submodule.smul_mem_smul hx Submodule.mem_top
  · 

Proof state:
case refine'_3
R✝ : Type u
S✝ : Type v
F : Type u_1
inst✝⁴ : Semiring R✝
inst✝³ : Semiring S✝
rc : RingHomClass F R✝ S✝
f : F
I✝ J : Ideal R✝
K L : Ideal S✝
G : Type u_2
rcg : RingHomClass G S✝ R✝
ι : Sort u_3
R : Type u_4
S : Type u_5
inst✝² : CommSemiring R
inst✝¹ : CommSemiring S
inst✝ : Algebra R S
I : Ideal R
x : S
hx : x ∈ Submodule.restrictScalars R (map (algebraMap R S) I)
⊢ 0 ∈ I • ⊤

Next tactic:
exact Submodule.zero_mem _