l3lab/ntp-mathlib huggingface dataset:
theorem integral_sin_pow_aux :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b + (↑n + 1) * ∫ x in a..b, sin x ^ n) -
        (↑n + 1) * ∫ x in a..b, sin x ^ (n + 2) := by
  have continuous_sin_pow : ∀ (k : ℕ), (Continuous fun x => sin x ^ k) :=
    fun k => continuous_sin.pow k
  let C := sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b
  have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
  have hu : ∀ x ∈ [[a, b]],
      HasDerivAt (fun y => sin y ^ (n + 1)) ((n + 1 : ℕ) * cos x * sin x ^ n) x :=
    fun x _ => by simpa only [mul_right_comm] using (hasDerivAt_sin x).pow (n + 1)
  have hv : ∀ x ∈ [[a, b]], HasDerivAt (-cos) (sin x) x := fun x _ => by
    simpa only [neg_neg] using (hasDerivAt_cos x).neg
  have H := integral_mul_deriv_eq_deriv_mul hu hv ?_ ?_
  calc
    (∫ x in a..b, sin x ^ (n + 2)) = ∫ x in a..b, sin x ^ (n + 1) * sin x := by
      simp only [_root_.pow_succ']
    _ = C + (↑n + 1) * ∫ x in a..b, cos x ^ 2 * sin x ^ n := by simp [H, h, sq]; ring
    _ = C + (↑n + 1) * ∫ x in a..b, sin x ^ n - sin x ^ (n + 2) := by
      simp [cos_sq', sub_mul, ← pow_add, add_comm]
    _ = (C + (↑n + 1) * ∫ x in a..b, sin x ^ n) - (↑n + 1) * ∫ x in a..b, sin x ^ (n + 2) := by
      rw [integral_sub, mul_sub, add_sub_assoc] <;> apply Continuous.intervalIntegrable
      -- Porting note: was `... <;> continuity`
      · exact continuous_sin_pow n
      · exact continuous_sin_pow (n + 2)
  all_goals apply Continuous.intervalIntegrable
  -- Porting note: was `... <;> continuity`
  · have : Continuous fun x ↦ ↑(n + 1) * cos x := by continuity
    exact this.mul (continuous_sin_pow n)
  · 

Proof state:
case refine_2.hu
a b : ℝ
n : ℕ
continuous_sin_pow : ∀ (k : ℕ), Continuous fun x => sin x ^ k
C : ℝ := sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b
h : ∀ (α β γ : ℝ), β * α * γ * α = β * (α * α * γ)
hu : ∀ x ∈ [[a, b]], HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ x ∈ [[a, b]], HasDerivAt (-cos) (sin x) x
⊢ Continuous fun x => sin x

Next tactic:
exact continuous_sin
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  

Proof state:
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in a..b, sin x ^ (n + 2) =
    (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (↑n + 2) + (↑n + 1) / (↑n + 2) * ∫ (x : ℝ) in a..b, sin x ^ n

Next tactic:
have : n + 2 ≠ 0 := by linarith
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  have : n + 2 ≠ 0 := by 

Proof state:
a b : ℝ
n : ℕ
⊢ n + 2 ≠ 0

Next tactic:
linarith
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  have : n + 2 ≠ 0 := by linarith
  

Proof state:
a b : ℝ
n : ℕ
this : n + 2 ≠ 0
⊢ ∫ (x : ℝ) in a..b, sin x ^ (n + 2) =
    (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (↑n + 2) + (↑n + 1) / (↑n + 2) * ∫ (x : ℝ) in a..b, sin x ^ n

Next tactic:
have : (n : ℝ) + 2 ≠ 0 := by norm_cast
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  have : n + 2 ≠ 0 := by linarith
  have : (n : ℝ) + 2 ≠ 0 := by 

Proof state:
a b : ℝ
n : ℕ
this : n + 2 ≠ 0
⊢ ↑n + 2 ≠ 0

Next tactic:
norm_cast
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  have : n + 2 ≠ 0 := by linarith
  have : (n : ℝ) + 2 ≠ 0 := by norm_cast
  

Proof state:
a b : ℝ
n : ℕ
this✝ : n + 2 ≠ 0
this : ↑n + 2 ≠ 0
⊢ ∫ (x : ℝ) in a..b, sin x ^ (n + 2) =
    (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (↑n + 2) + (↑n + 1) / (↑n + 2) * ∫ (x : ℝ) in a..b, sin x ^ n

Next tactic:
field_simp
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  have : n + 2 ≠ 0 := by linarith
  have : (n : ℝ) + 2 ≠ 0 := by norm_cast
  field_simp
  

Proof state:
a b : ℝ
n : ℕ
this✝ : n + 2 ≠ 0
this : ↑n + 2 ≠ 0
⊢ (∫ (x : ℝ) in a..b, sin x ^ (n + 2)) * (↑n + 2) =
    sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b + (↑n + 1) * ∫ (x : ℝ) in a..b, sin x ^ n

Next tactic:
convert eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
    (∫ x in a..b, sin x ^ (n + 2)) =
      (sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
        (n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
  have : n + 2 ≠ 0 := by linarith
  have : (n : ℝ) + 2 ≠ 0 := by norm_cast
  field_simp
  convert eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1
  

Proof state:
case h.e'_2
a b : ℝ
n : ℕ
this✝ : n + 2 ≠ 0
this : ↑n + 2 ≠ 0
⊢ (∫ (x : ℝ) in a..b, sin x ^ (n + 2)) * (↑n + 2) =
    (∫ (x : ℝ) in a..b, sin x ^ (n + 2)) + (↑n + 1) * ∫ (x : ℝ) in a..b, sin x ^ (n + 2)

Next tactic:
ring
@[simp]
theorem integral_sin_sq : ∫ x in a..b, sin x ^ 2 = (sin a * cos a - sin b * cos b + b - a) / 2 :=
  by 

Proof state:
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in a..b, sin x ^ 2 = (sin a * cos a - sin b * cos b + b - a) / 2

Next tactic:
field_simp [integral_sin_pow, add_sub_assoc]
theorem integral_sin_pow_odd :
    (∫ x in (0)..π, sin x ^ (2 * n + 1)) = 2 * ∏ i in range n, (2 * (i:ℝ) + 2) / (2 * i + 3) := by
  

Proof state:
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * n + 1) = 2 * ∏ i in Finset.range n, (2 * ↑i + 2) / (2 * ↑i + 3)

Next tactic:
induction' n with k ih
theorem integral_sin_pow_odd :
    (∫ x in (0)..π, sin x ^ (2 * n + 1)) = 2 * ∏ i in range n, (2 * (i:ℝ) + 2) / (2 * i + 3) := by
  induction' n with k ih; · 

Proof state:
case zero
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * zero + 1) = 2 * ∏ i in Finset.range zero, (2 * ↑i + 2) / (2 * ↑i + 3)

Next tactic:
norm_num
theorem integral_sin_pow_odd :
    (∫ x in (0)..π, sin x ^ (2 * n + 1)) = 2 * ∏ i in range n, (2 * (i:ℝ) + 2) / (2 * i + 3) := by
  induction' n with k ih; · norm_num
  

Proof state:
case succ
a b : ℝ
n k : ℕ
ih : ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1) = 2 * ∏ i in Finset.range k, (2 * ↑i + 2) / (2 * ↑i + 3)
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * succ k + 1) = 2 * ∏ i in Finset.range (succ k), (2 * ↑i + 2) / (2 * ↑i + 3)

Next tactic:
rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
theorem integral_sin_pow_odd :
    (∫ x in (0)..π, sin x ^ (2 * n + 1)) = 2 * ∏ i in range n, (2 * (i:ℝ) + 2) / (2 * i + 3) := by
  induction' n with k ih; · norm_num
  rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
  

Proof state:
case succ
a b : ℝ
n k : ℕ
ih : ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1) = 2 * ∏ i in Finset.range k, (2 * ↑i + 2) / (2 * ↑i + 3)
⊢ (sin 0 ^ (2 * k + 1 + 1) * cos 0 - sin π ^ (2 * k + 1 + 1) * cos π) / (↑(2 * k + 1) + 2) +
      (↑(2 * k + 1) + 1) / (↑(2 * k + 1) + 2) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1) =
    (2 * ↑k + 2) / (2 * ↑k + 3) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1)

