Download data/lean/OAI/Probability/CriticalPercolation/Exploration/IncidenceIdentity.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.05 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/IncidenceIdentity.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Exploration/IncidenceIdentity.lean
-
curl -L -o IncidenceIdentity.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/IncidenceIdentity.lean
5.05 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.ProductMeasure.QueryMartingale | |
| import OAI.Probability.CriticalPercolation.Exploration.IncidenceSearch | |
| namespace OAI | |
| section | |
| section | |
| noncomputable section | |
| open Set | |
| open scoped Classical | |
| namespace CriticalPercolation.IncidenceSearch | |
| variable {V E : Type*} | |
| def readSum (p : β) (Ο : Set E) (st : State E) : β := | |
| β e β st.read, if eβΟ then 1-p else -p | |
| lemma compile_trace (G : BondGraph V E) (v : V) (n : β) (st : State E) | |
| (Ο : Set E) (p : β) : | |
| let t := compile G v n st | |
| let out := t.run (fun e => decide (eβΟ)) | |
| t.queryCount Ο + st.read.card = out.read.card β§ | |
| t.centeredSum p Ο + readSum p Ο st = readSum p Ο out := by | |
| induction n generalizing st with | |
| | zero => simp [compile,SearchTree.run,SearchTree.queryCount,SearchTree.centeredSum] | |
| | succ n ih => | |
| rw [compile] | |
| split_ifs with h | |
| Β· let e := h.choose | |
| have he : eβst.read := h.choose_spec.1 | |
| have hopen := ih (st.open e) | |
| have hclosed := ih (st.closed e) | |
| have hcard : (insert e st.read).card = st.read.card + 1 := Finset.card_insert_of_notMem he | |
| have hsum : readSum p Ο (st.open e) = | |
| (if eβΟ then 1-p else -p)+readSum p Ο st := by | |
| simp only [readSum,State.open,Finset.sum_insert he] | |
| have hsum' : readSum p Ο (st.closed e) = | |
| (if eβΟ then 1-p else -p)+readSum p Ο st := by | |
| simp only [readSum,State.closed,Finset.sum_insert he] | |
| change (let out := if decide (eβΟ) then | |
| (compile G v n (st.open e)).run (fun a => decide (aβΟ)) else | |
| (compile G v n (st.closed e)).run (fun a => decide (aβΟ)); | |
| (1 + if Ο e then (compile G v n (st.open e)).queryCount Ο else | |
| (compile G v n (st.closed e)).queryCount Ο) + st.read.card = out.read.card β§ | |
| (if Ο e then (1-p)+(compile G v n (st.open e)).centeredSum p Ο else | |
| -p+(compile G v n (st.closed e)).centeredSum p Ο) + readSum p Ο st = readSum p Ο out) | |
| by_cases hΟ : eβΟ | |
| Β· have hΟ' : Ο e := hΟ | |
| simp only [hΟ,hΟ',decide_true,ite_true] | |
| dsimp only at hopen | |
| constructor | |
| Β· have hh := hopen.1 | |
| change _ + (insert e st.read).card = _ at hh | |
| rw [hcard] at hh | |
| omega | |
| Β· rw [hsum,ite_eq_left hΟ] at hopen | |
| linarith [hopen.2] | |
| Β· have hΟ' : Β¬Ο e := hΟ | |
| simp only [hΟ,hΟ',decide_false,Bool.false_eq_true,ite_false] | |
| dsimp only at hclosed | |
| constructor | |
| Β· have hh := hclosed.1 | |
| change _ + (insert e st.read).card = _ at hh | |
| rw [hcard] at hh | |
| omega | |
| Β· rw [hsum',ite_eq_right hΟ] at hclosed | |
| linarith [hclosed.2] | |
| Β· simp [SearchTree.run,SearchTree.queryCount,SearchTree.centeredSum] | |
| variable [Fintype E] | |
| def tree (G : BondGraph V E) (v : V) : SearchTree E (State E) := | |
| compile G v (Fintype.card E + 1) β¨β ,β β© | |
| lemma tree_valid (G : BondGraph V E) (v : V) : (tree G v).Valid β := | |
| compile_valid G v _ _ | |
| lemma tree_read (G : BondGraph V E) (v : V) (Ο : Set E) : | |
| (((tree G v).run (fun e => decide (eβΟ))).read : Set E) = | |
| G.incidentEdges (G.cluster Ο v) := by | |
| have hg : Good G v Ο (β¨β ,β β© : State E) := by simp [Good] | |
| have hh := compile_terminal G v Ο (Fintype.card E+1) β¨β ,β β© hg (by simp) | |
| exact (terminal_cluster G v Ο _ hh.1 hh.2).2 | |
| lemma tree_mem_read (G : BondGraph V E) (v : V) (Ο : Set E) (e : E) : | |
| e β ((tree G v).run (fun a => decide (aβΟ))).read β | |
| e β G.incidentEdges (G.cluster Ο v) := by | |
| exact Set.ext_iff.mp (tree_read G v Ο) e | |
| lemma tree_count (G : BondGraph V E) (v : V) (Ο : Set E) : | |
| (tree G v).queryCount Ο = (G.incidentEdges (G.cluster Ο v)).toFinset.card := by | |
| have h := (compile_trace G v (Fintype.card E+1) β¨β ,β β© Ο (0:β)).1 | |
| change (tree G v).queryCount Ο + (β : Finset E).card = | |
| ((tree G v).run (fun e => decide (eβΟ))).read.card at h | |
| simp only [Finset.card_empty,add_zero] at h | |
| refine h.trans (congrArg Finset.card ?_) | |
| ext e | |
| rw [Set.mem_toFinset] | |
| exact tree_mem_read G v Ο e | |
| lemma tree_centered (G : BondGraph V E) (v : V) (Ο : Set E) (p : β) : | |
| (tree G v).centeredSum p Ο = β e, | |
| if eβG.incidentEdges (G.cluster Ο v) then (if eβΟ then 1-p else -p) else 0 := by | |
| have h := (compile_trace G v (Fintype.card E+1) β¨β ,β β© Ο p).2 | |
| change (tree G v).centeredSum p Ο + readSum p Ο β¨β ,β β© = | |
| readSum p Ο ((tree G v).run (fun e => decide (eβΟ))) at h | |
| simp only [readSum,Finset.sum_empty,add_zero] at h | |
| rw [h] | |
| calc | |
| _ = β e, if eβ((tree G v).run (fun a => decide (aβΟ))).read then | |
| (if eβΟ then 1-p else -p) else 0 := by | |
| simp only [β Finset.sum_filter] | |
| congr 1 | |
| ext e | |
| simp only [Finset.mem_filter,Finset.mem_univ,true_and] | |
| _ = _ := by | |
| apply Finset.sum_congr rfl | |
| intro e _ | |
| simp only [tree_mem_read] | |
| end CriticalPercolation.IncidenceSearch | |
| end | |
| end | |
| end | |
| end OAI | |