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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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