import Mathlib
import FoML


open MeasureTheory ProbabilityTheory Real

open scoped ENNReal

theorem extracted_formal_statement_391.{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 : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b)
  (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)))))
  (h_original_goal : ∃ a b, (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))) ⊆ Set.Icc a b) :
  BddBelow (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))) ∧
    BddAbove (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))) := sorry

Tactic state before:
Ω : 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, (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))) ⊆ Set.Icc a b

Tactic:
rw [<- bddBelow_bddAbove_iff_subset_Icc]

Tactic state after:
[Ω : 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))))
 ⊢ BddBelow (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k)))) ∧
     BddAbove (Set.range fun i => ∑ k, (f i (X (ω k)) - f i (X (x k))))]