l3lab/ntp-mathlib huggingface dataset:
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
  refine' { toFun := id.. } <;> 

Proof state:
case refine'_2
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } 0 = 0

Next tactic:
intros
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
  refine' { toFun := id.. } <;> 

Proof state:
case refine'_3
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ ∀ (x y : α),
    MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } (x + y) =
      MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } x +
        MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } y

Next tactic:
intros
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
  refine' { toFun := id.. } <;> intros <;> 

Proof state:
case refine'_1
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
x✝ y✝ : α
⊢ id (x✝ * y✝) = id x✝ * id y✝

Next tactic:
rfl
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
  refine' { toFun := id.. } <;> intros <;> 

Proof state:
case refine'_2
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } 0 = 0

Next tactic:
rfl
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
  refine' { toFun := id.. } <;> intros <;> 

Proof state:
case refine'_3
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
x✝ y✝ : α
⊢ MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } (x✝ + y✝) =
    MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } x✝ +
      MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } y✝

Next tactic:
rfl
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g✝ : β →ₙ+* γ
f : α →ₙ+* β
g : β →ₙ+* γ
⊢ comp g 0 = 0

Next tactic:
ext
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
  ext
  

Proof state:
case a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g✝ : β →ₙ+* γ
f : α →ₙ+* β
g : β →ₙ+* γ
x✝ : α
⊢ (comp g 0) x✝ = 0 x✝

Next tactic:
simp
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g : β →ₙ+* γ
f✝ f : α →ₙ+* β
⊢ comp 0 f = 0

Next tactic:
ext
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
  ext
  

Proof state:
case a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g : β →ₙ+* γ
f✝ f : α →ₙ+* β
x✝ : α
⊢ (comp 0 f) x✝ = 0 x✝

Next tactic:
rfl
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
    g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
  ⟨fun h => ext fun x => hg <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g✝ : β →ₙ+* γ
f : α →ₙ+* β
g : β →ₙ+* γ
f₁ f₂ : α →ₙ+* β
hg : Injective ⇑g
h : comp g f₁ = comp g f₂
x : α
⊢ g (f₁ x) = g (f₂ x)

