-- Mathlib/RingTheory/PowerBasis.lean
theorem mem_span_pow' {x y : S} {d : ℕ} :
    y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : ℕ)) ↔
      ∃ f : R[X], f.degree < d ∧ y = aeval x f

Proof state:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
this : (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)
⊢ (∃ l, (∀ (x : ℕ), d ≤ x → l x = 0) ∧ ∑ x_1 ∈ l.support, (algebraMap R S) (l x_1) * x ^ x_1 = y) ↔
    ∃ q, (∀ (m : ℕ), d ≤ m → q m = 0) ∧ ∑ x_1 ∈ { toFinsupp := q }.support, (algebraMap R S) (q x_1) * x ^ x_1 = y

Tactic:
exact Iff.rfl

Result:
no goals

Proof state:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
this : (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)
⊢ (∃ l, (∀ (x : ℕ), d ≤ x → l x = 0) ∧ ∑ x_1 ∈ l.support, (algebraMap R S) (l x_1) * x ^ x_1 = y) ↔
    ∃ q, (∀ (m : ℕ), d ≤ m → q m = 0) ∧ y = ∑ x_1 ∈ { toFinsupp := q }.support, (algebraMap R S) (q x_1) * x ^ x_1

Tactic:
simp_rw [@eq_comm _ y]

Result:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
this : (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)
⊢ (∃ l, (∀ (x : ℕ), d ≤ x → l x = 0) ∧ ∑ x_1 ∈ l.support, (algebraMap R S) (l x_1) * x ^ x_1 = y) ↔
    ∃ q, (∀ (m : ℕ), d ≤ m → q m = 0) ∧ ∑ x_1 ∈ { toFinsupp := q }.support, (algebraMap R S) (q x_1) * x ^ x_1 = y

Proof state:
case h
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
n : S
⊢ (∃ y, x ^ ↑y = n) ↔ ∃ x_1 < d, x ^ x_1 = n

Tactic:
exact ⟨fun ⟨⟨i, hi⟩, hy⟩ => ⟨i, hi, hy⟩, fun ⟨i, hi, hy⟩ => ⟨⟨i, hi⟩, hy⟩⟩

Result:
no goals

Proof state:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
⊢ (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)

Tactic:
ext n

Result:
case h
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
n : S
⊢ (n ∈ Set.range fun i => x ^ ↑i) ↔ n ∈ (fun i => x ^ i) '' ↑(Finset.range d)

Proof state:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
this : (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)
⊢ y ∈ Submodule.span R (Set.range fun i => x ^ ↑i) ↔ ∃ f, f.degree < ↑d ∧ y = (aeval x) f

Tactic:
simp only [this, mem_span_image_iff_linearCombination, degree_lt_iff_coeff_zero, Finsupp.support,
  exists_iff_exists_finsupp, coeff, aeval_def, eval₂RingHom', eval₂_eq_sum, Polynomial.sum,
  mem_supported', linearCombination, Finsupp.sum, Algebra.smul_def, eval₂_zero, exists_prop,
  LinearMap.id_coe, eval₂_one, id, not_lt, Finsupp.coe_lsum, LinearMap.coe_smulRight,
  Finset.mem_range, AlgHom.coe_mks, Finset.mem_coe]

Result:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
this : (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)
⊢ (∃ l, (∀ (x : ℕ), d ≤ x → l x = 0) ∧ ∑ x_1 ∈ l.support, (algebraMap R S) (l x_1) * x ^ x_1 = y) ↔
    ∃ q, (∀ (m : ℕ), d ≤ m → q m = 0) ∧ y = ∑ x_1 ∈ { toFinsupp := q }.support, (algebraMap R S) (q x_1) * x ^ x_1

Proof state:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
⊢ y ∈ Submodule.span R (Set.range fun i => x ^ ↑i) ↔ ∃ f, f.degree < ↑d ∧ y = (aeval x) f

Tactic:
have : (Set.range fun i : Fin d => x ^ (i : ℕ)) = (fun i : ℕ => x ^ i) '' ↑(Finset.range d) := by
  ext n
  simp_rw [Set.mem_range, Set.mem_image, Finset.mem_coe, Finset.mem_range]
  exact ⟨fun ⟨⟨i, hi⟩, hy⟩ => ⟨i, hi, hy⟩, fun ⟨i, hi, hy⟩ => ⟨⟨i, hi⟩, hy⟩⟩

Result:
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
this : (Set.range fun i => x ^ ↑i) = (fun i => x ^ i) '' ↑(Finset.range d)
⊢ y ∈ Submodule.span R (Set.range fun i => x ^ ↑i) ↔ ∃ f, f.degree < ↑d ∧ y = (aeval x) f

Proof state:
case h
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
n : S
⊢ (n ∈ Set.range fun i => x ^ ↑i) ↔ n ∈ (fun i => x ^ i) '' ↑(Finset.range d)

Tactic:
simp_rw [Set.mem_range, Set.mem_image, Finset.mem_coe, Finset.mem_range]

Result:
case h
R : Type u_1
S : Type u_2
inst✝² : CommRing R
inst✝¹ : Ring S
inst✝ : Algebra R S
x y : S
d : ℕ
n : S
⊢ (∃ y, x ^ ↑y = n) ↔ ∃ x_1 < d, x ^ x_1 = n