Theorem: Polynomial.sum_bernoulli
File: Mathlib/NumberTheory/BernoulliPolynomials.lean

tactic: simp_rw [bernoulli_def, Finset.smul_sum, Finset.range_eq_Ico, ← Finset.sum_Ico_Ico_comm,
  Finset.sum_Ico_eq_sum_range]
state_before: n : ℕ
⊢ ∑ k ∈ range (n + 1), ↑((n + 1).choose k) • bernoulli k = (monomial n) (↑n + 1)
state_after: n : ℕ
⊢ ∑ k ∈ range (n + 1 - 0),
      ∑ k_1 ∈ range (n + 1 - (0 + k)),
        ↑((n + 1).choose (0 + k + k_1)) •
          (monomial (0 + k)) (_root_.bernoulli (0 + k + k_1 - (0 + k)) * ↑((0 + k + k_1).choose (0 + k))) =
    (monomial n) (↑n + 1)

tactic: simp only [add_tsub_cancel_left, tsub_zero, zero_add, map_add]
state_before: n : ℕ
⊢ ∑ k ∈ range (n + 1 - 0),
      ∑ k_1 ∈ range (n + 1 - (0 + k)),
        ↑((n + 1).choose (0 + k + k_1)) •
          (monomial (0 + k)) (_root_.bernoulli (0 + k + k_1 - (0 + k)) * ↑((0 + k + k_1).choose (0 + k))) =
    (monomial n) (↑n + 1)
state_after: n : ℕ
⊢ ∑ x ∈ range (n + 1),
      ∑ x_1 ∈ range (n + 1 - x),
        ↑((n + 1).choose (x + x_1)) • (monomial x) (_root_.bernoulli x_1 * ↑((x + x_1).choose x)) =
    (monomial n) ↑n + (monomial n) 1

tactic: simp_rw [smul_monomial, mul_comm (_root_.bernoulli _) _, smul_eq_mul, ← mul_assoc]
state_before: n : ℕ
⊢ ∑ x ∈ range (n + 1),
      ∑ x_1 ∈ range (n + 1 - x),
        ↑((n + 1).choose (x + x_1)) • (monomial x) (_root_.bernoulli x_1 * ↑((x + x_1).choose x)) =
    (monomial n) ↑n + (monomial n) 1
state_after: n : ℕ
⊢ ∑ x ∈ range (n + 1),
      ∑ x_1 ∈ range (n + 1 - x),
        (monomial x) (↑((n + 1).choose (x + x_1)) * ↑((x + x_1).choose x) * _root_.bernoulli x_1) =
    (monomial n) ↑n + (monomial n) 1

tactic: simp_rw [← sum_smul]
state_before: n : ℕ
⊢ ∑ x ∈ range (n + 1),
      ∑ x_1 ∈ range (n + 1 - x), (↑((n + 1 - x).choose x_1) * _root_.bernoulli x_1) • (monomial x) ↑((n + 1).choose x) =
    (monomial n) ↑n + (monomial n) 1
state_after: n : ℕ
⊢ ∑ x ∈ range (n + 1),
      (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) =
    (monomial n) ↑n + (monomial n) 1

tactic: rw [sum_range_succ_comm]
state_before: n : ℕ
⊢ ∑ x ∈ range (n + 1),
      (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) =
    (monomial n) ↑n + (monomial n) 1
state_after: n : ℕ
⊢ (∑ i ∈ range (n + 1 - n), ↑((n + 1 - n).choose i) * _root_.bernoulli i) • (monomial n) ↑((n + 1).choose n) +
      ∑ x ∈ range n,
        (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) =
    (monomial n) ↑n + (monomial n) 1

tactic: simp only [add_right_eq_self, mul_one, cast_one, cast_add, add_tsub_cancel_left,
  choose_succ_self_right, one_smul, _root_.bernoulli_zero, sum_singleton, zero_add,
  map_add, range_one, bernoulli_zero, mul_one, one_mul, add_zero, choose_self]
state_before: n : ℕ
⊢ (∑ i ∈ range (n + 1 - n), ↑((n + 1 - n).choose i) * _root_.bernoulli i) • (monomial n) ↑((n + 1).choose n) +
      ∑ x ∈ range n,
        (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) =
    (monomial n) ↑n + (monomial n) 1
