Theorem: Polynomial.geom_sum_X_comp_X_add_one_eq_sum
File: Mathlib/RingTheory/Polynomial/Basic.lean

tactic: ext i
state_before: R : Type u
S : Type u_1
inst✝ : Semiring R
n : ℕ
⊢ (∑ i ∈ range n, X ^ i).comp (X + 1) = ∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i
state_after: case a
R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = (∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i).coeff i

tactic: trans (n.choose (i + 1) : R)
state_before: case a
R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = (∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i).coeff i
state_after: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = ↑(n.choose (i + 1))

R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ↑(n.choose (i + 1)) = (∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i).coeff i

tactic: swap
state_before: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = ↑(n.choose (i + 1))

R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ↑(n.choose (i + 1)) = (∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i).coeff i
state_after: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ↑(n.choose (i + 1)) = (∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i).coeff i

R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = ↑(n.choose (i + 1))

tactic: induction' n with n ih generalizing i
state_before: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = ↑(n.choose (i + 1))
state_after: case zero
R : Type u
S : Type u_1
inst✝ : Semiring R
i : ℕ
⊢ ((∑ i ∈ range 0, X ^ i).comp (X + 1)).coeff i = ↑(Nat.choose 0 (i + 1))

case succ
R : Type u
S : Type u_1
inst✝ : Semiring R
n : ℕ
ih : ∀ (i : ℕ), ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = ↑(n.choose (i + 1))
i : ℕ
⊢ ((∑ i ∈ range (n + 1), X ^ i).comp (X + 1)).coeff i = ↑((n + 1).choose (i + 1))

tactic: simp only [finset_sum_coeff, ← C_eq_natCast, coeff_C_mul_X_pow]
state_before: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ↑(n.choose (i + 1)) = (∑ i ∈ range n, ↑(n.choose (i + 1)) * X ^ i).coeff i
state_after: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ↑(n.choose (i + 1)) = ∑ x ∈ range n, if i = x then ↑(n.choose (x + 1)) else 0

tactic: rw [Finset.sum_eq_single i, if_pos rfl]
state_before: R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ↑(n.choose (i + 1)) = ∑ x ∈ range n, if i = x then ↑(n.choose (x + 1)) else 0
state_after: case h₀
R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ∀ b ∈ range n, b ≠ i → (if i = b then ↑(n.choose (b + 1)) else 0) = 0

case h₁
R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ i ∉ range n → (if i = i then ↑(n.choose (i + 1)) else 0) = 0

tactic: simp (config := { contextual := true }) only [@eq_comm _ i, if_false, eq_self_iff_true,
  imp_true_iff]
state_before: case h₀
R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ ∀ b ∈ range n, b ≠ i → (if i = b then ↑(n.choose (b + 1)) else 0) = 0
state_after: no goals

tactic: simp (config := { contextual := true }) only [Nat.lt_add_one_iff, Nat.choose_eq_zero_of_lt,
  Nat.cast_zero, Finset.mem_range, not_lt, eq_self_iff_true, if_true, imp_true_iff]
state_before: case h₁
R : Type u
S : Type u_1
inst✝ : Semiring R
n i : ℕ
⊢ i ∉ range n → (if i = i then ↑(n.choose (i + 1)) else 0) = 0
state_after: no goals

tactic: dsimp
state_before: case zero
R : Type u
S : Type u_1
inst✝ : Semiring R
i : ℕ
⊢ ((∑ i ∈ range 0, X ^ i).comp (X + 1)).coeff i = ↑(Nat.choose 0 (i + 1))
state_after: case zero
R : Type u
S : Type u_1
inst✝ : Semiring R
i : ℕ
⊢ (comp 0 (X + 1)).coeff i = ↑0

tactic: simp only [zero_comp, coeff_zero, Nat.cast_zero]
state_before: case zero
R : Type u
S : Type u_1
inst✝ : Semiring R
i : ℕ
⊢ (comp 0 (X + 1)).coeff i = ↑0
state_after: no goals

tactic: simp only [geom_sum_succ', ih, add_comp, X_pow_comp, coeff_add, Nat.choose_succ_succ,
Nat.cast_add, coeff_X_add_one_pow]
state_before: case succ
R : Type u
S : Type u_1
inst✝ : Semiring R
n : ℕ
ih : ∀ (i : ℕ), ((∑ i ∈ range n, X ^ i).comp (X + 1)).coeff i = ↑(n.choose (i + 1))
i : ℕ
⊢ ((∑ i ∈ range (n + 1), X ^ i).comp (X + 1)).coeff i = ↑((n + 1).choose (i + 1))
state_after: no goals