File size: 4,826 Bytes
4a56cd6 | 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 | import Mathlib
import OAI.Geometry.HyperbolicGroups.Random
namespace OAI
section
section
noncomputable section
open scoped BigOperators
namespace HyperbolicObstruction
namespace FiniteLaw
variable {I : Type*} [DecidableEq I]
def joinTables (S : Finset I) (a : S β Bool) (b : {i : I // i β S} β Bool) : I β Bool :=
(Equiv.piEquivPiSubtypeProd (fun i => i β S) (fun _ => Bool)).symm (a,b)
@[simp] lemma joinTables_in (S : Finset I) (a : S β Bool) (b : {i : I // i β S} β Bool)
(i : S) : joinTables S a b i.val = a i := by
simp [joinTables,Equiv.piEquivPiSubtypeProd_symm_apply,i.property]
@[simp] lemma joinTables_out (S : Finset I) (a : S β Bool) (b : {i : I // i β S} β Bool)
(i : {i : I // i β S}) : joinTables S a b i.val = b i := by
simp [joinTables,Equiv.piEquivPiSubtypeProd_symm_apply,i.property]
variable [Fintype I]
lemma bernoulliProduct_mass_join (p : I β β) (hp : β i, p i β Set.Icc (0 : β) 1)
(S : Finset I) (a : S β Bool) (b : {i : I // i β S} β Bool) :
(bernoulliProduct p hp).mass (joinTables S a b) =
(bernoulliProduct (fun i : S => p i.val) (fun i => hp i.val)).mass a *
(bernoulliProduct (fun i : {i : I // i β S} => p i.val) (fun i => hp i.val)).mass b := by
change (β i, if joinTables S a b i then p i else 1 - p i) = _
rw [β Fintype.prod_subtype_mul_prod_subtype (fun i => i β S)]
simp only [joinTables_in,joinTables_out,bernoulliProduct]
congr 1
apply Finset.prod_congr (by ext; simp)
intros
rfl
lemma bernoulliProduct_expect_split (p : I β β) (hp : β i, p i β Set.Icc (0 : β) 1)
(S : Finset I) (f : (I β Bool) β β) :
(bernoulliProduct p hp).expect f =
(bernoulliProduct (fun i : S => p i.val) (fun i => hp i.val)).expect (fun a =>
(bernoulliProduct (fun i : {i : I // i β S} => p i.val) (fun i => hp i.val)).expect
(fun b => f (joinTables S a b))) := by
unfold expect
rw [β (Equiv.piEquivPiSubtypeProd (fun i => i β S) (fun _ => Bool)).symm.sum_comp
(fun w => (bernoulliProduct p hp).mass w * f w),Fintype.sum_prod_type]
apply Finset.sum_congr rfl
intro a _
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro b _
change (bernoulliProduct p hp).mass (joinTables S a b) * f (joinTables S a b) = _
rw [bernoulliProduct_mass_join]
ring
/-- Exact independence of an arbitrary outside-trial statistic from the event
that every trial in S is present. -/
theorem bernoulliProduct_event_mul (p : I β β) (hp : β i, p i β Set.Icc (0 : β) 1)
(S : Finset I) (f : (I β Bool) β β)
(depends : β w z, (β i, i β S β w i = z i) β f w = f z) :
(bernoulliProduct p hp).expect (fun w => if β i β S, w i = true then f w else 0) =
(β i β S, p i) * (bernoulliProduct p hp).expect f := by
let ΞΌβ := bernoulliProduct (fun i : S => p i.val) (fun i => hp i.val)
let ΞΌβ := bernoulliProduct (fun i : {i : I // i β S} => p i.val) (fun i => hp i.val)
let g (b : {i : I // i β S} β Bool) := f (joinTables S (fun _ => true) b)
have hf (a : S β Bool) (b : {i : I // i β S} β Bool) : f (joinTables S a b) = g b := by
apply depends
intro i hi
exact (joinTables_out S a b β¨i,hiβ©).trans (joinTables_out S (fun _ => true) b β¨i,hiβ©).symm
have he (a : S β Bool) (b : {i : I // i β S} β Bool) :
(β i β S, joinTables S a b i = true) β β i, a i = true := by
constructor
Β· intro h i
simpa only [joinTables_in] using h i.val i.property
Β· intro h i hi
exact (joinTables_in S a b β¨i,hiβ©).trans (h β¨i,hiβ©)
have hmean : (bernoulliProduct p hp).expect f = ΞΌβ.expect g := by
rw [bernoulliProduct_expect_split p hp S]
simp only [hf]
exact ΞΌβ.expect_const _
have hprob : ΞΌβ.expect (fun a => if β i, a i = true then (1 : β) else 0) = β i β S, p i := by
have h := bernoulliProduct_all p hp S
rw [bernoulliProduct_expect_split p hp S] at h
simp only [he] at h
simp only [expect_const] at h
exact h
rw [bernoulliProduct_expect_split p hp S,hmean]
simp only [hf,he]
have hs : β a : S β Bool,
ΞΌβ.expect (fun b => if β i, a i = true then g b else 0) =
(if β i, a i = true then (1 : β) else 0) * ΞΌβ.expect g := by
intro a
split_ifs <;> simp [expect_const]
change ΞΌβ.expect (fun a => ΞΌβ.expect (fun b => if β i, a i = true then g b else 0)) = _
simp_rw [hs]
calc
_ = ΞΌβ.expect (fun a => ΞΌβ.expect g * (if β i, a i = true then (1 : β) else 0)) := by
congr 1; funext a; ring
_ = ΞΌβ.expect g * ΞΌβ.expect (fun a => if β i, a i = true then (1 : β) else 0) := ΞΌβ.expect_mul _ _
_ = _ := by rw [hprob]; ring
end FiniteLaw
end HyperbolicObstruction
end
end
section
end
end
end OAI
|