l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem ι_ne_algebraMap [Nontrivial R] (x : X) (r : R) : ι R x ≠ algebraMap R _ r := fun h ↦ by
  let f0 : FreeAlgebra R X →ₐ[R] R := lift R 0
  let f1 : FreeAlgebra R X →ₐ[R] R := lift R 1
  have hf0 : f0 (ι R x) = 0 := lift_ι_apply _ _
  have hf1 : f1 (ι R x) = 1 := lift_ι_apply _ _
  rw [h, f0.commutes, Algebra.id.map_eq_self] at hf0
  rw [h, f1.commutes, Algebra.id.map_eq_self] at hf1
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
X : Type u_2
A : Type u_3
inst✝² : Semiring A
inst✝¹ : Algebra R A
inst✝ : Nontrivial R
x : X
r : R
h : ι R x = (algebraMap R (FreeAlgebra R X)) r
f0 : FreeAlgebra R X →ₐ[R] R := (lift R) 0
f1 : FreeAlgebra R X →ₐ[R] R := (lift R) 1
hf0 : r = 0
hf1 : r = 1
⊢ False

Next tactic:
exact zero_ne_one (hf0.symm.trans hf1)
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
⊢ C a

Next tactic:
let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
⊢ C a

Next tactic:
let of : X → s := Subtype.coind (ι R) h_grade1
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
⊢ C a

Next tactic:
have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    simp [Subtype.coind]
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
⊢ AlgHom.id R (FreeAlgebra R X) = AlgHom.comp (Subalgebra.val s) ((lift R) of)

Next tactic:
ext
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    

Proof state:
case w.h
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
x✝ : X
⊢ (⇑(AlgHom.id R (FreeAlgebra R X)) ∘ ι R) x✝ = (⇑(AlgHom.comp (Subalgebra.val s) ((lift R) of)) ∘ ι R) x✝

Next tactic:
simp [Subtype.coind]
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    simp [Subtype.coind]
  -- finding a proof is finding an element of the subalgebra
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
of_id : AlgHom.id R (FreeAlgebra R X) = AlgHom.comp (Subalgebra.val s) ((lift R) of)
⊢ C a

Next tactic:
suffices : a = lift R of a
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    simp [Subtype.coind]
  -- finding a proof is finding an element of the subalgebra
  suffices : a = lift R of a
  · 

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
of_id : AlgHom.id R (FreeAlgebra R X) = AlgHom.comp (Subalgebra.val s) ((lift R) of)
this : a = ↑(((lift R) of) a)
⊢ C a

Next tactic:
rw [this]
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    simp [Subtype.coind]
  -- finding a proof is finding an element of the subalgebra
  suffices : a = lift R of a
  · rw [this]
    

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
of_id : AlgHom.id R (FreeAlgebra R X) = AlgHom.comp (Subalgebra.val s) ((lift R) of)
this : a = ↑(((lift R) of) a)
⊢ C ↑(((lift R) of) a)

Next tactic:
exact Subtype.prop (lift R of a)
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    simp [Subtype.coind]
  -- finding a proof is finding an element of the subalgebra
  suffices : a = lift R of a
  · rw [this]
    exact Subtype.prop (lift R of a)
  

Proof state:
case this
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
of_id : AlgHom.id R (FreeAlgebra R X) = AlgHom.comp (Subalgebra.val s) ((lift R) of)
⊢ a = ↑(((lift R) of) a)

Next tactic:
simp [AlgHom.ext_iff] at of_id
/-- An induction principle for the free algebra.

