l3lab/ntp-mathlib huggingface dataset:
/-- On `Ideal`s, `Submodule.quotientRel` is a ring congruence. -/
protected def ringCon (I : Ideal R) : RingCon R :=
  { QuotientAddGroup.con I.toAddSubgroup with
    mul' := fun {a₁ b₁ a₂ b₂} h₁ h₂ => by
      rw [Submodule.quotientRel_r_def] at h₁ h₂ ⊢
      have F := I.add_mem (I.mul_mem_left a₂ h₁) (I.mul_mem_right b₁ h₂)
      have : a₁ * a₂ - b₁ * b₂ = a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁ := by
        

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
src✝ : AddCon R := QuotientAddGroup.con (Submodule.toAddSubgroup I)
a₁ b₁ a₂ b₂ : R
h₁ : a₁ - b₁ ∈ I
h₂ : a₂ - b₂ ∈ I
F : a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁ ∈ I
⊢ a₁ * a₂ - b₁ * b₂ = a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁

Next tactic:
rw [mul_sub, sub_mul, sub_add_sub_cancel, mul_comm, mul_comm b₁]
/-- On `Ideal`s, `Submodule.quotientRel` is a ring congruence. -/
protected def ringCon (I : Ideal R) : RingCon R :=
  { QuotientAddGroup.con I.toAddSubgroup with
    mul' := fun {a₁ b₁ a₂ b₂} h₁ h₂ => by
      rw [Submodule.quotientRel_r_def] at h₁ h₂ ⊢
      have F := I.add_mem (I.mul_mem_left a₂ h₁) (I.mul_mem_right b₁ h₂)
      have : a₁ * a₂ - b₁ * b₂ = a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁ := by
        rw [mul_sub, sub_mul, sub_add_sub_cancel, mul_comm, mul_comm b₁]
      

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
src✝ : AddCon R := QuotientAddGroup.con (Submodule.toAddSubgroup I)
a₁ b₁ a₂ b₂ : R
h₁ : a₁ - b₁ ∈ I
h₂ : a₂ - b₂ ∈ I
F : a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁ ∈ I
this : a₁ * a₂ - b₁ * b₂ = a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁
⊢ a₁ * a₂ - b₁ * b₂ ∈ I

Next tactic:
rwa [← this] at F
theorem eq_zero_iff_dvd (x y : R) : Ideal.Quotient.mk (Ideal.span ({x} : Set R)) y = 0 ↔ x ∣ y := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I : Ideal R
a b : R
S : Type v
x✝ y✝ x y : R
⊢ (mk (span {x})) y = 0 ↔ x ∣ y

Next tactic:
rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton]
theorem mk_eq_mk_iff_sub_mem (x y : R) : mk I x = mk I y ↔ x - y ∈ I := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I : Ideal R
a b : R
S : Type v
x✝ y✝ x y : R
⊢ (mk I) x = (mk I) y ↔ x - y ∈ I

Next tactic:
rw [← eq_zero_iff_mem, map_sub, sub_eq_zero]
theorem subsingleton_iff {I : Ideal R} : Subsingleton (R ⧸ I) ↔ I = ⊤ := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
⊢ Subsingleton (R ⧸ I) ↔ I = ⊤

Next tactic:
rw [eq_top_iff_one, ← subsingleton_iff_zero_eq_one, eq_comm, ← (mk I).map_one,
    Quotient.eq_zero_iff_mem]
instance : Unique (R ⧸ (⊤ : Ideal R)) :=
  ⟨⟨0⟩, by 

Proof state:
R : Type u
inst✝ : CommRing R
I : Ideal R
a b : R
S : Type v
x y : R
⊢ ∀ (a : R ⧸ ⊤), a = default

Next tactic:
rintro ⟨x⟩
instance : Unique (R ⧸ (⊤ : Ideal R)) :=
  ⟨⟨0⟩, by rintro ⟨x⟩; 

Proof state:
case mk
R : Type u
inst✝ : CommRing R
I : Ideal R
a b : R
S : Type v
x✝ y : R
a✝ : R ⧸ ⊤
x : R
⊢ Quot.mk Setoid.r x = default

Next tactic:
exact Quotient.eq_zero_iff_mem.mpr Submodule.mem_top
/-- If `I` is an ideal of a commutative ring `R`, if `q : R → R/I` is the quotient map, and if
`s ⊆ R` is a subset, then `q⁻¹(q(s)) = ⋃ᵢ(i + s)`, the union running over all `i ∈ I`. -/
theorem quotient_ring_saturate (I : Ideal R) (s : Set R) :
    mk I ⁻¹' (mk I '' s) = ⋃ x : I, (fun y => x.1 + y) '' s := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
s : Set R
⊢ ⇑(mk I) ⁻¹' (⇑(mk I) '' s) = ⋃ x, (fun y => ↑x + y) '' s

Next tactic:
ext x
/-- If `I` is an ideal of a commutative ring `R`, if `q : R → R/I` is the quotient map, and if
`s ⊆ R` is a subset, then `q⁻¹(q(s)) = ⋃ᵢ(i + s)`, the union running over all `i ∈ I`. -/
theorem quotient_ring_saturate (I : Ideal R) (s : Set R) :
    mk I ⁻¹' (mk I '' s) = ⋃ x : I, (fun y => x.1 + y) '' s := by
  ext x
  

Proof state:
case h
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y : R
I : Ideal R
s : Set R
x : R
⊢ x ∈ ⇑(mk I) ⁻¹' (⇑(mk I) '' s) ↔ x ∈ ⋃ x, (fun y => ↑x + y) '' s

Next tactic:
simp only [mem_preimage, mem_image, mem_iUnion, Ideal.Quotient.eq]
/-- If `I` is an ideal of a commutative ring `R`, if `q : R → R/I` is the quotient map, and if
`s ⊆ R` is a subset, then `q⁻¹(q(s)) = ⋃ᵢ(i + s)`, the union running over all `i ∈ I`. -/
theorem quotient_ring_saturate (I : Ideal R) (s : Set R) :
    mk I ⁻¹' (mk I '' s) = ⋃ x : I, (fun y => x.1 + y) '' s := by
  ext x
  simp only [mem_preimage, mem_image, mem_iUnion, Ideal.Quotient.eq]
  

Proof state:
case h
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y : R
I : Ideal R
s : Set R
x : R
⊢ (∃ x_1 ∈ s, x_1 - x ∈ I) ↔ ∃ i, ∃ x_1 ∈ s, ↑i + x_1 = x

Next tactic:
exact
    ⟨fun ⟨a, a_in, h⟩ => ⟨⟨_, I.neg_mem h⟩, a, a_in, by simp⟩, fun ⟨⟨i, hi⟩, a, ha, Eq⟩ =>
      ⟨a, ha, by rw [← Eq, sub_add_eq_sub_sub_swap, sub_self, zero_sub]; exact I.neg_mem hi⟩⟩
/-- If `I` is an ideal of a commutative ring `R`, if `q : R → R/I` is the quotient map, and if
`s ⊆ R` is a subset, then `q⁻¹(q(s)) = ⋃ᵢ(i + s)`, the union running over all `i ∈ I`. -/
theorem quotient_ring_saturate (I : Ideal R) (s : Set R) :
    mk I ⁻¹' (mk I '' s) = ⋃ x : I, (fun y => x.1 + y) '' s := by
  ext x
  simp only [mem_preimage, mem_image, mem_iUnion, Ideal.Quotient.eq]
  exact
    ⟨fun ⟨a, a_in, h⟩ => ⟨⟨_, I.neg_mem h⟩, a, a_in, by 

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝ b : R
S : Type v
x✝¹ y : R
I : Ideal R
s : Set R
x : R
x✝ : ∃ x_1 ∈ s, x_1 - x ∈ I
a : R
a_in : a ∈ s
h : a - x ∈ I
⊢ ↑{ val := -(a - x), property := (_ : -(a - x) ∈ I) } + a = x

Next tactic:
simp
/-- If `I` is an ideal of a commutative ring `R`, if `q : R → R/I` is the quotient map, and if
`s ⊆ R` is a subset, then `q⁻¹(q(s)) = ⋃ᵢ(i + s)`, the union running over all `i ∈ I`. -/
theorem quotient_ring_saturate (I : Ideal R) (s : Set R) :
    mk I ⁻¹' (mk I '' s) = ⋃ x : I, (fun y => x.1 + y) '' s := by
  ext x
  simp only [mem_preimage, mem_image, mem_iUnion, Ideal.Quotient.eq]
  exact
    ⟨fun ⟨a, a_in, h⟩ => ⟨⟨_, I.neg_mem h⟩, a, a_in, by simp⟩, fun ⟨⟨i, hi⟩, a, ha, Eq⟩ =>
      ⟨a, ha, by 

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝ b : R
S : Type v
x✝¹ y : R
I : Ideal R
s : Set R
x : R
x✝ : ∃ i, ∃ x_1 ∈ s, ↑i + x_1 = x
i : R
hi : i ∈ I
a : R
ha : a ∈ s
Eq : ↑{ val := i, property := hi } + a = x
⊢ a - x ∈ I

Next tactic:
rw [← Eq, sub_add_eq_sub_sub_swap, sub_self, zero_sub]
/-- If `I` is an ideal of a commutative ring `R`, if `q : R → R/I` is the quotient map, and if
`s ⊆ R` is a subset, then `q⁻¹(q(s)) = ⋃ᵢ(i + s)`, the union running over all `i ∈ I`. -/
theorem quotient_ring_saturate (I : Ideal R) (s : Set R) :
    mk I ⁻¹' (mk I '' s) = ⋃ x : I, (fun y => x.1 + y) '' s := by
  ext x
  simp only [mem_preimage, mem_image, mem_iUnion, Ideal.Quotient.eq]
  exact
    ⟨fun ⟨a, a_in, h⟩ => ⟨⟨_, I.neg_mem h⟩, a, a_in, by simp⟩, fun ⟨⟨i, hi⟩, a, ha, Eq⟩ =>
      ⟨a, ha, by rw [← Eq, sub_add_eq_sub_sub_swap, sub_self, zero_sub]; 

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝ b : R
S : Type v
x✝¹ y : R
I : Ideal R
s : Set R
x : R
x✝ : ∃ i, ∃ x_1 ∈ s, ↑i + x_1 = x
i : R
hi : i ∈ I
a : R
ha : a ∈ s
Eq : ↑{ val := i, property := hi } + a = x
⊢ -↑{ val := i, property := hi } ∈ I

Next tactic:
exact I.neg_mem hi
theorem isDomain_iff_prime (I : Ideal R) : IsDomain (R ⧸ I) ↔ I.IsPrime := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
⊢ IsDomain (R ⧸ I) ↔ IsPrime I

Next tactic:
refine' ⟨fun H => ⟨zero_ne_one_iff.1 _, fun {x y} h => _⟩, fun h => inferInstance⟩
theorem isDomain_iff_prime (I : Ideal R) : IsDomain (R ⧸ I) ↔ I.IsPrime := by
  refine' ⟨fun H => ⟨zero_ne_one_iff.1 _, fun {x y} h => _⟩, fun h => inferInstance⟩
  · 

Proof state:
case refine'_1
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
H : IsDomain (R ⧸ I)
⊢ 0 ≠ 1

Next tactic:
haveI : Nontrivial (R ⧸ I) := ⟨H.2.1⟩
theorem isDomain_iff_prime (I : Ideal R) : IsDomain (R ⧸ I) ↔ I.IsPrime := by
  refine' ⟨fun H => ⟨zero_ne_one_iff.1 _, fun {x y} h => _⟩, fun h => inferInstance⟩
  · haveI : Nontrivial (R ⧸ I) := ⟨H.2.1⟩
    

Proof state:
case refine'_1
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
H : IsDomain (R ⧸ I)
this : Nontrivial (R ⧸ I)
⊢ 0 ≠ 1

Next tactic:
exact zero_ne_one
theorem isDomain_iff_prime (I : Ideal R) : IsDomain (R ⧸ I) ↔ I.IsPrime := by
  refine' ⟨fun H => ⟨zero_ne_one_iff.1 _, fun {x y} h => _⟩, fun h => inferInstance⟩
  · haveI : Nontrivial (R ⧸ I) := ⟨H.2.1⟩
    exact zero_ne_one
  · 

Proof state:
case refine'_2
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y✝ : R
I : Ideal R
H : IsDomain (R ⧸ I)
x y : R
h : x * y ∈ I
⊢ x ∈ I ∨ y ∈ I

Next tactic:
simp only [← eq_zero_iff_mem, (mk I).map_mul] at h ⊢
theorem isDomain_iff_prime (I : Ideal R) : IsDomain (R ⧸ I) ↔ I.IsPrime := by
  refine' ⟨fun H => ⟨zero_ne_one_iff.1 _, fun {x y} h => _⟩, fun h => inferInstance⟩
  · haveI : Nontrivial (R ⧸ I) := ⟨H.2.1⟩
    exact zero_ne_one
  · simp only [← eq_zero_iff_mem, (mk I).map_mul] at h ⊢
    

Proof state:
case refine'_2
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y✝ : R
I : Ideal R
H : IsDomain (R ⧸ I)
x y : R
h : (mk I) x * (mk I) y = 0
⊢ (mk I) x = 0 ∨ (mk I) y = 0

Next tactic:
haveI := @IsDomain.to_noZeroDivisors (R ⧸ I) _ H
theorem isDomain_iff_prime (I : Ideal R) : IsDomain (R ⧸ I) ↔ I.IsPrime := by
  refine' ⟨fun H => ⟨zero_ne_one_iff.1 _, fun {x y} h => _⟩, fun h => inferInstance⟩
  · haveI : Nontrivial (R ⧸ I) := ⟨H.2.1⟩
    exact zero_ne_one
  · simp only [← eq_zero_iff_mem, (mk I).map_mul] at h ⊢
    haveI := @IsDomain.to_noZeroDivisors (R ⧸ I) _ H
    

Proof state:
case refine'_2
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y✝ : R
I : Ideal R
H : IsDomain (R ⧸ I)
x y : R
h : (mk I) x * (mk I) y = 0
this : NoZeroDivisors (R ⧸ I)
⊢ (mk I) x = 0 ∨ (mk I) y = 0

Next tactic:
exact eq_zero_or_eq_zero_of_mul_eq_zero h
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
⊢ ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b, a * b = 1

Next tactic:
rintro ⟨a⟩ h
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  rintro ⟨a⟩ h
  

Proof state:
case mk
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝¹ b : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a✝ : R ⧸ I
a : R
h : Quot.mk Setoid.r a ≠ 0
⊢ ∃ b, Quot.mk Setoid.r a * b = 1

Next tactic:
rcases hI.exists_inv (mt eq_zero_iff_mem.2 h) with ⟨b, c, hc, abc⟩
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  rintro ⟨a⟩ h
  rcases hI.exists_inv (mt eq_zero_iff_mem.2 h) with ⟨b, c, hc, abc⟩
  

Proof state:
case mk.intro.intro.intro
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝¹ b✝ : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a✝ : R ⧸ I
a : R
h : Quot.mk Setoid.r a ≠ 0
b c : R
hc : c ∈ I
abc : b * a + c = 1
⊢ ∃ b, Quot.mk Setoid.r a * b = 1

Next tactic:
rw [mul_comm] at abc
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  rintro ⟨a⟩ h
  rcases hI.exists_inv (mt eq_zero_iff_mem.2 h) with ⟨b, c, hc, abc⟩
  rw [mul_comm] at abc
  

Proof state:
case mk.intro.intro.intro
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝¹ b✝ : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a✝ : R ⧸ I
a : R
h : Quot.mk Setoid.r a ≠ 0
b c : R
hc : c ∈ I
abc : a * b + c = 1
⊢ ∃ b, Quot.mk Setoid.r a * b = 1

Next tactic:
refine' ⟨mk _ b, Quot.sound _⟩
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  rintro ⟨a⟩ h
  rcases hI.exists_inv (mt eq_zero_iff_mem.2 h) with ⟨b, c, hc, abc⟩
  rw [mul_comm] at abc
  refine' ⟨mk _ b, Quot.sound _⟩
  

Proof state:
case mk.intro.intro.intro
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝¹ b✝ : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a✝ : R ⧸ I
a : R
h : Quot.mk Setoid.r a ≠ 0
b c : R
hc : c ∈ I
abc : a * b + c = 1
⊢ Setoid.r ((fun x x_1 => x * x_1) a b) 1

Next tactic:
simp only [Submodule.quotientRel_r_def]
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  rintro ⟨a⟩ h
  rcases hI.exists_inv (mt eq_zero_iff_mem.2 h) with ⟨b, c, hc, abc⟩
  rw [mul_comm] at abc
  refine' ⟨mk _ b, Quot.sound _⟩
  simp only [Submodule.quotientRel_r_def]
  

Proof state:
case mk.intro.intro.intro
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝¹ b✝ : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a✝ : R ⧸ I
a : R
h : Quot.mk Setoid.r a ≠ 0
b c : R
hc : c ∈ I
abc : a * b + c = 1
⊢ a * b - 1 ∈ I

Next tactic:
rw [← eq_sub_iff_add_eq'] at abc
theorem exists_inv {I : Ideal R} [hI : I.IsMaximal] :
    ∀ {a : R ⧸ I}, a ≠ 0 → ∃ b : R ⧸ I, a * b = 1 := by
  rintro ⟨a⟩ h
  rcases hI.exists_inv (mt eq_zero_iff_mem.2 h) with ⟨b, c, hc, abc⟩
  rw [mul_comm] at abc
  refine' ⟨mk _ b, Quot.sound _⟩
  simp only [Submodule.quotientRel_r_def]
  rw [← eq_sub_iff_add_eq'] at abc
  

Proof state:
case mk.intro.intro.intro
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝¹ b✝ : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a✝ : R ⧸ I
a : R
h : Quot.mk Setoid.r a ≠ 0
b c : R
hc : c ∈ I
abc : c = 1 - a * b
⊢ a * b - 1 ∈ I

Next tactic:
rwa [abc, ← neg_mem_iff (G := R) (H := I), neg_sub] at hc
/-- The quotient by a maximal ideal is a group with zero. This is a `def` rather than `instance`,
since users will have computable inverses in some applications.

See note [reducible non-instances]. -/
@[reducible]
protected noncomputable def groupWithZero (I : Ideal R) [hI : I.IsMaximal] :
    GroupWithZero (R ⧸ I) :=
  { inv := fun a => if ha : a = 0 then 0 else Classical.choose (exists_inv ha)
    mul_inv_cancel := fun a (ha : a ≠ 0) =>
      show a * dite _ _ _ = _ by 

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝ b : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a : R ⧸ I
ha : a ≠ 0
⊢ (a * if ha : a = 0 then 0 else choose (_ : ∃ b, a * b = 1)) = 1

Next tactic:
rw [dif_neg ha]
/-- The quotient by a maximal ideal is a group with zero. This is a `def` rather than `instance`,
since users will have computable inverses in some applications.

See note [reducible non-instances]. -/
@[reducible]
protected noncomputable def groupWithZero (I : Ideal R) [hI : I.IsMaximal] :
    GroupWithZero (R ⧸ I) :=
  { inv := fun a => if ha : a = 0 then 0 else Classical.choose (exists_inv ha)
    mul_inv_cancel := fun a (ha : a ≠ 0) =>
      show a * dite _ _ _ = _ by rw [dif_neg ha]; 

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a✝ b : R
S : Type v
x y : R
I : Ideal R
hI : IsMaximal I
a : R ⧸ I
ha : a ≠ 0
⊢ a * choose (_ : ∃ b, a * b = 1) = 1

Next tactic:
exact Classical.choose_spec (exists_inv ha)
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
hqf : IsField (R ⧸ I)
⊢ IsMaximal I

Next tactic:
apply Ideal.isMaximal_iff.2
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  

Proof state:
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
hqf : IsField (R ⧸ I)
⊢ 1 ∉ I ∧ ∀ (J : Ideal R) (x : R), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J

Next tactic:
constructor
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · 

Proof state:
case left
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
hqf : IsField (R ⧸ I)
⊢ 1 ∉ I

Next tactic:
intro h
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · intro h
    

Proof state:
case left
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
hqf : IsField (R ⧸ I)
h : 1 ∈ I
⊢ False

Next tactic:
rcases hqf.exists_pair_ne with ⟨⟨x⟩, ⟨y⟩, hxy⟩
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · intro h
    rcases hqf.exists_pair_ne with ⟨⟨x⟩, ⟨y⟩, hxy⟩
    

Proof state:
case left.intro.mk.intro.mk
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y✝ : R
I : Ideal R
hqf : IsField (R ⧸ I)
h : 1 ∈ I
w✝¹ : R ⧸ I
x : R
w✝ : R ⧸ I
y : R
hxy : Quot.mk Setoid.r x ≠ Quot.mk Setoid.r y
⊢ False

Next tactic:
exact hxy (Ideal.Quotient.eq.2 (mul_one (x - y) ▸ I.mul_mem_left _ h))
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · intro h
    rcases hqf.exists_pair_ne with ⟨⟨x⟩, ⟨y⟩, hxy⟩
    exact hxy (Ideal.Quotient.eq.2 (mul_one (x - y) ▸ I.mul_mem_left _ h))
  · 

Proof state:
case right
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
I : Ideal R
hqf : IsField (R ⧸ I)
⊢ ∀ (J : Ideal R) (x : R), I ≤ J → x ∉ I → x ∈ J → 1 ∈ J

Next tactic:
intro J x hIJ hxnI hxJ
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · intro h
    rcases hqf.exists_pair_ne with ⟨⟨x⟩, ⟨y⟩, hxy⟩
    exact hxy (Ideal.Quotient.eq.2 (mul_one (x - y) ▸ I.mul_mem_left _ h))
  · intro J x hIJ hxnI hxJ
    

Proof state:
case right
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y : R
I : Ideal R
hqf : IsField (R ⧸ I)
J : Ideal R
x : R
hIJ : I ≤ J
hxnI : x ∉ I
hxJ : x ∈ J
⊢ 1 ∈ J

Next tactic:
rcases hqf.mul_inv_cancel (mt Ideal.Quotient.eq_zero_iff_mem.1 hxnI) with ⟨⟨y⟩, hy⟩
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · intro h
    rcases hqf.exists_pair_ne with ⟨⟨x⟩, ⟨y⟩, hxy⟩
    exact hxy (Ideal.Quotient.eq.2 (mul_one (x - y) ▸ I.mul_mem_left _ h))
  · intro J x hIJ hxnI hxJ
    rcases hqf.mul_inv_cancel (mt Ideal.Quotient.eq_zero_iff_mem.1 hxnI) with ⟨⟨y⟩, hy⟩
    

Proof state:
case right.intro.mk
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y✝ : R
I : Ideal R
hqf : IsField (R ⧸ I)
J : Ideal R
x : R
hIJ : I ≤ J
hxnI : x ∉ I
hxJ : x ∈ J
w✝ : R ⧸ I
y : R
hy : (mk I) x * Quot.mk Setoid.r y = 1
⊢ 1 ∈ J

Next tactic:
rw [← zero_add (1 : R), ← sub_self (x * y), sub_add]
/-- If the quotient by an ideal is a field, then the ideal is maximal. -/
theorem maximal_of_isField (I : Ideal R) (hqf : IsField (R ⧸ I)) : I.IsMaximal := by
  apply Ideal.isMaximal_iff.2
  constructor
  · intro h
    rcases hqf.exists_pair_ne with ⟨⟨x⟩, ⟨y⟩, hxy⟩
    exact hxy (Ideal.Quotient.eq.2 (mul_one (x - y) ▸ I.mul_mem_left _ h))
  · intro J x hIJ hxnI hxJ
    rcases hqf.mul_inv_cancel (mt Ideal.Quotient.eq_zero_iff_mem.1 hxnI) with ⟨⟨y⟩, hy⟩
    rw [← zero_add (1 : R), ← sub_self (x * y), sub_add]
    

Proof state:
case right.intro.mk
R : Type u
inst✝ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y✝ : R
I : Ideal R
hqf : IsField (R ⧸ I)
J : Ideal R
x : R
hIJ : I ≤ J
hxnI : x ∉ I
hxJ : x ∈ J
w✝ : R ⧸ I
y : R
hy : (mk I) x * Quot.mk Setoid.r y = 1
⊢ x * y - (x * y - 1) ∈ J

Next tactic:
refine' J.sub_mem (J.mul_mem_right _ hxJ) (hIJ (Ideal.Quotient.eq.1 hy))
theorem lift_surjective_of_surjective (I : Ideal R) {f : R →+* S} (H : ∀ a : R, a ∈ I → f a = 0)
    (hf : Function.Surjective f) : Function.Surjective (Ideal.Quotient.lift I f H) := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y : R
inst✝ : CommRing S
I : Ideal R
f : R →+* S
H : ∀ a ∈ I, f a = 0
hf : Function.Surjective ⇑f
⊢ Function.Surjective ⇑(lift I f H)

Next tactic:
intro y
theorem lift_surjective_of_surjective (I : Ideal R) {f : R →+* S} (H : ∀ a : R, a ∈ I → f a = 0)
    (hf : Function.Surjective f) : Function.Surjective (Ideal.Quotient.lift I f H) := by
  intro y
  

Proof state:
R : Type u
inst✝¹ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x y✝ : R
inst✝ : CommRing S
I : Ideal R
f : R →+* S
H : ∀ a ∈ I, f a = 0
hf : Function.Surjective ⇑f
y : S
⊢ ∃ a, (lift I f H) a = y

Next tactic:
obtain ⟨x, rfl⟩ := hf y
theorem lift_surjective_of_surjective (I : Ideal R) {f : R →+* S} (H : ∀ a : R, a ∈ I → f a = 0)
    (hf : Function.Surjective f) : Function.Surjective (Ideal.Quotient.lift I f H) := by
  intro y
  obtain ⟨x, rfl⟩ := hf y
  

Proof state:
case intro
R : Type u
inst✝¹ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y : R
inst✝ : CommRing S
I : Ideal R
f : R →+* S
H : ∀ a ∈ I, f a = 0
hf : Function.Surjective ⇑f
x : R
⊢ ∃ a, (lift I f H) a = f x

Next tactic:
use Ideal.Quotient.mk I x
theorem lift_surjective_of_surjective (I : Ideal R) {f : R →+* S} (H : ∀ a : R, a ∈ I → f a = 0)
    (hf : Function.Surjective f) : Function.Surjective (Ideal.Quotient.lift I f H) := by
  intro y
  obtain ⟨x, rfl⟩ := hf y
  use Ideal.Quotient.mk I x
  

Proof state:
case h
R : Type u
inst✝¹ : CommRing R
I✝ : Ideal R
a b : R
S : Type v
x✝ y : R
inst✝ : CommRing S
I : Ideal R
f : R →+* S
H : ∀ a ∈ I, f a = 0
hf : Function.Surjective ⇑f
x : R
⊢ (lift I f H) ((mk I) x) = f x

Next tactic:
simp only [Ideal.Quotient.lift_mk]
@[simp]
theorem factor_comp_mk (S T : Ideal R) (H : S ≤ T) : (factor S T H).comp (mk S) = mk T := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
I : Ideal R
a b : R
S✝ : Type v
x y : R
inst✝ : CommRing S✝
S T : Ideal R
H : S ≤ T
⊢ RingHom.comp (factor S T H) (mk S) = mk T

Next tactic:
ext x
@[simp]
theorem factor_comp_mk (S T : Ideal R) (H : S ≤ T) : (factor S T H).comp (mk S) = mk T := by
  ext x
  

Proof state:
case a
R : Type u
inst✝¹ : CommRing R
I : Ideal R
a b : R
S✝ : Type v
x✝ y : R
inst✝ : CommRing S✝
S T : Ideal R
H : S ≤ T
x : R
⊢ (RingHom.comp (factor S T H) (mk S)) x = (mk T) x

Next tactic:
rw [RingHom.comp_apply, factor_mk]
/-- Quotienting by equal ideals gives equivalent rings.

See also `Submodule.quotEquivOfEq` and `Ideal.quotientEquivAlgOfEq`.
-/
def quotEquivOfEq {R : Type*} [CommRing R] {I J : Ideal R} (h : I = J) : R ⧸ I ≃+* R ⧸ J :=
  { Submodule.quotEquivOfEq I J h with
    map_mul' := by
      

Proof state:
R✝ : Type u
inst✝¹ : CommRing R✝
I✝ : Ideal R✝
a b : R✝
S : Type v
R : Type u_1
inst✝ : CommRing R
I J : Ideal R
h : I = J
src✝ : (R ⧸ I) ≃ₗ[R] R ⧸ J := Submodule.quotEquivOfEq I J h
⊢ ∀ (x y : R ⧸ I),
    Equiv.toFun
        { toFun := src✝.toFun, invFun := src✝.invFun, left_inv := (_ : Function.LeftInverse src✝.invFun src✝.toFun),
          right_inv := (_ : Function.RightInverse src✝.invFun src✝.toFun) }
        (x * y) =
      Equiv.toFun
          { toFun := src✝.toFun, invFun := src✝.invFun, left_inv := (_ : Function.LeftInverse src✝.invFun src✝.toFun),
            right_inv := (_ : Function.RightInverse src✝.invFun src✝.toFun) }
          x *
        Equiv.toFun
          { toFun := src✝.toFun, invFun := src✝.invFun, left_inv := (_ : Function.LeftInverse src✝.invFun src✝.toFun),
            right_inv := (_ : Function.RightInverse src✝.invFun src✝.toFun) }
          y

Next tactic:
rintro ⟨x⟩ ⟨y⟩