probability.independence.basicMathlib.Probability.Independence.Basic

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

feat(probability/independence): Independence of singletons (#18506)

Characterisation of independence in terms of measure distributing over finite intersections, and lemmas connecting the different concepts of independence.

Also add supporting measurable_space and set.preimage lemmas

Diff
@@ -64,7 +64,7 @@ when defining `μ` in the example above, the measurable space used is the last o
 Part A, Chapter 4.
 -/
 
-open measure_theory measurable_space
+open measure_theory measurable_space set
 open_locale big_operators measure_theory ennreal
 
 namespace probability_theory
@@ -577,7 +577,8 @@ We prove the following equivalences on `indep_set`, for measurable sets `s, t`.
 * `indep_set s t μ ↔ indep_sets {s} {t} μ`.
 -/
 
-variables {s t : set Ω} (S T : set (set Ω))
+variables {s t : set Ω} (S T : set (set Ω)) {π : ι → set (set Ω)} {f : ι → set Ω}
+  {m0 : measurable_space Ω} {μ : measure Ω}
 
 lemma indep_set_iff_indep_sets_singleton {m0 : measurable_space Ω}
   (hs_meas : measurable_set s) (ht_meas : measurable_set t)
@@ -624,6 +625,40 @@ lemma indep_iff_forall_indep_set (m₁ m₂ : measurable_space Ω) {m0 : measura
   λ h s t hs ht, h s t hs ht s t (measurable_set_generate_from (set.mem_singleton s))
     (measurable_set_generate_from (set.mem_singleton t))⟩
 
+lemma Indep_sets.meas_Inter [fintype ι] (h : Indep_sets π μ) (hf : ∀ i, f i ∈ π i) :
+  μ (⋂ i, f i) = ∏ i, μ (f i) :=
+by simp [← h _ (λ i _, hf _)]
+
+lemma Indep_comap_mem_iff : Indep (λ i, measurable_space.comap (∈ f i) ⊤) μ ↔ Indep_set f μ :=
+by { simp_rw ←generate_from_singleton, refl }
+
+alias Indep_comap_mem_iff ↔ _ Indep_set.Indep_comap_mem
+
+lemma Indep_sets_singleton_iff :
+  Indep_sets (λ i, {f i}) μ ↔ ∀ t, μ (⋂ i ∈ t, f i) = ∏ i in t, μ (f i) :=
+forall_congr $ λ t,
+  ⟨λ h, h $ λ _ _, mem_singleton _,
+  λ h f hf, begin
+    refine eq.trans _ (h.trans $ finset.prod_congr rfl $ λ i hi, congr_arg _ $ (hf i hi).symm),
+    rw Inter₂_congr hf,
+  end⟩
+
+variables [is_probability_measure μ]
+
+lemma Indep_set_iff_Indep_sets_singleton (hf : ∀ i, measurable_set (f i)) :
+  Indep_set f μ ↔ Indep_sets (λ i, {f i}) μ :=
+⟨Indep.Indep_sets $ λ _, rfl, Indep_sets.Indep _
+  (λ i, generate_from_le $ by { rintro t (rfl : t = _), exact hf _}) _
+    (λ _, is_pi_system.singleton _) $ λ _, rfl⟩
+
+lemma Indep_set_iff_measure_Inter_eq_prod (hf : ∀ i, measurable_set (f i)) :
+  Indep_set f μ ↔ ∀ s, μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) :=
+(Indep_set_iff_Indep_sets_singleton hf).trans Indep_sets_singleton_iff
+
+lemma Indep_sets.Indep_set_of_mem (hfπ : ∀ i, f i ∈ π i) (hf : ∀ i, measurable_set (f i))
+  (hπ : Indep_sets π μ) : Indep_set f μ :=
+(Indep_set_iff_measure_Inter_eq_prod hf).2 $ λ t, hπ _ $ λ i _, hfπ _
+
 end indep_set
 
 section indep_fun

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -184,7 +184,7 @@ theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ :
     [IsProbabilityMeasure μ] : Indep m' ⊥ μ :=
   by
   intro s t hs ht
-  rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht 
+  rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht
   cases ht
   · rw [ht, Set.inter_empty, measure_empty, MulZeroClass.mul_zero]
   · rw [ht, Set.inter_univ, measure_univ, mul_one]
@@ -267,7 +267,7 @@ theorem IndepSets.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Se
     {μ : Measure Ω} (hyp : ∀ n, IndepSets (s n) s' μ) : IndepSets (⋃ n, s n) s' μ :=
   by
   intro t1 t2 ht1 ht2
-  rw [Set.mem_iUnion] at ht1 
+  rw [Set.mem_iUnion] at ht1
   cases' ht1 with n ht1
   exact hyp n t1 t2 ht1 ht2
 #align probability_theory.indep_sets.Union ProbabilityTheory.IndepSets.iUnion
@@ -278,7 +278,7 @@ theorem IndepSets.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Se
     {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSets (s n) s' μ) :
     IndepSets (⋃ n ∈ u, s n) s' μ := by
   intro t1 t2 ht1 ht2
-  simp_rw [Set.mem_iUnion] at ht1 
+  simp_rw [Set.mem_iUnion] at ht1
   rcases ht1 with ⟨n, hpn, ht1⟩
   exact hyp n hpn t1 t2 ht1 ht2
 #align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSets.bUnion
@@ -473,7 +473,7 @@ theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι 
     have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i :=
       by
       intro i hi_mem_union
-      rw [Finset.mem_union] at hi_mem_union 
+      rw [Finset.mem_union] at hi_mem_union
       cases' hi_mem_union with hi1 hi2
       · have hi2 : i ∉ p2 := fun hip2 => set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
         simp_rw [g, if_pos hi1, if_neg hi2, Set.inter_univ]
@@ -555,7 +555,7 @@ theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 :
   have h_pi_system_indep : indep_sets (⋃ n, p n) p' μ :=
     by
     refine' indep_sets.Union _
-    simp_rw [h_gen_n, h_gen'] at h_indep 
+    simp_rw [h_gen_n, h_gen'] at h_indep
     exact fun n => (h_indep n).IndepSets
   -- now go from π-systems to σ-algebras
   refine' indep_sets.indep (iSup_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
@@ -618,7 +618,7 @@ theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι}
     (hp_ind : iIndepSets π μ) (haS : a ∉ S) : IndepSets (piiUnionInter π S) (π a) μ :=
   by
   rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
-  rw [Finset.coe_subset] at hs_mem 
+  rw [Finset.coe_subset] at hs_mem
   classical
   let f n := ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
   have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n :=
@@ -861,7 +861,7 @@ theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → T
     congr with (i x)
     simp only [Set.mem_iInter]
     constructor <;> intro h hi_mem <;> specialize h hi_mem
-    · rwa [h_preim i hi_mem] at h 
+    · rwa [h_preim i hi_mem] at h
     · rwa [h_preim i hi_mem]
   have h_right_eq : ∏ i in S, μ (setsΩ i) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
     by
@@ -954,7 +954,7 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
       (Measurable.comap_le (measurable_pi_iff.mpr fun i => hf_meas i)) hπS_pi hπT_pi hπS_gen hπT_gen
       _
   rintro _ _ ⟨s, ⟨sets_s, hs1, hs2⟩, rfl⟩ ⟨t, ⟨sets_t, ht1, ht2⟩, rfl⟩
-  simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1 
+  simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1
   rw [← hs2, ← ht2]
   classical
   let sets_s' : ∀ i : ι, Set (β i) := fun i =>
@@ -978,7 +978,7 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
     simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
     constructor <;> intro h
     · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
-    · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h ; exact h
+    · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h; exact h
   have h_eq_inter_T :
     (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
     by
@@ -986,8 +986,8 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
     simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
     constructor <;> intro h
     · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
-    · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h ; exact h
-  rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep 
+    · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h; exact h
+  rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep
   rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
   have h_Inter_inter :
     ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
@@ -1004,7 +1004,7 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
   rw [h_Inter_inter, hf_Indep (S ∪ T)]
   swap
   · intro i hi_mem
-    rw [Finset.mem_union] at hi_mem 
+    rw [Finset.mem_union] at hi_mem
     cases hi_mem
     · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
     · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
Diff
@@ -325,7 +325,30 @@ section FromIndepToIndep
 
 #print ProbabilityTheory.iIndepSets.indepSets /-
 theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by classical
+    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by
+  classical
+  intro t₁ t₂ ht₁ ht₂
+  have hf_m : ∀ x : ι, x ∈ {i, j} → ite (x = i) t₁ t₂ ∈ s x :=
+    by
+    intro x hx
+    cases' finset.mem_insert.mp hx with hx hx
+    · simp [hx, ht₁]
+    · simp [finset.mem_singleton.mp hx, hij.symm, ht₂]
+  have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
+  have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
+  have h_inter :
+    (⋂ (t : ι) (H : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
+      ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
+    by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
+  have h_prod :
+    ∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂) =
+      μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) :=
+    by
+    simp only [hij, Finset.prod_singleton, Finset.prod_insert, not_false_iff, Finset.mem_singleton]
+  rw [h1]
+  nth_rw 2 [h2]
+  nth_rw 4 [h2]
+  rw [← h_inter, ← h_prod, h_indep {i, j} hf_m]
 #align probability_theory.Indep_sets.indep_sets ProbabilityTheory.iIndepSets.indepSets
 -/
 
@@ -444,6 +467,41 @@ theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι 
   by
   rintro t1 t2 ⟨p1, hp1, f1, ht1_m, ht1_eq⟩ ⟨p2, hp2, f2, ht2_m, ht2_eq⟩
   classical
+  let g i := ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ
+  have h_P_inter : μ (t1 ∩ t2) = ∏ n in p1 ∪ p2, μ (g n) :=
+    by
+    have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i :=
+      by
+      intro i hi_mem_union
+      rw [Finset.mem_union] at hi_mem_union 
+      cases' hi_mem_union with hi1 hi2
+      · have hi2 : i ∉ p2 := fun hip2 => set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
+        simp_rw [g, if_pos hi1, if_neg hi2, Set.inter_univ]
+        exact ht1_m i hi1
+      · have hi1 : i ∉ p1 := fun hip1 => set.disjoint_right.mp hST (hp2 hi2) (hp1 hip1)
+        simp_rw [g, if_neg hi1, if_pos hi2, Set.univ_inter]
+        exact ht2_m i hi2
+    have h_p1_inter_p2 :
+      ((⋂ x ∈ p1, f1 x) ∩ ⋂ x ∈ p2, f2 x) =
+        ⋂ i ∈ p1 ∪ p2, ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ :=
+      by
+      ext1 x
+      simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
+      exact
+        ⟨fun h i _ => ⟨h.1 i, h.2 i⟩, fun h =>
+          ⟨fun i hi => (h i (Or.inl hi)).1 hi, fun i hi => (h i (Or.inr hi)).2 hi⟩⟩
+    rw [ht1_eq, ht2_eq, h_p1_inter_p2, ← h_indep _ hgm]
+  have h_μg : ∀ n, μ (g n) = ite (n ∈ p1) (μ (f1 n)) 1 * ite (n ∈ p2) (μ (f2 n)) 1 :=
+    by
+    intro n
+    simp_rw [g]
+    split_ifs
+    · exact absurd rfl (set.disjoint_iff_forall_ne.mp hST _ (hp1 h) _ (hp2 h_1))
+    all_goals simp only [measure_univ, one_mul, mul_one, Set.inter_univ, Set.univ_inter]
+  simp_rw [h_P_inter, h_μg, Finset.prod_mul_distrib,
+    Finset.prod_ite_mem (p1 ∪ p2) p1 fun x => μ (f1 x), Finset.union_inter_cancel_left,
+    Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
+    h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
 #align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSets_piiUnionInter_of_disjoint
 -/
 
@@ -461,7 +519,7 @@ theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s :
   · exact fun k => generate_from_le fun t ht => (Set.mem_singleton_iff.1 ht).symm ▸ hsm k
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
-  · classical
+  · classical exact indep_sets_pi_Union_Inter_of_disjoint (Indep.Indep_sets (fun n => rfl) hs) hST
 #align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint
 -/
 
@@ -476,7 +534,7 @@ theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableS
       (generateFrom_piiUnionInter_measurableSet m T).symm _
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
-  · classical
+  · classical exact indep_sets_pi_Union_Inter_of_disjoint h_indep hST
 #align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indep_iSup_of_disjoint
 -/
 
@@ -562,6 +620,35 @@ theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι}
   rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
   rw [Finset.coe_subset] at hs_mem 
   classical
+  let f n := ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
+  have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n :=
+    by
+    intro n hn_mem_insert
+    simp_rw [f]
+    cases' finset.mem_insert.mp hn_mem_insert with hn_mem hn_mem
+    · simp [hn_mem, ht2_mem_pia]
+    · have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hn_mem)
+      simp [hn_ne_a, hn_mem, hft1_mem n hn_mem]
+  have h_f_mem_pi : ∀ n ∈ s, f n ∈ π n := fun x hxS => h_f_mem x (by simp [hxS])
+  have h_t1 : t1 = ⋂ n ∈ s, f n :=
+    by
+    suffices h_forall : ∀ n ∈ s, f n = ft1 n
+    · rw [ht1_eq]
+      congr with (n x)
+      congr with (hns y)
+      simp only [(h_forall n hns).symm]
+    intro n hnS
+    have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hnS)
+    simp_rw [f, if_pos hnS, if_neg hn_ne_a]
+  have h_μ_t1 : μ t1 = ∏ n in s, μ (f n) := by rw [h_t1, ← hp_ind s h_f_mem_pi]
+  have h_t2 : t2 = f a := by simp_rw [f]; simp
+  have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) :=
+    by
+    have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
+      rw [h_t1, h_t2, Finset.set_biInter_insert, Set.inter_comm]
+    rw [h_t1_inter_t2, ← hp_ind (insert a s) h_f_mem]
+  have has : a ∉ s := fun has_mem => haS (hs_mem Membership)
+  rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
 #align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
 -/
 
@@ -571,6 +658,30 @@ theorem iIndepSets.iIndep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace
     (h_le : ∀ i, m i ≤ m0) (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
     (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) : iIndep m μ := by
   classical
+  refine' Finset.induction _ _
+  ·
+    simp only [measure_univ, imp_true_iff, Set.iInter_false, Set.iInter_univ, Finset.prod_empty,
+      eq_self_iff_true]
+  intro a S ha_notin_S h_rec f hf_m
+  have hf_m_S : ∀ x ∈ S, measurable_set[m x] (f x) := fun x hx => hf_m x (by simp [hx])
+  rw [Finset.set_biInter_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
+  let p := piiUnionInter π S
+  set m_p := generate_from p with hS_eq_generate
+  have h_indep : indep m_p (m a) μ :=
+    by
+    have hp : IsPiSystem p := isPiSystem_piiUnionInter π h_pi S
+    have h_le' : ∀ i, generate_from (π i) ≤ m0 := fun i => (h_generate i).symm.trans_le (h_le i)
+    have hm_p : m_p ≤ m0 := generateFrom_piiUnionInter_le π h_le' S
+    exact
+      indep_sets.indep hm_p (h_le a) hp (h_pi a) hS_eq_generate (h_generate a)
+        (h_ind.pi_Union_Inter_of_not_mem ha_notin_S)
+  refine' h_indep.symm (f a) (⋂ n ∈ S, f n) (hf_m a (Finset.mem_insert_self a S)) _
+  have h_le_p : ∀ i ∈ S, m i ≤ m_p := by
+    intro n hn
+    rw [hS_eq_generate, h_generate n]
+    exact le_generateFrom_piiUnionInter S hn
+  have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
+  exact S.measurable_set_bInter h_S_f
 #align probability_theory.Indep_sets.Indep ProbabilityTheory.iIndepSets.iIndep
 -/
 
@@ -733,6 +844,31 @@ theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → T
   refine' ⟨fun h S sets h_meas => h _ fun i hi_mem => ⟨sets i, h_meas i hi_mem, rfl⟩, _⟩
   intro h S setsΩ h_meas
   classical
+  let setsβ : ∀ i : ι, Set (β i) := fun i =>
+    dite (i ∈ S) (fun hi_mem => (h_meas i hi_mem).some) fun _ => Set.univ
+  have h_measβ : ∀ i ∈ S, measurable_set[m i] (setsβ i) :=
+    by
+    intro i hi_mem
+    simp_rw [setsβ, dif_pos hi_mem]
+    exact (h_meas i hi_mem).choose_spec.1
+  have h_preim : ∀ i ∈ S, setsΩ i = f i ⁻¹' setsβ i :=
+    by
+    intro i hi_mem
+    simp_rw [setsβ, dif_pos hi_mem]
+    exact (h_meas i hi_mem).choose_spec.2.symm
+  have h_left_eq : μ (⋂ i ∈ S, setsΩ i) = μ (⋂ i ∈ S, f i ⁻¹' setsβ i) :=
+    by
+    congr with (i x)
+    simp only [Set.mem_iInter]
+    constructor <;> intro h hi_mem <;> specialize h hi_mem
+    · rwa [h_preim i hi_mem] at h 
+    · rwa [h_preim i hi_mem]
+  have h_right_eq : ∏ i in S, μ (setsΩ i) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
+    by
+    refine' Finset.prod_congr rfl fun i hi_mem => _
+    rw [h_preim i hi_mem]
+  rw [h_left_eq, h_right_eq]
+  exact h S h_measβ
 #align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul
 -/
 
@@ -821,6 +957,63 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
   simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1 
   rw [← hs2, ← ht2]
   classical
+  let sets_s' : ∀ i : ι, Set (β i) := fun i =>
+    dite (i ∈ S) (fun hi => sets_s ⟨i, hi⟩) fun _ => Set.univ
+  have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ := by intro i hi;
+    simp_rw [sets_s', dif_pos hi]
+  have h_sets_s'_univ : ∀ {i} (hi : i ∈ T), sets_s' i = Set.univ := by intro i hi;
+    simp_rw [sets_s', dif_neg (finset.disjoint_right.mp hST hi)]
+  let sets_t' : ∀ i : ι, Set (β i) := fun i =>
+    dite (i ∈ T) (fun hi => sets_t ⟨i, hi⟩) fun _ => Set.univ
+  have h_sets_t'_univ : ∀ {i} (hi : i ∈ S), sets_t' i = Set.univ := by intro i hi;
+    simp_rw [sets_t', dif_neg (finset.disjoint_left.mp hST hi)]
+  have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) := by intro i hi; rw [h_sets_s'_eq hi];
+    exact hs1 _
+  have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) := by intro i hi;
+    simp_rw [sets_t', dif_pos hi]; exact ht1 _
+  have h_eq_inter_S :
+    (fun (ω : Ω) (i : ↥S) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i :=
+    by
+    ext1 x
+    simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
+    constructor <;> intro h
+    · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
+    · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h ; exact h
+  have h_eq_inter_T :
+    (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
+    by
+    ext1 x
+    simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
+    constructor <;> intro h
+    · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
+    · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h ; exact h
+  rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep 
+  rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
+  have h_Inter_inter :
+    ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
+      ⋂ i ∈ S ∪ T, f i ⁻¹' (sets_s' i ∩ sets_t' i) :=
+    by
+    ext1 x
+    simp only [Set.mem_inter_iff, Set.mem_iInter, Set.mem_preimage, Finset.mem_union]
+    constructor <;> intro h
+    · intro i hi
+      cases hi
+      · rw [h_sets_t'_univ hi]; exact ⟨h.1 i hi, Set.mem_univ _⟩
+      · rw [h_sets_s'_univ hi]; exact ⟨Set.mem_univ _, h.2 i hi⟩
+    · exact ⟨fun i hi => (h i (Or.inl hi)).1, fun i hi => (h i (Or.inr hi)).2⟩
+  rw [h_Inter_inter, hf_Indep (S ∪ T)]
+  swap
+  · intro i hi_mem
+    rw [Finset.mem_union] at hi_mem 
+    cases hi_mem
+    · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
+    · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
+  rw [Finset.prod_union hST]
+  congr 1
+  · refine' Finset.prod_congr rfl fun i hi => _
+    rw [h_sets_t'_univ hi, Set.inter_univ]
+  · refine' Finset.prod_congr rfl fun i hi => _
+    rw [h_sets_s'_univ hi, Set.univ_inter]
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 -/
 
@@ -828,7 +1021,38 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
 theorem iIndepFun.indepFun_prod_mk [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFun (fun a => (f i a, f j a)) (f k) μ := by classical
+    IndepFun (fun a => (f i a, f j a)) (f k) μ := by
+  classical
+  have h_right :
+    f k =
+      (fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩) ∘
+        fun a (j : ({k} : Finset ι)) => f j a :=
+    rfl
+  have h_meas_right :
+    Measurable fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩ :=
+    measurable_pi_apply ⟨k, Finset.mem_singleton_self k⟩
+  let s : Finset ι := {i, j}
+  have h_left :
+    (fun ω => (f i ω, f j ω)) =
+      (fun p : ∀ l : s, β l =>
+          (p ⟨i, Finset.mem_insert_self i _⟩,
+            p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩)) ∘
+        fun a (j : s) => f j a :=
+    by
+    ext1 a
+    simp only [Prod.mk.inj_iff]
+    constructor <;> rfl
+  have h_meas_left :
+    Measurable fun p : ∀ l : s, β l =>
+      (p ⟨i, Finset.mem_insert_self i _⟩,
+        p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩) :=
+    Measurable.prod (measurable_pi_apply ⟨i, Finset.mem_insert_self i {j}⟩)
+      (measurable_pi_apply ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self j)⟩)
+  rw [h_left, h_right]
+  refine' (hf_Indep.indep_fun_finset s {k} _ hf_meas).comp h_meas_left h_meas_right
+  rw [Finset.disjoint_singleton_right]
+  simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
+  exact ⟨hik.symm, hjk.symm⟩
 #align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod_mk
 -/
 
@@ -852,7 +1076,28 @@ theorem iIndepFun.indepFun_mul_left [IsProbabilityMeasure μ] {ι : Type _} {β
 theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
-    (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by classical
+    (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by
+  classical
+  have h_right :
+    f i =
+      (fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩) ∘
+        fun a (j : ({i} : Finset ι)) => f j a :=
+    rfl
+  have h_meas_right :
+    Measurable fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩ :=
+    measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
+  have h_left : ∏ j in s, f j = (fun p : ∀ j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a :=
+    by
+    ext1 a
+    simp only [Function.comp_apply]
+    have : ∏ j : ↥s, f (↑j) a = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
+    rw [this, Finset.prod_coe_sort]
+  have h_meas_left : Measurable fun p : ∀ j : s, β => ∏ j, p j :=
+    finset.univ.measurable_prod fun (j : ↥s) (H : j ∈ Finset.univ) => measurable_pi_apply j
+  rw [h_left, h_right]
+  exact
+    (hf_Indep.indep_fun_finset s {i} (finset.disjoint_singleton_left.mpr hi).symm hf_meas).comp
+      h_meas_left h_meas_right
 #align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem
 #align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
 -/
@@ -872,6 +1117,17 @@ theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type
 theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
     (hs : iIndepSet s μ) : iIndepFun (fun n => m) (fun n => (s n).indicator fun ω => 1) μ := by
   classical
+  rw [Indep_fun_iff_measure_inter_preimage_eq_mul]
+  rintro S π hπ
+  simp_rw [Set.indicator_const_preimage_eq_union]
+  refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s iᶜ) ∅) fun i hi => _
+  have hsi : measurable_set[generate_from {s i}] (s i) :=
+    measurable_set_generate_from (Set.mem_singleton _)
+  refine'
+    MeasurableSet.union (MeasurableSet.ite' (fun _ => hsi) fun _ => _)
+      (MeasurableSet.ite' (fun _ => hsi.compl) fun _ => _)
+  · exact @MeasurableSet.empty _ (generate_from {s i})
+  · exact @MeasurableSet.empty _ (generate_from {s i})
 #align probability_theory.Indep_set.Indep_fun_indicator ProbabilityTheory.iIndepSet.iIndepFun_indicator
 -/
 
Diff
@@ -325,30 +325,7 @@ section FromIndepToIndep
 
 #print ProbabilityTheory.iIndepSets.indepSets /-
 theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by
-  classical
-  intro t₁ t₂ ht₁ ht₂
-  have hf_m : ∀ x : ι, x ∈ {i, j} → ite (x = i) t₁ t₂ ∈ s x :=
-    by
-    intro x hx
-    cases' finset.mem_insert.mp hx with hx hx
-    · simp [hx, ht₁]
-    · simp [finset.mem_singleton.mp hx, hij.symm, ht₂]
-  have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
-  have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
-  have h_inter :
-    (⋂ (t : ι) (H : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
-      ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
-    by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
-  have h_prod :
-    ∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂) =
-      μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) :=
-    by
-    simp only [hij, Finset.prod_singleton, Finset.prod_insert, not_false_iff, Finset.mem_singleton]
-  rw [h1]
-  nth_rw 2 [h2]
-  nth_rw 4 [h2]
-  rw [← h_inter, ← h_prod, h_indep {i, j} hf_m]
+    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by classical
 #align probability_theory.Indep_sets.indep_sets ProbabilityTheory.iIndepSets.indepSets
 -/
 
@@ -467,41 +444,6 @@ theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι 
   by
   rintro t1 t2 ⟨p1, hp1, f1, ht1_m, ht1_eq⟩ ⟨p2, hp2, f2, ht2_m, ht2_eq⟩
   classical
-  let g i := ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ
-  have h_P_inter : μ (t1 ∩ t2) = ∏ n in p1 ∪ p2, μ (g n) :=
-    by
-    have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i :=
-      by
-      intro i hi_mem_union
-      rw [Finset.mem_union] at hi_mem_union 
-      cases' hi_mem_union with hi1 hi2
-      · have hi2 : i ∉ p2 := fun hip2 => set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
-        simp_rw [g, if_pos hi1, if_neg hi2, Set.inter_univ]
-        exact ht1_m i hi1
-      · have hi1 : i ∉ p1 := fun hip1 => set.disjoint_right.mp hST (hp2 hi2) (hp1 hip1)
-        simp_rw [g, if_neg hi1, if_pos hi2, Set.univ_inter]
-        exact ht2_m i hi2
-    have h_p1_inter_p2 :
-      ((⋂ x ∈ p1, f1 x) ∩ ⋂ x ∈ p2, f2 x) =
-        ⋂ i ∈ p1 ∪ p2, ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ :=
-      by
-      ext1 x
-      simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
-      exact
-        ⟨fun h i _ => ⟨h.1 i, h.2 i⟩, fun h =>
-          ⟨fun i hi => (h i (Or.inl hi)).1 hi, fun i hi => (h i (Or.inr hi)).2 hi⟩⟩
-    rw [ht1_eq, ht2_eq, h_p1_inter_p2, ← h_indep _ hgm]
-  have h_μg : ∀ n, μ (g n) = ite (n ∈ p1) (μ (f1 n)) 1 * ite (n ∈ p2) (μ (f2 n)) 1 :=
-    by
-    intro n
-    simp_rw [g]
-    split_ifs
-    · exact absurd rfl (set.disjoint_iff_forall_ne.mp hST _ (hp1 h) _ (hp2 h_1))
-    all_goals simp only [measure_univ, one_mul, mul_one, Set.inter_univ, Set.univ_inter]
-  simp_rw [h_P_inter, h_μg, Finset.prod_mul_distrib,
-    Finset.prod_ite_mem (p1 ∪ p2) p1 fun x => μ (f1 x), Finset.union_inter_cancel_left,
-    Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
-    h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
 #align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSets_piiUnionInter_of_disjoint
 -/
 
@@ -519,7 +461,7 @@ theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s :
   · exact fun k => generate_from_le fun t ht => (Set.mem_singleton_iff.1 ht).symm ▸ hsm k
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
-  · classical exact indep_sets_pi_Union_Inter_of_disjoint (Indep.Indep_sets (fun n => rfl) hs) hST
+  · classical
 #align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint
 -/
 
@@ -534,7 +476,7 @@ theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableS
       (generateFrom_piiUnionInter_measurableSet m T).symm _
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
-  · classical exact indep_sets_pi_Union_Inter_of_disjoint h_indep hST
+  · classical
 #align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indep_iSup_of_disjoint
 -/
 
@@ -620,35 +562,6 @@ theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι}
   rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
   rw [Finset.coe_subset] at hs_mem 
   classical
-  let f n := ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
-  have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n :=
-    by
-    intro n hn_mem_insert
-    simp_rw [f]
-    cases' finset.mem_insert.mp hn_mem_insert with hn_mem hn_mem
-    · simp [hn_mem, ht2_mem_pia]
-    · have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hn_mem)
-      simp [hn_ne_a, hn_mem, hft1_mem n hn_mem]
-  have h_f_mem_pi : ∀ n ∈ s, f n ∈ π n := fun x hxS => h_f_mem x (by simp [hxS])
-  have h_t1 : t1 = ⋂ n ∈ s, f n :=
-    by
-    suffices h_forall : ∀ n ∈ s, f n = ft1 n
-    · rw [ht1_eq]
-      congr with (n x)
-      congr with (hns y)
-      simp only [(h_forall n hns).symm]
-    intro n hnS
-    have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hnS)
-    simp_rw [f, if_pos hnS, if_neg hn_ne_a]
-  have h_μ_t1 : μ t1 = ∏ n in s, μ (f n) := by rw [h_t1, ← hp_ind s h_f_mem_pi]
-  have h_t2 : t2 = f a := by simp_rw [f]; simp
-  have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) :=
-    by
-    have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
-      rw [h_t1, h_t2, Finset.set_biInter_insert, Set.inter_comm]
-    rw [h_t1_inter_t2, ← hp_ind (insert a s) h_f_mem]
-  have has : a ∉ s := fun has_mem => haS (hs_mem Membership)
-  rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
 #align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
 -/
 
@@ -658,30 +571,6 @@ theorem iIndepSets.iIndep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace
     (h_le : ∀ i, m i ≤ m0) (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
     (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) : iIndep m μ := by
   classical
-  refine' Finset.induction _ _
-  ·
-    simp only [measure_univ, imp_true_iff, Set.iInter_false, Set.iInter_univ, Finset.prod_empty,
-      eq_self_iff_true]
-  intro a S ha_notin_S h_rec f hf_m
-  have hf_m_S : ∀ x ∈ S, measurable_set[m x] (f x) := fun x hx => hf_m x (by simp [hx])
-  rw [Finset.set_biInter_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
-  let p := piiUnionInter π S
-  set m_p := generate_from p with hS_eq_generate
-  have h_indep : indep m_p (m a) μ :=
-    by
-    have hp : IsPiSystem p := isPiSystem_piiUnionInter π h_pi S
-    have h_le' : ∀ i, generate_from (π i) ≤ m0 := fun i => (h_generate i).symm.trans_le (h_le i)
-    have hm_p : m_p ≤ m0 := generateFrom_piiUnionInter_le π h_le' S
-    exact
-      indep_sets.indep hm_p (h_le a) hp (h_pi a) hS_eq_generate (h_generate a)
-        (h_ind.pi_Union_Inter_of_not_mem ha_notin_S)
-  refine' h_indep.symm (f a) (⋂ n ∈ S, f n) (hf_m a (Finset.mem_insert_self a S)) _
-  have h_le_p : ∀ i ∈ S, m i ≤ m_p := by
-    intro n hn
-    rw [hS_eq_generate, h_generate n]
-    exact le_generateFrom_piiUnionInter S hn
-  have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
-  exact S.measurable_set_bInter h_S_f
 #align probability_theory.Indep_sets.Indep ProbabilityTheory.iIndepSets.iIndep
 -/
 
@@ -844,31 +733,6 @@ theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → T
   refine' ⟨fun h S sets h_meas => h _ fun i hi_mem => ⟨sets i, h_meas i hi_mem, rfl⟩, _⟩
   intro h S setsΩ h_meas
   classical
-  let setsβ : ∀ i : ι, Set (β i) := fun i =>
-    dite (i ∈ S) (fun hi_mem => (h_meas i hi_mem).some) fun _ => Set.univ
-  have h_measβ : ∀ i ∈ S, measurable_set[m i] (setsβ i) :=
-    by
-    intro i hi_mem
-    simp_rw [setsβ, dif_pos hi_mem]
-    exact (h_meas i hi_mem).choose_spec.1
-  have h_preim : ∀ i ∈ S, setsΩ i = f i ⁻¹' setsβ i :=
-    by
-    intro i hi_mem
-    simp_rw [setsβ, dif_pos hi_mem]
-    exact (h_meas i hi_mem).choose_spec.2.symm
-  have h_left_eq : μ (⋂ i ∈ S, setsΩ i) = μ (⋂ i ∈ S, f i ⁻¹' setsβ i) :=
-    by
-    congr with (i x)
-    simp only [Set.mem_iInter]
-    constructor <;> intro h hi_mem <;> specialize h hi_mem
-    · rwa [h_preim i hi_mem] at h 
-    · rwa [h_preim i hi_mem]
-  have h_right_eq : ∏ i in S, μ (setsΩ i) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
-    by
-    refine' Finset.prod_congr rfl fun i hi_mem => _
-    rw [h_preim i hi_mem]
-  rw [h_left_eq, h_right_eq]
-  exact h S h_measβ
 #align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul
 -/
 
@@ -957,63 +821,6 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
   simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1 
   rw [← hs2, ← ht2]
   classical
-  let sets_s' : ∀ i : ι, Set (β i) := fun i =>
-    dite (i ∈ S) (fun hi => sets_s ⟨i, hi⟩) fun _ => Set.univ
-  have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ := by intro i hi;
-    simp_rw [sets_s', dif_pos hi]
-  have h_sets_s'_univ : ∀ {i} (hi : i ∈ T), sets_s' i = Set.univ := by intro i hi;
-    simp_rw [sets_s', dif_neg (finset.disjoint_right.mp hST hi)]
-  let sets_t' : ∀ i : ι, Set (β i) := fun i =>
-    dite (i ∈ T) (fun hi => sets_t ⟨i, hi⟩) fun _ => Set.univ
-  have h_sets_t'_univ : ∀ {i} (hi : i ∈ S), sets_t' i = Set.univ := by intro i hi;
-    simp_rw [sets_t', dif_neg (finset.disjoint_left.mp hST hi)]
-  have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) := by intro i hi; rw [h_sets_s'_eq hi];
-    exact hs1 _
-  have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) := by intro i hi;
-    simp_rw [sets_t', dif_pos hi]; exact ht1 _
-  have h_eq_inter_S :
-    (fun (ω : Ω) (i : ↥S) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i :=
-    by
-    ext1 x
-    simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
-    constructor <;> intro h
-    · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
-    · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h ; exact h
-  have h_eq_inter_T :
-    (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
-    by
-    ext1 x
-    simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
-    constructor <;> intro h
-    · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
-    · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h ; exact h
-  rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep 
-  rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
-  have h_Inter_inter :
-    ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
-      ⋂ i ∈ S ∪ T, f i ⁻¹' (sets_s' i ∩ sets_t' i) :=
-    by
-    ext1 x
-    simp only [Set.mem_inter_iff, Set.mem_iInter, Set.mem_preimage, Finset.mem_union]
-    constructor <;> intro h
-    · intro i hi
-      cases hi
-      · rw [h_sets_t'_univ hi]; exact ⟨h.1 i hi, Set.mem_univ _⟩
-      · rw [h_sets_s'_univ hi]; exact ⟨Set.mem_univ _, h.2 i hi⟩
-    · exact ⟨fun i hi => (h i (Or.inl hi)).1, fun i hi => (h i (Or.inr hi)).2⟩
-  rw [h_Inter_inter, hf_Indep (S ∪ T)]
-  swap
-  · intro i hi_mem
-    rw [Finset.mem_union] at hi_mem 
-    cases hi_mem
-    · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
-    · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
-  rw [Finset.prod_union hST]
-  congr 1
-  · refine' Finset.prod_congr rfl fun i hi => _
-    rw [h_sets_t'_univ hi, Set.inter_univ]
-  · refine' Finset.prod_congr rfl fun i hi => _
-    rw [h_sets_s'_univ hi, Set.univ_inter]
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 -/
 
@@ -1021,38 +828,7 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
 theorem iIndepFun.indepFun_prod_mk [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFun (fun a => (f i a, f j a)) (f k) μ := by
-  classical
-  have h_right :
-    f k =
-      (fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩) ∘
-        fun a (j : ({k} : Finset ι)) => f j a :=
-    rfl
-  have h_meas_right :
-    Measurable fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩ :=
-    measurable_pi_apply ⟨k, Finset.mem_singleton_self k⟩
-  let s : Finset ι := {i, j}
-  have h_left :
-    (fun ω => (f i ω, f j ω)) =
-      (fun p : ∀ l : s, β l =>
-          (p ⟨i, Finset.mem_insert_self i _⟩,
-            p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩)) ∘
-        fun a (j : s) => f j a :=
-    by
-    ext1 a
-    simp only [Prod.mk.inj_iff]
-    constructor <;> rfl
-  have h_meas_left :
-    Measurable fun p : ∀ l : s, β l =>
-      (p ⟨i, Finset.mem_insert_self i _⟩,
-        p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩) :=
-    Measurable.prod (measurable_pi_apply ⟨i, Finset.mem_insert_self i {j}⟩)
-      (measurable_pi_apply ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self j)⟩)
-  rw [h_left, h_right]
-  refine' (hf_Indep.indep_fun_finset s {k} _ hf_meas).comp h_meas_left h_meas_right
-  rw [Finset.disjoint_singleton_right]
-  simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
-  exact ⟨hik.symm, hjk.symm⟩
+    IndepFun (fun a => (f i a, f j a)) (f k) μ := by classical
 #align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod_mk
 -/
 
@@ -1076,28 +852,7 @@ theorem iIndepFun.indepFun_mul_left [IsProbabilityMeasure μ] {ι : Type _} {β
 theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
-    (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by
-  classical
-  have h_right :
-    f i =
-      (fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩) ∘
-        fun a (j : ({i} : Finset ι)) => f j a :=
-    rfl
-  have h_meas_right :
-    Measurable fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩ :=
-    measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
-  have h_left : ∏ j in s, f j = (fun p : ∀ j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a :=
-    by
-    ext1 a
-    simp only [Function.comp_apply]
-    have : ∏ j : ↥s, f (↑j) a = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
-    rw [this, Finset.prod_coe_sort]
-  have h_meas_left : Measurable fun p : ∀ j : s, β => ∏ j, p j :=
-    finset.univ.measurable_prod fun (j : ↥s) (H : j ∈ Finset.univ) => measurable_pi_apply j
-  rw [h_left, h_right]
-  exact
-    (hf_Indep.indep_fun_finset s {i} (finset.disjoint_singleton_left.mpr hi).symm hf_meas).comp
-      h_meas_left h_meas_right
+    (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by classical
 #align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem
 #align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
 -/
@@ -1117,17 +872,6 @@ theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type
 theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
     (hs : iIndepSet s μ) : iIndepFun (fun n => m) (fun n => (s n).indicator fun ω => 1) μ := by
   classical
-  rw [Indep_fun_iff_measure_inter_preimage_eq_mul]
-  rintro S π hπ
-  simp_rw [Set.indicator_const_preimage_eq_union]
-  refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s iᶜ) ∅) fun i hi => _
-  have hsi : measurable_set[generate_from {s i}] (s i) :=
-    measurable_set_generate_from (Set.mem_singleton _)
-  refine'
-    MeasurableSet.union (MeasurableSet.ite' (fun _ => hsi) fun _ => _)
-      (MeasurableSet.ite' (fun _ => hsi.compl) fun _ => _)
-  · exact @MeasurableSet.empty _ (generate_from {s i})
-  · exact @MeasurableSet.empty _ (generate_from {s i})
 #align probability_theory.Indep_set.Indep_fun_indicator ProbabilityTheory.iIndepSet.iIndepFun_indicator
 -/
 
Diff
@@ -1017,8 +1017,8 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 -/
 
-#print ProbabilityTheory.iIndepFun.indepFun_prod /-
-theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+#print ProbabilityTheory.iIndepFun.indepFun_prod_mk /-
+theorem iIndepFun.indepFun_prod_mk [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (fun a => (f i a, f j a)) (f k) μ := by
@@ -1053,22 +1053,22 @@ theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι
   rw [Finset.disjoint_singleton_right]
   simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
   exact ⟨hik.symm, hjk.symm⟩
-#align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
+#align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod_mk
 -/
 
-#print ProbabilityTheory.iIndepFun.mul /-
+#print ProbabilityTheory.iIndepFun.indepFun_mul_left /-
 @[to_additive]
-theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
-    [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
-    (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFun (f i * f j) (f k) μ :=
+theorem iIndepFun.indepFun_mul_left [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
+    {m : MeasurableSpace β} [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β}
+    (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (i j k : ι)
+    (hik : i ≠ k) (hjk : j ≠ k) : IndepFun (f i * f j) (f k) μ :=
   by
   have : indep_fun (fun ω => (f i ω, f j ω)) (f k) μ :=
     hf_Indep.indep_fun_prod hf_meas i j k hik hjk
   change indep_fun ((fun p : β × β => p.fst * p.snd) ∘ fun ω => (f i ω, f j ω)) (id ∘ f k) μ
   exact indep_fun.comp this (measurable_fst.mul measurable_snd) measurable_id
-#align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.mul
-#align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.add
+#align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.indepFun_mul_left
+#align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.indepFun_add_left
 -/
 
 #print ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem /-
Diff
@@ -652,12 +652,10 @@ theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι}
 #align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
 -/
 
-/- warning: probability_theory.Indep_sets.Indep clashes with probability_theory.indep_sets.indep -> ProbabilityTheory.IndepSets.indep
-Case conversion may be inaccurate. Consider using '#align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indepₓ'. -/
-#print ProbabilityTheory.IndepSets.indep /-
+#print ProbabilityTheory.iIndepSets.iIndep /-
 /-- The measurable space structures generated by independent pi-systems are independent. -/
-theorem IndepSets.indep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω) (h_le : ∀ i, m i ≤ m0)
-    (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
+theorem iIndepSets.iIndep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω)
+    (h_le : ∀ i, m i ≤ m0) (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
     (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) : iIndep m μ := by
   classical
   refine' Finset.induction _ _
@@ -684,7 +682,7 @@ theorem IndepSets.indep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω
     exact le_generateFrom_piiUnionInter S hn
   have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
   exact S.measurable_set_bInter h_S_f
-#align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indep
+#align probability_theory.Indep_sets.Indep ProbabilityTheory.iIndepSets.iIndep
 -/
 
 end FromPiSystemsToMeasurableSpaces
@@ -759,18 +757,23 @@ theorem indep_iff_forall_indepSet (m₁ m₂ : MeasurableSpace Ω) {m0 : Measura
 #align probability_theory.indep_iff_forall_indep_set ProbabilityTheory.indep_iff_forall_indepSet
 -/
 
+#print ProbabilityTheory.iIndepSets.meas_iInter /-
 theorem iIndepSets.meas_iInter [Fintype ι] (h : iIndepSets π μ) (hf : ∀ i, f i ∈ π i) :
     μ (⋂ i, f i) = ∏ i, μ (f i) := by simp [← h _ fun i _ => hf _]
 #align probability_theory.Indep_sets.meas_Inter ProbabilityTheory.iIndepSets.meas_iInter
+-/
 
+#print ProbabilityTheory.iIndep_comap_mem_iff /-
 theorem iIndep_comap_mem_iff :
     iIndep (fun i => MeasurableSpace.comap (· ∈ f i) ⊤) μ ↔ iIndepSet f μ := by
   simp_rw [← generate_from_singleton]; rfl
 #align probability_theory.Indep_comap_mem_iff ProbabilityTheory.iIndep_comap_mem_iff
+-/
 
 alias ⟨_, Indep_set.Indep_comap_mem⟩ := Indep_comap_mem_iff
 #align probability_theory.Indep_set.Indep_comap_mem ProbabilityTheory.iIndepSet.iIndep_comap_mem
 
+#print ProbabilityTheory.iIndepSets_singleton_iff /-
 theorem iIndepSets_singleton_iff :
     iIndepSets (fun i => {f i}) μ ↔ ∀ t, μ (⋂ i ∈ t, f i) = ∏ i in t, μ (f i) :=
   forall_congr' fun t =>
@@ -780,25 +783,32 @@ theorem iIndepSets_singleton_iff :
         Eq.trans _ (h.trans <| Finset.prod_congr rfl fun i hi => congr_arg _ <| (hf i hi).symm)
       rw [Inter₂_congr hf]⟩
 #align probability_theory.Indep_sets_singleton_iff ProbabilityTheory.iIndepSets_singleton_iff
+-/
 
 variable [IsProbabilityMeasure μ]
 
+#print ProbabilityTheory.iIndepSet_iff_iIndepSets_singleton /-
 theorem iIndepSet_iff_iIndepSets_singleton (hf : ∀ i, MeasurableSet (f i)) :
     iIndepSet f μ ↔ iIndepSets (fun i => {f i}) μ :=
   ⟨iIndep.iIndepSets fun _ => rfl,
-    IndepSets.indep _ (fun i => generateFrom_le <| by rintro t (rfl : t = _); exact hf _) _
+    iIndepSets.iIndep _ (fun i => generateFrom_le <| by rintro t (rfl : t = _); exact hf _) _
       (fun _ => IsPiSystem.singleton _) fun _ => rfl⟩
 #align probability_theory.Indep_set_iff_Indep_sets_singleton ProbabilityTheory.iIndepSet_iff_iIndepSets_singleton
+-/
 
-theorem iIndepSet_iff_measure_iInter_eq_prod (hf : ∀ i, MeasurableSet (f i)) :
+#print ProbabilityTheory.iIndepSet_iff_meas_biInter /-
+theorem iIndepSet_iff_meas_biInter (hf : ∀ i, MeasurableSet (f i)) :
     iIndepSet f μ ↔ ∀ s, μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) :=
   (iIndepSet_iff_iIndepSets_singleton hf).trans iIndepSets_singleton_iff
-#align probability_theory.Indep_set_iff_measure_Inter_eq_prod ProbabilityTheory.iIndepSet_iff_measure_iInter_eq_prod
+#align probability_theory.Indep_set_iff_measure_Inter_eq_prod ProbabilityTheory.iIndepSet_iff_meas_biInter
+-/
 
+#print ProbabilityTheory.iIndepSets.iIndepSet_of_mem /-
 theorem iIndepSets.iIndepSet_of_mem (hfπ : ∀ i, f i ∈ π i) (hf : ∀ i, MeasurableSet (f i))
     (hπ : iIndepSets π μ) : iIndepSet f μ :=
-  (iIndepSet_iff_measure_iInter_eq_prod hf).2 fun t => hπ _ fun i _ => hfπ _
+  (iIndepSet_iff_meas_biInter hf).2 fun t => hπ _ fun i _ => hfπ _
 #align probability_theory.Indep_sets.Indep_set_of_mem ProbabilityTheory.iIndepSets.iIndepSet_of_mem
+-/
 
 end IndepSet
 
Diff
@@ -609,7 +609,7 @@ theorem indep_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSp
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Antitone m) :
     Indep (⨆ i, m i) m' μ :=
-  indep_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
+  indep_iSup_of_directed_le h_indep h_le h_le' (directed_of_isDirected_ge hm)
 #align probability_theory.indep_supr_of_antitone ProbabilityTheory.indep_iSup_of_antitone
 -/
 
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2021 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 -/
-import Mathbin.MeasureTheory.Constructions.Pi
+import MeasureTheory.Constructions.Pi
 
 #align_import probability.independence.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29"
 
Diff
@@ -5,7 +5,7 @@ Authors: Rémy Degenne
 -/
 import Mathbin.MeasureTheory.Constructions.Pi
 
-#align_import probability.independence.basic from "leanprover-community/mathlib"@"af471b9e3ce868f296626d33189b4ce730fa4c00"
+#align_import probability.independence.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29"
 
 /-!
 # Independence of sets of sets and measure spaces (σ-algebras)
@@ -67,7 +67,7 @@ Part A, Chapter 4.
 -/
 
 
-open MeasureTheory MeasurableSpace
+open MeasureTheory MeasurableSpace Set
 
 open scoped BigOperators MeasureTheory ENNReal
 
@@ -699,7 +699,8 @@ We prove the following equivalences on `indep_set`, for measurable sets `s, t`.
 -/
 
 
-variable {s t : Set Ω} (S T : Set (Set Ω))
+variable {s t : Set Ω} (S T : Set (Set Ω)) {π : ι → Set (Set Ω)} {f : ι → Set Ω}
+  {m0 : MeasurableSpace Ω} {μ : Measure Ω}
 
 #print ProbabilityTheory.indepSet_iff_indepSets_singleton /-
 theorem indepSet_iff_indepSets_singleton {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
@@ -758,6 +759,47 @@ theorem indep_iff_forall_indepSet (m₁ m₂ : MeasurableSpace Ω) {m0 : Measura
 #align probability_theory.indep_iff_forall_indep_set ProbabilityTheory.indep_iff_forall_indepSet
 -/
 
+theorem iIndepSets.meas_iInter [Fintype ι] (h : iIndepSets π μ) (hf : ∀ i, f i ∈ π i) :
+    μ (⋂ i, f i) = ∏ i, μ (f i) := by simp [← h _ fun i _ => hf _]
+#align probability_theory.Indep_sets.meas_Inter ProbabilityTheory.iIndepSets.meas_iInter
+
+theorem iIndep_comap_mem_iff :
+    iIndep (fun i => MeasurableSpace.comap (· ∈ f i) ⊤) μ ↔ iIndepSet f μ := by
+  simp_rw [← generate_from_singleton]; rfl
+#align probability_theory.Indep_comap_mem_iff ProbabilityTheory.iIndep_comap_mem_iff
+
+alias ⟨_, Indep_set.Indep_comap_mem⟩ := Indep_comap_mem_iff
+#align probability_theory.Indep_set.Indep_comap_mem ProbabilityTheory.iIndepSet.iIndep_comap_mem
+
+theorem iIndepSets_singleton_iff :
+    iIndepSets (fun i => {f i}) μ ↔ ∀ t, μ (⋂ i ∈ t, f i) = ∏ i in t, μ (f i) :=
+  forall_congr' fun t =>
+    ⟨fun h => h fun _ _ => mem_singleton _, fun h f hf =>
+      by
+      refine'
+        Eq.trans _ (h.trans <| Finset.prod_congr rfl fun i hi => congr_arg _ <| (hf i hi).symm)
+      rw [Inter₂_congr hf]⟩
+#align probability_theory.Indep_sets_singleton_iff ProbabilityTheory.iIndepSets_singleton_iff
+
+variable [IsProbabilityMeasure μ]
+
+theorem iIndepSet_iff_iIndepSets_singleton (hf : ∀ i, MeasurableSet (f i)) :
+    iIndepSet f μ ↔ iIndepSets (fun i => {f i}) μ :=
+  ⟨iIndep.iIndepSets fun _ => rfl,
+    IndepSets.indep _ (fun i => generateFrom_le <| by rintro t (rfl : t = _); exact hf _) _
+      (fun _ => IsPiSystem.singleton _) fun _ => rfl⟩
+#align probability_theory.Indep_set_iff_Indep_sets_singleton ProbabilityTheory.iIndepSet_iff_iIndepSets_singleton
+
+theorem iIndepSet_iff_measure_iInter_eq_prod (hf : ∀ i, MeasurableSet (f i)) :
+    iIndepSet f μ ↔ ∀ s, μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) :=
+  (iIndepSet_iff_iIndepSets_singleton hf).trans iIndepSets_singleton_iff
+#align probability_theory.Indep_set_iff_measure_Inter_eq_prod ProbabilityTheory.iIndepSet_iff_measure_iInter_eq_prod
+
+theorem iIndepSets.iIndepSet_of_mem (hfπ : ∀ i, f i ∈ π i) (hf : ∀ i, MeasurableSet (f i))
+    (hπ : iIndepSets π μ) : iIndepSet f μ :=
+  (iIndepSet_iff_measure_iInter_eq_prod hf).2 fun t => hπ _ fun i _ => hfπ _
+#align probability_theory.Indep_sets.Indep_set_of_mem ProbabilityTheory.iIndepSets.iIndepSet_of_mem
+
 end IndepSet
 
 section IndepFun
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2021 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
-
-! This file was ported from Lean 3 source module probability.independence.basic
-! leanprover-community/mathlib commit af471b9e3ce868f296626d33189b4ce730fa4c00
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.MeasureTheory.Constructions.Pi
 
+#align_import probability.independence.basic from "leanprover-community/mathlib"@"af471b9e3ce868f296626d33189b4ce730fa4c00"
+
 /-!
 # Independence of sets of sets and measure spaces (σ-algebras)
 
Diff
@@ -182,6 +182,7 @@ theorem Indep.symm {m₁ m₂ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : M
 #align probability_theory.indep.symm ProbabilityTheory.Indep.symm
 -/
 
+#print ProbabilityTheory.indep_bot_right /-
 theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
     [IsProbabilityMeasure μ] : Indep m' ⊥ μ :=
   by
@@ -191,11 +192,14 @@ theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ :
   · rw [ht, Set.inter_empty, measure_empty, MulZeroClass.mul_zero]
   · rw [ht, Set.inter_univ, measure_univ, mul_one]
 #align probability_theory.indep_bot_right ProbabilityTheory.indep_bot_right
+-/
 
+#print ProbabilityTheory.indep_bot_left /-
 theorem indep_bot_left (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
     [IsProbabilityMeasure μ] : Indep ⊥ m' μ :=
   (indep_bot_right m').symm
 #align probability_theory.indep_bot_left ProbabilityTheory.indep_bot_left
+-/
 
 #print ProbabilityTheory.indepSet_empty_right /-
 theorem indepSet_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
@@ -239,6 +243,7 @@ theorem indep_of_indep_of_le_right {m₁ m₂ m₃ : MeasurableSpace Ω} [Measur
 #align probability_theory.indep_of_indep_of_le_right ProbabilityTheory.indep_of_indep_of_le_right
 -/
 
+#print ProbabilityTheory.IndepSets.union /-
 theorem IndepSets.union [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω}
     (h₁ : IndepSets s₁ s' μ) (h₂ : IndepSets s₂ s' μ) : IndepSets (s₁ ∪ s₂) s' μ :=
   by
@@ -247,7 +252,9 @@ theorem IndepSets.union [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ :
   · exact h₁ t1 t2 ht1₁ ht2
   · exact h₂ t1 t2 ht1₂ ht2
 #align probability_theory.indep_sets.union ProbabilityTheory.IndepSets.union
+-/
 
+#print ProbabilityTheory.IndepSets.union_iff /-
 @[simp]
 theorem IndepSets.union_iff [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω} :
     IndepSets (s₁ ∪ s₂) s' μ ↔ IndepSets s₁ s' μ ∧ IndepSets s₂ s' μ :=
@@ -256,7 +263,9 @@ theorem IndepSets.union_iff [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {
       indepSets_of_indepSets_of_le_left h (Set.subset_union_right s₁ s₂)⟩,
     fun h => IndepSets.union h.left h.right⟩
 #align probability_theory.indep_sets.union_iff ProbabilityTheory.IndepSets.union_iff
+-/
 
+#print ProbabilityTheory.IndepSets.iUnion /-
 theorem IndepSets.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} (hyp : ∀ n, IndepSets (s n) s' μ) : IndepSets (⋃ n, s n) s' μ :=
   by
@@ -265,7 +274,9 @@ theorem IndepSets.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Se
   cases' ht1 with n ht1
   exact hyp n t1 t2 ht1 ht2
 #align probability_theory.indep_sets.Union ProbabilityTheory.IndepSets.iUnion
+-/
 
+#print ProbabilityTheory.IndepSets.bUnion /-
 theorem IndepSets.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSets (s n) s' μ) :
     IndepSets (⋃ n ∈ u, s n) s' μ := by
@@ -274,17 +285,23 @@ theorem IndepSets.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Se
   rcases ht1 with ⟨n, hpn, ht1⟩
   exact hyp n hpn t1 t2 ht1 ht2
 #align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSets.bUnion
+-/
 
+#print ProbabilityTheory.IndepSets.inter /-
 theorem IndepSets.inter [MeasurableSpace Ω] {s₁ s' : Set (Set Ω)} (s₂ : Set (Set Ω)) {μ : Measure Ω}
     (h₁ : IndepSets s₁ s' μ) : IndepSets (s₁ ∩ s₂) s' μ := fun t1 t2 ht1 ht2 =>
   h₁ t1 t2 ((Set.mem_inter_iff _ _ _).mp ht1).left ht2
 #align probability_theory.indep_sets.inter ProbabilityTheory.IndepSets.inter
+-/
 
+#print ProbabilityTheory.IndepSets.iInter /-
 theorem IndepSets.iInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} (h : ∃ n, IndepSets (s n) s' μ) : IndepSets (⋂ n, s n) s' μ := by
   intro t1 t2 ht1 ht2; cases' h with n h; exact h t1 t2 (set.mem_Inter.mp ht1 n) ht2
 #align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSets.iInter
+-/
 
+#print ProbabilityTheory.IndepSets.bInter /-
 theorem IndepSets.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} {u : Set ι} (h : ∃ n ∈ u, IndepSets (s n) s' μ) :
     IndepSets (⋂ n ∈ u, s n) s' μ := by
@@ -292,12 +309,15 @@ theorem IndepSets.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Se
   rcases h with ⟨n, hn, h⟩
   exact h t1 t2 (Set.biInter_subset_of_mem hn ht1) ht2
 #align probability_theory.indep_sets.bInter ProbabilityTheory.IndepSets.bInter
+-/
 
+#print ProbabilityTheory.indepSets_singleton_iff /-
 theorem indepSets_singleton_iff [MeasurableSpace Ω] {s t : Set Ω} {μ : Measure Ω} :
     IndepSets {s} {t} μ ↔ μ (s ∩ t) = μ s * μ t :=
   ⟨fun h => h s t rfl rfl, fun h s1 t1 hs1 ht1 => by
     rwa [set.mem_singleton_iff.mp hs1, set.mem_singleton_iff.mp ht1]⟩
 #align probability_theory.indep_sets_singleton_iff ProbabilityTheory.indepSets_singleton_iff
+-/
 
 end Indep
 
@@ -306,6 +326,7 @@ end Indep
 
 section FromIndepToIndep
 
+#print ProbabilityTheory.iIndepSets.indepSets /-
 theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
     (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by
   classical
@@ -332,19 +353,24 @@ theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ
   nth_rw 4 [h2]
   rw [← h_inter, ← h_prod, h_indep {i, j} hf_m]
 #align probability_theory.Indep_sets.indep_sets ProbabilityTheory.iIndepSets.indepSets
+-/
 
+#print ProbabilityTheory.iIndep.indep /-
 theorem iIndep.indep {m : ι → MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
     (h_indep : iIndep m μ) {i j : ι} (hij : i ≠ j) : Indep (m i) (m j) μ :=
   by
   change indep_sets ((fun x => measurable_set[m x]) i) ((fun x => measurable_set[m x]) j) μ
   exact Indep_sets.indep_sets h_indep hij
 #align probability_theory.Indep.indep ProbabilityTheory.iIndep.indep
+-/
 
+#print ProbabilityTheory.iIndepFun.indepFun /-
 theorem iIndepFun.indepFun {m₀ : MeasurableSpace Ω} {μ : Measure Ω} {β : ι → Type _}
     {m : ∀ x, MeasurableSpace (β x)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ) {i j : ι}
     (hij : i ≠ j) : IndepFun (f i) (f j) μ :=
   hf_Indep.indep hij
 #align probability_theory.Indep_fun.indep_fun ProbabilityTheory.iIndepFun.indepFun
+-/
 
 end FromIndepToIndep
 
@@ -360,12 +386,14 @@ section FromMeasurableSpacesToSetsOfSets
 /-! ### Independence of measurable space structures implies independence of generating π-systems -/
 
 
+#print ProbabilityTheory.iIndep.iIndepSets /-
 theorem iIndep.iIndepSets [MeasurableSpace Ω] {μ : Measure Ω} {m : ι → MeasurableSpace Ω}
     {s : ι → Set (Set Ω)} (hms : ∀ n, m n = generateFrom (s n)) (h_indep : iIndep m μ) :
     iIndepSets s μ := fun S f hfs =>
   h_indep S fun x hxS =>
     ((hms x).symm ▸ measurableSet_generateFrom (hfs x hxS) : measurable_set[m x] (f x))
 #align probability_theory.Indep.Indep_sets ProbabilityTheory.iIndep.iIndepSets
+-/
 
 #print ProbabilityTheory.Indep.indepSets /-
 theorem Indep.indepSets [MeasurableSpace Ω] {μ : Measure Ω} {s1 s2 : Set (Set Ω)}
@@ -435,6 +463,7 @@ theorem IndepSets.indep' {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabili
 
 variable {m0 : MeasurableSpace Ω} {μ : Measure Ω}
 
+#print ProbabilityTheory.indepSets_piiUnionInter_of_disjoint /-
 theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set (Set Ω)}
     {S T : Set ι} (h_indep : iIndepSets s μ) (hST : Disjoint S T) :
     IndepSets (piiUnionInter s S) (piiUnionInter s T) μ :=
@@ -477,7 +506,9 @@ theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι 
     Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
     h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
 #align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSets_piiUnionInter_of_disjoint
+-/
 
+#print ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint /-
 theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (S T : Set ι) (hST : Disjoint S T) :
     Indep (generateFrom {t | ∃ n ∈ S, s n = t}) (generateFrom {t | ∃ k ∈ T, s k = t}) μ :=
@@ -493,7 +524,9 @@ theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s :
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
   · classical exact indep_sets_pi_Union_Inter_of_disjoint (Indep.Indep_sets (fun n => rfl) hs) hST
 #align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint
+-/
 
+#print ProbabilityTheory.indep_iSup_of_disjoint /-
 theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
     (h_le : ∀ i, m i ≤ m0) (h_indep : iIndep m μ) {S T : Set ι} (hST : Disjoint S T) :
     Indep (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ :=
@@ -506,7 +539,9 @@ theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableS
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
   · classical exact indep_sets_pi_Union_Inter_of_disjoint h_indep hST
 #align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indep_iSup_of_disjoint
+-/
 
+#print ProbabilityTheory.indep_iSup_of_directed_le /-
 theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
     {μ : Measure Ω} [IsProbabilityMeasure μ] (h_indep : ∀ i, Indep (m i) m' μ)
     (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Directed (· ≤ ·) m) : Indep (⨆ i, m i) m' μ :=
@@ -529,7 +564,9 @@ theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 :
   refine' indep_sets.indep (iSup_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
   exact (generate_from_Union_measurable_set _).symm
 #align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indep_iSup_of_directed_le
+-/
 
+#print ProbabilityTheory.iIndepSet.indep_generateFrom_lt /-
 theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) :
     Indep (generateFrom {s i}) (generateFrom {t | ∃ j < i, s j = t}) μ :=
@@ -539,7 +576,9 @@ theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [IsProbabilityMeasure μ]
       (set.disjoint_singleton_left.mpr (lt_irrefl _))
   simp only [Set.mem_singleton_iff, exists_prop, exists_eq_left, Set.setOf_eq_eq_singleton']
 #align probability_theory.Indep_set.indep_generate_from_lt ProbabilityTheory.iIndepSet.indep_generateFrom_lt
+-/
 
+#print ProbabilityTheory.iIndepSet.indep_generateFrom_le /-
 theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) {k : ι} (hk : i < k) :
     Indep (generateFrom {s k}) (generateFrom {t | ∃ j ≤ i, s j = t}) μ :=
@@ -549,27 +588,35 @@ theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [IsProbabilityMeasure 
       (set.disjoint_singleton_left.mpr hk.not_le)
   simp only [Set.mem_singleton_iff, exists_prop, exists_eq_left, Set.setOf_eq_eq_singleton']
 #align probability_theory.Indep_set.indep_generate_from_le ProbabilityTheory.iIndepSet.indep_generateFrom_le
+-/
 
+#print ProbabilityTheory.iIndepSet.indep_generateFrom_le_nat /-
 theorem iIndepSet.indep_generateFrom_le_nat [IsProbabilityMeasure μ] {s : ℕ → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (n : ℕ) :
     Indep (generateFrom {s (n + 1)}) (generateFrom {t | ∃ k ≤ n, s k = t}) μ :=
   hs.indep_generateFrom_le hsm _ n.lt_succ_self
 #align probability_theory.Indep_set.indep_generate_from_le_nat ProbabilityTheory.iIndepSet.indep_generateFrom_le_nat
+-/
 
+#print ProbabilityTheory.indep_iSup_of_monotone /-
 theorem indep_iSup_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Monotone m) :
     Indep (⨆ i, m i) m' μ :=
   indep_iSup_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
 #align probability_theory.indep_supr_of_monotone ProbabilityTheory.indep_iSup_of_monotone
+-/
 
+#print ProbabilityTheory.indep_iSup_of_antitone /-
 theorem indep_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Antitone m) :
     Indep (⨆ i, m i) m' μ :=
   indep_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
 #align probability_theory.indep_supr_of_antitone ProbabilityTheory.indep_iSup_of_antitone
+-/
 
+#print ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem /-
 theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {S : Finset ι}
     (hp_ind : iIndepSets π μ) (haS : a ∉ S) : IndepSets (piiUnionInter π S) (π a) μ :=
   by
@@ -606,9 +653,11 @@ theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι}
   have has : a ∉ s := fun has_mem => haS (hs_mem Membership)
   rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
 #align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
+-/
 
 /- warning: probability_theory.Indep_sets.Indep clashes with probability_theory.indep_sets.indep -> ProbabilityTheory.IndepSets.indep
 Case conversion may be inaccurate. Consider using '#align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indepₓ'. -/
+#print ProbabilityTheory.IndepSets.indep /-
 /-- The measurable space structures generated by independent pi-systems are independent. -/
 theorem IndepSets.indep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω) (h_le : ∀ i, m i ≤ m0)
     (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
@@ -639,6 +688,7 @@ theorem IndepSets.indep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω
   have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
   exact S.measurable_set_bInter h_S_f
 #align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indep
+-/
 
 end FromPiSystemsToMeasurableSpaces
 
@@ -665,11 +715,13 @@ theorem indepSet_iff_indepSets_singleton {m0 : MeasurableSpace Ω} (hs_meas : Me
 #align probability_theory.indep_set_iff_indep_sets_singleton ProbabilityTheory.indepSet_iff_indepSets_singleton
 -/
 
+#print ProbabilityTheory.indepSet_iff_measure_inter_eq_mul /-
 theorem indepSet_iff_measure_inter_eq_mul {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume)
     [IsProbabilityMeasure μ] : IndepSet s t μ ↔ μ (s ∩ t) = μ s * μ t :=
   (indepSet_iff_indepSets_singleton hs_meas ht_meas μ).trans indepSets_singleton_iff
 #align probability_theory.indep_set_iff_measure_inter_eq_mul ProbabilityTheory.indepSet_iff_measure_inter_eq_mul
+-/
 
 #print ProbabilityTheory.IndepSets.indepSet_of_mem /-
 theorem IndepSets.indepSet_of_mem {m0 : MeasurableSpace Ω} (hs : s ∈ S) (ht : t ∈ T)
@@ -720,6 +772,7 @@ section IndepFun
 
 variable {β β' γ γ' : Type _} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {f : Ω → β} {g : Ω → β'}
 
+#print ProbabilityTheory.indepFun_iff_measure_inter_preimage_eq_mul /-
 theorem indepFun_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
     {mβ' : MeasurableSpace β'} :
     IndepFun f g μ ↔
@@ -730,7 +783,9 @@ theorem indepFun_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
   · refine' fun s t hs ht => h (f ⁻¹' s) (g ⁻¹' t) ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩
   · rintro _ _ ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩; exact h s t hs ht
 #align probability_theory.indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFun_iff_measure_inter_preimage_eq_mul
+-/
 
+#print ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul /-
 theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Type _}
     (m : ∀ x, MeasurableSpace (β x)) (f : ∀ i, Ω → β i) :
     iIndepFun m f μ ↔
@@ -766,7 +821,9 @@ theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → T
   rw [h_left_eq, h_right_eq]
   exact h S h_measβ
 #align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul
+-/
 
+#print ProbabilityTheory.indepFun_iff_indepSet_preimage /-
 theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
     [IsProbabilityMeasure μ] (hf : Measurable f) (hg : Measurable g) :
     IndepFun f g μ ↔ ∀ s t, MeasurableSet s → MeasurableSet t → IndepSet (f ⁻¹' s) (g ⁻¹' t) μ :=
@@ -776,6 +833,7 @@ theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : Measur
   · rwa [indep_set_iff_measure_inter_eq_mul (hf hs) (hg ht) μ]
   · rwa [← indep_set_iff_measure_inter_eq_mul (hf hs) (hg ht) μ]
 #align probability_theory.indep_fun_iff_indep_set_preimage ProbabilityTheory.indepFun_iff_indepSet_preimage
+-/
 
 #print ProbabilityTheory.IndepFun.symm /-
 @[symm]
@@ -797,6 +855,7 @@ theorem IndepFun.ae_eq {mβ : MeasurableSpace β} {f g f' g' : Ω → β} (hfg :
 #align probability_theory.indep_fun.ae_eq ProbabilityTheory.IndepFun.ae_eq
 -/
 
+#print ProbabilityTheory.IndepFun.comp /-
 theorem IndepFun.comp {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'} {mγ : MeasurableSpace γ}
     {mγ' : MeasurableSpace γ'} {φ : β → γ} {ψ : β' → γ'} (hfg : IndepFun f g μ) (hφ : Measurable φ)
     (hψ : Measurable ψ) : IndepFun (φ ∘ f) (ψ ∘ g) μ :=
@@ -806,7 +865,9 @@ theorem IndepFun.comp {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'} {m
   · exact ⟨φ ⁻¹' A, hφ hA, set.preimage_comp.symm⟩
   · exact ⟨ψ ⁻¹' B, hψ hB, set.preimage_comp.symm⟩
 #align probability_theory.indep_fun.comp ProbabilityTheory.IndepFun.comp
+-/
 
+#print ProbabilityTheory.iIndepFun.indepFun_finset /-
 /-- If `f` is a family of mutually independent random variables (`Indep_fun 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`. -/
@@ -905,7 +966,9 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
   · refine' Finset.prod_congr rfl fun i hi => _
     rw [h_sets_s'_univ hi, Set.univ_inter]
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
+-/
 
+#print ProbabilityTheory.iIndepFun.indepFun_prod /-
 theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
@@ -942,7 +1005,9 @@ theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι
   simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
   exact ⟨hik.symm, hjk.symm⟩
 #align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
+-/
 
+#print ProbabilityTheory.iIndepFun.mul /-
 @[to_additive]
 theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
     [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
@@ -955,7 +1020,9 @@ theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m :
   exact indep_fun.comp this (measurable_fst.mul measurable_snd) measurable_id
 #align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.mul
 #align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.add
+-/
 
+#print ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem /-
 @[to_additive]
 theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
@@ -984,7 +1051,9 @@ theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι
       h_meas_left h_meas_right
 #align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem
 #align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
+-/
 
+#print ProbabilityTheory.iIndepFun.indepFun_prod_range_succ /-
 @[to_additive]
 theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ℕ → Ω → β}
@@ -993,7 +1062,9 @@ theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type
   hf_Indep.indepFun_finset_prod_of_not_mem hf_meas Finset.not_mem_range_self
 #align probability_theory.Indep_fun.indep_fun_prod_range_succ ProbabilityTheory.iIndepFun.indepFun_prod_range_succ
 #align probability_theory.Indep_fun.indep_fun_sum_range_succ ProbabilityTheory.iIndepFun.indepFun_sum_range_succ
+-/
 
+#print ProbabilityTheory.iIndepSet.iIndepFun_indicator /-
 theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
     (hs : iIndepSet s μ) : iIndepFun (fun n => m) (fun n => (s n).indicator fun ω => 1) μ := by
   classical
@@ -1009,6 +1080,7 @@ theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β
   · exact @MeasurableSet.empty _ (generate_from {s i})
   · exact @MeasurableSet.empty _ (generate_from {s i})
 #align probability_theory.Indep_set.Indep_fun_indicator ProbabilityTheory.iIndepSet.iIndepFun_indicator
+-/
 
 end IndepFun
 
Diff
@@ -323,7 +323,7 @@ theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ
       ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
     by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
   have h_prod :
-    (∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂)) =
+    ∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂) =
       μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) :=
     by
     simp only [hij, Finset.prod_singleton, Finset.prod_insert, not_false_iff, Finset.mem_singleton]
@@ -759,7 +759,7 @@ theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → T
     constructor <;> intro h hi_mem <;> specialize h hi_mem
     · rwa [h_preim i hi_mem] at h 
     · rwa [h_preim i hi_mem]
-  have h_right_eq : (∏ i in S, μ (setsΩ i)) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
+  have h_right_eq : ∏ i in S, μ (setsΩ i) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
     by
     refine' Finset.prod_congr rfl fun i hi_mem => _
     rw [h_preim i hi_mem]
@@ -970,11 +970,11 @@ theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι
   have h_meas_right :
     Measurable fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩ :=
     measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
-  have h_left : (∏ j in s, f j) = (fun p : ∀ j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a :=
+  have h_left : ∏ j in s, f j = (fun p : ∀ j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a :=
     by
     ext1 a
     simp only [Function.comp_apply]
-    have : (∏ j : ↥s, f (↑j) a) = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
+    have : ∏ j : ↥s, f (↑j) a = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
     rw [this, Finset.prod_coe_sort]
   have h_meas_left : Measurable fun p : ∀ j : s, β => ∏ j, p j :=
     finset.univ.measurable_prod fun (j : ↥s) (H : j ∈ Finset.univ) => measurable_pi_apply j
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 
 ! This file was ported from Lean 3 source module probability.independence.basic
-! leanprover-community/mathlib commit 2f8347015b12b0864dfaf366ec4909eb70c78740
+! leanprover-community/mathlib commit af471b9e3ce868f296626d33189b4ce730fa4c00
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.MeasureTheory.Constructions.Pi
 /-!
 # Independence of sets of sets and measure spaces (σ-algebras)
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 * A family of sets of sets `π : ι → set (set Ω)` is independent with respect to a measure `μ` if for
   any finite set of indices `s = {i_1, ..., i_n}`, for any sets `f i_1 ∈ π i_1, ..., f i_n ∈ π i_n`,
   `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. It will be used for families of π-systems.
@@ -77,192 +80,224 @@ variable {Ω ι : Type _}
 
 section Definitions
 
+#print ProbabilityTheory.iIndepSets /-
 /-- A family of sets of sets `π : ι → set (set Ω)` is independent with respect to a measure `μ` if
 for any finite set of indices `s = {i_1, ..., i_n}`, for any sets
 `f i_1 ∈ π i_1, ..., f i_n ∈ π i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `.
 It will be used for families of pi_systems. -/
-def IndepSets [MeasurableSpace Ω] (π : ι → Set (Set Ω))
+def iIndepSets [MeasurableSpace Ω] (π : ι → Set (Set Ω))
     (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
   ∀ (s : Finset ι) {f : ι → Set Ω} (H : ∀ i, i ∈ s → f i ∈ π i),
     μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i)
-#align probability_theory.Indep_sets ProbabilityTheory.IndepSets
+#align probability_theory.Indep_sets ProbabilityTheory.iIndepSets
+-/
 
+#print ProbabilityTheory.IndepSets /-
 /-- Two sets of sets `s₁, s₂` are independent with respect to a measure `μ` if for any sets
 `t₁ ∈ p₁, t₂ ∈ s₂`, then `μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/
-def IndepSetsCat [MeasurableSpace Ω] (s1 s2 : Set (Set Ω))
+def IndepSets [MeasurableSpace Ω] (s1 s2 : Set (Set Ω))
     (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
   ∀ t1 t2 : Set Ω, t1 ∈ s1 → t2 ∈ s2 → μ (t1 ∩ t2) = μ t1 * μ t2
-#align probability_theory.indep_sets ProbabilityTheory.IndepSetsCat
+#align probability_theory.indep_sets ProbabilityTheory.IndepSets
+-/
 
+#print ProbabilityTheory.iIndep /-
 /-- A family of measurable space structures (i.e. of σ-algebras) is independent with respect to a
 measure `μ` (typically defined on a finer σ-algebra) if the family of sets of measurable sets they
 define is independent. `m : ι → measurable_space Ω` is independent with respect to measure `μ` if
 for any finite set of indices `s = {i_1, ..., i_n}`, for any sets
 `f i_1 ∈ m i_1, ..., f i_n ∈ m i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. -/
-def Indep (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω]
+def iIndep (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω]
     (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
-  IndepSets (fun x => { s | measurable_set[m x] s }) μ
-#align probability_theory.Indep ProbabilityTheory.Indep
+  iIndepSets (fun x => {s | measurable_set[m x] s}) μ
+#align probability_theory.Indep ProbabilityTheory.iIndep
+-/
 
+#print ProbabilityTheory.Indep /-
 /-- Two measurable space structures (or σ-algebras) `m₁, m₂` are independent with respect to a
 measure `μ` (defined on a third σ-algebra) if for any sets `t₁ ∈ m₁, t₂ ∈ m₂`,
 `μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/
-def IndepCat (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω]
+def Indep (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω]
     (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
-  IndepSetsCat { s | measurable_set[m₁] s } { s | measurable_set[m₂] s } μ
-#align probability_theory.indep ProbabilityTheory.IndepCat
+  IndepSets {s | measurable_set[m₁] s} {s | measurable_set[m₂] s} μ
+#align probability_theory.indep ProbabilityTheory.Indep
+-/
 
+#print ProbabilityTheory.iIndepSet /-
 /-- A family of sets is independent if the family of measurable space structures they generate is
 independent. For a set `s`, the generated measurable space has measurable sets `∅, s, sᶜ, univ`. -/
-def IndepSet [MeasurableSpace Ω] (s : ι → Set Ω)
+def iIndepSet [MeasurableSpace Ω] (s : ι → Set Ω)
     (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
-  Indep (fun i => generateFrom {s i}) μ
-#align probability_theory.Indep_set ProbabilityTheory.IndepSet
+  iIndep (fun i => generateFrom {s i}) μ
+#align probability_theory.Indep_set ProbabilityTheory.iIndepSet
+-/
 
+#print ProbabilityTheory.IndepSet /-
 /-- Two sets are independent if the two measurable space structures they generate are independent.
 For a set `s`, the generated measurable space structure has measurable sets `∅, s, sᶜ, univ`. -/
-def IndepSetCat [MeasurableSpace Ω] (s t : Set Ω)
+def IndepSet [MeasurableSpace Ω] (s t : Set Ω)
     (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
-  IndepCat (generateFrom {s}) (generateFrom {t}) μ
-#align probability_theory.indep_set ProbabilityTheory.IndepSetCat
+  Indep (generateFrom {s}) (generateFrom {t}) μ
+#align probability_theory.indep_set ProbabilityTheory.IndepSet
+-/
 
+#print ProbabilityTheory.iIndepFun /-
 /-- A family of functions defined on the same space `Ω` and taking values in possibly different
 spaces, each with a measurable space structure, is independent if the family of measurable space
 structures they generate on `Ω` is independent. For a function `g` with codomain having measurable
 space structure `m`, the generated measurable space structure is `measurable_space.comap g m`. -/
-def IndepFun [MeasurableSpace Ω] {β : ι → Type _} (m : ∀ x : ι, MeasurableSpace (β x))
+def iIndepFun [MeasurableSpace Ω] {β : ι → Type _} (m : ∀ x : ι, MeasurableSpace (β x))
     (f : ∀ x : ι, Ω → β x) (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
-  Indep (fun x => MeasurableSpace.comap (f x) (m x)) μ
-#align probability_theory.Indep_fun ProbabilityTheory.IndepFun
+  iIndep (fun x => MeasurableSpace.comap (f x) (m x)) μ
+#align probability_theory.Indep_fun ProbabilityTheory.iIndepFun
+-/
 
+#print ProbabilityTheory.IndepFun /-
 /-- Two functions are independent if the two measurable space structures they generate are
 independent. For a function `f` with codomain having measurable space structure `m`, the generated
 measurable space structure is `measurable_space.comap f m`. -/
-def IndepFunCat {β γ} [MeasurableSpace Ω] [mβ : MeasurableSpace β] [mγ : MeasurableSpace γ]
-    (f : Ω → β) (g : Ω → γ) (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
-  IndepCat (MeasurableSpace.comap f mβ) (MeasurableSpace.comap g mγ) μ
-#align probability_theory.indep_fun ProbabilityTheory.IndepFunCat
+def IndepFun {β γ} [MeasurableSpace Ω] [mβ : MeasurableSpace β] [mγ : MeasurableSpace γ] (f : Ω → β)
+    (g : Ω → γ) (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) : Prop :=
+  Indep (MeasurableSpace.comap f mβ) (MeasurableSpace.comap g mγ) μ
+#align probability_theory.indep_fun ProbabilityTheory.IndepFun
+-/
 
 end Definitions
 
 section Indep
 
+#print ProbabilityTheory.IndepSets.symm /-
 @[symm]
-theorem IndepSetsCat.symm {s₁ s₂ : Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h : IndepSetsCat s₁ s₂ μ) : IndepSetsCat s₂ s₁ μ := by intro t1 t2 ht1 ht2;
+theorem IndepSets.symm {s₁ s₂ : Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
+    (h : IndepSets s₁ s₂ μ) : IndepSets s₂ s₁ μ := by intro t1 t2 ht1 ht2;
   rw [Set.inter_comm, mul_comm]; exact h t2 t1 ht2 ht1
-#align probability_theory.indep_sets.symm ProbabilityTheory.IndepSetsCat.symm
+#align probability_theory.indep_sets.symm ProbabilityTheory.IndepSets.symm
+-/
 
+#print ProbabilityTheory.Indep.symm /-
 @[symm]
-theorem IndepCat.symm {m₁ m₂ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h : IndepCat m₁ m₂ μ) : IndepCat m₂ m₁ μ :=
-  IndepSetsCat.symm h
-#align probability_theory.indep.symm ProbabilityTheory.IndepCat.symm
+theorem Indep.symm {m₁ m₂ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
+    (h : Indep m₁ m₂ μ) : Indep m₂ m₁ μ :=
+  IndepSets.symm h
+#align probability_theory.indep.symm ProbabilityTheory.Indep.symm
+-/
 
-theorem indepCat_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
-    [ProbabilityMeasure μ] : IndepCat m' ⊥ μ :=
+theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
+    [IsProbabilityMeasure μ] : Indep m' ⊥ μ :=
   by
   intro s t hs ht
   rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht 
   cases ht
   · rw [ht, Set.inter_empty, measure_empty, MulZeroClass.mul_zero]
   · rw [ht, Set.inter_univ, measure_univ, mul_one]
-#align probability_theory.indep_bot_right ProbabilityTheory.indepCat_bot_right
+#align probability_theory.indep_bot_right ProbabilityTheory.indep_bot_right
 
-theorem indepCat_bot_left (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
-    [ProbabilityMeasure μ] : IndepCat ⊥ m' μ :=
-  (indepCat_bot_right m').symm
-#align probability_theory.indep_bot_left ProbabilityTheory.indepCat_bot_left
+theorem indep_bot_left (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
+    [IsProbabilityMeasure μ] : Indep ⊥ m' μ :=
+  (indep_bot_right m').symm
+#align probability_theory.indep_bot_left ProbabilityTheory.indep_bot_left
 
-theorem indepSetCat_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
-    (s : Set Ω) : IndepSetCat s ∅ μ := by simp only [indep_set, generate_from_singleton_empty];
+#print ProbabilityTheory.indepSet_empty_right /-
+theorem indepSet_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
+    (s : Set Ω) : IndepSet s ∅ μ := by simp only [indep_set, generate_from_singleton_empty];
   exact indep_bot_right _
-#align probability_theory.indep_set_empty_right ProbabilityTheory.indepSetCat_empty_right
+#align probability_theory.indep_set_empty_right ProbabilityTheory.indepSet_empty_right
+-/
 
-theorem indepSetCat_empty_left {m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
-    (s : Set Ω) : IndepSetCat ∅ s μ :=
-  (indepSetCat_empty_right s).symm
-#align probability_theory.indep_set_empty_left ProbabilityTheory.indepSetCat_empty_left
+#print ProbabilityTheory.indepSet_empty_left /-
+theorem indepSet_empty_left {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
+    (s : Set Ω) : IndepSet ∅ s μ :=
+  (indepSet_empty_right s).symm
+#align probability_theory.indep_set_empty_left ProbabilityTheory.indepSet_empty_left
+-/
 
-theorem indepSetsCat_of_indepSetsCat_of_le_left {s₁ s₂ s₃ : Set (Set Ω)} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : IndepSetsCat s₁ s₂ μ) (h31 : s₃ ⊆ s₁) : IndepSetsCat s₃ s₂ μ :=
+#print ProbabilityTheory.indepSets_of_indepSets_of_le_left /-
+theorem indepSets_of_indepSets_of_le_left {s₁ s₂ s₃ : Set (Set Ω)} [MeasurableSpace Ω]
+    {μ : Measure Ω} (h_indep : IndepSets s₁ s₂ μ) (h31 : s₃ ⊆ s₁) : IndepSets s₃ s₂ μ :=
   fun t1 t2 ht1 ht2 => h_indep t1 t2 (Set.mem_of_subset_of_mem h31 ht1) ht2
-#align probability_theory.indep_sets_of_indep_sets_of_le_left ProbabilityTheory.indepSetsCat_of_indepSetsCat_of_le_left
+#align probability_theory.indep_sets_of_indep_sets_of_le_left ProbabilityTheory.indepSets_of_indepSets_of_le_left
+-/
 
-theorem indepSetsCat_of_indepSetsCat_of_le_right {s₁ s₂ s₃ : Set (Set Ω)} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : IndepSetsCat s₁ s₂ μ) (h32 : s₃ ⊆ s₂) : IndepSetsCat s₁ s₃ μ :=
+#print ProbabilityTheory.indepSets_of_indepSets_of_le_right /-
+theorem indepSets_of_indepSets_of_le_right {s₁ s₂ s₃ : Set (Set Ω)} [MeasurableSpace Ω]
+    {μ : Measure Ω} (h_indep : IndepSets s₁ s₂ μ) (h32 : s₃ ⊆ s₂) : IndepSets s₁ s₃ μ :=
   fun t1 t2 ht1 ht2 => h_indep t1 t2 ht1 (Set.mem_of_subset_of_mem h32 ht2)
-#align probability_theory.indep_sets_of_indep_sets_of_le_right ProbabilityTheory.indepSetsCat_of_indepSetsCat_of_le_right
+#align probability_theory.indep_sets_of_indep_sets_of_le_right ProbabilityTheory.indepSets_of_indepSets_of_le_right
+-/
 
-theorem indepCat_of_indepCat_of_le_left {m₁ m₂ m₃ : MeasurableSpace Ω} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : IndepCat m₁ m₂ μ) (h31 : m₃ ≤ m₁) : IndepCat m₃ m₂ μ :=
-  fun t1 t2 ht1 ht2 => h_indep t1 t2 (h31 _ ht1) ht2
-#align probability_theory.indep_of_indep_of_le_left ProbabilityTheory.indepCat_of_indepCat_of_le_left
+#print ProbabilityTheory.indep_of_indep_of_le_left /-
+theorem indep_of_indep_of_le_left {m₁ m₂ m₃ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
+    (h_indep : Indep m₁ m₂ μ) (h31 : m₃ ≤ m₁) : Indep m₃ m₂ μ := fun t1 t2 ht1 ht2 =>
+  h_indep t1 t2 (h31 _ ht1) ht2
+#align probability_theory.indep_of_indep_of_le_left ProbabilityTheory.indep_of_indep_of_le_left
+-/
 
-theorem indepCat_of_indepCat_of_le_right {m₁ m₂ m₃ : MeasurableSpace Ω} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : IndepCat m₁ m₂ μ) (h32 : m₃ ≤ m₂) : IndepCat m₁ m₃ μ :=
+#print ProbabilityTheory.indep_of_indep_of_le_right /-
+theorem indep_of_indep_of_le_right {m₁ m₂ m₃ : MeasurableSpace Ω} [MeasurableSpace Ω]
+    {μ : Measure Ω} (h_indep : Indep m₁ m₂ μ) (h32 : m₃ ≤ m₂) : Indep m₁ m₃ μ :=
   fun t1 t2 ht1 ht2 => h_indep t1 t2 ht1 (h32 _ ht2)
-#align probability_theory.indep_of_indep_of_le_right ProbabilityTheory.indepCat_of_indepCat_of_le_right
+#align probability_theory.indep_of_indep_of_le_right ProbabilityTheory.indep_of_indep_of_le_right
+-/
 
-theorem IndepSetsCat.union [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω}
-    (h₁ : IndepSetsCat s₁ s' μ) (h₂ : IndepSetsCat s₂ s' μ) : IndepSetsCat (s₁ ∪ s₂) s' μ :=
+theorem IndepSets.union [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω}
+    (h₁ : IndepSets s₁ s' μ) (h₂ : IndepSets s₂ s' μ) : IndepSets (s₁ ∪ s₂) s' μ :=
   by
   intro t1 t2 ht1 ht2
   cases' (Set.mem_union _ _ _).mp ht1 with ht1₁ ht1₂
   · exact h₁ t1 t2 ht1₁ ht2
   · exact h₂ t1 t2 ht1₂ ht2
-#align probability_theory.indep_sets.union ProbabilityTheory.IndepSetsCat.union
+#align probability_theory.indep_sets.union ProbabilityTheory.IndepSets.union
 
 @[simp]
-theorem IndepSetsCat.union_iff [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω} :
-    IndepSetsCat (s₁ ∪ s₂) s' μ ↔ IndepSetsCat s₁ s' μ ∧ IndepSetsCat s₂ s' μ :=
+theorem IndepSets.union_iff [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω} :
+    IndepSets (s₁ ∪ s₂) s' μ ↔ IndepSets s₁ s' μ ∧ IndepSets s₂ s' μ :=
   ⟨fun h =>
-    ⟨indepSetsCat_of_indepSetsCat_of_le_left h (Set.subset_union_left s₁ s₂),
-      indepSetsCat_of_indepSetsCat_of_le_left h (Set.subset_union_right s₁ s₂)⟩,
-    fun h => IndepSetsCat.union h.left h.right⟩
-#align probability_theory.indep_sets.union_iff ProbabilityTheory.IndepSetsCat.union_iff
+    ⟨indepSets_of_indepSets_of_le_left h (Set.subset_union_left s₁ s₂),
+      indepSets_of_indepSets_of_le_left h (Set.subset_union_right s₁ s₂)⟩,
+    fun h => IndepSets.union h.left h.right⟩
+#align probability_theory.indep_sets.union_iff ProbabilityTheory.IndepSets.union_iff
 
-theorem IndepSetsCat.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} (hyp : ∀ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋃ n, s n) s' μ :=
+theorem IndepSets.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
+    {μ : Measure Ω} (hyp : ∀ n, IndepSets (s n) s' μ) : IndepSets (⋃ n, s n) s' μ :=
   by
   intro t1 t2 ht1 ht2
   rw [Set.mem_iUnion] at ht1 
   cases' ht1 with n ht1
   exact hyp n t1 t2 ht1 ht2
-#align probability_theory.indep_sets.Union ProbabilityTheory.IndepSetsCat.iUnion
+#align probability_theory.indep_sets.Union ProbabilityTheory.IndepSets.iUnion
 
-theorem IndepSetsCat.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSetsCat (s n) s' μ) :
-    IndepSetsCat (⋃ n ∈ u, s n) s' μ := by
+theorem IndepSets.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
+    {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSets (s n) s' μ) :
+    IndepSets (⋃ n ∈ u, s n) s' μ := by
   intro t1 t2 ht1 ht2
   simp_rw [Set.mem_iUnion] at ht1 
   rcases ht1 with ⟨n, hpn, ht1⟩
   exact hyp n hpn t1 t2 ht1 ht2
-#align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSetsCat.bUnion
+#align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSets.bUnion
 
-theorem IndepSetsCat.inter [MeasurableSpace Ω] {s₁ s' : Set (Set Ω)} (s₂ : Set (Set Ω))
-    {μ : Measure Ω} (h₁ : IndepSetsCat s₁ s' μ) : IndepSetsCat (s₁ ∩ s₂) s' μ :=
-  fun t1 t2 ht1 ht2 => h₁ t1 t2 ((Set.mem_inter_iff _ _ _).mp ht1).left ht2
-#align probability_theory.indep_sets.inter ProbabilityTheory.IndepSetsCat.inter
+theorem IndepSets.inter [MeasurableSpace Ω] {s₁ s' : Set (Set Ω)} (s₂ : Set (Set Ω)) {μ : Measure Ω}
+    (h₁ : IndepSets s₁ s' μ) : IndepSets (s₁ ∩ s₂) s' μ := fun t1 t2 ht1 ht2 =>
+  h₁ t1 t2 ((Set.mem_inter_iff _ _ _).mp ht1).left ht2
+#align probability_theory.indep_sets.inter ProbabilityTheory.IndepSets.inter
 
-theorem IndepSetsCat.iInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} (h : ∃ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋂ n, s n) s' μ := by
+theorem IndepSets.iInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
+    {μ : Measure Ω} (h : ∃ n, IndepSets (s n) s' μ) : IndepSets (⋂ n, s n) s' μ := by
   intro t1 t2 ht1 ht2; cases' h with n h; exact h t1 t2 (set.mem_Inter.mp ht1 n) ht2
-#align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSetsCat.iInter
+#align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSets.iInter
 
-theorem IndepSetsCat.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} {u : Set ι} (h : ∃ n ∈ u, IndepSetsCat (s n) s' μ) :
-    IndepSetsCat (⋂ n ∈ u, s n) s' μ := by
+theorem IndepSets.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
+    {μ : Measure Ω} {u : Set ι} (h : ∃ n ∈ u, IndepSets (s n) s' μ) :
+    IndepSets (⋂ n ∈ u, s n) s' μ := by
   intro t1 t2 ht1 ht2
   rcases h with ⟨n, hn, h⟩
   exact h t1 t2 (Set.biInter_subset_of_mem hn ht1) ht2
-#align probability_theory.indep_sets.bInter ProbabilityTheory.IndepSetsCat.bInter
+#align probability_theory.indep_sets.bInter ProbabilityTheory.IndepSets.bInter
 
-theorem indepSetsCat_singleton_iff [MeasurableSpace Ω] {s t : Set Ω} {μ : Measure Ω} :
-    IndepSetsCat {s} {t} μ ↔ μ (s ∩ t) = μ s * μ t :=
+theorem indepSets_singleton_iff [MeasurableSpace Ω] {s t : Set Ω} {μ : Measure Ω} :
+    IndepSets {s} {t} μ ↔ μ (s ∩ t) = μ s * μ t :=
   ⟨fun h => h s t rfl rfl, fun h s1 t1 hs1 ht1 => by
     rwa [set.mem_singleton_iff.mp hs1, set.mem_singleton_iff.mp ht1]⟩
-#align probability_theory.indep_sets_singleton_iff ProbabilityTheory.indepSetsCat_singleton_iff
+#align probability_theory.indep_sets_singleton_iff ProbabilityTheory.indepSets_singleton_iff
 
 end Indep
 
@@ -271,46 +306,45 @@ end Indep
 
 section FromIndepToIndep
 
-theorem IndepSets.indepSetsCat {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h_indep : IndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSetsCat (s i) (s j) μ := by
+theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
+    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by
   classical
-    intro t₁ t₂ ht₁ ht₂
-    have hf_m : ∀ x : ι, x ∈ {i, j} → ite (x = i) t₁ t₂ ∈ s x :=
-      by
-      intro x hx
-      cases' finset.mem_insert.mp hx with hx hx
-      · simp [hx, ht₁]
-      · simp [finset.mem_singleton.mp hx, hij.symm, ht₂]
-    have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
-    have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
-    have h_inter :
-      (⋂ (t : ι) (H : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
-        ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
-      by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
-    have h_prod :
-      (∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂)) =
-        μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) :=
-      by
-      simp only [hij, Finset.prod_singleton, Finset.prod_insert, not_false_iff,
-        Finset.mem_singleton]
-    rw [h1]
-    nth_rw 2 [h2]
-    nth_rw 4 [h2]
-    rw [← h_inter, ← h_prod, h_indep {i, j} hf_m]
-#align probability_theory.Indep_sets.indep_sets ProbabilityTheory.IndepSets.indepSetsCat
-
-theorem Indep.indepCat {m : ι → MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h_indep : Indep m μ) {i j : ι} (hij : i ≠ j) : IndepCat (m i) (m j) μ :=
+  intro t₁ t₂ ht₁ ht₂
+  have hf_m : ∀ x : ι, x ∈ {i, j} → ite (x = i) t₁ t₂ ∈ s x :=
+    by
+    intro x hx
+    cases' finset.mem_insert.mp hx with hx hx
+    · simp [hx, ht₁]
+    · simp [finset.mem_singleton.mp hx, hij.symm, ht₂]
+  have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
+  have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
+  have h_inter :
+    (⋂ (t : ι) (H : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
+      ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
+    by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
+  have h_prod :
+    (∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂)) =
+      μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) :=
+    by
+    simp only [hij, Finset.prod_singleton, Finset.prod_insert, not_false_iff, Finset.mem_singleton]
+  rw [h1]
+  nth_rw 2 [h2]
+  nth_rw 4 [h2]
+  rw [← h_inter, ← h_prod, h_indep {i, j} hf_m]
+#align probability_theory.Indep_sets.indep_sets ProbabilityTheory.iIndepSets.indepSets
+
+theorem iIndep.indep {m : ι → MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
+    (h_indep : iIndep m μ) {i j : ι} (hij : i ≠ j) : Indep (m i) (m j) μ :=
   by
   change indep_sets ((fun x => measurable_set[m x]) i) ((fun x => measurable_set[m x]) j) μ
   exact Indep_sets.indep_sets h_indep hij
-#align probability_theory.Indep.indep ProbabilityTheory.Indep.indepCat
+#align probability_theory.Indep.indep ProbabilityTheory.iIndep.indep
 
-theorem IndepFun.indepFunCat {m₀ : MeasurableSpace Ω} {μ : Measure Ω} {β : ι → Type _}
-    {m : ∀ x, MeasurableSpace (β x)} {f : ∀ i, Ω → β i} (hf_Indep : IndepFun m f μ) {i j : ι}
-    (hij : i ≠ j) : IndepFunCat (f i) (f j) μ :=
+theorem iIndepFun.indepFun {m₀ : MeasurableSpace Ω} {μ : Measure Ω} {β : ι → Type _}
+    {m : ∀ x, MeasurableSpace (β x)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ) {i j : ι}
+    (hij : i ≠ j) : IndepFun (f i) (f j) μ :=
   hf_Indep.indep hij
-#align probability_theory.Indep_fun.indep_fun ProbabilityTheory.IndepFun.indepFunCat
+#align probability_theory.Indep_fun.indep_fun ProbabilityTheory.iIndepFun.indepFun
 
 end FromIndepToIndep
 
@@ -326,18 +360,20 @@ section FromMeasurableSpacesToSetsOfSets
 /-! ### Independence of measurable space structures implies independence of generating π-systems -/
 
 
-theorem Indep.indepSets [MeasurableSpace Ω] {μ : Measure Ω} {m : ι → MeasurableSpace Ω}
-    {s : ι → Set (Set Ω)} (hms : ∀ n, m n = generateFrom (s n)) (h_indep : Indep m μ) :
-    IndepSets s μ := fun S f hfs =>
+theorem iIndep.iIndepSets [MeasurableSpace Ω] {μ : Measure Ω} {m : ι → MeasurableSpace Ω}
+    {s : ι → Set (Set Ω)} (hms : ∀ n, m n = generateFrom (s n)) (h_indep : iIndep m μ) :
+    iIndepSets s μ := fun S f hfs =>
   h_indep S fun x hxS =>
     ((hms x).symm ▸ measurableSet_generateFrom (hfs x hxS) : measurable_set[m x] (f x))
-#align probability_theory.Indep.Indep_sets ProbabilityTheory.Indep.indepSets
+#align probability_theory.Indep.Indep_sets ProbabilityTheory.iIndep.iIndepSets
 
-theorem IndepCat.indepSetsCat [MeasurableSpace Ω] {μ : Measure Ω} {s1 s2 : Set (Set Ω)}
-    (h_indep : IndepCat (generateFrom s1) (generateFrom s2) μ) : IndepSetsCat s1 s2 μ :=
+#print ProbabilityTheory.Indep.indepSets /-
+theorem Indep.indepSets [MeasurableSpace Ω] {μ : Measure Ω} {s1 s2 : Set (Set Ω)}
+    (h_indep : Indep (generateFrom s1) (generateFrom s2) μ) : IndepSets s1 s2 μ :=
   fun t1 t2 ht1 ht2 =>
   h_indep t1 t2 (measurableSet_generateFrom ht1) (measurableSet_generateFrom ht2)
-#align probability_theory.indep.indep_sets ProbabilityTheory.IndepCat.indepSetsCat
+#align probability_theory.indep.indep_sets ProbabilityTheory.Indep.indepSets
+-/
 
 end FromMeasurableSpacesToSetsOfSets
 
@@ -347,9 +383,9 @@ section FromPiSystemsToMeasurableSpaces
 
 
 private theorem indep_sets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω}
-    {μ : Measure Ω} [ProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h2 : m2 ≤ m) (hp2 : IsPiSystem p2)
-    (hpm2 : m2 = generateFrom p2) (hyp : IndepSetsCat p1 p2 μ) {t1 t2 : Set Ω} (ht1 : t1 ∈ p1)
-    (ht2m : measurable_set[m2] t2) : μ (t1 ∩ t2) = μ t1 * μ t2 :=
+    {μ : Measure Ω} [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h2 : m2 ≤ m)
+    (hp2 : IsPiSystem p2) (hpm2 : m2 = generateFrom p2) (hyp : IndepSets p1 p2 μ) {t1 t2 : Set Ω}
+    (ht1 : t1 ∈ p1) (ht2m : measurable_set[m2] t2) : μ (t1 ∩ t2) = μ t1 * μ t2 :=
   by
   let μ_inter := μ.restrict t1
   let ν := μ t1 • μ
@@ -365,10 +401,11 @@ private theorem indep_sets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSp
   rw [measure.restrict_apply ht2, measure.smul_apply, Set.inter_comm]
   exact hyp t1 t ht1 ht
 
-theorem IndepSetsCat.indepCat {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {μ : Measure Ω}
-    [ProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : IsPiSystem p1)
+#print ProbabilityTheory.IndepSets.indep /-
+theorem IndepSets.indep {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {μ : Measure Ω}
+    [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : IsPiSystem p1)
     (hp2 : IsPiSystem p2) (hpm1 : m1 = generateFrom p1) (hpm2 : m2 = generateFrom p2)
-    (hyp : IndepSetsCat p1 p2 μ) : IndepCat m1 m2 μ :=
+    (hyp : IndepSets p1 p2 μ) : Indep m1 m2 μ :=
   by
   intro t1 t2 ht1 ht2
   let μ_inter := μ.restrict t2
@@ -384,63 +421,66 @@ theorem IndepSetsCat.indepCat {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace
     exact measurable_set_generate_from ht
   rw [measure.restrict_apply ht1, measure.smul_apply, smul_eq_mul, mul_comm]
   exact indep_sets.indep_aux h2 hp2 hpm2 hyp ht ht2
-#align probability_theory.indep_sets.indep ProbabilityTheory.IndepSetsCat.indepCat
+#align probability_theory.indep_sets.indep ProbabilityTheory.IndepSets.indep
+-/
 
-theorem IndepSetsCat.indep' {m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
+#print ProbabilityTheory.IndepSets.indep' /-
+theorem IndepSets.indep' {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     {p1 p2 : Set (Set Ω)} (hp1m : ∀ s ∈ p1, MeasurableSet s) (hp2m : ∀ s ∈ p2, MeasurableSet s)
-    (hp1 : IsPiSystem p1) (hp2 : IsPiSystem p2) (hyp : IndepSetsCat p1 p2 μ) :
-    IndepCat (generateFrom p1) (generateFrom p2) μ :=
+    (hp1 : IsPiSystem p1) (hp2 : IsPiSystem p2) (hyp : IndepSets p1 p2 μ) :
+    Indep (generateFrom p1) (generateFrom p2) μ :=
   hyp.indep (generateFrom_le hp1m) (generateFrom_le hp2m) hp1 hp2 rfl rfl
-#align probability_theory.indep_sets.indep' ProbabilityTheory.IndepSetsCat.indep'
+#align probability_theory.indep_sets.indep' ProbabilityTheory.IndepSets.indep'
+-/
 
 variable {m0 : MeasurableSpace Ω} {μ : Measure Ω}
 
-theorem indepSetsCat_piiUnionInter_of_disjoint [ProbabilityMeasure μ] {s : ι → Set (Set Ω)}
-    {S T : Set ι} (h_indep : IndepSets s μ) (hST : Disjoint S T) :
-    IndepSetsCat (piiUnionInter s S) (piiUnionInter s T) μ :=
+theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set (Set Ω)}
+    {S T : Set ι} (h_indep : iIndepSets s μ) (hST : Disjoint S T) :
+    IndepSets (piiUnionInter s S) (piiUnionInter s T) μ :=
   by
   rintro t1 t2 ⟨p1, hp1, f1, ht1_m, ht1_eq⟩ ⟨p2, hp2, f2, ht2_m, ht2_eq⟩
   classical
-    let g i := ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ
-    have h_P_inter : μ (t1 ∩ t2) = ∏ n in p1 ∪ p2, μ (g n) :=
+  let g i := ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ
+  have h_P_inter : μ (t1 ∩ t2) = ∏ n in p1 ∪ p2, μ (g n) :=
+    by
+    have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i :=
       by
-      have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i :=
-        by
-        intro i hi_mem_union
-        rw [Finset.mem_union] at hi_mem_union 
-        cases' hi_mem_union with hi1 hi2
-        · have hi2 : i ∉ p2 := fun hip2 => set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
-          simp_rw [g, if_pos hi1, if_neg hi2, Set.inter_univ]
-          exact ht1_m i hi1
-        · have hi1 : i ∉ p1 := fun hip1 => set.disjoint_right.mp hST (hp2 hi2) (hp1 hip1)
-          simp_rw [g, if_neg hi1, if_pos hi2, Set.univ_inter]
-          exact ht2_m i hi2
-      have h_p1_inter_p2 :
-        ((⋂ x ∈ p1, f1 x) ∩ ⋂ x ∈ p2, f2 x) =
-          ⋂ i ∈ p1 ∪ p2, ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ :=
-        by
-        ext1 x
-        simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
-        exact
-          ⟨fun h i _ => ⟨h.1 i, h.2 i⟩, fun h =>
-            ⟨fun i hi => (h i (Or.inl hi)).1 hi, fun i hi => (h i (Or.inr hi)).2 hi⟩⟩
-      rw [ht1_eq, ht2_eq, h_p1_inter_p2, ← h_indep _ hgm]
-    have h_μg : ∀ n, μ (g n) = ite (n ∈ p1) (μ (f1 n)) 1 * ite (n ∈ p2) (μ (f2 n)) 1 :=
+      intro i hi_mem_union
+      rw [Finset.mem_union] at hi_mem_union 
+      cases' hi_mem_union with hi1 hi2
+      · have hi2 : i ∉ p2 := fun hip2 => set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
+        simp_rw [g, if_pos hi1, if_neg hi2, Set.inter_univ]
+        exact ht1_m i hi1
+      · have hi1 : i ∉ p1 := fun hip1 => set.disjoint_right.mp hST (hp2 hi2) (hp1 hip1)
+        simp_rw [g, if_neg hi1, if_pos hi2, Set.univ_inter]
+        exact ht2_m i hi2
+    have h_p1_inter_p2 :
+      ((⋂ x ∈ p1, f1 x) ∩ ⋂ x ∈ p2, f2 x) =
+        ⋂ i ∈ p1 ∪ p2, ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ :=
       by
-      intro n
-      simp_rw [g]
-      split_ifs
-      · exact absurd rfl (set.disjoint_iff_forall_ne.mp hST _ (hp1 h) _ (hp2 h_1))
-      all_goals simp only [measure_univ, one_mul, mul_one, Set.inter_univ, Set.univ_inter]
-    simp_rw [h_P_inter, h_μg, Finset.prod_mul_distrib,
-      Finset.prod_ite_mem (p1 ∪ p2) p1 fun x => μ (f1 x), Finset.union_inter_cancel_left,
-      Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
-      h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
-#align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSetsCat_piiUnionInter_of_disjoint
-
-theorem IndepSet.indepCat_generateFrom_of_disjoint [ProbabilityMeasure μ] {s : ι → Set Ω}
-    (hsm : ∀ n, MeasurableSet (s n)) (hs : IndepSet s μ) (S T : Set ι) (hST : Disjoint S T) :
-    IndepCat (generateFrom { t | ∃ n ∈ S, s n = t }) (generateFrom { t | ∃ k ∈ T, s k = t }) μ :=
+      ext1 x
+      simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
+      exact
+        ⟨fun h i _ => ⟨h.1 i, h.2 i⟩, fun h =>
+          ⟨fun i hi => (h i (Or.inl hi)).1 hi, fun i hi => (h i (Or.inr hi)).2 hi⟩⟩
+    rw [ht1_eq, ht2_eq, h_p1_inter_p2, ← h_indep _ hgm]
+  have h_μg : ∀ n, μ (g n) = ite (n ∈ p1) (μ (f1 n)) 1 * ite (n ∈ p2) (μ (f2 n)) 1 :=
+    by
+    intro n
+    simp_rw [g]
+    split_ifs
+    · exact absurd rfl (set.disjoint_iff_forall_ne.mp hST _ (hp1 h) _ (hp2 h_1))
+    all_goals simp only [measure_univ, one_mul, mul_one, Set.inter_univ, Set.univ_inter]
+  simp_rw [h_P_inter, h_μg, Finset.prod_mul_distrib,
+    Finset.prod_ite_mem (p1 ∪ p2) p1 fun x => μ (f1 x), Finset.union_inter_cancel_left,
+    Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
+    h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
+#align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSets_piiUnionInter_of_disjoint
+
+theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set Ω}
+    (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (S T : Set ι) (hST : Disjoint S T) :
+    Indep (generateFrom {t | ∃ n ∈ S, s n = t}) (generateFrom {t | ∃ k ∈ T, s k = t}) μ :=
   by
   rw [← generateFrom_piiUnionInter_singleton_left, ← generateFrom_piiUnionInter_singleton_left]
   refine'
@@ -452,11 +492,11 @@ theorem IndepSet.indepCat_generateFrom_of_disjoint [ProbabilityMeasure μ] {s :
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
   · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
   · classical exact indep_sets_pi_Union_Inter_of_disjoint (Indep.Indep_sets (fun n => rfl) hs) hST
-#align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.IndepSet.indepCat_generateFrom_of_disjoint
+#align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint
 
-theorem indepCat_iSup_of_disjoint [ProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
-    (h_le : ∀ i, m i ≤ m0) (h_indep : Indep m μ) {S T : Set ι} (hST : Disjoint S T) :
-    IndepCat (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ :=
+theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
+    (h_le : ∀ i, m i ≤ m0) (h_indep : iIndep m μ) {S T : Set ι} (hST : Disjoint S T) :
+    Indep (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ :=
   by
   refine'
     indep_sets.indep (iSup₂_le fun i _ => h_le i) (iSup₂_le fun i _ => h_le i) _ _
@@ -465,18 +505,18 @@ theorem indepCat_iSup_of_disjoint [ProbabilityMeasure μ] {m : ι → Measurable
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
   · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
   · classical exact indep_sets_pi_Union_Inter_of_disjoint h_indep hST
-#align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indepCat_iSup_of_disjoint
+#align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indep_iSup_of_disjoint
 
-theorem indepCat_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
-    {μ : Measure Ω} [ProbabilityMeasure μ] (h_indep : ∀ i, IndepCat (m i) m' μ)
-    (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Directed (· ≤ ·) m) : IndepCat (⨆ i, m i) m' μ :=
+theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
+    {μ : Measure Ω} [IsProbabilityMeasure μ] (h_indep : ∀ i, Indep (m i) m' μ)
+    (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Directed (· ≤ ·) m) : Indep (⨆ i, m i) m' μ :=
   by
-  let p : ι → Set (Set Ω) := fun n => { t | measurable_set[m n] t }
+  let p : ι → Set (Set Ω) := fun n => {t | measurable_set[m n] t}
   have hp : ∀ n, IsPiSystem (p n) := fun n => @is_pi_system_measurable_set Ω (m n)
   have h_gen_n : ∀ n, m n = generate_from (p n) := fun n =>
     (@generate_from_measurable_set Ω (m n)).symm
   have hp_supr_pi : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp hm
-  let p' := { t : Set Ω | measurable_set[m'] t }
+  let p' := {t : Set Ω | measurable_set[m'] t}
   have hp'_pi : IsPiSystem p' := @is_pi_system_measurable_set Ω m'
   have h_gen' : m' = generate_from p' := (@generate_from_measurable_set Ω m').symm
   -- the π-systems defined are independent
@@ -484,116 +524,120 @@ theorem indepCat_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0
     by
     refine' indep_sets.Union _
     simp_rw [h_gen_n, h_gen'] at h_indep 
-    exact fun n => (h_indep n).IndepSetsCat
+    exact fun n => (h_indep n).IndepSets
   -- now go from π-systems to σ-algebras
   refine' indep_sets.indep (iSup_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
   exact (generate_from_Union_measurable_set _).symm
-#align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indepCat_iSup_of_directed_le
+#align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indep_iSup_of_directed_le
 
-theorem IndepSet.indepCat_generateFrom_lt [Preorder ι] [ProbabilityMeasure μ] {s : ι → Set Ω}
-    (hsm : ∀ n, MeasurableSet (s n)) (hs : IndepSet s μ) (i : ι) :
-    IndepCat (generateFrom {s i}) (generateFrom { t | ∃ j < i, s j = t }) μ :=
+theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
+    (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) :
+    Indep (generateFrom {s i}) (generateFrom {t | ∃ j < i, s j = t}) μ :=
   by
-  convert hs.indep_generate_from_of_disjoint hsm {i} { j | j < i }
+  convert
+    hs.indep_generate_from_of_disjoint hsm {i} {j | j < i}
       (set.disjoint_singleton_left.mpr (lt_irrefl _))
   simp only [Set.mem_singleton_iff, exists_prop, exists_eq_left, Set.setOf_eq_eq_singleton']
-#align probability_theory.Indep_set.indep_generate_from_lt ProbabilityTheory.IndepSet.indepCat_generateFrom_lt
+#align probability_theory.Indep_set.indep_generate_from_lt ProbabilityTheory.iIndepSet.indep_generateFrom_lt
 
-theorem IndepSet.indepCat_generateFrom_le [LinearOrder ι] [ProbabilityMeasure μ] {s : ι → Set Ω}
-    (hsm : ∀ n, MeasurableSet (s n)) (hs : IndepSet s μ) (i : ι) {k : ι} (hk : i < k) :
-    IndepCat (generateFrom {s k}) (generateFrom { t | ∃ j ≤ i, s j = t }) μ :=
+theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
+    (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) {k : ι} (hk : i < k) :
+    Indep (generateFrom {s k}) (generateFrom {t | ∃ j ≤ i, s j = t}) μ :=
   by
-  convert hs.indep_generate_from_of_disjoint hsm {k} { j | j ≤ i }
+  convert
+    hs.indep_generate_from_of_disjoint hsm {k} {j | j ≤ i}
       (set.disjoint_singleton_left.mpr hk.not_le)
   simp only [Set.mem_singleton_iff, exists_prop, exists_eq_left, Set.setOf_eq_eq_singleton']
-#align probability_theory.Indep_set.indep_generate_from_le ProbabilityTheory.IndepSet.indepCat_generateFrom_le
-
-theorem IndepSet.indepCat_generateFrom_le_nat [ProbabilityMeasure μ] {s : ℕ → Set Ω}
-    (hsm : ∀ n, MeasurableSet (s n)) (hs : IndepSet s μ) (n : ℕ) :
-    IndepCat (generateFrom {s (n + 1)}) (generateFrom { t | ∃ k ≤ n, s k = t }) μ :=
-  hs.indepCat_generateFrom_le hsm _ n.lt_succ_self
-#align probability_theory.Indep_set.indep_generate_from_le_nat ProbabilityTheory.IndepSet.indepCat_generateFrom_le_nat
-
-theorem indepCat_iSup_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
-    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
-    (h_indep : ∀ i, IndepCat (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
-    (hm : Monotone m) : IndepCat (⨆ i, m i) m' μ :=
-  indepCat_iSup_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
-#align probability_theory.indep_supr_of_monotone ProbabilityTheory.indepCat_iSup_of_monotone
-
-theorem indepCat_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
-    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
-    (h_indep : ∀ i, IndepCat (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
-    (hm : Antitone m) : IndepCat (⨆ i, m i) m' μ :=
-  indepCat_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
-#align probability_theory.indep_supr_of_antitone ProbabilityTheory.indepCat_iSup_of_antitone
-
-theorem IndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {S : Finset ι}
-    (hp_ind : IndepSets π μ) (haS : a ∉ S) : IndepSetsCat (piiUnionInter π S) (π a) μ :=
+#align probability_theory.Indep_set.indep_generate_from_le ProbabilityTheory.iIndepSet.indep_generateFrom_le
+
+theorem iIndepSet.indep_generateFrom_le_nat [IsProbabilityMeasure μ] {s : ℕ → Set Ω}
+    (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (n : ℕ) :
+    Indep (generateFrom {s (n + 1)}) (generateFrom {t | ∃ k ≤ n, s k = t}) μ :=
+  hs.indep_generateFrom_le hsm _ n.lt_succ_self
+#align probability_theory.Indep_set.indep_generate_from_le_nat ProbabilityTheory.iIndepSet.indep_generateFrom_le_nat
+
+theorem indep_iSup_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
+    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
+    (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Monotone m) :
+    Indep (⨆ i, m i) m' μ :=
+  indep_iSup_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
+#align probability_theory.indep_supr_of_monotone ProbabilityTheory.indep_iSup_of_monotone
+
+theorem indep_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
+    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
+    (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Antitone m) :
+    Indep (⨆ i, m i) m' μ :=
+  indep_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
+#align probability_theory.indep_supr_of_antitone ProbabilityTheory.indep_iSup_of_antitone
+
+theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {S : Finset ι}
+    (hp_ind : iIndepSets π μ) (haS : a ∉ S) : IndepSets (piiUnionInter π S) (π a) μ :=
   by
   rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
   rw [Finset.coe_subset] at hs_mem 
   classical
-    let f n := ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
-    have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n :=
-      by
-      intro n hn_mem_insert
-      simp_rw [f]
-      cases' finset.mem_insert.mp hn_mem_insert with hn_mem hn_mem
-      · simp [hn_mem, ht2_mem_pia]
-      · have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hn_mem)
-        simp [hn_ne_a, hn_mem, hft1_mem n hn_mem]
-    have h_f_mem_pi : ∀ n ∈ s, f n ∈ π n := fun x hxS => h_f_mem x (by simp [hxS])
-    have h_t1 : t1 = ⋂ n ∈ s, f n :=
-      by
-      suffices h_forall : ∀ n ∈ s, f n = ft1 n
-      · rw [ht1_eq]
-        congr with (n x)
-        congr with (hns y)
-        simp only [(h_forall n hns).symm]
-      intro n hnS
-      have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hnS)
-      simp_rw [f, if_pos hnS, if_neg hn_ne_a]
-    have h_μ_t1 : μ t1 = ∏ n in s, μ (f n) := by rw [h_t1, ← hp_ind s h_f_mem_pi]
-    have h_t2 : t2 = f a := by simp_rw [f]; simp
-    have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) :=
-      by
-      have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
-        rw [h_t1, h_t2, Finset.set_biInter_insert, Set.inter_comm]
-      rw [h_t1_inter_t2, ← hp_ind (insert a s) h_f_mem]
-    have has : a ∉ s := fun has_mem => haS (hs_mem Membership)
-    rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
-#align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.IndepSets.piiUnionInter_of_not_mem
-
+  let f n := ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
+  have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n :=
+    by
+    intro n hn_mem_insert
+    simp_rw [f]
+    cases' finset.mem_insert.mp hn_mem_insert with hn_mem hn_mem
+    · simp [hn_mem, ht2_mem_pia]
+    · have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hn_mem)
+      simp [hn_ne_a, hn_mem, hft1_mem n hn_mem]
+  have h_f_mem_pi : ∀ n ∈ s, f n ∈ π n := fun x hxS => h_f_mem x (by simp [hxS])
+  have h_t1 : t1 = ⋂ n ∈ s, f n :=
+    by
+    suffices h_forall : ∀ n ∈ s, f n = ft1 n
+    · rw [ht1_eq]
+      congr with (n x)
+      congr with (hns y)
+      simp only [(h_forall n hns).symm]
+    intro n hnS
+    have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hnS)
+    simp_rw [f, if_pos hnS, if_neg hn_ne_a]
+  have h_μ_t1 : μ t1 = ∏ n in s, μ (f n) := by rw [h_t1, ← hp_ind s h_f_mem_pi]
+  have h_t2 : t2 = f a := by simp_rw [f]; simp
+  have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) :=
+    by
+    have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
+      rw [h_t1, h_t2, Finset.set_biInter_insert, Set.inter_comm]
+    rw [h_t1_inter_t2, ← hp_ind (insert a s) h_f_mem]
+  have has : a ∉ s := fun has_mem => haS (hs_mem Membership)
+  rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
+#align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
+
+/- warning: probability_theory.Indep_sets.Indep clashes with probability_theory.indep_sets.indep -> ProbabilityTheory.IndepSets.indep
+Case conversion may be inaccurate. Consider using '#align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indepₓ'. -/
 /-- The measurable space structures generated by independent pi-systems are independent. -/
-theorem IndepSets.indep [ProbabilityMeasure μ] (m : ι → MeasurableSpace Ω) (h_le : ∀ i, m i ≤ m0)
+theorem IndepSets.indep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω) (h_le : ∀ i, m i ≤ m0)
     (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
-    (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : IndepSets π μ) : Indep m μ := by
+    (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) : iIndep m μ := by
   classical
-    refine' Finset.induction _ _
-    ·
-      simp only [measure_univ, imp_true_iff, Set.iInter_false, Set.iInter_univ, Finset.prod_empty,
-        eq_self_iff_true]
-    intro a S ha_notin_S h_rec f hf_m
-    have hf_m_S : ∀ x ∈ S, measurable_set[m x] (f x) := fun x hx => hf_m x (by simp [hx])
-    rw [Finset.set_biInter_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
-    let p := piiUnionInter π S
-    set m_p := generate_from p with hS_eq_generate
-    have h_indep : indep m_p (m a) μ :=
-      by
-      have hp : IsPiSystem p := isPiSystem_piiUnionInter π h_pi S
-      have h_le' : ∀ i, generate_from (π i) ≤ m0 := fun i => (h_generate i).symm.trans_le (h_le i)
-      have hm_p : m_p ≤ m0 := generateFrom_piiUnionInter_le π h_le' S
-      exact
-        indep_sets.indep hm_p (h_le a) hp (h_pi a) hS_eq_generate (h_generate a)
-          (h_ind.pi_Union_Inter_of_not_mem ha_notin_S)
-    refine' h_indep.symm (f a) (⋂ n ∈ S, f n) (hf_m a (Finset.mem_insert_self a S)) _
-    have h_le_p : ∀ i ∈ S, m i ≤ m_p := by
-      intro n hn
-      rw [hS_eq_generate, h_generate n]
-      exact le_generateFrom_piiUnionInter S hn
-    have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
-    exact S.measurable_set_bInter h_S_f
+  refine' Finset.induction _ _
+  ·
+    simp only [measure_univ, imp_true_iff, Set.iInter_false, Set.iInter_univ, Finset.prod_empty,
+      eq_self_iff_true]
+  intro a S ha_notin_S h_rec f hf_m
+  have hf_m_S : ∀ x ∈ S, measurable_set[m x] (f x) := fun x hx => hf_m x (by simp [hx])
+  rw [Finset.set_biInter_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
+  let p := piiUnionInter π S
+  set m_p := generate_from p with hS_eq_generate
+  have h_indep : indep m_p (m a) μ :=
+    by
+    have hp : IsPiSystem p := isPiSystem_piiUnionInter π h_pi S
+    have h_le' : ∀ i, generate_from (π i) ≤ m0 := fun i => (h_generate i).symm.trans_le (h_le i)
+    have hm_p : m_p ≤ m0 := generateFrom_piiUnionInter_le π h_le' S
+    exact
+      indep_sets.indep hm_p (h_le a) hp (h_pi a) hS_eq_generate (h_generate a)
+        (h_ind.pi_Union_Inter_of_not_mem ha_notin_S)
+  refine' h_indep.symm (f a) (⋂ n ∈ S, f n) (hf_m a (Finset.mem_insert_self a S)) _
+  have h_le_p : ∀ i ∈ S, m i ≤ m_p := by
+    intro n hn
+    rw [hS_eq_generate, h_generate n]
+    exact le_generateFrom_piiUnionInter S hn
+  have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
+  exact S.measurable_set_bInter h_S_f
 #align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indep
 
 end FromPiSystemsToMeasurableSpaces
@@ -610,31 +654,36 @@ We prove the following equivalences on `indep_set`, for measurable sets `s, t`.
 
 variable {s t : Set Ω} (S T : Set (Set Ω))
 
-theorem indepSetCat_iff_indepSetsCat_singleton {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
+#print ProbabilityTheory.indepSet_iff_indepSets_singleton /-
+theorem indepSet_iff_indepSets_singleton {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume)
-    [ProbabilityMeasure μ] : IndepSetCat s t μ ↔ IndepSetsCat {s} {t} μ :=
-  ⟨IndepCat.indepSetsCat, fun h =>
-    IndepSetsCat.indepCat (generateFrom_le fun u hu => by rwa [set.mem_singleton_iff.mp hu])
+    [IsProbabilityMeasure μ] : IndepSet s t μ ↔ IndepSets {s} {t} μ :=
+  ⟨Indep.indepSets, fun h =>
+    IndepSets.indep (generateFrom_le fun u hu => by rwa [set.mem_singleton_iff.mp hu])
       (generateFrom_le fun u hu => by rwa [set.mem_singleton_iff.mp hu]) (IsPiSystem.singleton s)
       (IsPiSystem.singleton t) rfl rfl h⟩
-#align probability_theory.indep_set_iff_indep_sets_singleton ProbabilityTheory.indepSetCat_iff_indepSetsCat_singleton
+#align probability_theory.indep_set_iff_indep_sets_singleton ProbabilityTheory.indepSet_iff_indepSets_singleton
+-/
 
-theorem indepSetCat_iff_measure_inter_eq_mul {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
+theorem indepSet_iff_measure_inter_eq_mul {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume)
-    [ProbabilityMeasure μ] : IndepSetCat s t μ ↔ μ (s ∩ t) = μ s * μ t :=
-  (indepSetCat_iff_indepSetsCat_singleton hs_meas ht_meas μ).trans indepSetsCat_singleton_iff
-#align probability_theory.indep_set_iff_measure_inter_eq_mul ProbabilityTheory.indepSetCat_iff_measure_inter_eq_mul
+    [IsProbabilityMeasure μ] : IndepSet s t μ ↔ μ (s ∩ t) = μ s * μ t :=
+  (indepSet_iff_indepSets_singleton hs_meas ht_meas μ).trans indepSets_singleton_iff
+#align probability_theory.indep_set_iff_measure_inter_eq_mul ProbabilityTheory.indepSet_iff_measure_inter_eq_mul
 
-theorem IndepSetsCat.indepSetCat_of_mem {m0 : MeasurableSpace Ω} (hs : s ∈ S) (ht : t ∈ T)
+#print ProbabilityTheory.IndepSets.indepSet_of_mem /-
+theorem IndepSets.indepSet_of_mem {m0 : MeasurableSpace Ω} (hs : s ∈ S) (ht : t ∈ T)
     (hs_meas : MeasurableSet s) (ht_meas : MeasurableSet t)
-    (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) [ProbabilityMeasure μ]
-    (h_indep : IndepSetsCat S T μ) : IndepSetCat s t μ :=
-  (indepSetCat_iff_measure_inter_eq_mul hs_meas ht_meas μ).mpr (h_indep s t hs ht)
-#align probability_theory.indep_sets.indep_set_of_mem ProbabilityTheory.IndepSetsCat.indepSetCat_of_mem
-
-theorem IndepCat.indepSetCat_of_measurableSet {m₁ m₂ m0 : MeasurableSpace Ω} {μ : Measure Ω}
-    (h_indep : IndepCat m₁ m₂ μ) {s t : Set Ω} (hs : measurable_set[m₁] s)
-    (ht : measurable_set[m₂] t) : IndepSetCat s t μ :=
+    (μ : Measure Ω := by exact MeasureTheory.MeasureSpace.volume) [IsProbabilityMeasure μ]
+    (h_indep : IndepSets S T μ) : IndepSet s t μ :=
+  (indepSet_iff_measure_inter_eq_mul hs_meas ht_meas μ).mpr (h_indep s t hs ht)
+#align probability_theory.indep_sets.indep_set_of_mem ProbabilityTheory.IndepSets.indepSet_of_mem
+-/
+
+#print ProbabilityTheory.Indep.indepSet_of_measurableSet /-
+theorem Indep.indepSet_of_measurableSet {m₁ m₂ m0 : MeasurableSpace Ω} {μ : Measure Ω}
+    (h_indep : Indep m₁ m₂ μ) {s t : Set Ω} (hs : measurable_set[m₁] s)
+    (ht : measurable_set[m₂] t) : IndepSet s t μ :=
   by
   refine' fun s' t' hs' ht' => h_indep s' t' _ _
   · refine' generate_from_induction (fun u => measurable_set[m₁] u) {s} _ _ _ _ hs'
@@ -647,15 +696,18 @@ theorem IndepCat.indepSetCat_of_measurableSet {m₁ m₂ m0 : MeasurableSpace Ω
     · exact @MeasurableSet.empty _ m₂
     · exact fun u hu => hu.compl
     · exact fun f hf => MeasurableSet.iUnion hf
-#align probability_theory.indep.indep_set_of_measurable_set ProbabilityTheory.IndepCat.indepSetCat_of_measurableSet
+#align probability_theory.indep.indep_set_of_measurable_set ProbabilityTheory.Indep.indepSet_of_measurableSet
+-/
 
-theorem indepCat_iff_forall_indepSetCat (m₁ m₂ : MeasurableSpace Ω) {m0 : MeasurableSpace Ω}
+#print ProbabilityTheory.indep_iff_forall_indepSet /-
+theorem indep_iff_forall_indepSet (m₁ m₂ : MeasurableSpace Ω) {m0 : MeasurableSpace Ω}
     (μ : Measure Ω) :
-    IndepCat m₁ m₂ μ ↔ ∀ s t, measurable_set[m₁] s → measurable_set[m₂] t → IndepSetCat s t μ :=
-  ⟨fun h => fun s t hs ht => h.indepSetCat_of_measurableSet hs ht, fun h s t hs ht =>
+    Indep m₁ m₂ μ ↔ ∀ s t, measurable_set[m₁] s → measurable_set[m₂] t → IndepSet s t μ :=
+  ⟨fun h => fun s t hs ht => h.indepSet_of_measurableSet hs ht, fun h s t hs ht =>
     h s t hs ht s t (measurableSet_generateFrom (Set.mem_singleton s))
       (measurableSet_generateFrom (Set.mem_singleton t))⟩
-#align probability_theory.indep_iff_forall_indep_set ProbabilityTheory.indepCat_iff_forall_indepSetCat
+#align probability_theory.indep_iff_forall_indep_set ProbabilityTheory.indep_iff_forall_indepSet
+-/
 
 end IndepSet
 
@@ -668,104 +720,106 @@ section IndepFun
 
 variable {β β' γ γ' : Type _} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {f : Ω → β} {g : Ω → β'}
 
-theorem indepFunCat_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
+theorem indepFun_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
     {mβ' : MeasurableSpace β'} :
-    IndepFunCat f g μ ↔
+    IndepFun f g μ ↔
       ∀ s t,
         MeasurableSet s → MeasurableSet t → μ (f ⁻¹' s ∩ g ⁻¹' t) = μ (f ⁻¹' s) * μ (g ⁻¹' t) :=
   by
   constructor <;> intro h
   · refine' fun s t hs ht => h (f ⁻¹' s) (g ⁻¹' t) ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩
   · rintro _ _ ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩; exact h s t hs ht
-#align probability_theory.indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFunCat_iff_measure_inter_preimage_eq_mul
+#align probability_theory.indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFun_iff_measure_inter_preimage_eq_mul
 
-theorem indepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Type _}
+theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Type _}
     (m : ∀ x, MeasurableSpace (β x)) (f : ∀ i, Ω → β i) :
-    IndepFun m f μ ↔
+    iIndepFun m f μ ↔
       ∀ (S : Finset ι) {sets : ∀ i : ι, Set (β i)} (H : ∀ i, i ∈ S → measurable_set[m i] (sets i)),
         μ (⋂ i ∈ S, f i ⁻¹' sets i) = ∏ i in S, μ (f i ⁻¹' sets i) :=
   by
   refine' ⟨fun h S sets h_meas => h _ fun i hi_mem => ⟨sets i, h_meas i hi_mem, rfl⟩, _⟩
   intro h S setsΩ h_meas
   classical
-    let setsβ : ∀ i : ι, Set (β i) := fun i =>
-      dite (i ∈ S) (fun hi_mem => (h_meas i hi_mem).some) fun _ => Set.univ
-    have h_measβ : ∀ i ∈ S, measurable_set[m i] (setsβ i) :=
-      by
-      intro i hi_mem
-      simp_rw [setsβ, dif_pos hi_mem]
-      exact (h_meas i hi_mem).choose_spec.1
-    have h_preim : ∀ i ∈ S, setsΩ i = f i ⁻¹' setsβ i :=
-      by
-      intro i hi_mem
-      simp_rw [setsβ, dif_pos hi_mem]
-      exact (h_meas i hi_mem).choose_spec.2.symm
-    have h_left_eq : μ (⋂ i ∈ S, setsΩ i) = μ (⋂ i ∈ S, f i ⁻¹' setsβ i) :=
-      by
-      congr with (i x)
-      simp only [Set.mem_iInter]
-      constructor <;> intro h hi_mem <;> specialize h hi_mem
-      · rwa [h_preim i hi_mem] at h 
-      · rwa [h_preim i hi_mem]
-    have h_right_eq : (∏ i in S, μ (setsΩ i)) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
-      by
-      refine' Finset.prod_congr rfl fun i hi_mem => _
-      rw [h_preim i hi_mem]
-    rw [h_left_eq, h_right_eq]
-    exact h S h_measβ
-#align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFun_iff_measure_inter_preimage_eq_mul
-
-theorem indepFunCat_iff_indepSetCat_preimage {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
-    [ProbabilityMeasure μ] (hf : Measurable f) (hg : Measurable g) :
-    IndepFunCat f g μ ↔
-      ∀ s t, MeasurableSet s → MeasurableSet t → IndepSetCat (f ⁻¹' s) (g ⁻¹' t) μ :=
+  let setsβ : ∀ i : ι, Set (β i) := fun i =>
+    dite (i ∈ S) (fun hi_mem => (h_meas i hi_mem).some) fun _ => Set.univ
+  have h_measβ : ∀ i ∈ S, measurable_set[m i] (setsβ i) :=
+    by
+    intro i hi_mem
+    simp_rw [setsβ, dif_pos hi_mem]
+    exact (h_meas i hi_mem).choose_spec.1
+  have h_preim : ∀ i ∈ S, setsΩ i = f i ⁻¹' setsβ i :=
+    by
+    intro i hi_mem
+    simp_rw [setsβ, dif_pos hi_mem]
+    exact (h_meas i hi_mem).choose_spec.2.symm
+  have h_left_eq : μ (⋂ i ∈ S, setsΩ i) = μ (⋂ i ∈ S, f i ⁻¹' setsβ i) :=
+    by
+    congr with (i x)
+    simp only [Set.mem_iInter]
+    constructor <;> intro h hi_mem <;> specialize h hi_mem
+    · rwa [h_preim i hi_mem] at h 
+    · rwa [h_preim i hi_mem]
+  have h_right_eq : (∏ i in S, μ (setsΩ i)) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
+    by
+    refine' Finset.prod_congr rfl fun i hi_mem => _
+    rw [h_preim i hi_mem]
+  rw [h_left_eq, h_right_eq]
+  exact h S h_measβ
+#align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul
+
+theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
+    [IsProbabilityMeasure μ] (hf : Measurable f) (hg : Measurable g) :
+    IndepFun f g μ ↔ ∀ s t, MeasurableSet s → MeasurableSet t → IndepSet (f ⁻¹' s) (g ⁻¹' t) μ :=
   by
   refine' indep_fun_iff_measure_inter_preimage_eq_mul.trans _
   constructor <;> intro h s t hs ht <;> specialize h s t hs ht
   · rwa [indep_set_iff_measure_inter_eq_mul (hf hs) (hg ht) μ]
   · rwa [← indep_set_iff_measure_inter_eq_mul (hf hs) (hg ht) μ]
-#align probability_theory.indep_fun_iff_indep_set_preimage ProbabilityTheory.indepFunCat_iff_indepSetCat_preimage
+#align probability_theory.indep_fun_iff_indep_set_preimage ProbabilityTheory.indepFun_iff_indepSet_preimage
 
+#print ProbabilityTheory.IndepFun.symm /-
 @[symm]
-theorem IndepFunCat.symm {mβ : MeasurableSpace β} {f g : Ω → β} (hfg : IndepFunCat f g μ) :
-    IndepFunCat g f μ :=
+theorem IndepFun.symm {mβ : MeasurableSpace β} {f g : Ω → β} (hfg : IndepFun f g μ) :
+    IndepFun g f μ :=
   hfg.symm
-#align probability_theory.indep_fun.symm ProbabilityTheory.IndepFunCat.symm
+#align probability_theory.indep_fun.symm ProbabilityTheory.IndepFun.symm
+-/
 
-theorem IndepFunCat.ae_eq {mβ : MeasurableSpace β} {f g f' g' : Ω → β} (hfg : IndepFunCat f g μ)
-    (hf : f =ᵐ[μ] f') (hg : g =ᵐ[μ] g') : IndepFunCat f' g' μ :=
+#print ProbabilityTheory.IndepFun.ae_eq /-
+theorem IndepFun.ae_eq {mβ : MeasurableSpace β} {f g f' g' : Ω → β} (hfg : IndepFun f g μ)
+    (hf : f =ᵐ[μ] f') (hg : g =ᵐ[μ] g') : IndepFun f' g' μ :=
   by
   rintro _ _ ⟨A, hA, rfl⟩ ⟨B, hB, rfl⟩
   have h1 : f ⁻¹' A =ᵐ[μ] f' ⁻¹' A := hf.fun_comp A
   have h2 : g ⁻¹' B =ᵐ[μ] g' ⁻¹' B := hg.fun_comp B
   rw [← measure_congr h1, ← measure_congr h2, ← measure_congr (h1.inter h2)]
   exact hfg _ _ ⟨_, hA, rfl⟩ ⟨_, hB, rfl⟩
-#align probability_theory.indep_fun.ae_eq ProbabilityTheory.IndepFunCat.ae_eq
+#align probability_theory.indep_fun.ae_eq ProbabilityTheory.IndepFun.ae_eq
+-/
 
-theorem IndepFunCat.comp {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
-    {mγ : MeasurableSpace γ} {mγ' : MeasurableSpace γ'} {φ : β → γ} {ψ : β' → γ'}
-    (hfg : IndepFunCat f g μ) (hφ : Measurable φ) (hψ : Measurable ψ) :
-    IndepFunCat (φ ∘ f) (ψ ∘ g) μ :=
+theorem IndepFun.comp {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'} {mγ : MeasurableSpace γ}
+    {mγ' : MeasurableSpace γ'} {φ : β → γ} {ψ : β' → γ'} (hfg : IndepFun f g μ) (hφ : Measurable φ)
+    (hψ : Measurable ψ) : IndepFun (φ ∘ f) (ψ ∘ g) μ :=
   by
   rintro _ _ ⟨A, hA, rfl⟩ ⟨B, hB, rfl⟩
   apply hfg
   · exact ⟨φ ⁻¹' A, hφ hA, set.preimage_comp.symm⟩
   · exact ⟨ψ ⁻¹' B, hψ hB, set.preimage_comp.symm⟩
-#align probability_theory.indep_fun.comp ProbabilityTheory.IndepFunCat.comp
+#align probability_theory.indep_fun.comp ProbabilityTheory.IndepFun.comp
 
 /-- If `f` is a family of mutually independent random variables (`Indep_fun 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 IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (S T : Finset ι) (hST : Disjoint S T)
-    (hf_Indep : IndepFun m f μ) (hf_meas : ∀ i, Measurable (f i)) :
-    IndepFunCat (fun a (i : S) => f i a) (fun a (i : T) => f i a) μ :=
+    (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, build from the π-system of boxes which generates `measurable_space.pi`.
   let πSβ :=
     Set.pi (Set.univ : Set S) ''
-      Set.pi (Set.univ : Set S) fun i => { s : Set (β i) | measurable_set[m i] s }
-  let πS := { s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s }
+      Set.pi (Set.univ : Set S) fun i => {s : Set (β i) | measurable_set[m i] s}
+  let πS := {s : Set Ω | ∃ t ∈ πSβ, (fun a (i : S) => f i a) ⁻¹' t = s}
   have hπS_pi : IsPiSystem πS := is_pi_system_pi.comap fun a i => f i a
   have hπS_gen : (measurable_space.pi.comap fun a (i : S) => f i a) = generate_from πS :=
     by
@@ -775,8 +829,8 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
     · infer_instance
   let πTβ :=
     Set.pi (Set.univ : Set T) ''
-      Set.pi (Set.univ : Set T) fun i => { s : Set (β i) | measurable_set[m i] s }
-  let πT := { s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s }
+      Set.pi (Set.univ : Set T) fun i => {s : Set (β i) | measurable_set[m i] s}
+  let πT := {s : Set Ω | ∃ t ∈ πTβ, (fun a (i : T) => f i a) ⁻¹' t = s}
   have hπT_pi : IsPiSystem πT := is_pi_system_pi.comap fun a i => f i a
   have hπT_gen : (measurable_space.pi.comap fun a (i : T) => f i a) = generate_from πT :=
     by
@@ -793,168 +847,168 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
   simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1 
   rw [← hs2, ← ht2]
   classical
-    let sets_s' : ∀ i : ι, Set (β i) := fun i =>
-      dite (i ∈ S) (fun hi => sets_s ⟨i, hi⟩) fun _ => Set.univ
-    have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ := by intro i hi;
-      simp_rw [sets_s', dif_pos hi]
-    have h_sets_s'_univ : ∀ {i} (hi : i ∈ T), sets_s' i = Set.univ := by intro i hi;
-      simp_rw [sets_s', dif_neg (finset.disjoint_right.mp hST hi)]
-    let sets_t' : ∀ i : ι, Set (β i) := fun i =>
-      dite (i ∈ T) (fun hi => sets_t ⟨i, hi⟩) fun _ => Set.univ
-    have h_sets_t'_univ : ∀ {i} (hi : i ∈ S), sets_t' i = Set.univ := by intro i hi;
-      simp_rw [sets_t', dif_neg (finset.disjoint_left.mp hST hi)]
-    have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) := by intro i hi; rw [h_sets_s'_eq hi];
-      exact hs1 _
-    have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) := by intro i hi;
-      simp_rw [sets_t', dif_pos hi]; exact ht1 _
-    have h_eq_inter_S :
-      (fun (ω : Ω) (i : ↥S) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i :=
-      by
-      ext1 x
-      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
-      constructor <;> intro h
-      · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h ; exact h
-    have h_eq_inter_T :
-      (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
-      by
-      ext1 x
-      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
-      constructor <;> intro h
-      · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h ; exact h
-    rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep 
-    rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
-    have h_Inter_inter :
-      ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
-        ⋂ i ∈ S ∪ T, f i ⁻¹' (sets_s' i ∩ sets_t' i) :=
-      by
-      ext1 x
-      simp only [Set.mem_inter_iff, Set.mem_iInter, Set.mem_preimage, Finset.mem_union]
-      constructor <;> intro h
-      · intro i hi
-        cases hi
-        · rw [h_sets_t'_univ hi]; exact ⟨h.1 i hi, Set.mem_univ _⟩
-        · rw [h_sets_s'_univ hi]; exact ⟨Set.mem_univ _, h.2 i hi⟩
-      · exact ⟨fun i hi => (h i (Or.inl hi)).1, fun i hi => (h i (Or.inr hi)).2⟩
-    rw [h_Inter_inter, hf_Indep (S ∪ T)]
-    swap
-    · intro i hi_mem
-      rw [Finset.mem_union] at hi_mem 
-      cases hi_mem
-      · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
-      · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
-    rw [Finset.prod_union hST]
-    congr 1
-    · refine' Finset.prod_congr rfl fun i hi => _
-      rw [h_sets_t'_univ hi, Set.inter_univ]
-    · refine' Finset.prod_congr rfl fun i hi => _
-      rw [h_sets_s'_univ hi, Set.univ_inter]
-#align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.IndepFun.indepFunCat_finset
-
-theorem IndepFun.indepFunCat_prod [ProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
-    {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : IndepFun m f μ)
+  let sets_s' : ∀ i : ι, Set (β i) := fun i =>
+    dite (i ∈ S) (fun hi => sets_s ⟨i, hi⟩) fun _ => Set.univ
+  have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ := by intro i hi;
+    simp_rw [sets_s', dif_pos hi]
+  have h_sets_s'_univ : ∀ {i} (hi : i ∈ T), sets_s' i = Set.univ := by intro i hi;
+    simp_rw [sets_s', dif_neg (finset.disjoint_right.mp hST hi)]
+  let sets_t' : ∀ i : ι, Set (β i) := fun i =>
+    dite (i ∈ T) (fun hi => sets_t ⟨i, hi⟩) fun _ => Set.univ
+  have h_sets_t'_univ : ∀ {i} (hi : i ∈ S), sets_t' i = Set.univ := by intro i hi;
+    simp_rw [sets_t', dif_neg (finset.disjoint_left.mp hST hi)]
+  have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) := by intro i hi; rw [h_sets_s'_eq hi];
+    exact hs1 _
+  have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) := by intro i hi;
+    simp_rw [sets_t', dif_pos hi]; exact ht1 _
+  have h_eq_inter_S :
+    (fun (ω : Ω) (i : ↥S) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i :=
+    by
+    ext1 x
+    simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
+    constructor <;> intro h
+    · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
+    · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h ; exact h
+  have h_eq_inter_T :
+    (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
+    by
+    ext1 x
+    simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
+    constructor <;> intro h
+    · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
+    · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h ; exact h
+  rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep 
+  rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
+  have h_Inter_inter :
+    ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
+      ⋂ i ∈ S ∪ T, f i ⁻¹' (sets_s' i ∩ sets_t' i) :=
+    by
+    ext1 x
+    simp only [Set.mem_inter_iff, Set.mem_iInter, Set.mem_preimage, Finset.mem_union]
+    constructor <;> intro h
+    · intro i hi
+      cases hi
+      · rw [h_sets_t'_univ hi]; exact ⟨h.1 i hi, Set.mem_univ _⟩
+      · rw [h_sets_s'_univ hi]; exact ⟨Set.mem_univ _, h.2 i hi⟩
+    · exact ⟨fun i hi => (h i (Or.inl hi)).1, fun i hi => (h i (Or.inr hi)).2⟩
+  rw [h_Inter_inter, hf_Indep (S ∪ T)]
+  swap
+  · intro i hi_mem
+    rw [Finset.mem_union] at hi_mem 
+    cases hi_mem
+    · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
+    · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
+  rw [Finset.prod_union hST]
+  congr 1
+  · refine' Finset.prod_congr rfl fun i hi => _
+    rw [h_sets_t'_univ hi, Set.inter_univ]
+  · refine' Finset.prod_congr rfl fun i hi => _
+    rw [h_sets_s'_univ hi, Set.univ_inter]
+#align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
+
+theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+    {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFunCat (fun a => (f i a, f j a)) (f k) μ := by
+    IndepFun (fun a => (f i a, f j a)) (f k) μ := by
   classical
-    have h_right :
-      f k =
-        (fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩) ∘
-          fun a (j : ({k} : Finset ι)) => f j a :=
-      rfl
-    have h_meas_right :
-      Measurable fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩ :=
-      measurable_pi_apply ⟨k, Finset.mem_singleton_self k⟩
-    let s : Finset ι := {i, j}
-    have h_left :
-      (fun ω => (f i ω, f j ω)) =
-        (fun p : ∀ l : s, β l =>
-            (p ⟨i, Finset.mem_insert_self i _⟩,
-              p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩)) ∘
-          fun a (j : s) => f j a :=
-      by
-      ext1 a
-      simp only [Prod.mk.inj_iff]
-      constructor <;> rfl
-    have h_meas_left :
-      Measurable fun p : ∀ l : s, β l =>
-        (p ⟨i, Finset.mem_insert_self i _⟩,
-          p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩) :=
-      Measurable.prod (measurable_pi_apply ⟨i, Finset.mem_insert_self i {j}⟩)
-        (measurable_pi_apply ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self j)⟩)
-    rw [h_left, h_right]
-    refine' (hf_Indep.indep_fun_finset s {k} _ hf_meas).comp h_meas_left h_meas_right
-    rw [Finset.disjoint_singleton_right]
-    simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
-    exact ⟨hik.symm, hjk.symm⟩
-#align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.IndepFun.indepFunCat_prod
+  have h_right :
+    f k =
+      (fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩) ∘
+        fun a (j : ({k} : Finset ι)) => f j a :=
+    rfl
+  have h_meas_right :
+    Measurable fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩ :=
+    measurable_pi_apply ⟨k, Finset.mem_singleton_self k⟩
+  let s : Finset ι := {i, j}
+  have h_left :
+    (fun ω => (f i ω, f j ω)) =
+      (fun p : ∀ l : s, β l =>
+          (p ⟨i, Finset.mem_insert_self i _⟩,
+            p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩)) ∘
+        fun a (j : s) => f j a :=
+    by
+    ext1 a
+    simp only [Prod.mk.inj_iff]
+    constructor <;> rfl
+  have h_meas_left :
+    Measurable fun p : ∀ l : s, β l =>
+      (p ⟨i, Finset.mem_insert_self i _⟩,
+        p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩) :=
+    Measurable.prod (measurable_pi_apply ⟨i, Finset.mem_insert_self i {j}⟩)
+      (measurable_pi_apply ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self j)⟩)
+  rw [h_left, h_right]
+  refine' (hf_Indep.indep_fun_finset s {k} _ hf_meas).comp h_meas_left h_meas_right
+  rw [Finset.disjoint_singleton_right]
+  simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
+  exact ⟨hik.symm, hjk.symm⟩
+#align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
 
 @[to_additive]
-theorem IndepFun.mul [ProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
-    [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : IndepFun (fun _ => m) f μ)
+theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
+    [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFunCat (f i * f j) (f k) μ :=
+    IndepFun (f i * f j) (f k) μ :=
   by
   have : indep_fun (fun ω => (f i ω, f j ω)) (f k) μ :=
     hf_Indep.indep_fun_prod hf_meas i j k hik hjk
   change indep_fun ((fun p : β × β => p.fst * p.snd) ∘ fun ω => (f i ω, f j ω)) (id ∘ f k) μ
   exact indep_fun.comp this (measurable_fst.mul measurable_snd) measurable_id
-#align probability_theory.Indep_fun.mul ProbabilityTheory.IndepFun.mul
-#align probability_theory.Indep_fun.add ProbabilityTheory.IndepFun.add
+#align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.mul
+#align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.add
 
 @[to_additive]
-theorem IndepFun.indepFunCat_finset_prod_of_not_mem [ProbabilityMeasure μ] {ι : Type _} {β : Type _}
+theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
-    (hf_Indep : IndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
-    (hi : i ∉ s) : IndepFunCat (∏ j in s, f j) (f i) μ := by
+    (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
+    (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by
   classical
-    have h_right :
-      f i =
-        (fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩) ∘
-          fun a (j : ({i} : Finset ι)) => f j a :=
-      rfl
-    have h_meas_right :
-      Measurable fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩ :=
-      measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
-    have h_left : (∏ j in s, f j) = (fun p : ∀ j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a :=
-      by
-      ext1 a
-      simp only [Function.comp_apply]
-      have : (∏ j : ↥s, f (↑j) a) = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
-      rw [this, Finset.prod_coe_sort]
-    have h_meas_left : Measurable fun p : ∀ j : s, β => ∏ j, p j :=
-      finset.univ.measurable_prod fun (j : ↥s) (H : j ∈ Finset.univ) => measurable_pi_apply j
-    rw [h_left, h_right]
-    exact
-      (hf_Indep.indep_fun_finset s {i} (finset.disjoint_singleton_left.mpr hi).symm hf_meas).comp
-        h_meas_left h_meas_right
-#align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.IndepFun.indepFunCat_finset_prod_of_not_mem
-#align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.IndepFun.indepFunCat_finset_sum_of_not_mem
+  have h_right :
+    f i =
+      (fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩) ∘
+        fun a (j : ({i} : Finset ι)) => f j a :=
+    rfl
+  have h_meas_right :
+    Measurable fun p : ∀ j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩ :=
+    measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
+  have h_left : (∏ j in s, f j) = (fun p : ∀ j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a :=
+    by
+    ext1 a
+    simp only [Function.comp_apply]
+    have : (∏ j : ↥s, f (↑j) a) = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
+    rw [this, Finset.prod_coe_sort]
+  have h_meas_left : Measurable fun p : ∀ j : s, β => ∏ j, p j :=
+    finset.univ.measurable_prod fun (j : ↥s) (H : j ∈ Finset.univ) => measurable_pi_apply j
+  rw [h_left, h_right]
+  exact
+    (hf_Indep.indep_fun_finset s {i} (finset.disjoint_singleton_left.mpr hi).symm hf_meas).comp
+      h_meas_left h_meas_right
+#align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem
+#align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
 
 @[to_additive]
-theorem IndepFun.indepFunCat_prod_range_succ [ProbabilityMeasure μ] {β : Type _}
+theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ℕ → Ω → β}
-    (hf_Indep : IndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) :
-    IndepFunCat (∏ j in Finset.range n, f j) (f n) μ :=
-  hf_Indep.indepFunCat_finset_prod_of_not_mem hf_meas Finset.not_mem_range_self
-#align probability_theory.Indep_fun.indep_fun_prod_range_succ ProbabilityTheory.IndepFun.indepFunCat_prod_range_succ
-#align probability_theory.Indep_fun.indep_fun_sum_range_succ ProbabilityTheory.IndepFun.indepFunCat_sum_range_succ
-
-theorem IndepSet.indepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
-    (hs : IndepSet s μ) : IndepFun (fun n => m) (fun n => (s n).indicator fun ω => 1) μ := by
+    (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) :
+    IndepFun (∏ j in Finset.range n, f j) (f n) μ :=
+  hf_Indep.indepFun_finset_prod_of_not_mem hf_meas Finset.not_mem_range_self
+#align probability_theory.Indep_fun.indep_fun_prod_range_succ ProbabilityTheory.iIndepFun.indepFun_prod_range_succ
+#align probability_theory.Indep_fun.indep_fun_sum_range_succ ProbabilityTheory.iIndepFun.indepFun_sum_range_succ
+
+theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
+    (hs : iIndepSet s μ) : iIndepFun (fun n => m) (fun n => (s n).indicator fun ω => 1) μ := by
   classical
-    rw [Indep_fun_iff_measure_inter_preimage_eq_mul]
-    rintro S π hπ
-    simp_rw [Set.indicator_const_preimage_eq_union]
-    refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s iᶜ) ∅) fun i hi => _
-    have hsi : measurable_set[generate_from {s i}] (s i) :=
-      measurable_set_generate_from (Set.mem_singleton _)
-    refine'
-      MeasurableSet.union (MeasurableSet.ite' (fun _ => hsi) fun _ => _)
-        (MeasurableSet.ite' (fun _ => hsi.compl) fun _ => _)
-    · exact @MeasurableSet.empty _ (generate_from {s i})
-    · exact @MeasurableSet.empty _ (generate_from {s i})
-#align probability_theory.Indep_set.Indep_fun_indicator ProbabilityTheory.IndepSet.indepFun_indicator
+  rw [Indep_fun_iff_measure_inter_preimage_eq_mul]
+  rintro S π hπ
+  simp_rw [Set.indicator_const_preimage_eq_union]
+  refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s iᶜ) ∅) fun i hi => _
+  have hsi : measurable_set[generate_from {s i}] (s i) :=
+    measurable_set_generate_from (Set.mem_singleton _)
+  refine'
+    MeasurableSet.union (MeasurableSet.ite' (fun _ => hsi) fun _ => _)
+      (MeasurableSet.ite' (fun _ => hsi.compl) fun _ => _)
+  · exact @MeasurableSet.empty _ (generate_from {s i})
+  · exact @MeasurableSet.empty _ (generate_from {s i})
+#align probability_theory.Indep_set.Indep_fun_indicator ProbabilityTheory.iIndepSet.iIndepFun_indicator
 
 end IndepFun
 
Diff
@@ -163,7 +163,7 @@ theorem indepCat_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {
     [ProbabilityMeasure μ] : IndepCat m' ⊥ μ :=
   by
   intro s t hs ht
-  rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht
+  rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht 
   cases ht
   · rw [ht, Set.inter_empty, measure_empty, MulZeroClass.mul_zero]
   · rw [ht, Set.inter_univ, measure_univ, mul_one]
@@ -226,7 +226,7 @@ theorem IndepSetsCat.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' :
     {μ : Measure Ω} (hyp : ∀ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋃ n, s n) s' μ :=
   by
   intro t1 t2 ht1 ht2
-  rw [Set.mem_iUnion] at ht1
+  rw [Set.mem_iUnion] at ht1 
   cases' ht1 with n ht1
   exact hyp n t1 t2 ht1 ht2
 #align probability_theory.indep_sets.Union ProbabilityTheory.IndepSetsCat.iUnion
@@ -235,7 +235,7 @@ theorem IndepSetsCat.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' :
     {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSetsCat (s n) s' μ) :
     IndepSetsCat (⋃ n ∈ u, s n) s' μ := by
   intro t1 t2 ht1 ht2
-  simp_rw [Set.mem_iUnion] at ht1
+  simp_rw [Set.mem_iUnion] at ht1 
   rcases ht1 with ⟨n, hpn, ht1⟩
   exact hyp n hpn t1 t2 ht1 ht2
 #align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSetsCat.bUnion
@@ -407,7 +407,7 @@ theorem indepSetsCat_piiUnionInter_of_disjoint [ProbabilityMeasure μ] {s : ι 
       have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i :=
         by
         intro i hi_mem_union
-        rw [Finset.mem_union] at hi_mem_union
+        rw [Finset.mem_union] at hi_mem_union 
         cases' hi_mem_union with hi1 hi2
         · have hi2 : i ∉ p2 := fun hip2 => set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
           simp_rw [g, if_pos hi1, if_neg hi2, Set.inter_univ]
@@ -483,7 +483,7 @@ theorem indepCat_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0
   have h_pi_system_indep : indep_sets (⋃ n, p n) p' μ :=
     by
     refine' indep_sets.Union _
-    simp_rw [h_gen_n, h_gen'] at h_indep
+    simp_rw [h_gen_n, h_gen'] at h_indep 
     exact fun n => (h_indep n).IndepSetsCat
   -- now go from π-systems to σ-algebras
   refine' indep_sets.indep (iSup_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
@@ -532,7 +532,7 @@ theorem IndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {
     (hp_ind : IndepSets π μ) (haS : a ∉ S) : IndepSetsCat (piiUnionInter π S) (π a) μ :=
   by
   rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
-  rw [Finset.coe_subset] at hs_mem
+  rw [Finset.coe_subset] at hs_mem 
   classical
     let f n := ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
     have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n :=
@@ -705,7 +705,7 @@ theorem indepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Ty
       congr with (i x)
       simp only [Set.mem_iInter]
       constructor <;> intro h hi_mem <;> specialize h hi_mem
-      · rwa [h_preim i hi_mem] at h
+      · rwa [h_preim i hi_mem] at h 
       · rwa [h_preim i hi_mem]
     have h_right_eq : (∏ i in S, μ (setsΩ i)) = ∏ i in S, μ (f i ⁻¹' setsβ i) :=
       by
@@ -790,7 +790,7 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
       (Measurable.comap_le (measurable_pi_iff.mpr fun i => hf_meas i)) hπS_pi hπT_pi hπS_gen hπT_gen
       _
   rintro _ _ ⟨s, ⟨sets_s, hs1, hs2⟩, rfl⟩ ⟨t, ⟨sets_t, ht1, ht2⟩, rfl⟩
-  simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1
+  simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1 
   rw [← hs2, ← ht2]
   classical
     let sets_s' : ∀ i : ι, Set (β i) := fun i =>
@@ -814,7 +814,7 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
       simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
       constructor <;> intro h
       · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h; exact h
+      · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h ; exact h
     have h_eq_inter_T :
       (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
       by
@@ -822,8 +822,8 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
       simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
       constructor <;> intro h
       · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h; exact h
-    rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep
+      · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h ; exact h
+    rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep 
     rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
     have h_Inter_inter :
       ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
@@ -840,7 +840,7 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
     rw [h_Inter_inter, hf_Indep (S ∪ T)]
     swap
     · intro i hi_mem
-      rw [Finset.mem_union] at hi_mem
+      rw [Finset.mem_union] at hi_mem 
       cases hi_mem
       · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
       · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
Diff
@@ -69,7 +69,7 @@ Part A, Chapter 4.
 
 open MeasureTheory MeasurableSpace
 
-open BigOperators MeasureTheory ENNReal
+open scoped BigOperators MeasureTheory ENNReal
 
 namespace ProbabilityTheory
 
Diff
@@ -149,11 +149,8 @@ section Indep
 
 @[symm]
 theorem IndepSetsCat.symm {s₁ s₂ : Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h : IndepSetsCat s₁ s₂ μ) : IndepSetsCat s₂ s₁ μ :=
-  by
-  intro t1 t2 ht1 ht2
-  rw [Set.inter_comm, mul_comm]
-  exact h t2 t1 ht2 ht1
+    (h : IndepSetsCat s₁ s₂ μ) : IndepSetsCat s₂ s₁ μ := by intro t1 t2 ht1 ht2;
+  rw [Set.inter_comm, mul_comm]; exact h t2 t1 ht2 ht1
 #align probability_theory.indep_sets.symm ProbabilityTheory.IndepSetsCat.symm
 
 @[symm]
@@ -178,9 +175,7 @@ theorem indepCat_bot_left (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ
 #align probability_theory.indep_bot_left ProbabilityTheory.indepCat_bot_left
 
 theorem indepSetCat_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
-    (s : Set Ω) : IndepSetCat s ∅ μ :=
-  by
-  simp only [indep_set, generate_from_singleton_empty]
+    (s : Set Ω) : IndepSetCat s ∅ μ := by simp only [indep_set, generate_from_singleton_empty];
   exact indep_bot_right _
 #align probability_theory.indep_set_empty_right ProbabilityTheory.indepSetCat_empty_right
 
@@ -251,11 +246,8 @@ theorem IndepSetsCat.inter [MeasurableSpace Ω] {s₁ s' : Set (Set Ω)} (s₂ :
 #align probability_theory.indep_sets.inter ProbabilityTheory.IndepSetsCat.inter
 
 theorem IndepSetsCat.iInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} (h : ∃ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋂ n, s n) s' μ :=
-  by
-  intro t1 t2 ht1 ht2
-  cases' h with n h
-  exact h t1 t2 (set.mem_Inter.mp ht1 n) ht2
+    {μ : Measure Ω} (h : ∃ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋂ n, s n) s' μ := by
+  intro t1 t2 ht1 ht2; cases' h with n h; exact h t1 t2 (set.mem_Inter.mp ht1 n) ht2
 #align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSetsCat.iInter
 
 theorem IndepSetsCat.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
@@ -549,9 +541,7 @@ theorem IndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {
       simp_rw [f]
       cases' finset.mem_insert.mp hn_mem_insert with hn_mem hn_mem
       · simp [hn_mem, ht2_mem_pia]
-      · have hn_ne_a : n ≠ a := by
-          rintro rfl
-          exact haS (hs_mem hn_mem)
+      · have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hn_mem)
         simp [hn_ne_a, hn_mem, hft1_mem n hn_mem]
     have h_f_mem_pi : ∀ n ∈ s, f n ∈ π n := fun x hxS => h_f_mem x (by simp [hxS])
     have h_t1 : t1 = ⋂ n ∈ s, f n :=
@@ -562,14 +552,10 @@ theorem IndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {
         congr with (hns y)
         simp only [(h_forall n hns).symm]
       intro n hnS
-      have hn_ne_a : n ≠ a := by
-        rintro rfl
-        exact haS (hs_mem hnS)
+      have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hnS)
       simp_rw [f, if_pos hnS, if_neg hn_ne_a]
     have h_μ_t1 : μ t1 = ∏ n in s, μ (f n) := by rw [h_t1, ← hp_ind s h_f_mem_pi]
-    have h_t2 : t2 = f a := by
-      simp_rw [f]
-      simp
+    have h_t2 : t2 = f a := by simp_rw [f]; simp
     have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) :=
       by
       have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
@@ -690,8 +676,7 @@ theorem indepFunCat_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
   by
   constructor <;> intro h
   · refine' fun s t hs ht => h (f ⁻¹' s) (g ⁻¹' t) ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩
-  · rintro _ _ ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩
-    exact h s t hs ht
+  · rintro _ _ ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩; exact h s t hs ht
 #align probability_theory.indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFunCat_iff_measure_inter_preimage_eq_mul
 
 theorem indepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Type _}
@@ -810,56 +795,34 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
   classical
     let sets_s' : ∀ i : ι, Set (β i) := fun i =>
       dite (i ∈ S) (fun hi => sets_s ⟨i, hi⟩) fun _ => Set.univ
-    have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ :=
-      by
-      intro i hi
+    have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ := by intro i hi;
       simp_rw [sets_s', dif_pos hi]
-    have h_sets_s'_univ : ∀ {i} (hi : i ∈ T), sets_s' i = Set.univ :=
-      by
-      intro i hi
+    have h_sets_s'_univ : ∀ {i} (hi : i ∈ T), sets_s' i = Set.univ := by intro i hi;
       simp_rw [sets_s', dif_neg (finset.disjoint_right.mp hST hi)]
     let sets_t' : ∀ i : ι, Set (β i) := fun i =>
       dite (i ∈ T) (fun hi => sets_t ⟨i, hi⟩) fun _ => Set.univ
-    have h_sets_t'_univ : ∀ {i} (hi : i ∈ S), sets_t' i = Set.univ :=
-      by
-      intro i hi
+    have h_sets_t'_univ : ∀ {i} (hi : i ∈ S), sets_t' i = Set.univ := by intro i hi;
       simp_rw [sets_t', dif_neg (finset.disjoint_left.mp hST hi)]
-    have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) :=
-      by
-      intro i hi
-      rw [h_sets_s'_eq hi]
+    have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) := by intro i hi; rw [h_sets_s'_eq hi];
       exact hs1 _
-    have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) :=
-      by
-      intro i hi
-      simp_rw [sets_t', dif_pos hi]
-      exact ht1 _
+    have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) := by intro i hi;
+      simp_rw [sets_t', dif_pos hi]; exact ht1 _
     have h_eq_inter_S :
       (fun (ω : Ω) (i : ↥S) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i :=
       by
       ext1 x
       simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
       constructor <;> intro h
-      · intro i hi
-        rw [h_sets_s'_eq hi]
-        exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩
-        specialize h i hi
-        rw [h_sets_s'_eq hi] at h
-        exact h
+      · intro i hi; rw [h_sets_s'_eq hi]; exact h ⟨i, hi⟩
+      · rintro ⟨i, hi⟩; specialize h i hi; rw [h_sets_s'_eq hi] at h; exact h
     have h_eq_inter_T :
       (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
       by
       ext1 x
       simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
       constructor <;> intro h
-      · intro i hi
-        simp_rw [sets_t', dif_pos hi]
-        exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩
-        specialize h i hi
-        simp_rw [sets_t', dif_pos hi] at h
-        exact h
+      · intro i hi; simp_rw [sets_t', dif_pos hi]; exact h ⟨i, hi⟩
+      · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [sets_t', dif_pos hi] at h; exact h
     rw [Indep_fun_iff_measure_inter_preimage_eq_mul] at hf_Indep
     rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
     have h_Inter_inter :
@@ -871,20 +834,16 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
       constructor <;> intro h
       · intro i hi
         cases hi
-        · rw [h_sets_t'_univ hi]
-          exact ⟨h.1 i hi, Set.mem_univ _⟩
-        · rw [h_sets_s'_univ hi]
-          exact ⟨Set.mem_univ _, h.2 i hi⟩
+        · rw [h_sets_t'_univ hi]; exact ⟨h.1 i hi, Set.mem_univ _⟩
+        · rw [h_sets_s'_univ hi]; exact ⟨Set.mem_univ _, h.2 i hi⟩
       · exact ⟨fun i hi => (h i (Or.inl hi)).1, fun i hi => (h i (Or.inr hi)).2⟩
     rw [h_Inter_inter, hf_Indep (S ∪ T)]
     swap
     · intro i hi_mem
       rw [Finset.mem_union] at hi_mem
       cases hi_mem
-      · rw [h_sets_t'_univ hi_mem, Set.inter_univ]
-        exact h_meas_s' i hi_mem
-      · rw [h_sets_s'_univ hi_mem, Set.univ_inter]
-        exact h_meas_t' i hi_mem
+      · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
+      · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
     rw [Finset.prod_union hST]
     congr 1
     · refine' Finset.prod_congr rfl fun i hi => _
Diff
@@ -372,7 +372,6 @@ private theorem indep_sets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSp
     exact measurable_set_generate_from ht
   rw [measure.restrict_apply ht2, measure.smul_apply, Set.inter_comm]
   exact hyp t1 t ht1 ht
-#align probability_theory.indep_sets.indep_aux probability_theory.indep_sets.indep_aux
 
 theorem IndepSetsCat.indepCat {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {μ : Measure Ω}
     [ProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : IsPiSystem p1)
Diff
@@ -227,20 +227,20 @@ theorem IndepSetsCat.union_iff [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)
     fun h => IndepSetsCat.union h.left h.right⟩
 #align probability_theory.indep_sets.union_iff ProbabilityTheory.IndepSetsCat.union_iff
 
-theorem IndepSetsCat.unionᵢ [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
+theorem IndepSetsCat.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} (hyp : ∀ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋃ n, s n) s' μ :=
   by
   intro t1 t2 ht1 ht2
-  rw [Set.mem_unionᵢ] at ht1
+  rw [Set.mem_iUnion] at ht1
   cases' ht1 with n ht1
   exact hyp n t1 t2 ht1 ht2
-#align probability_theory.indep_sets.Union ProbabilityTheory.IndepSetsCat.unionᵢ
+#align probability_theory.indep_sets.Union ProbabilityTheory.IndepSetsCat.iUnion
 
 theorem IndepSetsCat.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSetsCat (s n) s' μ) :
     IndepSetsCat (⋃ n ∈ u, s n) s' μ := by
   intro t1 t2 ht1 ht2
-  simp_rw [Set.mem_unionᵢ] at ht1
+  simp_rw [Set.mem_iUnion] at ht1
   rcases ht1 with ⟨n, hpn, ht1⟩
   exact hyp n hpn t1 t2 ht1 ht2
 #align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSetsCat.bUnion
@@ -250,20 +250,20 @@ theorem IndepSetsCat.inter [MeasurableSpace Ω] {s₁ s' : Set (Set Ω)} (s₂ :
   fun t1 t2 ht1 ht2 => h₁ t1 t2 ((Set.mem_inter_iff _ _ _).mp ht1).left ht2
 #align probability_theory.indep_sets.inter ProbabilityTheory.IndepSetsCat.inter
 
-theorem IndepSetsCat.interᵢ [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
+theorem IndepSetsCat.iInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} (h : ∃ n, IndepSetsCat (s n) s' μ) : IndepSetsCat (⋂ n, s n) s' μ :=
   by
   intro t1 t2 ht1 ht2
   cases' h with n h
   exact h t1 t2 (set.mem_Inter.mp ht1 n) ht2
-#align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSetsCat.interᵢ
+#align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSetsCat.iInter
 
 theorem IndepSetsCat.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} {u : Set ι} (h : ∃ n ∈ u, IndepSetsCat (s n) s' μ) :
     IndepSetsCat (⋂ n ∈ u, s n) s' μ := by
   intro t1 t2 ht1 ht2
   rcases h with ⟨n, hn, h⟩
-  exact h t1 t2 (Set.binterᵢ_subset_of_mem hn ht1) ht2
+  exact h t1 t2 (Set.biInter_subset_of_mem hn ht1) ht2
 #align probability_theory.indep_sets.bInter ProbabilityTheory.IndepSetsCat.bInter
 
 theorem indepSetsCat_singleton_iff [MeasurableSpace Ω] {s t : Set Ω} {μ : Measure Ω} :
@@ -294,7 +294,7 @@ theorem IndepSets.indepSetsCat {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {
     have h_inter :
       (⋂ (t : ι) (H : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
         ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
-      by simp only [Finset.set_binterᵢ_singleton, Finset.set_binterᵢ_insert]
+      by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
     have h_prod :
       (∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂)) =
         μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) :=
@@ -404,9 +404,9 @@ theorem IndepSetsCat.indep' {m : MeasurableSpace Ω} {μ : Measure Ω} [Probabil
 
 variable {m0 : MeasurableSpace Ω} {μ : Measure Ω}
 
-theorem indepSetsCat_piUnionᵢInter_of_disjoint [ProbabilityMeasure μ] {s : ι → Set (Set Ω)}
+theorem indepSetsCat_piiUnionInter_of_disjoint [ProbabilityMeasure μ] {s : ι → Set (Set Ω)}
     {S T : Set ι} (h_indep : IndepSets s μ) (hST : Disjoint S T) :
-    IndepSetsCat (piUnionᵢInter s S) (piUnionᵢInter s T) μ :=
+    IndepSetsCat (piiUnionInter s S) (piiUnionInter s T) μ :=
   by
   rintro t1 t2 ⟨p1, hp1, f1, ht1_m, ht1_eq⟩ ⟨p2, hp2, f2, ht2_m, ht2_eq⟩
   classical
@@ -429,7 +429,7 @@ theorem indepSetsCat_piUnionᵢInter_of_disjoint [ProbabilityMeasure μ] {s : ι
           ⋂ i ∈ p1 ∪ p2, ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ :=
         by
         ext1 x
-        simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_interᵢ, Finset.mem_union]
+        simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
         exact
           ⟨fun h i _ => ⟨h.1 i, h.2 i⟩, fun h =>
             ⟨fun i hi => (h i (Or.inl hi)).1 hi, fun i hi => (h i (Or.inr hi)).2 hi⟩⟩
@@ -445,38 +445,38 @@ theorem indepSetsCat_piUnionᵢInter_of_disjoint [ProbabilityMeasure μ] {s : ι
       Finset.prod_ite_mem (p1 ∪ p2) p1 fun x => μ (f1 x), Finset.union_inter_cancel_left,
       Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
       h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
-#align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSetsCat_piUnionᵢInter_of_disjoint
+#align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSetsCat_piiUnionInter_of_disjoint
 
 theorem IndepSet.indepCat_generateFrom_of_disjoint [ProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : IndepSet s μ) (S T : Set ι) (hST : Disjoint S T) :
     IndepCat (generateFrom { t | ∃ n ∈ S, s n = t }) (generateFrom { t | ∃ k ∈ T, s k = t }) μ :=
   by
-  rw [← generateFrom_piUnionᵢInter_singleton_left, ← generateFrom_piUnionᵢInter_singleton_left]
+  rw [← generateFrom_piiUnionInter_singleton_left, ← generateFrom_piiUnionInter_singleton_left]
   refine'
     indep_sets.indep'
-      (fun t ht => generateFrom_piUnionᵢInter_le _ _ _ _ (measurable_set_generate_from ht))
-      (fun t ht => generateFrom_piUnionᵢInter_le _ _ _ _ (measurable_set_generate_from ht)) _ _ _
+      (fun t ht => generateFrom_piiUnionInter_le _ _ _ _ (measurable_set_generate_from ht))
+      (fun t ht => generateFrom_piiUnionInter_le _ _ _ _ (measurable_set_generate_from ht)) _ _ _
   · exact fun k => generate_from_le fun t ht => (Set.mem_singleton_iff.1 ht).symm ▸ hsm k
   · exact fun k => generate_from_le fun t ht => (Set.mem_singleton_iff.1 ht).symm ▸ hsm k
-  · exact isPiSystem_piUnionᵢInter _ (fun k => IsPiSystem.singleton _) _
-  · exact isPiSystem_piUnionᵢInter _ (fun k => IsPiSystem.singleton _) _
+  · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
+  · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
   · classical exact indep_sets_pi_Union_Inter_of_disjoint (Indep.Indep_sets (fun n => rfl) hs) hST
 #align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.IndepSet.indepCat_generateFrom_of_disjoint
 
-theorem indepCat_supᵢ_of_disjoint [ProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
+theorem indepCat_iSup_of_disjoint [ProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
     (h_le : ∀ i, m i ≤ m0) (h_indep : Indep m μ) {S T : Set ι} (hST : Disjoint S T) :
     IndepCat (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ :=
   by
   refine'
-    indep_sets.indep (supᵢ₂_le fun i _ => h_le i) (supᵢ₂_le fun i _ => h_le i) _ _
-      (generateFrom_piUnionᵢInter_measurableSet m S).symm
-      (generateFrom_piUnionᵢInter_measurableSet m T).symm _
-  · exact isPiSystem_piUnionᵢInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
-  · exact isPiSystem_piUnionᵢInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
+    indep_sets.indep (iSup₂_le fun i _ => h_le i) (iSup₂_le fun i _ => h_le i) _ _
+      (generateFrom_piiUnionInter_measurableSet m S).symm
+      (generateFrom_piiUnionInter_measurableSet m T).symm _
+  · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
+  · exact isPiSystem_piiUnionInter _ (fun n => @is_pi_system_measurable_set Ω (m n)) _
   · classical exact indep_sets_pi_Union_Inter_of_disjoint h_indep hST
-#align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indepCat_supᵢ_of_disjoint
+#align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indepCat_iSup_of_disjoint
 
-theorem indepCat_supᵢ_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
+theorem indepCat_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
     {μ : Measure Ω} [ProbabilityMeasure μ] (h_indep : ∀ i, IndepCat (m i) m' μ)
     (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Directed (· ≤ ·) m) : IndepCat (⨆ i, m i) m' μ :=
   by
@@ -484,7 +484,7 @@ theorem indepCat_supᵢ_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m'
   have hp : ∀ n, IsPiSystem (p n) := fun n => @is_pi_system_measurable_set Ω (m n)
   have h_gen_n : ∀ n, m n = generate_from (p n) := fun n =>
     (@generate_from_measurable_set Ω (m n)).symm
-  have hp_supr_pi : IsPiSystem (⋃ n, p n) := isPiSystem_unionᵢ_of_directed_le p hp hm
+  have hp_supr_pi : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp hm
   let p' := { t : Set Ω | measurable_set[m'] t }
   have hp'_pi : IsPiSystem p' := @is_pi_system_measurable_set Ω m'
   have h_gen' : m' = generate_from p' := (@generate_from_measurable_set Ω m').symm
@@ -495,9 +495,9 @@ theorem indepCat_supᵢ_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m'
     simp_rw [h_gen_n, h_gen'] at h_indep
     exact fun n => (h_indep n).IndepSetsCat
   -- now go from π-systems to σ-algebras
-  refine' indep_sets.indep (supᵢ_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
+  refine' indep_sets.indep (iSup_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
   exact (generate_from_Union_measurable_set _).symm
-#align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indepCat_supᵢ_of_directed_le
+#align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indepCat_iSup_of_directed_le
 
 theorem IndepSet.indepCat_generateFrom_lt [Preorder ι] [ProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : IndepSet s μ) (i : ι) :
@@ -523,22 +523,22 @@ theorem IndepSet.indepCat_generateFrom_le_nat [ProbabilityMeasure μ] {s : ℕ 
   hs.indepCat_generateFrom_le hsm _ n.lt_succ_self
 #align probability_theory.Indep_set.indep_generate_from_le_nat ProbabilityTheory.IndepSet.indepCat_generateFrom_le_nat
 
-theorem indepCat_supᵢ_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
+theorem indepCat_iSup_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
     (h_indep : ∀ i, IndepCat (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
     (hm : Monotone m) : IndepCat (⨆ i, m i) m' μ :=
-  indepCat_supᵢ_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
-#align probability_theory.indep_supr_of_monotone ProbabilityTheory.indepCat_supᵢ_of_monotone
+  indepCat_iSup_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
+#align probability_theory.indep_supr_of_monotone ProbabilityTheory.indepCat_iSup_of_monotone
 
-theorem indepCat_supᵢ_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
+theorem indepCat_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
     (h_indep : ∀ i, IndepCat (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
     (hm : Antitone m) : IndepCat (⨆ i, m i) m' μ :=
-  indepCat_supᵢ_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
-#align probability_theory.indep_supr_of_antitone ProbabilityTheory.indepCat_supᵢ_of_antitone
+  indepCat_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
+#align probability_theory.indep_supr_of_antitone ProbabilityTheory.indepCat_iSup_of_antitone
 
-theorem IndepSets.piUnionᵢInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {S : Finset ι}
-    (hp_ind : IndepSets π μ) (haS : a ∉ S) : IndepSetsCat (piUnionᵢInter π S) (π a) μ :=
+theorem IndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {S : Finset ι}
+    (hp_ind : IndepSets π μ) (haS : a ∉ S) : IndepSetsCat (piiUnionInter π S) (π a) μ :=
   by
   rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
   rw [Finset.coe_subset] at hs_mem
@@ -574,11 +574,11 @@ theorem IndepSets.piUnionᵢInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι}
     have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) :=
       by
       have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
-        rw [h_t1, h_t2, Finset.set_binterᵢ_insert, Set.inter_comm]
+        rw [h_t1, h_t2, Finset.set_biInter_insert, Set.inter_comm]
       rw [h_t1_inter_t2, ← hp_ind (insert a s) h_f_mem]
     have has : a ∉ s := fun has_mem => haS (hs_mem Membership)
     rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
-#align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.IndepSets.piUnionᵢInter_of_not_mem
+#align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.IndepSets.piiUnionInter_of_not_mem
 
 /-- The measurable space structures generated by independent pi-systems are independent. -/
 theorem IndepSets.indep [ProbabilityMeasure μ] (m : ι → MeasurableSpace Ω) (h_le : ∀ i, m i ≤ m0)
@@ -587,18 +587,18 @@ theorem IndepSets.indep [ProbabilityMeasure μ] (m : ι → MeasurableSpace Ω)
   classical
     refine' Finset.induction _ _
     ·
-      simp only [measure_univ, imp_true_iff, Set.interᵢ_false, Set.interᵢ_univ, Finset.prod_empty,
+      simp only [measure_univ, imp_true_iff, Set.iInter_false, Set.iInter_univ, Finset.prod_empty,
         eq_self_iff_true]
     intro a S ha_notin_S h_rec f hf_m
     have hf_m_S : ∀ x ∈ S, measurable_set[m x] (f x) := fun x hx => hf_m x (by simp [hx])
-    rw [Finset.set_binterᵢ_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
-    let p := piUnionᵢInter π S
+    rw [Finset.set_biInter_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
+    let p := piiUnionInter π S
     set m_p := generate_from p with hS_eq_generate
     have h_indep : indep m_p (m a) μ :=
       by
-      have hp : IsPiSystem p := isPiSystem_piUnionᵢInter π h_pi S
+      have hp : IsPiSystem p := isPiSystem_piiUnionInter π h_pi S
       have h_le' : ∀ i, generate_from (π i) ≤ m0 := fun i => (h_generate i).symm.trans_le (h_le i)
-      have hm_p : m_p ≤ m0 := generateFrom_piUnionᵢInter_le π h_le' S
+      have hm_p : m_p ≤ m0 := generateFrom_piiUnionInter_le π h_le' S
       exact
         indep_sets.indep hm_p (h_le a) hp (h_pi a) hS_eq_generate (h_generate a)
           (h_ind.pi_Union_Inter_of_not_mem ha_notin_S)
@@ -606,7 +606,7 @@ theorem IndepSets.indep [ProbabilityMeasure μ] (m : ι → MeasurableSpace Ω)
     have h_le_p : ∀ i ∈ S, m i ≤ m_p := by
       intro n hn
       rw [hS_eq_generate, h_generate n]
-      exact le_generateFrom_piUnionᵢInter S hn
+      exact le_generateFrom_piiUnionInter S hn
     have h_S_f : ∀ i ∈ S, measurable_set[m_p] (f i) := fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
     exact S.measurable_set_bInter h_S_f
 #align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indep
@@ -656,12 +656,12 @@ theorem IndepCat.indepSetCat_of_measurableSet {m₁ m₂ m0 : MeasurableSpace Ω
     · simp only [hs, Set.mem_singleton_iff, Set.mem_setOf_eq, forall_eq]
     · exact @MeasurableSet.empty _ m₁
     · exact fun u hu => hu.compl
-    · exact fun f hf => MeasurableSet.unionᵢ hf
+    · exact fun f hf => MeasurableSet.iUnion hf
   · refine' generate_from_induction (fun u => measurable_set[m₂] u) {t} _ _ _ _ ht'
     · simp only [ht, Set.mem_singleton_iff, Set.mem_setOf_eq, forall_eq]
     · exact @MeasurableSet.empty _ m₂
     · exact fun u hu => hu.compl
-    · exact fun f hf => MeasurableSet.unionᵢ hf
+    · exact fun f hf => MeasurableSet.iUnion hf
 #align probability_theory.indep.indep_set_of_measurable_set ProbabilityTheory.IndepCat.indepSetCat_of_measurableSet
 
 theorem indepCat_iff_forall_indepSetCat (m₁ m₂ : MeasurableSpace Ω) {m0 : MeasurableSpace Ω}
@@ -719,7 +719,7 @@ theorem indepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Ty
     have h_left_eq : μ (⋂ i ∈ S, setsΩ i) = μ (⋂ i ∈ S, f i ⁻¹' setsβ i) :=
       by
       congr with (i x)
-      simp only [Set.mem_interᵢ]
+      simp only [Set.mem_iInter]
       constructor <;> intro h hi_mem <;> specialize h hi_mem
       · rwa [h_preim i hi_mem] at h
       · rwa [h_preim i hi_mem]
@@ -839,7 +839,7 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
       (fun (ω : Ω) (i : ↥S) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i :=
       by
       ext1 x
-      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_interᵢ]
+      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
       constructor <;> intro h
       · intro i hi
         rw [h_sets_s'_eq hi]
@@ -852,7 +852,7 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
       (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t = ⋂ i ∈ T, f i ⁻¹' sets_t' i :=
       by
       ext1 x
-      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_interᵢ]
+      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
       constructor <;> intro h
       · intro i hi
         simp_rw [sets_t', dif_pos hi]
@@ -868,7 +868,7 @@ theorem IndepFun.indepFunCat_finset [ProbabilityMeasure μ] {ι : Type _} {β :
         ⋂ i ∈ S ∪ T, f i ⁻¹' (sets_s' i ∩ sets_t' i) :=
       by
       ext1 x
-      simp only [Set.mem_inter_iff, Set.mem_interᵢ, Set.mem_preimage, Finset.mem_union]
+      simp only [Set.mem_inter_iff, Set.mem_iInter, Set.mem_preimage, Finset.mem_union]
       constructor <;> intro h
       · intro i hi
         cases hi
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2021 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 
-! This file was ported from Lean 3 source module probability.independence
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
+! This file was ported from Lean 3 source module probability.independence.basic
+! leanprover-community/mathlib commit 2f8347015b12b0864dfaf366ec4909eb70c78740
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -33,9 +33,6 @@ import Mathbin.MeasureTheory.Constructions.Pi
 * `Indep_sets.Indep`: if π-systems are independent as sets of sets, then the
   measurable space structures they generate are independent.
 * `indep_sets.indep`: variant with two π-systems.
-* `measure_zero_or_one_of_measurable_set_limsup_at_top`: Kolmogorov's 0-1 law. Any set which is
-  measurable with respect to the tail σ-algebra `limsup s at_top` of an independent sequence of
-  σ-algebras `s` has probability 0 or 1.
 
 ## Implementation notes
 
@@ -1003,189 +1000,5 @@ theorem IndepSet.indepFun_indicator [Zero β] [One β] {m : MeasurableSpace β}
 
 end IndepFun
 
-/-! ### Kolmogorov's 0-1 law
-
-Let `s : ι → measurable_space Ω` be an independent sequence of sub-σ-algebras. Then any set which
-is measurable with respect to the tail σ-algebra `limsup s at_top` has probability 0 or 1.
--/
-
-
-section ZeroOneLaw
-
-variable {m m0 : MeasurableSpace Ω} {μ : Measure Ω}
-
-theorem measure_eq_zero_or_one_or_top_of_indepSetCat_self {t : Set Ω}
-    (h_indep : IndepSetCat t t μ) : μ t = 0 ∨ μ t = 1 ∨ μ t = ∞ :=
-  by
-  specialize
-    h_indep t t (measurable_set_generate_from (Set.mem_singleton t))
-      (measurable_set_generate_from (Set.mem_singleton t))
-  by_cases h0 : μ t = 0
-  · exact Or.inl h0
-  by_cases h_top : μ t = ∞
-  · exact Or.inr (Or.inr h_top)
-  rw [← one_mul (μ (t ∩ t)), Set.inter_self, ENNReal.mul_eq_mul_right h0 h_top] at h_indep
-  exact Or.inr (Or.inl h_indep.symm)
-#align probability_theory.measure_eq_zero_or_one_or_top_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_or_top_of_indepSetCat_self
-
-theorem measure_eq_zero_or_one_of_indepSetCat_self [FiniteMeasure μ] {t : Set Ω}
-    (h_indep : IndepSetCat t t μ) : μ t = 0 ∨ μ t = 1 :=
-  by
-  have h_0_1_top := measure_eq_zero_or_one_or_top_of_indep_set_self h_indep
-  simpa [measure_ne_top μ] using h_0_1_top
-#align probability_theory.measure_eq_zero_or_one_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_of_indepSetCat_self
-
-variable [ProbabilityMeasure μ] {s : ι → MeasurableSpace Ω}
-
-open Filter
-
-theorem indepCat_bsupr_compl (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (t : Set ι) :
-    IndepCat (⨆ n ∈ t, s n) (⨆ n ∈ tᶜ, s n) μ :=
-  indepCat_supᵢ_of_disjoint h_le h_indep disjoint_compl_right
-#align probability_theory.indep_bsupr_compl ProbabilityTheory.indepCat_bsupr_compl
-
-section Abstract
-
-variable {α : Type _} {p : Set ι → Prop} {f : Filter ι} {ns : α → Set ι}
-
-/-! We prove a version of Kolmogorov's 0-1 law for the σ-algebra `limsup s f` where `f` is a filter
-for which we can define the following two functions:
-* `p : set ι → Prop` such that for a set `t`, `p t → tᶜ ∈ f`,
-* `ns : α → set ι` a directed sequence of sets which all verify `p` and such that
-  `⋃ a, ns a = set.univ`.
-
-For the example of `f = at_top`, we can take `p = bdd_above` and `ns : ι → set ι := λ i, set.Iic i`.
--/
-
-
-/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic filter.is_bounded_default -/
-theorem indepCat_bsupr_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (hf : ∀ t, p t → tᶜ ∈ f)
-    {t : Set ι} (ht : p t) : IndepCat (⨆ n ∈ t, s n) (limsup s f) μ :=
-  by
-  refine' indep_of_indep_of_le_right (indep_bsupr_compl h_le h_indep t) _
-  refine'
-    Limsup_le_of_le
-      (by
-        run_tac
-          is_bounded_default)
-      _
-  simp only [Set.mem_compl_iff, eventually_map]
-  exact eventually_of_mem (hf t ht) le_supᵢ₂
-#align probability_theory.indep_bsupr_limsup ProbabilityTheory.indepCat_bsupr_limsup
-
-theorem indepCat_supᵢ_directed_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ)
-    (hf : ∀ t, p t → tᶜ ∈ f) (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a)) :
-    IndepCat (⨆ a, ⨆ n ∈ ns a, s n) (limsup s f) μ :=
-  by
-  refine' indep_supr_of_directed_le _ _ _ _
-  · exact fun a => indep_bsupr_limsup h_le h_indep hf (hnsp a)
-  · exact fun a => supᵢ₂_le fun n hn => h_le n
-  · exact limsup_le_supr.trans (supᵢ_le h_le)
-  · intro a b
-    obtain ⟨c, hc⟩ := hns a b
-    refine' ⟨c, _, _⟩ <;> refine' supᵢ_mono fun n => supᵢ_mono' fun hn => ⟨_, le_rfl⟩
-    · exact hc.1 hn
-    · exact hc.2 hn
-#align probability_theory.indep_supr_directed_limsup ProbabilityTheory.indepCat_supᵢ_directed_limsup
-
-theorem indepCat_supᵢ_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (hf : ∀ t, p t → tᶜ ∈ f)
-    (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a)) (hns_univ : ∀ n, ∃ a, n ∈ ns a) :
-    IndepCat (⨆ n, s n) (limsup s f) μ :=
-  by
-  suffices (⨆ a, ⨆ n ∈ ns a, s n) = ⨆ n, s n by
-    rw [← this]
-    exact indep_supr_directed_limsup h_le h_indep hf hns hnsp
-  rw [supᵢ_comm]
-  refine' supᵢ_congr fun n => _
-  have : (⨆ (i : α) (H : n ∈ ns i), s n) = ⨆ h : ∃ i, n ∈ ns i, s n := by rw [supᵢ_exists]
-  haveI : Nonempty (∃ i : α, n ∈ ns i) := ⟨hns_univ n⟩
-  rw [this, supᵢ_const]
-#align probability_theory.indep_supr_limsup ProbabilityTheory.indepCat_supᵢ_limsup
-
-theorem indepCat_limsup_self (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (hf : ∀ t, p t → tᶜ ∈ f)
-    (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a)) (hns_univ : ∀ n, ∃ a, n ∈ ns a) :
-    IndepCat (limsup s f) (limsup s f) μ :=
-  indepCat_of_indepCat_of_le_left (indepCat_supᵢ_limsup h_le h_indep hf hns hnsp hns_univ)
-    limsup_le_supᵢ
-#align probability_theory.indep_limsup_self ProbabilityTheory.indepCat_limsup_self
-
-theorem measure_zero_or_one_of_measurableSet_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ)
-    (hf : ∀ t, p t → tᶜ ∈ f) (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a))
-    (hns_univ : ∀ n, ∃ a, n ∈ ns a) {t : Set Ω} (ht_tail : measurable_set[limsup s f] t) :
-    μ t = 0 ∨ μ t = 1 :=
-  measure_eq_zero_or_one_of_indepSetCat_self
-    ((indepCat_limsup_self h_le h_indep hf hns hnsp hns_univ).indepSetCat_of_measurableSet ht_tail
-      ht_tail)
-#align probability_theory.measure_zero_or_one_of_measurable_set_limsup ProbabilityTheory.measure_zero_or_one_of_measurableSet_limsup
-
-end Abstract
-
-section AtTop
-
-variable [SemilatticeSup ι] [NoMaxOrder ι] [Nonempty ι]
-
-theorem indepCat_limsup_atTop_self (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) :
-    IndepCat (limsup s atTop) (limsup s atTop) μ :=
-  by
-  let ns : ι → Set ι := Set.Iic
-  have hnsp : ∀ i, BddAbove (ns i) := fun i => bddAbove_Iic
-  refine' indep_limsup_self h_le h_indep _ _ hnsp _
-  · simp only [mem_at_top_sets, ge_iff_le, Set.mem_compl_iff, BddAbove, upperBounds, Set.Nonempty]
-    rintro t ⟨a, ha⟩
-    obtain ⟨b, hb⟩ : ∃ b, a < b := exists_gt a
-    refine' ⟨b, fun c hc hct => _⟩
-    suffices : ∀ i ∈ t, i < c
-    exact lt_irrefl c (this c hct)
-    exact fun i hi => (ha hi).trans_lt (hb.trans_le hc)
-  · exact Monotone.directed_le fun i j hij k hki => le_trans hki hij
-  · exact fun n => ⟨n, le_rfl⟩
-#align probability_theory.indep_limsup_at_top_self ProbabilityTheory.indepCat_limsup_atTop_self
-
-/-- **Kolmogorov's 0-1 law** : any event in the tail σ-algebra of an independent sequence of
-sub-σ-algebras has probability 0 or 1.
-The tail σ-algebra `limsup s at_top` is the same as `⋂ n, ⋃ i ≥ n, s i`. -/
-theorem measure_zero_or_one_of_measurableSet_limsup_atTop (h_le : ∀ n, s n ≤ m0)
-    (h_indep : Indep s μ) {t : Set Ω} (ht_tail : measurable_set[limsup s atTop] t) :
-    μ t = 0 ∨ μ t = 1 :=
-  measure_eq_zero_or_one_of_indepSetCat_self
-    ((indepCat_limsup_atTop_self h_le h_indep).indepSetCat_of_measurableSet ht_tail ht_tail)
-#align probability_theory.measure_zero_or_one_of_measurable_set_limsup_at_top ProbabilityTheory.measure_zero_or_one_of_measurableSet_limsup_atTop
-
-end AtTop
-
-section AtBot
-
-variable [SemilatticeInf ι] [NoMinOrder ι] [Nonempty ι]
-
-theorem indepCat_limsup_atBot_self (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) :
-    IndepCat (limsup s atBot) (limsup s atBot) μ :=
-  by
-  let ns : ι → Set ι := Set.Ici
-  have hnsp : ∀ i, BddBelow (ns i) := fun i => bddBelow_Ici
-  refine' indep_limsup_self h_le h_indep _ _ hnsp _
-  · simp only [mem_at_bot_sets, ge_iff_le, Set.mem_compl_iff, BddBelow, lowerBounds, Set.Nonempty]
-    rintro t ⟨a, ha⟩
-    obtain ⟨b, hb⟩ : ∃ b, b < a := exists_lt a
-    refine' ⟨b, fun c hc hct => _⟩
-    suffices : ∀ i ∈ t, c < i
-    exact lt_irrefl c (this c hct)
-    exact fun i hi => hc.trans_lt (hb.trans_le (ha hi))
-  · exact directed_of_inf fun i j hij k hki => hij.trans hki
-  · exact fun n => ⟨n, le_rfl⟩
-#align probability_theory.indep_limsup_at_bot_self ProbabilityTheory.indepCat_limsup_atBot_self
-
-/-- **Kolmogorov's 0-1 law** : any event in the tail σ-algebra of an independent sequence of
-sub-σ-algebras has probability 0 or 1. -/
-theorem measure_zero_or_one_of_measurableSet_limsup_atBot (h_le : ∀ n, s n ≤ m0)
-    (h_indep : Indep s μ) {t : Set Ω} (ht_tail : measurable_set[limsup s atBot] t) :
-    μ t = 0 ∨ μ t = 1 :=
-  measure_eq_zero_or_one_of_indepSetCat_self
-    ((indepCat_limsup_atBot_self h_le h_indep).indepSetCat_of_measurableSet ht_tail ht_tail)
-#align probability_theory.measure_zero_or_one_of_measurable_set_limsup_at_bot ProbabilityTheory.measure_zero_or_one_of_measurableSet_limsup_atBot
-
-end AtBot
-
-end ZeroOneLaw
-
 end ProbabilityTheory
 
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2021 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 
-! This file was ported from Lean 3 source module probability.independence
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
+! This file was ported from Lean 3 source module probability.independence.basic
+! leanprover-community/mathlib commit 2f8347015b12b0864dfaf366ec4909eb70c78740
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -33,9 +33,6 @@ import Mathbin.MeasureTheory.Constructions.Pi
 * `Indep_sets.Indep`: if π-systems are independent as sets of sets, then the
   measurable space structures they generate are independent.
 * `indep_sets.indep`: variant with two π-systems.
-* `measure_zero_or_one_of_measurable_set_limsup_at_top`: Kolmogorov's 0-1 law. Any set which is
-  measurable with respect to the tail σ-algebra `limsup s at_top` of an independent sequence of
-  σ-algebras `s` has probability 0 or 1.
 
 ## Implementation notes
 
@@ -1003,189 +1000,5 @@ theorem IndepSet.indepFun_indicator [Zero β] [One β] {m : MeasurableSpace β}
 
 end IndepFun
 
-/-! ### Kolmogorov's 0-1 law
-
-Let `s : ι → measurable_space Ω` be an independent sequence of sub-σ-algebras. Then any set which
-is measurable with respect to the tail σ-algebra `limsup s at_top` has probability 0 or 1.
--/
-
-
-section ZeroOneLaw
-
-variable {m m0 : MeasurableSpace Ω} {μ : Measure Ω}
-
-theorem measure_eq_zero_or_one_or_top_of_indepSetCat_self {t : Set Ω}
-    (h_indep : IndepSetCat t t μ) : μ t = 0 ∨ μ t = 1 ∨ μ t = ∞ :=
-  by
-  specialize
-    h_indep t t (measurable_set_generate_from (Set.mem_singleton t))
-      (measurable_set_generate_from (Set.mem_singleton t))
-  by_cases h0 : μ t = 0
-  · exact Or.inl h0
-  by_cases h_top : μ t = ∞
-  · exact Or.inr (Or.inr h_top)
-  rw [← one_mul (μ (t ∩ t)), Set.inter_self, ENNReal.mul_eq_mul_right h0 h_top] at h_indep
-  exact Or.inr (Or.inl h_indep.symm)
-#align probability_theory.measure_eq_zero_or_one_or_top_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_or_top_of_indepSetCat_self
-
-theorem measure_eq_zero_or_one_of_indepSetCat_self [FiniteMeasure μ] {t : Set Ω}
-    (h_indep : IndepSetCat t t μ) : μ t = 0 ∨ μ t = 1 :=
-  by
-  have h_0_1_top := measure_eq_zero_or_one_or_top_of_indep_set_self h_indep
-  simpa [measure_ne_top μ] using h_0_1_top
-#align probability_theory.measure_eq_zero_or_one_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_of_indepSetCat_self
-
-variable [ProbabilityMeasure μ] {s : ι → MeasurableSpace Ω}
-
-open Filter
-
-theorem indepCat_bsupr_compl (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (t : Set ι) :
-    IndepCat (⨆ n ∈ t, s n) (⨆ n ∈ tᶜ, s n) μ :=
-  indepCat_supᵢ_of_disjoint h_le h_indep disjoint_compl_right
-#align probability_theory.indep_bsupr_compl ProbabilityTheory.indepCat_bsupr_compl
-
-section Abstract
-
-variable {α : Type _} {p : Set ι → Prop} {f : Filter ι} {ns : α → Set ι}
-
-/-! We prove a version of Kolmogorov's 0-1 law for the σ-algebra `limsup s f` where `f` is a filter
-for which we can define the following two functions:
-* `p : set ι → Prop` such that for a set `t`, `p t → tᶜ ∈ f`,
-* `ns : α → set ι` a directed sequence of sets which all verify `p` and such that
-  `⋃ a, ns a = set.univ`.
-
-For the example of `f = at_top`, we can take `p = bdd_above` and `ns : ι → set ι := λ i, set.Iic i`.
--/
-
-
-/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic filter.is_bounded_default -/
-theorem indepCat_bsupr_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (hf : ∀ t, p t → tᶜ ∈ f)
-    {t : Set ι} (ht : p t) : IndepCat (⨆ n ∈ t, s n) (limsup s f) μ :=
-  by
-  refine' indep_of_indep_of_le_right (indep_bsupr_compl h_le h_indep t) _
-  refine'
-    Limsup_le_of_le
-      (by
-        run_tac
-          is_bounded_default)
-      _
-  simp only [Set.mem_compl_iff, eventually_map]
-  exact eventually_of_mem (hf t ht) le_supᵢ₂
-#align probability_theory.indep_bsupr_limsup ProbabilityTheory.indepCat_bsupr_limsup
-
-theorem indepCat_supᵢ_directed_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ)
-    (hf : ∀ t, p t → tᶜ ∈ f) (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a)) :
-    IndepCat (⨆ a, ⨆ n ∈ ns a, s n) (limsup s f) μ :=
-  by
-  refine' indep_supr_of_directed_le _ _ _ _
-  · exact fun a => indep_bsupr_limsup h_le h_indep hf (hnsp a)
-  · exact fun a => supᵢ₂_le fun n hn => h_le n
-  · exact limsup_le_supr.trans (supᵢ_le h_le)
-  · intro a b
-    obtain ⟨c, hc⟩ := hns a b
-    refine' ⟨c, _, _⟩ <;> refine' supᵢ_mono fun n => supᵢ_mono' fun hn => ⟨_, le_rfl⟩
-    · exact hc.1 hn
-    · exact hc.2 hn
-#align probability_theory.indep_supr_directed_limsup ProbabilityTheory.indepCat_supᵢ_directed_limsup
-
-theorem indepCat_supᵢ_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (hf : ∀ t, p t → tᶜ ∈ f)
-    (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a)) (hns_univ : ∀ n, ∃ a, n ∈ ns a) :
-    IndepCat (⨆ n, s n) (limsup s f) μ :=
-  by
-  suffices (⨆ a, ⨆ n ∈ ns a, s n) = ⨆ n, s n by
-    rw [← this]
-    exact indep_supr_directed_limsup h_le h_indep hf hns hnsp
-  rw [supᵢ_comm]
-  refine' supᵢ_congr fun n => _
-  have : (⨆ (i : α) (H : n ∈ ns i), s n) = ⨆ h : ∃ i, n ∈ ns i, s n := by rw [supᵢ_exists]
-  haveI : Nonempty (∃ i : α, n ∈ ns i) := ⟨hns_univ n⟩
-  rw [this, supᵢ_const]
-#align probability_theory.indep_supr_limsup ProbabilityTheory.indepCat_supᵢ_limsup
-
-theorem indepCat_limsup_self (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) (hf : ∀ t, p t → tᶜ ∈ f)
-    (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a)) (hns_univ : ∀ n, ∃ a, n ∈ ns a) :
-    IndepCat (limsup s f) (limsup s f) μ :=
-  indepCat_of_indepCat_of_le_left (indepCat_supᵢ_limsup h_le h_indep hf hns hnsp hns_univ)
-    limsup_le_supᵢ
-#align probability_theory.indep_limsup_self ProbabilityTheory.indepCat_limsup_self
-
-theorem measure_zero_or_one_of_measurableSet_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ)
-    (hf : ∀ t, p t → tᶜ ∈ f) (hns : Directed (· ≤ ·) ns) (hnsp : ∀ a, p (ns a))
-    (hns_univ : ∀ n, ∃ a, n ∈ ns a) {t : Set Ω} (ht_tail : measurable_set[limsup s f] t) :
-    μ t = 0 ∨ μ t = 1 :=
-  measure_eq_zero_or_one_of_indepSetCat_self
-    ((indepCat_limsup_self h_le h_indep hf hns hnsp hns_univ).indepSetCat_of_measurableSet ht_tail
-      ht_tail)
-#align probability_theory.measure_zero_or_one_of_measurable_set_limsup ProbabilityTheory.measure_zero_or_one_of_measurableSet_limsup
-
-end Abstract
-
-section AtTop
-
-variable [SemilatticeSup ι] [NoMaxOrder ι] [Nonempty ι]
-
-theorem indepCat_limsup_atTop_self (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) :
-    IndepCat (limsup s atTop) (limsup s atTop) μ :=
-  by
-  let ns : ι → Set ι := Set.Iic
-  have hnsp : ∀ i, BddAbove (ns i) := fun i => bddAbove_Iic
-  refine' indep_limsup_self h_le h_indep _ _ hnsp _
-  · simp only [mem_at_top_sets, ge_iff_le, Set.mem_compl_iff, BddAbove, upperBounds, Set.Nonempty]
-    rintro t ⟨a, ha⟩
-    obtain ⟨b, hb⟩ : ∃ b, a < b := exists_gt a
-    refine' ⟨b, fun c hc hct => _⟩
-    suffices : ∀ i ∈ t, i < c
-    exact lt_irrefl c (this c hct)
-    exact fun i hi => (ha hi).trans_lt (hb.trans_le hc)
-  · exact Monotone.directed_le fun i j hij k hki => le_trans hki hij
-  · exact fun n => ⟨n, le_rfl⟩
-#align probability_theory.indep_limsup_at_top_self ProbabilityTheory.indepCat_limsup_atTop_self
-
-/-- **Kolmogorov's 0-1 law** : any event in the tail σ-algebra of an independent sequence of
-sub-σ-algebras has probability 0 or 1.
-The tail σ-algebra `limsup s at_top` is the same as `⋂ n, ⋃ i ≥ n, s i`. -/
-theorem measure_zero_or_one_of_measurableSet_limsup_atTop (h_le : ∀ n, s n ≤ m0)
-    (h_indep : Indep s μ) {t : Set Ω} (ht_tail : measurable_set[limsup s atTop] t) :
-    μ t = 0 ∨ μ t = 1 :=
-  measure_eq_zero_or_one_of_indepSetCat_self
-    ((indepCat_limsup_atTop_self h_le h_indep).indepSetCat_of_measurableSet ht_tail ht_tail)
-#align probability_theory.measure_zero_or_one_of_measurable_set_limsup_at_top ProbabilityTheory.measure_zero_or_one_of_measurableSet_limsup_atTop
-
-end AtTop
-
-section AtBot
-
-variable [SemilatticeInf ι] [NoMinOrder ι] [Nonempty ι]
-
-theorem indepCat_limsup_atBot_self (h_le : ∀ n, s n ≤ m0) (h_indep : Indep s μ) :
-    IndepCat (limsup s atBot) (limsup s atBot) μ :=
-  by
-  let ns : ι → Set ι := Set.Ici
-  have hnsp : ∀ i, BddBelow (ns i) := fun i => bddBelow_Ici
-  refine' indep_limsup_self h_le h_indep _ _ hnsp _
-  · simp only [mem_at_bot_sets, ge_iff_le, Set.mem_compl_iff, BddBelow, lowerBounds, Set.Nonempty]
-    rintro t ⟨a, ha⟩
-    obtain ⟨b, hb⟩ : ∃ b, b < a := exists_lt a
-    refine' ⟨b, fun c hc hct => _⟩
-    suffices : ∀ i ∈ t, c < i
-    exact lt_irrefl c (this c hct)
-    exact fun i hi => hc.trans_lt (hb.trans_le (ha hi))
-  · exact directed_of_inf fun i j hij k hki => hij.trans hki
-  · exact fun n => ⟨n, le_rfl⟩
-#align probability_theory.indep_limsup_at_bot_self ProbabilityTheory.indepCat_limsup_atBot_self
-
-/-- **Kolmogorov's 0-1 law** : any event in the tail σ-algebra of an independent sequence of
-sub-σ-algebras has probability 0 or 1. -/
-theorem measure_zero_or_one_of_measurableSet_limsup_atBot (h_le : ∀ n, s n ≤ m0)
-    (h_indep : Indep s μ) {t : Set Ω} (ht_tail : measurable_set[limsup s atBot] t) :
-    μ t = 0 ∨ μ t = 1 :=
-  measure_eq_zero_or_one_of_indepSetCat_self
-    ((indepCat_limsup_atBot_self h_le h_indep).indepSetCat_of_measurableSet ht_tail ht_tail)
-#align probability_theory.measure_zero_or_one_of_measurable_set_limsup_at_bot ProbabilityTheory.measure_zero_or_one_of_measurableSet_limsup_atBot
-
-end AtBot
-
-end ZeroOneLaw
-
 end ProbabilityTheory
 

Changes in mathlib4

mathlib3
mathlib4
chore(*): replace $ with <| (#9319)

See Zulip thread for the discussion.

Diff
@@ -704,7 +704,7 @@ lemma iIndepFun.indepFun_prod_mk_prod_mk (h_indep : iIndepFun m f μ) (hf : ∀
     IndepFun (fun a ↦ (f i a, f j a)) (fun a ↦ (f k a, f l a)) μ := by
   classical
   let g (i j : ι) (v : Π x : ({i, j} : Finset ι), β x) : β i × β j :=
-    ⟨v ⟨i, mem_insert_self _ _⟩, v ⟨j, mem_insert_of_mem $ mem_singleton_self _⟩⟩
+    ⟨v ⟨i, mem_insert_self _ _⟩, v ⟨j, mem_insert_of_mem <| mem_singleton_self _⟩⟩
   have hg (i j : ι) : Measurable (g i j) := by measurability
   exact (h_indep.indepFun_finset {i, j} {k, l} (by aesop) hf).comp (hg i j) (hg k l)
 
feat: IndepFun.symm of different domains (#9425)

Co-authored-by: L Lllvvuu <git@llllvvuu.dev>

Diff
@@ -650,11 +650,12 @@ theorem indepFun_iff_map_prod_eq_prod_map_map {mβ : MeasurableSpace β} {mβ' :
     rw [(h₀ hs ht).1, (h₀ hs ht).2, h, Measure.prod_prod]
 
 @[symm]
-nonrec theorem IndepFun.symm {_ : MeasurableSpace β} {f g : Ω → β} (hfg : IndepFun f g μ) :
-    IndepFun g f μ := hfg.symm
+nonrec theorem IndepFun.symm {_ : MeasurableSpace β} {_ : MeasurableSpace β'}
+    (hfg : IndepFun f g μ) : IndepFun g f μ := hfg.symm
 #align probability_theory.indep_fun.symm ProbabilityTheory.IndepFun.symm
 
-theorem IndepFun.ae_eq {mβ : MeasurableSpace β} {f g f' g' : Ω → β} (hfg : IndepFun f g μ)
+theorem IndepFun.ae_eq {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
+    {f' : Ω → β} {g' : Ω → β'} (hfg : IndepFun f g μ)
     (hf : f =ᵐ[μ] f') (hg : g =ᵐ[μ] g') : IndepFun f' g' μ := by
   refine kernel.IndepFun.ae_eq hfg ?_ ?_ <;>
     simp only [ae_dirac_eq, Filter.eventually_pure, kernel.const_apply]
feat: f i * f j, f k * f l are independent if f is (#8971)

Also prove that a subsingleton family is always independent and that an independent family implies the measure is a probability measure.

This latter result means we can drop IsProbabilityMeasure μ assumptions from many theorems.

From PFR

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>

Diff
@@ -668,42 +668,113 @@ theorem IndepFun.comp {_mβ : MeasurableSpace β} {_mβ' : MeasurableSpace β'}
   kernel.IndepFun.comp hfg hφ hψ
 #align probability_theory.indep_fun.comp ProbabilityTheory.IndepFun.comp
 
+section iIndepFun
+variable {β : ι → Type*} {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i}
+
+@[nontriviality]
+lemma iIndepFun.of_subsingleton [IsProbabilityMeasure μ] [Subsingleton ι] : iIndepFun m f μ :=
+  kernel.iIndepFun.of_subsingleton
+
+lemma iIndepFun.isProbabilityMeasure (h : iIndepFun m f μ) : IsProbabilityMeasure μ :=
+  ⟨by simpa using h.meas_biInter (S := ∅) (s := fun _ ↦ univ)⟩
+
 /-- 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 [IsProbabilityMeasure μ] {ι : Type*} {β : ι → Type*}
-    {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (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) μ :=
+lemma iIndepFun.indepFun_finset (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) μ :=
+  have := hf_Indep.isProbabilityMeasure
   kernel.iIndepFun.indepFun_finset S T hST hf_Indep hf_meas
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 
-theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type*} {β : ι → Type*}
-    {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
-    (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
+lemma iIndepFun.indepFun_prod_mk (hf_Indep : iIndepFun m f μ) (hf_meas : ∀ i, Measurable (f i))
+    (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (fun a => (f i a, f j a)) (f k) μ :=
-  kernel.iIndepFun.indepFun_prod hf_Indep hf_meas i j k hik hjk
+  have := hf_Indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_prod_mk hf_Indep hf_meas i j k hik hjk
 set_option linter.uppercaseLean3 false in
-#align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
+#align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod_mk
+
+open Finset in
+lemma iIndepFun.indepFun_prod_mk_prod_mk (h_indep : iIndepFun m f μ) (hf : ∀ i, Measurable (f i))
+    (i j k l : ι) (hik : i ≠ k) (hil : i ≠ l) (hjk : j ≠ k) (hjl : j ≠ l) :
+    IndepFun (fun a ↦ (f i a, f j a)) (fun a ↦ (f k a, f l a)) μ := by
+  classical
+  let g (i j : ι) (v : Π x : ({i, j} : Finset ι), β x) : β i × β j :=
+    ⟨v ⟨i, mem_insert_self _ _⟩, v ⟨j, mem_insert_of_mem $ mem_singleton_self _⟩⟩
+  have hg (i j : ι) : Measurable (g i j) := by measurability
+  exact (h_indep.indepFun_finset {i, j} {k, l} (by aesop) hf).comp (hg i j) (hg k l)
+
+end iIndepFun
+
+section Mul
+variable {β : Type*} {m : MeasurableSpace β} [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β}
 
 @[to_additive]
-theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type*} {β : Type*} {m : MeasurableSpace β}
-    [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
+lemma iIndepFun.indepFun_mul_left (hf_indep : iIndepFun (fun _ ↦ m) f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (f i * f j) (f k) μ :=
-  kernel.iIndepFun.mul hf_Indep hf_meas i j k hik hjk
+  have := hf_indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_mul_left hf_indep hf_meas i j k hik hjk
 set_option linter.uppercaseLean3 false in
-#align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.mul
+#align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.indepFun_mul_left
 set_option linter.uppercaseLean3 false in
-#align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.add
+#align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.indepFun_add_left
+
+@[to_additive]
+lemma iIndepFun.indepFun_mul_right (hf_indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hij : i ≠ j) (hik : i ≠ k) :
+    IndepFun (f i) (f j * f k) μ :=
+  have := hf_indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_mul_right hf_indep hf_meas i j k hij hik
 
 @[to_additive]
-theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type*} {β : Type*}
-    {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
-    (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
-    (hi : i ∉ s) :
+lemma iIndepFun.indepFun_mul_mul (hf_indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i))
+    (i j k l : ι) (hik : i ≠ k) (hil : i ≠ l) (hjk : j ≠ k) (hjl : j ≠ l) :
+    IndepFun (f i * f j) (f k * f l) μ :=
+  have := hf_indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_mul_mul hf_indep hf_meas i j k l hik hil hjk hjl
+
+end Mul
+
+section Div
+variable {β : Type*} {m : MeasurableSpace β} [Div β] [MeasurableDiv₂ β] {f : ι → Ω → β}
+
+@[to_additive]
+lemma iIndepFun.indepFun_div_left (hf_indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
+    IndepFun (f i / f j) (f k) μ :=
+  have := hf_indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_div_left hf_indep hf_meas i j k hik hjk
+
+@[to_additive]
+lemma iIndepFun.indepFun_div_right (hf_indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hij : i ≠ j) (hik : i ≠ k) :
+    IndepFun (f i) (f j / f k) μ :=
+  have := hf_indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_div_right hf_indep hf_meas i j k hij hik
+
+@[to_additive]
+lemma iIndepFun.indepFun_div_div (hf_indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i))
+    (i j k l : ι) (hik : i ≠ k) (hil : i ≠ l) (hjk : j ≠ k) (hjl : j ≠ l) :
+    IndepFun (f i / f j) (f k / f l) μ :=
+  have := hf_indep.isProbabilityMeasure
+  kernel.iIndepFun.indepFun_div_div hf_indep hf_meas i j k l hik hil hjk hjl
+
+end Div
+
+section CommMonoid
+variable {β : Type*} {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
+
+@[to_additive]
+lemma iIndepFun.indepFun_finset_prod_of_not_mem (hf_Indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι} (hi : i ∉ s) :
     IndepFun (∏ j in s, f j) (f i) μ :=
+  have := hf_Indep.isProbabilityMeasure
   kernel.iIndepFun.indepFun_finset_prod_of_not_mem hf_Indep hf_meas hi
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem
@@ -711,16 +782,17 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
 
 @[to_additive]
-theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type*}
-    {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ℕ → Ω → β}
-    (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) :
-    IndepFun (∏ j in Finset.range n, f j) (f n) μ :=
+lemma iIndepFun.indepFun_prod_range_succ {f : ℕ → Ω → β} (hf_Indep : iIndepFun (fun _ ↦ m) f μ)
+    (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) : IndepFun (∏ j in Finset.range n, f j) (f n) μ :=
+  have := hf_Indep.isProbabilityMeasure
   kernel.iIndepFun.indepFun_prod_range_succ hf_Indep hf_meas n
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_prod_range_succ ProbabilityTheory.iIndepFun.indepFun_prod_range_succ
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_sum_range_succ ProbabilityTheory.iIndepFun.indepFun_sum_range_succ
 
+end CommMonoid
+
 theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
     (hs : iIndepSet s μ) :
     iIndepFun (fun _n => m) (fun n => (s n).indicator fun _ω => 1) μ :=
chore: space after (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -156,7 +156,7 @@ lemma iIndepSets.meas_biInter (h : iIndepSets π μ) (s : Finset ι) {f : ι →
   (iIndepSets_iff _ _).1 h s hf
 
 lemma iIndepSets.meas_iInter [Fintype ι] (h : iIndepSets π μ) (hs : ∀ i, s i ∈ π i) :
-    μ (⋂ i, s i) = ∏ i, μ (s i) := by simp [←h.meas_biInter _ fun _i _ ↦ hs _]
+    μ (⋂ i, s i) = ∏ i, μ (s i) := by simp [← h.meas_biInter _ fun _i _ ↦ hs _]
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_sets.meas_Inter ProbabilityTheory.iIndepSets.meas_iInter
 
@@ -180,7 +180,7 @@ lemma iIndep.meas_biInter (hμ : iIndep m μ) (hs : ∀ i, i ∈ S → Measurabl
     μ (⋂ i ∈ S, s i) = ∏ i in S, μ (s i) := (iIndep_iff _ _).1 hμ _ hs
 
 lemma iIndep.meas_iInter [Fintype ι] (hμ : iIndep m μ) (hs : ∀ i, MeasurableSet[m i] (s i)) :
-    μ (⋂ i, s i) = ∏ i, μ (s i) := by simp [←hμ.meas_biInter fun _ _ ↦ hs _]
+    μ (⋂ i, s i) = ∏ i, μ (s i) := by simp [← hμ.meas_biInter fun _ _ ↦ hs _]
 
 lemma Indep_iff_IndepSets (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
     Indep m₁ m₂ μ ↔ IndepSets {s | MeasurableSet[m₁] s} {s | MeasurableSet[m₂] s} μ := by
refactor(Probability/Density): define pdf using rnDeriv (#8544)

Defines pdf in terms of rnDeriv.

Main definition change:

/-- A random variable `X : Ω → E` is said to `HasPDF` with respect to the measure `ℙ` on `Ω` and
`μ` on `E` if the push-forward measure of `ℙ` along `X` is absolutely continuous with respect to
`μ` and they `HaveLebesgueDecomposition`. -/
class HasPDF {m : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω)
    (μ : Measure E := by volume_tac) : Prop where
  pdf' : Measurable X ∧ HaveLebesgueDecomposition (map X ℙ) μ ∧ map X ℙ ≪ μ

/-- If `X` is a random variable that `HasPDF X ℙ μ`, then `pdf X` is the Radon–Nikodym
derivative of the push-forward measure of `ℙ` along `X` with respect to `μ`. -/
def pdf {_ : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) :
    E → ℝ≥0∞ :=
  if HasPDF X ℙ μ then (map X ℙ).rnDeriv μ else 0

The law of the unconscious statistician is first generalized to rnDeriv on a general Banach space (∫ x, (μ.rnDeriv ν x).toReal • f x ∂ν = ∫ x, f x ∂μ), and then proven for PDFs.

Zulip thread

Diff
@@ -635,14 +635,14 @@ theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : Measur
 #align probability_theory.indep_fun_iff_indep_set_preimage ProbabilityTheory.indepFun_iff_indepSet_preimage
 
 theorem indepFun_iff_map_prod_eq_prod_map_map {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
-    [IsFiniteMeasure μ] (hf : Measurable f) (hg : Measurable g) :
+    [IsFiniteMeasure μ] (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
     IndepFun f g μ ↔ μ.map (fun ω ↦ (f ω, g ω)) = (μ.map f).prod (μ.map g) := by
   rw [indepFun_iff_measure_inter_preimage_eq_mul]
   have h₀ {s : Set β} {t : Set β'} (hs : MeasurableSet s) (ht : MeasurableSet t) :
       μ (f ⁻¹' s) * μ (g ⁻¹' t) = μ.map f s * μ.map g t ∧
       μ (f ⁻¹' s ∩ g ⁻¹' t) = μ.map (fun ω ↦ (f ω, g ω)) (s ×ˢ t) :=
-    ⟨by rw [Measure.map_apply hf hs, Measure.map_apply hg ht],
-      (Measure.map_apply (hf.prod_mk hg) (hs.prod ht)).symm⟩
+    ⟨by rw [Measure.map_apply_of_aemeasurable hf hs, Measure.map_apply_of_aemeasurable hg ht],
+      (Measure.map_apply_of_aemeasurable (hf.prod_mk hg) (hs.prod ht)).symm⟩
   constructor
   · refine fun h ↦ (Measure.prod_eq fun s t hs ht ↦ ?_).symm
     rw [← (h₀ hs ht).1, ← (h₀ hs ht).2, h s t hs ht]
feat(Probability/Density): Random variables are independent iff joint density is product (#8026)

This PR proves that two random variables are independent, iff their joint distribution is the product measure of marginal distributions, iff their joint density is a product of their marginal densities up to AE equality. It also uses lemmas stating that μ.withDensity is injective up to AE equality.

Diff
@@ -634,6 +634,21 @@ theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : Measur
     Filter.eventually_pure, kernel.const_apply]
 #align probability_theory.indep_fun_iff_indep_set_preimage ProbabilityTheory.indepFun_iff_indepSet_preimage
 
+theorem indepFun_iff_map_prod_eq_prod_map_map {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
+    [IsFiniteMeasure μ] (hf : Measurable f) (hg : Measurable g) :
+    IndepFun f g μ ↔ μ.map (fun ω ↦ (f ω, g ω)) = (μ.map f).prod (μ.map g) := by
+  rw [indepFun_iff_measure_inter_preimage_eq_mul]
+  have h₀ {s : Set β} {t : Set β'} (hs : MeasurableSet s) (ht : MeasurableSet t) :
+      μ (f ⁻¹' s) * μ (g ⁻¹' t) = μ.map f s * μ.map g t ∧
+      μ (f ⁻¹' s ∩ g ⁻¹' t) = μ.map (fun ω ↦ (f ω, g ω)) (s ×ˢ t) :=
+    ⟨by rw [Measure.map_apply hf hs, Measure.map_apply hg ht],
+      (Measure.map_apply (hf.prod_mk hg) (hs.prod ht)).symm⟩
+  constructor
+  · refine fun h ↦ (Measure.prod_eq fun s t hs ht ↦ ?_).symm
+    rw [← (h₀ hs ht).1, ← (h₀ hs ht).2, h s t hs ht]
+  · intro h s t hs ht
+    rw [(h₀ hs ht).1, (h₀ hs ht).2, h, Measure.prod_prod]
+
 @[symm]
 nonrec theorem IndepFun.symm {_ : MeasurableSpace β} {f g : Ω → β} (hfg : IndepFun f g μ) :
     IndepFun g f μ := hfg.symm
feat: Independence of singletons (#7251)

Port a bit of https://github.com/leanprover-community/mathlib/pull/18506, but it's mostly handmade.

Co-authored-by: RemyDegenne <Remydegenne@gmail.com>

Diff
@@ -5,7 +5,7 @@ Authors: Rémy Degenne
 -/
 import Mathlib.Probability.Independence.Kernel
 
-#align_import probability.independence.basic from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740"
+#align_import probability.independence.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29"
 
 /-!
 # Independence of sets of sets and measure spaces (σ-algebras)
@@ -66,15 +66,13 @@ when defining `μ` in the example above, the measurable space used is the last o
 Part A, Chapter 4.
 -/
 
-set_option autoImplicit true
-
-open MeasureTheory MeasurableSpace
+open MeasureTheory MeasurableSpace Set
 
 open scoped BigOperators MeasureTheory ENNReal
 
 namespace ProbabilityTheory
 
-variable {Ω ι : Type*}
+variable {Ω ι β γ : Type*} {κ : ι → Type*}
 
 section Definitions
 
@@ -145,12 +143,23 @@ def IndepFun {β γ} [MeasurableSpace Ω] [MeasurableSpace β] [MeasurableSpace
 end Definitions
 
 section Definition_lemmas
+variable {π : ι → Set (Set Ω)} {m : ι → MeasurableSpace Ω} {_ : MeasurableSpace Ω} {μ : Measure Ω}
+  {S : Finset ι} {s : ι → Set Ω}
 
 lemma iIndepSets_iff [MeasurableSpace Ω] (π : ι → Set (Set Ω)) (μ : Measure Ω) :
     iIndepSets π μ ↔ ∀ (s : Finset ι) {f : ι → Set Ω} (_H : ∀ i, i ∈ s → f i ∈ π i),
       μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) := by
   simp only [iIndepSets, kernel.iIndepSets, ae_dirac_eq, Filter.eventually_pure, kernel.const_apply]
 
+lemma iIndepSets.meas_biInter (h : iIndepSets π μ) (s : Finset ι) {f : ι → Set Ω}
+    (hf : ∀ i, i ∈ s → f i ∈ π i) : μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) :=
+  (iIndepSets_iff _ _).1 h s hf
+
+lemma iIndepSets.meas_iInter [Fintype ι] (h : iIndepSets π μ) (hs : ∀ i, s i ∈ π i) :
+    μ (⋂ i, s i) = ∏ i, μ (s i) := by simp [←h.meas_biInter _ fun _i _ ↦ hs _]
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_sets.meas_Inter ProbabilityTheory.iIndepSets.meas_iInter
+
 lemma IndepSets_iff [MeasurableSpace Ω] (s1 s2 : Set (Set Ω)) (μ : Measure Ω) :
     IndepSets s1 s2 μ ↔ ∀ t1 t2 : Set Ω, t1 ∈ s1 → t2 ∈ s2 → (μ (t1 ∩ t2) = μ t1 * μ t2) := by
   simp only [IndepSets, kernel.IndepSets, ae_dirac_eq, Filter.eventually_pure, kernel.const_apply]
@@ -159,11 +168,20 @@ lemma iIndep_iff_iIndepSets (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω]
     iIndep m μ ↔ iIndepSets (fun x ↦ {s | MeasurableSet[m x] s}) μ := by
   simp only [iIndep, iIndepSets, kernel.iIndep]
 
+lemma iIndep.iIndepSets' {m : ι → MeasurableSpace Ω} (hμ : iIndep m μ) :
+    iIndepSets (fun x ↦ {s | MeasurableSet[m x] s}) μ := (iIndep_iff_iIndepSets _ _).1 hμ
+
 lemma iIndep_iff (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
     iIndep m μ ↔ ∀ (s : Finset ι) {f : ι → Set Ω} (_H : ∀ i, i ∈ s → MeasurableSet[m i] (f i)),
       μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) := by
   simp only [iIndep_iff_iIndepSets, iIndepSets_iff]; rfl
 
+lemma iIndep.meas_biInter (hμ : iIndep m μ) (hs : ∀ i, i ∈ S → MeasurableSet[m i] (s i)) :
+    μ (⋂ i ∈ S, s i) = ∏ i in S, μ (s i) := (iIndep_iff _ _).1 hμ _ hs
+
+lemma iIndep.meas_iInter [Fintype ι] (hμ : iIndep m μ) (hs : ∀ i, MeasurableSet[m i] (s i)) :
+    μ (⋂ i, s i) = ∏ i, μ (s i) := by simp [←hμ.meas_biInter fun _ _ ↦ hs _]
+
 lemma Indep_iff_IndepSets (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
     Indep m₁ m₂ μ ↔ IndepSets {s | MeasurableSet[m₁] s} {s | MeasurableSet[m₂] s} μ := by
   simp only [Indep, IndepSets, kernel.Indep]
@@ -197,6 +215,10 @@ lemma iIndepFun_iff_iIndep [MeasurableSpace Ω] {β : ι → Type*}
     iIndepFun m f μ ↔ iIndep (fun x ↦ (m x).comap (f x)) μ := by
   simp only [iIndepFun, iIndep, kernel.iIndepFun]
 
+protected lemma iIndepFun.iIndep {m : ∀ i, MeasurableSpace (κ i)} {f : ∀ x : ι, Ω → κ x}
+    (hf : iIndepFun m f μ) :
+    iIndep (fun x ↦ (m x).comap (f x)) μ := hf
+
 lemma iIndepFun_iff [MeasurableSpace Ω] {β : ι → Type*}
     (m : ∀ x : ι, MeasurableSpace (β x)) (f : ∀ x : ι, Ω → β x) (μ : Measure Ω) :
     iIndepFun m f μ ↔ ∀ (s : Finset ι) {f' : ι → Set Ω}
@@ -204,6 +226,14 @@ lemma iIndepFun_iff [MeasurableSpace Ω] {β : ι → Type*}
       μ (⋂ i ∈ s, f' i) = ∏ i in s, μ (f' i) := by
   simp only [iIndepFun_iff_iIndep, iIndep_iff]
 
+lemma iIndepFun.meas_biInter {m : ∀ i, MeasurableSpace (κ i)} {f : ∀ x : ι, Ω → κ x}
+    (hf : iIndepFun m f μ) (hs : ∀ i, i ∈ S → MeasurableSet[(m i).comap (f i)] (s i)) :
+    μ (⋂ i ∈ S, s i) = ∏ i in S, μ (s i) := hf.iIndep.meas_biInter hs
+
+lemma iIndepFun.meas_iInter [Fintype ι] {m : ∀ i, MeasurableSpace (κ i)} {f : ∀ x : ι, Ω → κ x}
+    (hf : iIndepFun m f μ) (hs : ∀ i, MeasurableSet[(m i).comap (f i)] (s i)) :
+    μ (⋂ i, s i) = ∏ i, μ (s i) := hf.iIndep.meas_iInter hs
+
 lemma IndepFun_iff_Indep [MeasurableSpace Ω] [mβ : MeasurableSpace β]
     [mγ : MeasurableSpace γ] (f : Ω → β) (g : Ω → γ) (μ : Measure Ω) :
     IndepFun f g μ ↔ Indep (MeasurableSpace.comap f mβ) (MeasurableSpace.comap g mγ) μ := by
@@ -215,6 +245,12 @@ lemma IndepFun_iff {β γ} [MeasurableSpace Ω] [mβ : MeasurableSpace β] [mγ
       → MeasurableSet[MeasurableSpace.comap g mγ] t2 → μ (t1 ∩ t2) = μ t1 * μ t2 := by
   rw [IndepFun_iff_Indep, Indep_iff]
 
+lemma IndepFun.meas_inter [mβ : MeasurableSpace β] [mγ : MeasurableSpace γ] {f : Ω → β} {g : Ω → γ}
+    (hfg : IndepFun f g μ) {s t : Set Ω} (hs : MeasurableSet[mβ.comap f] s)
+    (ht : MeasurableSet[mγ.comap g] t) :
+    μ (s ∩ t) = μ s * μ t :=
+  (IndepFun_iff _ _ _).1 hfg _ _ hs ht
+
 end Definition_lemmas
 
 section Indep
@@ -472,7 +508,7 @@ theorem iIndepSets.iIndep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace
     iIndep m μ :=
   kernel.iIndepSets.iIndep m h_le π h_pi h_generate h_ind
 set_option linter.uppercaseLean3 false in
-#align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indep
+#align probability_theory.Indep_sets.Indep ProbabilityTheory.iIndepSets.iIndep
 
 end FromPiSystemsToMeasurableSpaces
 
@@ -486,7 +522,7 @@ We prove the following equivalences on `IndepSet`, for measurable sets `s, t`.
 -/
 
 
-variable {s t : Set Ω} (S T : Set (Set Ω))
+variable {_ : MeasurableSpace Ω} {μ : Measure Ω} {s t : Set Ω} (S T : Set (Set Ω))
 
 theorem indepSet_iff_indepSets_singleton {_m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by volume_tac)
@@ -521,6 +557,45 @@ theorem indep_iff_forall_indepSet (m₁ m₂ : MeasurableSpace Ω) {_m0 : Measur
   kernel.indep_iff_forall_indepSet m₁ m₂ _ _
 #align probability_theory.indep_iff_forall_indep_set ProbabilityTheory.indep_iff_forall_indepSet
 
+theorem iIndep_comap_mem_iff {f : ι → Set Ω} :
+    iIndep (fun i => MeasurableSpace.comap (· ∈ f i) ⊤) μ ↔ iIndepSet f μ :=
+  kernel.iIndep_comap_mem_iff
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_comap_mem_iff ProbabilityTheory.iIndep_comap_mem_iff
+
+alias ⟨_, iIndepSet.iIndep_comap_mem⟩ := iIndep_comap_mem_iff
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_set.Indep_comap_mem ProbabilityTheory.iIndepSet.iIndep_comap_mem
+
+theorem iIndepSets_singleton_iff {s : ι → Set Ω} :
+    iIndepSets (fun i ↦ {s i}) μ ↔ ∀ t, μ (⋂ i ∈ t, s i) = ∏ i in t, μ (s i) := by
+  simp_rw [iIndepSets, kernel.iIndepSets_singleton_iff, ae_dirac_eq, Filter.eventually_pure,
+    kernel.const_apply]
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_sets_singleton_iff ProbabilityTheory.iIndepSets_singleton_iff
+
+variable [IsProbabilityMeasure μ]
+
+theorem iIndepSet_iff_iIndepSets_singleton {f : ι → Set Ω} (hf : ∀ i, MeasurableSet (f i)) :
+    iIndepSet f μ ↔ iIndepSets (fun i ↦ {f i}) μ :=
+  kernel.iIndepSet_iff_iIndepSets_singleton hf
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_set_iff_Indep_sets_singleton ProbabilityTheory.iIndepSet_iff_iIndepSets_singleton
+
+theorem iIndepSet_iff_meas_biInter {f : ι → Set Ω} (hf : ∀ i, MeasurableSet (f i)) :
+    iIndepSet f μ ↔ ∀ s, μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) := by
+  simp_rw [iIndepSet, kernel.iIndepSet_iff_meas_biInter hf, ae_dirac_eq, Filter.eventually_pure,
+    kernel.const_apply]
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_set_iff_measure_Inter_eq_prod ProbabilityTheory.iIndepSet_iff_meas_biInter
+
+theorem iIndepSets.iIndepSet_of_mem {π : ι → Set (Set Ω)} {f : ι → Set Ω}
+    (hfπ : ∀ i, f i ∈ π i) (hf : ∀ i, MeasurableSet (f i))
+    (hπ : iIndepSets π μ) : iIndepSet f μ :=
+  kernel.iIndepSets.iIndepSet_of_mem hfπ hf hπ
+set_option linter.uppercaseLean3 false in
+#align probability_theory.Indep_sets.Indep_set_of_mem ProbabilityTheory.iIndepSets.iIndepSet_of_mem
+
 end IndepSet
 
 section IndepFun
chore: remove some double spaces (#7983)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -164,11 +164,11 @@ lemma iIndep_iff (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Meas
       μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) := by
   simp only [iIndep_iff_iIndepSets, iIndepSets_iff]; rfl
 
-lemma Indep_iff_IndepSets (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω ) :
+lemma Indep_iff_IndepSets (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
     Indep m₁ m₂ μ ↔ IndepSets {s | MeasurableSet[m₁] s} {s | MeasurableSet[m₂] s} μ := by
   simp only [Indep, IndepSets, kernel.Indep]
 
-lemma Indep_iff (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω ) :
+lemma Indep_iff (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
     Indep m₁ m₂ μ
       ↔ ∀ t1 t2, MeasurableSet[m₁] t1 → MeasurableSet[m₂] t2 → μ (t1 ∩ t2) = μ t1 * μ t2 := by
   rw [Indep_iff_IndepSets, IndepSets_iff]; rfl
chore: remove trailing space in backticks (#7617)

This will improve spaces in the mathlib4 docs.

Diff
@@ -12,7 +12,7 @@ import Mathlib.Probability.Independence.Kernel
 
 * A family of sets of sets `π : ι → Set (Set Ω)` is independent with respect to a measure `μ` if for
   any finite set of indices `s = {i_1, ..., i_n}`, for any sets `f i_1 ∈ π i_1, ..., f i_n ∈ π i_n`,
-  `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. It will be used for families of π-systems.
+  `μ (⋂ i in s, f i) = ∏ i in s, μ (f i)`. It will be used for families of π-systems.
 * A family of measurable space structures (i.e. of σ-algebras) is independent with respect to a
   measure `μ` (typically defined on a finer σ-algebra) if the family of sets of measurable sets they
   define is independent. I.e., `m : ι → MeasurableSpace Ω` is independent with respect to a
@@ -97,7 +97,7 @@ def IndepSets [MeasurableSpace Ω] (s1 s2 : Set (Set Ω)) (μ : Measure Ω := by
 measure `μ` (typically defined on a finer σ-algebra) if the family of sets of measurable sets they
 define is independent. `m : ι → MeasurableSpace Ω` is independent with respect to measure `μ` if
 for any finite set of indices `s = {i_1, ..., i_n}`, for any sets
-`f i_1 ∈ m i_1, ..., f i_n ∈ m i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. -/
+`f i_1 ∈ m i_1, ..., f i_n ∈ m i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i)`. -/
 def iIndep (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω := by volume_tac) :
     Prop :=
   kernel.iIndep m (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
fix: disable autoImplicit globally (#6528)

Autoimplicits are highly controversial and also defeat the performance-improving work in #6474.

The intent of this PR is to make autoImplicit opt-in on a per-file basis, by disabling it in the lakefile and enabling it again with set_option autoImplicit true in the few files that rely on it.

That also keeps this PR small, as opposed to attempting to "fix" files to not need it any more.

I claim that many of the uses of autoImplicit in these files are accidental; situations such as:

  • Assuming variables are in scope, but pasting the lemma in the wrong section
  • Pasting in a lemma from a scratch file without checking to see if the variable names are consistent with the rest of the file
  • Making a copy-paste error between lemmas and forgetting to add an explicit arguments.

Having set_option autoImplicit false as the default prevents these types of mistake being made in the 90% of files where autoImplicits are not used at all, and causes them to be caught by CI during review.

I think there were various points during the port where we encouraged porters to delete the universes u v lines; I think having autoparams for universe variables only would cover a lot of the cases we actually use them, while avoiding any real shortcomings.

A Zulip poll (after combining overlapping votes accordingly) was in favor of this change with 5:5:18 as the no:dontcare:yes vote ratio.

While this PR was being reviewed, a handful of files gained some more likely-accidental autoImplicits. In these places, set_option autoImplicit true has been placed locally within a section, rather than at the top of the file.

Diff
@@ -66,6 +66,8 @@ when defining `μ` in the example above, the measurable space used is the last o
 Part A, Chapter 4.
 -/
 
+set_option autoImplicit true
+
 open MeasureTheory MeasurableSpace
 
 open scoped BigOperators MeasureTheory ENNReal
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -72,7 +72,7 @@ open scoped BigOperators MeasureTheory ENNReal
 
 namespace ProbabilityTheory
 
-variable {Ω ι : Type _}
+variable {Ω ι : Type*}
 
 section Definitions
 
@@ -126,7 +126,7 @@ def IndepSet [MeasurableSpace Ω] (s t : Set Ω) (μ : Measure Ω := by volume_t
 spaces, each with a measurable space structure, is independent if the family of measurable space
 structures they generate on `Ω` is independent. For a function `g` with codomain having measurable
 space structure `m`, the generated measurable space structure is `MeasurableSpace.comap g m`. -/
-def iIndepFun [MeasurableSpace Ω] {β : ι → Type _} (m : ∀ x : ι, MeasurableSpace (β x))
+def iIndepFun [MeasurableSpace Ω] {β : ι → Type*} (m : ∀ x : ι, MeasurableSpace (β x))
     (f : ∀ x : ι, Ω → β x) (μ : Measure Ω := by volume_tac) : Prop :=
   kernel.iIndepFun m f (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 set_option linter.uppercaseLean3 false in
@@ -190,12 +190,12 @@ lemma IndepSet_iff [MeasurableSpace Ω] (s t : Set Ω) (μ : Measure Ω) :
       → MeasurableSet[generateFrom {t}] t2 → μ (t1 ∩ t2) = μ t1 * μ t2 := by
   simp only [IndepSet_iff_Indep, Indep_iff]
 
-lemma iIndepFun_iff_iIndep [MeasurableSpace Ω] {β : ι → Type _}
+lemma iIndepFun_iff_iIndep [MeasurableSpace Ω] {β : ι → Type*}
     (m : ∀ x : ι, MeasurableSpace (β x)) (f : ∀ x : ι, Ω → β x) (μ : Measure Ω) :
     iIndepFun m f μ ↔ iIndep (fun x ↦ (m x).comap (f x)) μ := by
   simp only [iIndepFun, iIndep, kernel.iIndepFun]
 
-lemma iIndepFun_iff [MeasurableSpace Ω] {β : ι → Type _}
+lemma iIndepFun_iff [MeasurableSpace Ω] {β : ι → Type*}
     (m : ∀ x : ι, MeasurableSpace (β x)) (f : ∀ x : ι, Ω → β x) (μ : Measure Ω) :
     iIndepFun m f μ ↔ ∀ (s : Finset ι) {f' : ι → Set Ω}
       (_H : ∀ i, i ∈ s → MeasurableSet[(m i).comap (f i)] (f' i)),
@@ -337,7 +337,7 @@ theorem iIndep.indep {m : ι → MeasurableSpace Ω} [MeasurableSpace Ω] {μ :
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep.indep ProbabilityTheory.iIndep.indep
 
-theorem iIndepFun.indepFun {_m₀ : MeasurableSpace Ω} {μ : Measure Ω} {β : ι → Type _}
+theorem iIndepFun.indepFun {_m₀ : MeasurableSpace Ω} {μ : Measure Ω} {β : ι → Type*}
     {m : ∀ x, MeasurableSpace (β x)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ) {i j : ι}
     (hij : i ≠ j) :
     IndepFun (f i) (f j) μ :=
@@ -528,7 +528,7 @@ section IndepFun
 -/
 
 
-variable {β β' γ γ' : Type _} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {f : Ω → β} {g : Ω → β'}
+variable {β β' γ γ' : Type*} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {f : Ω → β} {g : Ω → β'}
 
 theorem indepFun_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
     {mβ' : MeasurableSpace β'} :
@@ -539,7 +539,7 @@ theorem indepFun_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
     Filter.eventually_pure, kernel.const_apply]
 #align probability_theory.indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFun_iff_measure_inter_preimage_eq_mul
 
-theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Type _}
+theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type*} {β : ι → Type*}
     (m : ∀ x, MeasurableSpace (β x)) (f : ∀ i, Ω → β i) :
     iIndepFun m f μ ↔
       ∀ (S : Finset ι) {sets : ∀ i : ι, Set (β i)} (_H : ∀ i, i ∈ S → MeasurableSet[m i] (sets i)),
@@ -579,7 +579,7 @@ theorem IndepFun.comp {_mβ : MeasurableSpace β} {_mβ' : MeasurableSpace β'}
 /-- 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 [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type*} {β : ι → Type*}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (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) μ :=
@@ -587,7 +587,7 @@ theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β :
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 
-theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type*} {β : ι → Type*}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (fun a => (f i a, f j a)) (f k) μ :=
@@ -596,7 +596,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
 
 @[to_additive]
-theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
+theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type*} {β : Type*} {m : MeasurableSpace β}
     [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (f i * f j) (f k) μ :=
@@ -607,7 +607,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.add
 
 @[to_additive]
-theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
+theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type*} {β : Type*}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
     (hi : i ∉ s) :
@@ -619,7 +619,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
 
 @[to_additive]
-theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type _}
+theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type*}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ℕ → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) :
     IndepFun (∏ j in Finset.range n, f j) (f n) μ :=
refactor(Probability/Independence): define independence using kernel independence (#6294)

Independence is the special case of independence with respect to a kernel and a measure where the kernel is constant.

Diff
@@ -3,7 +3,7 @@ Copyright (c) 2021 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 -/
-import Mathlib.MeasureTheory.Constructions.Pi
+import Mathlib.Probability.Independence.Kernel
 
 #align_import probability.independence.basic from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740"
 
@@ -33,9 +33,12 @@ import Mathlib.MeasureTheory.Constructions.Pi
 
 ## Implementation notes
 
-We provide one main definition of independence:
-* `iIndepSets`: independence of a family of sets of sets `pi : ι → Set (Set Ω)`.
-Three other independence notions are defined using `iIndepSets`:
+The definitions of independence in this file are a particular case of independence with respect to a
+kernel and a measure, as defined in the file `Kernel.lean`.
+
+We provide four definitions of independence:
+* `iIndepSets`: independence of a family of sets of sets `pi : ι → Set (Set Ω)`. This is meant to
+  be used with π-systems.
 * `iIndep`: independence of a family of measurable space structures `m : ι → MeasurableSpace Ω`,
 * `iIndepSet`: independence of a family of sets `s : ι → Set Ω`,
 * `iIndepFun`: independence of a family of functions. For measurable spaces
@@ -46,11 +49,11 @@ sets of sets, sets, functions) instead of a family. These properties are denoted
 as for a family, but without the starting `i`, for example `IndepFun` is the version of `iIndepFun`
 for two functions.
 
-The definition of independence for `iIndepSets` uses finite sets (`Finset`). An alternative and
-equivalent way of defining independence would have been to use countable sets.
-TODO: prove that equivalence.
+The definition of independence for `iIndepSets` uses finite sets (`Finset`). See
+`ProbabilityTheory.kernel.iIndepSets`. An alternative and equivalent way of defining independence
+would have been to use countable sets.
 
-Most of the definitions and lemma in this file list all variables instead of using the `variables`
+Most of the definitions and lemmas in this file list all variables instead of using the `variable`
 keyword at the beginning of a section, for example
 `lemma Indep.symm {Ω} {m₁ m₂ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : measure Ω} ...` .
 This is intentional, to be able to control the order of the `MeasurableSpace` variables. Indeed
@@ -78,15 +81,14 @@ for any finite set of indices `s = {i_1, ..., i_n}`, for any sets
 `f i_1 ∈ π i_1, ..., f i_n ∈ π i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `.
 It will be used for families of pi_systems. -/
 def iIndepSets [MeasurableSpace Ω] (π : ι → Set (Set Ω)) (μ : Measure Ω := by volume_tac) : Prop :=
-    ∀ (s : Finset ι) {f : ι → Set Ω} (_H : ∀ i, i ∈ s → f i ∈ π i),
-    μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i)
+  kernel.iIndepSets π (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_sets ProbabilityTheory.iIndepSets
 
 /-- Two sets of sets `s₁, s₂` are independent with respect to a measure `μ` if for any sets
 `t₁ ∈ p₁, t₂ ∈ s₂`, then `μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/
-def IndepSets [MeasurableSpace Ω] (s1 s2 : Set (Set Ω)) (μ : Measure Ω := by volume_tac) : Prop
-    := ∀ t1 t2 : Set Ω, t1 ∈ s1 → t2 ∈ s2 → μ (t1 ∩ t2) = μ t1 * μ t2
+def IndepSets [MeasurableSpace Ω] (s1 s2 : Set (Set Ω)) (μ : Measure Ω := by volume_tac) : Prop :=
+  kernel.IndepSets s1 s2 (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 #align probability_theory.indep_sets ProbabilityTheory.IndepSets
 
 /-- A family of measurable space structures (i.e. of σ-algebras) is independent with respect to a
@@ -95,28 +97,29 @@ define is independent. `m : ι → MeasurableSpace Ω` is independent with respe
 for any finite set of indices `s = {i_1, ..., i_n}`, for any sets
 `f i_1 ∈ m i_1, ..., f i_n ∈ m i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. -/
 def iIndep (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω := by volume_tac) :
-    Prop := iIndepSets (fun x => { s | MeasurableSet[m x] s }) μ
+    Prop :=
+  kernel.iIndep m (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep ProbabilityTheory.iIndep
 
 /-- Two measurable space structures (or σ-algebras) `m₁, m₂` are independent with respect to a
 measure `μ` (defined on a third σ-algebra) if for any sets `t₁ ∈ m₁, t₂ ∈ m₂`,
 `μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/
-def Indep (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω := by volume_tac) : Prop
-    := IndepSets { s | MeasurableSet[m₁] s } { s | MeasurableSet[m₂] s } μ
+def Indep (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω := by volume_tac) : Prop :=
+  kernel.Indep m₁ m₂ (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 #align probability_theory.indep ProbabilityTheory.Indep
 
 /-- A family of sets is independent if the family of measurable space structures they generate is
 independent. For a set `s`, the generated measurable space has measurable sets `∅, s, sᶜ, univ`. -/
 def iIndepSet [MeasurableSpace Ω] (s : ι → Set Ω) (μ : Measure Ω := by volume_tac) : Prop :=
-    iIndep (fun i => generateFrom {s i}) μ
+  kernel.iIndepSet s (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set ProbabilityTheory.iIndepSet
 
 /-- Two sets are independent if the two measurable space structures they generate are independent.
 For a set `s`, the generated measurable space structure has measurable sets `∅, s, sᶜ, univ`. -/
 def IndepSet [MeasurableSpace Ω] (s t : Set Ω) (μ : Measure Ω := by volume_tac) : Prop :=
-    Indep (generateFrom {s}) (generateFrom {t}) μ
+  kernel.IndepSet s t (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 #align probability_theory.indep_set ProbabilityTheory.IndepSet
 
 /-- A family of functions defined on the same space `Ω` and taking values in possibly different
@@ -125,27 +128,99 @@ structures they generate on `Ω` is independent. For a function `g` with codomai
 space structure `m`, the generated measurable space structure is `MeasurableSpace.comap g m`. -/
 def iIndepFun [MeasurableSpace Ω] {β : ι → Type _} (m : ∀ x : ι, MeasurableSpace (β x))
     (f : ∀ x : ι, Ω → β x) (μ : Measure Ω := by volume_tac) : Prop :=
-    iIndep (fun x => MeasurableSpace.comap (f x) (m x)) μ
+  kernel.iIndepFun m f (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun ProbabilityTheory.iIndepFun
 
 /-- Two functions are independent if the two measurable space structures they generate are
 independent. For a function `f` with codomain having measurable space structure `m`, the generated
 measurable space structure is `MeasurableSpace.comap f m`. -/
-def IndepFun {β γ} [MeasurableSpace Ω] [mβ : MeasurableSpace β] [mγ : MeasurableSpace γ]
+def IndepFun {β γ} [MeasurableSpace Ω] [MeasurableSpace β] [MeasurableSpace γ]
     (f : Ω → β) (g : Ω → γ) (μ : Measure Ω := by volume_tac) : Prop :=
-    Indep (MeasurableSpace.comap f mβ) (MeasurableSpace.comap g mγ) μ
+  kernel.IndepFun f g (kernel.const Unit μ) (Measure.dirac () : Measure Unit)
 #align probability_theory.indep_fun ProbabilityTheory.IndepFun
 
 end Definitions
 
+section Definition_lemmas
+
+lemma iIndepSets_iff [MeasurableSpace Ω] (π : ι → Set (Set Ω)) (μ : Measure Ω) :
+    iIndepSets π μ ↔ ∀ (s : Finset ι) {f : ι → Set Ω} (_H : ∀ i, i ∈ s → f i ∈ π i),
+      μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) := by
+  simp only [iIndepSets, kernel.iIndepSets, ae_dirac_eq, Filter.eventually_pure, kernel.const_apply]
+
+lemma IndepSets_iff [MeasurableSpace Ω] (s1 s2 : Set (Set Ω)) (μ : Measure Ω) :
+    IndepSets s1 s2 μ ↔ ∀ t1 t2 : Set Ω, t1 ∈ s1 → t2 ∈ s2 → (μ (t1 ∩ t2) = μ t1 * μ t2) := by
+  simp only [IndepSets, kernel.IndepSets, ae_dirac_eq, Filter.eventually_pure, kernel.const_apply]
+
+lemma iIndep_iff_iIndepSets (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
+    iIndep m μ ↔ iIndepSets (fun x ↦ {s | MeasurableSet[m x] s}) μ := by
+  simp only [iIndep, iIndepSets, kernel.iIndep]
+
+lemma iIndep_iff (m : ι → MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω) :
+    iIndep m μ ↔ ∀ (s : Finset ι) {f : ι → Set Ω} (_H : ∀ i, i ∈ s → MeasurableSet[m i] (f i)),
+      μ (⋂ i ∈ s, f i) = ∏ i in s, μ (f i) := by
+  simp only [iIndep_iff_iIndepSets, iIndepSets_iff]; rfl
+
+lemma Indep_iff_IndepSets (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω ) :
+    Indep m₁ m₂ μ ↔ IndepSets {s | MeasurableSet[m₁] s} {s | MeasurableSet[m₂] s} μ := by
+  simp only [Indep, IndepSets, kernel.Indep]
+
+lemma Indep_iff (m₁ m₂ : MeasurableSpace Ω) [MeasurableSpace Ω] (μ : Measure Ω ) :
+    Indep m₁ m₂ μ
+      ↔ ∀ t1 t2, MeasurableSet[m₁] t1 → MeasurableSet[m₂] t2 → μ (t1 ∩ t2) = μ t1 * μ t2 := by
+  rw [Indep_iff_IndepSets, IndepSets_iff]; rfl
+
+lemma iIndepSet_iff_iIndep [MeasurableSpace Ω] (s : ι → Set Ω) (μ : Measure Ω) :
+    iIndepSet s μ ↔ iIndep (fun i ↦ generateFrom {s i}) μ := by
+  simp only [iIndepSet, iIndep, kernel.iIndepSet]
+
+lemma iIndepSet_iff [MeasurableSpace Ω] (s : ι → Set Ω) (μ : Measure Ω) :
+    iIndepSet s μ ↔ ∀ (s' : Finset ι) {f : ι → Set Ω}
+      (_H : ∀ i, i ∈ s' → MeasurableSet[generateFrom {s i}] (f i)),
+      μ (⋂ i ∈ s', f i) = ∏ i in s', μ (f i) := by
+  simp only [iIndepSet_iff_iIndep, iIndep_iff]
+
+lemma IndepSet_iff_Indep [MeasurableSpace Ω] (s t : Set Ω) (μ : Measure Ω) :
+    IndepSet s t μ ↔ Indep (generateFrom {s}) (generateFrom {t}) μ := by
+  simp only [IndepSet, Indep, kernel.IndepSet]
+
+lemma IndepSet_iff [MeasurableSpace Ω] (s t : Set Ω) (μ : Measure Ω) :
+    IndepSet s t μ ↔ ∀ t1 t2, MeasurableSet[generateFrom {s}] t1
+      → MeasurableSet[generateFrom {t}] t2 → μ (t1 ∩ t2) = μ t1 * μ t2 := by
+  simp only [IndepSet_iff_Indep, Indep_iff]
+
+lemma iIndepFun_iff_iIndep [MeasurableSpace Ω] {β : ι → Type _}
+    (m : ∀ x : ι, MeasurableSpace (β x)) (f : ∀ x : ι, Ω → β x) (μ : Measure Ω) :
+    iIndepFun m f μ ↔ iIndep (fun x ↦ (m x).comap (f x)) μ := by
+  simp only [iIndepFun, iIndep, kernel.iIndepFun]
+
+lemma iIndepFun_iff [MeasurableSpace Ω] {β : ι → Type _}
+    (m : ∀ x : ι, MeasurableSpace (β x)) (f : ∀ x : ι, Ω → β x) (μ : Measure Ω) :
+    iIndepFun m f μ ↔ ∀ (s : Finset ι) {f' : ι → Set Ω}
+      (_H : ∀ i, i ∈ s → MeasurableSet[(m i).comap (f i)] (f' i)),
+      μ (⋂ i ∈ s, f' i) = ∏ i in s, μ (f' i) := by
+  simp only [iIndepFun_iff_iIndep, iIndep_iff]
+
+lemma IndepFun_iff_Indep [MeasurableSpace Ω] [mβ : MeasurableSpace β]
+    [mγ : MeasurableSpace γ] (f : Ω → β) (g : Ω → γ) (μ : Measure Ω) :
+    IndepFun f g μ ↔ Indep (MeasurableSpace.comap f mβ) (MeasurableSpace.comap g mγ) μ := by
+  simp only [IndepFun, Indep, kernel.IndepFun]
+
+lemma IndepFun_iff {β γ} [MeasurableSpace Ω] [mβ : MeasurableSpace β] [mγ : MeasurableSpace γ]
+    (f : Ω → β) (g : Ω → γ) (μ : Measure Ω) :
+    IndepFun f g μ ↔ ∀ t1 t2, MeasurableSet[MeasurableSpace.comap f mβ] t1
+      → MeasurableSet[MeasurableSpace.comap g mγ] t2 → μ (t1 ∩ t2) = μ t1 * μ t2 := by
+  rw [IndepFun_iff_Indep, Indep_iff]
+
+end Definition_lemmas
+
 section Indep
 
 @[symm]
 theorem IndepSets.symm {s₁ s₂ : Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h : IndepSets s₁ s₂ μ) : IndepSets s₂ s₁ μ := by
-  intro t1 t2 ht1 ht2
-  rw [Set.inter_comm, mul_comm]; exact h t2 t1 ht2 ht1
+    (h : IndepSets s₁ s₂ μ) : IndepSets s₂ s₁ μ :=
+  kernel.IndepSets.symm h
 #align probability_theory.indep_sets.symm ProbabilityTheory.IndepSets.symm
 
 @[symm]
@@ -153,105 +228,94 @@ theorem Indep.symm {m₁ m₂ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : M
     (h : Indep m₁ m₂ μ) : Indep m₂ m₁ μ := IndepSets.symm h
 #align probability_theory.indep.symm ProbabilityTheory.Indep.symm
 
-theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
-    [IsProbabilityMeasure μ] : Indep m' ⊥ μ := by
-  intro s t _hs ht
-  rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht
-  cases' ht with ht ht
-  · rw [ht, Set.inter_empty, measure_empty, MulZeroClass.mul_zero]
-  · rw [ht, Set.inter_univ, measure_univ, mul_one]
+theorem indep_bot_right (m' : MeasurableSpace Ω) {_m : MeasurableSpace Ω} {μ : Measure Ω}
+    [IsProbabilityMeasure μ] : Indep m' ⊥ μ :=
+  kernel.indep_bot_right m'
 #align probability_theory.indep_bot_right ProbabilityTheory.indep_bot_right
 
 theorem indep_bot_left (m' : MeasurableSpace Ω) {_m : MeasurableSpace Ω} {μ : Measure Ω}
     [IsProbabilityMeasure μ] : Indep ⊥ m' μ := (indep_bot_right m').symm
 #align probability_theory.indep_bot_left ProbabilityTheory.indep_bot_left
 
-theorem indepSet_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
-    (s : Set Ω) : IndepSet s ∅ μ := by
-  simp only [IndepSet, generateFrom_singleton_empty];
-  exact indep_bot_right _
+theorem indepSet_empty_right {_m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
+    (s : Set Ω) : IndepSet s ∅ μ :=
+  kernel.indepSet_empty_right s
 #align probability_theory.indep_set_empty_right ProbabilityTheory.indepSet_empty_right
 
 theorem indepSet_empty_left {_m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
-    (s : Set Ω) : IndepSet ∅ s μ := (indepSet_empty_right s).symm
+    (s : Set Ω) : IndepSet ∅ s μ :=
+  kernel.indepSet_empty_left s
 #align probability_theory.indep_set_empty_left ProbabilityTheory.indepSet_empty_left
 
 theorem indepSets_of_indepSets_of_le_left {s₁ s₂ s₃ : Set (Set Ω)} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : IndepSets s₁ s₂ μ) (h31 : s₃ ⊆ s₁) : IndepSets s₃ s₂ μ :=
-  fun t1 t2 ht1 ht2 => h_indep t1 t2 (Set.mem_of_subset_of_mem h31 ht1) ht2
+    {μ : Measure Ω} (h_indep : IndepSets s₁ s₂ μ) (h31 : s₃ ⊆ s₁) :
+    IndepSets s₃ s₂ μ :=
+  kernel.indepSets_of_indepSets_of_le_left h_indep h31
 #align probability_theory.indep_sets_of_indep_sets_of_le_left ProbabilityTheory.indepSets_of_indepSets_of_le_left
 
 theorem indepSets_of_indepSets_of_le_right {s₁ s₂ s₃ : Set (Set Ω)} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : IndepSets s₁ s₂ μ) (h32 : s₃ ⊆ s₂) : IndepSets s₁ s₃ μ :=
-  fun t1 t2 ht1 ht2 => h_indep t1 t2 ht1 (Set.mem_of_subset_of_mem h32 ht2)
+    {μ : Measure Ω} (h_indep : IndepSets s₁ s₂ μ) (h32 : s₃ ⊆ s₂) :
+    IndepSets s₁ s₃ μ :=
+  kernel.indepSets_of_indepSets_of_le_right h_indep h32
 #align probability_theory.indep_sets_of_indep_sets_of_le_right ProbabilityTheory.indepSets_of_indepSets_of_le_right
 
 theorem indep_of_indep_of_le_left {m₁ m₂ m₃ : MeasurableSpace Ω} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : Indep m₁ m₂ μ) (h31 : m₃ ≤ m₁) : Indep m₃ m₂ μ :=
-  fun t1 t2 ht1 ht2 => h_indep t1 t2 (h31 _ ht1) ht2
+    {μ : Measure Ω} (h_indep : Indep m₁ m₂ μ) (h31 : m₃ ≤ m₁) :
+    Indep m₃ m₂ μ :=
+  kernel.indep_of_indep_of_le_left h_indep h31
 #align probability_theory.indep_of_indep_of_le_left ProbabilityTheory.indep_of_indep_of_le_left
 
 theorem indep_of_indep_of_le_right {m₁ m₂ m₃ : MeasurableSpace Ω} [MeasurableSpace Ω]
-    {μ : Measure Ω} (h_indep : Indep m₁ m₂ μ) (h32 : m₃ ≤ m₂) : Indep m₁ m₃ μ :=
-  fun t1 t2 ht1 ht2 => h_indep t1 t2 ht1 (h32 _ ht2)
+    {μ : Measure Ω} (h_indep : Indep m₁ m₂ μ) (h32 : m₃ ≤ m₂) :
+    Indep m₁ m₃ μ :=
+  kernel.indep_of_indep_of_le_right h_indep h32
 #align probability_theory.indep_of_indep_of_le_right ProbabilityTheory.indep_of_indep_of_le_right
 
 theorem IndepSets.union [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω}
-    (h₁ : IndepSets s₁ s' μ) (h₂ : IndepSets s₂ s' μ) : IndepSets (s₁ ∪ s₂) s' μ := by
-  intro t1 t2 ht1 ht2
-  cases' (Set.mem_union _ _ _).mp ht1 with ht1₁ ht1₂
-  · exact h₁ t1 t2 ht1₁ ht2
-  · exact h₂ t1 t2 ht1₂ ht2
+    (h₁ : IndepSets s₁ s' μ) (h₂ : IndepSets s₂ s' μ) :
+    IndepSets (s₁ ∪ s₂) s' μ :=
+  kernel.IndepSets.union h₁ h₂
 #align probability_theory.indep_sets.union ProbabilityTheory.IndepSets.union
 
 @[simp]
 theorem IndepSets.union_iff [MeasurableSpace Ω] {s₁ s₂ s' : Set (Set Ω)} {μ : Measure Ω} :
     IndepSets (s₁ ∪ s₂) s' μ ↔ IndepSets s₁ s' μ ∧ IndepSets s₂ s' μ :=
-  ⟨fun h =>
-    ⟨indepSets_of_indepSets_of_le_left h (Set.subset_union_left s₁ s₂),
-      indepSets_of_indepSets_of_le_left h (Set.subset_union_right s₁ s₂)⟩,
-    fun h => IndepSets.union h.left h.right⟩
+  kernel.IndepSets.union_iff
 #align probability_theory.indep_sets.union_iff ProbabilityTheory.IndepSets.union_iff
 
 theorem IndepSets.iUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} (hyp : ∀ n, IndepSets (s n) s' μ) : IndepSets (⋃ n, s n) s' μ := by
-  intro t1 t2 ht1 ht2
-  rw [Set.mem_iUnion] at ht1
-  cases' ht1 with n ht1
-  exact hyp n t1 t2 ht1 ht2
+    {μ : Measure Ω} (hyp : ∀ n, IndepSets (s n) s' μ) :
+    IndepSets (⋃ n, s n) s' μ :=
+  kernel.IndepSets.iUnion hyp
 #align probability_theory.indep_sets.Union ProbabilityTheory.IndepSets.iUnion
 
 theorem IndepSets.bUnion [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} {u : Set ι} (hyp : ∀ n ∈ u, IndepSets (s n) s' μ) :
-    IndepSets (⋃ n ∈ u, s n) s' μ := by
-  intro t1 t2 ht1 ht2
-  simp_rw [Set.mem_iUnion] at ht1
-  rcases ht1 with ⟨n, hpn, ht1⟩
-  exact hyp n hpn t1 t2 ht1 ht2
+    IndepSets (⋃ n ∈ u, s n) s' μ :=
+  kernel.IndepSets.bUnion hyp
 #align probability_theory.indep_sets.bUnion ProbabilityTheory.IndepSets.bUnion
 
 theorem IndepSets.inter [MeasurableSpace Ω] {s₁ s' : Set (Set Ω)} (s₂ : Set (Set Ω))
     {μ : Measure Ω} (h₁ : IndepSets s₁ s' μ) : IndepSets (s₁ ∩ s₂) s' μ :=
-  fun t1 t2 ht1 ht2 => h₁ t1 t2 ((Set.mem_inter_iff _ _ _).mp ht1).left ht2
+  kernel.IndepSets.inter s₂ h₁
 #align probability_theory.indep_sets.inter ProbabilityTheory.IndepSets.inter
 
 theorem IndepSets.iInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
-    {μ : Measure Ω} (h : ∃ n, IndepSets (s n) s' μ) : IndepSets (⋂ n, s n) s' μ := by
-  intro t1 t2 ht1 ht2; cases' h with n h; exact h t1 t2 (Set.mem_iInter.mp ht1 n) ht2
+    {μ : Measure Ω} (h : ∃ n, IndepSets (s n) s' μ) :
+    IndepSets (⋂ n, s n) s' μ :=
+  kernel.IndepSets.iInter h
 #align probability_theory.indep_sets.Inter ProbabilityTheory.IndepSets.iInter
 
 theorem IndepSets.bInter [MeasurableSpace Ω] {s : ι → Set (Set Ω)} {s' : Set (Set Ω)}
     {μ : Measure Ω} {u : Set ι} (h : ∃ n ∈ u, IndepSets (s n) s' μ) :
-    IndepSets (⋂ n ∈ u, s n) s' μ := by
-  intro t1 t2 ht1 ht2
-  rcases h with ⟨n, hn, h⟩
-  exact h t1 t2 (Set.biInter_subset_of_mem hn ht1) ht2
+    IndepSets (⋂ n ∈ u, s n) s' μ :=
+  kernel.IndepSets.bInter h
 #align probability_theory.indep_sets.bInter ProbabilityTheory.IndepSets.bInter
 
 theorem indepSets_singleton_iff [MeasurableSpace Ω] {s t : Set Ω} {μ : Measure Ω} :
-    IndepSets {s} {t} μ ↔ μ (s ∩ t) = μ s * μ t :=
-  ⟨fun h => h s t rfl rfl, fun h s1 t1 hs1 ht1 => by
-    rwa [Set.mem_singleton_iff.mp hs1, Set.mem_singleton_iff.mp ht1]⟩
+    IndepSets {s} {t} μ ↔ μ (s ∩ t) = μ s * μ t := by
+  simp only [IndepSets, kernel.indepSets_singleton_iff, ae_dirac_eq, Filter.eventually_pure,
+    kernel.const_apply]
 #align probability_theory.indep_sets_singleton_iff ProbabilityTheory.indepSets_singleton_iff
 
 end Indep
@@ -262,43 +326,22 @@ end Indep
 section FromIndepToIndep
 
 theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := by
-  classical
-    intro t₁ t₂ ht₁ ht₂
-    have hf_m : ∀ x : ι, x ∈ ({i, j} : Finset ι) → ite (x = i) t₁ t₂ ∈ s x := by
-      intro x hx
-      cases' Finset.mem_insert.mp hx with hx hx
-      · simp [hx, ht₁]
-      · simp [Finset.mem_singleton.mp hx, hij.symm, ht₂]
-    have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
-    have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
-    have h_inter :
-      ⋂ (t : ι) (_ : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂ =
-        ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
-      by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
-    have h_prod :
-      (∏ t : ι in ({i, j} : Finset ι), μ (ite (t = i) t₁ t₂)) =
-        μ (ite (i = i) t₁ t₂) * μ (ite (j = i) t₁ t₂) := by
-      simp only [hij, Finset.prod_singleton, Finset.prod_insert, not_false_iff,
-        Finset.mem_singleton]
-    rw [h1]
-    nth_rw 2 [h2]
-    nth_rw 4 [h2]
-    rw [← h_inter, ← h_prod, h_indep {i, j} hf_m]
+    (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ :=
+  kernel.iIndepSets.indepSets h_indep hij
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_sets.indep_sets ProbabilityTheory.iIndepSets.indepSets
 
 theorem iIndep.indep {m : ι → MeasurableSpace Ω} [MeasurableSpace Ω] {μ : Measure Ω}
-    (h_indep : iIndep m μ) {i j : ι} (hij : i ≠ j) : Indep (m i) (m j) μ := by
-  change IndepSets ((fun x => MeasurableSet[m x]) i) ((fun x => MeasurableSet[m x]) j) μ
-  exact iIndepSets.indepSets h_indep hij
+    (h_indep : iIndep m μ) {i j : ι} (hij : i ≠ j) : Indep (m i) (m j) μ :=
+  kernel.iIndep.indep h_indep hij
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep.indep ProbabilityTheory.iIndep.indep
 
 theorem iIndepFun.indepFun {_m₀ : MeasurableSpace Ω} {μ : Measure Ω} {β : ι → Type _}
     {m : ∀ x, MeasurableSpace (β x)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ) {i j : ι}
-    (hij : i ≠ j) : IndepFun (f i) (f j) μ :=
-  hf_Indep.indep hij
+    (hij : i ≠ j) :
+    IndepFun (f i) (f j) μ :=
+  kernel.iIndepFun.indepFun hf_Indep hij
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun ProbabilityTheory.iIndepFun.indepFun
 
@@ -318,16 +361,15 @@ section FromMeasurableSpacesToSetsOfSets
 
 theorem iIndep.iIndepSets [MeasurableSpace Ω] {μ : Measure Ω} {m : ι → MeasurableSpace Ω}
     {s : ι → Set (Set Ω)} (hms : ∀ n, m n = generateFrom (s n)) (h_indep : iIndep m μ) :
-    iIndepSets s μ := fun S f hfs =>
-  h_indep S fun x hxS =>
-    ((hms x).symm ▸ measurableSet_generateFrom (hfs x hxS) : MeasurableSet[m x] (f x))
+    iIndepSets s μ :=
+  kernel.iIndep.iIndepSets hms h_indep
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep.Indep_sets ProbabilityTheory.iIndep.iIndepSets
 
 theorem Indep.indepSets [MeasurableSpace Ω] {μ : Measure Ω} {s1 s2 : Set (Set Ω)}
-    (h_indep : Indep (generateFrom s1) (generateFrom s2) μ) : IndepSets s1 s2 μ :=
-  fun t1 t2 ht1 ht2 =>
-  h_indep t1 t2 (measurableSet_generateFrom ht1) (measurableSet_generateFrom ht2)
+    (h_indep : Indep (generateFrom s1) (generateFrom s2) μ) :
+    IndepSets s1 s2 μ :=
+  kernel.Indep.indepSets h_indep
 #align probability_theory.indep.indep_sets ProbabilityTheory.Indep.indepSets
 
 end FromMeasurableSpacesToSetsOfSets
@@ -336,246 +378,97 @@ section FromPiSystemsToMeasurableSpaces
 
 /-! ### Independence of generating π-systems implies independence of measurable space structures -/
 
-
-private theorem IndepSets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω}
-    {μ : Measure Ω} [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h2 : m2 ≤ m)
-    (hp2 : IsPiSystem p2) (hpm2 : m2 = generateFrom p2) (hyp : IndepSets p1 p2 μ) {t1 t2 : Set Ω}
-    (ht1 : t1 ∈ p1) (ht2m : MeasurableSet[m2] t2) : μ (t1 ∩ t2) = μ t1 * μ t2 := by
-  let μ_inter := μ.restrict t1
-  let ν := μ t1 • μ
-  have h_univ : μ_inter Set.univ = ν Set.univ := by
-    rw [Measure.restrict_apply_univ, Measure.smul_apply, smul_eq_mul, measure_univ, mul_one]
-  haveI : IsFiniteMeasure μ_inter := @Restrict.isFiniteMeasure Ω _ t1 μ ⟨measure_lt_top μ t1⟩
-  rw [Set.inter_comm, ← Measure.restrict_apply (h2 t2 ht2m)]
-  refine' ext_on_measurableSpace_of_generate_finite m p2 (fun t ht => _) h2 hpm2 hp2 h_univ ht2m
-  have ht2 : MeasurableSet[m] t := by
-    refine' h2 _ _
-    rw [hpm2]
-    exact measurableSet_generateFrom ht
-  rw [Measure.restrict_apply ht2, Measure.smul_apply, Set.inter_comm]
-  exact hyp t1 t ht1 ht
-
 theorem IndepSets.indep {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {μ : Measure Ω}
     [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : IsPiSystem p1)
     (hp2 : IsPiSystem p2) (hpm1 : m1 = generateFrom p1) (hpm2 : m2 = generateFrom p2)
-    (hyp : IndepSets p1 p2 μ) : Indep m1 m2 μ := by
-  intro t1 t2 ht1 ht2
-  let μ_inter := μ.restrict t2
-  let ν := μ t2 • μ
-  have h_univ : μ_inter Set.univ = ν Set.univ := by
-    rw [Measure.restrict_apply_univ, Measure.smul_apply, smul_eq_mul, measure_univ, mul_one]
-  haveI : IsFiniteMeasure μ_inter := @Restrict.isFiniteMeasure Ω _ t2 μ ⟨measure_lt_top μ t2⟩
-  rw [mul_comm, ← Measure.restrict_apply (h1 t1 ht1)]
-  refine' ext_on_measurableSpace_of_generate_finite m p1 (fun t ht => _) h1 hpm1 hp1 h_univ ht1
-  have ht1 : MeasurableSet[m] t := by
-    refine' h1 _ _
-    rw [hpm1]
-    exact measurableSet_generateFrom ht
-  rw [Measure.restrict_apply ht1, Measure.smul_apply, smul_eq_mul, mul_comm]
-  exact IndepSets.indep_aux h2 hp2 hpm2 hyp ht ht2
+    (hyp : IndepSets p1 p2 μ) :
+    Indep m1 m2 μ :=
+  kernel.IndepSets.indep h1 h2 hp1 hp2 hpm1 hpm2 hyp
 #align probability_theory.indep_sets.indep ProbabilityTheory.IndepSets.indep
 
 theorem IndepSets.indep' {_m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     {p1 p2 : Set (Set Ω)} (hp1m : ∀ s ∈ p1, MeasurableSet s) (hp2m : ∀ s ∈ p2, MeasurableSet s)
     (hp1 : IsPiSystem p1) (hp2 : IsPiSystem p2) (hyp : IndepSets p1 p2 μ) :
     Indep (generateFrom p1) (generateFrom p2) μ :=
-  hyp.indep (generateFrom_le hp1m) (generateFrom_le hp2m) hp1 hp2 rfl rfl
+  kernel.IndepSets.indep' hp1m hp2m hp1 hp2 hyp
 #align probability_theory.indep_sets.indep' ProbabilityTheory.IndepSets.indep'
 
 variable {m0 : MeasurableSpace Ω} {μ : Measure Ω}
 
 theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set (Set Ω)}
     {S T : Set ι} (h_indep : iIndepSets s μ) (hST : Disjoint S T) :
-    IndepSets (piiUnionInter s S) (piiUnionInter s T) μ := by
-  rintro t1 t2 ⟨p1, hp1, f1, ht1_m, ht1_eq⟩ ⟨p2, hp2, f2, ht2_m, ht2_eq⟩
-  classical
-    let g i := ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ
-    have h_P_inter : μ (t1 ∩ t2) = ∏ n in p1 ∪ p2, μ (g n) := by
-      have hgm : ∀ i ∈ p1 ∪ p2, g i ∈ s i := by
-        intro i hi_mem_union
-        rw [Finset.mem_union] at hi_mem_union
-        cases' hi_mem_union with hi1 hi2
-        · have hi2 : i ∉ p2 := fun hip2 => Set.disjoint_left.mp hST (hp1 hi1) (hp2 hip2)
-          simp_rw [if_pos hi1, if_neg hi2, Set.inter_univ]
-          exact ht1_m i hi1
-        · have hi1 : i ∉ p1 := fun hip1 => Set.disjoint_right.mp hST (hp2 hi2) (hp1 hip1)
-          simp_rw [if_neg hi1, if_pos hi2, Set.univ_inter]
-          exact ht2_m i hi2
-      have h_p1_inter_p2 :
-        ((⋂ x ∈ p1, f1 x) ∩ ⋂ x ∈ p2, f2 x) =
-          ⋂ i ∈ p1 ∪ p2, ite (i ∈ p1) (f1 i) Set.univ ∩ ite (i ∈ p2) (f2 i) Set.univ := by
-        ext1 x
-        simp only [Set.mem_ite_univ_right, Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
-        exact
-          ⟨fun h i _ => ⟨h.1 i, h.2 i⟩, fun h =>
-            ⟨fun i hi => (h i (Or.inl hi)).1 hi, fun i hi => (h i (Or.inr hi)).2 hi⟩⟩
-      rw [ht1_eq, ht2_eq, h_p1_inter_p2, ← h_indep _ hgm]
-    have h_μg : ∀ n, μ (g n) = ite (n ∈ p1) (μ (f1 n)) 1 * ite (n ∈ p2) (μ (f2 n)) 1 := by
-      intro n
-      dsimp only
-      split_ifs with h1 h2
-      · exact absurd rfl (Set.disjoint_iff_forall_ne.mp hST (hp1 h1) (hp2 h2))
-      all_goals simp only [measure_univ, one_mul, mul_one, Set.inter_univ, Set.univ_inter]
-    simp_rw [h_P_inter, h_μg, Finset.prod_mul_distrib,
-      Finset.prod_ite_mem (p1 ∪ p2) p1 fun x => μ (f1 x), Finset.union_inter_cancel_left,
-      Finset.prod_ite_mem (p1 ∪ p2) p2 fun x => μ (f2 x), Finset.union_inter_cancel_right, ht1_eq, ←
-      h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
+    IndepSets (piiUnionInter s S) (piiUnionInter s T) μ :=
+  kernel.indepSets_piiUnionInter_of_disjoint h_indep hST
 #align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSets_piiUnionInter_of_disjoint
 
 theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (S T : Set ι) (hST : Disjoint S T) :
-    Indep (generateFrom { t | ∃ n ∈ S, s n = t }) (generateFrom { t | ∃ k ∈ T, s k = t }) μ := by
-  rw [← generateFrom_piiUnionInter_singleton_left, ← generateFrom_piiUnionInter_singleton_left]
-  refine'
-    IndepSets.indep'
-      (fun t ht => generateFrom_piiUnionInter_le _ _ _ _ (measurableSet_generateFrom ht))
-      (fun t ht => generateFrom_piiUnionInter_le _ _ _ _ (measurableSet_generateFrom ht)) _ _ _
-  · exact fun k => generateFrom_le fun t ht => (Set.mem_singleton_iff.1 ht).symm ▸ hsm k
-  · exact fun k => generateFrom_le fun t ht => (Set.mem_singleton_iff.1 ht).symm ▸ hsm k
-  · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
-  · exact isPiSystem_piiUnionInter _ (fun k => IsPiSystem.singleton _) _
-  · classical exact indepSets_piiUnionInter_of_disjoint (iIndep.iIndepSets (fun n => rfl) hs) hST
+    Indep (generateFrom { t | ∃ n ∈ S, s n = t }) (generateFrom { t | ∃ k ∈ T, s k = t }) μ :=
+  kernel.iIndepSet.indep_generateFrom_of_disjoint hsm hs S T hST
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint
 
 theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
     (h_le : ∀ i, m i ≤ m0) (h_indep : iIndep m μ) {S T : Set ι} (hST : Disjoint S T) :
-    Indep (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ := by
-  refine'
-    IndepSets.indep (iSup₂_le fun i _ => h_le i) (iSup₂_le fun i _ => h_le i) _ _
-      (generateFrom_piiUnionInter_measurableSet m S).symm
-      (generateFrom_piiUnionInter_measurableSet m T).symm _
-  · exact isPiSystem_piiUnionInter _ (fun n => @isPiSystem_measurableSet Ω (m n)) _
-  · exact isPiSystem_piiUnionInter _ (fun n => @isPiSystem_measurableSet Ω (m n)) _
-  · classical exact indepSets_piiUnionInter_of_disjoint h_indep hST
+    Indep (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ :=
+  kernel.indep_iSup_of_disjoint h_le h_indep hST
 #align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indep_iSup_of_disjoint
 
 theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
     {μ : Measure Ω} [IsProbabilityMeasure μ] (h_indep : ∀ i, Indep (m i) m' μ)
     (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Directed (· ≤ ·) m) :
-    Indep (⨆ i, m i) m' μ := by
-  let p : ι → Set (Set Ω) := fun n => { t | MeasurableSet[m n] t }
-  have hp : ∀ n, IsPiSystem (p n) := fun n => @isPiSystem_measurableSet Ω (m n)
-  have h_gen_n : ∀ n, m n = generateFrom (p n) := fun n =>
-    (@generateFrom_measurableSet Ω (m n)).symm
-  have hp_supr_pi : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp hm
-  let p' := { t : Set Ω | MeasurableSet[m'] t }
-  have hp'_pi : IsPiSystem p' := @isPiSystem_measurableSet Ω m'
-  have h_gen' : m' = generateFrom p' := (@generateFrom_measurableSet Ω m').symm
-  -- the π-systems defined are independent
-  have h_pi_system_indep : IndepSets (⋃ n, p n) p' μ := by
-    refine IndepSets.iUnion ?_
-    conv at h_indep =>
-      intro i
-      rw [h_gen_n i, h_gen']
-    exact fun n => (h_indep n).indepSets
-  -- now go from π-systems to σ-algebras
-  refine' IndepSets.indep (iSup_le h_le) h_le' hp_supr_pi hp'_pi _ h_gen' h_pi_system_indep
-  exact (generateFrom_iUnion_measurableSet _).symm
+    Indep (⨆ i, m i) m' μ :=
+  kernel.indep_iSup_of_directed_le h_indep h_le h_le' hm
 #align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indep_iSup_of_directed_le
 
 theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) :
-    Indep (generateFrom {s i}) (generateFrom { t | ∃ j < i, s j = t }) μ := by
-  convert iIndepSet.indep_generateFrom_of_disjoint hsm hs {i} { j | j < i }
-    (Set.disjoint_singleton_left.mpr (lt_irrefl _))
-  simp only [Set.mem_singleton_iff, exists_prop, exists_eq_left, Set.setOf_eq_eq_singleton']
+    Indep (generateFrom {s i}) (generateFrom { t | ∃ j < i, s j = t }) μ :=
+  kernel.iIndepSet.indep_generateFrom_lt hsm hs i
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_lt ProbabilityTheory.iIndepSet.indep_generateFrom_lt
 
 theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) {k : ι} (hk : i < k) :
-    Indep (generateFrom {s k}) (generateFrom { t | ∃ j ≤ i, s j = t }) μ := by
-  convert iIndepSet.indep_generateFrom_of_disjoint hsm hs {k} { j | j ≤ i }
-      (Set.disjoint_singleton_left.mpr hk.not_le)
-  simp only [Set.mem_singleton_iff, exists_prop, exists_eq_left, Set.setOf_eq_eq_singleton']
+    Indep (generateFrom {s k}) (generateFrom { t | ∃ j ≤ i, s j = t }) μ :=
+  kernel.iIndepSet.indep_generateFrom_le hsm hs i hk
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_le ProbabilityTheory.iIndepSet.indep_generateFrom_le
 
 theorem iIndepSet.indep_generateFrom_le_nat [IsProbabilityMeasure μ] {s : ℕ → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (n : ℕ) :
     Indep (generateFrom {s (n + 1)}) (generateFrom { t | ∃ k ≤ n, s k = t }) μ :=
-  iIndepSet.indep_generateFrom_le hsm hs _ n.lt_succ_self
+  kernel.iIndepSet.indep_generateFrom_le_nat hsm hs n
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_le_nat ProbabilityTheory.iIndepSet.indep_generateFrom_le_nat
 
 theorem indep_iSup_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
-    (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
-    (hm : Monotone m) : Indep (⨆ i, m i) m' μ :=
-  indep_iSup_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
+    (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Monotone m) :
+    Indep (⨆ i, m i) m' μ :=
+  kernel.indep_iSup_of_monotone h_indep h_le h_le' hm
 #align probability_theory.indep_supr_of_monotone ProbabilityTheory.indep_iSup_of_monotone
 
 theorem indep_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
     {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
-    (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
-    (hm : Antitone m) : Indep (⨆ i, m i) m' μ :=
-  indep_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
+    (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Antitone m) :
+    Indep (⨆ i, m i) m' μ :=
+  kernel.indep_iSup_of_antitone h_indep h_le h_le' hm
 #align probability_theory.indep_supr_of_antitone ProbabilityTheory.indep_iSup_of_antitone
 
 theorem iIndepSets.piiUnionInter_of_not_mem {π : ι → Set (Set Ω)} {a : ι} {S : Finset ι}
-    (hp_ind : iIndepSets π μ) (haS : a ∉ S) : IndepSets (piiUnionInter π S) (π a) μ := by
-  rintro t1 t2 ⟨s, hs_mem, ft1, hft1_mem, ht1_eq⟩ ht2_mem_pia
-  rw [Finset.coe_subset] at hs_mem
-  classical
-    let f := fun n => ite (n = a) t2 (ite (n ∈ s) (ft1 n) Set.univ)
-    have h_f_mem : ∀ n ∈ insert a s, f n ∈ π n := by
-      intro n hn_mem_insert
-      dsimp only
-      cases' Finset.mem_insert.mp hn_mem_insert with hn_mem hn_mem
-      · simp [hn_mem, ht2_mem_pia]
-      · have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hn_mem)
-        simp [hn_ne_a, hn_mem, hft1_mem n hn_mem]
-    have h_f_mem_pi : ∀ n ∈ s, f n ∈ π n := fun x hxS => h_f_mem x (by simp [hxS])
-    have h_t1 : t1 = ⋂ n ∈ s, f n := by
-      suffices h_forall : ∀ n ∈ s, f n = ft1 n
-      · rw [ht1_eq]
-        ext x
-        simp_rw [Set.mem_iInter]
-        conv => lhs; intro i hns; rw [← h_forall i hns]
-      intro n hnS
-      have hn_ne_a : n ≠ a := by rintro rfl; exact haS (hs_mem hnS)
-      simp_rw [if_pos hnS, if_neg hn_ne_a]
-    have h_μ_t1 : μ t1 = ∏ n in s, μ (f n) := by rw [h_t1, ← hp_ind s h_f_mem_pi]
-    have h_t2 : t2 = f a := by simp
-    have h_μ_inter : μ (t1 ∩ t2) = ∏ n in insert a s, μ (f n) := by
-      have h_t1_inter_t2 : t1 ∩ t2 = ⋂ n ∈ insert a s, f n := by
-        rw [h_t1, h_t2, Finset.set_biInter_insert, Set.inter_comm]
-      rw [h_t1_inter_t2, ← hp_ind (insert a s) h_f_mem]
-    have has : a ∉ s := fun has_mem => haS (hs_mem has_mem)
-    rw [h_μ_inter, Finset.prod_insert has, h_t2, mul_comm, h_μ_t1]
+    (hp_ind : iIndepSets π μ) (haS : a ∉ S) :
+    IndepSets (piiUnionInter π S) (π a) μ :=
+  kernel.iIndepSets.piiUnionInter_of_not_mem hp_ind haS
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
 
 /-- The measurable space structures generated by independent pi-systems are independent. -/
 theorem iIndepSets.iIndep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω)
     (h_le : ∀ i, m i ≤ m0) (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
-    (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) : iIndep m μ := by
-  classical
-    intro s f
-    refine Finset.induction ?_ ?_ s
-    · simp only [Finset.not_mem_empty, Set.mem_setOf_eq, IsEmpty.forall_iff, implies_true,
-      Set.iInter_of_empty, Set.iInter_univ, measure_univ, Finset.prod_empty, forall_true_left]
-    · intro a S ha_notin_S h_rec hf_m
-      have hf_m_S : ∀ x ∈ S, MeasurableSet[m x] (f x) := fun x hx => hf_m x (by simp [hx])
-      rw [Finset.set_biInter_insert, Finset.prod_insert ha_notin_S, ← h_rec hf_m_S]
-      let p := piiUnionInter π S
-      set m_p := generateFrom p with hS_eq_generate
-      have h_indep : @Indep Ω m_p (m a) m0 μ := by
-        have hp : IsPiSystem p := isPiSystem_piiUnionInter π h_pi S
-        have h_le' : ∀ i, generateFrom (π i) ≤ m0 := fun i => (h_generate i).symm.trans_le (h_le i)
-        have hm_p : m_p ≤ m0 := generateFrom_piiUnionInter_le π h_le' S
-        exact IndepSets.indep hm_p (h_le a) hp (h_pi a) hS_eq_generate (h_generate a)
-            (iIndepSets.piiUnionInter_of_not_mem h_ind ha_notin_S)
-      refine @Indep.symm Ω _ _ m0 μ h_indep (f a) (⋂ n ∈ S, f n)
-        (hf_m a (Finset.mem_insert_self a S)) ?_
-      have h_le_p : ∀ i ∈ S, m i ≤ m_p := by
-        intro n hn
-        rw [hS_eq_generate, h_generate n]
-        exact le_generateFrom_piiUnionInter _ hn
-      have h_S_f : ∀ i ∈ S, MeasurableSet[m_p] (f i) :=
-        fun i hi => (h_le_p i hi) (f i) (hf_m_S i hi)
-      exact S.measurableSet_biInter h_S_f
+    (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) :
+    iIndep m μ :=
+  kernel.iIndepSets.iIndep m h_le π h_pi h_generate h_ind
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_sets.Indep ProbabilityTheory.IndepSets.indep
 
@@ -593,13 +486,10 @@ We prove the following equivalences on `IndepSet`, for measurable sets `s, t`.
 
 variable {s t : Set Ω} (S T : Set (Set Ω))
 
-theorem indepSet_iff_indepSets_singleton {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
+theorem indepSet_iff_indepSets_singleton {_m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by volume_tac)
     [IsProbabilityMeasure μ] : IndepSet s t μ ↔ IndepSets {s} {t} μ :=
-  ⟨Indep.indepSets, fun h =>
-    IndepSets.indep (generateFrom_le fun u hu => by rwa [Set.mem_singleton_iff.mp hu])
-      (generateFrom_le fun u hu => by rwa [Set.mem_singleton_iff.mp hu]) (IsPiSystem.singleton s)
-      (IsPiSystem.singleton t) rfl rfl h⟩
+  kernel.indepSet_iff_indepSets_singleton hs_meas ht_meas _ _
 #align probability_theory.indep_set_iff_indep_sets_singleton ProbabilityTheory.indepSet_iff_indepSets_singleton
 
 theorem indepSet_iff_measure_inter_eq_mul {_m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
@@ -611,32 +501,22 @@ theorem indepSet_iff_measure_inter_eq_mul {_m0 : MeasurableSpace Ω} (hs_meas :
 theorem IndepSets.indepSet_of_mem {_m0 : MeasurableSpace Ω} (hs : s ∈ S) (ht : t ∈ T)
     (hs_meas : MeasurableSet s) (ht_meas : MeasurableSet t)
     (μ : Measure Ω := by volume_tac) [IsProbabilityMeasure μ]
-    (h_indep : IndepSets S T μ) : IndepSet s t μ :=
-  (indepSet_iff_measure_inter_eq_mul hs_meas ht_meas μ).mpr (h_indep s t hs ht)
+    (h_indep : IndepSets S T μ) :
+    IndepSet s t μ :=
+  kernel.IndepSets.indepSet_of_mem _ _ hs ht hs_meas ht_meas _ _ h_indep
 #align probability_theory.indep_sets.indep_set_of_mem ProbabilityTheory.IndepSets.indepSet_of_mem
 
-theorem Indep.indepSet_of_measurableSet {m₁ m₂ m0 : MeasurableSpace Ω} {μ : Measure Ω}
+theorem Indep.indepSet_of_measurableSet {m₁ m₂ _m0 : MeasurableSpace Ω} {μ : Measure Ω}
     (h_indep : Indep m₁ m₂ μ) {s t : Set Ω} (hs : MeasurableSet[m₁] s)
-    (ht : MeasurableSet[m₂] t) : IndepSet s t μ := by
-  refine fun s' t' hs' ht' => h_indep s' t' ?_ ?_
-  · refine @generateFrom_induction _ (fun u => MeasurableSet[m₁] u) {s} ?_ ?_ ?_ ?_ _ hs'
-    · simp only [Set.mem_singleton_iff, forall_eq, hs]
-    · exact @MeasurableSet.empty _ m₁
-    · exact fun u hu => hu.compl
-    · exact fun f hf => MeasurableSet.iUnion hf
-  · refine @generateFrom_induction _ (fun u => MeasurableSet[m₂] u) {t} ?_ ?_ ?_ ?_ _ ht'
-    · simp only [Set.mem_singleton_iff, forall_eq, ht]
-    · exact @MeasurableSet.empty _ m₂
-    · exact fun u hu => hu.compl
-    · exact fun f hf => MeasurableSet.iUnion hf
+    (ht : MeasurableSet[m₂] t) :
+    IndepSet s t μ :=
+  kernel.Indep.indepSet_of_measurableSet h_indep hs ht
 #align probability_theory.indep.indep_set_of_measurable_set ProbabilityTheory.Indep.indepSet_of_measurableSet
 
 theorem indep_iff_forall_indepSet (m₁ m₂ : MeasurableSpace Ω) {_m0 : MeasurableSpace Ω}
     (μ : Measure Ω) :
     Indep m₁ m₂ μ ↔ ∀ s t, MeasurableSet[m₁] s → MeasurableSet[m₂] t → IndepSet s t μ :=
-  ⟨fun h => fun _s _t hs ht => h.indepSet_of_measurableSet hs ht, fun h s t hs ht =>
-    h s t hs ht s t (measurableSet_generateFrom (Set.mem_singleton s))
-      (measurableSet_generateFrom (Set.mem_singleton t))⟩
+  kernel.indep_iff_forall_indepSet m₁ m₂ _ _
 #align probability_theory.indep_iff_forall_indep_set ProbabilityTheory.indep_iff_forall_indepSet
 
 end IndepSet
@@ -653,11 +533,10 @@ variable {β β' γ γ' : Type _} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {
 theorem indepFun_iff_measure_inter_preimage_eq_mul {mβ : MeasurableSpace β}
     {mβ' : MeasurableSpace β'} :
     IndepFun f g μ ↔
-      ∀ s t,
-        MeasurableSet s → MeasurableSet t → μ (f ⁻¹' s ∩ g ⁻¹' t) = μ (f ⁻¹' s) * μ (g ⁻¹' t) := by
-  constructor <;> intro h
-  · refine' fun s t hs ht => h (f ⁻¹' s) (g ⁻¹' t) ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩
-  · rintro _ _ ⟨s, hs, rfl⟩ ⟨t, ht, rfl⟩; exact h s t hs ht
+      ∀ s t, MeasurableSet s → MeasurableSet t
+        → μ (f ⁻¹' s ∩ g ⁻¹' t) = μ (f ⁻¹' s) * μ (g ⁻¹' t) := by
+  simp only [IndepFun, kernel.indepFun_iff_measure_inter_preimage_eq_mul, ae_dirac_eq,
+    Filter.eventually_pure, kernel.const_apply]
 #align probability_theory.indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.indepFun_iff_measure_inter_preimage_eq_mul
 
 theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → Type _}
@@ -665,30 +544,8 @@ theorem iIndepFun_iff_measure_inter_preimage_eq_mul {ι : Type _} {β : ι → T
     iIndepFun m f μ ↔
       ∀ (S : Finset ι) {sets : ∀ i : ι, Set (β i)} (_H : ∀ i, i ∈ S → MeasurableSet[m i] (sets i)),
         μ (⋂ i ∈ S, f i ⁻¹' sets i) = ∏ i in S, μ (f i ⁻¹' sets i) := by
-  refine' ⟨fun h S sets h_meas => h _ fun i hi_mem => ⟨sets i, h_meas i hi_mem, rfl⟩, _⟩
-  intro h S setsΩ h_meas
-  classical
-    let setsβ : ∀ i : ι, Set (β i) := fun i =>
-      dite (i ∈ S) (fun hi_mem => (h_meas i hi_mem).choose) fun _ => Set.univ
-    have h_measβ : ∀ i ∈ S, MeasurableSet[m i] (setsβ i) := by
-      intro i hi_mem
-      simp_rw [dif_pos hi_mem]
-      exact (h_meas i hi_mem).choose_spec.1
-    have h_preim : ∀ i ∈ S, setsΩ i = f i ⁻¹' setsβ i := by
-      intro i hi_mem
-      simp_rw [dif_pos hi_mem]
-      exact (h_meas i hi_mem).choose_spec.2.symm
-    have h_left_eq : μ (⋂ i ∈ S, setsΩ i) = μ (⋂ i ∈ S, f i ⁻¹' setsβ i) := by
-      congr with x
-      simp_rw [Set.mem_iInter]
-      constructor <;> intro h i hi_mem <;> specialize h i hi_mem
-      · rwa [h_preim i hi_mem] at h
-      · rwa [h_preim i hi_mem]
-    have h_right_eq : (∏ i in S, μ (setsΩ i)) = ∏ i in S, μ (f i ⁻¹' setsβ i) := by
-      refine' Finset.prod_congr rfl fun i hi_mem => _
-      rw [h_preim i hi_mem]
-    rw [h_left_eq, h_right_eq]
-    exact h S h_measβ
+  simp only [iIndepFun, kernel.iIndepFun_iff_measure_inter_preimage_eq_mul, ae_dirac_eq,
+    Filter.eventually_pure, kernel.const_apply]
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul
 
@@ -696,10 +553,8 @@ theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : Measur
     [IsProbabilityMeasure μ] (hf : Measurable f) (hg : Measurable g) :
     IndepFun f g μ ↔
       ∀ s t, MeasurableSet s → MeasurableSet t → IndepSet (f ⁻¹' s) (g ⁻¹' t) μ := by
-  refine' indepFun_iff_measure_inter_preimage_eq_mul.trans _
-  constructor <;> intro h s t hs ht <;> specialize h s t hs ht
-  · rwa [indepSet_iff_measure_inter_eq_mul (hf hs) (hg ht) μ]
-  · rwa [← indepSet_iff_measure_inter_eq_mul (hf hs) (hg ht) μ]
+  simp only [IndepFun, IndepSet, kernel.indepFun_iff_indepSet_preimage hf hg, ae_dirac_eq,
+    Filter.eventually_pure, kernel.const_apply]
 #align probability_theory.indep_fun_iff_indep_set_preimage ProbabilityTheory.indepFun_iff_indepSet_preimage
 
 @[symm]
@@ -709,21 +564,16 @@ nonrec theorem IndepFun.symm {_ : MeasurableSpace β} {f g : Ω → β} (hfg : I
 
 theorem IndepFun.ae_eq {mβ : MeasurableSpace β} {f g f' g' : Ω → β} (hfg : IndepFun f g μ)
     (hf : f =ᵐ[μ] f') (hg : g =ᵐ[μ] g') : IndepFun f' g' μ := by
-  rintro _ _ ⟨A, hA, rfl⟩ ⟨B, hB, rfl⟩
-  have h1 : f ⁻¹' A =ᵐ[μ] f' ⁻¹' A := hf.fun_comp A
-  have h2 : g ⁻¹' B =ᵐ[μ] g' ⁻¹' B := hg.fun_comp B
-  rw [← measure_congr h1, ← measure_congr h2, ← measure_congr (h1.inter h2)]
-  exact hfg _ _ ⟨_, hA, rfl⟩ ⟨_, hB, rfl⟩
+  refine kernel.IndepFun.ae_eq hfg ?_ ?_ <;>
+    simp only [ae_dirac_eq, Filter.eventually_pure, kernel.const_apply]
+  exacts [hf, hg]
 #align probability_theory.indep_fun.ae_eq ProbabilityTheory.IndepFun.ae_eq
 
-theorem IndepFun.comp {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
-    {mγ : MeasurableSpace γ} {mγ' : MeasurableSpace γ'} {φ : β → γ} {ψ : β' → γ'}
+theorem IndepFun.comp {_mβ : MeasurableSpace β} {_mβ' : MeasurableSpace β'}
+    {_mγ : MeasurableSpace γ} {_mγ' : MeasurableSpace γ'} {φ : β → γ} {ψ : β' → γ'}
     (hfg : IndepFun f g μ) (hφ : Measurable φ) (hψ : Measurable ψ) :
-    IndepFun (φ ∘ f) (ψ ∘ g) μ := by
-  rintro _ _ ⟨A, hA, rfl⟩ ⟨B, hB, rfl⟩
-  apply hfg
-  · exact ⟨φ ⁻¹' A, hφ hA, Set.preimage_comp.symm⟩
-  · exact ⟨ψ ⁻¹' B, hψ hB, Set.preimage_comp.symm⟩
+    IndepFun (φ ∘ f) (ψ ∘ g) μ :=
+  kernel.IndepFun.comp hfg hφ hψ
 #align probability_theory.indep_fun.comp ProbabilityTheory.IndepFun.comp
 
 /-- If `f` is a family of mutually independent random variables (`iIndepFun m f μ`) and `S, T` are
@@ -732,117 +582,16 @@ tuple `(f i)_i` for `i ∈ T`. -/
 theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (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, build 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
-    rw [generateFrom_pi.symm, comap_generateFrom]
-    congr
-  -- To prove independence, we prove independence of the generating π-systems.
-  refine IndepSets.indep (Measurable.comap_le (measurable_pi_iff.mpr fun i => hf_meas i))
-    (Measurable.comap_le (measurable_pi_iff.mpr fun i => hf_meas i)) hπS_pi hπT_pi hπS_gen hπT_gen
-    ?_
-  rintro _ _ ⟨s, ⟨sets_s, hs1, hs2⟩, rfl⟩ ⟨t, ⟨sets_t, ht1, ht2⟩, rfl⟩
-  simp only [Set.mem_univ_pi, Set.mem_setOf_eq] at hs1 ht1
-  rw [← hs2, ← ht2]
-  classical
-    let sets_s' : ∀ i : ι, Set (β i) := fun i =>
-      dite (i ∈ S) (fun hi => sets_s ⟨i, hi⟩) fun _ => Set.univ
-    have h_sets_s'_eq : ∀ {i} (hi : i ∈ S), sets_s' i = sets_s ⟨i, hi⟩ := by
-      intro i hi; simp_rw [dif_pos hi]
-    have h_sets_s'_univ : ∀ {i} (_hi : i ∈ T), sets_s' i = Set.univ := by
-      intro i hi; simp_rw [dif_neg (Finset.disjoint_right.mp hST hi)]
-    let sets_t' : ∀ i : ι, Set (β i) := fun i =>
-      dite (i ∈ T) (fun hi => sets_t ⟨i, hi⟩) fun _ => Set.univ
-    have h_sets_t'_univ : ∀ {i} (_hi : i ∈ S), sets_t' i = Set.univ := by
-      intro i hi; simp_rw [dif_neg (Finset.disjoint_left.mp hST hi)]
-    have h_meas_s' : ∀ i ∈ S, MeasurableSet (sets_s' i) := by
-      intro i hi; rw [h_sets_s'_eq hi]; exact hs1 _
-    have h_meas_t' : ∀ i ∈ T, MeasurableSet (sets_t' i) := by
-      intro i hi; simp_rw [dif_pos hi]; exact ht1 _
-    have h_eq_inter_S : (fun (ω : Ω) (i : ↥S) =>
-      f (↑i) ω) ⁻¹' Set.pi Set.univ sets_s = ⋂ i ∈ S, f i ⁻¹' sets_s' i := by
-      ext1 x
-      simp_rw [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
-      constructor <;> intro h
-      · intro i hi; simp only [h_sets_s'_eq hi, Set.mem_preimage]; exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩; specialize h i hi; rwa [dif_pos hi] at h
-    have h_eq_inter_T : (fun (ω : Ω) (i : ↥T) => f (↑i) ω) ⁻¹' Set.pi Set.univ sets_t
-      = ⋂ i ∈ T, f i ⁻¹' sets_t' i := by
-      ext1 x
-      simp only [Set.mem_preimage, Set.mem_univ_pi, Set.mem_iInter]
-      constructor <;> intro h
-      · intro i hi; simp_rw [dif_pos hi]; exact h ⟨i, hi⟩
-      · rintro ⟨i, hi⟩; specialize h i hi; simp_rw [dif_pos hi] at h; exact h
-    rw [iIndepFun_iff_measure_inter_preimage_eq_mul] at hf_Indep
-    rw [h_eq_inter_S, h_eq_inter_T, hf_Indep S h_meas_s', hf_Indep T h_meas_t']
-    have h_Inter_inter :
-      ((⋂ i ∈ S, f i ⁻¹' sets_s' i) ∩ ⋂ i ∈ T, f i ⁻¹' sets_t' i) =
-        ⋂ i ∈ S ∪ T, f i ⁻¹' (sets_s' i ∩ sets_t' i) := by
-      ext1 x
-      simp_rw [Set.mem_inter_iff, Set.mem_iInter, Set.mem_preimage, Finset.mem_union]
-      constructor <;> intro h
-      · intro i hi
-        cases' hi with hiS hiT
-        · replace h := h.1 i hiS
-          simp_rw [dif_pos hiS, dif_neg (Finset.disjoint_left.mp hST hiS)]
-          exact ⟨by rwa [dif_pos hiS] at h, Set.mem_univ _⟩
-        · replace h := h.2 i hiT
-          simp_rw [dif_pos hiT, dif_neg (Finset.disjoint_right.mp hST hiT)]
-          exact ⟨Set.mem_univ _, by rwa [dif_pos hiT] at h⟩
-      · exact ⟨fun i hi => (h i (Or.inl hi)).1, fun i hi => (h i (Or.inr hi)).2⟩
-    rw [h_Inter_inter, hf_Indep (S ∪ T)]
-    swap
-    · intro i hi_mem
-      rw [Finset.mem_union] at hi_mem
-      cases' hi_mem with hi_mem hi_mem
-      · rw [h_sets_t'_univ hi_mem, Set.inter_univ]; exact h_meas_s' i hi_mem
-      · rw [h_sets_s'_univ hi_mem, Set.univ_inter]; exact h_meas_t' i hi_mem
-    rw [Finset.prod_union hST]
-    congr 1
-    · refine' Finset.prod_congr rfl fun i hi => _
-      rw [h_sets_t'_univ hi, Set.inter_univ]
-    · refine' Finset.prod_congr rfl fun i hi => _
-      rw [h_sets_s'_univ hi, Set.univ_inter]
+    IndepFun (fun a (i : S) => f i a) (fun a (i : T) => f i a) μ :=
+  kernel.iIndepFun.indepFun_finset S T hST hf_Indep hf_meas
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 
 theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFun (fun a => (f i a, f j a)) (f k) μ := by
-  classical
-    have h_right : f k =
-      (fun p : ∀ j : ({k} : Finset ι), β j => p ⟨k, Finset.mem_singleton_self k⟩) ∘
-      fun a (j : ({k} : Finset ι)) => f j a := rfl
-    have h_meas_right :  Measurable fun p : ∀ j : ({k} : Finset ι),
-      β j => p ⟨k, Finset.mem_singleton_self k⟩ := measurable_pi_apply _
-    let s : Finset ι := {i, j}
-    have h_left : (fun ω => (f i ω, f j ω)) = (fun p : ∀ l : s, β l =>
-      (p ⟨i, Finset.mem_insert_self i _⟩,
-      p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩)) ∘ fun a (j : s) => f j a := by
-      ext1 a
-      simp only [Prod.mk.inj_iff]
-      constructor
-    have h_meas_left : Measurable fun p : ∀ l : s, β l =>
-      (p ⟨i, Finset.mem_insert_self i _⟩,
-      p ⟨j, Finset.mem_insert_of_mem (Finset.mem_singleton_self _)⟩) :=
-        Measurable.prod (measurable_pi_apply _) (measurable_pi_apply _)
-    rw [h_left, h_right]
-    refine' (hf_Indep.indepFun_finset s {k} _ hf_meas).comp h_meas_left h_meas_right
-    rw [Finset.disjoint_singleton_right]
-    simp only [Finset.mem_insert, Finset.mem_singleton, not_or]
-    exact ⟨hik.symm, hjk.symm⟩
+    IndepFun (fun a => (f i a, f j a)) (f k) μ :=
+  kernel.iIndepFun.indepFun_prod hf_Indep hf_meas i j k hik hjk
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
 
@@ -850,11 +599,8 @@ set_option linter.uppercaseLean3 false in
 theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
     [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
-    IndepFun (f i * f j) (f k) μ := by
-  have : IndepFun (fun ω => (f i ω, f j ω)) (f k) μ :=
-    hf_Indep.indepFun_prod hf_meas i j k hik hjk
-  change IndepFun ((fun p : β × β => p.fst * p.snd) ∘ fun ω => (f i ω, f j ω)) (id ∘ f k) μ
-  exact IndepFun.comp this (measurable_fst.mul measurable_snd) measurable_id
+    IndepFun (f i * f j) (f k) μ :=
+  kernel.iIndepFun.mul hf_Indep hf_meas i j k hik hjk
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.mul ProbabilityTheory.iIndepFun.mul
 set_option linter.uppercaseLean3 false in
@@ -864,24 +610,9 @@ set_option linter.uppercaseLean3 false in
 theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
-    (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by
-  classical
-    have h_right : f i =
-      (fun p : ∀ _j : ({i} : Finset ι), β => p ⟨i, Finset.mem_singleton_self i⟩) ∘
-      fun a (j : ({i} : Finset ι)) => f j a := rfl
-    have h_meas_right : Measurable fun p : ∀ _j : ({i} : Finset ι), β
-      => p ⟨i, Finset.mem_singleton_self i⟩ := measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
-    have h_left : ∏ j in s, f j = (fun p : ∀ _j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a := by
-      ext1 a
-      simp only [Function.comp_apply]
-      have : (∏ j : ↥s, f (↑j) a) = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
-      rw [this, Finset.prod_coe_sort]
-    have h_meas_left : Measurable fun p : ∀ _j : s, β => ∏ j, p j :=
-      Finset.univ.measurable_prod fun (j : ↥s) (_H : j ∈ Finset.univ) => measurable_pi_apply j
-    rw [h_left, h_right]
-    exact
-      (hf_Indep.indepFun_finset s {i} (Finset.disjoint_singleton_left.mpr hi).symm hf_meas).comp
-        h_meas_left h_meas_right
+    (hi : i ∉ s) :
+    IndepFun (∏ j in s, f j) (f i) μ :=
+  kernel.iIndepFun.indepFun_finset_prod_of_not_mem hf_Indep hf_meas hi
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset_prod_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_prod_of_not_mem
 set_option linter.uppercaseLean3 false in
@@ -892,26 +623,16 @@ theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ℕ → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) :
     IndepFun (∏ j in Finset.range n, f j) (f n) μ :=
-  hf_Indep.indepFun_finset_prod_of_not_mem hf_meas Finset.not_mem_range_self
+  kernel.iIndepFun.indepFun_prod_range_succ hf_Indep hf_meas n
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_prod_range_succ ProbabilityTheory.iIndepFun.indepFun_prod_range_succ
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_sum_range_succ ProbabilityTheory.iIndepFun.indepFun_sum_range_succ
 
 theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β} {s : ι → Set Ω}
-    (hs : iIndepSet s μ) : iIndepFun (fun _n => m) (fun n => (s n).indicator fun _ω => 1) μ := by
-  classical
-    rw [iIndepFun_iff_measure_inter_preimage_eq_mul]
-    rintro S π _hπ
-    simp_rw [Set.indicator_const_preimage_eq_union]
-    refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s i)ᶜ ∅) fun i _hi => _
-    have hsi : MeasurableSet[generateFrom {s i}] (s i) :=
-      measurableSet_generateFrom (Set.mem_singleton _)
-    refine'
-      MeasurableSet.union (MeasurableSet.ite' (fun _ => hsi) fun _ => _)
-        (MeasurableSet.ite' (fun _ => hsi.compl) fun _ => _)
-    · exact @MeasurableSet.empty _ (generateFrom {s i})
-    · exact @MeasurableSet.empty _ (generateFrom {s i})
+    (hs : iIndepSet s μ) :
+    iIndepFun (fun _n => m) (fun n => (s n).indicator fun _ω => 1) μ :=
+  kernel.iIndepSet.iIndepFun_indicator hs
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.Indep_fun_indicator ProbabilityTheory.iIndepSet.iIndepFun_indicator
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2021 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
-
-! This file was ported from Lean 3 source module probability.independence.basic
-! leanprover-community/mathlib commit 2f8347015b12b0864dfaf366ec4909eb70c78740
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.MeasureTheory.Constructions.Pi
 
+#align_import probability.independence.basic from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740"
+
 /-!
 # Independence of sets of sets and measure spaces (σ-algebras)
 
fix: ∑' precedence (#5615)
  • Also remove most superfluous parentheses around big operators (, and variants).
  • roughly the used regex: ([^a-zA-Zα-ωΑ-Ω'𝓝ℳ₀𝕂ₛ)]) \(([∑∏][^()∑∏]*,[^()∑∏:]*)\) ([⊂⊆=<≤]) replaced by $1 $2 $3
Diff
@@ -874,7 +874,7 @@ theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι
       fun a (j : ({i} : Finset ι)) => f j a := rfl
     have h_meas_right : Measurable fun p : ∀ _j : ({i} : Finset ι), β
       => p ⟨i, Finset.mem_singleton_self i⟩ := measurable_pi_apply ⟨i, Finset.mem_singleton_self i⟩
-    have h_left : (∏ j in s, f j) = (fun p : ∀ _j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a := by
+    have h_left : ∏ j in s, f j = (fun p : ∀ _j : s, β => ∏ j, p j) ∘ fun a (j : s) => f j a := by
       ext1 a
       simp only [Function.comp_apply]
       have : (∏ j : ↥s, f (↑j) a) = (∏ j : ↥s, f ↑j) a := by rw [Finset.prod_apply]
fix: precedences of ⨆⋃⋂⨅ (#5614)
Diff
@@ -276,7 +276,7 @@ theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ
     have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
     have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
     have h_inter :
-      (⋂ (t : ι) (_ : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
+      ⋂ (t : ι) (_ : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂ =
         ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
       by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
     have h_prod :
fix: change compl precedence (#5586)

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

Diff
@@ -907,7 +907,7 @@ theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β
     rw [iIndepFun_iff_measure_inter_preimage_eq_mul]
     rintro S π _hπ
     simp_rw [Set.indicator_const_preimage_eq_union]
-    refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s iᶜ) ∅) fun i _hi => _
+    refine' @hs S (fun i => ite (1 ∈ π i) (s i) ∅ ∪ ite ((0 : β) ∈ π i) (s i)ᶜ ∅) fun i _hi => _
     have hsi : MeasurableSet[generateFrom {s i}] (s i) :=
       measurableSet_generateFrom (Set.mem_singleton _)
     refine'
chore: tidy various files (#4757)
Diff
@@ -147,7 +147,7 @@ section Indep
 @[symm]
 theorem IndepSets.symm {s₁ s₂ : Set (Set Ω)} [MeasurableSpace Ω] {μ : Measure Ω}
     (h : IndepSets s₁ s₂ μ) : IndepSets s₂ s₁ μ := by
-  intro t1 t2 ht1 ht2;
+  intro t1 t2 ht1 ht2
   rw [Set.inter_comm, mul_comm]; exact h t2 t1 ht2 ht1
 #align probability_theory.indep_sets.symm ProbabilityTheory.IndepSets.symm
 
@@ -259,7 +259,7 @@ theorem indepSets_singleton_iff [MeasurableSpace Ω] {s t : Set Ω} {μ : Measur
 
 end Indep
 
-/-! ### Deducing `indep` from `Indep` -/
+/-! ### Deducing `Indep` from `iIndep` -/
 
 
 section FromIndepToIndep
@@ -340,7 +340,7 @@ section FromPiSystemsToMeasurableSpaces
 /-! ### Independence of generating π-systems implies independence of measurable space structures -/
 
 
-private theorem indep_sets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω}
+private theorem IndepSets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω}
     {μ : Measure Ω} [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h2 : m2 ≤ m)
     (hp2 : IsPiSystem p2) (hpm2 : m2 = generateFrom p2) (hyp : IndepSets p1 p2 μ) {t1 t2 : Set Ω}
     (ht1 : t1 ∈ p1) (ht2m : MeasurableSet[m2] t2) : μ (t1 ∩ t2) = μ t1 * μ t2 := by
@@ -375,7 +375,7 @@ theorem IndepSets.indep {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {
     rw [hpm1]
     exact measurableSet_generateFrom ht
   rw [Measure.restrict_apply ht1, Measure.smul_apply, smul_eq_mul, mul_comm]
-  exact indep_sets.indep_aux h2 hp2 hpm2 hyp ht ht2
+  exact IndepSets.indep_aux h2 hp2 hpm2 hyp ht ht2
 #align probability_theory.indep_sets.indep ProbabilityTheory.IndepSets.indep
 
 theorem IndepSets.indep' {_m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
@@ -588,9 +588,9 @@ section IndepSet
 
 /-! ### Independence of measurable sets
 
-We prove the following equivalences on `indep_set`, for measurable sets `s, t`.
-* `indep_set s t μ ↔ μ (s ∩ t) = μ s * μ t`,
-* `indep_set s t μ ↔ indep_sets {s} {t} μ`.
+We prove the following equivalences on `IndepSet`, for measurable sets `s, t`.
+* `IndepSet s t μ ↔ μ (s ∩ t) = μ s * μ t`,
+* `IndepSet s t μ ↔ IndepSets {s} {t} μ`.
 -/
 
 
style: allow _ for an argument in notation3 & replace _foo with _ in notation3 (#4652)
Diff
@@ -276,7 +276,7 @@ theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} [MeasurableSpace Ω] {μ
     have h1 : t₁ = ite (i = i) t₁ t₂ := by simp only [if_true, eq_self_iff_true]
     have h2 : t₂ = ite (j = i) t₁ t₂ := by simp only [hij.symm, if_false]
     have h_inter :
-      (⋂ (t : ι) (_H : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
+      (⋂ (t : ι) (_ : t ∈ ({i, j} : Finset ι)), ite (t = i) t₁ t₂) =
         ite (i = i) t₁ t₂ ∩ ite (j = i) t₁ t₂ :=
       by simp only [Finset.set_biInter_singleton, Finset.set_biInter_insert]
     have h_prod :
style: recover Is of Foo which is ported from is_foo (#4639)

I have misported is_foo to Foo because I misunderstood the rule for IsLawfulFoo. This PR recover Is of Foo which is ported from is_foo. This PR also renames some misported theorems.

Diff
@@ -157,7 +157,7 @@ theorem Indep.symm {m₁ m₂ : MeasurableSpace Ω} [MeasurableSpace Ω] {μ : M
 #align probability_theory.indep.symm ProbabilityTheory.Indep.symm
 
 theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ : Measure Ω}
-    [ProbabilityMeasure μ] : Indep m' ⊥ μ := by
+    [IsProbabilityMeasure μ] : Indep m' ⊥ μ := by
   intro s t _hs ht
   rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht
   cases' ht with ht ht
@@ -166,16 +166,16 @@ theorem indep_bot_right (m' : MeasurableSpace Ω) {m : MeasurableSpace Ω} {μ :
 #align probability_theory.indep_bot_right ProbabilityTheory.indep_bot_right
 
 theorem indep_bot_left (m' : MeasurableSpace Ω) {_m : MeasurableSpace Ω} {μ : Measure Ω}
-    [ProbabilityMeasure μ] : Indep ⊥ m' μ := (indep_bot_right m').symm
+    [IsProbabilityMeasure μ] : Indep ⊥ m' μ := (indep_bot_right m').symm
 #align probability_theory.indep_bot_left ProbabilityTheory.indep_bot_left
 
-theorem indepSet_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
+theorem indepSet_empty_right {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (s : Set Ω) : IndepSet s ∅ μ := by
   simp only [IndepSet, generateFrom_singleton_empty];
   exact indep_bot_right _
 #align probability_theory.indep_set_empty_right ProbabilityTheory.indepSet_empty_right
 
-theorem indepSet_empty_left {_m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
+theorem indepSet_empty_left {_m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (s : Set Ω) : IndepSet ∅ s μ := (indepSet_empty_right s).symm
 #align probability_theory.indep_set_empty_left ProbabilityTheory.indepSet_empty_left
 
@@ -341,14 +341,14 @@ section FromPiSystemsToMeasurableSpaces
 
 
 private theorem indep_sets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω}
-    {μ : Measure Ω} [ProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h2 : m2 ≤ m) (hp2 : IsPiSystem p2)
-    (hpm2 : m2 = generateFrom p2) (hyp : IndepSets p1 p2 μ) {t1 t2 : Set Ω} (ht1 : t1 ∈ p1)
-    (ht2m : MeasurableSet[m2] t2) : μ (t1 ∩ t2) = μ t1 * μ t2 := by
+    {μ : Measure Ω} [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h2 : m2 ≤ m)
+    (hp2 : IsPiSystem p2) (hpm2 : m2 = generateFrom p2) (hyp : IndepSets p1 p2 μ) {t1 t2 : Set Ω}
+    (ht1 : t1 ∈ p1) (ht2m : MeasurableSet[m2] t2) : μ (t1 ∩ t2) = μ t1 * μ t2 := by
   let μ_inter := μ.restrict t1
   let ν := μ t1 • μ
   have h_univ : μ_inter Set.univ = ν Set.univ := by
     rw [Measure.restrict_apply_univ, Measure.smul_apply, smul_eq_mul, measure_univ, mul_one]
-  haveI : FiniteMeasure μ_inter := @Restrict.finiteMeasure Ω _ t1 μ ⟨measure_lt_top μ t1⟩
+  haveI : IsFiniteMeasure μ_inter := @Restrict.isFiniteMeasure Ω _ t1 μ ⟨measure_lt_top μ t1⟩
   rw [Set.inter_comm, ← Measure.restrict_apply (h2 t2 ht2m)]
   refine' ext_on_measurableSpace_of_generate_finite m p2 (fun t ht => _) h2 hpm2 hp2 h_univ ht2m
   have ht2 : MeasurableSet[m] t := by
@@ -359,7 +359,7 @@ private theorem indep_sets.indep_aux {m2 : MeasurableSpace Ω} {m : MeasurableSp
   exact hyp t1 t ht1 ht
 
 theorem IndepSets.indep {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {μ : Measure Ω}
-    [ProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : IsPiSystem p1)
+    [IsProbabilityMeasure μ] {p1 p2 : Set (Set Ω)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : IsPiSystem p1)
     (hp2 : IsPiSystem p2) (hpm1 : m1 = generateFrom p1) (hpm2 : m2 = generateFrom p2)
     (hyp : IndepSets p1 p2 μ) : Indep m1 m2 μ := by
   intro t1 t2 ht1 ht2
@@ -367,7 +367,7 @@ theorem IndepSets.indep {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {
   let ν := μ t2 • μ
   have h_univ : μ_inter Set.univ = ν Set.univ := by
     rw [Measure.restrict_apply_univ, Measure.smul_apply, smul_eq_mul, measure_univ, mul_one]
-  haveI : FiniteMeasure μ_inter := @Restrict.finiteMeasure Ω _ t2 μ ⟨measure_lt_top μ t2⟩
+  haveI : IsFiniteMeasure μ_inter := @Restrict.isFiniteMeasure Ω _ t2 μ ⟨measure_lt_top μ t2⟩
   rw [mul_comm, ← Measure.restrict_apply (h1 t1 ht1)]
   refine' ext_on_measurableSpace_of_generate_finite m p1 (fun t ht => _) h1 hpm1 hp1 h_univ ht1
   have ht1 : MeasurableSet[m] t := by
@@ -378,7 +378,7 @@ theorem IndepSets.indep {m1 m2 : MeasurableSpace Ω} {m : MeasurableSpace Ω} {
   exact indep_sets.indep_aux h2 hp2 hpm2 hyp ht ht2
 #align probability_theory.indep_sets.indep ProbabilityTheory.IndepSets.indep
 
-theorem IndepSets.indep' {_m : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
+theorem IndepSets.indep' {_m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     {p1 p2 : Set (Set Ω)} (hp1m : ∀ s ∈ p1, MeasurableSet s) (hp2m : ∀ s ∈ p2, MeasurableSet s)
     (hp1 : IsPiSystem p1) (hp2 : IsPiSystem p2) (hyp : IndepSets p1 p2 μ) :
     Indep (generateFrom p1) (generateFrom p2) μ :=
@@ -387,7 +387,7 @@ theorem IndepSets.indep' {_m : MeasurableSpace Ω} {μ : Measure Ω} [Probabilit
 
 variable {m0 : MeasurableSpace Ω} {μ : Measure Ω}
 
-theorem indepSets_piiUnionInter_of_disjoint [ProbabilityMeasure μ] {s : ι → Set (Set Ω)}
+theorem indepSets_piiUnionInter_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set (Set Ω)}
     {S T : Set ι} (h_indep : iIndepSets s μ) (hST : Disjoint S T) :
     IndepSets (piiUnionInter s S) (piiUnionInter s T) μ := by
   rintro t1 t2 ⟨p1, hp1, f1, ht1_m, ht1_eq⟩ ⟨p2, hp2, f2, ht2_m, ht2_eq⟩
@@ -425,7 +425,7 @@ theorem indepSets_piiUnionInter_of_disjoint [ProbabilityMeasure μ] {s : ι →
       h_indep p1 ht1_m, ht2_eq, ← h_indep p2 ht2_m]
 #align probability_theory.indep_sets_pi_Union_Inter_of_disjoint ProbabilityTheory.indepSets_piiUnionInter_of_disjoint
 
-theorem iIndepSet.indep_generateFrom_of_disjoint [ProbabilityMeasure μ] {s : ι → Set Ω}
+theorem iIndepSet.indep_generateFrom_of_disjoint [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (S T : Set ι) (hST : Disjoint S T) :
     Indep (generateFrom { t | ∃ n ∈ S, s n = t }) (generateFrom { t | ∃ k ∈ T, s k = t }) μ := by
   rw [← generateFrom_piiUnionInter_singleton_left, ← generateFrom_piiUnionInter_singleton_left]
@@ -441,7 +441,7 @@ theorem iIndepSet.indep_generateFrom_of_disjoint [ProbabilityMeasure μ] {s : ι
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_of_disjoint ProbabilityTheory.iIndepSet.indep_generateFrom_of_disjoint
 
-theorem indep_iSup_of_disjoint [ProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
+theorem indep_iSup_of_disjoint [IsProbabilityMeasure μ] {m : ι → MeasurableSpace Ω}
     (h_le : ∀ i, m i ≤ m0) (h_indep : iIndep m μ) {S T : Set ι} (hST : Disjoint S T) :
     Indep (⨆ i ∈ S, m i) (⨆ i ∈ T, m i) μ := by
   refine'
@@ -454,7 +454,7 @@ theorem indep_iSup_of_disjoint [ProbabilityMeasure μ] {m : ι → MeasurableSpa
 #align probability_theory.indep_supr_of_disjoint ProbabilityTheory.indep_iSup_of_disjoint
 
 theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : MeasurableSpace Ω}
-    {μ : Measure Ω} [ProbabilityMeasure μ] (h_indep : ∀ i, Indep (m i) m' μ)
+    {μ : Measure Ω} [IsProbabilityMeasure μ] (h_indep : ∀ i, Indep (m i) m' μ)
     (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0) (hm : Directed (· ≤ ·) m) :
     Indep (⨆ i, m i) m' μ := by
   let p : ι → Set (Set Ω) := fun n => { t | MeasurableSet[m n] t }
@@ -477,7 +477,7 @@ theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 :
   exact (generateFrom_iUnion_measurableSet _).symm
 #align probability_theory.indep_supr_of_directed_le ProbabilityTheory.indep_iSup_of_directed_le
 
-theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [ProbabilityMeasure μ] {s : ι → Set Ω}
+theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) :
     Indep (generateFrom {s i}) (generateFrom { t | ∃ j < i, s j = t }) μ := by
   convert iIndepSet.indep_generateFrom_of_disjoint hsm hs {i} { j | j < i }
@@ -486,7 +486,7 @@ theorem iIndepSet.indep_generateFrom_lt [Preorder ι] [ProbabilityMeasure μ] {s
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_lt ProbabilityTheory.iIndepSet.indep_generateFrom_lt
 
-theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [ProbabilityMeasure μ] {s : ι → Set Ω}
+theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [IsProbabilityMeasure μ] {s : ι → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (i : ι) {k : ι} (hk : i < k) :
     Indep (generateFrom {s k}) (generateFrom { t | ∃ j ≤ i, s j = t }) μ := by
   convert iIndepSet.indep_generateFrom_of_disjoint hsm hs {k} { j | j ≤ i }
@@ -495,7 +495,7 @@ theorem iIndepSet.indep_generateFrom_le [LinearOrder ι] [ProbabilityMeasure μ]
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_le ProbabilityTheory.iIndepSet.indep_generateFrom_le
 
-theorem iIndepSet.indep_generateFrom_le_nat [ProbabilityMeasure μ] {s : ℕ → Set Ω}
+theorem iIndepSet.indep_generateFrom_le_nat [IsProbabilityMeasure μ] {s : ℕ → Set Ω}
     (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (n : ℕ) :
     Indep (generateFrom {s (n + 1)}) (generateFrom { t | ∃ k ≤ n, s k = t }) μ :=
   iIndepSet.indep_generateFrom_le hsm hs _ n.lt_succ_self
@@ -503,14 +503,14 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_set.indep_generate_from_le_nat ProbabilityTheory.iIndepSet.indep_generateFrom_le_nat
 
 theorem indep_iSup_of_monotone [SemilatticeSup ι] {Ω} {m : ι → MeasurableSpace Ω}
-    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
+    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
     (hm : Monotone m) : Indep (⨆ i, m i) m' μ :=
   indep_iSup_of_directed_le h_indep h_le h_le' (Monotone.directed_le hm)
 #align probability_theory.indep_supr_of_monotone ProbabilityTheory.indep_iSup_of_monotone
 
 theorem indep_iSup_of_antitone [SemilatticeInf ι] {Ω} {m : ι → MeasurableSpace Ω}
-    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [ProbabilityMeasure μ]
+    {m' m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
     (h_indep : ∀ i, Indep (m i) m' μ) (h_le : ∀ i, m i ≤ m0) (h_le' : m' ≤ m0)
     (hm : Antitone m) : Indep (⨆ i, m i) m' μ :=
   indep_iSup_of_directed_le h_indep h_le h_le' (directed_of_inf hm)
@@ -551,8 +551,8 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_sets.pi_Union_Inter_of_not_mem ProbabilityTheory.iIndepSets.piiUnionInter_of_not_mem
 
 /-- The measurable space structures generated by independent pi-systems are independent. -/
-theorem iIndepSets.iIndep [ProbabilityMeasure μ] (m : ι → MeasurableSpace Ω) (h_le : ∀ i, m i ≤ m0)
-    (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
+theorem iIndepSets.iIndep [IsProbabilityMeasure μ] (m : ι → MeasurableSpace Ω)
+    (h_le : ∀ i, m i ≤ m0) (π : ι → Set (Set Ω)) (h_pi : ∀ n, IsPiSystem (π n))
     (h_generate : ∀ i, m i = generateFrom (π i)) (h_ind : iIndepSets π μ) : iIndep m μ := by
   classical
     intro s f
@@ -598,7 +598,7 @@ variable {s t : Set Ω} (S T : Set (Set Ω))
 
 theorem indepSet_iff_indepSets_singleton {m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by volume_tac)
-    [ProbabilityMeasure μ] : IndepSet s t μ ↔ IndepSets {s} {t} μ :=
+    [IsProbabilityMeasure μ] : IndepSet s t μ ↔ IndepSets {s} {t} μ :=
   ⟨Indep.indepSets, fun h =>
     IndepSets.indep (generateFrom_le fun u hu => by rwa [Set.mem_singleton_iff.mp hu])
       (generateFrom_le fun u hu => by rwa [Set.mem_singleton_iff.mp hu]) (IsPiSystem.singleton s)
@@ -607,13 +607,13 @@ theorem indepSet_iff_indepSets_singleton {m0 : MeasurableSpace Ω} (hs_meas : Me
 
 theorem indepSet_iff_measure_inter_eq_mul {_m0 : MeasurableSpace Ω} (hs_meas : MeasurableSet s)
     (ht_meas : MeasurableSet t) (μ : Measure Ω := by volume_tac)
-    [ProbabilityMeasure μ] : IndepSet s t μ ↔ μ (s ∩ t) = μ s * μ t :=
+    [IsProbabilityMeasure μ] : IndepSet s t μ ↔ μ (s ∩ t) = μ s * μ t :=
   (indepSet_iff_indepSets_singleton hs_meas ht_meas μ).trans indepSets_singleton_iff
 #align probability_theory.indep_set_iff_measure_inter_eq_mul ProbabilityTheory.indepSet_iff_measure_inter_eq_mul
 
 theorem IndepSets.indepSet_of_mem {_m0 : MeasurableSpace Ω} (hs : s ∈ S) (ht : t ∈ T)
     (hs_meas : MeasurableSet s) (ht_meas : MeasurableSet t)
-    (μ : Measure Ω := by volume_tac) [ProbabilityMeasure μ]
+    (μ : Measure Ω := by volume_tac) [IsProbabilityMeasure μ]
     (h_indep : IndepSets S T μ) : IndepSet s t μ :=
   (indepSet_iff_measure_inter_eq_mul hs_meas ht_meas μ).mpr (h_indep s t hs ht)
 #align probability_theory.indep_sets.indep_set_of_mem ProbabilityTheory.IndepSets.indepSet_of_mem
@@ -696,7 +696,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun_iff_measure_inter_preimage_eq_mul ProbabilityTheory.iIndepFun_iff_measure_inter_preimage_eq_mul
 
 theorem indepFun_iff_indepSet_preimage {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
-    [ProbabilityMeasure μ] (hf : Measurable f) (hg : Measurable g) :
+    [IsProbabilityMeasure μ] (hf : Measurable f) (hg : Measurable g) :
     IndepFun f g μ ↔
       ∀ s t, MeasurableSet s → MeasurableSet t → IndepSet (f ⁻¹' s) (g ⁻¹' t) μ := by
   refine' indepFun_iff_measure_inter_preimage_eq_mul.trans _
@@ -732,7 +732,7 @@ theorem IndepFun.comp {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
 /-- 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 [ProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+theorem iIndepFun.indepFun_finset [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (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
@@ -820,7 +820,7 @@ theorem iIndepFun.indepFun_finset [ProbabilityMeasure μ] {ι : Type _} {β : ι
 set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset ProbabilityTheory.iIndepFun.indepFun_finset
 
-theorem iIndepFun.indepFun_prod [ProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
+theorem iIndepFun.indepFun_prod [IsProbabilityMeasure μ] {ι : Type _} {β : ι → Type _}
     {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i} (hf_Indep : iIndepFun m f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (fun a => (f i a, f j a)) (f k) μ := by
@@ -850,7 +850,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_prod ProbabilityTheory.iIndepFun.indepFun_prod
 
 @[to_additive]
-theorem iIndepFun.mul [ProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
+theorem iIndepFun.mul [IsProbabilityMeasure μ] {ι : Type _} {β : Type _} {m : MeasurableSpace β}
     [Mul β] [MeasurableMul₂ β] {f : ι → Ω → β} (hf_Indep : iIndepFun (fun _ => m) f μ)
     (hf_meas : ∀ i, Measurable (f i)) (i j k : ι) (hik : i ≠ k) (hjk : j ≠ k) :
     IndepFun (f i * f j) (f k) μ := by
@@ -864,7 +864,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.add ProbabilityTheory.iIndepFun.add
 
 @[to_additive]
-theorem iIndepFun.indepFun_finset_prod_of_not_mem [ProbabilityMeasure μ] {ι : Type _} {β : Type _}
+theorem iIndepFun.indepFun_finset_prod_of_not_mem [IsProbabilityMeasure μ] {ι : Type _} {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ι → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) {s : Finset ι} {i : ι}
     (hi : i ∉ s) : IndepFun (∏ j in s, f j) (f i) μ := by
@@ -891,7 +891,7 @@ set_option linter.uppercaseLean3 false in
 #align probability_theory.Indep_fun.indep_fun_finset_sum_of_not_mem ProbabilityTheory.iIndepFun.indepFun_finset_sum_of_not_mem
 
 @[to_additive]
-theorem iIndepFun.indepFun_prod_range_succ [ProbabilityMeasure μ] {β : Type _}
+theorem iIndepFun.indepFun_prod_range_succ [IsProbabilityMeasure μ] {β : Type _}
     {m : MeasurableSpace β} [CommMonoid β] [MeasurableMul₂ β] {f : ℕ → Ω → β}
     (hf_Indep : iIndepFun (fun _ => m) f μ) (hf_meas : ∀ i, Measurable (f i)) (n : ℕ) :
     IndepFun (∏ j in Finset.range n, f j) (f n) μ :=
feat: port Probability.Independence.ZeroOne (#4606)
Diff
@@ -90,7 +90,7 @@ set_option linter.uppercaseLean3 false in
 `t₁ ∈ p₁, t₂ ∈ s₂`, then `μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/
 def IndepSets [MeasurableSpace Ω] (s1 s2 : Set (Set Ω)) (μ : Measure Ω := by volume_tac) : Prop
     := ∀ t1 t2 : Set Ω, t1 ∈ s1 → t2 ∈ s2 → μ (t1 ∩ t2) = μ t1 * μ t2
-#align probability_theory.indep_sets ProbabilityTheory.iIndepSets
+#align probability_theory.indep_sets ProbabilityTheory.IndepSets
 
 /-- A family of measurable space structures (i.e. of σ-algebras) is independent with respect to a
 measure `μ` (typically defined on a finer σ-algebra) if the family of sets of measurable sets they
feat: port Probability.Independence.Basic (#4557)

The names of many definitions and lemmas in the Mathlib3 file contained Indep so Mathport added Cat at a bunch of places that had to be removed. The Mathlib4 equivalent is iIndep see this thread

Dependencies 10 + 646

647 files ported (98.5%)
292566 lines ported (98.2%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file