Next tactic:
norm_cast
theorem integral_sin_pow_odd :
    (∫ x in (0)..π, sin x ^ (2 * n + 1)) = 2 * ∏ i in range n, (2 * (i:ℝ) + 2) / (2 * i + 3) := by
  induction' n with k ih; · norm_num
  rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
  norm_cast
  

Proof state:
case succ
a b : ℝ
n k : ℕ
ih : ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1) = 2 * ∏ i in Finset.range k, (2 * ↑i + 2) / (2 * ↑i + 3)
⊢ (sin 0 ^ (2 * k + 1 + 1) * cos 0 - sin π ^ (2 * k + 1 + 1) * cos π) / ↑(2 * k + 1 + 2) +
      ↑(2 * k + 1 + 1) / ↑(2 * k + 1 + 2) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1) =
    ↑(2 * k + 2) / ↑(2 * k + 3) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1)

Next tactic:
simp [-cast_add, field_simps]
theorem integral_sin_pow_even :
    (∫ x in (0)..π, sin x ^ (2 * n)) = π * ∏ i in range n, (2 * (i:ℝ) + 1) / (2 * i + 2) := by
  

Proof state:
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * n) = π * ∏ i in Finset.range n, (2 * ↑i + 1) / (2 * ↑i + 2)

Next tactic:
induction' n with k ih
theorem integral_sin_pow_even :
    (∫ x in (0)..π, sin x ^ (2 * n)) = π * ∏ i in range n, (2 * (i:ℝ) + 1) / (2 * i + 2) := by
  induction' n with k ih; · 

