l3lab/ntp-mathlib huggingface dataset:
irreducible_def preLift {r : R → R → Prop} { f : R →+* T } (h : ∀ ⦃x y⦄, r x y → f x = f y) :
  RingQuot r →+* T :=
  { toFun := fun x ↦ Quot.lift f
        (by
          rintro _ _ r
          induction r with
          | of r => exact h r
          | add_left _ r' => rw [map_add, map_add, r']
          | mul_left _ r' => rw [map_mul, map_mul, r']
          | mul_right _ r' => rw [map_mul, map_mul, r'])
        x.toQuot
    map_zero' := by simp only [← zero_quot, f.map_zero]
    map_add' := by
      rintro ⟨⟨x⟩⟩ ⟨⟨y⟩⟩
      simp only [add_quot, f.map_add x y]
    map_one' := by simp only [← one_quot, f.map_one]
    map_mul' := by
      rintro ⟨⟨x⟩⟩ ⟨⟨y⟩⟩
      

Proof state:
case mk.mk.mk.mk
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : R →+* T
h : ∀ ⦃x y : R⦄, r x y → f x = f y
toQuot✝¹ : Quot (Rel r)
x : R
toQuot✝ : Quot (Rel r)
y : R
⊢ OneHom.toFun
      { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
        map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) }
      ({ toQuot := Quot.mk (Rel r) x } * { toQuot := Quot.mk (Rel r) y }) =
    OneHom.toFun
        { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
          map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) }
        { toQuot := Quot.mk (Rel r) x } *
      OneHom.toFun
        { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
          map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) }
        { toQuot := Quot.mk (Rel r) y }

Next tactic:
simp only [mul_quot, f.map_mul x y]
irreducible_def preLift {r : R → R → Prop} { f : R →+* T } (h : ∀ ⦃x y⦄, r x y → f x = f y) :
  RingQuot r →+* T :=
  { toFun := fun x ↦ Quot.lift f
        (by
          rintro _ _ r
          induction r with
          | of r => exact h r
          | add_left _ r' => rw [map_add, map_add, r']
          | mul_left _ r' => rw [map_mul, map_mul, r']
          | mul_right _ r' => rw [map_mul, map_mul, r'])
        x.toQuot
    map_zero' := by 

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : R →+* T
h : ∀ ⦃x y : R⦄, r x y → f x = f y
⊢ OneHom.toFun
      (↑{
          toOneHom :=
            { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
              map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) },
          map_mul' :=
            (_ :
              ∀ (x y : RingQuot r),
                OneHom.toFun
                    { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
                      map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) }
                    (x * y) =
                  OneHom.toFun
                      { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
                        map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) }
                      x *
                    OneHom.toFun
                      { toFun := fun x => Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) x.toQuot,
                        map_one' := (_ : Quot.lift ⇑f (_ : ∀ (a b : R), Rel r a b → f a = f b) 1.toQuot = 1) }
                      y) })
      0 =
    0

