theorem extracted_formal_statement_3.{u_1, w, u} {Ω : Type u} [inst : MeasurableSpace Ω] {Z : Type w} {n : ℕ}
  {ι : Type u_1} {f : ι → Z → ℝ} {μ : Measure Ω} [inst_1 : IsProbabilityMeasure μ] {X : Ω → Z} [inst_3 : Countable ι]
  (hf : ∀ (i : ι), Measurable (f i ∘ X)) (i : ι) : Measurable fun p => ∑ k, (f i (X (p.2 k)) - f i (X (p.1 k))) := sorry

State before:
case hf.left.hf.hf.hg.hf.hf.hf.hf
Ω : Type u
inst✝¹ : MeasurableSpace Ω
Z : Type w
n : ℕ
ι : Type u_1
f : ι → Z → ℝ
μ : Measure Ω
inst✝ : IsProbabilityMeasure μ
X : Ω → Z
inst_3 : Countable ι
hf : ∀ (i : ι), Measurable (f i ∘ X)
i : ι
⊢ Measurable fun p => ∑ k, (f i (X (p.2 k)) - f i (X (p.1 k)))

Tactic: apply Finset.measurable_sum Finset.univ
    intro i' hi
    apply Measurable.sub
    apply (hf i).comp measurable_snd.eval
    apply (hf i).comp measurable_fst.eval

State after:

Relevant lemmas:
Finset.measurable_sum : ∀ {M : Type u_2} {ι : Type u_3} {α : Type u_4} [inst : AddCommMonoid M]
  [inst_2 : MeasurableSpace M] [inst_4 : MeasurableAdd₂ M] {m : MeasurableSpace α} {f : ι → α → M} (s : Finset ι),
  (∀ i ∈ s, Measurable (f i)) → Measurable fun a => ∑ i ∈ s, f i a
Measurable.sub : ∀ {G : Type u_2} {α : Type u_3} [inst : MeasurableSpace G] [inst_2 : Sub G] {m : MeasurableSpace α}
  {f g : α → G} [inst_4 : MeasurableSub₂ G], Measurable f → Measurable g → Measurable fun a => f a - g a