Proof state:
case zero
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * zero) = π * ∏ i in Finset.range zero, (2 * ↑i + 1) / (2 * ↑i + 2)

Next tactic:
simp
theorem integral_sin_pow_even :
    (∫ x in (0)..π, sin x ^ (2 * n)) = π * ∏ i in range n, (2 * (i:ℝ) + 1) / (2 * i + 2) := by
  induction' n with k ih; · simp
  

Proof state:
case succ
a b : ℝ
n k : ℕ
ih : ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k) = π * ∏ i in Finset.range k, (2 * ↑i + 1) / (2 * ↑i + 2)
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * succ k) = π * ∏ i in Finset.range (succ k), (2 * ↑i + 1) / (2 * ↑i + 2)

Next tactic:
rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
theorem integral_sin_pow_even :
    (∫ x in (0)..π, sin x ^ (2 * n)) = π * ∏ i in range n, (2 * (i:ℝ) + 1) / (2 * i + 2) := by
  induction' n with k ih; · simp
  rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
  

Proof state:
case succ
a b : ℝ
n k : ℕ
ih : ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k) = π * ∏ i in Finset.range k, (2 * ↑i + 1) / (2 * ↑i + 2)
⊢ (sin 0 ^ (2 * k + 1) * cos 0 - sin π ^ (2 * k + 1) * cos π) / (↑(2 * k) + 2) +
      (↑(2 * k) + 1) / (↑(2 * k) + 2) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k) =
    (2 * ↑k + 1) / (2 * ↑k + 2) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k)

Next tactic:
norm_cast
theorem integral_sin_pow_even :
    (∫ x in (0)..π, sin x ^ (2 * n)) = π * ∏ i in range n, (2 * (i:ℝ) + 1) / (2 * i + 2) := by
  induction' n with k ih; · simp
  rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
  norm_cast
  

Proof state:
case succ
a b : ℝ
n k : ℕ
ih : ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k) = π * ∏ i in Finset.range k, (2 * ↑i + 1) / (2 * ↑i + 2)
⊢ (sin 0 ^ (2 * k + 1) * cos 0 - sin π ^ (2 * k + 1) * cos π) / ↑(2 * k + 2) +
      ↑(2 * k + 1) / ↑(2 * k + 2) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k) =
    ↑(2 * k + 1) / ↑(2 * k + 2) * ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k)

Next tactic:
simp [-cast_add, field_simps]
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  

Proof state:
a b : ℝ
n : ℕ
⊢ 0 < ∫ (x : ℝ) in 0 ..π, sin x ^ n

Next tactic:
rcases even_or_odd' n with ⟨k, rfl | rfl⟩
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  

Proof state:
case intro.inl
a b : ℝ
k : ℕ
⊢ 0 < ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k)

Next tactic:
simp only [integral_sin_pow_even, integral_sin_pow_odd]
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  

Proof state:
case intro.inr
a b : ℝ
k : ℕ
⊢ 0 < ∫ (x : ℝ) in 0 ..π, sin x ^ (2 * k + 1)

Next tactic:
simp only [integral_sin_pow_even, integral_sin_pow_odd]
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  

