l3lab/ntp-mathlib huggingface dataset:
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) :
    u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
  -- NB: If we knew `Gamma (u + v + 1) ≠ 0` this would be an easy consequence of
  -- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
  -- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
  let F : ℝ → ℂ := fun x => (x : ℂ) ^ u * (1 - (x : ℂ)) ^ v
  have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
  have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
  have hc : ContinuousOn F (Icc 0 1) := by
    refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
    · refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
      rw [ofReal_re]; exact hx.1
    · refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
        (continuous_const.sub continuous_ofReal).continuousAt
      rw [sub_re, one_re, ofReal_re, sub_nonneg]
      exact hx.2
  have hder : ∀ x : ℝ, x ∈ Ioo (0 : ℝ) 1 →
      HasDerivAt F (u * ((x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ v) -
        v * ((x : ℂ) ^ u * (1 - (x : ℂ)) ^ (v - 1))) x := by
    intro x hx
    have U : HasDerivAt (fun y : ℂ => y ^ u) (u * (x : ℂ) ^ (u - 1)) ↑x := by
      have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : ℂ)) (Or.inl ?_)
      simp only [id_eq, mul_one] at this
      · exact this
      · rw [id_eq, ofReal_re]; exact hx.1
    have V : HasDerivAt (fun y : ℂ => (1 - y) ^ v) (-v * (1 - (x : ℂ)) ^ (v - 1)) ↑x := by
      have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : ℂ))) (Or.inl ?_)
      swap; · rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
      simp_rw [id.def] at A
      have B : HasDerivAt (fun y : ℂ => 1 - y) (-1) ↑x := by
        apply HasDerivAt.const_sub; apply hasDerivAt_id
      convert HasDerivAt.comp (↑x) A B using 1
      ring
    convert (U.mul V).comp_ofReal using 1
    ring
  have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
    ((betaIntegral_convergent hu' hv).const_mul v)
  rw [add_sub_cancel, add_sub_cancel] at h_int
  have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
  have hF0 : F 0 = 0 := by
    simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
      sub_zero, one_cpow, one_ne_zero, or_false_iff]
    

Proof state:
u v : ℂ
hu : 0 < u.re
hv : 0 < v.re
F : ℝ → ℂ := fun x => ↑x ^ u * (1 - ↑x) ^ v
hu' : 0 < (u + 1).re
hv' : 0 < (v + 1).re
hc : ContinuousOn F (Icc 0 1)
hder : ∀ x ∈ Ioo 0 1, HasDerivAt F (u * (↑x ^ (u - 1) * (1 - ↑x) ^ v) - v * (↑x ^ u * (1 - ↑x) ^ (v - 1))) x
h_int : IntervalIntegrable (fun x => u * (↑x ^ (u - 1) * (1 - ↑x) ^ v) - v * (↑x ^ u * (1 - ↑x) ^ (v - 1))) volume 0 1
int_ev : ∫ (y : ℝ) in 0 ..1, u * (↑y ^ (u - 1) * (1 - ↑y) ^ v) - v * (↑y ^ u * (1 - ↑y) ^ (v - 1)) = F 1 - F 0
⊢ ¬u = 0

Next tactic:
contrapose! hu
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) :
    u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
  -- NB: If we knew `Gamma (u + v + 1) ≠ 0` this would be an easy consequence of
  -- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
  -- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
  let F : ℝ → ℂ := fun x => (x : ℂ) ^ u * (1 - (x : ℂ)) ^ v
  have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
  have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
  have hc : ContinuousOn F (Icc 0 1) := by
    refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
    · refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
      rw [ofReal_re]; exact hx.1
    · refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
        (continuous_const.sub continuous_ofReal).continuousAt
      rw [sub_re, one_re, ofReal_re, sub_nonneg]
      exact hx.2
  have hder : ∀ x : ℝ, x ∈ Ioo (0 : ℝ) 1 →
      HasDerivAt F (u * ((x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ v) -
        v * ((x : ℂ) ^ u * (1 - (x : ℂ)) ^ (v - 1))) x := by
    intro x hx
    have U : HasDerivAt (fun y : ℂ => y ^ u) (u * (x : ℂ) ^ (u - 1)) ↑x := by
      have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : ℂ)) (Or.inl ?_)
      simp only [id_eq, mul_one] at this
      · exact this
      · rw [id_eq, ofReal_re]; exact hx.1
    have V : HasDerivAt (fun y : ℂ => (1 - y) ^ v) (-v * (1 - (x : ℂ)) ^ (v - 1)) ↑x := by
      have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : ℂ))) (Or.inl ?_)
      swap; · rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
      simp_rw [id.def] at A
      have B : HasDerivAt (fun y : ℂ => 1 - y) (-1) ↑x := by
        apply HasDerivAt.const_sub; apply hasDerivAt_id
      convert HasDerivAt.comp (↑x) A B using 1
      ring
    convert (U.mul V).comp_ofReal using 1
    ring
  have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
    ((betaIntegral_convergent hu' hv).const_mul v)
  rw [add_sub_cancel, add_sub_cancel] at h_int
  have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
  have hF0 : F 0 = 0 := by
    simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
      sub_zero, one_cpow, one_ne_zero, or_false_iff]
    contrapose! hu; 

Proof state:
u v : ℂ
hv : 0 < v.re
F : ℝ → ℂ := fun x => ↑x ^ u * (1 - ↑x) ^ v
hu' : 0 < (u + 1).re
hv' : 0 < (v + 1).re
hc : ContinuousOn F (Icc 0 1)
hder : ∀ x ∈ Ioo 0 1, HasDerivAt F (u * (↑x ^ (u - 1) * (1 - ↑x) ^ v) - v * (↑x ^ u * (1 - ↑x) ^ (v - 1))) x
h_int : IntervalIntegrable (fun x => u * (↑x ^ (u - 1) * (1 - ↑x) ^ v) - v * (↑x ^ u * (1 - ↑x) ^ (v - 1))) volume 0 1
int_ev : ∫ (y : ℝ) in 0 ..1, u * (↑y ^ (u - 1) * (1 - ↑y) ^ v) - v * (↑y ^ u * (1 - ↑y) ^ (v - 1)) = F 1 - F 0
hu : u = 0
⊢ u.re ≤ 0

Next tactic:
rw [hu, zero_re]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  

Proof state:
u : ℂ
hu : 0 < u.re
n : ℕ
⊢ betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)

