l3lab/ntp-mathlib huggingface dataset:
/-- Copy of a non-unital subalgebra with a new `carrier` equal to the old one.
Useful to fix definitional equalities. -/
protected def copy (S : NonUnitalSubalgebra R A) (s : Set A) (hs : s = ↑S) :
    NonUnitalSubalgebra R A :=
  { S.toNonUnitalSubsemiring.copy s hs with
    smul_mem' := fun r a (ha : a ∈ s) => by
      show r • a ∈ s
      rw [hs] at ha ⊢
      

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : NonUnitalNonAssocSemiring A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : NonUnitalNonAssocSemiring C
inst✝² : Module R A
inst✝¹ : Module R B
inst✝ : Module R C
S : NonUnitalSubalgebra R A
s : Set A
hs : s = ↑S
src✝ : NonUnitalSubsemiring A := NonUnitalSubsemiring.copy S.toNonUnitalSubsemiring s hs
r : R
a : A
ha : a ∈ ↑S
⊢ r • a ∈ ↑S

Next tactic:
exact S.smul_mem' r ha
theorem toNonUnitalSubring_injective :
    Function.Injective (toNonUnitalSubring : NonUnitalSubalgebra R A → NonUnitalSubring A) :=
  fun S T h => ext fun x => by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommRing R
inst✝⁵ : NonUnitalNonAssocRing A
inst✝⁴ : NonUnitalNonAssocRing B
inst✝³ : NonUnitalNonAssocRing C
inst✝² : Module R A
inst✝¹ : Module R B
inst✝ : Module R C
S T : NonUnitalSubalgebra R A
h : toNonUnitalSubring S = toNonUnitalSubring T
x : A
⊢ x ∈ S ↔ x ∈ T

Next tactic:
rw [← mem_toNonUnitalSubring, ← mem_toNonUnitalSubring, h]
/-- The forgetful map from `NonUnitalSubalgebra` to `Submodule` as an `OrderEmbedding` -/
def toSubmodule' [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A] :
    NonUnitalSubalgebra R A ↪o Submodule R A where
  toEmbedding :=
    { toFun := fun S => S.toSubmodule
      inj' := fun S T h => ext <| by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝² : CommSemiring R
inst✝¹ : NonUnitalNonAssocSemiring A
inst✝ : Module R A
S T : NonUnitalSubalgebra R A
h : (fun S => toSubmodule S) S = (fun S => toSubmodule S) T
⊢ ∀ (x : A), x ∈ S ↔ x ∈ T

Next tactic:
apply SetLike.ext_iff.1 h
/-- The forgetful map from `NonUnitalSubalgebra` to `NonUnitalSubsemiring` as an
`OrderEmbedding` -/
def toNonUnitalSubsemiring' [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A] :
    NonUnitalSubalgebra R A ↪o NonUnitalSubsemiring A where
  toEmbedding :=
    { toFun := fun S => S.toNonUnitalSubsemiring
      inj' := fun S T h => ext <| by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝² : CommSemiring R
inst✝¹ : NonUnitalNonAssocSemiring A
inst✝ : Module R A
S T : NonUnitalSubalgebra R A
h : (fun S => S.toNonUnitalSubsemiring) S = (fun S => S.toNonUnitalSubsemiring) T
⊢ ∀ (x : A), x ∈ S ↔ x ∈ T

Next tactic:
apply SetLike.ext_iff.1 h
/-- The forgetful map from `NonUnitalSubalgebra` to `NonUnitalSubsemiring` as an
`OrderEmbedding` -/
def toNonUnitalSubring' [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :
    NonUnitalSubalgebra R A ↪o NonUnitalSubring A where
  toEmbedding :=
    { toFun := fun S => S.toNonUnitalSubring
      inj' := fun S T h => ext <| by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝² : CommRing R
inst✝¹ : NonUnitalNonAssocRing A
inst✝ : Module R A
S T : NonUnitalSubalgebra R A
h : (fun S => toNonUnitalSubring S) S = (fun S => toNonUnitalSubring S) T
⊢ ∀ (x : A), x ∈ S ↔ x ∈ T

Next tactic:
apply SetLike.ext_iff.1 h
/-- Transport a non-unital subalgebra via an algebra homomorphism. -/
def map (f : F) (S : NonUnitalSubalgebra R A) : NonUnitalSubalgebra R B :=
  { S.toNonUnitalSubsemiring.map (f : A →ₙ+* B) with
    smul_mem' := fun r b hb => by
      

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : NonUnitalNonAssocSemiring B
inst✝⁴ : NonUnitalNonAssocSemiring C
inst✝³ : Module R A
inst✝² : Module R B
inst✝¹ : Module R C
S✝ : NonUnitalSubalgebra R A
inst✝ : NonUnitalAlgHomClass F R A B
f : F
S : NonUnitalSubalgebra R A
src✝ : NonUnitalSubsemiring B := NonUnitalSubsemiring.map (↑f) S.toNonUnitalSubsemiring
r : R
b : B
hb :
  b ∈
    { toAddSubmonoid := src✝.toAddSubmonoid,
            mul_mem' :=
              (_ :
                ∀ {a b : B},
                  a ∈ src✝.carrier → b ∈ src✝.carrier → a * b ∈ src✝.carrier) }.toAddSubmonoid.toAddSubsemigroup.carrier
⊢ r • b ∈
    { toAddSubmonoid := src✝.toAddSubmonoid,
            mul_mem' :=
              (_ :
                ∀ {a b : B},
                  a ∈ src✝.carrier → b ∈ src✝.carrier → a * b ∈ src✝.carrier) }.toAddSubmonoid.toAddSubsemigroup.carrier

Next tactic:
rcases hb with ⟨a, ha, rfl⟩
/-- Transport a non-unital subalgebra via an algebra homomorphism. -/
def map (f : F) (S : NonUnitalSubalgebra R A) : NonUnitalSubalgebra R B :=
  { S.toNonUnitalSubsemiring.map (f : A →ₙ+* B) with
    smul_mem' := fun r b hb => by
      rcases hb with ⟨a, ha, rfl⟩
      

Proof state:
case intro.intro
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : NonUnitalNonAssocSemiring B
inst✝⁴ : NonUnitalNonAssocSemiring C
inst✝³ : Module R A
inst✝² : Module R B
inst✝¹ : Module R C
S✝ : NonUnitalSubalgebra R A
inst✝ : NonUnitalAlgHomClass F R A B
f : F
S : NonUnitalSubalgebra R A
src✝ : NonUnitalSubsemiring B := NonUnitalSubsemiring.map (↑f) S.toNonUnitalSubsemiring
r : R
a : A
ha : a ∈ ↑S.toNonUnitalSubsemiring
⊢ r • ↑f a ∈
    { toAddSubmonoid := src✝.toAddSubmonoid,
            mul_mem' :=
              (_ :
                ∀ {a b : B},
                  a ∈ src✝.carrier → b ∈ src✝.carrier → a * b ∈ src✝.carrier) }.toAddSubmonoid.toAddSubsemigroup.carrier

Next tactic:
exact map_smul f r a ▸ Set.mem_image_of_mem f (S.smul_mem' r ha)
/-- Range of an `NonUnitalAlgHom` as a non-unital subalgebra. -/
protected def range (φ : F) : NonUnitalSubalgebra R B where
  toNonUnitalSubsemiring := NonUnitalRingHom.srange (φ : A →ₙ+* B)
  smul_mem' := fun r a => by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
φ : F
r : R
a : B
⊢ a ∈ (NonUnitalRingHom.srange ↑φ).toAddSubmonoid.toAddSubsemigroup.carrier →
    r • a ∈ (NonUnitalRingHom.srange ↑φ).toAddSubmonoid.toAddSubsemigroup.carrier

Next tactic:
rintro ⟨a, rfl⟩
/-- Range of an `NonUnitalAlgHom` as a non-unital subalgebra. -/
protected def range (φ : F) : NonUnitalSubalgebra R B where
  toNonUnitalSubsemiring := NonUnitalRingHom.srange (φ : A →ₙ+* B)
  smul_mem' := fun r a => by rintro ⟨a, rfl⟩; 

Proof state:
case intro
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
φ : F
r : R
a : A
⊢ r • ↑φ a ∈ (NonUnitalRingHom.srange ↑φ).toAddSubmonoid.toAddSubsemigroup.carrier

Next tactic:
exact ⟨r • a, map_smul φ r a⟩
@[simp]
theorem coe_range (φ : F) :
    ((NonUnitalAlgHom.range φ : NonUnitalSubalgebra R B) : Set B) = Set.range (φ : A → B) := by
  

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
φ : F
⊢ ↑(NonUnitalAlgHom.range φ) = Set.range ⇑φ

Next tactic:
ext
@[simp]
theorem coe_range (φ : F) :
    ((NonUnitalAlgHom.range φ : NonUnitalSubalgebra R B) : Set B) = Set.range (φ : A → B) := by
  ext
  

Proof state:
case h
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
φ : F
x✝ : B
⊢ x✝ ∈ ↑(NonUnitalAlgHom.range φ) ↔ x✝ ∈ Set.range ⇑φ

Next tactic:
rw [SetLike.mem_coe, mem_range]
@[simp]
theorem coe_range (φ : F) :
    ((NonUnitalAlgHom.range φ : NonUnitalSubalgebra R B) : Set B) = Set.range (φ : A → B) := by
  ext
  rw [SetLike.mem_coe, mem_range]
  

Proof state:
case h
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
φ : F
x✝ : B
⊢ (∃ x, φ x = x✝) ↔ x✝ ∈ Set.range ⇑φ

Next tactic:
rfl
/-- The equalizer of two non-unital `R`-algebra homomorphisms -/
def equalizer (ϕ ψ : F) : NonUnitalSubalgebra R A
    where
  carrier := {a | (ϕ a : B) = ψ a}
  zero_mem' := by rw [Set.mem_setOf_eq, map_zero, map_zero]
  add_mem' {x y} (hx : ϕ x = ψ x) (hy : ϕ y = ψ y) := by
    

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
ϕ ψ : F
x y : A
hx : ϕ x = ψ x
hy : ϕ y = ψ y
⊢ x + y ∈ {a | ϕ a = ψ a}

Next tactic:
rw [Set.mem_setOf_eq, map_add, map_add, hx, hy]
/-- The equalizer of two non-unital `R`-algebra homomorphisms -/
def equalizer (ϕ ψ : F) : NonUnitalSubalgebra R A
    where
  carrier := {a | (ϕ a : B) = ψ a}
  zero_mem' := by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
ϕ ψ : F
⊢ 0 ∈
    { carrier := {a | ϕ a = ψ a},
        add_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x + y ∈ {a | ϕ a = ψ a}) }.carrier

Next tactic:
rw [Set.mem_setOf_eq, map_zero, map_zero]
/-- The equalizer of two non-unital `R`-algebra homomorphisms -/
def equalizer (ϕ ψ : F) : NonUnitalSubalgebra R A
    where
  carrier := {a | (ϕ a : B) = ψ a}
  zero_mem' := by rw [Set.mem_setOf_eq, map_zero, map_zero]
  add_mem' {x y} (hx : ϕ x = ψ x) (hy : ϕ y = ψ y) := by
    rw [Set.mem_setOf_eq, map_add, map_add, hx, hy]
  mul_mem' {x y} (hx : ϕ x = ψ x) (hy : ϕ y = ψ y) := by
    

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
ϕ ψ : F
x y : A
hx : ϕ x = ψ x
hy : ϕ y = ψ y
⊢ x * y ∈
    {
          toAddSubsemigroup :=
            { carrier := {a | ϕ a = ψ a},
              add_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x + y ∈ {a | ϕ a = ψ a}) },
          zero_mem' :=
            (_ :
              0 ∈
                { carrier := {a | ϕ a = ψ a},
                    add_mem' :=
                      (_ :
                        ∀ {x y : A},
                          ϕ x = ψ x → ϕ y = ψ y → x + y ∈ {a | ϕ a = ψ a}) }.carrier) }.toAddSubsemigroup.carrier

Next tactic:
rw [Set.mem_setOf_eq, map_mul, map_mul, hx, hy]
/-- The equalizer of two non-unital `R`-algebra homomorphisms -/
def equalizer (ϕ ψ : F) : NonUnitalSubalgebra R A
    where
  carrier := {a | (ϕ a : B) = ψ a}
  zero_mem' := by rw [Set.mem_setOf_eq, map_zero, map_zero]
  add_mem' {x y} (hx : ϕ x = ψ x) (hy : ϕ y = ψ y) := by
    rw [Set.mem_setOf_eq, map_add, map_add, hx, hy]
  mul_mem' {x y} (hx : ϕ x = ψ x) (hy : ϕ y = ψ y) := by
    rw [Set.mem_setOf_eq, map_mul, map_mul, hx, hy]
  smul_mem' r x (hx : ϕ x = ψ x) := by 

Proof state:
F : Type v'
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁷ : CommSemiring R
inst✝⁶ : NonUnitalNonAssocSemiring A
inst✝⁵ : Module R A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : NonUnitalNonAssocSemiring C
inst✝¹ : Module R C
inst✝ : NonUnitalAlgHomClass F R A B
ϕ ψ : F
r : R
x : A
hx : ϕ x = ψ x
⊢ r • x ∈
    {
            toAddSubmonoid :=
              {
                toAddSubsemigroup :=
                  { carrier := {a | ϕ a = ψ a},
                    add_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x + y ∈ {a | ϕ a = ψ a}) },
                zero_mem' :=
                  (_ :
                    0 ∈
                      { carrier := {a | ϕ a = ψ a},
                          add_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x + y ∈ {a | ϕ a = ψ a}) }.carrier) },
            mul_mem' :=
              (_ :
                ∀ {x y : A},
                  ϕ x = ψ x →
                    ϕ y = ψ y →
                      x * y ∈
                        {
                              toAddSubsemigroup :=
                                { carrier := {a | ϕ a = ψ a},
                                  add_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x + y ∈ {a | ϕ a = ψ a}) },
                              zero_mem' :=
                                (_ :
                                  0 ∈
                                    { carrier := {a | ϕ a = ψ a},
                                        add_mem' :=
                                          (_ :
                                            ∀ {x y : A},
                                              ϕ x = ψ x →
                                                ϕ y = ψ y →
                                                  x + y ∈
                                                    {a |
                                                      ϕ a =
                                                        ψ
                                                          a}) }.carrier) }.toAddSubsemigroup.carrier) }.toAddSubmonoid.toAddSubsemigroup.carrier

Next tactic:
rw [Set.mem_setOf_eq, map_smul, map_smul, hx]
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalSubalgebra R A :=
  { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with
    mul_mem' :=
      @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A))
        (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) =>
      show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by
        

Proof state:
F : Type u_1
R : Type u
A : Type v
B : Type w
inst✝⁹ : CommSemiring R
inst✝⁸ : NonUnitalNonAssocSemiring A
inst✝⁷ : Module R A
inst✝⁶ : IsScalarTower R A A
inst✝⁵ : SMulCommClass R A A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : IsScalarTower R B B
inst✝¹ : SMulCommClass R B B
inst✝ : NonUnitalAlgHomClass F R A B
s : Set A
src✝ : Submodule R A := Submodule.span R ↑(NonUnitalSubsemiring.closure s)
a b : A
ha : a ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
hb : b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
⊢ a * b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)

