import Mathlib
import FoML


open MeasureTheory ProbabilityTheory

theorem extracted_formal_statement_463.{u_2, u_1} {Ω : Type u_1} [inst : MeasurableSpace Ω] {μ : Measure Ω}
  [inst_1 : IsProbabilityMeasure μ] {𝓧 : Type u_2} {m𝓧 : MeasurableSpace 𝓧} [hnonempty𝓧 : Nonempty 𝓧] {m : ℕ}
  {X' : Ω → 𝓧} (hX'' : Measurable X') {f' : (Fin m → 𝓧) → ℝ} {c' : Fin m → ℝ}
  (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i)
  (hf'' : StronglyMeasurable f') {ε : ℝ} (hε : ε ≥ 0) {t : ℝ} (ht : t ≥ 0) (ht' : t * ∑ i, c' i ^ 2 ≤ 1)
  (hX''' : ∀ (i : Fin m), Measurable fun ω => X' (ω i)) :
  let Y := fun k Xk =>
    ∫ (x : Fin m → Ω), (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else X' (ω i)) x ∂Measure.pi fun x => μ;
  let A := fun k Xk =>
    ⨅ x,
      ∫ (x_1 : Fin m → Ω),
        (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
          x_1 ∂Measure.pi fun x => μ;
  let B := fun k Xk =>
    ⨆ x,
      ∫ (x_1 : Fin m → Ω),
        (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
          x_1 ∂Measure.pi fun x => μ;
  (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧),
      Y k.succ (Fin.snoc Xk x) =
        ∫ (x_1 : Fin m → Ω),
          (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
            x_1 ∂Measure.pi fun x => μ) →
    ∀ (x₀ : 𝓧),
      let bdf := |f' fun x => x₀| + ∑ i, c' i;
      (∀ (xi : Fin m → 𝓧), |f' xi| ≤ bdf) →
        (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧),
            Integrable (fun a => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (a i))
              (Measure.pi fun x => μ)) →
          (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧), A k Xk ≤ Y k.succ (Fin.snoc Xk x)) →
            (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
                𝓧 →
                  BddAbove
                    (Set.range fun x =>
                      ∫ (a : Fin m → Ω),
                        (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
                          a ∂Measure.pi fun x => μ)) →
              (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧), B k Xk ≥ Y k.succ (Fin.snoc Xk x)) →
                (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧), B k Xk ≤ A k Xk + c' k) →
                  (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
                      (∫ (ω : Fin m → Ω), Y k.succ (Fin.snoc Xk (X' (ω k))) ∂Measure.pi fun x => μ) = Y k.castSucc Xk) →
                    (∀ (k : Fin m.succ), Measurable (Y k)) →
                      (∀ (k : Fin m.succ) (Xk : Fin ↑k → 𝓧), |Y k Xk| ≤ bdf) →
                        let V := fun k Xk ω => Y k.succ (Fin.snoc Xk (X' (ω k))) - Y k.castSucc Xk;
                        let t'' := 4 * ε * t;
                        t'' ≥ 0 →
                          (∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
                              (∫ (ω : Fin m → Ω), Real.exp (t'' * V k Xk ω) ∂Measure.pi fun x => μ) ≤
                                Real.exp (t'' ^ 2 * c' k ^ 2 / 8)) →
                            let E := Y 0 fun x => x₀;
                            (∀ (k : ℕ) (h : k ≤ m),
                                Integrable
                                  (fun x =>
                                    Real.exp
                                      (t'' * ((Y ⟨k, Nat.lt_add_one_of_le h⟩ fun i => X' (x (Fin.castLE h i))) - E)))
                                  (Measure.pi fun x => μ)) →
                              ∀ (k : ℕ),
                                (∀ (h : k ≤ m),
                                    (∫ (ω : Fin m → Ω),
                                        Real.exp
                                          (t'' *
                                            ((Y ⟨k, Nat.lt_add_one_of_le h⟩ fun i => X' (ω (Fin.castLE h i))) -
                                              E)) ∂Measure.pi fun x => μ) ≤
                                      Real.exp ((t'' ^ 2 * ∑ i, c' (Fin.castLE h i) ^ 2) / 8)) →
                                  ∀ (h : k + 1 ≤ m),
                                    (∫ (ω : Fin m → Ω),
                                          Real.exp
                                            (t'' *
                                              ((Y ⟨k, Nat.lt_add_one_of_le (Nat.le_of_succ_le h)⟩ fun i =>
                                                  X' (ω (Fin.castLE (Nat.le_of_succ_le h) i))) -
                                                E)) ∂Measure.pi fun x => μ) ≤
                                        Real.exp ((t'' ^ 2 * ∑ i, c' (Fin.castLE (Nat.le_of_succ_le h) i) ^ 2) / 8) →
                                      Integrable
                                          (fun x =>
                                            Real.exp
                                              (t'' *
                                                ((Y ⟨k, Nat.lt_add_one_of_le (Nat.le_of_succ_le h)⟩ fun i =>
                                                    X' (x (Fin.castLE (Nat.le_of_succ_le h) i))) -
                                                  E)))
                                          (Measure.pi fun x => μ) →
                                        ((fun ω =>
                                              Real.exp
                                                  (t'' *
                                                    ((Y ⟨k, Nat.lt_succ_of_lt h⟩ fun i => X' (ω (Fin.castLE h ↑↑i))) -
                                                      E)) *
                                                ∫ (ω' : Fin m → Ω),
                                                  Real.exp
                                                    (t'' *
                                                      V ⟨k, h⟩ (fun i => X' (ω (Fin.castLE h ↑↑i)))
                                                        ω') ∂Measure.pi fun x => μ) =
                                            fun ω =>
                                            (∫ (ω' : Fin m → Ω),
                                                Real.exp
                                                  (t'' *
                                                    V ⟨k, h⟩ (fun i => X' (ω (Fin.castLE h ↑↑i)))
                                                      ω') ∂Measure.pi fun x => μ) *
                                              Real.exp
                                                (t'' *
                                                  ((Y ⟨k, Nat.lt_succ_of_lt h⟩ fun i => X' (ω (Fin.castLE h ↑↑i))) -
                                                    E))) →
                                          ∀ (i : Fin (↑⟨k, h⟩ + 1)),
                                            ↑i < k →
                                              ((fun c =>
                                                    Fin.snoc (fun i => X' (c.2 (Fin.castLE h ↑↑i))) (X' (c.1 ⟨k, h⟩))
                                                      i) =
                                                  fun c => X' (c.2 (Fin.castLE h i))) →
                                                (Measurable fun c =>
                                                    Fin.snoc (fun i => X' (c.2 (Fin.castLE h ↑↑i))) (X' (c.1 ⟨k, h⟩))
                                                      i) →
                                                  Measurable fun c => X' (c.2 (Fin.castLE h i)) := sorry

Tactic state before:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
μ : Measure Ω
inst✝ : IsProbabilityMeasure μ
𝓧 : Type u_2
m𝓧 : MeasurableSpace 𝓧
hnonempty𝓧 : Nonempty 𝓧
m : ℕ
X' : Ω → 𝓧
hX'' : Measurable X'
f' : (Fin m → 𝓧) → ℝ
c' : Fin m → ℝ
hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i
hf'' : StronglyMeasurable f'
ε : ℝ
hε : ε ≥ 0
t : ℝ
ht : t ≥ 0
ht' : t * ∑ i, c' i ^ 2 ≤ 1
hX''' : ∀ (i : Fin m), Measurable fun ω => X' (ω i)
Y : (k : Fin m.succ) → (Fin ↑k → 𝓧) → ℝ :=
  fun k Xk =>
    ∫ (x : Fin m → Ω), (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else X' (ω i)) x ∂Measure.pi fun x => μ
A : (k : Fin m) → (Fin ↑k → 𝓧) → ℝ :=
  fun k Xk =>
    ⨅ x,
      ∫ (x_1 : Fin m → Ω),
        (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
          x_1 ∂Measure.pi fun x => μ
B : (k : Fin m) → (Fin ↑k → 𝓧) → ℝ :=
  fun k Xk =>
    ⨆ x,
      ∫ (x_1 : Fin m → Ω),
        (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
          x_1 ∂Measure.pi fun x => μ
AB_rw :
  ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧),
    Y k.succ (Fin.snoc Xk x) =
      ∫ (x_1 : Fin m → Ω),
        (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
          x_1 ∂Measure.pi fun x => μ
x₀ : 𝓧
bdf : ℝ := |f' fun x => x₀| + ∑ i, c' i
hfbdd : ∀ (xi : Fin m → 𝓧), |f' xi| ≤ bdf
hintegrableAB :
  ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧),
    Integrable (fun a => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (a i))
      (Measure.pi fun x => μ)
hAY : ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧), A k Xk ≤ Y k.succ (Fin.snoc Xk x)
hBddAbove :
  ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
    𝓧 →
      BddAbove
        (Set.range fun x =>
          ∫ (a : Fin m → Ω),
            (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
              a ∂Measure.pi fun x => μ)
hYB : ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧), B k Xk ≥ Y k.succ (Fin.snoc Xk x)
hAB : ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧), B k Xk ≤ A k Xk + c' k
hmartigale :
  ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
    (∫ (ω : Fin m → Ω), Y k.succ (Fin.snoc Xk (X' (ω k))) ∂Measure.pi fun x => μ) = Y k.castSucc Xk
hmeasurableY : ∀ (k : Fin m.succ), Measurable (Y k)
hYbdd : ∀ (k : Fin m.succ) (Xk : Fin ↑k → 𝓧), |Y k Xk| ≤ bdf
V : (k : Fin m) → (Fin ↑k → 𝓧) → (Fin m → Ω) → ℝ := fun k Xk ω => Y k.succ (Fin.snoc Xk (X' (ω k))) - Y k.castSucc Xk
t'' : ℝ := 4 * ε * t
ht'' : t'' ≥ 0
hhoefdding :
  ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
    (∫ (ω : Fin m → Ω), Real.exp (t'' * V k Xk ω) ∂Measure.pi fun x => μ) ≤ Real.exp (t'' ^ 2 * c' k ^ 2 / 8)
E : ℝ := Y 0 fun x => x₀
hintegrablelefts :
  ∀ (k : ℕ) (h : k ≤ m),
    Integrable (fun x => Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (x (Fin.castLE h i))) - E))) (Measure.pi fun x => μ)
k : ℕ
ih✝ :
  ∀ (h : k ≤ m),
    (∫ (ω : Fin m → Ω), Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE h i))) - E)) ∂Measure.pi fun x => μ) ≤
      Real.exp ((t'' ^ 2 * ∑ i, c' (Fin.castLE h i) ^ 2) / 8)
h : k + 1 ≤ m
ih :
  (∫ (ω : Fin m → Ω), Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE ⋯ i))) - E)) ∂Measure.pi fun x => μ) ≤
    Real.exp ((t'' ^ 2 * ∑ i, c' (Fin.castLE ⋯ i) ^ 2) / 8)
hintegrableleft :
  Integrable (fun x => Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (x (Fin.castLE ⋯ i))) - E))) (Measure.pi fun x => μ)
