l3lab/ntp-mathlib huggingface dataset:
theorem mem_span_singleton_sup {S : Type*} [CommSemiring S] {x y : S} {I : Ideal S} :
    x ∈ Ideal.span {y} ⊔ I ↔ ∃ a : S, ∃ b ∈ I, a * y + b = x := by
  rw [Submodule.mem_sup]
  constructor
  · 

Proof state:
case mp
α : Type u
β : Type v
inst✝¹ : Semiring α
I✝ : Ideal α
a b : α
S : Type u_1
inst✝ : CommSemiring S
x y : S
I : Ideal S
⊢ (∃ y_1 ∈ span {y}, ∃ z ∈ I, y_1 + z = x) → ∃ a, ∃ b ∈ I, a * y + b = x

Next tactic:
rintro ⟨ya, hya, b, hb, rfl⟩
theorem mem_span_singleton_sup {S : Type*} [CommSemiring S] {x y : S} {I : Ideal S} :
    x ∈ Ideal.span {y} ⊔ I ↔ ∃ a : S, ∃ b ∈ I, a * y + b = x := by
  rw [Submodule.mem_sup]
  constructor
  · rintro ⟨ya, hya, b, hb, rfl⟩
    

Proof state:
case mp.intro.intro.intro.intro
α : Type u
β : Type v
inst✝¹ : Semiring α
I✝ : Ideal α
a b✝ : α
S : Type u_1
inst✝ : CommSemiring S
y : S
I : Ideal S
ya : S
hya : ya ∈ span {y}
b : S
hb : b ∈ I
⊢ ∃ a, ∃ b_1 ∈ I, a * y + b_1 = ya + b

Next tactic:
obtain ⟨a, rfl⟩ := mem_span_singleton'.mp hya
theorem mem_span_singleton_sup {S : Type*} [CommSemiring S] {x y : S} {I : Ideal S} :
    x ∈ Ideal.span {y} ⊔ I ↔ ∃ a : S, ∃ b ∈ I, a * y + b = x := by
  rw [Submodule.mem_sup]
  constructor
  · rintro ⟨ya, hya, b, hb, rfl⟩
    obtain ⟨a, rfl⟩ := mem_span_singleton'.mp hya
    

Proof state:
case mp.intro.intro.intro.intro.intro
α : Type u
β : Type v
inst✝¹ : Semiring α
I✝ : Ideal α
a✝ b✝ : α
S : Type u_1
inst✝ : CommSemiring S
y : S
I : Ideal S
b : S
hb : b ∈ I
a : S
hya : a * y ∈ span {y}
⊢ ∃ a_1, ∃ b_1 ∈ I, a_1 * y + b_1 = a * y + b

Next tactic:
exact ⟨a, b, hb, rfl⟩
theorem mem_span_singleton_sup {S : Type*} [CommSemiring S] {x y : S} {I : Ideal S} :
    x ∈ Ideal.span {y} ⊔ I ↔ ∃ a : S, ∃ b ∈ I, a * y + b = x := by
  rw [Submodule.mem_sup]
  constructor
  · rintro ⟨ya, hya, b, hb, rfl⟩
    obtain ⟨a, rfl⟩ := mem_span_singleton'.mp hya
    exact ⟨a, b, hb, rfl⟩
  · 

Proof state:
case mpr
α : Type u
β : Type v
inst✝¹ : Semiring α
I✝ : Ideal α
a b : α
S : Type u_1
inst✝ : CommSemiring S
x y : S
I : Ideal S
⊢ (∃ a, ∃ b ∈ I, a * y + b = x) → ∃ y_1 ∈ span {y}, ∃ z ∈ I, y_1 + z = x

Next tactic:
rintro ⟨a, b, hb, rfl⟩
theorem mem_span_singleton_sup {S : Type*} [CommSemiring S] {x y : S} {I : Ideal S} :
    x ∈ Ideal.span {y} ⊔ I ↔ ∃ a : S, ∃ b ∈ I, a * y + b = x := by
  rw [Submodule.mem_sup]
  constructor
  · rintro ⟨ya, hya, b, hb, rfl⟩
    obtain ⟨a, rfl⟩ := mem_span_singleton'.mp hya
    exact ⟨a, b, hb, rfl⟩
  · rintro ⟨a, b, hb, rfl⟩
    

