Theorem: Stirling.log_stirlingSeq_bounded_aux
File: Mathlib/Analysis/SpecialFunctions/Stirling.lean

tactic: let d := ∑' k : ℕ, ↑1 / (k.succ:ℝ) ^ 2
state_before: ⊢ ∃ c, ∀ (n : ℕ), Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ c

tactic: use (1 / 4 * d : ℝ)
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
⊢ ∃ c, ∀ (n : ℕ), Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ c

tactic: let log_stirlingSeq' : ℕ → ℝ := fun k => log (stirlingSeq k.succ)
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
⊢ ∀ (n : ℕ), Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ 1 / 4 * d

tactic: intro n
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
⊢ ∀ (n : ℕ), Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ 1 / 4 * d

tactic: have h₁ : ∀ k, log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤
    ↑1 / ↑4 * (↑1 / (k.succ:ℝ) ^ 2) := by
  intro k; convert log_stirlingSeq_sub_log_stirlingSeq_succ k using 1; field_simp
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
⊢ Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ 1 / 4 * d

tactic: have h₂ : (∑ k : ℕ in range n, ↑1 / (k.succ:ℝ) ^ 2) ≤ d := by
  have := (summable_nat_add_iff 1).mpr <| Real.summable_one_div_nat_pow.mpr one_lt_two
  simp only [rpow_nat_cast] at this
  exact sum_le_tsum (range n) (fun k _ => by positivity) this
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
⊢ Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ 1 / 4 * d

tactic: calc
  log (stirlingSeq 1) - log (stirlingSeq n.succ) = log_stirlingSeq' 0 - log_stirlingSeq' n :=
    rfl
  _ = ∑ k in range n, (log_stirlingSeq' k - log_stirlingSeq' (k + 1)) := by
    rw [← sum_range_sub' log_stirlingSeq' n]
  _ ≤ ∑ k in range n, ↑1 / ↑4 * (↑1 / ↑(k.succ) ^ 2) := (sum_le_sum fun k _ => h₁ k)
  _ = ↑1 / ↑4 * ∑ k in range n, ↑1 / ↑(k.succ) ^ 2 := by rw [mul_sum]
  _ ≤ 1 / 4 * d := mul_le_mul_of_nonneg_left h₂ <| by positivity
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
h₂ : ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d
⊢ Real.log (stirlingSeq 1) - Real.log (stirlingSeq (succ n)) ≤ 1 / 4 * d

tactic: intro k
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
⊢ ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)

tactic: convert log_stirlingSeq_sub_log_stirlingSeq_succ k using 1
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n k : ℕ
⊢ log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)

tactic: field_simp
state_before: case h.e'_4
d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n k : ℕ
⊢ 1 / 4 * (1 / ↑(succ k) ^ 2) = 1 / (4 * ↑(succ k) ^ 2)

tactic: have := (summable_nat_add_iff 1).mpr <| Real.summable_one_div_nat_pow.mpr one_lt_two
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
⊢ ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d

tactic: simp only [rpow_nat_cast] at this
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
this : Summable fun n => 1 / ↑(n + 1) ^ ↑2
⊢ ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d

tactic: exact sum_le_tsum (range n) (fun k _ => by positivity) this
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
this : Summable fun n => 1 / ↑(n + 1) ^ 2
⊢ ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d

tactic: positivity
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
this : Summable fun n => 1 / ↑(n + 1) ^ 2
k : ℕ
x✝ : ¬k ∈ range n
⊢ 0 ≤ 1 / ↑(succ k) ^ 2

tactic: rw [← sum_range_sub' log_stirlingSeq' n]
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
h₂ : ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d
⊢ log_stirlingSeq' 0 - log_stirlingSeq' n = ∑ k in range n, (log_stirlingSeq' k - log_stirlingSeq' (k + 1))

tactic: rw [mul_sum]
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
h₂ : ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d
⊢ ∑ k in range n, 1 / 4 * (1 / ↑(succ k) ^ 2) = 1 / 4 * ∑ k in range n, 1 / ↑(succ k) ^ 2

tactic: positivity
state_before: d : ℝ := ∑' (k : ℕ), 1 / ↑(succ k) ^ 2
log_stirlingSeq' : ℕ → ℝ := fun k => Real.log (stirlingSeq (succ k))
n : ℕ
h₁ : ∀ (k : ℕ), log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / ↑(succ k) ^ 2)
h₂ : ∑ k in range n, 1 / ↑(succ k) ^ 2 ≤ d
⊢ 0 ≤ 1 / 4