Download data/lean/OAI/Probability/CriticalPercolation/Entropy/ReverseGuess.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.45 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Entropy/ReverseGuess.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Entropy/ReverseGuess.lean
-
curl -L -o ReverseGuess.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Entropy/ReverseGuess.lean
5.45 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.ClosedPivotWeight | |
| import OAI.Probability.CriticalPercolation.Modular.Mass | |
| 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 reverseGuess (T : SearchTree E R) (p : β) (F : Set E β Prop) | |
| (w : E β Prop β β) (Ο : Set E) (s : β) (e : E) : β := | |
| (if openPivot F e Ο then (1-p)*T.queryDelta F w Ο e else 0) / | |
| (1+s+T.prefixScore p F w Ο e)^2 | |
| noncomputable def reverseMass (T : SearchTree E R) (p : β) (F : Set E β Prop) | |
| (w : E β Prop β β) (Ο : Set E) (s : β) : β := | |
| match T with | |
| | .done _ => 0 | |
| | .ask f l r => | |
| let b := if openPivot F f Ο then (1-p)*delta w F f else 0 | |
| b/(1+s+b)^2 + if Ο f then r.reverseMass p F (pin w f True) Ο (s+b) | |
| else l.reverseMass p F (pin w f False) Ο (s+b) | |
| lemma reverseMass_eq_sum (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| (p : β) (F : Set E β Prop) (w : E β Prop β β) (Ο : Set E) (s : β) : | |
| T.reverseMass p F w Ο s = β e, T.reverseGuess p F w Ο s e := by | |
| induction T generalizing used w s with | |
| | done _ => simp [reverseMass,reverseGuess,queryDelta,prefixScore] | |
| | ask f l r hl hr => | |
| let b := if openPivot F f Ο then (1-p)*delta w F f else 0 | |
| 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) / | |
| (1+s+(b+if e=f then 0 else T'.prefixScore p F w' Ο e))^2) = | |
| b/(1+s+b)^2 + β e, T'.reverseGuess p F w' Ο (s+b) e := 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) / | |
| (1+s+(b+if e=f then 0 else T'.prefixScore p F w' Ο e))^2 = | |
| (if e=f then b/(1+s+b)^2 else 0) + T'.reverseGuess p F w' Ο (s+b) e := by | |
| by_cases he : e=f | |
| Β· subst e | |
| simp [reverseGuess,hz,b] | |
| Β· simp only [ite_eq_right he,reverseGuess,zero_add] | |
| congr 2; ring | |
| simp only [heq,Finset.sum_add_distrib] | |
| simp | |
| rw [reverseMass] | |
| by_cases hf : Ο f | |
| Β· simp only [ite_eq_left hf] | |
| rw [hr _ hT.2.2 (pin w f True),β hsum r (pin w f True) hT.2.2] | |
| simp only [reverseGuess,queryDelta,prefixScore,ite_eq_left hf] | |
| rfl | |
| Β· simp only [ite_eq_right hf] | |
| rw [hl _ hT.2.1 (pin w f False),β hsum l (pin w f False) hT.2.1] | |
| simp only [reverseGuess,queryDelta,prefixScore,ite_eq_right hf] | |
| rfl | |
| lemma reverseMass_bound (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| {p : β} (hp : p β Set.Ioo 0 1) (F : Set E β Prop) | |
| (hF : β a b, a β b β F a β F b) (w : E β Prop β β) | |
| (hw : β e, β b, w e b = 1) (hn : β e b, 0 β€ w e b) | |
| (hf : Fresh w p used) (Ο : Set E) {s : β} (hs : 0 β€ s) : | |
| 0 β€ T.reverseMass p F w Ο s β§ T.reverseMass p F w Ο s β€ 1/(1+s) := by | |
| induction T generalizing used w s with | |
| | done _ => exact β¨le_rfl, div_nonneg zero_le_one (by linarith)β© | |
| | ask f l r hl hr => | |
| let b := if openPivot F f Ο then (1-p)*delta w F f else 0 | |
| 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' | |
| have hb : 0 β€ b := by | |
| dsimp [b] | |
| split_ifs | |
| Β· exact mul_nonneg (sub_nonneg.mpr hp.2.le) (delta_unit w hw hn f hf0 hf1 F hF).1 | |
| Β· exact le_rfl | |
| have hb' : 0 β€ b/(1+s+b)^2 := div_nonneg hb (sq_nonneg _) | |
| have hs' : 0 β€ s+b := add_nonneg hs hb | |
| have step {x : β} (hx : 0 β€ x β§ x β€ 1/(1+(s+b))) : | |
| 0 β€ b/(1+s+b)^2+x β§ b/(1+s+b)^2+x β€ 1/(1+s) := by | |
| refine β¨add_nonneg hb' hx.1, ?_β© | |
| calc | |
| _ β€ b/(1+s+b)^2 + 1/(1+(s+b)) := add_le_add_right hx.2 _ | |
| _ β€ _ := by simpa only [add_assoc] using ReverseGuess.step_bound hs hb | |
| simp only [reverseMass] | |
| by_cases hbit : Ο f | |
| Β· simp only [ite_eq_left hbit] | |
| exact step (hr _ hT.2.2 _ (pin_normalized w hw f True) | |
| (pin_nonneg w hn f True) (fresh_pin w p used hf f True) hs') | |
| Β· simp only [ite_eq_right hbit] | |
| exact step (hl _ hT.2.1 _ (pin_normalized w hw f False) | |
| (pin_nonneg w hn f False) (fresh_pin w p used hf f False) hs') | |
| theorem reverseGuess_subprobability (T : SearchTree E R) (used : Finset E) (hT : T.Valid used) | |
| {p : β} (hp : p β Set.Ioo 0 1) (F : Set E β Prop) | |
| (hF : β a b, a β b β F a β F b) (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, 0 β€ T.reverseGuess p F w Ο 0 e) β§ (β e, T.reverseGuess p F w Ο 0 e) β€ 1 := by | |
| constructor | |
| Β· intro e | |
| apply div_nonneg _ (sq_nonneg _) | |
| 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 | |
| Β· rw [β reverseMass_eq_sum T used hT] | |
| simpa using (reverseMass_bound T used hT hp F hF w hw hn hf Ο (s := 0) le_rfl).2 | |
| end CriticalPercolation.SearchTree | |
| end | |
| end | |
| end OAI | |