Next tactic:
rw [← comp_apply, h, comp_apply]
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
    (f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonAssocSemiring α
inst✝¹ : NonAssocSemiring β
inst✝ : RingHomClass F α β
f : F
a : α
⊢ f (bit1 a) = bit1 (f a)

Next tactic:
simp [bit1]
instance instRingHomClass : RingHomClass (α →+* β) α β where
  coe f := f.toFun
  coe_injective' f g h := by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f g : α →+* β
h : (fun f => f.toFun) f = (fun f => f.toFun) g
⊢ f = g

Next tactic:
cases f
instance instRingHomClass : RingHomClass (α →+* β) α β where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    

Proof state:
case mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
g : α →+* β
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
  (fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } =
    (fun f => f.toFun) g
⊢ { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } = g

Next tactic:
cases g
instance instRingHomClass : RingHomClass (α →+* β) α β where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    cases g
    

Proof state:
case mk.mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
toMonoidHom✝¹ : α →* β
map_zero'✝¹ : OneHom.toFun (↑toMonoidHom✝¹) 0 = 0
map_add'✝¹ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝¹) (x + y) = OneHom.toFun (↑toMonoidHom✝¹) x + OneHom.toFun (↑toMonoidHom✝¹) y
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
  (fun f => f.toFun) { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
    (fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
    { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }

Next tactic:
congr
instance instRingHomClass : RingHomClass (α →+* β) α β where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    cases g
    congr
    

Proof state:
case mk.mk.e_toMonoidHom
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
toMonoidHom✝¹ : α →* β
map_zero'✝¹ : OneHom.toFun (↑toMonoidHom✝¹) 0 = 0
map_add'✝¹ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝¹) (x + y) = OneHom.toFun (↑toMonoidHom✝¹) x + OneHom.toFun (↑toMonoidHom✝¹) y
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
  (fun f => f.toFun) { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
    (fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ toMonoidHom✝¹ = toMonoidHom✝

Next tactic:
apply FunLike.coe_injective'
instance instRingHomClass : RingHomClass (α →+* β) α β where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    cases g
    congr
    apply FunLike.coe_injective'
    

Proof state:
case mk.mk.e_toMonoidHom.a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
toMonoidHom✝¹ : α →* β
map_zero'✝¹ : OneHom.toFun (↑toMonoidHom✝¹) 0 = 0
map_add'✝¹ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝¹) (x + y) = OneHom.toFun (↑toMonoidHom✝¹) x + OneHom.toFun (↑toMonoidHom✝¹) y
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
  (fun f => f.toFun) { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
    (fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ ⇑toMonoidHom✝¹ = ⇑toMonoidHom✝

Next tactic:
exact h
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f : α →+* β
⊢ ⇑(toMonoidWithZeroHom f) = ⇑f

Next tactic:
rfl
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
    f (ite p 0 1) = ite p 0 1 := by
  

Proof state:
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
⊢ f (if p then 0 else 1) = if p then 0 else 1

Next tactic:
split_ifs with h
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
    f (ite p 0 1) = ite p 0 1 := by
  split_ifs with h <;> 

Proof state:
case pos
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : p
⊢ f 0 = 0

Next tactic:
simp [h]
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
    f (ite p 0 1) = ite p 0 1 := by
  split_ifs with h <;> 

Proof state:
case neg
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : ¬p
⊢ f 1 = 1

Next tactic:
simp [h]
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
    f (ite p 1 0) = ite p 1 0 := by
  

Proof state:
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
⊢ f (if p then 1 else 0) = if p then 1 else 0

Next tactic:
split_ifs with h
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
    f (ite p 1 0) = ite p 1 0 := by
  split_ifs with h <;> 

Proof state:
case pos
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : p
⊢ f 1 = 1

Next tactic:
simp [h]
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
    f (ite p 1 0) = ite p 1 0 := by
  split_ifs with h <;> 

Proof state:
case neg
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : ¬p
⊢ f 0 = 0

Next tactic:
simp [h]
/-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f : α →+* β
x y : α
⊢ 0 = 1 ↔ f 1 = 0

Next tactic:
rw [map_one, eq_comm]
/-- `f : α →+* β` has a trivial codomain iff it has a trivial range. -/
theorem codomain_trivial_iff_range_trivial : (0 : β) = 1 ↔ ∀ x, f x = 0 :=
  f.codomain_trivial_iff_map_one_eq_zero.trans
    ⟨fun h x => by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝² : NonAssocSemiring α
x✝¹ : NonAssocSemiring β
f : α →+* β
x✝ y : α
h : f 1 = 0
x : α
⊢ f x = 0

Next tactic:
rw [← mul_one x, map_mul, h, mul_zero]
/-- If there is a homomorphism `f : α →+* β` and `β` is nontrivial, then `α` is nontrivial. -/
theorem domain_nontrivial [Nontrivial β] : Nontrivial α :=
  ⟨⟨1, 0, mt (fun h => show f 1 = 0 by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f : α →+* β
x y : α
inst✝ : Nontrivial β
h : 1 = 0
⊢ f 1 = 0

Next tactic:
rw [h, map_zero]
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  

Proof state:
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ α →+* α

Next tactic:
refine' { toFun := _root_.id.. }
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> 

Proof state:
case refine'_1
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ _root_.id 1 = 1

Next tactic:
intros
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> 

Proof state:
case refine'_2
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ ∀ (x y : α),
    OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } (x * y) =
      OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } x *
        OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } y

Next tactic:
intros
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> 

Proof state:
case refine'_3
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ OneHom.toFun
      (↑{ toOneHom := { toFun := _root_.id, map_one' := ?refine'_1 },
          map_mul' :=
            (_ :
              ∀ (x y : α),
                OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } (x * y) =
                  OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } x *
                    OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } y) })
      0 =
    0

Next tactic:
intros
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> 

Proof state:
case refine'_4
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ ∀ (x y : α),
    OneHom.toFun
        (↑{ toOneHom := { toFun := _root_.id, map_one' := ?refine'_1 },
            map_mul' :=
              (_ :
                ∀ (x y : α),
                  OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } (x * y) =
                    OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } x *
                      OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } y) })
        (x + y) =
      OneHom.toFun
          (↑{ toOneHom := { toFun := _root_.id, map_one' := ?refine'_1 },
              map_mul' :=
                (_ :
                  ∀ (x y : α),
                    OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } (x * y) =
                      OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } x *
                        OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } y) })
          x +
        OneHom.toFun
          (↑{ toOneHom := { toFun := _root_.id, map_one' := ?refine'_1 },
              map_mul' :=
                (_ :
                  ∀ (x y : α),
                    OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } (x * y) =
                      OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } x *
                        OneHom.toFun { toFun := _root_.id, map_one' := ?refine'_1 } y) })
          y

Next tactic:
intros
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> intros <;> 

Proof state:
case refine'_1
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ _root_.id 1 = 1

Next tactic:
rfl
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> intros <;> 

Proof state:
case refine'_2
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝² : NonAssocSemiring α✝
x✝¹ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
x✝ y✝ : α
⊢ OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x✝ * y✝) =
    OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } x✝ *
      OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } y✝

Next tactic:
rfl
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> intros <;> 

Proof state:
case refine'_3
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α✝
x✝ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
⊢ OneHom.toFun
      (↑{ toOneHom := { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) },
          map_mul' :=
            (_ :
              ∀ (x y : α),
                OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y) =
                  OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y)) })
      0 =
    0