Next tactic:
refine' Submodule.span_induction ha _ _ _ _
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalSubalgebra R A :=
  { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with
    mul_mem' :=
      @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A))
        (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) =>
      show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by
        refine' Submodule.span_induction ha _ _ _ _
        · 

Proof state:
case refine'_1
F : Type u_1
R : Type u
A : Type v
B : Type w
inst✝⁹ : CommSemiring R
inst✝⁸ : NonUnitalNonAssocSemiring A
inst✝⁷ : Module R A
inst✝⁶ : IsScalarTower R A A
inst✝⁵ : SMulCommClass R A A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : IsScalarTower R B B
inst✝¹ : SMulCommClass R B B
inst✝ : NonUnitalAlgHomClass F R A B
s : Set A
src✝ : Submodule R A := Submodule.span R ↑(NonUnitalSubsemiring.closure s)
a b : A
ha : a ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
hb : b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
⊢ ∀ x ∈ ↑(NonUnitalSubsemiring.closure s), x * b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)

Next tactic:
refine' Submodule.span_induction hb _ _ _ _
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalSubalgebra R A :=
  { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with
    mul_mem' :=
      @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A))
        (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) =>
      show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by
        refine' Submodule.span_induction ha _ _ _ _
        · refine' Submodule.span_induction hb _ _ _ _
          · 

