Download data/lean/OAI/Probability/CriticalPercolation/ProductMeasure/Density.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.07 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/ProductMeasure/Density.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/ProductMeasure/Density.lean
-
curl -L -o Density.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/ProductMeasure/Density.lean
7.07 kB
| import Mathlib | |
| namespace OAI | |
| section | |
| section | |
| open Set MeasureTheory ProbabilityTheory | |
| open scoped BigOperators | |
| open Set | |
| namespace CriticalPercolation.FiniteProduct | |
| variable {E A : Type*} [Fintype E] [Fintype A] | |
| noncomputable def density (w : E β A β β) (Ο : E β A) : β := β e, w e (Ο e) | |
| noncomputable def expect (w : E β A β β) (f : (E β A) β β) : β := by | |
| classical | |
| exact β Ο, density w Ο * f Ο | |
| omit [Fintype A] in | |
| lemma density_nonneg {w : E β A β β} (h : β e a, 0 β€ w e a) (Ο : E β A) : | |
| 0 β€ density w Ο := Finset.prod_nonneg fun e _ => h e (Ο e) | |
| lemma sum_density [DecidableEq E] (w : E β A β β) (h : β e, β a, w e a = 1) : | |
| β Ο, density w Ο = 1 := by | |
| classical | |
| unfold density | |
| rw [β Fintype.prod_sum] | |
| simp [h] | |
| lemma expect_const (w : E β A β β) (h : β e, β a, w e a = 1) (c : β) : | |
| expect w (fun _ => c) = c := by | |
| classical | |
| rw [expect, β Finset.sum_mul, sum_density w h, one_mul] | |
| lemma expect_add (w : E β A β β) (f g : (E β A) β β) : | |
| expect w (fun Ο => f Ο + g Ο) = expect w f + expect w g := by | |
| classical | |
| simp [expect, mul_add, Finset.sum_add_distrib] | |
| lemma expect_sub (w : E β A β β) (f g : (E β A) β β) : | |
| expect w (fun Ο => f Ο - g Ο) = expect w f - expect w g := by | |
| classical | |
| simp [expect, mul_sub, Finset.sum_sub_distrib] | |
| lemma expect_mono {w : E β A β β} (hw : β e a, 0 β€ w e a) | |
| {f g : (E β A) β β} (hfg : β Ο, f Ο β€ g Ο) : expect w f β€ expect w g := by | |
| classical | |
| exact Finset.sum_le_sum fun Ο _ => mul_le_mul_of_nonneg_left (hfg Ο) (density_nonneg hw Ο) | |
| omit [Fintype A] in | |
| lemma density_split (w : E β A β β) (P : E β Prop) [DecidablePred P] (Ο : E β A) : | |
| density w Ο = | |
| density (fun e : {e // P e} => w e) (fun e => Ο e) * | |
| density (fun e : {e // Β¬ P e} => w e) (fun e => Ο e) := by | |
| exact (Fintype.prod_subtype_mul_prod_subtype P (fun e => w e (Ο e))).symm | |
| lemma expect_split (w : E β A β β) (P : E β Prop) [DecidablePred P] | |
| (f : (E β A) β β) : | |
| expect w f = | |
| expect (fun e : {e // P e} => w e) (fun a => | |
| expect (fun e : {e // Β¬ P e} => w e) (fun b => | |
| f ((Equiv.piEquivPiSubtypeProd P (fun _ => A)).symm (a, b)))) := by | |
| classical | |
| let e := Equiv.piEquivPiSubtypeProd P (fun _ => A) | |
| unfold expect | |
| rw [β e.symm.sum_comp] | |
| rw [Fintype.sum_prod_type] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro a _ | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro b _ | |
| have hβ : (fun i : {e // P e} => e.symm (a, b) i) = a := | |
| congrArg Prod.fst (e.apply_symm_apply (a, b)) | |
| have hβ : (fun i : {e // Β¬ P e} => e.symm (a, b) i) = b := | |
| congrArg Prod.snd (e.apply_symm_apply (a, b)) | |
| rw [density_split w P, hβ, hβ, mul_assoc] | |
| lemma expect_factor (w : E β A β β) (P : E β Prop) [DecidablePred P] | |
| (f : ({e // P e} β A) β β) (g : ({e // Β¬ P e} β A) β β) : | |
| expect w (fun Ο => f (fun e => Ο e) * g (fun e => Ο e)) = | |
| expect (fun e : {e // P e} => w e) f * | |
| expect (fun e : {e // Β¬ P e} => w e) g := by | |
| classical | |
| rw [expect_split w P] | |
| have hβ : β (a : {e // P e} β A) (b : {e // Β¬ P e} β A), | |
| (fun i : {e // P e} => | |
| (Equiv.piEquivPiSubtypeProd P (fun _ => A)).symm (a, b) i) = a := by | |
| intro a b | |
| exact congrArg Prod.fst ((Equiv.piEquivPiSubtypeProd P (fun _ => A)).apply_symm_apply (a, b)) | |
| have hβ : β (a : {e // P e} β A) (b : {e // Β¬ P e} β A), | |
| (fun i : {e // Β¬ P e} => | |
| (Equiv.piEquivPiSubtypeProd P (fun _ => A)).symm (a, b) i) = b := by | |
| intro a b | |
| exact congrArg Prod.snd ((Equiv.piEquivPiSubtypeProd P (fun _ => A)).apply_symm_apply (a, b)) | |
| simp_rw [hβ, hβ] | |
| unfold expect | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro a _ | |
| rw [Finset.mul_sum, Finset.mul_sum] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro b _ | |
| ring | |
| lemma expect_indep (w : E β A β β) (hw : β e, β a, w e a = 1) | |
| (S : Set E) {f g : (E β A) β β} | |
| (hf : DependsOn f S) (hg : DependsOn g SαΆ) : | |
| expect w (fun Ο => f Ο * g Ο) = expect w f * expect w g := by | |
| classical | |
| obtain β¨f', rflβ© := dependsOn_iff_exists_comp.mp hf | |
| obtain β¨g', rflβ© := dependsOn_iff_exists_comp.mp hg | |
| have hwβ : β e : S, β a, w e a = 1 := fun e => hw e | |
| have hwβ : β e : {e // e β S}, β a, w e a = 1 := fun e => hw e | |
| have hf' : expect w (fun Ο => f' (fun e => Ο e)) = | |
| expect (fun e : S => w e) f' := by | |
| have h := expect_factor w (fun e => e β S) f' (fun _ => 1) | |
| simpa only [mul_one, expect_const _ hwβ] using h | |
| have hg' : expect w (fun Ο => g' (fun e => Ο e)) = | |
| expect (fun e : {e // e β S} => w e) g' := by | |
| have h := expect_factor w (fun e => e β S) (fun _ => 1) g' | |
| simp only [one_mul, expect_const _ hwβ] at h | |
| convert h using 1 | |
| rfl | |
| change expect w (fun Ο => f' (fun e => Ο e) * g' (fun e => Ο e)) = | |
| expect w (fun Ο => f' (fun e => Ο e)) * expect w (fun Ο => g' (fun e => Ο e)) | |
| rw [hf', hg'] | |
| convert expect_factor w (fun e => e β S) f' g' using 1 | |
| rfl | |
| lemma expect_mul_const (w : E β A β β) (f : (E β A) β β) (c : β) : | |
| expect w (fun Ο => f Ο * c) = expect w f * c := by | |
| classical | |
| unfold expect | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro Ο _ | |
| ring | |
| lemma expect_partition {B : Type*} [Fintype B] [DecidableEq B] (w : E β A β β) | |
| (r : (E β A) β B) (f : B β (E β A) β β) : | |
| expect w (fun Ο => f (r Ο) Ο) = | |
| β b, expect w (fun Ο => if r Ο = b then f b Ο else 0) := by | |
| classical | |
| simp only [expect] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro Ο _ | |
| rw [β Finset.mul_sum] | |
| simp | |
| lemma expect_exposure {B : Type*} [Fintype B] (w : E β A β β) | |
| (hw : β e, β a, w e a = 1) (r : (E β A) β B) (D : B β Set E) | |
| (hr : β b, DependsOn (fun Ο => r Ο = b) (D b)) | |
| (f : B β (E β A) β β) (hf : β b, DependsOn (f b) (D b)αΆ) : | |
| expect w (fun Ο => f (r Ο) Ο) = | |
| expect w (fun Ο => expect w (f (r Ο))) := by | |
| classical | |
| rw [expect_partition w r f, | |
| expect_partition w r (fun b _ => expect w (f b))] | |
| apply Finset.sum_congr (by ext; simp) | |
| intro b _ | |
| have hi : DependsOn (fun Ο => if r Ο = b then (1 : β) else 0) (D b) := by | |
| intro Ο Ο' hΟ | |
| change (if r Ο = b then (1 : β) else 0) = (if r Ο' = b then 1 else 0) | |
| have hh : (r Ο = b) = (r Ο' = b) := hr b hΟ | |
| rw [hh] | |
| have hleft : (fun Ο => if r Ο = b then f b Ο else 0) = | |
| (fun Ο => (if r Ο = b then (1 : β) else 0) * f b Ο) := by | |
| funext Ο | |
| split_ifs <;> simp | |
| have hright : (fun Ο => if r Ο = b then expect w (f b) else 0) = | |
| (fun Ο => (if r Ο = b then (1 : β) else 0) * expect w (f b)) := by | |
| funext Ο | |
| split_ifs <;> simp | |
| rw [hleft, hright, expect_indep w hw (D b) hi (hf b), expect_mul_const] | |
| end CriticalPercolation.FiniteProduct | |
| end | |
| end | |
| end OAI | |