l3lab/ntp-mathlib huggingface dataset:
variable (K) in
/-- A bijection between between (left) ideals of a division ring and `{0, 1}`, sending `⊥` to `0`
and `⊤` to `1`. -/
def equivFinTwo [DecidableEq (Ideal K)] : Ideal K ≃ Fin 2 where
  toFun := fun I ↦ if I = ⊥ then 0 else 1
  invFun := ![⊥, ⊤]
  left_inv := fun I ↦ by rcases eq_bot_or_top I with rfl | rfl <;> simp
  right_inv := fun i ↦ by 

Proof state:
α : Type u
β : Type v
K : Type u
inst✝¹ : DivisionSemiring K
I : Ideal K
inst✝ : DecidableEq (Ideal K)
i : Fin 2
⊢ (fun I => if I = ⊥ then 0 else 1) (Matrix.vecCons ⊥ ![⊤] i) = i

Next tactic:
fin_cases i
variable (K) in
/-- A bijection between between (left) ideals of a division ring and `{0, 1}`, sending `⊥` to `0`
and `⊤` to `1`. -/
def equivFinTwo [DecidableEq (Ideal K)] : Ideal K ≃ Fin 2 where
  toFun := fun I ↦ if I = ⊥ then 0 else 1
  invFun := ![⊥, ⊤]
  left_inv := fun I ↦ by rcases eq_bot_or_top I with rfl | rfl <;> simp
  right_inv := fun i ↦ by fin_cases i <;> 

Proof state:
case head
α : Type u
β : Type v
K : Type u
inst✝¹ : DivisionSemiring K
I : Ideal K
inst✝ : DecidableEq (Ideal K)
⊢ (fun I => if I = ⊥ then 0 else 1) (Matrix.vecCons ⊥ ![⊤] { val := 0, isLt := (_ : 0 < 2) }) =
    { val := 0, isLt := (_ : 0 < 2) }

Next tactic:
simp
variable (K) in
/-- A bijection between between (left) ideals of a division ring and `{0, 1}`, sending `⊥` to `0`
and `⊤` to `1`. -/
def equivFinTwo [DecidableEq (Ideal K)] : Ideal K ≃ Fin 2 where
  toFun := fun I ↦ if I = ⊥ then 0 else 1
  invFun := ![⊥, ⊤]
  left_inv := fun I ↦ by rcases eq_bot_or_top I with rfl | rfl <;> simp
  right_inv := fun i ↦ by fin_cases i <;> 

Proof state:
case tail.head
α : Type u
β : Type v
K : Type u
inst✝¹ : DivisionSemiring K
I : Ideal K
inst✝ : DecidableEq (Ideal K)
⊢ (fun I => if I = ⊥ then 0 else 1) (Matrix.vecCons ⊥ ![⊤] { val := 1, isLt := (_ : (fun a => a < 2) 1) }) =
    { val := 1, isLt := (_ : (fun a => a < 2) 1) }