Proof state:
case refine'_1.refine'_1
F : Type u_1
R : Type u
A : Type v
B : Type w
inst✝⁹ : CommSemiring R
inst✝⁸ : NonUnitalNonAssocSemiring A
inst✝⁷ : Module R A
inst✝⁶ : IsScalarTower R A A
inst✝⁵ : SMulCommClass R A A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : IsScalarTower R B B
inst✝¹ : SMulCommClass R B B
inst✝ : NonUnitalAlgHomClass F R A B
s : Set A
src✝ : Submodule R A := Submodule.span R ↑(NonUnitalSubsemiring.closure s)
a b : A
ha : a ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
hb : b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
⊢ ∀ x ∈ ↑(NonUnitalSubsemiring.closure s),
    ∀ x_1 ∈ ↑(NonUnitalSubsemiring.closure s), x_1 * x ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)

Next tactic:
exact fun x (hx : x ∈ NonUnitalSubsemiring.closure s) y
              (hy : y ∈ NonUnitalSubsemiring.closure s) => Submodule.subset_span (mul_mem hy hx)
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalSubalgebra R A :=
  { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with
    mul_mem' :=
      @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A))
        (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) =>
      show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by
        refine' Submodule.span_induction ha _ _ _ _
        · refine' Submodule.span_induction hb _ _ _ _
          · exact fun x (hx : x ∈ NonUnitalSubsemiring.closure s) y
              (hy : y ∈ NonUnitalSubsemiring.closure s) => Submodule.subset_span (mul_mem hy hx)
          · 

