l3lab/ntp-mathlib huggingface dataset:
noncomputable instance field [Fact (Irreducible f)] : Field (AdjoinRoot f) :=
  { Quotient.groupWithZero (span {f} : Ideal K[X]) with
    toCommRing := AdjoinRoot.instCommRing f
    ratCast := fun a => of f (a : K)
    ratCast_mk := fun a b h1 h2 => by
      letI : GroupWithZero (AdjoinRoot f) := Ideal.Quotient.groupWithZero _
      -- porting note: was
      -- `rw [Rat.cast_mk' (K := ℚ), _root_.map_mul, _root_.map_intCast, map_inv₀, map_natCast]`
      convert_to ((Rat.mk' a b h1 h2 : K) : AdjoinRoot f) = ((↑a * (↑b)⁻¹ : K) : AdjoinRoot f)
      · 

Proof state:
case h.e'_3
R : Type u
S : Type v
K : Type w
inst✝¹ : Field K
f : K[X]
inst✝ : Fact (Irreducible f)
src✝ : GroupWithZero (K[X] ⧸ span {f}) := Quotient.groupWithZero (span {f})
a : ℤ
b : ℕ
h1 : b ≠ 0
h2 : Nat.Coprime (Int.natAbs a) b
this : GroupWithZero (AdjoinRoot f) := Quotient.groupWithZero (span {f})
⊢ ↑a * (↑b)⁻¹ = (of f) (↑a * (↑b)⁻¹)

Next tactic:
simp only [_root_.map_mul, map_intCast, map_inv₀, map_natCast]
noncomputable instance field [Fact (Irreducible f)] : Field (AdjoinRoot f) :=
  { Quotient.groupWithZero (span {f} : Ideal K[X]) with
    toCommRing := AdjoinRoot.instCommRing f
    ratCast := fun a => of f (a : K)
    ratCast_mk := fun a b h1 h2 => by
      letI : GroupWithZero (AdjoinRoot f) := Ideal.Quotient.groupWithZero _
      -- porting note: was
      -- `rw [Rat.cast_mk' (K := ℚ), _root_.map_mul, _root_.map_intCast, map_inv₀, map_natCast]`
      convert_to ((Rat.mk' a b h1 h2 : K) : AdjoinRoot f) = ((↑a * (↑b)⁻¹ : K) : AdjoinRoot f)
      · simp only [_root_.map_mul, map_intCast, map_inv₀, map_natCast]
      · 

Proof state:
R : Type u
S : Type v
K : Type w
inst✝¹ : Field K
f : K[X]
inst✝ : Fact (Irreducible f)
src✝ : GroupWithZero (K[X] ⧸ span {f}) := Quotient.groupWithZero (span {f})
a : ℤ
b : ℕ
h1 : b ≠ 0
h2 : Nat.Coprime (Int.natAbs a) b
this : GroupWithZero (AdjoinRoot f) := Quotient.groupWithZero (span {f})
⊢ (of f) ↑(Rat.mk' a b) = (of f) (↑a * (↑b)⁻¹)

Next tactic:
simp only [Rat.cast_mk', _root_.map_mul, map_intCast, map_inv₀, map_natCast]
noncomputable instance field [Fact (Irreducible f)] : Field (AdjoinRoot f) :=
  { Quotient.groupWithZero (span {f} : Ideal K[X]) with
    toCommRing := AdjoinRoot.instCommRing f
    ratCast := fun a => of f (a : K)
    ratCast_mk := fun a b h1 h2 => by
      letI : GroupWithZero (AdjoinRoot f) := Ideal.Quotient.groupWithZero _
      -- porting note: was
      -- `rw [Rat.cast_mk' (K := ℚ), _root_.map_mul, _root_.map_intCast, map_inv₀, map_natCast]`
      convert_to ((Rat.mk' a b h1 h2 : K) : AdjoinRoot f) = ((↑a * (↑b)⁻¹ : K) : AdjoinRoot f)
      · simp only [_root_.map_mul, map_intCast, map_inv₀, map_natCast]
      · simp only [Rat.cast_mk', _root_.map_mul, map_intCast, map_inv₀, map_natCast]
    qsmul := (· • ·)
    qsmul_eq_mul' := fun a x =>
      -- porting note: I gave the explicit motive and changed `rw` to `simp`.
      AdjoinRoot.induction_on (C := fun y => a • y = (of f) a * y) x fun p => by
        

Proof state:
R : Type u
S : Type v
K : Type w
inst✝¹ : Field K
f : K[X]
inst✝ : Fact (Irreducible f)
src✝ : GroupWithZero (K[X] ⧸ span {f}) := Quotient.groupWithZero (span {f})
a : ℚ
x : AdjoinRoot f
p : K[X]
⊢ (fun y => a • y = (of f) ↑a * y) ((mk f) p)

Next tactic:
simp only [smul_mk, of, RingHom.comp_apply, ← (mk f).map_mul, Polynomial.rat_smul_eq_C_mul]
theorem mk_leftInverse (hg : g.Monic) : Function.LeftInverse (mk g) (modByMonicHom hg) := by
  

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
⊢ Function.LeftInverse ⇑(mk g) ⇑(modByMonicHom hg)

Next tactic:
intro f
theorem mk_leftInverse (hg : g.Monic) : Function.LeftInverse (mk g) (modByMonicHom hg) := by
  intro f
  

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
f : AdjoinRoot g
⊢ (mk g) ((modByMonicHom hg) f) = f

Next tactic:
induction f using AdjoinRoot.induction_on
theorem mk_leftInverse (hg : g.Monic) : Function.LeftInverse (mk g) (modByMonicHom hg) := by
  intro f
  induction f using AdjoinRoot.induction_on
  

Proof state:
case ih
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
p✝ : R[X]
⊢ (mk g) ((modByMonicHom hg) ((mk g) p✝)) = (mk g) p✝

Next tactic:
rw [modByMonicHom_mk hg, mk_eq_mk, modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel_left,
    dvd_neg]
theorem mk_leftInverse (hg : g.Monic) : Function.LeftInverse (mk g) (modByMonicHom hg) := by
  intro f
  induction f using AdjoinRoot.induction_on
  rw [modByMonicHom_mk hg, mk_eq_mk, modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel_left,
    dvd_neg]
  

Proof state:
case ih
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
p✝ : R[X]
⊢ g ∣ g * (p✝ /ₘ g)

Next tactic:
apply dvd_mul_right
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by 

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
f₁ f₂ : AdjoinRoot g
i : Fin (natDegree g)
⊢ (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) i =
    ((fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ + (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) i

Next tactic:
simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
f₁ : R
f₂ : AdjoinRoot g
i : Fin (natDegree g)
⊢ AddHom.toFun
      { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
        map_add' :=
          (_ :
            ∀ (f₁ f₂ : AdjoinRoot g),
              (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ + (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
      (f₁ • f₂) i =
    ((RingHom.id R) f₁ •
        AddHom.toFun
          { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
            map_add' :=
              (_ :
                ∀ (f₁ f₂ : AdjoinRoot g),
                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                    (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ + (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
          f₂)
      i

Next tactic:
simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
⊢ Function.LeftInverse (fun c => (mk g) (∑ i : Fin (natDegree g), (monomial ↑i) (c i)))
    {
          toAddHom :=
            { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
              map_add' :=
                (_ :
                  ∀ (f₁ f₂ : AdjoinRoot g),
                    (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                      (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                        (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) },
          map_smul' :=
            (_ :
              ∀ (f₁ : R) (f₂ : AdjoinRoot g),
                AddHom.toFun
                    { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                      map_add' :=
                        (_ :
                          ∀ (f₁ f₂ : AdjoinRoot g),
                            (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                    (f₁ • f₂) =
                  (RingHom.id R) f₁ •
                    AddHom.toFun
                      { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                        map_add' :=
                          (_ :
                            ∀ (f₁ f₂ : AdjoinRoot g),
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                      f₂) }.toAddHom.toFun

Next tactic:
intro f
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
f : AdjoinRoot g
⊢ (fun c => (mk g) (∑ i : Fin (natDegree g), (monomial ↑i) (c i)))
      (AddHom.toFun
        {
            toAddHom :=
              { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                map_add' :=
                  (_ :
                    ∀ (f₁ f₂ : AdjoinRoot g),
                      (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                        (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                          (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) },
            map_smul' :=
              (_ :
                ∀ (f₁ : R) (f₂ : AdjoinRoot g),
                  AddHom.toFun
                      { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                        map_add' :=
                          (_ :
                            ∀ (f₁ f₂ : AdjoinRoot g),
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                      (f₁ • f₂) =
                    (RingHom.id R) f₁ •
                      AddHom.toFun
                        { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                          map_add' :=
                            (_ :
                              ∀ (f₁ f₂ : AdjoinRoot g),
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                    (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                        f₂) }.toAddHom
        f) =
    f

Next tactic:
induction f using AdjoinRoot.induction_on
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        induction f using AdjoinRoot.induction_on
        

Proof state:
case ih
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
p✝ : R[X]
⊢ (fun c => (mk g) (∑ i : Fin (natDegree g), (monomial ↑i) (c i)))
      (AddHom.toFun
        {
            toAddHom :=
              { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                map_add' :=
                  (_ :
                    ∀ (f₁ f₂ : AdjoinRoot g),
                      (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                        (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                          (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) },
            map_smul' :=
              (_ :
                ∀ (f₁ : R) (f₂ : AdjoinRoot g),
                  AddHom.toFun
                      { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                        map_add' :=
                          (_ :
                            ∀ (f₁ f₂ : AdjoinRoot g),
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                      (f₁ • f₂) =
                    (RingHom.id R) f₁ •
                      AddHom.toFun
                        { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                          map_add' :=
                            (_ :
                              ∀ (f₁ f₂ : AdjoinRoot g),
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                    (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                        f₂) }.toAddHom
        ((mk g) p✝)) =
    (mk g) p✝

Next tactic:
simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        induction f using AdjoinRoot.induction_on
        simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
        

Proof state:
case ih
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
p✝ : R[X]
⊢ (mk g) (p✝ %ₘ g) = (mk g) p✝

Next tactic:
refine (mk_eq_mk.mpr ?_).symm
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        induction f using AdjoinRoot.induction_on
        simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
        refine (mk_eq_mk.mpr ?_).symm
        

Proof state:
case ih
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
p✝ : R[X]
⊢ g ∣ p✝ - p✝ %ₘ g

Next tactic:
rw [modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel]
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        induction f using AdjoinRoot.induction_on
        simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
        refine (mk_eq_mk.mpr ?_).symm
        rw [modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel]
        

Proof state:
case ih
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
p✝ : R[X]
⊢ g ∣ g * (p✝ /ₘ g)

Next tactic:
exact dvd_mul_right _ _
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        induction f using AdjoinRoot.induction_on
        simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
        refine (mk_eq_mk.mpr ?_).symm
        rw [modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel]
        exact dvd_mul_right _ _
      right_inv := fun x =>
        funext fun i => by
          

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
x : Fin (natDegree g) → R
i : Fin (natDegree g)
⊢ AddHom.toFun
      {
          toAddHom :=
            { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
              map_add' :=
                (_ :
                  ∀ (f₁ f₂ : AdjoinRoot g),
                    (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                      (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                        (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) },
          map_smul' :=
            (_ :
              ∀ (f₁ : R) (f₂ : AdjoinRoot g),
                AddHom.toFun
                    { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                      map_add' :=
                        (_ :
                          ∀ (f₁ f₂ : AdjoinRoot g),
                            (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                    (f₁ • f₂) =
                  (RingHom.id R) f₁ •
                    AddHom.toFun
                      { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                        map_add' :=
                          (_ :
                            ∀ (f₁ f₂ : AdjoinRoot g),
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                      f₂) }.toAddHom
      ((fun c => (mk g) (∑ i : Fin (natDegree g), (monomial ↑i) (c i))) x) i =
    x i

Next tactic:
nontriviality R
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
  Basis.ofEquivFun
    { toFun := fun f i => (modByMonicHom hg f).coeff i
      invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
      map_add' := fun f₁ f₂ =>
        funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
      map_smul' := fun f₁ f₂ =>
        funext fun i => by
          simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
      -- porting note: another proof that I converted to tactic mode
      left_inv := by
        intro f
        induction f using AdjoinRoot.induction_on
        simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
        refine (mk_eq_mk.mpr ?_).symm
        rw [modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel]
        exact dvd_mul_right _ _
      right_inv := fun x =>
        funext fun i => by
          nontriviality R
          

Proof state:
R : Type u
S : Type v
K : Type w
inst✝ : CommRing R
g : R[X]
hg : Monic g
x : Fin (natDegree g) → R
i : Fin (natDegree g)
✝ : Nontrivial R
⊢ AddHom.toFun
      {
          toAddHom :=
            { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
              map_add' :=
                (_ :
                  ∀ (f₁ f₂ : AdjoinRoot g),
                    (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                      (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                        (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) },
          map_smul' :=
            (_ :
              ∀ (f₁ : R) (f₂ : AdjoinRoot g),
                AddHom.toFun
                    { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                      map_add' :=
                        (_ :
                          ∀ (f₁ f₂ : AdjoinRoot g),
                            (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                    (f₁ • f₂) =
                  (RingHom.id R) f₁ •
                    AddHom.toFun
                      { toFun := fun f i => coeff ((modByMonicHom hg) f) ↑i,
                        map_add' :=
                          (_ :
                            ∀ (f₁ f₂ : AdjoinRoot g),
                              (fun f i => coeff ((modByMonicHom hg) f) ↑i) (f₁ + f₂) =
                                (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₁ +
                                  (fun f i => coeff ((modByMonicHom hg) f) ↑i) f₂) }
                      f₂) }.toAddHom
      ((fun c => (mk g) (∑ i : Fin (natDegree g), (monomial ↑i) (c i))) x) i =
    x i

Next tactic:
simp only [modByMonicHom_mk]