Download data/lean/OAI/Geometry/HyperbolicGroups/Conditioning.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.83 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/HyperbolicGroups/Conditioning.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/HyperbolicGroups/Conditioning.lean
-
curl -L -o Conditioning.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/HyperbolicGroups/Conditioning.lean
4.83 kB
| 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 | |