Proof state:
case intro.inl
a b : ℝ
k : ℕ
⊢ 0 < π * ∏ i in Finset.range k, (2 * ↑i + 1) / (2 * ↑i + 2)

Next tactic:
refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _)
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by 

Proof state:
a b : ℝ
k : ℕ
⊢ 0 < π

Next tactic:
norm_num [pi_pos]
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  

Proof state:
case intro.inr
a b : ℝ
k : ℕ
⊢ 0 < 2 * ∏ i in Finset.range k, (2 * ↑i + 2) / (2 * ↑i + 3)

Next tactic:
refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _)
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by 

Proof state:
a b : ℝ
k : ℕ
⊢ 0 < 2

Next tactic:
norm_num [pi_pos]
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  

Proof state:
case intro.inl.refine'_1
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * ↑n + 1

Next tactic:
norm_cast
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  

Proof state:
case intro.inl.refine'_2
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * ↑n + 2

Next tactic:
norm_cast
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  

Proof state:
case intro.inr.refine'_1
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * ↑n + 2

Next tactic:
norm_cast
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  

Proof state:
case intro.inr.refine'_2
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * ↑n + 3

Next tactic:
norm_cast
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  norm_cast <;>
  

Proof state:
case intro.inl.refine'_1
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * n + 1

Next tactic:
linarith
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  norm_cast <;>
  

Proof state:
case intro.inl.refine'_2
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * n + 2

Next tactic:
linarith
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  norm_cast <;>
  

Proof state:
case intro.inr.refine'_1
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * n + 2

Next tactic:
linarith
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
  rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
  simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
  refine' mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos _ _) <;>
  norm_cast <;>
  

Proof state:
case intro.inr.refine'_2
a b : ℝ
k n : ℕ
x✝ : n ∈ Finset.range k
⊢ 0 < 2 * n + 3

Next tactic:
linarith
theorem integral_sin_pow_succ_le : (∫ x in (0)..π, sin x ^ (n + 1)) ≤ ∫ x in (0)..π, sin x ^ n := by
  

Proof state:
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (n + 1) ≤ ∫ (x : ℝ) in 0 ..π, sin x ^ n

Next tactic:
let H x h := pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (n.le_add_right 1)
theorem integral_sin_pow_succ_le : (∫ x in (0)..π, sin x ^ (n + 1)) ≤ ∫ x in (0)..π, sin x ^ n := by
  let H x h := pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (n.le_add_right 1)
  

Proof state:
a b : ℝ
n : ℕ
H : ∀ x ∈ Set.Icc 0 π, sin x ^ (n + 1) ≤ sin x ^ n :=
  fun x h => pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (Nat.le_add_right n 1)
⊢ ∫ (x : ℝ) in 0 ..π, sin x ^ (n + 1) ≤ ∫ (x : ℝ) in 0 ..π, sin x ^ n

Next tactic:
refine' integral_mono_on pi_pos.le _ _ H
theorem integral_sin_pow_succ_le : (∫ x in (0)..π, sin x ^ (n + 1)) ≤ ∫ x in (0)..π, sin x ^ n := by
  let H x h := pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (n.le_add_right 1)
  refine' integral_mono_on pi_pos.le _ _ H <;> 

Proof state:
case refine'_1
a b : ℝ
n : ℕ
H : ∀ x ∈ Set.Icc 0 π, sin x ^ (n + 1) ≤ sin x ^ n :=
  fun x h => pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (Nat.le_add_right n 1)
⊢ IntervalIntegrable (fun x => sin x ^ (n + 1)) MeasureTheory.volume 0 π

Next tactic:
exact (continuous_sin.pow _).intervalIntegrable 0 π
theorem integral_sin_pow_succ_le : (∫ x in (0)..π, sin x ^ (n + 1)) ≤ ∫ x in (0)..π, sin x ^ n := by
  let H x h := pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (n.le_add_right 1)
  refine' integral_mono_on pi_pos.le _ _ H <;> 

Proof state:
case refine'_2
a b : ℝ
n : ℕ
H : ∀ x ∈ Set.Icc 0 π, sin x ^ (n + 1) ≤ sin x ^ n :=
  fun x h => pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (Nat.le_add_right n 1)
⊢ IntervalIntegrable (fun x => sin x ^ n) MeasureTheory.volume 0 π

Next tactic:
exact (continuous_sin.pow _).intervalIntegrable 0 π
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  

Proof state:
a b : ℝ
n : ℕ
⊢ ∫ (x : ℝ) in a..b, cos x ^ (n + 2) =
    (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ n) -
      (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ (n + 2)

Next tactic:
have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
  

Proof state:
a b : ℝ
n : ℕ
continuous_cos_pow : ∀ (k : ℕ), Continuous fun x => cos x ^ k
⊢ ∫ (x : ℝ) in a..b, cos x ^ (n + 2) =
    (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ n) -
      (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ (n + 2)

Next tactic:
let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
  let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
  

Proof state:
a b : ℝ
n : ℕ
continuous_cos_pow : ∀ (k : ℕ), Continuous fun x => cos x ^ k
C : ℝ := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
⊢ ∫ (x : ℝ) in a..b, cos x ^ (n + 2) =
    (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ n) -
      (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ (n + 2)

Next tactic:
have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
  let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
  have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by 

Proof state:
a b : ℝ
n : ℕ
continuous_cos_pow : ∀ (k : ℕ), Continuous fun x => cos x ^ k
C : ℝ := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
α β γ : ℝ
⊢ β * α * γ * α = β * (α * α * γ)

Next tactic:
ring
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
  let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
  have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
  

Proof state:
a b : ℝ
n : ℕ
continuous_cos_pow : ∀ (k : ℕ), Continuous fun x => cos x ^ k
C : ℝ := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
h : ∀ (α β γ : ℝ), β * α * γ * α = β * (α * α * γ)
⊢ ∫ (x : ℝ) in a..b, cos x ^ (n + 2) =
    (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ n) -
      (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ (n + 2)

Next tactic:
have hu : ∀ x ∈ [[a, b]],
      HasDerivAt (fun y => cos y ^ (n + 1)) (-(n + 1 : ℕ) * sin x * cos x ^ n) x :=
    fun x _ => by
      simpa only [mul_right_comm, neg_mul, mul_neg] using (hasDerivAt_cos x).pow (n + 1)
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
  let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
  have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
  have hu : ∀ x ∈ [[a, b]],
      HasDerivAt (fun y => cos y ^ (n + 1)) (-(n + 1 : ℕ) * sin x * cos x ^ n) x :=
    fun x _ => by
      

Proof state:
a b : ℝ
n : ℕ
continuous_cos_pow : ∀ (k : ℕ), Continuous fun x => cos x ^ k
C : ℝ := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
h : ∀ (α β γ : ℝ), β * α * γ * α = β * (α * α * γ)
x : ℝ
x✝ : x ∈ [[a, b]]
⊢ HasDerivAt (fun y => cos y ^ (n + 1)) (-↑(n + 1) * sin x * cos x ^ n) x

Next tactic:
simpa only [mul_right_comm, neg_mul, mul_neg] using (hasDerivAt_cos x).pow (n + 1)
theorem integral_cos_pow_aux :
    (∫ x in a..b, cos x ^ (n + 2)) =
      (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
        (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
  have continuous_cos_pow : ∀ (k : ℕ), (Continuous fun x => cos x ^ k) :=
    fun k => continuous_cos.pow k
  let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
  have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
  have hu : ∀ x ∈ [[a, b]],
      HasDerivAt (fun y => cos y ^ (n + 1)) (-(n + 1 : ℕ) * sin x * cos x ^ n) x :=
    fun x _ => by
      simpa only [mul_right_comm, neg_mul, mul_neg] using (hasDerivAt_cos x).pow (n + 1)
  

Proof state:
a b : ℝ
n : ℕ
continuous_cos_pow : ∀ (k : ℕ), Continuous fun x => cos x ^ k
C : ℝ := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
h : ∀ (α β γ : ℝ), β * α * γ * α = β * (α * α * γ)
hu : ∀ x ∈ [[a, b]], HasDerivAt (fun y => cos y ^ (n + 1)) (-↑(n + 1) * sin x * cos x ^ n) x
⊢ ∫ (x : ℝ) in a..b, cos x ^ (n + 2) =
    (cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ n) -
      (↑n + 1) * ∫ (x : ℝ) in a..b, cos x ^ (n + 2)

Next tactic:
have hv : ∀ x ∈ [[a, b]], HasDerivAt sin (cos x) x := fun x _ => hasDerivAt_sin x