File size: 8,509 Bytes
bf6216d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | module
public import PFR.Mathlib.Probability.Independence.Basic
public section
open MeasureTheory ProbabilityTheory
namespace ProbabilityTheory.iIndepFun
variable {Ω : Type*} [MeasureSpace Ω]
{G : Type*} [hG : MeasurableSpace G]
variable {Z₁ Z₂ Z₃ Z₄ : Ω → G} (h_indep : iIndepFun ![Z₁, Z₂, Z₃, Z₄])
include h_indep
lemma reindex_four_abcd :
iIndepFun ![Z₁, Z₂, Z₃, Z₄] := h_indep
lemma reindex_four_abdc :
iIndepFun ![Z₁, Z₂, Z₄, Z₃] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![0, 1, 3, 2]
invFun := ![0, 1, 3, 2]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_acbd :
iIndepFun ![Z₁, Z₃, Z₂, Z₄] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![0, 2, 1, 3]
invFun := ![0, 2, 1, 3]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_acdb :
iIndepFun ![Z₁, Z₃, Z₄, Z₂] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![0, 2, 3, 1]
invFun := ![0, 3, 1, 2]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_adbc :
iIndepFun ![Z₁, Z₄, Z₂, Z₃] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![0, 3, 1, 2]
invFun := ![0, 2, 3, 1]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_adcb :
iIndepFun ![Z₁, Z₄, Z₃, Z₂] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![0, 3, 2, 1]
invFun := ![0, 3, 2, 1]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_bacd :
iIndepFun ![Z₂, Z₁, Z₃, Z₄] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![1, 0, 2, 3]
invFun := ![1, 0, 2, 3]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_badc :
iIndepFun ![Z₂, Z₁, Z₄, Z₃] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![1, 0, 3, 2]
invFun := ![1, 0, 3, 2]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_bcad :
iIndepFun ![Z₂, Z₃, Z₁, Z₄] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![1, 2, 0, 3]
invFun := ![2, 0, 1, 3]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_bcda :
iIndepFun ![Z₂, Z₃, Z₄, Z₁] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![1, 2, 3, 0]
invFun := ![3, 0, 1, 2]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_bdac :
iIndepFun ![Z₂, Z₄, Z₁, Z₃] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![1, 3, 0, 2]
invFun := ![2, 0, 3, 1]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_bdca :
iIndepFun ![Z₂, Z₄, Z₃, Z₁] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![1, 3, 2, 0]
invFun := ![3, 0, 2, 1]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_cadb :
iIndepFun ![Z₃, Z₁, Z₄, Z₂] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![2, 0, 3, 1]
invFun := ![1, 3, 0, 2]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_cabd :
iIndepFun ![Z₃, Z₁, Z₂, Z₄] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![2, 0, 1, 3]
invFun := ![1, 2, 0, 3]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_cbad :
iIndepFun ![Z₃, Z₂, Z₁, Z₄] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![2, 1, 0, 3]
invFun := ![2, 1, 0, 3]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_dabc :
iIndepFun ![Z₄, Z₁, Z₂, Z₃] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![3, 0, 1, 2]
invFun := ![1, 2, 3, 0]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_dacb :
iIndepFun ![Z₄, Z₁, Z₃, Z₂] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![3, 0, 2, 1]
invFun := ![1, 3, 2, 0]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_dbac :
iIndepFun ![Z₄, Z₂, Z₁, Z₃] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![3, 1, 0, 2]
invFun := ![2, 1, 3, 0]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
lemma reindex_four_dbca :
iIndepFun ![Z₄, Z₂, Z₃, Z₁] := by
let σ : Fin 4 ≃ Fin 4 :=
{ toFun := ![3, 1, 2, 0]
invFun := ![3, 1, 2, 0]
left_inv i := by fin_cases i <;> rfl
right_inv i := by fin_cases i <;> rfl }
refine .of_precomp σ.symm.surjective ?_
convert h_indep using 1
ext i
fin_cases i <;> rfl
private abbrev κ : Fin 3 → Type
| 0 | 1 => Fin 1
| 2 => Fin 2
private def κ_equiv : (Σ i, κ i) ≃ Fin 4 where
toFun := fun x ↦ match x with
| Sigma.mk 0 _ => 0
| Sigma.mk 1 _ => 1
| Sigma.mk 2 ⟨0, _⟩ => 2
| Sigma.mk 2 ⟨1, _⟩ => 3
invFun := ![Sigma.mk 0 ⟨0, zero_lt_one⟩, Sigma.mk 1 ⟨0, zero_lt_one⟩,
Sigma.mk 2 ⟨0, zero_lt_two⟩, Sigma.mk 2 ⟨1, one_lt_two⟩]
left_inv := by rintro ⟨i, j⟩; fin_cases i <;> fin_cases j <;> rfl
right_inv i := by fin_cases i <;> rfl
private instance fintype_kappa : ∀ (i : Fin 3), Fintype (κ i)
| 0 | 1 | 2 => inferInstanceAs (Fintype (Fin _))
/-- If `(Z₁, Z₂, Z₃, Z₄)` are independent, so are `(Z₁, Z₂, φ Z₃ Z₄)` for any measurable `φ`. -/
lemma apply_two_last
(hZ₁ : Measurable Z₁) (hZ₂ : Measurable Z₂) (hZ₃ : Measurable Z₃) (hZ₄ : Measurable Z₄)
{phi : G → G → G} (hphi : Measurable phi.uncurry) :
iIndepFun ![Z₁, Z₂, (fun ω ↦ phi (Z₃ ω) (Z₄ ω))] := by
-- deduce from the assumption the independence of `Z₁`, `Z₂` and `(Z₃, Z₄)`.
have T := (h_indep.precomp κ_equiv.injective).pi' (m := fun _ _ ↦ hG) ?_; swap
· rintro ⟨i, j⟩; fin_cases i <;> fin_cases j <;> assumption
-- apply to this triplet of independent variables the function `phi` applied to `Z₃` and `Z₄`
-- which does not change the other variables. It retains independence, proving the conclusion.
let phi_third : ∀ (i : Fin 3), (κ i → G) → G
| 0 | 1 => (fun f ↦ f ⟨0, zero_lt_one⟩)
| 2 => (fun f ↦ phi (f ⟨0, zero_lt_two⟩) (f ⟨1, one_lt_two⟩))
convert T.comp phi_third ?_ with i
· fin_cases i <;> rfl
· intro i
match i with
| 0 | 1 => exact measurable_pi_apply _
| 2 =>
have : Measurable (fun (p : Fin 2 → G) ↦ (p 0, p 1)) := by fun_prop
exact hphi.comp this
end ProbabilityTheory.iIndepFun
|