Download data/lean/OAI/Probability/CriticalZ3/ShellProbability.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalZ3/ShellProbability.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalZ3/ShellProbability.lean
-
curl -L -o ShellProbability.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalZ3/ShellProbability.lean
13.5 kB
| import OAI.Probability.CriticalZ3.TrialCounts | |
| namespace OAI | |
| open MeasureTheory ProbabilityTheory Classical Filter | |
| open scoped ENNReal BigOperators Matrix | |
| namespace CriticalZ3.LatticeGraph | |
| open MeasureTheory ProbabilityTheory Classical InfiniteConditioning | |
| variable (G : LatticeGraph) (m : Model) | |
| theorem shell_blocking_lower (p : m.Bit β Set.Icc (0 : β) 1) | |
| (C : Box) (o : G.Node) (q : Set.Icc (0 : β) 1) {pβ : β} | |
| (hq : (q : β) β€ pβ) (hpβ : pβ < 1) (L : β) | |
| (hp : β y, C.Exterior y β p (C.entryBit m y) = q) : | |
| (1-pβ)^L * (ProductCylinder.law p).real | |
| {Ο | 0 < (G.entrants m C Ο o).card β§ (G.entrants m C Ο o).card < L} β€ | |
| (ProductCylinder.law p).real | |
| {Ο | 0 < (G.entrants m C Ο o).card β§ (G.entrants m C Ο o).card < L β§ | |
| G.Blocked m C Ο o} := by | |
| let J := G.outsideBits m C | |
| let ΞΎ (a : J β Bool) := ProductCylinder.extend J a | |
| let P (a : J β Bool) := 0 < (G.entrants m C (ΞΎ a) o).card β§ | |
| (G.entrants m C (ΞΎ a) o).card < L | |
| let A (a : J β Bool) := allValue (G.entryBits m C (ΞΎ a) o) false | |
| have h := select_probability_lower p J P A (fun a => measurableSet_allValue _ _) (b := (1-pβ)^L) ?_ | |
| Β· have hY (Ο : m.Config) : G.entrants m C Ο o = G.entrants m C (ΞΎ (J.restrict Ο)) o := | |
| ProductCylinder.determinedBy_eq_extend (G.entrants_determined m C o) Ο | |
| have hK (Ο : m.Config) : G.entryBits m C Ο o = G.entryBits m C (ΞΎ (J.restrict Ο)) o := | |
| ProductCylinder.determinedBy_eq_extend (G.entryBits_determined m C o) Ο | |
| have heP : {Ο | P (J.restrict Ο)} = | |
| {Ο | 0 < (G.entrants m C Ο o).card β§ (G.entrants m C Ο o).card < L} := by | |
| ext Ο; simp only [P,Set.mem_ofPred_eq]; rw [βhY Ο] | |
| have heA : {Ο | P (J.restrict Ο) β§ Ο β A (J.restrict Ο)} = | |
| {Ο | 0 < (G.entrants m C Ο o).card β§ (G.entrants m C Ο o).card < L β§ | |
| G.Blocked m C Ο o} := by | |
| ext Ο | |
| simp only [P,A,allValue,Blocked,Set.mem_ofPred_eq] | |
| rw [βhY Ο,βhK Ο] | |
| exact and_assoc | |
| rwa [heP,heA] at h | |
| Β· intro a ha | |
| rw [fixed_determined_probability p J (G.entryBits m C (ΞΎ a) o) | |
| (G.entryBits_disjoint_outside m C (ΞΎ a) o).symm _ _ (allValue_determined _ _)] | |
| rw [allValue_probability_constant p _ q ?_ false] | |
| Β· change (1-pβ)^L β€ (1-(q : β))^(G.entryBits m C (ΞΎ a) o).card | |
| have h0 : 0 β€ 1-pβ := by linarith | |
| have h1 : 1-(q : β) β€ 1 := by linarith [q.property.1] | |
| calc | |
| _ β€ (1-(q : β))^L := pow_le_pow_leftβ h0 (by linarith) L | |
| _ β€ _ := pow_le_pow_of_le_one (by linarith [q.property.2]) h1 | |
| ((G.entryBits_card m C (ΞΎ a) o).trans (Nat.le_of_lt ha.2)) | |
| Β· intro e he | |
| obtain β¨y,hy,rflβ© := Finset.mem_image.mp he | |
| have hyG : y β G.vertices := (Finset.mem_filter.mp hy).1 | |
| exact hp y ((G.mem_entrants m C (ΞΎ a) o β¨y,hyGβ©).mp hy).1 | |
| theorem measurableSet_shell_blocked (C : Box) (o : G.Node) (L : β) : | |
| MeasurableSet {Ο | 0 < (G.entrants m C Ο o).card β§ | |
| (G.entrants m C Ο o).card < L β§ G.Blocked m C Ο o} := by | |
| let J := G.outsideBits m C | |
| let ΞΎ (a : J β Bool) := ProductCylinder.extend J a | |
| let A (a : J β Bool) : Set m.Config := if 0 < (G.entrants m C (ΞΎ a) o).card β§ | |
| (G.entrants m C (ΞΎ a) o).card < L then allValue (G.entryBits m C (ΞΎ a) o) false else β | |
| have h := measurableSet_select J A (fun a => by | |
| dsimp only [A]; split_ifs | |
| Β· exact measurableSet_allValue _ _ | |
| Β· exact MeasurableSet.empty) | |
| have he : {Ο | Ο β A (J.restrict Ο)} = {Ο | 0 < (G.entrants m C Ο o).card β§ | |
| (G.entrants m C Ο o).card < L β§ G.Blocked m C Ο o} := by | |
| ext Ο | |
| have hY := ProductCylinder.determinedBy_eq_extend (G.entrants_determined m C o) Ο | |
| have hK := ProductCylinder.determinedBy_eq_extend (G.entryBits_determined m C o) Ο | |
| change G.entrants m C Ο o = G.entrants m C (ΞΎ (J.restrict Ο)) o at hY | |
| change G.entryBits m C Ο o = G.entryBits m C (ΞΎ (J.restrict Ο)) o at hK | |
| simp only [A,βhY,βhK,Set.mem_ofPred_eq,Blocked,allValue] | |
| split_ifs with hh | |
| Β· tauto | |
| Β· simp only [Set.mem_empty_iff_false]; tauto | |
| rwa [he] at h | |
| /-- Deterministic shell selection for the finite graph in bond and site percolation. -/ | |
| theorem exists_shell (p : m.Bit β Set.Icc (0 : β) 1) | |
| (B : Box) (o : G.Node) (q : Set.Icc (0 : β) 1) {pβ : β} | |
| (hq : (q : β) β€ pβ) (hpβ : pβ < 1) (L a R : β) (haR : a < R) | |
| (ho : Β¬(B.expand R).Contains o.1) | |
| (hp : β j β Finset.Ico a R, β y, (B.expand j).Exterior y β | |
| p ((B.expand j).entryBit m y) = q) : | |
| β j β Finset.Ico a R, (ProductCylinder.law p).real | |
| {Ο | G.Meets m Ο o {x | B.Contains x} β§ (G.entrants m (B.expand j) Ο o).card < L} β€ | |
| 1/((1-pβ)^L*(R-a : β)) := by | |
| let I := β₯(Finset.Ico a R) | |
| have : Nonempty I := β¨β¨a,Finset.mem_Ico.mpr β¨le_rfl,haRβ©β©β© | |
| let Q (i : I) : Set m.Config := | |
| {Ο | G.Meets m Ο o {x | B.Contains x} β§ (G.entrants m (B.expand i.1) Ο o).card < L} | |
| let A (i : I) : Set m.Config := | |
| {Ο | 0 < (G.entrants m (B.expand i.1) Ο o).card β§ | |
| (G.entrants m (B.expand i.1) Ο o).card < L β§ G.Blocked m (B.expand i.1) Ο o} | |
| have hoi (i : I) : Β¬(B.expand i.1).Contains o.1 := fun h => | |
| ho (B.expand_mono (Nat.le_of_lt (Finset.mem_Ico.mp i.2).2) h) | |
| have hAd : Pairwise (fun i j : I => Disjoint (A i) (A j)) := by | |
| intro i j hij | |
| have hi : i.1 β j.1 := fun h => hij (Subtype.ext h) | |
| apply Set.disjoint_left.mpr | |
| intro Ο hΟi hΟj | |
| rcases lt_or_gt_of_ne hi with hlt | hlt | |
| Β· have he := G.blocked_earlier_entrants m hlt (hoi j) hΟj.2.2 | |
| have hpos := hΟi.1 | |
| rw [he,Finset.card_empty] at hpos | |
| exact Nat.not_lt_zero _ hpos | |
| Β· have he := G.blocked_earlier_entrants m hlt (hoi i) hΟi.2.2 | |
| have hpos := hΟj.1 | |
| rw [he,Finset.card_empty] at hpos | |
| exact Nat.not_lt_zero _ hpos | |
| have hblock (i : I) : (1-pβ)^L * (ProductCylinder.law p).real (Q i) β€ | |
| (ProductCylinder.law p).real (A i) := by | |
| have hsub : Q i β {Ο | 0 < (G.entrants m (B.expand i.1) Ο o).card β§ | |
| (G.entrants m (B.expand i.1) Ο o).card < L} := by | |
| intro Ο hΟ | |
| refine β¨Finset.card_pos.mpr (G.meets_entrants_nonempty m (hoi i) ?_),hΟ.2β© | |
| obtain β¨z,hz,hconnβ© := hΟ.1 | |
| exact β¨z,B.contains_expand i.1 hz,hconnβ© | |
| exact (mul_le_mul_of_nonneg_left (measureReal_mono hsub) (pow_nonneg (by linarith) _)).trans | |
| (G.shell_blocking_lower m p (B.expand i.1) o q hq hpβ L (hp i.1 i.2)) | |
| obtain β¨i,hiβ© := ShellEstimates.exists_layer (ProductCylinder.law p) Q A | |
| (fun i => G.measurableSet_shell_blocked m (B.expand i.1) o L) hAd | |
| (pow_pos (by linarith) L) hblock | |
| refine β¨i.1,i.2,?_β© | |
| simpa only [I,Fintype.card_coe,Nat.card_Ico] using hi | |
| end CriticalZ3.LatticeGraph | |
| namespace FiniteAssociation | |
| open Classical | |
| variable {E : Type} | |
| theorem indicator_monotone {P : (E β Bool) β Prop} (hP : Monotone P) : | |
| Monotone (fun Ο => if P Ο then (1 : β) else 0) := by | |
| intro Ο Ο' h | |
| by_cases h' : P Ο | |
| Β· simp [h',hP h h'] | |
| Β· simp only [h',ite_false] | |
| split_ifs <;> norm_num | |
| theorem prob_and_increasing [Fintype E] (p : E β Set.Icc (0 : β) 1) | |
| {P Q : (E β Bool) β Prop} (hP : Monotone P) (hQ : Monotone Q) : | |
| prob p P * prob p Q β€ prob p (fun Ο => P Ο β§ Q Ο) := by | |
| have h := increasing p _ _ (indicator_monotone hP) (indicator_monotone hQ) | |
| change mean p _ * mean p _ β€ mean p _ | |
| convert h using 1 | |
| congr 1 | |
| funext Ο | |
| by_cases hβ : P Ο <;> by_cases hβ : Q Ο <;> simp [hβ,hβ] | |
| end FiniteAssociation | |
| namespace ProductCylinder | |
| open MeasureTheory ProbabilityTheory Classical | |
| variable {E : Type} | |
| theorem probability_congr_parameters (J : Finset E) | |
| (p q : E β Set.Icc (0 : β) 1) (hpq : β e β J, p e = q e) | |
| (A : Set (E β Bool)) (hA : DeterminedBy (F := Prop) J (fun Ο => Ο β A)) : | |
| (law p).real A = (law q).real A := by | |
| simp only [Measure.real_def,probability_determined J _ A (fun Ο Ο' h => eq_iff_iff.mp (hA Ο Ο' h))] | |
| congr 2 | |
| unfold finiteLaw | |
| congr 1 | |
| funext e | |
| rw [hpq e e.2] | |
| theorem determinedBy_mono {J K : Finset E} (hJK : J β K) {F : Type} | |
| {f : (E β Bool) β F} (hf : DeterminedBy J f) : DeterminedBy K f := | |
| fun Ο Ο' h => hf Ο Ο' (fun e he => h e (hJK he)) | |
| theorem increasing_and (J : Finset E) (p : E β Set.Icc (0 : β) 1) | |
| (A B : Set (E β Bool)) | |
| (hA : DeterminedBy (F := Prop) J (fun Ο => Ο β A)) | |
| (hB : DeterminedBy (F := Prop) J (fun Ο => Ο β B)) | |
| (hmA : Monotone (fun Ο => Ο β A)) (hmB : Monotone (fun Ο => Ο β B)) : | |
| (law p).real A*(law p).real B β€ (law p).real (A β© B) := by | |
| have he (C : Set (E β Bool)) (hC : DeterminedBy (F := Prop) J (fun Ο => Ο β C)) : | |
| (law p).real C = FiniteAssociation.prob (fun e : J => p e) (fun ΞΎ => extend J ΞΎ β C) := by | |
| rw [FiniteAssociation.prob_eq_real,Measure.real_def,Measure.real_def, | |
| probability_determined J p C (fun Ο Ο' h => eq_iff_iff.mp (hC Ο Ο' h))] | |
| rfl | |
| have hAB : DeterminedBy (F := Prop) J (fun Ο => Ο β A β© B) := by | |
| intro Ο Ο' h | |
| simp only [Set.mem_inter_iff,hA Ο Ο' h,hB Ο Ο' h] | |
| rw [he A hA,he B hB,he (A β© B) hAB] | |
| exact FiniteAssociation.prob_and_increasing _ (hmA.comp (extend_mono J)) (hmB.comp (extend_mono J)) | |
| /-- The open-seed Harris estimate, with a separate increasing connecting event. -/ | |
| theorem seed_failure_bound (J : Finset E) (p : E β Set.Icc (0 : β) 1) | |
| (O A C : Set (E β Bool)) | |
| (hO : DeterminedBy (F := Prop) J (fun Ο => Ο β O)) | |
| (hA : DeterminedBy (F := Prop) J (fun Ο => Ο β A)) | |
| (hmO : Monotone (fun Ο => Ο β O)) (hmA : Monotone (fun Ο => Ο β A)) | |
| (hsub : O β© A β C) {Ξ³ : β} (hprob : 1-Ξ³ β€ (law p).real A) : | |
| (law p).real (O β© CαΆ) β€ (law p).real O*Ξ³ := by | |
| have hm := measurableSet_determined J A (fun Ο Ο' h => eq_iff_iff.mp (hA Ο Ο' h)) | |
| have ha := increasing_and J p O A hO hA hmO hmA | |
| have hadd := measureReal_inter_add_sdiff (ΞΌ := law p) (s := O) hm | |
| have hsub' : O β© CαΆ β O \ A := by | |
| intro Ο hΟ | |
| exact β¨hΟ.1,fun h => hΟ.2 (hsub β¨hΟ.1,hβ©)β© | |
| have hle := measureReal_mono (ΞΌ := law p) hsub' | |
| have h0 : 0 β€ (law p).real O := measureReal_nonneg | |
| nlinarith | |
| end ProductCylinder | |
| namespace InfiniteConditioning | |
| open MeasureTheory ProbabilityTheory Classical | |
| variable {E : Type} | |
| theorem allValue_true_monotone (J : Finset E) : Monotone (fun Ο => Ο β allValue J true) := by | |
| intro Ο Ο' h hh e he | |
| have hi := h e | |
| rw [hh e he] at hi | |
| exact le_antisymm le_top hi | |
| theorem measurableSet_conditional_test (p : E β Set.Icc (0 : β) 1) (J : Finset E) | |
| (C : Set (E β Bool)) (a : β) : | |
| MeasurableSet {Ο | conditionalProbability p J C Ο β€ a} := by | |
| refine ProductCylinder.measurableSet_determined J _ ?_ | |
| intro Ο Ο' h | |
| simp only [Set.mem_ofPred_eq,conditionalProbability_determined p J C Ο Ο' h] | |
| end InfiniteConditioning | |
| namespace CriticalZ3.LatticeGraph | |
| open MeasureTheory ProbabilityTheory Classical InfiniteConditioning | |
| variable (G : LatticeGraph) (m : Model) | |
| theorem conn_mono {Ο Ο' : m.Config} (h : Ο β€ Ο') {x y : G.Node} | |
| (hc : G.Conn m Ο x y) : G.Conn m Ο' x y := by | |
| have hopen {e : m.Bit} (he : Ο e = true) : Ο' e = true := by | |
| have hi := h e | |
| rw [he] at hi | |
| exact le_antisymm le_top hi | |
| obtain β¨hx,hcβ© := (G.conn_iff m Ο x y).mp hc | |
| refine (G.conn_iff m Ο' x y).mpr β¨?_,?_β© | |
| Β· cases m | |
| Β· trivial | |
| Β· exact hopen hx | |
| Β· apply Relation.ReflTransGen.mono (r := G.Adj m Ο) (p := G.Adj m Ο') ?_ x y hc | |
| intro a b hab | |
| cases m | |
| Β· obtain β¨e,he,hi,hoβ© := hab | |
| exact β¨e,he,hi,hopen hoβ© | |
| Β· exact β¨hab.1,hopen hab.2.1,hopen hab.2.2β© | |
| theorem meets_mono (o : G.Node) (T : Set Vertex) : Monotone (fun Ο => G.Meets m Ο o T) := by | |
| intro Ο Ο' h β¨y,hy,hcβ© | |
| exact β¨y,hy,G.conn_mono m h hcβ© | |
| noncomputable def goodRelays (p : m.Bit β Set.Icc (0 : β) 1) (J : Finset m.Bit) | |
| (T : Set Vertex) (Ο : β) (Ο : m.Config) : Set Vertex := | |
| {v | β a : G.Node, a.1 = v β§ 1-Ο < conditionalProbability p J {Ο | G.Meets m Ο a T} Ο} | |
| theorem goodRelays_determined (p : m.Bit β Set.Icc (0 : β) 1) (J : Finset m.Bit) | |
| (T : Set Vertex) (Ο : β) : ProductCylinder.DeterminedBy J (G.goodRelays m p J T Ο) := by | |
| intro Ο Ο' h | |
| ext v | |
| simp only [goodRelays,Set.mem_ofPred_eq,conditionalProbability_determined p J _ Ο Ο' h] | |
| theorem random_relay_failure (p : m.Bit β Set.Icc (0 : β) 1) (J : Finset m.Bit) | |
| (o : G.Node) (T : Set Vertex) {Ο : β} (hΟ : 0 β€ Ο) : | |
| (ProductCylinder.law p).real | |
| {Ο | G.Meets m Ο o (G.goodRelays m p J T Ο Ο) β§ Β¬G.Meets m Ο o T} β€ Ο := by | |
| let A (a : J β Bool) : Set m.Config := | |
| {Ο | G.Meets m Ο o (G.goodRelays m p J T Ο (ProductCylinder.extend J a)) β§ Β¬G.Meets m Ο o T} | |
| have he : {Ο | G.Meets m Ο o (G.goodRelays m p J T Ο Ο) β§ Β¬G.Meets m Ο o T} = | |
| {Ο | Ο β A (J.restrict Ο)} := by | |
| ext Ο | |
| simp only [A,Set.mem_ofPred_eq, | |
| ProductCylinder.determinedBy_eq_extend (G.goodRelays_determined m p J T Ο) Ο] | |
| rw [he] | |
| apply select_probability_le p J A | |
| Β· intro a | |
| exact (G.measurableSet_meets m _ _).inter (G.measurableSet_meets m _ _).compl | |
| Β· intro a | |
| apply G.failure_comparison m _ o _ T hΟ | |
| intro v β¨u,hu,hhβ© | |
| have heu : u = v := Subtype.ext hu | |
| subst u | |
| exact hh.le | |
| end CriticalZ3.LatticeGraph | |
| end OAI | |