Theorem: integral_sin_pow_aux
File: Mathlib/Analysis/SpecialFunctions/Integrals.lean

tactic: have continuous_sin_pow : ∀ (k : ℕ), (Continuous fun x => sin x ^ k) :=
  fun k => continuous_sin.pow k
state_before: a b : ℝ
n : ℕ
⊢ (∫ (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)

tactic: let C := sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b
state_before: a b : ℝ
n : ℕ
continuous_sin_pow : ∀ (k : ℕ), Continuous fun x => sin x ^ k
⊢ (∫ (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)

tactic: have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
state_before: 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
⊢ (∫ (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)

tactic: 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)
state_before: 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 : ∀ (α β γ : ℝ), β * α * γ * α = β * (α * α * γ)
⊢ (∫ (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)

tactic: have hv : ∀ x ∈ [[a, b]], HasDerivAt (-cos) (sin x) x := fun x _ => by
  simpa only [neg_neg] using (hasDerivAt_cos x).neg
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
⊢ (∫ (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)

tactic: have H := integral_mul_deriv_eq_deriv_mul hu hv ?_ ?_
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ (∫ (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)

tactic: all_goals apply Continuous.intervalIntegrable
state_before: case refine_1
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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ IntervalIntegrable (fun x => ↑(n + 1) * cos x * sin x ^ n) MeasureTheory.volume a b

case refine_2
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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ IntervalIntegrable (fun x => sin x) MeasureTheory.volume a b

tactic: ring
state_before: 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
α β γ : ℝ
⊢ β * α * γ * α = β * (α * α * γ)

tactic: simpa only [mul_right_comm] using (hasDerivAt_sin x).pow (n + 1)
state_before: 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 : ∀ (α β γ : ℝ), β * α * γ * α = β * (α * α * γ)
x : ℝ
x✝ : x ∈ [[a, b]]
⊢ HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x

tactic: simpa only [neg_neg] using (hasDerivAt_cos x).neg
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
x : ℝ
x✝ : x ∈ [[a, b]]
⊢ HasDerivAt (-cos) (sin x) x

tactic: simp only [_root_.pow_succ']
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ (∫ (x : ℝ) in a..b, sin x ^ (n + 2)) = ∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x

tactic: simp [H, h, sq]
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) = C + (↑n + ↑1) * ∫ (x : ℝ) in a..b, cos x ^ 2 * sin x ^ n

tactic: ring
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ -(sin b ^ (n + 1) * cos b) + sin a ^ (n + 1) * cos a = sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b

tactic: simp [cos_sq', sub_mul, ← pow_add, add_comm]
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ (C + (↑n + ↑1) * ∫ (x : ℝ) in a..b, cos x ^ 2 * sin x ^ n) =
    C + (↑n + 1) * ∫ (x : ℝ) in a..b, sin x ^ n - sin x ^ (n + 2)

tactic: rw [integral_sub, mul_sub, add_sub_assoc] <;> apply Continuous.intervalIntegrable
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ (C + (↑n + 1) * ∫ (x : ℝ) in a..b, sin x ^ n - sin x ^ (n + 2)) =
    (C + (↑n + 1) * ∫ (x : ℝ) in a..b, sin x ^ n) - (↑n + 1) * ∫ (x : ℝ) in a..b, sin x ^ (n + 2)

tactic: exact continuous_sin_pow n
state_before: case hf.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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ Continuous fun x => sin x ^ n

tactic: exact continuous_sin_pow (n + 2)
state_before: case hg.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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
H :
  (∫ (x : ℝ) in a..b, sin x ^ (n + 1) * sin x) =
    sin b ^ (n + 1) * (-cos) b - sin a ^ (n + 1) * (-cos) a - ∫ (x : ℝ) in a..b, ↑(n + 1) * cos x * sin x ^ n * (-cos) x
⊢ Continuous fun x => sin x ^ (n + 2)

tactic: apply Continuous.intervalIntegrable
state_before: case refine_2
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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ IntervalIntegrable (fun x => sin x) MeasureTheory.volume a b

tactic: have : Continuous fun x ↦ ↑(n + 1) * cos x := by continuity
state_before: case refine_1.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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ Continuous fun x => ↑(n + 1) * cos x * sin x ^ n

tactic: exact this.mul (continuous_sin_pow n)
state_before: case refine_1.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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
this : Continuous fun x => ↑(n + 1) * cos x
⊢ Continuous fun x => ↑(n + 1) * cos x * sin x ^ n

tactic: continuity
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ Continuous fun x => ↑(n + 1) * cos x

tactic: exact continuous_sin
state_before: 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 : ℝ), x ∈ [[a, b]] → HasDerivAt (fun y => sin y ^ (n + 1)) (↑(n + 1) * cos x * sin x ^ n) x
hv : ∀ (x : ℝ), x ∈ [[a, b]] → HasDerivAt (-cos) (sin x) x
⊢ Continuous fun x => sin x