-- Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : ℂ} (hs : 0 < re s) :
    Tendsto (fun n : ℕ => ∫ x : ℝ in (0)..n, ((1 - x / n) ^ n : ℝ) * (x : ℂ) ^ (s - 1)) atTop
      (𝓝 <| Gamma s)

Proof state:
case h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
⊢ Tendsto (fun x_1 => ↑((1 - x / ↑x_1) ^ x_1) * ↑x ^ (s - 1)) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))

Tactic:
simp_rw [mul_comm]

Result:
case h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
⊢ Tendsto (fun x_1 => ↑x ^ (s - 1) * ↑((1 - x / ↑x_1) ^ x_1)) atTop (𝓝 (↑x ^ (s - 1) * ↑(rexp (-x))))

Proof state:
case h.h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
n : ℕ
hn : x ≤ ↑n
⊢ x ∈ Ioc 0 ↑n

Tactic:
exact ⟨hx, hn⟩

Result:
no goals

Proof state:
case h.e'_3
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
⊢ (fun x_1 => (1 - x / ↑x_1) ^ x_1) = fun x_1 => (1 + -x / ↑x_1) ^ x_1

Tactic:
ext1 n

Result:
case h.e'_3.h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
n : ℕ
⊢ (1 - x / ↑n) ^ n = (1 + -x / ↑n) ^ n

Proof state:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
⊢ ∀ᵐ (a : ℝ) ∂volume.restrict (Ioi 0), ‖f n a‖ ≤ rexp (-a) * a ^ (s.re - 1)

Tactic:
rw [ae_restrict_iff' measurableSet_Ioi]

Result:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
⊢ ∀ᵐ (x : ℝ), x ∈ Ioi 0 → ‖f n x‖ ≤ rexp (-x) * x ^ (s.re - 1)

Proof state:
case h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
x : ℝ
hx : x ∈ Ioi 0
⊢ ‖f n x‖ ≤ rexp (-x) * x ^ (s.re - 1)

Tactic:
dsimp only [f]

Result:
case h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
x : ℝ
hx : x ∈ Ioi 0
⊢ ‖(Ioc 0 ↑n).indicator (fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)) x‖ ≤ rexp (-x) * x ^ (s.re - 1)

Proof state:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
n : ℕ
⊢ IntervalIntegrable (fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)) volume 0 ↑n

Tactic:
apply IntervalIntegrable.continuousOn_mul

Result:
case hf
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
n : ℕ
⊢ IntervalIntegrable (fun x => ↑x ^ (s - 1)) volume 0 ↑n

case hg
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
n : ℕ
⊢ ContinuousOn (fun x => ↑((1 - x / ↑n) ^ n)) (uIcc 0 ↑n)

Proof state:
case h.e'_3.h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
n : ℕ
⊢ (1 - x / ↑n) ^ n = (1 + -x / ↑n) ^ n

Tactic:
rw [neg_div, ← sub_eq_add_neg]

Result:
no goals

Proof state:
case h.inr
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
x : ℝ
hx : x ∈ Ioi 0
hxn : x ≤ ↑n
⊢ ‖(Ioc 0 ↑n).indicator (fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)) x‖ ≤ rexp (-x) * x ^ (s.re - 1)

Tactic:
rw [indicator_of_mem (mem_Ioc.mpr ⟨mem_Ioi.mp hx, hxn⟩), norm_mul, Complex.norm_of_nonneg
    (pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le₀ hxn <| by positivity) _),
    norm_cpow_eq_rpow_re_of_pos hx, sub_re, one_re, mul_le_mul_right (rpow_pos_of_pos hx _)]

Result:
case h.inr
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
x : ℝ
hx : x ∈ Ioi 0
hxn : x ≤ ↑n
⊢ (1 - x / ↑n) ^ n ≤ rexp (-x)

Proof state:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
⊢ ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))

Tactic:
intro x hx

Result:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
⊢ Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))

Proof state:
case hf
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
n : ℕ
⊢ -1 < (s - 1).re

Tactic:
rwa [sub_re, one_re, ← zero_sub, sub_lt_sub_iff_right]

Result:
no goals

Proof state:
case h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
n : ℕ
hn : ⌈x⌉₊ ≤ n
⊢ ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1) = f n x

Tactic:
rw [Nat.ceil_le] at hn

Result:
case h
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
x : ℝ
hx : x ∈ Ioi 0
n : ℕ
hn : x ≤ ↑n
⊢ ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1) = f n x

Proof state:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
⊢ ∀ (n : ℕ), ∀ᵐ (a : ℝ) ∂volume.restrict (Ioi 0), ‖f n a‖ ≤ rexp (-a) * a ^ (s.re - 1)

Tactic:
intro n

Result:
s : ℂ
hs : 0 < s.re
f : ℕ → ℝ → ℂ := fun n => (Ioc 0 ↑n).indicator fun x => ↑((1 - x / ↑n) ^ n) * ↑x ^ (s - 1)
f_ible : ∀ (n : ℕ), Integrable (f n) (volume.restrict (Ioi 0))
f_tends : ∀ x ∈ Ioi 0, Tendsto (fun n => f n x) atTop (𝓝 (↑(rexp (-x)) * ↑x ^ (s - 1)))
n : ℕ
⊢ ∀ᵐ (a : ℝ) ∂volume.restrict (Ioi 0), ‖f n a‖ ≤ rexp (-a) * a ^ (s.re - 1)