Proof state:
case mpr.intro.intro.intro
α : Type u
β : Type v
inst✝¹ : Semiring α
I✝ : Ideal α
a✝ b✝ : α
S : Type u_1
inst✝ : CommSemiring S
y : S
I : Ideal S
a b : S
hb : b ∈ I
⊢ ∃ y_1 ∈ span {y}, ∃ z ∈ I, y_1 + z = a * y + b

Next tactic:
exact ⟨a * y, Ideal.mem_span_singleton'.mpr ⟨a, rfl⟩, b, hb, rfl⟩
theorem IsPrime.mem_of_pow_mem {I : Ideal α} (hI : I.IsPrime) {r : α} (n : ℕ) (H : r ^ n ∈ I) :
    r ∈ I := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsPrime I
r : α
n : ℕ
H : r ^ n ∈ I
⊢ r ∈ I

Next tactic:
induction' n with n ih
theorem IsPrime.mem_of_pow_mem {I : Ideal α} (hI : I.IsPrime) {r : α} (n : ℕ) (H : r ^ n ∈ I) :
    r ∈ I := by
  induction' n with n ih
  · 

Proof state:
case zero
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsPrime I
r : α
H : r ^ Nat.zero ∈ I
⊢ r ∈ I

Next tactic:
rw [pow_zero] at H
theorem IsPrime.mem_of_pow_mem {I : Ideal α} (hI : I.IsPrime) {r : α} (n : ℕ) (H : r ^ n ∈ I) :
    r ∈ I := by
  induction' n with n ih
  · rw [pow_zero] at H
    

Proof state:
case zero
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsPrime I
r : α
H : 1 ∈ I
⊢ r ∈ I

Next tactic:
exact (mt (eq_top_iff_one _).2 hI.1).elim H
theorem IsPrime.mem_of_pow_mem {I : Ideal α} (hI : I.IsPrime) {r : α} (n : ℕ) (H : r ^ n ∈ I) :
    r ∈ I := by
  induction' n with n ih
  · rw [pow_zero] at H
    exact (mt (eq_top_iff_one _).2 hI.1).elim H
  · 

Proof state:
case succ
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsPrime I
r : α
n : ℕ
ih : r ^ n ∈ I → r ∈ I
H : r ^ Nat.succ n ∈ I
⊢ r ∈ I

Next tactic:
rw [pow_succ] at H
theorem IsPrime.mem_of_pow_mem {I : Ideal α} (hI : I.IsPrime) {r : α} (n : ℕ) (H : r ^ n ∈ I) :
    r ∈ I := by
  induction' n with n ih
  · rw [pow_zero] at H
    exact (mt (eq_top_iff_one _).2 hI.1).elim H
  · rw [pow_succ] at H
    

Proof state:
case succ
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsPrime I
r : α
n : ℕ
ih : r ^ n ∈ I → r ∈ I
H : r * r ^ n ∈ I
⊢ r ∈ I

Next tactic:
exact Or.casesOn (hI.mem_or_mem H) id ih
theorem not_isPrime_iff {I : Ideal α} :
    ¬I.IsPrime ↔ I = ⊤ ∨ ∃ (x : α) (_hx : x ∉ I) (y : α) (_hy : y ∉ I), x * y ∈ I := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
⊢ ¬IsPrime I ↔ I = ⊤ ∨ ∃ x, ∃ (_ : x ∉ I), ∃ y, ∃ (_ : y ∉ I), x * y ∈ I

Next tactic:
simp_rw [Ideal.isPrime_iff, not_and_or, Ne.def, Classical.not_not, not_forall, not_or]
theorem not_isPrime_iff {I : Ideal α} :
    ¬I.IsPrime ↔ I = ⊤ ∨ ∃ (x : α) (_hx : x ∉ I) (y : α) (_hy : y ∉ I), x * y ∈ I := by
  simp_rw [Ideal.isPrime_iff, not_and_or, Ne.def, Classical.not_not, not_forall, not_or]
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
⊢ (I = ⊤ ∨ ∃ x x_1, ∃ (_ : x * x_1 ∈ I), x ∉ I ∧ x_1 ∉ I) ↔ I = ⊤ ∨ ∃ x, ∃ (_ : x ∉ I), ∃ y, ∃ (_ : y ∉ I), x * y ∈ I

