Download data/lean/OAI/Probability/CriticalPercolation/Exploration/QueryDelta.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.13 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/QueryDelta.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Exploration/QueryDelta.lean
-
curl -L -o QueryDelta.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/QueryDelta.lean
7.13 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.SearchContactMoments | |
| import OAI.Probability.CriticalPercolation.Exploration.CompileContactScoreErase | |
| import OAI.Probability.CriticalPercolation.ProductMeasure.ExposureLawSupport | |
| namespace OAI | |
| section | |
| section | |
| open Set MeasureTheory ProbabilityTheory | |
| open Set | |
| open scoped BigOperators | |
| open scoped Classical | |
| namespace CriticalPercolation.LazyDFS | |
| open scoped Classical | |
| open FiniteProduct SearchTree | |
| variable {V E : Type*} [Fintype E] [Fintype V] [DecidableEq V] [DecidableEq E] | |
| theorem search_contact_moments_exposure (G : BondGraph V E) | |
| (order : List (Dart V E)) (ho : β v e z, G.ends e = s(v,z) β (v,e,z) β order) | |
| (B O : Set V) (a : V) (ha : a β O) (hB : B β O) (Ο : Set E) | |
| (hΟ : β e β G.cutEdges O, Β¬Ο e) (p : β) (hp : 0 < p β§ p < 1) | |
| (w : E β Prop β β) (h0 : β e, w e False = 1-p) (h1 : β e, w e True = p) : | |
| let F := fun Ο : Set E => β b β B, (G.openGraph Ο).Reachable a b | |
| let T := search G order a B | |
| let v := exposureLaw w (G.incidentEdges O) Ο | |
| expect v (T.contactScore p (G.cutEdges O) F w) = prob w F β§ | |
| expect v (fun Ο => (T.contactScore p (G.cutEdges O) F w Ο)^2) β€ 3 := by | |
| dsimp only | |
| let F := fun Ο : Set E => β b β B, (G.openGraph Ο).Reachable a b | |
| let v := exposureLaw w (G.incidentEdges O) Ο | |
| let v' := forceClosed w (G.cutEdges O) | |
| have hw := homogeneous_normalized w p h0 h1 | |
| have hv : β e, β b, v e b = 1 := exposureLaw_normalized w _ Ο hw | |
| have hv' : β e, β b, v' e b = 1 := forceClosed_normalized w _ hw | |
| have hc : β Ο, density v Ο β 0 β β e β G.cutEdges O, Β¬Ο e := by | |
| intro Ο hΟ e he hbit | |
| have hh := exposureLaw_support w (G.incidentEdges O) Ο Ο hΟ e | |
| (G.cutEdges_subset_incidentEdges O he) | |
| exact hΟ e he (hh βΈ hbit) | |
| have hc' : β Ο, density v' Ο β 0 β β e β G.cutEdges O, Β¬Ο e := | |
| fun Ο hΟ => forceClosed_support w _ Ο hΟ | |
| have heq : β e β G.incidentEdges O, v e = v' e := by | |
| intro e he | |
| have he' : e β G.cutEdges O := fun hc => he (G.cutEdges_subset_incidentEdges O hc) | |
| funext b | |
| simp [v,v',exposureLaw,forceClosed,he,he'] | |
| have ht := search_contact_moments G order ho O B hB a ha hp w h0 h1 | |
| constructor | |
| Β· exact (contact_expect_exterior G order B O a ha p F w v v' hv hv' hc hc' heq id).trans ht.1 | |
| Β· exact (contact_expect_exterior G order B O a ha p F w v v' hv hv' hc hc' heq | |
| (fun x => x^2)).le.trans ht.2 | |
| end CriticalPercolation.LazyDFS | |
| namespace CriticalPercolation.SearchTree | |
| open scoped Classical | |
| open FiniteProduct LazyDFS | |
| variable {E R : Type*} [Fintype E] [DecidableEq E] | |
| noncomputable def queryDelta (T : SearchTree E R) (F : Set E β Prop) | |
| (w : E β Prop β β) (Ο : Set E) (e : E) : β := | |
| match T with | |
| | .done _ => 0 | |
| | .ask f l r => if e = f then delta w F f else | |
| if Ο f then r.queryDelta F (pin w f True) Ο e | |
| else l.queryDelta F (pin w f False) Ο e | |
| lemma queryDelta_update (T : SearchTree E R) (F : Set E β Prop) | |
| (w : E β Prop β β) (Ο : Set E) (e : E) (b : Prop) : | |
| T.queryDelta F w (Function.update Ο e b) e = T.queryDelta F w Ο e := by | |
| induction T generalizing w with | |
| | done _ => rfl | |
| | ask f l r hl hr => | |
| simp only [queryDelta] | |
| by_cases he : e = f | |
| Β· simp only [ite_eq_left he] | |
| Β· have hfe : f β e := Ne.symm he | |
| simp only [ite_eq_right he] | |
| erw [Function.update_of_ne hfe] | |
| split_ifs <;> first | exact hr _ | exact hl _ | |
| lemma queryDelta_zero_used (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| (F : Set E β Prop) (w : E β Prop β β) (Ο : Set E) (e : E) (he : e β used) : | |
| T.queryDelta F w Ο e = 0 := by | |
| induction T generalizing used w with | |
| | done _ => rfl | |
| | ask f l r hl hr => | |
| have hef : e β f := fun h => hT.1 (h βΈ he) | |
| simp only [queryDelta,ite_eq_right hef] | |
| split_ifs | |
| Β· exact hr _ hT.2.2 _ (Finset.mem_insert_of_mem he) | |
| Β· exact hl _ hT.2.1 _ (Finset.mem_insert_of_mem he) | |
| lemma queryDelta_nonneg (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| {p : β} (hp : p β Set.Ioo 0 1) (F : Set E β Prop) | |
| (hF : β s t, s β t β F s β F t) (w : E β Prop β β) | |
| (hw : β e, β b, w e b = 1) (hn : β e b, 0 β€ w e b) | |
| (hf : Fresh w p used) (Ο : Set E) (e : E) : 0 β€ T.queryDelta F w Ο e := by | |
| induction T generalizing used w with | |
| | done _ => exact le_rfl | |
| | ask f l r hl hr => | |
| have hf0 : w f False β 0 := by rw [(hf f hT.1).1]; linarith [hp.2] | |
| have hf1 : w f True β 0 := by rw [(hf f hT.1).2]; exact hp.1.ne' | |
| simp only [queryDelta] | |
| split_ifs | |
| Β· exact (delta_unit w hw hn f hf0 hf1 F hF).1 | |
| Β· exact hr _ hT.2.2 _ (pin_normalized w hw f True) (pin_nonneg w hn f True) | |
| (fresh_pin w p used hf f True) | |
| Β· exact hl _ hT.2.1 _ (pin_normalized w hw f False) (pin_nonneg w hn f False) | |
| (fresh_pin w p used hf f False) | |
| theorem score_eq_queryDelta_sum (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| (p : β) (F : Set E β Prop) (w : E β Prop β β) (Ο : Set E) : | |
| T.score p F w Ο = β e, if openPivot F e Ο then (1-p)*T.queryDelta F w Ο e else 0 := by | |
| induction T generalizing used w with | |
| | done _ => simp [score,queryDelta] | |
| | ask f l r hl hr => | |
| have hsum (T' : SearchTree E R) (w' : E β Prop β β) (hT' : T'.Valid (insert f used)) : | |
| (β e, if openPivot F e Ο then | |
| (1-p)*(if e = f then delta w F f else T'.queryDelta F w' Ο e) else 0) = | |
| (if openPivot F f Ο then (1-p)*delta w F f else 0) + | |
| β e, if openPivot F e Ο then (1-p)*T'.queryDelta F w' Ο e else 0 := by | |
| have hz := queryDelta_zero_used T' _ hT' F w' Ο f (Finset.mem_insert_self _ _) | |
| have heq (e : E) : (if openPivot F e Ο then | |
| (1-p)*(if e = f then delta w F f else T'.queryDelta F w' Ο e) else 0) = | |
| (if e = f then (if openPivot F f Ο then (1-p)*delta w F f else 0) else 0) + | |
| (if openPivot F e Ο then (1-p)*T'.queryDelta F w' Ο e else 0) := by | |
| by_cases he : e = f | |
| Β· subst e; rw [hz]; simp | |
| Β· simp only [ite_eq_right he,zero_add] | |
| simp only [heq,Finset.sum_add_distrib] | |
| simp | |
| rw [score] | |
| by_cases hf : Ο f | |
| Β· simp only [ite_eq_left hf,queryDelta] | |
| rw [hr _ hT.2.2 (pin w f True),β hsum r (pin w f True) hT.2.2] | |
| Β· simp only [ite_eq_right hf,queryDelta] | |
| rw [hl _ hT.2.1 (pin w f False),β hsum l (pin w f False) hT.2.1] | |
| lemma score_nonneg (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| {p : β} (hp : p β Set.Ioo 0 1) (F : Set E β Prop) | |
| (hF : β s t, s β t β F s β F t) (w : E β Prop β β) | |
| (hw : β e, β b, w e b = 1) (hn : β e b, 0 β€ w e b) | |
| (hf : Fresh w p used) (Ο : Set E) : 0 β€ T.score p F w Ο := by | |
| rw [score_eq_queryDelta_sum T used hT] | |
| apply Finset.sum_nonneg | |
| intro e _ | |
| split_ifs | |
| Β· exact mul_nonneg (sub_nonneg.mpr hp.2.le) (queryDelta_nonneg T used hT hp F hF w hw hn hf Ο e) | |
| Β· exact le_rfl | |
| end CriticalPercolation.SearchTree | |
| end | |
| end | |
| end OAI | |