Next tactic:
simp only [← zero_quot, f.map_zero]
/-- Any ring homomorphism `f : R →+* T` which respects a relation `r : R → R → Prop`
factors uniquely through a morphism `RingQuot r →+* T`.
-/
irreducible_def lift {r : R → R → Prop} :
  { f : R →+* T // ∀ ⦃x y⦄, r x y → f x = f y } ≃ (RingQuot r →+* T) :=
  { toFun := fun f ↦ preLift f.prop
    invFun := fun F ↦ ⟨F.comp (mkRingHom r), fun x y h ↦ congr_arg F (mkRingHom_rel h)⟩
    left_inv := fun f ↦ by
      

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : { f // ∀ ⦃x y : R⦄, r x y → f x = f y }
⊢ (fun F =>
        { val := RingHom.comp F (mkRingHom r),
          property := (_ : ∀ (x y : R), r x y → F ((mkRingHom r) x) = F ((mkRingHom r) y)) })
      ((fun f => preLift (_ : ∀ ⦃x y : R⦄, r x y → ↑f x = ↑f y)) f) =
    f

Next tactic:
ext
/-- Any ring homomorphism `f : R →+* T` which respects a relation `r : R → R → Prop`
factors uniquely through a morphism `RingQuot r →+* T`.
-/
irreducible_def lift {r : R → R → Prop} :
  { f : R →+* T // ∀ ⦃x y⦄, r x y → f x = f y } ≃ (RingQuot r →+* T) :=
  { toFun := fun f ↦ preLift f.prop
    invFun := fun F ↦ ⟨F.comp (mkRingHom r), fun x y h ↦ congr_arg F (mkRingHom_rel h)⟩
    left_inv := fun f ↦ by
      ext
      

Proof state:
case a.a
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : { f // ∀ ⦃x y : R⦄, r x y → f x = f y }
x✝ : R
⊢ ↑((fun F =>
            { val := RingHom.comp F (mkRingHom r),
              property := (_ : ∀ (x y : R), r x y → F ((mkRingHom r) x) = F ((mkRingHom r) y)) })
          ((fun f => preLift (_ : ∀ ⦃x y : R⦄, r x y → ↑f x = ↑f y)) f))
      x✝ =
    ↑f x✝

Next tactic:
simp only [preLift_def, mkRingHom_def, RingHom.coe_comp, RingHom.coe_mk, MonoidHom.coe_mk,
                 OneHom.coe_mk, Function.comp_apply]
/-- Any ring homomorphism `f : R →+* T` which respects a relation `r : R → R → Prop`
factors uniquely through a morphism `RingQuot r →+* T`.
-/
irreducible_def lift {r : R → R → Prop} :
  { f : R →+* T // ∀ ⦃x y⦄, r x y → f x = f y } ≃ (RingQuot r →+* T) :=
  { toFun := fun f ↦ preLift f.prop
    invFun := fun F ↦ ⟨F.comp (mkRingHom r), fun x y h ↦ congr_arg F (mkRingHom_rel h)⟩
    left_inv := fun f ↦ by
      ext
      simp only [preLift_def, mkRingHom_def, RingHom.coe_comp, RingHom.coe_mk, MonoidHom.coe_mk,
                 OneHom.coe_mk, Function.comp_apply]
    right_inv := fun F ↦ by
      

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
F : RingQuot r →+* T
⊢ (fun f => preLift (_ : ∀ ⦃x y : R⦄, r x y → ↑f x = ↑f y))
      ((fun F =>
          { val := RingHom.comp F (mkRingHom r),
            property := (_ : ∀ (x y : R), r x y → F ((mkRingHom r) x) = F ((mkRingHom r) y)) })
        F) =
    F

Next tactic:
simp only [preLift_def]
@[simp]
theorem lift_mkRingHom_apply (f : R →+* T) {r : R → R → Prop} (w : ∀ ⦃x y⦄, r x y → f x = f y) (x) :
    lift ⟨f, w⟩ (mkRingHom r x) = f x := by
  

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
f : R →+* T
r : R → R → Prop
w : ∀ ⦃x y : R⦄, r x y → f x = f y
x : R
⊢ (lift { val := f, property := w }) ((mkRingHom r) x) = f x

Next tactic:
simp_rw [lift_def, preLift_def, mkRingHom_def]
theorem lift_unique (f : R →+* T) {r : R → R → Prop} (w : ∀ ⦃x y⦄, r x y → f x = f y)
    (g : RingQuot r →+* T) (h : g.comp (mkRingHom r) = f) : g = lift ⟨f, w⟩ := by
  

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
f : R →+* T
r : R → R → Prop
w : ∀ ⦃x y : R⦄, r x y → f x = f y
g : RingQuot r →+* T
h : RingHom.comp g (mkRingHom r) = f
⊢ g = lift { val := f, property := w }

Next tactic:
ext
theorem lift_unique (f : R →+* T) {r : R → R → Prop} (w : ∀ ⦃x y⦄, r x y → f x = f y)
    (g : RingQuot r →+* T) (h : g.comp (mkRingHom r) = f) : g = lift ⟨f, w⟩ := by
  ext
  

Proof state:
case w.a
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
f : R →+* T
r : R → R → Prop
w : ∀ ⦃x y : R⦄, r x y → f x = f y
g : RingQuot r →+* T
h : RingHom.comp g (mkRingHom r) = f
x✝ : R
⊢ (RingHom.comp g (mkRingHom r)) x✝ = (RingHom.comp (lift { val := f, property := w }) (mkRingHom r)) x✝

Next tactic:
simp [h]
theorem eq_lift_comp_mkRingHom {r : R → R → Prop} (f : RingQuot r →+* T) :
    f = lift ⟨f.comp (mkRingHom r), fun x y h ↦ congr_arg f (mkRingHom_rel h)⟩ := by
  

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : RingQuot r →+* T
⊢ f =
    lift
      { val := RingHom.comp f (mkRingHom r),
        property := (_ : ∀ (x y : R), r x y → f ((mkRingHom r) x) = f ((mkRingHom r) y)) }

Next tactic:
conv_lhs => rw [← lift.apply_symm_apply f]
theorem eq_lift_comp_mkRingHom {r : R → R → Prop} (f : RingQuot r →+* T) :
    f = lift ⟨f.comp (mkRingHom r), fun x y h ↦ congr_arg f (mkRingHom_rel h)⟩ := by
  conv_lhs => 

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : RingQuot r →+* T
| f

Next tactic:
rw [← lift.apply_symm_apply f]
theorem eq_lift_comp_mkRingHom {r : R → R → Prop} (f : RingQuot r →+* T) :
    f = lift ⟨f.comp (mkRingHom r), fun x y h ↦ congr_arg f (mkRingHom_rel h)⟩ := by
  conv_lhs => rw [← lift.apply_symm_apply f]
  

Proof state:
R : Type uR
inst✝⁴ : Semiring R
S : Type uS
inst✝³ : CommSemiring S
T : Type uT
A : Type uA
inst✝² : Semiring A
inst✝¹ : Algebra S A
r✝ : R → R → Prop
inst✝ : Semiring T
r : R → R → Prop
f : RingQuot r →+* T
⊢ lift (lift.symm f) =
    lift
      { val := RingHom.comp f (mkRingHom r),
        property := (_ : ∀ (x y : R), r x y → f ((mkRingHom r) x) = f ((mkRingHom r) y)) }

Next tactic:
rw [lift_def]
@[simp]
theorem ringQuotToIdealQuotient_apply (r : B → B → Prop) (x : B) :
    ringQuotToIdealQuotient r (mkRingHom r x) = Ideal.Quotient.mk (Ideal.ofRel r) x := by
  

Proof state:
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
⊢ (ringQuotToIdealQuotient r) ((mkRingHom r) x) = (Ideal.Quotient.mk (Ideal.ofRel r)) x

Next tactic:
simp_rw [ringQuotToIdealQuotient, lift_def, preLift_def, mkRingHom_def]
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      

Proof state:
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
⊢ ∀ a ∈ Ideal.ofRel r, (mkRingHom r) a = 0

Next tactic:
refine' fun x h ↦ Submodule.span_induction h _ _ _ _
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · 

Proof state:
case refine'_1
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h : x ∈ Ideal.ofRel r
⊢ ∀ x ∈ {x | ∃ a b, ∃ (_ : r a b), x + b = a}, (mkRingHom r) x = 0

Next tactic:
rintro y ⟨a, b, h, su⟩
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        

Proof state:
case refine'_1.intro.intro.intro
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h✝ : x ∈ Ideal.ofRel r
y a b : B
h : r a b
su : y + b = a
⊢ (mkRingHom r) y = 0

Next tactic:
symm at su
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        

Proof state:
case refine'_1.intro.intro.intro
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h✝ : x ∈ Ideal.ofRel r
y a b : B
h : r a b
su : a = y + b
⊢ (mkRingHom r) y = 0

Next tactic:
rw [← sub_eq_iff_eq_add] at su
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        rw [← sub_eq_iff_eq_add] at su
        

Proof state:
case refine'_1.intro.intro.intro
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h✝ : x ∈ Ideal.ofRel r
y a b : B
h : r a b
su : a - b = y
⊢ (mkRingHom r) y = 0

Next tactic:
rw [← su, RingHom.map_sub, mkRingHom_rel h, sub_self]
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        rw [← sub_eq_iff_eq_add] at su
        rw [← su, RingHom.map_sub, mkRingHom_rel h, sub_self]
      · 

Proof state:
case refine'_2
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h : x ∈ Ideal.ofRel r
⊢ (mkRingHom r) 0 = 0

Next tactic:
simp
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        rw [← sub_eq_iff_eq_add] at su
        rw [← su, RingHom.map_sub, mkRingHom_rel h, sub_self]
      · simp
      · 

Proof state:
case refine'_3
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h : x ∈ Ideal.ofRel r
⊢ ∀ (x y : B), (mkRingHom r) x = 0 → (mkRingHom r) y = 0 → (mkRingHom r) (x + y) = 0

Next tactic:
intro a b ha hb
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        rw [← sub_eq_iff_eq_add] at su
        rw [← su, RingHom.map_sub, mkRingHom_rel h, sub_self]
      · simp
      · intro a b ha hb
        

Proof state:
case refine'_3
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h : x ∈ Ideal.ofRel r
a b : B
ha : (mkRingHom r) a = 0
hb : (mkRingHom r) b = 0
⊢ (mkRingHom r) (a + b) = 0

Next tactic:
simp [ha, hb]
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        rw [← sub_eq_iff_eq_add] at su
        rw [← su, RingHom.map_sub, mkRingHom_rel h, sub_self]
      · simp
      · intro a b ha hb
        simp [ha, hb]
      · 

Proof state:
case refine'_4
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
h : x ∈ Ideal.ofRel r
⊢ ∀ (a x : B), (mkRingHom r) x = 0 → (mkRingHom r) (a • x) = 0

Next tactic:
intro a x hx
/-- The universal ring homomorphism from `B ⧸ Ideal.ofRel r` to `RingQuot r`. -/
def idealQuotientToRingQuot (r : B → B → Prop) : B ⧸ Ideal.ofRel r →+* RingQuot r :=
  Ideal.Quotient.lift (Ideal.ofRel r) (mkRingHom r)
    (by
      refine' fun x h ↦ Submodule.span_induction h _ _ _ _
      · rintro y ⟨a, b, h, su⟩
        symm at su
        rw [← sub_eq_iff_eq_add] at su
        rw [← su, RingHom.map_sub, mkRingHom_rel h, sub_self]
      · simp
      · intro a b ha hb
        simp [ha, hb]
      · intro a x hx
        

Proof state:
case refine'_4
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x✝ : B
h : x✝ ∈ Ideal.ofRel r
a x : B
hx : (mkRingHom r) x = 0
⊢ (mkRingHom r) (a • x) = 0

Next tactic:
simp [hx]
/-- The ring equivalence between `RingQuot r` and `(Ideal.ofRel r).quotient`
-/
def ringQuotEquivIdealQuotient (r : B → B → Prop) : RingQuot r ≃+* B ⧸ Ideal.ofRel r :=
  RingEquiv.ofHomInv (ringQuotToIdealQuotient r) (idealQuotientToRingQuot r)
    (by
      

Proof state:
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
⊢ RingHom.comp ↑(idealQuotientToRingQuot r) ↑(ringQuotToIdealQuotient r) = RingHom.id (RingQuot r)

Next tactic:
ext x
/-- The ring equivalence between `RingQuot r` and `(Ideal.ofRel r).quotient`
-/
def ringQuotEquivIdealQuotient (r : B → B → Prop) : RingQuot r ≃+* B ⧸ Ideal.ofRel r :=
  RingEquiv.ofHomInv (ringQuotToIdealQuotient r) (idealQuotientToRingQuot r)
    (by
      ext x
      

Proof state:
case w.a
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
⊢ (RingHom.comp (RingHom.comp ↑(idealQuotientToRingQuot r) ↑(ringQuotToIdealQuotient r)) (mkRingHom r)) x =
    (RingHom.comp (RingHom.id (RingQuot r)) (mkRingHom r)) x

Next tactic:
simp_rw [ringQuotToIdealQuotient, lift_def, preLift_def, mkRingHom_def]
/-- The ring equivalence between `RingQuot r` and `(Ideal.ofRel r).quotient`
-/
def ringQuotEquivIdealQuotient (r : B → B → Prop) : RingQuot r ≃+* B ⧸ Ideal.ofRel r :=
  RingEquiv.ofHomInv (ringQuotToIdealQuotient r) (idealQuotientToRingQuot r)
    (by
      ext x
      simp_rw [ringQuotToIdealQuotient, lift_def, preLift_def, mkRingHom_def]
      change mkRingHom r x = _
      

Proof state:
case w.a
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
⊢ (mkRingHom r) x =
    (RingHom.comp (RingHom.id (RingQuot r))
        {
          toMonoidHom :=
            {
              toOneHom :=
                { toFun := fun x => { toQuot := Quot.mk (Rel r) x },
                  map_one' := (_ : { toQuot := Quot.mk (Rel r) 1 } = 1) },
              map_mul' :=
                (_ :
                  ∀ (a a_1 : B),
                    { toQuot := Quot.mk (Rel r) (a * a_1) } =
                      { toQuot := Quot.mk (Rel r) a } * { toQuot := Quot.mk (Rel r) a_1 }) },
          map_zero' := (_ : { toQuot := Quot.mk (Rel r) 0 } = 0),
          map_add' :=
            (_ :
              ∀ (a a_1 : B),
                { toQuot := Quot.mk (Rel r) (a + a_1) } =
                  { toQuot := Quot.mk (Rel r) a } + { toQuot := Quot.mk (Rel r) a_1 }) })
      x

Next tactic:
rw [mkRingHom_def]
/-- The ring equivalence between `RingQuot r` and `(Ideal.ofRel r).quotient`
-/
def ringQuotEquivIdealQuotient (r : B → B → Prop) : RingQuot r ≃+* B ⧸ Ideal.ofRel r :=
  RingEquiv.ofHomInv (ringQuotToIdealQuotient r) (idealQuotientToRingQuot r)
    (by
      ext x
      simp_rw [ringQuotToIdealQuotient, lift_def, preLift_def, mkRingHom_def]
      change mkRingHom r x = _
      rw [mkRingHom_def]
      

Proof state:
case w.a
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
x : B
⊢ {
        toMonoidHom :=
          {
            toOneHom :=
              { toFun := fun x => { toQuot := Quot.mk (Rel r) x },
                map_one' := (_ : { toQuot := Quot.mk (Rel r) 1 } = 1) },
            map_mul' :=
              (_ :
                ∀ (a a_1 : B),
                  { toQuot := Quot.mk (Rel r) (a * a_1) } =
                    { toQuot := Quot.mk (Rel r) a } * { toQuot := Quot.mk (Rel r) a_1 }) },
        map_zero' := (_ : { toQuot := Quot.mk (Rel r) 0 } = 0),
        map_add' :=
          (_ :
            ∀ (a a_1 : B),
              { toQuot := Quot.mk (Rel r) (a + a_1) } =
                { toQuot := Quot.mk (Rel r) a } + { toQuot := Quot.mk (Rel r) a_1 }) }
      x =
    (RingHom.comp (RingHom.id (RingQuot r))
        {
          toMonoidHom :=
            {
              toOneHom :=
                { toFun := fun x => { toQuot := Quot.mk (Rel r) x },
                  map_one' := (_ : { toQuot := Quot.mk (Rel r) 1 } = 1) },
              map_mul' :=
                (_ :
                  ∀ (a a_1 : B),
                    { toQuot := Quot.mk (Rel r) (a * a_1) } =
                      { toQuot := Quot.mk (Rel r) a } * { toQuot := Quot.mk (Rel r) a_1 }) },
          map_zero' := (_ : { toQuot := Quot.mk (Rel r) 0 } = 0),
          map_add' :=
            (_ :
              ∀ (a a_1 : B),
                { toQuot := Quot.mk (Rel r) (a + a_1) } =
                  { toQuot := Quot.mk (Rel r) a } + { toQuot := Quot.mk (Rel r) a_1 }) })
      x

Next tactic:
rfl
/-- The ring equivalence between `RingQuot r` and `(Ideal.ofRel r).quotient`
-/
def ringQuotEquivIdealQuotient (r : B → B → Prop) : RingQuot r ≃+* B ⧸ Ideal.ofRel r :=
  RingEquiv.ofHomInv (ringQuotToIdealQuotient r) (idealQuotientToRingQuot r)
    (by
      ext x
      simp_rw [ringQuotToIdealQuotient, lift_def, preLift_def, mkRingHom_def]
      change mkRingHom r x = _
      rw [mkRingHom_def]
      rfl)
    (by
      

Proof state:
R : Type uR
inst✝⁵ : Semiring R
S : Type uS
inst✝⁴ : CommSemiring S
T : Type uT
A : Type uA
inst✝³ : Semiring A
inst✝² : Algebra S A
r✝ : R → R → Prop
inst✝¹ : Semiring T
B : Type uR
inst✝ : CommRing B
r : B → B → Prop
⊢ RingHom.comp ↑(ringQuotToIdealQuotient r) ↑(idealQuotientToRingQuot r) = RingHom.id (B ⧸ Ideal.ofRel r)

Next tactic:
ext x