Next tactic:
exact
    or_congr Iff.rfl
      ⟨fun ⟨x, y, hxy, hx, hy⟩ => ⟨x, hx, y, hy, hxy⟩, fun ⟨x, hx, y, hy, hxy⟩ =>
        ⟨x, y, hxy, hx, hy⟩⟩
theorem bot_prime [IsDomain α] : (⊥ : Ideal α).IsPrime :=
  ⟨fun h => one_ne_zero (by 

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
inst✝ : IsDomain α
h : ⊥ = ⊤
⊢ 1 = 0

Next tactic:
rwa [Ideal.eq_top_iff_one, Submodule.mem_bot] at h
theorem bot_prime [IsDomain α] : (⊥ : Ideal α).IsPrime :=
  ⟨fun h => one_ne_zero (by rwa [Ideal.eq_top_iff_one, Submodule.mem_bot] at h), fun h =>
    mul_eq_zero.mp (by 

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
inst✝ : IsDomain α
x✝ y✝ : α
h : x✝ * y✝ ∈ ⊥
⊢ x✝ * y✝ = 0

Next tactic:
simpa only [Submodule.mem_bot] using h
theorem isMaximal_iff {I : Ideal α} :
    I.IsMaximal ↔ (1 : α) ∉ I ∧ ∀ (J : Ideal α) (x), I ≤ J → x ∉ I → x ∈ J → (1 : α) ∈ J :=
  isMaximal_def.trans <|
    and_congr I.ne_top_iff_one <|
      forall_congr' fun J => by
        

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I J : Ideal α
⊢ I < J → J = ⊤ ↔ ∀ (x : α), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J

Next tactic:
rw [lt_iff_le_not_le]
theorem isMaximal_iff {I : Ideal α} :
    I.IsMaximal ↔ (1 : α) ∉ I ∧ ∀ (J : Ideal α) (x), I ≤ J → x ∉ I → x ∈ J → (1 : α) ∈ J :=
  isMaximal_def.trans <|
    and_congr I.ne_top_iff_one <|
      forall_congr' fun J => by
        rw [lt_iff_le_not_le];
          

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I J : Ideal α
⊢ I ≤ J ∧ ¬J ≤ I → J = ⊤ ↔ ∀ (x : α), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J

Next tactic:
exact
            ⟨fun H x h hx₁ hx₂ => J.eq_top_iff_one.1 <| H ⟨h, not_subset.2 ⟨_, hx₂, hx₁⟩⟩,
              fun H ⟨h₁, h₂⟩ =>
              let ⟨x, xJ, xI⟩ := not_subset.1 h₂
              J.eq_top_iff_one.2 <| H x h₁ xI xJ⟩
instance : IsCoatomic (Ideal α) := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
⊢ IsCoatomic (Ideal α)

Next tactic:
apply CompleteLattice.coatomic_of_top_compact
instance : IsCoatomic (Ideal α) := by
  apply CompleteLattice.coatomic_of_top_compact
  

Proof state:
case h
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
⊢ CompleteLattice.IsCompactElement ⊤

Next tactic:
rw [← span_singleton_one]
instance : IsCoatomic (Ideal α) := by
  apply CompleteLattice.coatomic_of_top_compact
  rw [← span_singleton_one]
  

Proof state:
case h
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
⊢ CompleteLattice.IsCompactElement (span {1})

Next tactic:
exact Submodule.singleton_span_isCompactElement 1
theorem IsMaximal.coprime_of_ne {M M' : Ideal α} (hM : M.IsMaximal) (hM' : M'.IsMaximal)
    (hne : M ≠ M') : M ⊔ M' = ⊤ := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
M M' : Ideal α
hM : IsMaximal M
hM' : IsMaximal M'
hne : M ≠ M'
⊢ M ⊔ M' = ⊤

Next tactic:
contrapose! hne with h
theorem IsMaximal.coprime_of_ne {M M' : Ideal α} (hM : M.IsMaximal) (hM' : M'.IsMaximal)
    (hne : M ≠ M') : M ⊔ M' = ⊤ := by
  contrapose! hne with h
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
M M' : Ideal α
hM : IsMaximal M
hM' : IsMaximal M'
h : M ⊔ M' ≠ ⊤
⊢ M = M'

Next tactic:
exact hM.eq_of_le hM'.ne_top (le_sup_left.trans_eq (hM'.eq_of_le h le_sup_right).symm)
instance [Nontrivial α] : Nontrivial (Ideal α) := by
  

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
inst✝ : Nontrivial α
⊢ Nontrivial (Ideal α)

Next tactic:
rcases@exists_maximal α _ _ with ⟨M, hM, _⟩
instance [Nontrivial α] : Nontrivial (Ideal α) := by
  rcases@exists_maximal α _ _ with ⟨M, hM, _⟩
  

Proof state:
case intro.mk.intro
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
inst✝ : Nontrivial α
M : Ideal α
hM : M ≠ ⊤
right✝ : ∀ (b : Ideal α), M < b → b = ⊤
⊢ Nontrivial (Ideal α)

Next tactic:
exact nontrivial_of_ne M ⊤ hM
/-- If P is not properly contained in any maximal ideal then it is not properly contained
  in any proper ideal -/
theorem maximal_of_no_maximal {P : Ideal α}
    (hmax : ∀ m : Ideal α, P < m → ¬IsMaximal m) (J : Ideal α) (hPJ : P < J) : J = ⊤ := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
P : Ideal α
hmax : ∀ (m : Ideal α), P < m → ¬IsMaximal m
J : Ideal α
hPJ : P < J
⊢ J = ⊤

Next tactic:
by_contra hnonmax
/-- If P is not properly contained in any maximal ideal then it is not properly contained
  in any proper ideal -/
theorem maximal_of_no_maximal {P : Ideal α}
    (hmax : ∀ m : Ideal α, P < m → ¬IsMaximal m) (J : Ideal α) (hPJ : P < J) : J = ⊤ := by
  by_contra hnonmax
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
P : Ideal α
hmax : ∀ (m : Ideal α), P < m → ¬IsMaximal m
J : Ideal α
hPJ : P < J
hnonmax : ¬J = ⊤
⊢ False

Next tactic:
rcases exists_le_maximal J hnonmax with ⟨M, hM1, hM2⟩
/-- If P is not properly contained in any maximal ideal then it is not properly contained
  in any proper ideal -/
theorem maximal_of_no_maximal {P : Ideal α}
    (hmax : ∀ m : Ideal α, P < m → ¬IsMaximal m) (J : Ideal α) (hPJ : P < J) : J = ⊤ := by
  by_contra hnonmax
  rcases exists_le_maximal J hnonmax with ⟨M, hM1, hM2⟩
  

Proof state:
case intro.intro
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
P : Ideal α
hmax : ∀ (m : Ideal α), P < m → ¬IsMaximal m
J : Ideal α
hPJ : P < J
hnonmax : ¬J = ⊤
M : Ideal α
hM1 : IsMaximal M
hM2 : J ≤ M
⊢ False

Next tactic:
exact hmax M (lt_of_lt_of_le hPJ hM2) hM1
theorem span_pair_comm {x y : α} : (span {x, y} : Ideal α) = span {y, x} := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b x y : α
⊢ span {x, y} = span {y, x}

Next tactic:
simp only [span_insert, sup_comm]
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
R : Type u
inst✝ : CommRing R
x y z : R
⊢ span {x + y * z, y} = span {x, y}

Next tactic:
ext
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  ext
  

Proof state:
case h
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
R : Type u
inst✝ : CommRing R
x y z x✝ : R
⊢ x✝ ∈ span {x + y * z, y} ↔ x✝ ∈ span {x, y}

Next tactic:
rw [mem_span_pair, mem_span_pair]
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  ext
  rw [mem_span_pair, mem_span_pair]
  

Proof state:
case h
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
R : Type u
inst✝ : CommRing R
x y z x✝ : R
⊢ (∃ a b, a * (x + y * z) + b * y = x✝) ↔ ∃ a b, a * x + b * y = x✝

Next tactic:
exact
    ⟨fun ⟨a, b, h⟩ =>
      ⟨a, b + a * z, by
        rw [← h]
        ring1⟩,
      fun ⟨a, b, h⟩ =>
      ⟨a, b - a * z, by
        rw [← h]
        ring1⟩⟩
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  ext
  rw [mem_span_pair, mem_span_pair]
  exact
    ⟨fun ⟨a, b, h⟩ =>
      ⟨a, b + a * z, by
        

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a✝ b✝ : α
R : Type u
inst✝ : CommRing R
x y z x✝¹ : R
x✝ : ∃ a b, a * (x + y * z) + b * y = x✝¹
a b : R
h : a * (x + y * z) + b * y = x✝¹
⊢ a * x + (b + a * z) * y = x✝¹

Next tactic:
rw [← h]
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  ext
  rw [mem_span_pair, mem_span_pair]
  exact
    ⟨fun ⟨a, b, h⟩ =>
      ⟨a, b + a * z, by
        rw [← h]
        

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a✝ b✝ : α
R : Type u
inst✝ : CommRing R
x y z x✝¹ : R
x✝ : ∃ a b, a * (x + y * z) + b * y = x✝¹
a b : R
h : a * (x + y * z) + b * y = x✝¹
⊢ a * x + (b + a * z) * y = a * (x + y * z) + b * y

Next tactic:
ring1
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  ext
  rw [mem_span_pair, mem_span_pair]
  exact
    ⟨fun ⟨a, b, h⟩ =>
      ⟨a, b + a * z, by
        rw [← h]
        ring1⟩,
      fun ⟨a, b, h⟩ =>
      ⟨a, b - a * z, by
        

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a✝ b✝ : α
R : Type u
inst✝ : CommRing R
x y z x✝¹ : R
x✝ : ∃ a b, a * x + b * y = x✝¹
a b : R
h : a * x + b * y = x✝¹
⊢ a * (x + y * z) + (b - a * z) * y = x✝¹

Next tactic:
rw [← h]
@[simp]
theorem span_pair_add_mul_left {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x + y * z, y} : Ideal R) = span {x, y} := by
  ext
  rw [mem_span_pair, mem_span_pair]
  exact
    ⟨fun ⟨a, b, h⟩ =>
      ⟨a, b + a * z, by
        rw [← h]
        ring1⟩,
      fun ⟨a, b, h⟩ =>
      ⟨a, b - a * z, by
        rw [← h]
        

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a✝ b✝ : α
R : Type u
inst✝ : CommRing R
x y z x✝¹ : R
x✝ : ∃ a b, a * x + b * y = x✝¹
a b : R
h : a * x + b * y = x✝¹
⊢ a * (x + y * z) + (b - a * z) * y = a * x + b * y

Next tactic:
ring1
@[simp]
theorem span_pair_add_mul_right {R : Type u} [CommRing R] {x y : R} (z : R) :
    (span {x, y + x * z} : Ideal R) = span {x, y} := by
  

Proof state:
α : Type u
β : Type v
inst✝¹ : Semiring α
I : Ideal α
a b : α
R : Type u
inst✝ : CommRing R
x y z : R
⊢ span {x, y + x * z} = span {x, y}

Next tactic:
rw [span_pair_comm, span_pair_add_mul_left, span_pair_comm]
theorem IsMaximal.exists_inv {I : Ideal α} (hI : I.IsMaximal) {x} (hx : x ∉ I) :
    ∃ y, ∃ i ∈ I, y * x + i = 1 := by
  

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsMaximal I
x : α
hx : x ∉ I
⊢ ∃ y, ∃ i ∈ I, y * x + i = 1

Next tactic:
cases' isMaximal_iff.1 hI with H₁ H₂
theorem IsMaximal.exists_inv {I : Ideal α} (hI : I.IsMaximal) {x} (hx : x ∉ I) :
    ∃ y, ∃ i ∈ I, y * x + i = 1 := by
  cases' isMaximal_iff.1 hI with H₁ H₂
  

Proof state:
case intro
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsMaximal I
x : α
hx : x ∉ I
H₁ : 1 ∉ I
H₂ : ∀ (J : Ideal α) (x : α), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J
⊢ ∃ y, ∃ i ∈ I, y * x + i = 1

Next tactic:
rcases mem_span_insert.1
      (H₂ (span (insert x I)) x (Set.Subset.trans (subset_insert _ _) subset_span) hx
        (subset_span (mem_insert _ _))) with
    ⟨y, z, hz, hy⟩
theorem IsMaximal.exists_inv {I : Ideal α} (hI : I.IsMaximal) {x} (hx : x ∉ I) :
    ∃ y, ∃ i ∈ I, y * x + i = 1 := by
  cases' isMaximal_iff.1 hI with H₁ H₂
  rcases mem_span_insert.1
      (H₂ (span (insert x I)) x (Set.Subset.trans (subset_insert _ _) subset_span) hx
        (subset_span (mem_insert _ _))) with
    ⟨y, z, hz, hy⟩
  

Proof state:
case intro.intro.intro.intro
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsMaximal I
x : α
hx : x ∉ I
H₁ : 1 ∉ I
H₂ : ∀ (J : Ideal α) (x : α), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J
y z : α
hz : z ∈ span ↑I
hy : 1 = y * x + z
⊢ ∃ y, ∃ i ∈ I, y * x + i = 1

Next tactic:
refine' ⟨y, z, _, hy.symm⟩
theorem IsMaximal.exists_inv {I : Ideal α} (hI : I.IsMaximal) {x} (hx : x ∉ I) :
    ∃ y, ∃ i ∈ I, y * x + i = 1 := by
  cases' isMaximal_iff.1 hI with H₁ H₂
  rcases mem_span_insert.1
      (H₂ (span (insert x I)) x (Set.Subset.trans (subset_insert _ _) subset_span) hx
        (subset_span (mem_insert _ _))) with
    ⟨y, z, hz, hy⟩
  refine' ⟨y, z, _, hy.symm⟩
  

Proof state:
case intro.intro.intro.intro
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
I : Ideal α
hI : IsMaximal I
x : α
hx : x ∉ I
H₁ : 1 ∉ I
H₂ : ∀ (J : Ideal α) (x : α), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J
y z : α
hz : z ∈ span ↑I
hy : 1 = y * x + z
⊢ z ∈ I

Next tactic:
rwa [← span_eq I]
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : x✝ * y✝ ∈ sInf s
hx : x✝ ∉ sInf s
⊢ y✝ ∈ sInf s

Next tactic:
rw [Ideal.mem_sInf] at hx e ⊢
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      rw [Ideal.mem_sInf] at hx e ⊢
      

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : ∀ ⦃I : Ideal α⦄, I ∈ s → x✝ * y✝ ∈ I
hx : ¬∀ ⦃I : Ideal α⦄, I ∈ s → x✝ ∈ I
⊢ ∀ ⦃I : Ideal α⦄, I ∈ s → y✝ ∈ I

Next tactic:
push_neg at hx
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      rw [Ideal.mem_sInf] at hx e ⊢
      push_neg at hx
      

Proof state:
α : Type u
β : Type v
inst✝ : Semiring α
I : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : ∀ ⦃I : Ideal α⦄, I ∈ s → x✝ * y✝ ∈ I
hx : ∃ I ∈ s, x✝ ∉ I
⊢ ∀ ⦃I : Ideal α⦄, I ∈ s → y✝ ∈ I

Next tactic:
obtain ⟨I, hI, hI'⟩ := hx
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      rw [Ideal.mem_sInf] at hx e ⊢
      push_neg at hx
      obtain ⟨I, hI, hI'⟩ := hx
      

Proof state:
case intro.intro
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : ∀ ⦃I : Ideal α⦄, I ∈ s → x✝ * y✝ ∈ I
I : Ideal α
hI : I ∈ s
hI' : x✝ ∉ I
⊢ ∀ ⦃I : Ideal α⦄, I ∈ s → y✝ ∈ I

Next tactic:
intro J hJ
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      rw [Ideal.mem_sInf] at hx e ⊢
      push_neg at hx
      obtain ⟨I, hI, hI'⟩ := hx
      intro J hJ
      

Proof state:
case intro.intro
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : ∀ ⦃I : Ideal α⦄, I ∈ s → x✝ * y✝ ∈ I
I : Ideal α
hI : I ∈ s
hI' : x✝ ∉ I
J : Ideal α
hJ : J ∈ s
⊢ y✝ ∈ J

Next tactic:
cases' hs'.total hI hJ with h h
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      rw [Ideal.mem_sInf] at hx e ⊢
      push_neg at hx
      obtain ⟨I, hI, hI'⟩ := hx
      intro J hJ
      cases' hs'.total hI hJ with h h
      · 

Proof state:
case intro.intro.inl
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : ∀ ⦃I : Ideal α⦄, I ∈ s → x✝ * y✝ ∈ I
I : Ideal α
hI : I ∈ s
hI' : x✝ ∉ I
J : Ideal α
hJ : J ∈ s
h : I ≤ J
⊢ y✝ ∈ J

Next tactic:
exact h (((H I hI).mem_or_mem (e hI)).resolve_left hI')
theorem sInf_isPrime_of_isChain {s : Set (Ideal α)} (hs : s.Nonempty) (hs' : IsChain (· ≤ ·) s)
    (H : ∀ p ∈ s, Ideal.IsPrime p) : (sInf s).IsPrime :=
  ⟨fun e =>
    let ⟨x, hx⟩ := hs
    (H x hx).ne_top (eq_top_iff.mpr (e.symm.trans_le (sInf_le hx))),
    fun e =>
    or_iff_not_imp_left.mpr fun hx => by
      rw [Ideal.mem_sInf] at hx e ⊢
      push_neg at hx
      obtain ⟨I, hI, hI'⟩ := hx
      intro J hJ
      cases' hs'.total hI hJ with h h
      · exact h (((H I hI).mem_or_mem (e hI)).resolve_left hI')
      · 

Proof state:
case intro.intro.inr
α : Type u
β : Type v
inst✝ : Semiring α
I✝ : Ideal α
a b : α
s : Set (Ideal α)
hs : Set.Nonempty s
hs' : IsChain (fun x x_1 => x ≤ x_1) s
H : ∀ p ∈ s, IsPrime p
x✝ y✝ : α
e : ∀ ⦃I : Ideal α⦄, I ∈ s → x✝ * y✝ ∈ I
I : Ideal α
hI : I ∈ s
hI' : x✝ ∉ I
J : Ideal α
hJ : J ∈ s
h : J ≤ I
⊢ y✝ ∈ J

Next tactic:
exact ((H J hJ).mem_or_mem (e hJ)).resolve_left fun x => hI' <| h x
theorem mem_span_singleton {x y : α} : x ∈ span ({y} : Set α) ↔ y ∣ x :=
  mem_span_singleton'.trans <| exists_congr fun _ => by 

Proof state:
α : Type u
β : Type v
a b : α
inst✝ : CommSemiring α
I : Ideal α
x y x✝ : α
⊢ x✝ * y = x ↔ x = y * x✝

Next tactic:
rw [eq_comm, mul_comm]
theorem span_singleton_eq_span_singleton {α : Type u} [CommRing α] [IsDomain α] {x y : α} :
    span ({x} : Set α) = span ({y} : Set α) ↔ Associated x y := by
  

Proof state:
α✝ : Type u
β : Type v
a b : α✝
inst✝² : CommSemiring α✝
I : Ideal α✝
α : Type u
inst✝¹ : CommRing α
inst✝ : IsDomain α
x y : α
⊢ span {x} = span {y} ↔ Associated x y

Next tactic:
rw [← dvd_dvd_iff_associated, le_antisymm_iff, and_comm]
theorem span_singleton_eq_span_singleton {α : Type u} [CommRing α] [IsDomain α] {x y : α} :
    span ({x} : Set α) = span ({y} : Set α) ↔ Associated x y := by
  rw [← dvd_dvd_iff_associated, le_antisymm_iff, and_comm]
  

Proof state:
α✝ : Type u
β : Type v
a b : α✝
inst✝² : CommSemiring α✝
I : Ideal α✝
α : Type u
inst✝¹ : CommRing α
inst✝ : IsDomain α
x y : α
⊢ span {y} ≤ span {x} ∧ span {x} ≤ span {y} ↔ x ∣ y ∧ y ∣ x

Next tactic:
apply and_congr
theorem span_singleton_eq_span_singleton {α : Type u} [CommRing α] [IsDomain α] {x y : α} :
    span ({x} : Set α) = span ({y} : Set α) ↔ Associated x y := by
  rw [← dvd_dvd_iff_associated, le_antisymm_iff, and_comm]
  apply and_congr <;> 

Proof state:
case h₁
α✝ : Type u
β : Type v
a b : α✝
inst✝² : CommSemiring α✝
I : Ideal α✝
α : Type u
inst✝¹ : CommRing α
inst✝ : IsDomain α
x y : α
⊢ span {y} ≤ span {x} ↔ x ∣ y

Next tactic:
rw [span_singleton_le_span_singleton]