Proof state:
case refine'_1.refine'_2
F : Type u_1
R : Type u
A : Type v
B : Type w
inst✝⁹ : CommSemiring R
inst✝⁸ : NonUnitalNonAssocSemiring A
inst✝⁷ : Module R A
inst✝⁶ : IsScalarTower R A A
inst✝⁵ : SMulCommClass R A A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : IsScalarTower R B B
inst✝¹ : SMulCommClass R B B
inst✝ : NonUnitalAlgHomClass F R A B
s : Set A
src✝ : Submodule R A := Submodule.span R ↑(NonUnitalSubsemiring.closure s)
a b : A
ha : a ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
hb : b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
⊢ ∀ x ∈ ↑(NonUnitalSubsemiring.closure s), x * 0 ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)

Next tactic:
exact fun x _hx => (mul_zero x).symm ▸ Submodule.zero_mem _
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalSubalgebra R A :=
  { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with
    mul_mem' :=
      @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A))
        (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) =>
      show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by
        refine' Submodule.span_induction ha _ _ _ _
        · refine' Submodule.span_induction hb _ _ _ _
          · exact fun x (hx : x ∈ NonUnitalSubsemiring.closure s) y
              (hy : y ∈ NonUnitalSubsemiring.closure s) => Submodule.subset_span (mul_mem hy hx)
          · exact fun x _hx => (mul_zero x).symm ▸ Submodule.zero_mem _
          · 