this✝ :
  (fun ω =>
      Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE h ↑↑i))) - E)) *
        ∫ (ω' : Fin m → Ω), Real.exp (t'' * V ⟨k, h⟩ (fun i => X' (ω (Fin.castLE h ↑↑i))) ω') ∂Measure.pi fun x => μ) =
    fun ω =>
    (∫ (ω' : Fin m → Ω), Real.exp (t'' * V ⟨k, h⟩ (fun i => X' (ω (Fin.castLE h ↑↑i))) ω') ∂Measure.pi fun x => μ) *
      Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE h ↑↑i))) - E))
i : Fin (↑⟨k, h⟩ + 1)
h' : ↑i < k
this :
  (fun c => Fin.snoc (fun i => X' (c.2 (Fin.castLE h ↑↑i))) (X' (c.1 ⟨k, h⟩)) i) = fun c => X' (c.2 (Fin.castLE h i))
⊢ Measurable fun c => Fin.snoc (fun i => X' (c.2 (Fin.castLE h ↑↑i))) (X' (c.1 ⟨k, h⟩)) i

Tactic:
rw [this]

Tactic state after:
[Ω : Type u_1
 inst✝¹ : MeasurableSpace Ω
 μ : Measure Ω
 inst✝ : IsProbabilityMeasure μ
 𝓧 : Type u_2
 m𝓧 : MeasurableSpace 𝓧
 hnonempty𝓧 : Nonempty 𝓧
 m : ℕ
 X' : Ω → 𝓧
 hX'' : Measurable X'
 f' : (Fin m → 𝓧) → ℝ
 c' : Fin m → ℝ
 hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i
 hf'' : StronglyMeasurable f'
 ε : ℝ
 hε : ε ≥ 0
 t : ℝ
 ht : t ≥ 0
 ht' : t * ∑ i, c' i ^ 2 ≤ 1
 hX''' : ∀ (i : Fin m), Measurable fun ω => X' (ω i)
 Y : (k : Fin m.succ) → (Fin ↑k → 𝓧) → ℝ :=
   fun k Xk =>
     ∫ (x : Fin m → Ω), (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else X' (ω i)) x ∂Measure.pi fun x => μ
 A : (k : Fin m) → (Fin ↑k → 𝓧) → ℝ :=
   fun k Xk =>
     ⨅ x,
       ∫ (x_1 : Fin m → Ω),
         (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
           x_1 ∂Measure.pi fun x => μ
 B : (k : Fin m) → (Fin ↑k → 𝓧) → ℝ :=
   fun k Xk =>
     ⨆ x,
       ∫ (x_1 : Fin m → Ω),
         (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
           x_1 ∂Measure.pi fun x => μ
 AB_rw :
   ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧),
     Y k.succ (Fin.snoc Xk x) =
       ∫ (x_1 : Fin m → Ω),
         (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
           x_1 ∂Measure.pi fun x => μ
 x₀ : 𝓧
 bdf : ℝ := |f' fun x => x₀| + ∑ i, c' i
 hfbdd : ∀ (xi : Fin m → 𝓧), |f' xi| ≤ bdf
 hintegrableAB :
   ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧),
     Integrable (fun a => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (a i))
       (Measure.pi fun x => μ)
 hAY : ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧), A k Xk ≤ Y k.succ (Fin.snoc Xk x)
 hBddAbove :
   ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
     𝓧 →
       BddAbove
         (Set.range fun x =>
           ∫ (a : Fin m → Ω),
             (fun ω => f' fun i => if h : ↑i < ↑k then Xk ⟨↑i, h⟩ else if ↑i = ↑k then x else X' (ω i))
               a ∂Measure.pi fun x => μ)
 hYB : ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧) (x : 𝓧), B k Xk ≥ Y k.succ (Fin.snoc Xk x)
 hAB : ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧), B k Xk ≤ A k Xk + c' k
 hmartigale :
   ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
     (∫ (ω : Fin m → Ω), Y k.succ (Fin.snoc Xk (X' (ω k))) ∂Measure.pi fun x => μ) = Y k.castSucc Xk
 hmeasurableY : ∀ (k : Fin m.succ), Measurable (Y k)
 hYbdd : ∀ (k : Fin m.succ) (Xk : Fin ↑k → 𝓧), |Y k Xk| ≤ bdf
 V : (k : Fin m) → (Fin ↑k → 𝓧) → (Fin m → Ω) → ℝ := fun k Xk ω => Y k.succ (Fin.snoc Xk (X' (ω k))) - Y k.castSucc Xk
 t'' : ℝ := 4 * ε * t
 ht'' : t'' ≥ 0
 hhoefdding :
   ∀ (k : Fin m) (Xk : Fin ↑k → 𝓧),
     (∫ (ω : Fin m → Ω), Real.exp (t'' * V k Xk ω) ∂Measure.pi fun x => μ) ≤ Real.exp (t'' ^ 2 * c' k ^ 2 / 8)
 E : ℝ := Y 0 fun x => x₀
 hintegrablelefts :
   ∀ (k : ℕ) (h : k ≤ m),
     Integrable (fun x => Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (x (Fin.castLE h i))) - E))) (Measure.pi fun x => μ)
 k : ℕ
 ih✝ :
   ∀ (h : k ≤ m),
     (∫ (ω : Fin m → Ω), Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE h i))) - E)) ∂Measure.pi fun x => μ) ≤
       Real.exp ((t'' ^ 2 * ∑ i, c' (Fin.castLE h i) ^ 2) / 8)
 h : k + 1 ≤ m
 ih :
   (∫ (ω : Fin m → Ω), Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE ⋯ i))) - E)) ∂Measure.pi fun x => μ) ≤
     Real.exp ((t'' ^ 2 * ∑ i, c' (Fin.castLE ⋯ i) ^ 2) / 8)
 hintegrableleft :
   Integrable (fun x => Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (x (Fin.castLE ⋯ i))) - E))) (Measure.pi fun x => μ)
 this✝ :
   (fun ω =>
       Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE h ↑↑i))) - E)) *
         ∫ (ω' : Fin m → Ω), Real.exp (t'' * V ⟨k, h⟩ (fun i => X' (ω (Fin.castLE h ↑↑i))) ω') ∂Measure.pi fun x => μ) =
     fun ω =>
     (∫ (ω' : Fin m → Ω), Real.exp (t'' * V ⟨k, h⟩ (fun i => X' (ω (Fin.castLE h ↑↑i))) ω') ∂Measure.pi fun x => μ) *
       Real.exp (t'' * ((Y ⟨k, ⋯⟩ fun i => X' (ω (Fin.castLE h ↑↑i))) - E))
 i : Fin (↑⟨k, h⟩ + 1)
 h' : ↑i < k
 this :
   (fun c => Fin.snoc (fun i => X' (c.2 (Fin.castLE h ↑↑i))) (X' (c.1 ⟨k, h⟩)) i) = fun c => X' (c.2 (Fin.castLE h i))
 ⊢ Measurable fun c => X' (c.2 (Fin.castLE h i))]