l3lab/ntp-mathlib huggingface dataset:
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by 

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
⊢ IsPiSystem πS

Next tactic:
exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
⊢ MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS

Next tactic:
rw [generateFrom_pi.symm, comap_generateFrom]
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
⊢ generateFrom
      ((Set.preimage fun a i => f (↑i) a) '' (Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s})) =
    generateFrom πS

Next tactic:
congr
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
hπS_gen : MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
let πTβ := Set.pi (Set.univ : Set T) ''
      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | MeasurableSet[m i] s }
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
  let πTβ := Set.pi (Set.univ : Set T) ''
      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
hπS_gen : MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS
πTβ : Set (Set ((i : { x // x ∈ T }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
let πT := { s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s }
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
  let πTβ := Set.pi (Set.univ : Set T) ''
      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πT := { s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s }
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
hπS_gen : MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS
πTβ : Set (Set ((i : { x // x ∈ T }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πT : Set (Set Ω) := {s | ∃ t ∈ πTβ, (fun a i => f (↑i) a) ⁻¹' t = s}
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
have hπT_pi : IsPiSystem πT := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
  let πTβ := Set.pi (Set.univ : Set T) ''
      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πT := { s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s }
  have hπT_pi : IsPiSystem πT := by 

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
hπS_gen : MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS
πTβ : Set (Set ((i : { x // x ∈ T }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πT : Set (Set Ω) := {s | ∃ t ∈ πTβ, (fun a i => f (↑i) a) ⁻¹' t = s}
⊢ IsPiSystem πT

Next tactic:
exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
  let πTβ := Set.pi (Set.univ : Set T) ''
      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πT := { s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s }
  have hπT_pi : IsPiSystem πT := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
hπS_gen : MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS
πTβ : Set (Set ((i : { x // x ∈ T }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πT : Set (Set Ω) := {s | ∃ t ∈ πTβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπT_pi : IsPiSystem πT
⊢ IndepFun (fun a i => f (↑i) a) (fun a i => f (↑i) a) κ

Next tactic:
have hπT_gen : (MeasurableSpace.pi.comap fun a (i : T) => f i a) = generateFrom πT := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
/-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
two disjoint finite index sets, then the tuple formed by `f i` for `i ∈ S` is independent of the
tuple `(f i)_i` for `i ∈ T`. -/
theorem iIndepFun.indepFun_finset [IsMarkovKernel κ] (S T : Finset ι) (hST : Disjoint S T)
    (hf_Indep : iIndepFun m f κ μ) (hf_meas : ∀ i, Measurable (f i)) :
    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) κ μ := by
  -- We introduce π-systems, built from the π-system of boxes which generates `MeasurableSpace.pi`.
  let πSβ := Set.pi (Set.univ : Set S) ''
    Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
  have hπS_pi : IsPiSystem πS := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπS_gen : (MeasurableSpace.pi.comap fun a (i : S) => f i a) = generateFrom πS := by
    rw [generateFrom_pi.symm, comap_generateFrom]
    congr
  let πTβ := Set.pi (Set.univ : Set T) ''
      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | MeasurableSet[m i] s }
  let πT := { s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s }
  have hπT_pi : IsPiSystem πT := by exact IsPiSystem.comap (@isPiSystem_pi _ _ ?_) _
  have hπT_gen : (MeasurableSpace.pi.comap fun a (i : T) => f i a) = generateFrom πT := by
    

Proof state:
α : Type u_1
Ω : Type u_2
ι : Type u_3
β✝ : Type u_4
β' : Type u_5
γ : Type u_6
γ' : Type u_7
_mα : MeasurableSpace α
_mΩ : MeasurableSpace Ω
κ : ↥(kernel α Ω)
μ : Measure α
f✝ : Ω → β✝
g : Ω → β'
β : ι → Type u_8
m : (i : ι) → MeasurableSpace (β i)
f : (i : ι) → Ω → β i
inst✝ : IsMarkovKernel κ
S T : Finset ι
hST : Disjoint S T
hf_Indep : iIndepFun m f κ
hf_meas : ∀ (i : ι), Measurable (f i)
πSβ : Set (Set ((i : { x // x ∈ S }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πS : Set (Set Ω) := {s | ∃ t ∈ πSβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπS_pi : IsPiSystem πS
hπS_gen : MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πS
πTβ : Set (Set ((i : { x // x ∈ T }) → β ↑i)) := Set.pi Set.univ '' Set.pi Set.univ fun i => {s | MeasurableSet s}
πT : Set (Set Ω) := {s | ∃ t ∈ πTβ, (fun a i => f (↑i) a) ⁻¹' t = s}
hπT_pi : IsPiSystem πT
⊢ MeasurableSpace.comap (fun a i => f (↑i) a) pi = generateFrom πT

Next tactic:
rw [generateFrom_pi.symm, comap_generateFrom]