Proof state:
case refine'_1.refine'_3
F : Type u_1
R : Type u
A : Type v
B : Type w
inst✝⁹ : CommSemiring R
inst✝⁸ : NonUnitalNonAssocSemiring A
inst✝⁷ : Module R A
inst✝⁶ : IsScalarTower R A A
inst✝⁵ : SMulCommClass R A A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : IsScalarTower R B B
inst✝¹ : SMulCommClass R B B
inst✝ : NonUnitalAlgHomClass F R A B
s : Set A
src✝ : Submodule R A := Submodule.span R ↑(NonUnitalSubsemiring.closure s)
a b : A
ha : a ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
hb : b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
⊢ ∀ (x y : A),
    (∀ x_1 ∈ ↑(NonUnitalSubsemiring.closure s), x_1 * x ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)) →
      (∀ x ∈ ↑(NonUnitalSubsemiring.closure s), x * y ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)) →
        ∀ x_1 ∈ ↑(NonUnitalSubsemiring.closure s), x_1 * (x + y) ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)

Next tactic:
exact fun x y hx hy z hz => (mul_add z x y).symm ▸ add_mem (hx z hz) (hy z hz)
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalSubalgebra R A :=
  { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with
    mul_mem' :=
      @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A))
        (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) =>
      show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by
        refine' Submodule.span_induction ha _ _ _ _
        · refine' Submodule.span_induction hb _ _ _ _
          · exact fun x (hx : x ∈ NonUnitalSubsemiring.closure s) y
              (hy : y ∈ NonUnitalSubsemiring.closure s) => Submodule.subset_span (mul_mem hy hx)
          · exact fun x _hx => (mul_zero x).symm ▸ Submodule.zero_mem _
          · exact fun x y hx hy z hz => (mul_add z x y).symm ▸ add_mem (hx z hz) (hy z hz)
          · 

Proof state:
case refine'_1.refine'_4
F : Type u_1
R : Type u
A : Type v
B : Type w
inst✝⁹ : CommSemiring R
inst✝⁸ : NonUnitalNonAssocSemiring A
inst✝⁷ : Module R A
inst✝⁶ : IsScalarTower R A A
inst✝⁵ : SMulCommClass R A A
inst✝⁴ : NonUnitalNonAssocSemiring B
inst✝³ : Module R B
inst✝² : IsScalarTower R B B
inst✝¹ : SMulCommClass R B B
inst✝ : NonUnitalAlgHomClass F R A B
s : Set A
src✝ : Submodule R A := Submodule.span R ↑(NonUnitalSubsemiring.closure s)
a b : A
ha : a ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
hb : b ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)
⊢ ∀ (a : R) (x : A),
    (∀ x_1 ∈ ↑(NonUnitalSubsemiring.closure s), x_1 * x ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)) →
      ∀ x_1 ∈ ↑(NonUnitalSubsemiring.closure s), x_1 * a • x ∈ Submodule.span R ↑(NonUnitalSubsemiring.closure s)

Next tactic:
exact fun r x hx y hy => (mul_smul_comm r y x).symm ▸ SMulMemClass.smul_mem r (hx y hy)