Download data/lean/OAI/Probability/CriticalPercolation/Exploration/ClosedPivotWeight.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.36 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/ClosedPivotWeight.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Exploration/ClosedPivotWeight.lean
-
curl -L -o ClosedPivotWeight.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/ClosedPivotWeight.lean
6.36 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.QueryDelta | |
| import OAI.Probability.CriticalPercolation.ProductMeasure.ExpectClosedFlip | |
| namespace OAI | |
| section | |
| section | |
| open Set MeasureTheory ProbabilityTheory | |
| open Set | |
| open scoped BigOperators | |
| open scoped Classical | |
| namespace CriticalPercolation.SearchTree | |
| open scoped Classical | |
| open FiniteProduct LazyDFS | |
| variable {E R : Type*} [Fintype E] [DecidableEq E] | |
| noncomputable def closedPivotWeight (T : SearchTree E R) (p : β) (F : Set E β Prop) | |
| (w : E β Prop β β) (Ο : Set E) (e : E) : β := | |
| if Β¬Ο e β§ openPivot F e (Function.update Ο e True) then p*T.queryDelta F w Ο e else 0 | |
| theorem contact_flip_identity (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| {p : β} (hp : p β Set.Ioo 0 1) (F : Set E β Prop) (w : E β Prop β β) | |
| (hw : β e, β b, w e b = 1) (h0 : β e, w e False = 1-p) (h1 : β e, w e True = p) | |
| (Ο : β β β) : | |
| expect w (fun Ο => β e, T.closedPivotWeight p F w Ο e * | |
| Ο (T.score p F w (Function.update Ο e True))) = | |
| expect w (fun Ο => T.score p F w Ο * Ο (T.score p F w Ο)) := by | |
| have hsingle (e : E) : | |
| expect w (fun Ο => T.closedPivotWeight p F w Ο e * | |
| Ο (T.score p F w (Function.update Ο e True))) = | |
| expect w (fun Ο => (if openPivot F e Ο then (1-p)*T.queryDelta F w Ο e else 0) * | |
| Ο (T.score p F w Ο)) := by | |
| have h := expect_closed_flip_decidable w hw e hp (h0 e) (h1 e) | |
| (fun Ο => (if openPivot F e Ο then T.queryDelta F w Ο e else 0) * Ο (T.score p F w Ο)) | |
| convert h using 1 | |
| Β· congr 1 | |
| funext Ο | |
| let Ο : Set E := Ο | |
| change T.closedPivotWeight p F w Ο e * Ο (T.score p F w (Function.update Ο e True)) = | |
| if Β¬Ο e then p*((if openPivot F e (Function.update Ο e True) then | |
| T.queryDelta F w (Function.update Ο e True) e else 0) * | |
| Ο (T.score p F w (Function.update Ο e True))) else 0 | |
| rw [queryDelta_update T F w Ο e True] | |
| simp only [closedPivotWeight] | |
| by_cases hc : Ο e <;> | |
| by_cases hpiv : openPivot F e (Function.update Ο e True) <;> simp [hc,hpiv,mul_assoc] | |
| Β· congr 1 | |
| funext Ο | |
| by_cases hpiv : openPivot F e Ο | |
| Β· simp only [ite_eq_left hpiv,ite_eq_left hpiv.1]; ring | |
| Β· simp only [ite_eq_right hpiv,mul_zero,zero_mul,ite_self] | |
| rw [expect_sum] | |
| simp_rw [hsingle] | |
| rw [β expect_sum] | |
| congr 1 | |
| funext Ο | |
| rw [β Finset.sum_mul] | |
| exact congrArg (fun x => x * Ο (T.score p F w Ο)) | |
| (score_eq_queryDelta_sum T used hT p F w Ο).symm | |
| end CriticalPercolation.SearchTree | |
| namespace CriticalPercolation.SearchTree | |
| open scoped Classical | |
| open FiniteProduct LazyDFS | |
| variable {E R : Type*} [Fintype E] [DecidableEq E] | |
| noncomputable def prefixScore (T : SearchTree E R) (p : β) (F : Set E β Prop) | |
| (w : E β Prop β β) (Ο : Set E) (e : E) : β := | |
| match T with | |
| | .done _ => 0 | |
| | .ask f l r => (if openPivot F f Ο then (1-p)*delta w F f else 0) + | |
| if e = f then 0 else | |
| if Ο f then r.prefixScore p F (pin w f True) Ο e | |
| else l.prefixScore p F (pin w f False) Ο e | |
| lemma prefixScore_le (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) : | |
| T.prefixScore p F w Ο e β€ T.score p F w Ο := by | |
| induction T generalizing used w with | |
| | done _ => exact le_rfl | |
| | ask f l r hl hr => | |
| simp only [prefixScore,score] | |
| apply add_le_add_right | |
| by_cases he : e = f | |
| Β· rw [ite_eq_left he] | |
| by_cases ho : Ο f | |
| Β· rw [ite_eq_left ho] | |
| exact score_nonneg r _ hT.2.2 hp F hF _ (pin_normalized w hw f True) | |
| (pin_nonneg w hn f True) (fresh_pin w p used hf f True) Ο | |
| Β· rw [ite_eq_right ho] | |
| exact score_nonneg l _ hT.2.1 hp F hF _ (pin_normalized w hw f False) | |
| (pin_nonneg w hn f False) (fresh_pin w p used hf f False) Ο | |
| Β· rw [ite_eq_right he] | |
| by_cases ho : Ο f | |
| Β· rw [ite_eq_left ho,ite_eq_left ho] | |
| 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) | |
| Β· rw [ite_eq_right ho,ite_eq_right ho] | |
| 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) | |
| lemma closedPivotWeight_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.closedPivotWeight p F w Ο e := by | |
| unfold closedPivotWeight | |
| split_ifs | |
| Β· exact mul_nonneg hp.1.le (queryDelta_nonneg T used hT hp F hF w hw hn hf Ο e) | |
| Β· exact le_rfl | |
| theorem marked_prefix_bound (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) (h0 : β e, w e False = 1-p) (h1 : β e, w e True = p) : | |
| expect w (fun Ο => β e, T.closedPivotWeight p F w Ο e * | |
| (1 + T.prefixScore p F w (Function.update Ο e True) e)) β€ | |
| expect w (T.score p F w) + expect w (fun Ο => (T.score p F w Ο)^2) := by | |
| calc | |
| _ β€ expect w (fun Ο => β e, T.closedPivotWeight p F w Ο e * | |
| (1 + T.score p F w (Function.update Ο e True))) := by | |
| apply expect_mono hn | |
| intro Ο | |
| apply Finset.sum_le_sum | |
| intro e _ | |
| exact mul_le_mul_of_nonneg_left | |
| (add_le_add_right (prefixScore_le T used hT hp F hF w hw hn hf _ e) 1) | |
| (closedPivotWeight_nonneg T used hT hp F hF w hw hn hf Ο e) | |
| _ = expect w (fun Ο => T.score p F w Ο * (1 + T.score p F w Ο)) := | |
| contact_flip_identity T used hT hp F w hw h0 h1 (fun x => 1+x) | |
| _ = expect w (fun Ο => T.score p F w Ο + (T.score p F w Ο)^2) := by | |
| congr 1 | |
| funext Ο | |
| ring | |
| _ = _ := expect_add w _ _ | |
| end CriticalPercolation.SearchTree | |
| end | |
| end | |
| end OAI | |