If `C` holds for the `algebraMap` of `r : R` into `FreeAlgebra R X`, the `ι` of `x : X`, and is
preserved under addition and muliplication, then it holds for all of `FreeAlgebra R X`.
-/
@[elab_as_elim]
theorem induction {C : FreeAlgebra R X → Prop}
    (h_grade0 : ∀ r, C (algebraMap R (FreeAlgebra R X) r)) (h_grade1 : ∀ x, C (ι R x))
    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))
    (a : FreeAlgebra R X) : C a := by
  -- the arguments are enough to construct a subalgebra, and a mapping into it from X
  let s : Subalgebra R (FreeAlgebra R X) :=
    { carrier := C
      mul_mem' := h_mul _ _
      add_mem' := h_add _ _
      algebraMap_mem' := h_grade0 }
  let of : X → s := Subtype.coind (ι R) h_grade1
  -- the mapping through the subalgebra is the identity
  have of_id : AlgHom.id R (FreeAlgebra R X) = s.val.comp (lift R of) := by
    ext
    simp [Subtype.coind]
  -- finding a proof is finding an element of the subalgebra
  suffices : a = lift R of a
  · rw [this]
    exact Subtype.prop (lift R of a)
  simp [AlgHom.ext_iff] at of_id
  

Proof state:
case this
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
C : FreeAlgebra R X → Prop
h_grade0 : ∀ (r : R), C ((algebraMap R (FreeAlgebra R X)) r)
h_grade1 : ∀ (x : X), C (ι R x)
h_mul : ∀ (a b : FreeAlgebra R X), C a → C b → C (a * b)
h_add : ∀ (a b : FreeAlgebra R X), C a → C b → C (a + b)
a : FreeAlgebra R X
s : Subalgebra R (FreeAlgebra R X) :=
  {
    toSubsemiring :=
      {
        toSubmonoid :=
          { toSubsemigroup := { carrier := C, mul_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a * b)) },
            one_mem' := (_ : 1 ∈ C) },
        add_mem' := (_ : ∀ {a b : FreeAlgebra R X}, C a → C b → C (a + b)), zero_mem' := (_ : 0 ∈ C) },
    algebraMap_mem' := h_grade0 }
of : X → ↥s := Subtype.coind (ι R) h_grade1
of_id : ∀ (x : FreeAlgebra R X), x = ↑(((lift R) (Subtype.coind (ι R) h_grade1)) x)
⊢ a = ↑(((lift R) of) a)

Next tactic:
exact of_id a
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
⊢ Algebra.adjoin R (Set.range (ι R)) = ⊤

Next tactic:
set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
⊢ S = ⊤

Next tactic:
refine top_unique fun x hx => ?_
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; 

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x : FreeAlgebra R X
hx : x ∈ ⊤
⊢ x ∈ S

Next tactic:
clear hx
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x : FreeAlgebra R X
⊢ x ∈ S

Next tactic:
induction x using FreeAlgebra.induction with
  | h_grade0 => exact S.algebraMap_mem _
  | h_add x y hx hy => exact S.add_mem hx hy
  | h_mul x y hx hy => exact S.mul_mem hx hy
  | h_grade1 x => exact Algebra.subset_adjoin (Set.mem_range_self _)
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  

Proof state:
case h_grade0
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
r✝ : R
⊢ (algebraMap R (FreeAlgebra R X)) r✝ ∈ S

Next tactic:
| h_grade0 => exact S.algebraMap_mem _
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  | h_grade0 => 

Proof state:
case h_grade0
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
r✝ : R
⊢ (algebraMap R (FreeAlgebra R X)) r✝ ∈ S

Next tactic:
exact S.algebraMap_mem _
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  | h_grade0 => exact S.algebraMap_mem _
  

Proof state:
case h_add
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x y : FreeAlgebra R X
hx : x ∈ S
hy : y ∈ S
⊢ x + y ∈ S

Next tactic:
| h_add x y hx hy => exact S.add_mem hx hy
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  | h_grade0 => exact S.algebraMap_mem _
  | h_add x y hx hy => 

Proof state:
case h_add
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x y : FreeAlgebra R X
hx : x ∈ S
hy : y ∈ S
⊢ x + y ∈ S

Next tactic:
exact S.add_mem hx hy
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  | h_grade0 => exact S.algebraMap_mem _
  | h_add x y hx hy => exact S.add_mem hx hy
  

Proof state:
case h_mul
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x y : FreeAlgebra R X
hx : x ∈ S
hy : y ∈ S
⊢ x * y ∈ S

Next tactic:
| h_mul x y hx hy => exact S.mul_mem hx hy
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  | h_grade0 => exact S.algebraMap_mem _
  | h_add x y hx hy => exact S.add_mem hx hy
  | h_mul x y hx hy => 

Proof state:
case h_mul
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x y : FreeAlgebra R X
hx : x ∈ S
hy : y ∈ S
⊢ x * y ∈ S

Next tactic:
exact S.mul_mem hx hy
@[simp]
theorem adjoin_range_ι : Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X)) = ⊤ := by
  set S := Algebra.adjoin R (Set.range (ι R : X → FreeAlgebra R X))
  refine top_unique fun x hx => ?_; clear hx
  induction x using FreeAlgebra.induction with
  | h_grade0 => exact S.algebraMap_mem _
  | h_add x y hx hy => exact S.add_mem hx hy
  | h_mul x y hx hy => exact S.mul_mem hx hy
  

Proof state:
case h_grade1
R : Type u_1
inst✝ : CommSemiring R
X : Type u_2
S : Subalgebra R (FreeAlgebra R X) := Algebra.adjoin R (Set.range (ι R))
x : X
⊢ ι R x ∈ S

Next tactic:
| h_grade1 x => exact Algebra.subset_adjoin (Set.mem_range_self _)