import Mathlib
import FoML


open scoped Topology

open MeasureTheory ProbabilityTheory BigOperators ENNReal Real Set Filter Asymptotics

theorem extracted_formal_statement_110.{u_1} {Ω : Type u_1} [inst : MeasurableSpace Ω] (μ : Measure Ω)
  [inst_1 : IsProbabilityMeasure μ] {n : ℕ} (hn : n > 0) {X : Fin n → Ω → ℝ} (hXm : ∀ (i : Fin n), Measurable (X i))
  (hXi : iIndepFun X μ) (hX_bdd : ∀ (i : Fin n), ∀ᵐ (ω : Ω) ∂μ, |X i ω| ≤ 1)
  (hμX : ∀ (i : Fin n), ∫ (x : Ω), X i x ∂μ = 0) (σ : ℝ) (hσ_pos : σ > 0)
  (hσ : ∀ (i : Fin n), σ ^ 2 = ∫ (x : Ω), (X i ^ 2) x ∂μ) (ε : ℝ) (hε : ε > 0) (ht_sq : 0 ≤ σ ^ 2)
  (bennett_bound : ∀ τ ≥ 0, (μ {ω | ε ≤ ∑ i, X i ω}).toReal ≤ rexp (-(τ * ε) + ↑n * σ ^ 2 * (rexp τ - 1 - τ))) :
  let τ_ := log (1 + ε / (↑n * σ ^ 2));
  τ_ ≥ 0 →
    (μ {ω | ε ≤ ∑ i, X i ω}).toReal ≤ rexp (-(τ_ * ε) + ↑n * σ ^ 2 * (rexp τ_ - 1 - τ_)) →
      ↑n * σ ^ 2 * (1 + ε / (↑n * σ ^ 2) - 1 - log (1 + ε / (↑n * σ ^ 2))) =
          ε - ↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2)) →
        rexp (-(↑n * σ ^ 2 * ((1 + ε / (↑n * σ ^ 2)) * log (1 + ε / (↑n * σ ^ 2)) - ε / (↑n * σ ^ 2)))) =
            rexp (-(↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2)) + ε * log (1 + ε / (↑n * σ ^ 2)) - ε)) →
          let z := log (1 + ε / (↑n * σ ^ 2));
          (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤ rexp (-(z * ε) + (ε - ↑n * σ ^ 2 * z)) →
            z = log (1 + ε / (↑n * σ ^ 2)) →
              (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤
                  rexp (-(↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2)) + ε * log (1 + ε / (↑n * σ ^ 2)) - ε)) →
                (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤ rexp (-(↑n * σ ^ 2 * z + ε * z - ε)) := sorry

Tactic state before:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
μ : Measure Ω
inst✝ : IsProbabilityMeasure μ
n : ℕ
hn : n > 0
X : Fin n → Ω → ℝ
hXm : ∀ (i : Fin n), Measurable (X i)
hXi : iIndepFun X μ
hX_bdd : ∀ (i : Fin n), ∀ᵐ (ω : Ω) ∂μ, |X i ω| ≤ 1
hμX : ∀ (i : Fin n), ∫ (x : Ω), X i x ∂μ = 0
σ : ℝ
hσ_pos : σ > 0
hσ : ∀ (i : Fin n), σ ^ 2 = ∫ (x : Ω), (X i ^ 2) x ∂μ
ε : ℝ
hε : ε > 0
S : Ω → ℝ := fun ω => ∑ i, X i ω
ht_sq : 0 ≤ σ ^ 2
bennett_bound : ∀ τ ≥ 0, (μ {ω | ε ≤ ∑ i, X i ω}).toReal ≤ rexp (-(τ * ε) + ↑n * σ ^ 2 * (rexp τ - 1 - τ))
τ_ : ℝ := log (1 + ε / (↑n * σ ^ 2))
τ_nonneg : τ_ ≥ 0
bennett_bound_τ_ : (μ {ω | ε ≤ ∑ i, X i ω}).toReal ≤ rexp (-(τ_ * ε) + ↑n * σ ^ 2 * (rexp τ_ - 1 - τ_))
this✝ :
  ↑n * σ ^ 2 * (1 + ε / (↑n * σ ^ 2) - 1 - log (1 + ε / (↑n * σ ^ 2))) = ε - ↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2))
this :
  rexp (-(↑n * σ ^ 2 * ((1 + ε / (↑n * σ ^ 2)) * log (1 + ε / (↑n * σ ^ 2)) - ε / (↑n * σ ^ 2)))) =
    rexp (-(↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2)) + ε * log (1 + ε / (↑n * σ ^ 2)) - ε))
z : ℝ := log (1 + ε / (↑n * σ ^ 2))
bound : (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤ rexp (-(z * ε) + (ε - ↑n * σ ^ 2 * z))
hz : z = log (1 + ε / (↑n * σ ^ 2))
⊢ (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤
    rexp (-(↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2)) + ε * log (1 + ε / (↑n * σ ^ 2)) - ε))

Tactic:
rw [<- hz]

Tactic state after:
[Ω : Type u_1
 inst✝¹ : MeasurableSpace Ω
 μ : Measure Ω
 inst✝ : IsProbabilityMeasure μ
 n : ℕ
 hn : n > 0
 X : Fin n → Ω → ℝ
 hXm : ∀ (i : Fin n), Measurable (X i)
 hXi : iIndepFun X μ
 hX_bdd : ∀ (i : Fin n), ∀ᵐ (ω : Ω) ∂μ, |X i ω| ≤ 1
 hμX : ∀ (i : Fin n), ∫ (x : Ω), X i x ∂μ = 0
 σ : ℝ
 hσ_pos : σ > 0
 hσ : ∀ (i : Fin n), σ ^ 2 = ∫ (x : Ω), (X i ^ 2) x ∂μ
 ε : ℝ
 hε : ε > 0
 S : Ω → ℝ := fun ω => ∑ i, X i ω
 ht_sq : 0 ≤ σ ^ 2
 bennett_bound : ∀ τ ≥ 0, (μ {ω | ε ≤ ∑ i, X i ω}).toReal ≤ rexp (-(τ * ε) + ↑n * σ ^ 2 * (rexp τ - 1 - τ))
 τ_ : ℝ := log (1 + ε / (↑n * σ ^ 2))
 τ_nonneg : τ_ ≥ 0
 bennett_bound_τ_ : (μ {ω | ε ≤ ∑ i, X i ω}).toReal ≤ rexp (-(τ_ * ε) + ↑n * σ ^ 2 * (rexp τ_ - 1 - τ_))
 this✝ :
   ↑n * σ ^ 2 * (1 + ε / (↑n * σ ^ 2) - 1 - log (1 + ε / (↑n * σ ^ 2))) = ε - ↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2))
 this :
   rexp (-(↑n * σ ^ 2 * ((1 + ε / (↑n * σ ^ 2)) * log (1 + ε / (↑n * σ ^ 2)) - ε / (↑n * σ ^ 2)))) =
     rexp (-(↑n * σ ^ 2 * log (1 + ε / (↑n * σ ^ 2)) + ε * log (1 + ε / (↑n * σ ^ 2)) - ε))
 z : ℝ := log (1 + ε / (↑n * σ ^ 2))
 bound : (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤ rexp (-(z * ε) + (ε - ↑n * σ ^ 2 * z))
 hz : z = log (1 + ε / (↑n * σ ^ 2))
 ⊢ (μ {ω | ∑ i, X i ω ≥ ε}).toReal ≤ rexp (-(↑n * σ ^ 2 * z + ε * z - ε))]