Next tactic:
induction' n with n IH generalizing u
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · 

Proof state:
case zero
u : ℂ
hu : 0 < u.re
⊢ betaIntegral u (↑Nat.zero + 1) = ↑Nat.zero ! / ∏ j in Finset.range (Nat.zero + 1), (u + ↑j)

Next tactic:
rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    

Proof state:
case zero
u : ℂ
hu : 0 < u.re
⊢ 1 / u = 1 / ∏ j in Finset.range (Nat.zero + 1), (u + ↑j)

Next tactic:
simp
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · 

Proof state:
case succ
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
⊢ betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n)! / ∏ j in Finset.range (Nat.succ n + 1), (u + ↑j)

Next tactic:
have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : u * betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n)
⊢ betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n)! / ∏ j in Finset.range (Nat.succ n + 1), (u + ↑j)
case succ.refine_1
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
⊢ 0 < (↑(Nat.succ n)).re

Next tactic:
swap
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · 

Proof state:
case succ.refine_1
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
⊢ 0 < (↑(Nat.succ n)).re

Next tactic:
rw [← ofReal_nat_cast, ofReal_re]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; 

Proof state:
case succ.refine_1
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
⊢ 0 < ↑(Nat.succ n)

Next tactic:
positivity
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : u * betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n)
⊢ betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n)! / ∏ j in Finset.range (Nat.succ n + 1), (u + ↑j)

