l3lab/ntp-mathlib huggingface dataset:
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p q : ↥(degreeLT R n)
x✝ : Fin n
⊢ (fun p n_1 => coeff ↑p ↑n_1) (p + q) x✝ = ((fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) x✝

Next tactic:
dsimp
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p q : ↥(degreeLT R n)
x✝ : Fin n
⊢ coeff (↑p + ↑q) ↑x✝ = coeff ↑p ↑x✝ + coeff ↑q ↑x✝

Next tactic:
rw [coeff_add]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    

Proof state:
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
x : R
p : ↥(degreeLT R n)
⊢ AddHom.toFun
      { toFun := fun p n_1 => coeff ↑p ↑n_1,
        map_add' :=
          (_ :
            ∀ (p q : ↥(degreeLT R n)),
              (fun p n_1 => coeff ↑p ↑n_1) (p + q) = (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
      (x • p) =
    (RingHom.id R) x •
      AddHom.toFun
        { toFun := fun p n_1 => coeff ↑p ↑n_1,
          map_add' :=
            (_ :
              ∀ (p q : ↥(degreeLT R n)),
                (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                  (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
        p

Next tactic:
ext
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
x : R
p : ↥(degreeLT R n)
x✝ : Fin n
⊢ AddHom.toFun
      { toFun := fun p n_1 => coeff ↑p ↑n_1,
        map_add' :=
          (_ :
            ∀ (p q : ↥(degreeLT R n)),
              (fun p n_1 => coeff ↑p ↑n_1) (p + q) = (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
      (x • p) x✝ =
    ((RingHom.id R) x •
        AddHom.toFun
          { toFun := fun p n_1 => coeff ↑p ↑n_1,
            map_add' :=
              (_ :
                ∀ (p q : ↥(degreeLT R n)),
                  (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                    (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
          p)
      x✝

Next tactic:
dsimp
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
x : R
p : ↥(degreeLT R n)
x✝ : Fin n
⊢ coeff (x • ↑p) ↑x✝ = x * coeff ↑p ↑x✝

Next tactic:
rw [coeff_smul]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
x : R
p : ↥(degreeLT R n)
x✝ : Fin n
⊢ x • coeff ↑p ↑x✝ = x * coeff ↑p ↑x✝

Next tactic:
rfl
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    

Proof state:
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
⊢ Function.LeftInverse
    (fun f =>
      { val := ∑ i : Fin n, (monomial ↑i) (f i), property := (_ : ∑ i : Fin n, (monomial ↑i) (f i) ∈ degreeLT R n) })
    {
          toAddHom :=
            { toFun := fun p n_1 => coeff ↑p ↑n_1,
              map_add' :=
                (_ :
                  ∀ (p q : ↥(degreeLT R n)),
                    (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                      (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) },
          map_smul' :=
            (_ :
              ∀ (x : R) (p : ↥(degreeLT R n)),
                AddHom.toFun
                    { toFun := fun p n_1 => coeff ↑p ↑n_1,
                      map_add' :=
                        (_ :
                          ∀ (p q : ↥(degreeLT R n)),
                            (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                              (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                    (x • p) =
                  (RingHom.id R) x •
                    AddHom.toFun
                      { toFun := fun p n_1 => coeff ↑p ↑n_1,
                        map_add' :=
                          (_ :
                            ∀ (p q : ↥(degreeLT R n)),
                              (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                      p) }.toAddHom.toFun

Next tactic:
rintro ⟨p, hp⟩
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    

Proof state:
case mk
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : p ∈ degreeLT R n
⊢ (fun f =>
        { val := ∑ i : Fin n, (monomial ↑i) (f i), property := (_ : ∑ i : Fin n, (monomial ↑i) (f i) ∈ degreeLT R n) })
      (AddHom.toFun
        {
            toAddHom :=
              { toFun := fun p n_1 => coeff ↑p ↑n_1,
                map_add' :=
                  (_ :
                    ∀ (p q : ↥(degreeLT R n)),
                      (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                        (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) },
            map_smul' :=
              (_ :
                ∀ (x : R) (p : ↥(degreeLT R n)),
                  AddHom.toFun
                      { toFun := fun p n_1 => coeff ↑p ↑n_1,
                        map_add' :=
                          (_ :
                            ∀ (p q : ↥(degreeLT R n)),
                              (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                      (x • p) =
                    (RingHom.id R) x •
                      AddHom.toFun
                        { toFun := fun p n_1 => coeff ↑p ↑n_1,
                          map_add' :=
                            (_ :
                              ∀ (p q : ↥(degreeLT R n)),
                                (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                  (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                        p) }.toAddHom
        { val := p, property := hp }) =
    { val := p, property := hp }

Next tactic:
ext1
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    

Proof state:
case mk.a
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : p ∈ degreeLT R n
⊢ ↑((fun f =>
          { val := ∑ i : Fin n, (monomial ↑i) (f i),
            property := (_ : ∑ i : Fin n, (monomial ↑i) (f i) ∈ degreeLT R n) })
        (AddHom.toFun
          {
              toAddHom :=
                { toFun := fun p n_1 => coeff ↑p ↑n_1,
                  map_add' :=
                    (_ :
                      ∀ (p q : ↥(degreeLT R n)),
                        (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                          (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) },
              map_smul' :=
                (_ :
                  ∀ (x : R) (p : ↥(degreeLT R n)),
                    AddHom.toFun
                        { toFun := fun p n_1 => coeff ↑p ↑n_1,
                          map_add' :=
                            (_ :
                              ∀ (p q : ↥(degreeLT R n)),
                                (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                  (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                        (x • p) =
                      (RingHom.id R) x •
                        AddHom.toFun
                          { toFun := fun p n_1 => coeff ↑p ↑n_1,
                            map_add' :=
                              (_ :
                                ∀ (p q : ↥(degreeLT R n)),
                                  (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                    (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                          p) }.toAddHom
          { val := p, property := hp })) =
    ↑{ val := p, property := hp }

Next tactic:
simp only [Submodule.coe_mk]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    

Proof state:
case mk.a
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : p ∈ degreeLT R n
⊢ ∑ x : Fin n, (monomial ↑x) (coeff p ↑x) = p

Next tactic:
by_cases hp0 : p = 0
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · 

Proof state:
case pos
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : p ∈ degreeLT R n
hp0 : p = 0
⊢ ∑ x : Fin n, (monomial ↑x) (coeff p ↑x) = p

Next tactic:
subst hp0
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      

Proof state:
case pos
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
hp : 0 ∈ degreeLT R n
⊢ ∑ x : Fin n, (monomial ↑x) (coeff 0 ↑x) = 0

Next tactic:
simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
    

Proof state:
case neg
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : p ∈ degreeLT R n
hp0 : ¬p = 0
⊢ ∑ x : Fin n, (monomial ↑x) (coeff p ↑x) = p

Next tactic:
rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
    rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
    

Proof state:
case neg
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : natDegree p < n
hp0 : ¬p = 0
⊢ ∑ x : Fin n, (monomial ↑x) (coeff p ↑x) = p

Next tactic:
conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
    rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
    conv_rhs => 

Proof state:
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
p : R[X]
hp : natDegree p < n
hp0 : ¬p = 0
| p

Next tactic:
rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
    rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
    conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]
  right_inv f := by
    

Proof state:
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
f : Fin n → R
⊢ AddHom.toFun
      {
          toAddHom :=
            { toFun := fun p n_1 => coeff ↑p ↑n_1,
              map_add' :=
                (_ :
                  ∀ (p q : ↥(degreeLT R n)),
                    (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                      (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) },
          map_smul' :=
            (_ :
              ∀ (x : R) (p : ↥(degreeLT R n)),
                AddHom.toFun
                    { toFun := fun p n_1 => coeff ↑p ↑n_1,
                      map_add' :=
                        (_ :
                          ∀ (p q : ↥(degreeLT R n)),
                            (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                              (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                    (x • p) =
                  (RingHom.id R) x •
                    AddHom.toFun
                      { toFun := fun p n_1 => coeff ↑p ↑n_1,
                        map_add' :=
                          (_ :
                            ∀ (p q : ↥(degreeLT R n)),
                              (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                      p) }.toAddHom
      ((fun f =>
          { val := ∑ i : Fin n, (monomial ↑i) (f i),
            property := (_ : ∑ i : Fin n, (monomial ↑i) (f i) ∈ degreeLT R n) })
        f) =
    f

Next tactic:
ext i
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
    rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
    conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]
  right_inv f := by
    ext i
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
f : Fin n → R
i : Fin n
⊢ AddHom.toFun
      {
          toAddHom :=
            { toFun := fun p n_1 => coeff ↑p ↑n_1,
              map_add' :=
                (_ :
                  ∀ (p q : ↥(degreeLT R n)),
                    (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                      (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) },
          map_smul' :=
            (_ :
              ∀ (x : R) (p : ↥(degreeLT R n)),
                AddHom.toFun
                    { toFun := fun p n_1 => coeff ↑p ↑n_1,
                      map_add' :=
                        (_ :
                          ∀ (p q : ↥(degreeLT R n)),
                            (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                              (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                    (x • p) =
                  (RingHom.id R) x •
                    AddHom.toFun
                      { toFun := fun p n_1 => coeff ↑p ↑n_1,
                        map_add' :=
                          (_ :
                            ∀ (p q : ↥(degreeLT R n)),
                              (fun p n_1 => coeff ↑p ↑n_1) (p + q) =
                                (fun p n_1 => coeff ↑p ↑n_1) p + (fun p n_1 => coeff ↑p ↑n_1) q) }
                      p) }.toAddHom
      ((fun f =>
          { val := ∑ i : Fin n, (monomial ↑i) (f i),
            property := (_ : ∑ i : Fin n, (monomial ↑i) (f i) ∈ degreeLT R n) })
        f)
      i =
    f i

Next tactic:
simp only [finset_sum_coeff, Submodule.coe_mk]
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
  toFun p n := (↑p : R[X]).coeff n
  invFun f :=
    ⟨∑ i : Fin n, monomial i (f i),
      (degreeLT R n).sum_mem fun i _ =>
        mem_degreeLT.mpr
          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
  map_add' p q := by
    ext
    dsimp
    rw [coeff_add]
  map_smul' x p := by
    ext
    dsimp
    rw [coeff_smul]
    rfl
  left_inv := by
    rintro ⟨p, hp⟩
    ext1
    simp only [Submodule.coe_mk]
    by_cases hp0 : p = 0
    · subst hp0
      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
    rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
    conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]
  right_inv f := by
    ext i
    simp only [finset_sum_coeff, Submodule.coe_mk]
    

Proof state:
case h
R✝ : Type u
S : Type u_1
inst✝¹ : Semiring R✝
R : Type ?u.20962
inst✝ : Semiring R
n : ℕ
f : Fin n → R
i : Fin n
⊢ ∑ b : Fin n, coeff ((monomial ↑b) (f b)) ↑i = f i

Next tactic:
rw [Finset.sum_eq_single i, coeff_monomial, if_pos rfl]