state_after: n : ℕ
⊢ ∑ x ∈ range n,
      (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) =
    0

tactic: apply sum_eq_zero fun x hx => _
state_before: n : ℕ
⊢ ∑ x ∈ range n,
      (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) =
    0
state_after: n : ℕ
⊢ ∀ x ∈ range n,
    (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) = 0

tactic: have f : ∀ x ∈ range n, ¬n + 1 - x = 1 := by
  rintro x H
  rw [mem_range] at H
  rw [eq_comm]
  exact _root_.ne_of_lt (Nat.lt_of_lt_of_le one_lt_two (le_tsub_of_add_le_left (succ_le_succ H)))
state_before: n : ℕ
⊢ ∀ x ∈ range n,
    (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) = 0
state_after: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
⊢ ∀ x ∈ range n,
    (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) = 0

tactic: intro x hx
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
⊢ ∀ x ∈ range n,
    (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) = 0
state_after: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) = 0

tactic: rw [sum_bernoulli]
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ (∑ i ∈ range (n + 1 - x), ↑((n + 1 - x).choose i) * _root_.bernoulli i) • (monomial x) ↑((n + 1).choose x) = 0
state_after: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ (if n + 1 - x = 1 then 1 else 0) • (monomial x) ↑((n + 1).choose x) = 0

tactic: have g : ite (n + 1 - x = 1) (1 : ℚ) 0 = 0 := by
  simp only [ite_eq_right_iff, one_ne_zero]
  intro h₁
  exact (f x hx) h₁
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ (if n + 1 - x = 1 then 1 else 0) • (monomial x) ↑((n + 1).choose x) = 0
state_after: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
g : (if n + 1 - x = 1 then 1 else 0) = 0
⊢ (if n + 1 - x = 1 then 1 else 0) • (monomial x) ↑((n + 1).choose x) = 0

tactic: rw [g, zero_smul]
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
g : (if n + 1 - x = 1 then 1 else 0) = 0
⊢ (if n + 1 - x = 1 then 1 else 0) • (monomial x) ↑((n + 1).choose x) = 0
state_after: no goals

tactic: assumption
state_before: n x✝¹ : ℕ
a✝¹ : x✝¹ ∈ range (n + 1)
x✝ : ℕ
a✝ : x✝ ∈ range (n + 1 - x✝¹)
⊢ x✝¹ ∈ range (n + 1)
state_after: no goals

tactic: assumption
state_before: n x✝¹ : ℕ
a✝¹ : x✝¹ ∈ range (n + 1)
x✝ : ℕ
a✝ : x✝ ∈ range (n + 1 - x✝¹)
⊢ x✝ ∈ range (n + 1 - x✝¹)
state_after: no goals

tactic: rintro x H
state_before: n : ℕ
⊢ ∀ x ∈ range n, ¬n + 1 - x = 1
state_after: n x : ℕ
H : x ∈ range n
⊢ ¬n + 1 - x = 1

tactic: rw [mem_range] at H
state_before: n x : ℕ
H : x ∈ range n
⊢ ¬n + 1 - x = 1
state_after: n x : ℕ
H : x < n
⊢ ¬n + 1 - x = 1

tactic: rw [eq_comm]
state_before: n x : ℕ
H : x < n
⊢ ¬n + 1 - x = 1
state_after: n x : ℕ
H : x < n
⊢ ¬1 = n + 1 - x

tactic: exact _root_.ne_of_lt (Nat.lt_of_lt_of_le one_lt_two (le_tsub_of_add_le_left (succ_le_succ H)))
state_before: n x : ℕ
H : x < n
⊢ ¬1 = n + 1 - x
state_after: no goals

tactic: simp only [ite_eq_right_iff, one_ne_zero]
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ (if n + 1 - x = 1 then 1 else 0) = 0
state_after: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ n + 1 - x = 1 → False

tactic: intro h₁
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
⊢ n + 1 - x = 1 → False
state_after: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
h₁ : n + 1 - x = 1
⊢ False

tactic: exact (f x hx) h₁
state_before: n : ℕ
f : ∀ x ∈ range n, ¬n + 1 - x = 1
x : ℕ
hx : x ∈ range n
h₁ : n + 1 - x = 1
⊢ False
state_after: no goals