Next tactic:
rw [mul_comm u _, ← eq_div_iff] at this
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n)! / ∏ j in Finset.range (Nat.succ n + 1), (u + ↑j)
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) * u = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n)
⊢ u ≠ 0

Next tactic:
swap
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · 

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) * u = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n)
⊢ u ≠ 0

Next tactic:
contrapose! hu
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; 

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
this : betaIntegral u (↑(Nat.succ n) + 1) * u = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n)
hu : u = 0
⊢ u.re ≤ 0

Next tactic:
rw [hu, zero_re]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n)! / ∏ j in Finset.range (Nat.succ n + 1), (u + ↑j)

Next tactic:
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ (↑n + 1) * (↑n ! / ∏ j in Finset.range (n + 1), (u + 1 + ↑j)) / u =
    ↑(Nat.succ n)! / ((∏ k in Finset.range (n + 1), (u + ↑(k + 1))) * (u + ↑0))
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ 0 < (u + 1).re

Next tactic:
swap
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    swap; · 

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ 0 < (u + 1).re

Next tactic:
rw [add_re, one_re]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    swap; · rw [add_re, one_re]; 

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ 0 < u.re + 1

Next tactic:
positivity
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    swap; · rw [add_re, one_re]; positivity
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ (↑n + 1) * (↑n ! / ∏ j in Finset.range (n + 1), (u + 1 + ↑j)) / u =
    ↑(Nat.succ n)! / ((∏ k in Finset.range (n + 1), (u + ↑(k + 1))) * (u + ↑0))

Next tactic:
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, ←
      mul_div_assoc, ← div_div]
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    swap; · rw [add_re, one_re]; positivity
    rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, ←
      mul_div_assoc, ← div_div]
    

Proof state:
case succ.refine_2
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
⊢ ((↑n + 1) * ↑n ! / ∏ j in Finset.range (n + 1), (u + 1 + ↑j)) / u =
    ((↑n + 1) * ↑n ! / ∏ k in Finset.range (n + 1), (u + ↑(k + 1))) / u

Next tactic:
congr 3 with j : 1
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    swap; · rw [add_re, one_re]; positivity
    rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, ←
      mul_div_assoc, ← div_div]
    congr 3 with j : 1
    

Proof state:
case succ.refine_2.e_a.e_a.e_f.h
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
j : ℕ
⊢ u + 1 + ↑j = u + ↑(j + 1)

Next tactic:
push_cast
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
    betaIntegral u (n + 1) = n ! / ∏ j : ℕ in Finset.range (n + 1), (u + j) := by
  induction' n with n IH generalizing u
  · rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
    simp
  · have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
    swap; · rw [← ofReal_nat_cast, ofReal_re]; positivity
    rw [mul_comm u _, ← eq_div_iff] at this
    swap; · contrapose! hu; rw [hu, zero_re]
    rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
    swap; · rw [add_re, one_re]; positivity
    rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, ←
      mul_div_assoc, ← div_div]
    congr 3 with j : 1
    push_cast; 

Proof state:
case succ.refine_2.e_a.e_a.e_f.h
n : ℕ
IH : ∀ {u : ℂ}, 0 < u.re → betaIntegral u (↑n + 1) = ↑n ! / ∏ j in Finset.range (n + 1), (u + ↑j)
u : ℂ
hu : 0 < u.re
this : betaIntegral u (↑(Nat.succ n) + 1) = ↑(Nat.succ n) * betaIntegral (u + 1) ↑(Nat.succ n) / u
j : ℕ
⊢ u + 1 + ↑j = u + (↑j + 1)

Next tactic:
abel
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : ℂ} (hs : 0 < re s) (n : ℕ) :
    GammaSeq s n = (n : ℂ) ^ s * betaIntegral s (n + 1) := by
  

Proof state:
s : ℂ
hs : 0 < s.re
n : ℕ
⊢ GammaSeq s n = ↑n ^ s * betaIntegral s (↑n + 1)

Next tactic:
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, ← mul_div_assoc]