-- Mathlib/RingTheory/Polynomial/Basic.lean
theorem degreeLE_eq_span_X_pow [DecidableEq R] {n : ℕ} :
    degreeLE R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n)

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
k : ℕ
hk : k ∈ p.support
this : k ≤ ↑n
⊢ p.coeff k • X ^ k ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
refine
  Submodule.smul_mem _ _
    (Submodule.subset_span <|
      Finset.mem_coe.2 <|
        Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩)

Result:
no goals

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p ∈ degreeLE R ↑n
⊢ p ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
replace hp := mem_degreeLE.1 hp

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
⊢ p ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
k : ℕ
hk : k ∈ p.support
this : k ≤ ↑n
⊢ (monomial k) (p.coeff k) ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
rw [← C_mul_X_pow_eq_monomial, C_mul']

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
k : ℕ
hk : k ∈ p.support
this : k ≤ ↑n
⊢ p.coeff k • X ^ k ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Proof state:
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ degreeLE R ↑n = Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
apply le_antisymm

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ degreeLE R ↑n ≤ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1))) ≤ degreeLE R ↑n

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
k : ℕ
hk : k ∈ p.support
⊢ (monomial k) (p.coeff k) ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk)

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
k : ℕ
hk : k ∈ p.support
this : k ≤ ↑n
⊢ (monomial k) (p.coeff k) ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
⊢ p ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
⊢ ∑ n ∈ p.support, (monomial n) (p.coeff n) ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1))) ≤ degreeLE R ↑n

Tactic:
rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ ↑(range (n + 1)) ⊆ (fun n => X ^ n) ⁻¹' ↑(degreeLE R ↑n)

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
⊢ ∑ n ∈ p.support, (monomial n) (p.coeff n) ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
refine Submodule.sum_mem _ fun k hk => ?_

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p.degree ≤ ↑n
k : ℕ
hk : k ∈ p.support
⊢ (monomial k) (p.coeff k) ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ degreeLE R ↑n ≤ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Tactic:
intro p hp

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
p : R[X]
hp : p ∈ degreeLE R ↑n
⊢ p ∈ Submodule.span R ↑(image (fun n => X ^ n) (range (n + 1)))

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n k : ℕ
hk : k ∈ ↑(range (n + 1))
⊢ ((fun n => X ^ n) k).degree ≤ ↑n

Tactic:
exact
  (degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk)

Result:
no goals

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n k : ℕ
hk : k ∈ ↑(range (n + 1))
⊢ k ∈ (fun n => X ^ n) ⁻¹' ↑(degreeLE R ↑n)

Tactic:
apply mem_degreeLE.2

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n k : ℕ
hk : k ∈ ↑(range (n + 1))
⊢ ((fun n => X ^ n) k).degree ≤ ↑n

Proof state:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n : ℕ
⊢ ↑(range (n + 1)) ⊆ (fun n => X ^ n) ⁻¹' ↑(degreeLE R ↑n)

Tactic:
intro k hk

Result:
case a
R : Type u
inst✝¹ : Semiring R
inst✝ : DecidableEq R
n k : ℕ
hk : k ∈ ↑(range (n + 1))
⊢ k ∈ (fun n => X ^ n) ⁻¹' ↑(degreeLE R ↑n)