Next tactic:
simp
theorem bot_isMaximal : IsMaximal (⊥ : Ideal K) :=
  ⟨⟨fun h => absurd ((eq_top_iff_one (⊤ : Ideal K)).mp rfl) (by 

Proof state:
α : Type u
β : Type v
K : Type u
inst✝ : DivisionSemiring K
I : Ideal K
h : ⊥ = ⊤
⊢ 1 ∉ ⊤

Next tactic:
rw [← h]
theorem bot_isMaximal : IsMaximal (⊥ : Ideal K) :=
  ⟨⟨fun h => absurd ((eq_top_iff_one (⊤ : Ideal K)).mp rfl) (by rw [← h]; 

Proof state:
α : Type u
β : Type v
K : Type u
inst✝ : DivisionSemiring K
I : Ideal K
h : ⊥ = ⊤
⊢ 1 ∉ ⊥

Next tactic:
simp
theorem mul_sub_mul_mem {R : Type*} [CommRing R] (I : Ideal R) {a b c d : R} (h1 : a - b ∈ I)
    (h2 : c - d ∈ I) : a * c - b * d ∈ I := by
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝ : CommRing R
I : Ideal R
a b c d : R
h1 : a - b ∈ I
h2 : c - d ∈ I
⊢ a * c - b * d ∈ I

Next tactic:
rw [show a * c - b * d = (a - b) * c + b * (c - d) by rw [sub_mul, mul_sub]; abel]
theorem mul_sub_mul_mem {R : Type*} [CommRing R] (I : Ideal R) {a b c d : R} (h1 : a - b ∈ I)
    (h2 : c - d ∈ I) : a * c - b * d ∈ I := by
  rw [show a * c - b * d = (a - b) * c + b * (c - d) by 

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝ : CommRing R
I : Ideal R
a b c d : R
h1 : a - b ∈ I
h2 : c - d ∈ I
⊢ a * c - b * d = (a - b) * c + b * (c - d)

Next tactic:
rw [sub_mul, mul_sub]
theorem mul_sub_mul_mem {R : Type*} [CommRing R] (I : Ideal R) {a b c d : R} (h1 : a - b ∈ I)
    (h2 : c - d ∈ I) : a * c - b * d ∈ I := by
  rw [show a * c - b * d = (a - b) * c + b * (c - d) by rw [sub_mul, mul_sub]; 

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝ : CommRing R
I : Ideal R
a b c d : R
h1 : a - b ∈ I
h2 : c - d ∈ I
⊢ a * c - b * d = a * c - b * c + (b * c - b * d)

Next tactic:
abel
theorem mul_sub_mul_mem {R : Type*} [CommRing R] (I : Ideal R) {a b c d : R} (h1 : a - b ∈ I)
    (h2 : c - d ∈ I) : a * c - b * d ∈ I := by
  rw [show a * c - b * d = (a - b) * c + b * (c - d) by rw [sub_mul, mul_sub]; abel]
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝ : CommRing R
I : Ideal R
a b c d : R
h1 : a - b ∈ I
h2 : c - d ∈ I
⊢ (a - b) * c + b * (c - d) ∈ I

Next tactic:
exact I.add_mem (I.mul_mem_right _ h1) (I.mul_mem_left _ h2)
theorem exists_not_isUnit_of_not_isField [Nontrivial R] (hf : ¬IsField R) :
    ∃ (x : R) (_hx : x ≠ (0 : R)), ¬IsUnit x := by
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
hf : ¬IsField R
⊢ ∃ x, ∃ (_ : x ≠ 0), ¬IsUnit x

Next tactic:
have : ¬_ := fun h => hf ⟨exists_pair_ne R, mul_comm, h⟩
theorem exists_not_isUnit_of_not_isField [Nontrivial R] (hf : ¬IsField R) :
    ∃ (x : R) (_hx : x ≠ (0 : R)), ¬IsUnit x := by
  have : ¬_ := fun h => hf ⟨exists_pair_ne R, mul_comm, h⟩
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
hf : ¬IsField R
this : ¬∀ {a : R}, a ≠ 0 → ∃ b, a * b = 1
⊢ ∃ x, ∃ (_ : x ≠ 0), ¬IsUnit x

Next tactic:
simp_rw [isUnit_iff_exists_inv]
theorem exists_not_isUnit_of_not_isField [Nontrivial R] (hf : ¬IsField R) :
    ∃ (x : R) (_hx : x ≠ (0 : R)), ¬IsUnit x := by
  have : ¬_ := fun h => hf ⟨exists_pair_ne R, mul_comm, h⟩
  simp_rw [isUnit_iff_exists_inv]
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
hf : ¬IsField R
this : ¬∀ {a : R}, a ≠ 0 → ∃ b, a * b = 1
⊢ ∃ x, ∃ (_ : x ≠ 0), ¬∃ b, x * b = 1

Next tactic:
push_neg at this ⊢
theorem exists_not_isUnit_of_not_isField [Nontrivial R] (hf : ¬IsField R) :
    ∃ (x : R) (_hx : x ≠ (0 : R)), ¬IsUnit x := by
  have : ¬_ := fun h => hf ⟨exists_pair_ne R, mul_comm, h⟩
  simp_rw [isUnit_iff_exists_inv]
  push_neg at this ⊢
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
hf : ¬IsField R
this : ∃ a, a ≠ 0 ∧ ∀ (b : R), a * b ≠ 1
⊢ ∃ x, ∃ (_ : x ≠ 0), ∀ (b : R), x * b ≠ 1

Next tactic:
obtain ⟨x, hx, not_unit⟩ := this
theorem exists_not_isUnit_of_not_isField [Nontrivial R] (hf : ¬IsField R) :
    ∃ (x : R) (_hx : x ≠ (0 : R)), ¬IsUnit x := by
  have : ¬_ := fun h => hf ⟨exists_pair_ne R, mul_comm, h⟩
  simp_rw [isUnit_iff_exists_inv]
  push_neg at this ⊢
  obtain ⟨x, hx, not_unit⟩ := this
  

Proof state:
case intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
hf : ¬IsField R
x : R
hx : x ≠ 0
not_unit : ∀ (b : R), x * b ≠ 1
⊢ ∃ x, ∃ (_ : x ≠ 0), ∀ (b : R), x * b ≠ 1

Next tactic:
exact ⟨x, hx, not_unit⟩
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
⊢ ¬IsField R ↔ ∃ I, ⊥ < I ∧ I < ⊤

Next tactic:
constructor
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · 

Proof state:
case mp
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
⊢ ¬IsField R → ∃ I, ⊥ < I ∧ I < ⊤

Next tactic:
intro h
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    

Proof state:
case mp
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
h : ¬IsField R
⊢ ∃ I, ⊥ < I ∧ I < ⊤

Next tactic:
obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    

Proof state:
case mp.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
h : ¬IsField R
x : R
nz : x ≠ 0
nu : ¬IsUnit x
⊢ ∃ I, ⊥ < I ∧ I < ⊤

Next tactic:
use Ideal.span {x}
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    

Proof state:
case h
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
h : ¬IsField R
x : R
nz : x ≠ 0
nu : ¬IsUnit x
⊢ ⊥ < Ideal.span {x} ∧ Ideal.span {x} < ⊤

Next tactic:
rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    

Proof state:
case h
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
h : ¬IsField R
x : R
nz : x ≠ 0
nu : ¬IsUnit x
⊢ Ideal.span {x} ≠ ⊥ ∧ Ideal.span {x} ≠ ⊤

Next tactic:
exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
  · 

Proof state:
case mpr
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
⊢ (∃ I, ⊥ < I ∧ I < ⊤) → ¬IsField R

Next tactic:
rintro ⟨I, bot_lt, lt_top⟩ hf
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
  · rintro ⟨I, bot_lt, lt_top⟩ hf
    

Proof state:
case mpr.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
I : Ideal R
bot_lt : ⊥ < I
lt_top : I < ⊤
hf : IsField R
⊢ False

Next tactic:
obtain ⟨x, mem, ne_zero⟩ := SetLike.exists_of_lt bot_lt
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
  · rintro ⟨I, bot_lt, lt_top⟩ hf
    obtain ⟨x, mem, ne_zero⟩ := SetLike.exists_of_lt bot_lt
    

Proof state:
case mpr.intro.intro.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
I : Ideal R
bot_lt : ⊥ < I
lt_top : I < ⊤
hf : IsField R
x : R
mem : x ∈ I
ne_zero : x ∉ ⊥
⊢ False

Next tactic:
rw [Submodule.mem_bot] at ne_zero
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
  · rintro ⟨I, bot_lt, lt_top⟩ hf
    obtain ⟨x, mem, ne_zero⟩ := SetLike.exists_of_lt bot_lt
    rw [Submodule.mem_bot] at ne_zero
    

Proof state:
case mpr.intro.intro.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
I : Ideal R
bot_lt : ⊥ < I
lt_top : I < ⊤
hf : IsField R
x : R
mem : x ∈ I
ne_zero : ¬x = 0
⊢ False

Next tactic:
obtain ⟨y, hy⟩ := hf.mul_inv_cancel ne_zero
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
  · rintro ⟨I, bot_lt, lt_top⟩ hf
    obtain ⟨x, mem, ne_zero⟩ := SetLike.exists_of_lt bot_lt
    rw [Submodule.mem_bot] at ne_zero
    obtain ⟨y, hy⟩ := hf.mul_inv_cancel ne_zero
    

Proof state:
case mpr.intro.intro.intro.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
I : Ideal R
bot_lt : ⊥ < I
lt_top : I < ⊤
hf : IsField R
x : R
mem : x ∈ I
ne_zero : ¬x = 0
y : R
hy : x * y = 1
⊢ False

Next tactic:
rw [lt_top_iff_ne_top, Ne.def, Ideal.eq_top_iff_one, ← hy] at lt_top
theorem not_isField_iff_exists_ideal_bot_lt_and_lt_top [Nontrivial R] :
    ¬IsField R ↔ ∃ I : Ideal R, ⊥ < I ∧ I < ⊤ := by
  constructor
  · intro h
    obtain ⟨x, nz, nu⟩ := exists_not_isUnit_of_not_isField h
    use Ideal.span {x}
    rw [bot_lt_iff_ne_bot, lt_top_iff_ne_top]
    exact ⟨mt Ideal.span_singleton_eq_bot.mp nz, mt Ideal.span_singleton_eq_top.mp nu⟩
  · rintro ⟨I, bot_lt, lt_top⟩ hf
    obtain ⟨x, mem, ne_zero⟩ := SetLike.exists_of_lt bot_lt
    rw [Submodule.mem_bot] at ne_zero
    obtain ⟨y, hy⟩ := hf.mul_inv_cancel ne_zero
    rw [lt_top_iff_ne_top, Ne.def, Ideal.eq_top_iff_one, ← hy] at lt_top
    

Proof state:
case mpr.intro.intro.intro.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
I : Ideal R
bot_lt : ⊥ < I
hf : IsField R
x : R
mem : x ∈ I
ne_zero : ¬x = 0
y : R
lt_top : x * y ∉ I
hy : x * y = 1
⊢ False

Next tactic:
exact lt_top (I.mul_mem_right _ mem)
/-- Also see `Ideal.isSimpleOrder` for the forward direction as an instance when `R` is a
division (semi)ring.

This result actually holds for all division semirings, but we lack the predicate to state it. -/
theorem isField_iff_isSimpleOrder_ideal : IsField R ↔ IsSimpleOrder (Ideal R) := by
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝ : CommSemiring R
⊢ IsField R ↔ IsSimpleOrder (Ideal R)

Next tactic:
cases subsingleton_or_nontrivial R
/-- Also see `Ideal.isSimpleOrder` for the forward direction as an instance when `R` is a
division (semi)ring.

This result actually holds for all division semirings, but we lack the predicate to state it. -/
theorem isField_iff_isSimpleOrder_ideal : IsField R ↔ IsSimpleOrder (Ideal R) := by
  cases subsingleton_or_nontrivial R
  · 

Proof state:
case inl
α : Type u
β : Type v
R : Type u_1
inst✝ : CommSemiring R
h✝ : Subsingleton R
⊢ IsField R ↔ IsSimpleOrder (Ideal R)

Next tactic:
exact
      ⟨fun h => (not_isField_of_subsingleton _ h).elim, fun h =>
        (false_of_nontrivial_of_subsingleton <| Ideal R).elim⟩
/-- Also see `Ideal.isSimpleOrder` for the forward direction as an instance when `R` is a
division (semi)ring.

This result actually holds for all division semirings, but we lack the predicate to state it. -/
theorem isField_iff_isSimpleOrder_ideal : IsField R ↔ IsSimpleOrder (Ideal R) := by
  cases subsingleton_or_nontrivial R
  · exact
      ⟨fun h => (not_isField_of_subsingleton _ h).elim, fun h =>
        (false_of_nontrivial_of_subsingleton <| Ideal R).elim⟩
  

Proof state:
case inr
α : Type u
β : Type v
R : Type u_1
inst✝ : CommSemiring R
h✝ : Nontrivial R
⊢ IsField R ↔ IsSimpleOrder (Ideal R)

Next tactic:
rw [← not_iff_not, Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top, ← not_iff_not]
/-- Also see `Ideal.isSimpleOrder` for the forward direction as an instance when `R` is a
division (semi)ring.

This result actually holds for all division semirings, but we lack the predicate to state it. -/
theorem isField_iff_isSimpleOrder_ideal : IsField R ↔ IsSimpleOrder (Ideal R) := by
  cases subsingleton_or_nontrivial R
  · exact
      ⟨fun h => (not_isField_of_subsingleton _ h).elim, fun h =>
        (false_of_nontrivial_of_subsingleton <| Ideal R).elim⟩
  rw [← not_iff_not, Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top, ← not_iff_not]
  

Proof state:
case inr
α : Type u
β : Type v
R : Type u_1
inst✝ : CommSemiring R
h✝ : Nontrivial R
⊢ (¬∃ I, ⊥ < I ∧ I < ⊤) ↔ ¬¬IsSimpleOrder (Ideal R)

Next tactic:
push_neg
/-- Also see `Ideal.isSimpleOrder` for the forward direction as an instance when `R` is a
division (semi)ring.

This result actually holds for all division semirings, but we lack the predicate to state it. -/
theorem isField_iff_isSimpleOrder_ideal : IsField R ↔ IsSimpleOrder (Ideal R) := by
  cases subsingleton_or_nontrivial R
  · exact
      ⟨fun h => (not_isField_of_subsingleton _ h).elim, fun h =>
        (false_of_nontrivial_of_subsingleton <| Ideal R).elim⟩
  rw [← not_iff_not, Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top, ← not_iff_not]
  push_neg
  

Proof state:
case inr
α : Type u
β : Type v
R : Type u_1
inst✝ : CommSemiring R
h✝ : Nontrivial R
⊢ (∀ (I : Ideal R), ⊥ < I → ¬I < ⊤) ↔ IsSimpleOrder (Ideal R)

Next tactic:
simp_rw [lt_top_iff_ne_top, bot_lt_iff_ne_bot, ← or_iff_not_imp_left, not_ne_iff]
/-- Also see `Ideal.isSimpleOrder` for the forward direction as an instance when `R` is a
division (semi)ring.

This result actually holds for all division semirings, but we lack the predicate to state it. -/
theorem isField_iff_isSimpleOrder_ideal : IsField R ↔ IsSimpleOrder (Ideal R) := by
  cases subsingleton_or_nontrivial R
  · exact
      ⟨fun h => (not_isField_of_subsingleton _ h).elim, fun h =>
        (false_of_nontrivial_of_subsingleton <| Ideal R).elim⟩
  rw [← not_iff_not, Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top, ← not_iff_not]
  push_neg
  simp_rw [lt_top_iff_ne_top, bot_lt_iff_ne_bot, ← or_iff_not_imp_left, not_ne_iff]
  

Proof state:
case inr
α : Type u
β : Type v
R : Type u_1
inst✝ : CommSemiring R
h✝ : Nontrivial R
⊢ (∀ (I : Ideal R), I = ⊥ ∨ I = ⊤) ↔ IsSimpleOrder (Ideal R)

Next tactic:
exact ⟨fun h => ⟨h⟩, fun h => h.2⟩
/-- When a ring is not a field, the maximal ideals are nontrivial. -/
theorem ne_bot_of_isMaximal_of_not_isField [Nontrivial R] {M : Ideal R} (max : M.IsMaximal)
    (not_field : ¬IsField R) : M ≠ ⊥ := by
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
max : Ideal.IsMaximal M
not_field : ¬IsField R
⊢ M ≠ ⊥

Next tactic:
rintro h
/-- When a ring is not a field, the maximal ideals are nontrivial. -/
theorem ne_bot_of_isMaximal_of_not_isField [Nontrivial R] {M : Ideal R} (max : M.IsMaximal)
    (not_field : ¬IsField R) : M ≠ ⊥ := by
  rintro h
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
max : Ideal.IsMaximal M
not_field : ¬IsField R
h : M = ⊥
⊢ False

Next tactic:
rw [h] at max
/-- When a ring is not a field, the maximal ideals are nontrivial. -/
theorem ne_bot_of_isMaximal_of_not_isField [Nontrivial R] {M : Ideal R} (max : M.IsMaximal)
    (not_field : ¬IsField R) : M ≠ ⊥ := by
  rintro h
  rw [h] at max
  

Proof state:
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
max : Ideal.IsMaximal ⊥
not_field : ¬IsField R
h : M = ⊥
⊢ False

Next tactic:
rcases max with ⟨⟨_h1, h2⟩⟩
/-- When a ring is not a field, the maximal ideals are nontrivial. -/
theorem ne_bot_of_isMaximal_of_not_isField [Nontrivial R] {M : Ideal R} (max : M.IsMaximal)
    (not_field : ¬IsField R) : M ≠ ⊥ := by
  rintro h
  rw [h] at max
  rcases max with ⟨⟨_h1, h2⟩⟩
  

Proof state:
case mk.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
not_field : ¬IsField R
h : M = ⊥
_h1 : ⊥ ≠ ⊤
h2 : ∀ (b : Ideal R), ⊥ < b → b = ⊤
⊢ False

Next tactic:
obtain ⟨I, hIbot, hItop⟩ := not_isField_iff_exists_ideal_bot_lt_and_lt_top.mp not_field
/-- When a ring is not a field, the maximal ideals are nontrivial. -/
theorem ne_bot_of_isMaximal_of_not_isField [Nontrivial R] {M : Ideal R} (max : M.IsMaximal)
    (not_field : ¬IsField R) : M ≠ ⊥ := by
  rintro h
  rw [h] at max
  rcases max with ⟨⟨_h1, h2⟩⟩
  obtain ⟨I, hIbot, hItop⟩ := not_isField_iff_exists_ideal_bot_lt_and_lt_top.mp not_field
  

Proof state:
case mk.intro.intro.intro
α : Type u
β : Type v
R : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
not_field : ¬IsField R
h : M = ⊥
_h1 : ⊥ ≠ ⊤
h2 : ∀ (b : Ideal R), ⊥ < b → b = ⊤
I : Ideal R
hIbot : ⊥ < I
hItop : I < ⊤
⊢ False

Next tactic:
exact ne_of_lt hItop (h2 I hIbot)
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  

Proof state:
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
⊢ ⊥ < M

Next tactic:
rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  

Proof state:
case intro.intro
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : ⊥ < I
Itop : I < ⊤
⊢ ⊥ < M

Next tactic:
constructor
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  constructor; · 

Proof state:
case intro.intro.left
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : ⊥ < I
Itop : I < ⊤
⊢ ↑⊥ ⊆ ↑M

Next tactic:
simp
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  constructor; · simp
  

Proof state:
case intro.intro.right
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : ⊥ < I
Itop : I < ⊤
⊢ ¬↑M ⊆ ↑⊥

Next tactic:
intro mle
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  constructor; · simp
  intro mle
  

Proof state:
case intro.intro.right
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : ⊥ < I
Itop : I < ⊤
mle : ↑M ⊆ ↑⊥
⊢ False

Next tactic:
apply lt_irrefl (⊤ : Ideal R)
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  constructor; · simp
  intro mle
  apply lt_irrefl (⊤ : Ideal R)
  

Proof state:
case intro.intro.right
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : ⊥ < I
Itop : I < ⊤
mle : ↑M ⊆ ↑⊥
⊢ ⊤ < ⊤

Next tactic:
have : M = ⊥ := eq_bot_iff.mpr mle
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  constructor; · simp
  intro mle
  apply lt_irrefl (⊤ : Ideal R)
  have : M = ⊥ := eq_bot_iff.mpr mle
  

Proof state:
case intro.intro.right
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : ⊥ < I
Itop : I < ⊤
mle : ↑M ⊆ ↑⊥
this : M = ⊥
⊢ ⊤ < ⊤

Next tactic:
rw [← this] at Ibot
theorem bot_lt_of_maximal (M : Ideal R) [hm : M.IsMaximal] (non_field : ¬IsField R) : ⊥ < M := by
  rcases Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top.1 non_field with ⟨I, Ibot, Itop⟩
  constructor; · simp
  intro mle
  apply lt_irrefl (⊤ : Ideal R)
  have : M = ⊥ := eq_bot_iff.mpr mle
  rw [← this] at Ibot
  

Proof state:
case intro.intro.right
α : Type u
β : Type v
R : Type u
inst✝¹ : CommSemiring R
inst✝ : Nontrivial R
M : Ideal R
hm : IsMaximal M
non_field : ¬IsField R
I : Ideal R
Ibot : M < I
Itop : I < ⊤
mle : ↑M ⊆ ↑⊥
this : M = ⊥
⊢ ⊤ < ⊤

Next tactic:
rwa [hm.1.2 I Ibot] at Itop
theorem exists_max_ideal_of_mem_nonunits [CommSemiring α] (h : a ∈ nonunits α) :
    ∃ I : Ideal α, I.IsMaximal ∧ a ∈ I := by
  

Proof state:
α : Type u
β : Type v
a b : α
inst✝ : CommSemiring α
h : a ∈ nonunits α
⊢ ∃ I, Ideal.IsMaximal I ∧ a ∈ I

Next tactic:
have : Ideal.span ({a} : Set α) ≠ ⊤ := by
    intro H
    rw [Ideal.span_singleton_eq_top] at H
    contradiction