import Mathlib
import FoML


open MeasureTheory ProbabilityTheory Real

open scoped ENNReal

theorem extracted_formal_statement_11.{u_1, w, u} {Ω : Type u} [inst : MeasurableSpace Ω] {Z : Type w} {n : ℕ}
  {ι : Type u_1} {f : ι → Z → ℝ} {μ : Measure Ω} [inst_1 : IsProbabilityMeasure μ] {X : Ω → Z} [inst_2 : Nonempty ι]
  [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b_1 : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b_1)
  (hp : ∀ (i : ι) (j : Fin n), Integrable (fun a => f i (X (a j))) (Measure.pi fun x => μ))
  (hr : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ Set.range fun i => f i (X (ω k)), y ≤ C)
  (hr' : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ Set.range fun i => f i (X (ω k)), C ≤ y)
  (hq : ∀ (ω : Fin n → Ω) (k : Fin n), BddAbove (Set.range fun i => f i (X (ω k))))
  (hq' : ∀ (ω : Fin n → Ω) (k : Fin n), BddBelow (Set.range fun i => f i (X (ω k))))
  (hq0 : ∀ (ω x : Fin n → Ω) (k : Fin n), BddAbove (Set.range fun i => f i (X (ω k)) - f i (X (x k))))
  (hq1 : ∀ (ω x : Fin n → Ω), BddAbove (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))))
  (hq2 : ∀ (ω x : Fin n → Ω) (k : Fin n), BddBelow (Set.range fun i => f i (X (ω k)) - f i (X (x k))))
  (hq3 : ∀ (ω x : Fin n → Ω), BddBelow (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))) (ω x : Fin n → Ω)
  (hq1'' : BddAbove (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))))
  (hq3'' : BddBelow (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))) (a b : ℝ)
  (hab : ∀ (y : ι), ∑ k, (f y (X (ω k)) - f y (X (x k))) ∈ Set.Icc a b) (y : ι)
  (hab' : a ≤ ∑ k, (f y (X (ω k)) - f y (X (x k))) ∧ ∑ k, (f y (X (ω k)) - f y (X (x k))) ≤ b) :
  |∑ k, (f y (X (ω k)) - f y (X (x k)))| ∈ Set.Icc (a ⊓ -b) (-a ⊔ b) := sorry

Tactic state before:
case h
Ω : Type u
inst✝³ : MeasurableSpace Ω
Z : Type w
n : ℕ
ι : Type u_1
f : ι → Z → ℝ
μ : Measure Ω
inst✝² : IsProbabilityMeasure μ
X : Ω → Z
inst✝¹ : Nonempty ι
inst✝ : Countable ι
hf : ∀ (i : ι), Measurable (f i ∘ X)
b✝ : ℝ
hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b✝
ω✝ : Fin n → Ω
hp : ∀ (i : ι) (j : Fin n), Integrable (fun a => f i (X (a j))) (Measure.pi fun x => μ)
hr : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ Set.range fun i => f i (X (ω k)), y ≤ C
hr' : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ Set.range fun i => f i (X (ω k)), C ≤ y
hq : ∀ (ω : Fin n → Ω) (k : Fin n), BddAbove (Set.range fun i => f i (X (ω k)))
hq' : ∀ (ω : Fin n → Ω) (k : Fin n), BddBelow (Set.range fun i => f i (X (ω k)))
hq0 : ∀ (ω x : Fin n → Ω) (k : Fin n), BddAbove (Set.range fun i => f i (X (ω k)) - f i (X (x k)))
hq1 : ∀ (ω x : Fin n → Ω), BddAbove (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))
hq2 : ∀ (ω x : Fin n → Ω) (k : Fin n), BddBelow (Set.range fun i => f i (X (ω k)) - f i (X (x k)))
hq3 : ∀ (ω x : Fin n → Ω), BddBelow (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))
ω x : Fin n → Ω
hq1'' : BddAbove (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))
hq3'' : BddBelow (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))
a b : ℝ
hab : ∀ (y : ι), ∑ k, (f y (X (ω k)) - f y (X (x k))) ∈ Set.Icc a b
y : ι
hab' : a ≤ ∑ k, (f y (X (ω k)) - f y (X (x k))) ∧ ∑ k, (f y (X (ω k)) - f y (X (x k))) ≤ b
⊢ |∑ k, (f y (X (ω k)) - f y (X (x k)))| ∈ Set.Icc (a ⊓ -b) (-a ⊔ b)

Tactic:
rw [Set.mem_Icc]
    obtain ⟨hab0', hab1'⟩ := hab'
    by_cases d : 0 ≤ ∑ k : Fin n, (f y (X (ω k)) - f y (X (x k)))
    case pos =>
  rw [abs_of_nonneg d]
  rw [inf_le_iff, le_sup_iff]
  exact ⟨Or.symm (Or.inr hab0'), Or.inr hab1'⟩
    case neg =>
  rw [abs_of_neg (lt_of_not_ge d)]
  constructor
  · rw [inf_le_iff]
    apply Or.inr (neg_le_neg_iff.mpr hab1')
  · rw [le_sup_iff]
    apply Or.inl (neg_le_neg_iff.mpr hab0')

Tactic state after: