l3lab/ntp-mathlib huggingface dataset:
theorem toSubsemiring_injective :
    Function.Injective (toSubsemiring : Subalgebra R A → Subsemiring A) := fun S T h =>
  ext fun x => by 

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
S T : Subalgebra R A
h : S.toSubsemiring = T.toSubsemiring
x : A
⊢ x ∈ S ↔ x ∈ T

Next tactic:
rw [← mem_toSubsemiring, ← mem_toSubsemiring, h]
theorem toSubring_injective {R : Type u} {A : Type v} [CommRing R] [Ring A] [Algebra R A] :
    Function.Injective (toSubring : Subalgebra R A → Subring A) := fun S T h =>
  ext fun x => by 

Proof state:
R' : Type u'
R✝ : Type u
A✝ : Type v
B : Type w
C : Type w'
inst✝⁹ : CommSemiring R✝
inst✝⁸ : Semiring A✝
inst✝⁷ : Algebra R✝ A✝
inst✝⁶ : Semiring B
inst✝⁵ : Algebra R✝ B
inst✝⁴ : Semiring C
inst✝³ : Algebra R✝ C
S✝ : Subalgebra R✝ A✝
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S T : Subalgebra R A
h : toSubring S = toSubring T
x : A
⊢ x ∈ S ↔ x ∈ T