Next tactic:
rfl
/-- The identity ring homomorphism from a semiring to itself. -/
def id (α : Type*) [NonAssocSemiring α] : α →+* α := by
  refine' { toFun := _root_.id.. } <;> intros <;> 

Proof state:
case refine'_4
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
x✝² : NonAssocSemiring α✝
x✝¹ : NonAssocSemiring β
α : Type u_5
inst✝ : NonAssocSemiring α
x✝ y✝ : α
⊢ OneHom.toFun
      (↑{ toOneHom := { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) },
          map_mul' :=
            (_ :
              ∀ (x y : α),
                OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y) =
                  OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y)) })
      (x✝ + y✝) =
    OneHom.toFun
        (↑{ toOneHom := { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) },
            map_mul' :=
              (_ :
                ∀ (x y : α),
                  OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y) =
                    OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y)) })
        x✝ +
      OneHom.toFun
        (↑{ toOneHom := { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) },
            map_mul' :=
              (_ :
                ∀ (x y : α),
                  OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y) =
                    OneHom.toFun { toFun := _root_.id, map_one' := (_ : _root_.id 1 = _root_.id 1) } (x * y)) })
        y✝

Next tactic:
rfl
/-- Composition of ring homomorphisms is a ring homomorphism. -/
def comp (g : β →+* γ) (f : α →+* β) : α →+* γ :=
  { g.toNonUnitalRingHom.comp f.toNonUnitalRingHom with toFun := g ∘ f, map_one' := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝² : NonAssocSemiring α
x✝¹ : NonAssocSemiring β
x✝ : NonAssocSemiring γ
g : β →+* γ
f : α →+* β
src✝ : α →ₙ+* γ := NonUnitalRingHom.comp (toNonUnitalRingHom g) (toNonUnitalRingHom f)
⊢ (⇑g ∘ ⇑f) 1 = 1

Next tactic:
simp
@[simp]
theorem cancel_left {g : β →+* γ} {f₁ f₂ : α →+* β} (hg : Injective g) :
    g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
  ⟨fun h => RingHom.ext fun x => hg <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝² : NonAssocSemiring α
x✝¹ : NonAssocSemiring β
x✝ : NonAssocSemiring γ
g : β →+* γ
f₁ f₂ : α →+* β
hg : Injective ⇑g
h : comp g f₁ = comp g f₂
x : α
⊢ g (f₁ x) = g (f₂ x)

Next tactic:
rw [← comp_apply, h, comp_apply]
/-- Make a ring homomorphism from an additive group homomorphism from a commutative ring to an
integral domain that commutes with self multiplication, assumes that two is nonzero and `1` is sent
to `1`. -/
def mkRingHomOfMulSelfOfTwoNeZero (h : ∀ x, f (x * x) = f x * f x) (h_two : (2 : α) ≠ 0)
    (h_one : f 1 = 1) : β →+* α :=
  { f with
    map_one' := h_one,
    map_mul' := fun x y => by
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CommRing α
inst✝¹ : IsDomain α
inst✝ : CommRing β
f : β →+ α
h : ∀ (x : β), f (x * x) = f x * f x
h_two : 2 ≠ 0
h_one : f 1 = 1
x y : β
⊢ OneHom.toFun { toFun := f.toFun, map_one' := h_one } (x * y) =
    OneHom.toFun { toFun := f.toFun, map_one' := h_one } x * OneHom.toFun { toFun := f.toFun, map_one' := h_one } y

Next tactic:
have hxy := h (x + y)
/-- Make a ring homomorphism from an additive group homomorphism from a commutative ring to an
integral domain that commutes with self multiplication, assumes that two is nonzero and `1` is sent
to `1`. -/
def mkRingHomOfMulSelfOfTwoNeZero (h : ∀ x, f (x * x) = f x * f x) (h_two : (2 : α) ≠ 0)
    (h_one : f 1 = 1) : β →+* α :=
  { f with
    map_one' := h_one,
    map_mul' := fun x y => by
      have hxy := h (x + y)
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CommRing α
inst✝¹ : IsDomain α
inst✝ : CommRing β
f : β →+ α
h : ∀ (x : β), f (x * x) = f x * f x
h_two : 2 ≠ 0
h_one : f 1 = 1
x y : β
hxy : f ((x + y) * (x + y)) = f (x + y) * f (x + y)
⊢ OneHom.toFun { toFun := f.toFun, map_one' := h_one } (x * y) =
    OneHom.toFun { toFun := f.toFun, map_one' := h_one } x * OneHom.toFun { toFun := f.toFun, map_one' := h_one } y

Next tactic:
rw [mul_add, add_mul, add_mul, f.map_add, f.map_add, f.map_add, f.map_add, h x, h y, add_mul,
        mul_add, mul_add, ← sub_eq_zero, add_comm (f x * f x + f (y * x)), ← sub_sub, ← sub_sub,
        ← sub_sub, mul_comm y x, mul_comm (f y) (f x)] at hxy