-- Mathlib/Analysis/SpecialFunctions/Gaussian/PoissonSummation.lean
theorem Complex.tsum_exp_neg_quadratic {a : ℂ} (ha : 0 < a.re) (b : ℂ) :
    (∑' n : ℤ, cexp (-π * a * n ^ 2 + 2 * π * b * n)) =
      1 / a ^ (1 / 2 : ℂ) * ∑' n : ℤ, cexp (-π / a * (n + I * b) ^ 2)

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
⊢ ∑' (n : ℤ), cexp (-↑π * a * ↑n ^ 2 + 2 * ↑π * b * ↑n) =
    1 / a ^ (1 / 2) * ∑' (n : ℤ), cexp (-↑π / a * (↑n + I * b) ^ 2)

Tactic:
have h2 : 0 < (↑π / a).re := by
  rw [div_eq_mul_inv, re_ofReal_mul, inv_re]
  refine mul_pos pi_pos (div_pos ha <| normSq_pos.mpr ?_)
  contrapose! ha
  rw [ha, zero_re]

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
⊢ ∑' (n : ℤ), cexp (-↑π * a * ↑n ^ 2 + 2 * ↑π * b * ↑n) =
    1 / a ^ (1 / 2) * ∑' (n : ℤ), cexp (-↑π / a * (↑n + I * b) ^ 2)

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
⊢ a ≠ 0

Tactic:
contrapose! ha

Result:
a b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
ha : a = 0
⊢ a.re ≤ 0

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
x : ℝ
⊢ -↑π / a * (↑x + I * b) ^ 2 = -↑π / a * ↑x ^ 2 + -2 * ↑π * I * b / a * ↑x + ↑π * b ^ 2 / a

Tactic:
ring_nf

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
x : ℝ
⊢ -(↑π * a⁻¹ * ↑x * I * b * 2) + (-(↑π * a⁻¹ * ↑x ^ 2) - ↑π * a⁻¹ * I ^ 2 * b ^ 2) =
    -(↑π * a⁻¹ * ↑x * I * b * 2) - ↑π * a⁻¹ * ↑x ^ 2 + ↑π * a⁻¹ * b ^ 2

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
this : ∀ (x : ℝ), -↑π / a * (↑x + I * b) ^ 2 = -↑π / a * ↑x ^ 2 + -2 * ↑π * I * b / a * ↑x + ↑π * b ^ 2 / a
⊢ (fun x =>
      cexp (↑π * b ^ 2 / a) * (1 / a ^ (1 / 2) * cexp (-↑π / a * ↑x ^ 2 + -2 * ↑π * I * b / a * ↑x))) =O[cocompact ℝ]
    fun x => |x| ^ (-2)

Tactic:
refine ((cexp_neg_quadratic_isLittleO_abs_rpow_cocompact
  (?_) (-2 * ↑π * I * b / a) (-2)).isBigO.const_mul_left _).const_mul_left _

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
this : ∀ (x : ℝ), -↑π / a * (↑x + I * b) ^ 2 = -↑π / a * ↑x ^ 2 + -2 * ↑π * I * b / a * ↑x + ↑π * b ^ 2 / a
⊢ (-↑π / a).re < 0

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
⊢ ∑' (n : ℤ), cexp (-↑π * a * ↑n ^ 2 + 2 * ↑π * b * ↑n) =
    1 / a ^ (1 / 2) * ∑' (n : ℤ), cexp (-↑π / a * (↑n + I * b) ^ 2)

Tactic:
let f : ℝ → ℂ := fun x ↦ cexp (-π * a * x ^ 2 + 2 * π * b * x)

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
⊢ ∑' (n : ℤ), cexp (-↑π * a * ↑n ^ 2 + 2 * ↑π * b * ↑n) =
    1 / a ^ (1 / 2) * ∑' (n : ℤ), cexp (-↑π / a * (↑n + I * b) ^ 2)

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
⊢ 0 < (↑π * a).re

Tactic:
rw [re_ofReal_mul]

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
⊢ 0 < π * a.re

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
x : ℝ
⊢ -(↑π * a⁻¹ * ↑x * I * b * 2) + (-(↑π * a⁻¹ * ↑x ^ 2) - ↑π * a⁻¹ * I ^ 2 * b ^ 2) =
    -(↑π * a⁻¹ * ↑x * I * b * 2) - ↑π * a⁻¹ * ↑x ^ 2 + ↑π * a⁻¹ * b ^ 2

Tactic:
rw [I_sq]

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
x : ℝ
⊢ -(↑π * a⁻¹ * ↑x * I * b * 2) + (-(↑π * a⁻¹ * ↑x ^ 2) - ↑π * a⁻¹ * -1 * b ^ 2) =
    -(↑π * a⁻¹ * ↑x * I * b * 2) - ↑π * a⁻¹ * ↑x ^ 2 + ↑π * a⁻¹ * b ^ 2

Proof state:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
⊢ ∑' (n : ℤ), cexp (-↑π * a * ↑n ^ 2 + 2 * ↑π * b * ↑n) =
    1 / a ^ (1 / 2) * ∑' (n : ℤ), cexp (-↑π / a * (↑n + I * b) ^ 2)

Tactic:
have Ff_bd : (𝓕 f) =O[cocompact ℝ] (fun x => |x| ^ (-2 : ℝ)) := by
  rw [hFf]
  have : ∀ (x : ℝ), -↑π / a * (↑x + I * b) ^ 2 =
      -↑π / a * x ^ 2 + (-2 * π * I * b) / a * x + π * b ^ 2 / a := by
    intro x; ring_nf; rw [I_sq]; ring
  simp_rw [this]
  conv => enter [2, x]; rw [Complex.exp_add, ← mul_assoc _ _ (Complex.exp _), mul_comm]
  refine ((cexp_neg_quadratic_isLittleO_abs_rpow_cocompact
    (?_) (-2 * ↑π * I * b / a) (-2)).isBigO.const_mul_left _).const_mul_left _
  rwa [neg_div, neg_re, neg_lt_zero]

Result:
a : ℂ
ha : 0 < a.re
b : ℂ
f : ℝ → ℂ := fun x => cexp (-↑π * a * ↑x ^ 2 + 2 * ↑π * b * ↑x)
hCf : Continuous f
hFf : 𝓕 f = fun x => 1 / a ^ (1 / 2) * cexp (-↑π / a * (↑x + I * b) ^ 2)
h1 : 0 < (↑π * a).re
h2 : 0 < (↑π / a).re
f_bd : f =O[cocompact ℝ] fun x => |x| ^ (-2)
Ff_bd : 𝓕 f =O[cocompact ℝ] fun x => |x| ^ (-2)
⊢ ∑' (n : ℤ), cexp (-↑π * a * ↑n ^ 2 + 2 * ↑π * b * ↑n) =
    1 / a ^ (1 / 2) * ∑' (n : ℤ), cexp (-↑π / a * (↑n + I * b) ^ 2)