Next tactic:
rw [← mem_toSubring, ← mem_toSubring, h]
instance algebra' [CommSemiring R'] [SMul R' R] [Algebra R' A] [IsScalarTower R' R A] :
    Algebra R' S :=
  { (algebraMap R' A).codRestrict S fun x => by
      

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝¹⁰ : CommSemiring R
inst✝⁹ : Semiring A
inst✝⁸ : Algebra R A
inst✝⁷ : Semiring B
inst✝⁶ : Algebra R B
inst✝⁵ : Semiring C
inst✝⁴ : Algebra R C
S : Subalgebra R A
inst✝³ : CommSemiring R'
inst✝² : SMul R' R
inst✝¹ : Algebra R' A
inst✝ : IsScalarTower R' R A
x : R'
⊢ (algebraMap R' A) x ∈ S

Next tactic:
rw [Algebra.algebraMap_eq_smul_one, ← smul_one_smul R x (1 : A), ←
        Algebra.algebraMap_eq_smul_one]
instance algebra' [CommSemiring R'] [SMul R' R] [Algebra R' A] [IsScalarTower R' R A] :
    Algebra R' S :=
  { (algebraMap R' A).codRestrict S fun x => by
      rw [Algebra.algebraMap_eq_smul_one, ← smul_one_smul R x (1 : A), ←
        Algebra.algebraMap_eq_smul_one]
      

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝¹⁰ : CommSemiring R
inst✝⁹ : Semiring A
inst✝⁸ : Algebra R A
inst✝⁷ : Semiring B
inst✝⁶ : Algebra R B
inst✝⁵ : Semiring C
inst✝⁴ : Algebra R C
S : Subalgebra R A
inst✝³ : CommSemiring R'
inst✝² : SMul R' R
inst✝¹ : Algebra R' A
inst✝ : IsScalarTower R' R A
x : R'
⊢ (algebraMap R A) (x • 1) ∈ S

Next tactic:
exact algebraMap_mem S
          _
/-- A submodule containing `1` and closed under multiplication is a subalgebra. -/
def toSubalgebra (p : Submodule R A) (h_one : (1 : A) ∈ p)
    (h_mul : ∀ x y, x ∈ p → y ∈ p → x * y ∈ p) : Subalgebra R A :=
  { p with
    mul_mem' := fun hx hy ↦ h_mul _ _ hx hy
    one_mem' := h_one
    algebraMap_mem' := fun r => by
      

Proof state:
R : Type u_1
A : Type u_2
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
p✝ p : Submodule R A
h_one : 1 ∈ p
h_mul : ∀ (x y : A), x ∈ p → y ∈ p → x * y ∈ p
r : R
⊢ (algebraMap R A) r ∈
    {
            toSubmonoid :=
              {
                toSubsemigroup :=
                  { carrier := p.carrier, mul_mem' := (_ : ∀ {a b : A}, a ∈ p.carrier → b ∈ p.carrier → a * b ∈ p) },
                one_mem' := h_one },
            add_mem' := (_ : ∀ {a b : A}, a ∈ p.carrier → b ∈ p.carrier → a + b ∈ p.carrier),
            zero_mem' := (_ : 0 ∈ p.carrier) }.toSubmonoid.toSubsemigroup.carrier

Next tactic:
rw [Algebra.algebraMap_eq_smul_one]
/-- A submodule containing `1` and closed under multiplication is a subalgebra. -/
def toSubalgebra (p : Submodule R A) (h_one : (1 : A) ∈ p)
    (h_mul : ∀ x y, x ∈ p → y ∈ p → x * y ∈ p) : Subalgebra R A :=
  { p with
    mul_mem' := fun hx hy ↦ h_mul _ _ hx hy
    one_mem' := h_one
    algebraMap_mem' := fun r => by
      rw [Algebra.algebraMap_eq_smul_one]
      

Proof state:
R : Type u_1
A : Type u_2
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
p✝ p : Submodule R A
h_one : 1 ∈ p
h_mul : ∀ (x y : A), x ∈ p → y ∈ p → x * y ∈ p
r : R
⊢ r • 1 ∈
    {
            toSubmonoid :=
              {
                toSubsemigroup :=
                  { carrier := p.carrier, mul_mem' := (_ : ∀ {a b : A}, a ∈ p.carrier → b ∈ p.carrier → a * b ∈ p) },
                one_mem' := h_one },
            add_mem' := (_ : ∀ {a b : A}, a ∈ p.carrier → b ∈ p.carrier → a + b ∈ p.carrier),
            zero_mem' := (_ : 0 ∈ p.carrier) }.toSubmonoid.toSubsemigroup.carrier

Next tactic:
exact p.smul_mem _ h_one
theorem toSubalgebra_mk (s : Submodule R A) (h1 hmul) :
    s.toSubalgebra h1 hmul =
      Subalgebra.mk ⟨⟨⟨s, @hmul⟩, h1⟩, s.add_mem, s.zero_mem⟩
        (by 

Proof state:
R : Type u_1
A : Type u_2
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
p s : Submodule R A
h1 : 1 ∈ s
hmul : ∀ (x y : A), x ∈ s → y ∈ s → x * y ∈ s
⊢ ∀ (r : R),
    (algebraMap R A) r ∈
      { toSubmonoid := { toSubsemigroup := { carrier := ↑s, mul_mem' := hmul }, one_mem' := h1 },
              add_mem' := (_ : ∀ {a b : A}, a ∈ s → b ∈ s → a + b ∈ s),
              zero_mem' := (_ : 0 ∈ s) }.toSubmonoid.toSubsemigroup.carrier

Next tactic:
intro r
theorem toSubalgebra_mk (s : Submodule R A) (h1 hmul) :
    s.toSubalgebra h1 hmul =
      Subalgebra.mk ⟨⟨⟨s, @hmul⟩, h1⟩, s.add_mem, s.zero_mem⟩
        (by intro r; 

Proof state:
R : Type u_1
A : Type u_2
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
p s : Submodule R A
h1 : 1 ∈ s
hmul : ∀ (x y : A), x ∈ s → y ∈ s → x * y ∈ s
r : R
⊢ (algebraMap R A) r ∈
    { toSubmonoid := { toSubsemigroup := { carrier := ↑s, mul_mem' := hmul }, one_mem' := h1 },
            add_mem' := (_ : ∀ {a b : A}, a ∈ s → b ∈ s → a + b ∈ s),
            zero_mem' := (_ : 0 ∈ s) }.toSubmonoid.toSubsemigroup.carrier

Next tactic:
rw [Algebra.algebraMap_eq_smul_one]
theorem toSubalgebra_mk (s : Submodule R A) (h1 hmul) :
    s.toSubalgebra h1 hmul =
      Subalgebra.mk ⟨⟨⟨s, @hmul⟩, h1⟩, s.add_mem, s.zero_mem⟩
        (by intro r; rw [Algebra.algebraMap_eq_smul_one]; 

Proof state:
R : Type u_1
A : Type u_2
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
p s : Submodule R A
h1 : 1 ∈ s
hmul : ∀ (x y : A), x ∈ s → y ∈ s → x * y ∈ s
r : R
⊢ r • 1 ∈
    { toSubmonoid := { toSubsemigroup := { carrier := ↑s, mul_mem' := hmul }, one_mem' := h1 },
            add_mem' := (_ : ∀ {a b : A}, a ∈ s → b ∈ s → a + b ∈ s),
            zero_mem' := (_ : 0 ∈ s) }.toSubmonoid.toSubsemigroup.carrier

Next tactic:
apply s.smul_mem _ h1
@[simp]
theorem coe_range (φ : A →ₐ[R] B) : (φ.range : Set B) = Set.range φ := by
  

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ✝ φ : A →ₐ[R] B
⊢ ↑(AlgHom.range φ) = Set.range ⇑φ

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

Proof state:
case h
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ✝ φ : A →ₐ[R] B
x✝ : B
⊢ x✝ ∈ ↑(AlgHom.range φ) ↔ x✝ ∈ Set.range ⇑φ

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

Proof state:
case h
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ✝ φ : A →ₐ[R] B
x✝ : B
⊢ (∃ x, φ x = x✝) ↔ x✝ ∈ Set.range ⇑φ

Next tactic:
rfl
/-- The equalizer of two R-algebra homomorphisms -/
def equalizer (ϕ ψ : A →ₐ[R] B) : Subalgebra R A where
  carrier := { a | ϕ a = ψ a }
  zero_mem' := by simp only [Set.mem_setOf_eq, map_zero]
  one_mem' := by simp only [Set.mem_setOf_eq, map_one]
  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:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ ϕ ψ : A →ₐ[R] B
x y : A
hx : ϕ x = ψ x
hy : ϕ y = ψ y
⊢ x * y ∈ {a | ϕ a = ψ a}

Next tactic:
rw [Set.mem_setOf_eq, ϕ.map_mul, ψ.map_mul, hx, hy]
/-- The equalizer of two R-algebra homomorphisms -/
def equalizer (ϕ ψ : A →ₐ[R] B) : Subalgebra R A where
  carrier := { a | ϕ a = ψ a }
  zero_mem' := by simp only [Set.mem_setOf_eq, map_zero]
  one_mem' := by 

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ ϕ ψ : A →ₐ[R] B
⊢ 1 ∈
    { carrier := {a | ϕ a = ψ a},
        mul_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x * y ∈ {a | ϕ a = ψ a}) }.carrier

Next tactic:
simp only [Set.mem_setOf_eq, map_one]
/-- The equalizer of two R-algebra homomorphisms -/
def equalizer (ϕ ψ : A →ₐ[R] B) : Subalgebra R A where
  carrier := { a | ϕ a = ψ a }
  zero_mem' := by simp only [Set.mem_setOf_eq, map_zero]
  one_mem' := by simp only [Set.mem_setOf_eq, map_one]
  add_mem' {x y} (hx : ϕ x = ψ x) (hy : ϕ y = ψ y) := by
    

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ ϕ ψ : A →ₐ[R] B
x y : A
hx : ϕ x = ψ x
hy : ϕ y = ψ y
⊢ x + y ∈
    {
          toSubsemigroup :=
            { carrier := {a | ϕ a = ψ a},
              mul_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x * y ∈ {a | ϕ a = ψ a}) },
          one_mem' := (_ : ϕ 1 = ψ 1) }.toSubsemigroup.carrier

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

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ ϕ ψ : A →ₐ[R] B
⊢ 0 ∈
    {
          toSubsemigroup :=
            { carrier := {a | ϕ a = ψ a},
              mul_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x * y ∈ {a | ϕ a = ψ a}) },
          one_mem' := (_ : ϕ 1 = ψ 1) }.toSubsemigroup.carrier

Next tactic:
simp only [Set.mem_setOf_eq, map_zero]
/-- The equalizer of two R-algebra homomorphisms -/
def equalizer (ϕ ψ : A →ₐ[R] B) : Subalgebra R A where
  carrier := { a | ϕ a = ψ a }
  zero_mem' := by simp only [Set.mem_setOf_eq, map_zero]
  one_mem' := by simp only [Set.mem_setOf_eq, map_one]
  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]
  algebraMap_mem' x := by 

Proof state:
R' : Type u'
R : Type u
A : Type v
B : Type w
C : Type w'
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
inst✝³ : Semiring B
inst✝² : Algebra R B
inst✝¹ : Semiring C
inst✝ : Algebra R C
φ ϕ ψ : A →ₐ[R] B
x : R
⊢ (algebraMap R A) x ∈
    {
            toSubmonoid :=
              {
                toSubsemigroup :=
                  { carrier := {a | ϕ a = ψ a},
                    mul_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x * y ∈ {a | ϕ a = ψ a}) },
                one_mem' := (_ : ϕ 1 = ψ 1) },
            add_mem' :=
              (_ :
                ∀ {x y : A},
                  ϕ x = ψ x →
                    ϕ y = ψ y →
                      x + y ∈
                        {
                              toSubsemigroup :=
                                { carrier := {a | ϕ a = ψ a},
                                  mul_mem' := (_ : ∀ {x y : A}, ϕ x = ψ x → ϕ y = ψ y → x * y ∈ {a | ϕ a = ψ a}) },
                              one_mem' := (_ : ϕ 1 = ψ 1) }.toSubsemigroup.carrier),
            zero_mem' := (_ : ϕ 0 = ψ 0) }.toSubmonoid.toSubsemigroup.carrier

Next tactic:
rw [Set.mem_setOf_eq, AlgHom.commutes, AlgHom.commutes]
/-- Restrict an algebra homomorphism with a left inverse to an algebra isomorphism to its range.

This is a computable alternative to `AlgEquiv.ofInjective`. -/
def ofLeftInverse {g : B → A} {f : A →ₐ[R] B} (h : Function.LeftInverse g f) : A ≃ₐ[R] f.range :=
  { f.rangeRestrict with
    toFun := f.rangeRestrict
    invFun := g ∘ f.range.val
    left_inv := h
    right_inv := fun x =>
      Subtype.ext <|
        let ⟨x', hx'⟩ := f.mem_range.mp x.prop
        show f (g x) = x by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Semiring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
g : B → A
f : A →ₐ[R] B
h : Function.LeftInverse g ⇑f
src✝ : A →ₐ[R] ↥(AlgHom.range f) := AlgHom.rangeRestrict f
x : ↥(AlgHom.range f)
x' : A
hx' : f x' = ↑x
⊢ f (g ↑x) = ↑x

Next tactic:
rw [← hx', h x']
/-- Given an equivalence `e : A ≃ₐ[R] B` of `R`-algebras and a subalgebra `S` of `A`,
`subalgebra_map` is the induced equivalence between `S` and `S.map e` -/
@[simps!]
def subalgebraMap (e : A ≃ₐ[R] B) (S : Subalgebra R A) : S ≃ₐ[R] S.map (e : A →ₐ[R] B) :=
  { e.toRingEquiv.subsemiringMap S.toSubsemiring with
    commutes' := fun r => by
      

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Semiring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
e : A ≃ₐ[R] B
S : Subalgebra R A
src✝ : ↥S.toSubsemiring ≃+* ↥(Subsemiring.map (RingEquiv.toRingHom (toRingEquiv e)) S.toSubsemiring) :=
  RingEquiv.subsemiringMap (toRingEquiv e) S.toSubsemiring
r : R
⊢ Equiv.toFun src✝.toEquiv ((algebraMap R ↥S) r) = (algebraMap R ↥(Subalgebra.map (↑e) S)) r

Next tactic:
ext
/-- Given an equivalence `e : A ≃ₐ[R] B` of `R`-algebras and a subalgebra `S` of `A`,
`subalgebra_map` is the induced equivalence between `S` and `S.map e` -/
@[simps!]
def subalgebraMap (e : A ≃ₐ[R] B) (S : Subalgebra R A) : S ≃ₐ[R] S.map (e : A →ₐ[R] B) :=
  { e.toRingEquiv.subsemiringMap S.toSubsemiring with
    commutes' := fun r => by
      ext; 

Proof state:
case a
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Semiring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
e : A ≃ₐ[R] B
S : Subalgebra R A
src✝ : ↥S.toSubsemiring ≃+* ↥(Subsemiring.map (RingEquiv.toRingHom (toRingEquiv e)) S.toSubsemiring) :=
  RingEquiv.subsemiringMap (toRingEquiv e) S.toSubsemiring
r : R
⊢ ↑(Equiv.toFun src✝.toEquiv ((algebraMap R ↥S) r)) = ↑((algebraMap R ↥(Subalgebra.map (↑e) S)) r)

Next tactic:
dsimp only
/-- Given an equivalence `e : A ≃ₐ[R] B` of `R`-algebras and a subalgebra `S` of `A`,
`subalgebra_map` is the induced equivalence between `S` and `S.map e` -/
@[simps!]
def subalgebraMap (e : A ≃ₐ[R] B) (S : Subalgebra R A) : S ≃ₐ[R] S.map (e : A →ₐ[R] B) :=
  { e.toRingEquiv.subsemiringMap S.toSubsemiring with
    commutes' := fun r => by
      ext; dsimp only; 

Proof state:
case a
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Semiring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
e : A ≃ₐ[R] B
S : Subalgebra R A
src✝ : ↥S.toSubsemiring ≃+* ↥(Subsemiring.map (RingEquiv.toRingHom (toRingEquiv e)) S.toSubsemiring) :=
  RingEquiv.subsemiringMap (toRingEquiv e) S.toSubsemiring
r : R
⊢ ↑(Equiv.toFun (RingEquiv.subsemiringMap (toRingEquiv e) S.toSubsemiring).toEquiv ((algebraMap R ↥S) r)) =
    ↑((algebraMap R ↥(Subalgebra.map (↑e) S)) r)

Next tactic:
erw [RingEquiv.subsemiringMap_apply_coe]
/-- Given an equivalence `e : A ≃ₐ[R] B` of `R`-algebras and a subalgebra `S` of `A`,
`subalgebra_map` is the induced equivalence between `S` and `S.map e` -/
@[simps!]
def subalgebraMap (e : A ≃ₐ[R] B) (S : Subalgebra R A) : S ≃ₐ[R] S.map (e : A →ₐ[R] B) :=
  { e.toRingEquiv.subsemiringMap S.toSubsemiring with
    commutes' := fun r => by
      ext; dsimp only; erw [RingEquiv.subsemiringMap_apply_coe]
      

Proof state:
case a
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Semiring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
e : A ≃ₐ[R] B
S : Subalgebra R A
src✝ : ↥S.toSubsemiring ≃+* ↥(Subsemiring.map (RingEquiv.toRingHom (toRingEquiv e)) S.toSubsemiring) :=
  RingEquiv.subsemiringMap (toRingEquiv e) S.toSubsemiring
r : R
⊢ (toRingEquiv e) ↑((algebraMap R ↥S) r) = ↑((algebraMap R ↥(Subalgebra.map (↑e) S)) r)

Next tactic:
exact e.commutes _
theorem mem_sInf {S : Set (Subalgebra R A)} {x : A} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p := by
  

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Set (Subalgebra R A)
x : A
⊢ x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p

Next tactic:
simp only [← SetLike.mem_coe, coe_sInf, Set.mem_iInter₂]
@[simp]
theorem sInf_toSubmodule (S : Set (Subalgebra R A)) :
    Subalgebra.toSubmodule (sInf S) = sInf (Subalgebra.toSubmodule '' S) :=
  SetLike.coe_injective <| by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Set (Subalgebra R A)
⊢ ↑(Subalgebra.toSubmodule (sInf S)) = ↑(sInf (⇑Subalgebra.toSubmodule '' S))

Next tactic:
simp
@[simp]
theorem sInf_toSubsemiring (S : Set (Subalgebra R A)) :
    (sInf S).toSubsemiring = sInf (Subalgebra.toSubsemiring '' S) :=
  SetLike.coe_injective <| by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Set (Subalgebra R A)
⊢ ↑(sInf S).toSubsemiring = ↑(sInf (Subalgebra.toSubsemiring '' S))

Next tactic:
simp
@[simp, norm_cast]
theorem coe_iInf {ι : Sort*} {S : ι → Subalgebra R A} : (↑(⨅ i, S i) : Set A) = ⋂ i, S i := by
  

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
ι : Sort u_1
S : ι → Subalgebra R A
⊢ ↑(⨅ i, S i) = ⋂ i, ↑(S i)

Next tactic:
simp [iInf]
theorem mem_iInf {ι : Sort*} {S : ι → Subalgebra R A} {x : A} : (x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i := by
  

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
ι : Sort u_1
S : ι → Subalgebra R A
x : A
⊢ x ∈ ⨅ i, S i ↔ ∀ (i : ι), x ∈ S i

Next tactic:
simp only [iInf, mem_sInf, Set.forall_range_iff]
open Subalgebra in
@[simp]
theorem iInf_toSubmodule {ι : Sort*} (S : ι → Subalgebra R A) :
    toSubmodule (⨅ i, S i) = ⨅ i, toSubmodule (S i) :=
  SetLike.coe_injective <| by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
ι : Sort u_1
S : ι → Subalgebra R A
⊢ ↑(toSubmodule (⨅ i, S i)) = ↑(⨅ i, toSubmodule (S i))

Next tactic:
simp
theorem eq_top_iff {S : Subalgebra R A} : S = ⊤ ↔ ∀ x : A, x ∈ S :=
  ⟨fun h x => by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Subalgebra R A
h : S = ⊤
x : A
⊢ x ∈ S

Next tactic:
rw [h]
theorem eq_top_iff {S : Subalgebra R A} : S = ⊤ ↔ ∀ x : A, x ∈ S :=
  ⟨fun h x => by rw [h]; 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Subalgebra R A
h : S = ⊤
x : A
⊢ x ∈ ⊤

Next tactic:
exact mem_top
theorem eq_top_iff {S : Subalgebra R A} : S = ⊤ ↔ ∀ x : A, x ∈ S :=
  ⟨fun h x => by rw [h]; exact mem_top, fun h => by
    

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Subalgebra R A
h : ∀ (x : A), x ∈ S
⊢ S = ⊤

Next tactic:
ext x
theorem eq_top_iff {S : Subalgebra R A} : S = ⊤ ↔ ∀ x : A, x ∈ S :=
  ⟨fun h x => by rw [h]; exact mem_top, fun h => by
    ext x; 

Proof state:
case h
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Subalgebra R A
h : ∀ (x : A), x ∈ S
x : A
⊢ x ∈ S ↔ x ∈ ⊤

Next tactic:
exact ⟨fun _ => mem_top, fun _ => h x⟩
instance subsingleton_of_subsingleton [Subsingleton A] : Subsingleton (Subalgebra R A) :=
  ⟨fun B C => ext fun x => by 

Proof state:
R : Type u
A : Type v
B✝ : Type w
inst✝⁵ : CommSemiring R
inst✝⁴ : Semiring A
inst✝³ : Algebra R A
inst✝² : Semiring B✝
inst✝¹ : Algebra R B✝
S : Subalgebra R A
inst✝ : Subsingleton A
B C : Subalgebra R A
x : A
⊢ x ∈ B ↔ x ∈ C

Next tactic:
simp only [Subsingleton.elim x 0, zero_mem B, zero_mem C]
instance _root_.AlgEquiv.subsingleton_right [Subsingleton (Subalgebra R B)] :
    Subsingleton (A ≃ₐ[R] B) :=
  ⟨fun f g => by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁵ : CommSemiring R
inst✝⁴ : Semiring A
inst✝³ : Algebra R A
inst✝² : Semiring B
inst✝¹ : Algebra R B
S : Subalgebra R A
inst✝ : Subsingleton (Subalgebra R B)
f g : A ≃ₐ[R] B
⊢ f = g

Next tactic:
rw [← f.symm_symm, Subsingleton.elim f.symm g.symm, g.symm_symm]
instance : Unique (Subalgebra R R) :=
  { inferInstanceAs (Inhabited (Subalgebra R R)) with
    uniq := by
      

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Subalgebra R A
src✝ : Inhabited (Subalgebra R R) := inferInstanceAs (Inhabited (Subalgebra R R))
⊢ ∀ (a : Subalgebra R R), a = default

Next tactic:
intro S
instance : Unique (Subalgebra R R) :=
  { inferInstanceAs (Inhabited (Subalgebra R R)) with
    uniq := by
      intro S
      

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S✝ : Subalgebra R A
src✝ : Inhabited (Subalgebra R R) := inferInstanceAs (Inhabited (Subalgebra R R))
S : Subalgebra R R
⊢ S = default

Next tactic:
refine' le_antisymm ?_ bot_le
instance : Unique (Subalgebra R R) :=
  { inferInstanceAs (Inhabited (Subalgebra R R)) with
    uniq := by
      intro S
      refine' le_antisymm ?_ bot_le
      

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S✝ : Subalgebra R A
src✝ : Inhabited (Subalgebra R R) := inferInstanceAs (Inhabited (Subalgebra R R))
S : Subalgebra R R
⊢ S ≤ default

Next tactic:
intro _ _
instance : Unique (Subalgebra R R) :=
  { inferInstanceAs (Inhabited (Subalgebra R R)) with
    uniq := by
      intro S
      refine' le_antisymm ?_ bot_le
      intro _ _
      

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S✝ : Subalgebra R A
src✝ : Inhabited (Subalgebra R R) := inferInstanceAs (Inhabited (Subalgebra R R))
S : Subalgebra R R
x✝ : R
a✝ : x✝ ∈ S
⊢ x✝ ∈ default

Next tactic:
simp only [Set.mem_range, mem_bot, id.map_eq_self, exists_apply_eq_apply, default]
@[simp]
theorem equivOfEq_rfl (S : Subalgebra R A) : equivOfEq S S rfl = AlgEquiv.refl := by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S✝ S : Subalgebra R A
⊢ equivOfEq S S (_ : S = S) = AlgEquiv.refl

Next tactic:
ext
@[simp]
theorem equivOfEq_rfl (S : Subalgebra R A) : equivOfEq S S rfl = AlgEquiv.refl := by ext; 

Proof state:
case h.a
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S✝ S : Subalgebra R A
a✝ : ↥S
⊢ ↑((equivOfEq S S (_ : S = S)) a✝) = ↑(AlgEquiv.refl a✝)

Next tactic:
rfl
@[simp]
theorem prod_top : (prod ⊤ ⊤ : Subalgebra R (A × B)) = ⊤ := by 

Proof state:
R : Type u
A : Type v
B : Type w
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Semiring B
inst✝ : Algebra R B
S : Subalgebra R A
S₁ : Subalgebra R B
⊢ prod ⊤ ⊤ = ⊤

Next tactic:
ext