Download data/lean/OAI/Probability/CriticalPercolation/Exploration/PhaseFrontier.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.06 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/PhaseFrontier.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Exploration/PhaseFrontier.lean
-
curl -L -o PhaseFrontier.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/PhaseFrontier.lean
7.06 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.Exhaustive | |
| namespace OAI | |
| section | |
| section | |
| open Set MeasureTheory ProbabilityTheory | |
| open Set | |
| open scoped BigOperators | |
| open scoped Classical | |
| namespace CriticalPercolation.LazyDFS | |
| open scoped Classical | |
| variable {V E : Type*} [DecidableEq V] [DecidableEq E] | |
| def PhaseFrontier (G : BondGraph V E) (A : Set V) (st : State V E) | |
| (stack : List (Dart V E)) : Prop := | |
| β v β st.reached, v β A β β e t, G.ends e = s(v,t) β t β st.reached β | |
| e β st.read β¨ (v,e,t) β stack | |
| omit [DecidableEq V] [DecidableEq E] in | |
| lemma phaseFrontier_pop (G : BondGraph V E) (A : Set V) (st : State V E) | |
| (v : V) (e : E) (t : V) (rest : List (Dart V E)) | |
| (h : PhaseFrontier G A st ((v,e,t)::rest)) | |
| (hskip : t β st.reached β¨ e β st.read β¨ v β st.reached β¨ G.ends e β s(v,t)) : | |
| PhaseFrontier G A st rest := by | |
| intro u hu huA f y hfy hy | |
| rcases h u hu huA f y hfy hy with hf | hf | |
| Β· exact Or.inl hf | |
| Β· rcases List.mem_cons.mp hf with hd | hd | |
| Β· simp only [Prod.mk.injEq] at hd | |
| rcases hd with β¨rfl,rfl,rflβ© | |
| rcases hskip with ht | he | hv | heq | |
| Β· exact (hy ht).elim | |
| Β· exact Or.inl he | |
| Β· exact (hv hu).elim | |
| Β· exact (heq hfy).elim | |
| Β· exact Or.inr hd | |
| omit [DecidableEq V] in | |
| lemma phaseFrontier_closed (G : BondGraph V E) (A : Set V) (st : State V E) | |
| (v : V) (e : E) (t : V) (rest : List (Dart V E)) | |
| (h : PhaseFrontier G A st ((v,e,t)::rest)) : PhaseFrontier G A (st.closed e) rest := by | |
| intro u hu huA f y hfy hy | |
| rcases h u hu huA f y hfy hy with hf | hf | |
| Β· exact Or.inl (Finset.mem_insert_of_mem hf) | |
| Β· rcases List.mem_cons.mp hf with hd | hd | |
| Β· simp only [Prod.mk.injEq] at hd | |
| rcases hd with β¨rfl,rfl,rflβ© | |
| exact Or.inl (Finset.mem_insert_self _ _) | |
| Β· exact Or.inr hd | |
| lemma phaseFrontier_opened (G : BondGraph V E) (A : Set V) (order : List (Dart V E)) | |
| (ho : Exhaustive G order) (st : State V E) | |
| (v : V) (e : E) (t : V) (rest : List (Dart V E)) | |
| (h : PhaseFrontier G A st ((v,e,t)::rest)) : | |
| PhaseFrontier G A (st.opened e t) (push G order t ++ rest) := by | |
| intro u hu huA f y hfy hy | |
| rcases Finset.mem_insert.mp hu with rfl | hu | |
| Β· exact Or.inr (List.mem_append_left _ (List.mem_filter.mpr | |
| β¨ho u f y hfy,by simpa only [decide_eq_true_eq,true_and] using hfyβ©)) | |
| Β· have hy' : y β st.reached := fun hy' => hy (Finset.mem_insert_of_mem hy') | |
| rcases h u hu huA f y hfy hy' with hf | hf | |
| Β· exact Or.inl (Finset.mem_insert_of_mem hf) | |
| Β· rcases List.mem_cons.mp hf with hd | hd | |
| Β· simp only [Prod.mk.injEq] at hd | |
| rcases hd with β¨rfl,rfl,rflβ© | |
| exact Or.inl (Finset.mem_insert_self _ _) | |
| Β· exact Or.inr (List.mem_append_right _ hd) | |
| omit [DecidableEq V] [DecidableEq E] in | |
| lemma empty_phaseFrontier_closed (G : BondGraph V E) (A : Set V) (st : State V E) | |
| (Ο : E β Bool) (hf : PhaseFrontier G A st []) (hc : ReadConsistent G st Ο) : | |
| β v β st.reached, v β A β β t, (G.openGraph {e | Ο e = true}).Adj v t β | |
| t β st.reached := by | |
| intro v hv hvA t ht | |
| obtain β¨β¨e,he,heqβ©,_β© := (SimpleGraph.fromEdgeSet_adj _).mp ht | |
| by_contra htr | |
| rcases hf v hv hvA e t heq htr with hr | hr | |
| Β· exact htr (hc e hr he t (by simp [heq])) | |
| Β· simp at hr | |
| variable [Fintype V] | |
| theorem phase_success_or_closed (G : BondGraph V E) (A : Set V) (order : List (Dart V E)) | |
| (ho : Exhaustive G order) (B : Set V) (fuel : β) (st : State V E) | |
| (stack : List (Dart V E)) (Ο : E β Bool) | |
| (hf : PhaseFrontier G A st stack) (hc : ReadConsistent G st Ο) (hr : rank order st stack β€ fuel) : | |
| let final := (compile G order B fuel st stack).run Ο | |
| (β v β final.reached, v β B) β¨ | |
| (β v β final.reached, v β A β β t, (G.openGraph {e | Ο e = true}).Adj v t β | |
| t β final.reached) := by | |
| induction fuel generalizing st stack with | |
| | zero => | |
| have hs : stack = [] := by | |
| have hh : stack.length = 0 := by dsimp [rank] at hr; omega | |
| exact List.length_eq_zero_iff.mp hh | |
| subst stack | |
| exact Or.inr (empty_phaseFrontier_closed G A st Ο hf hc) | |
| | succ n ih => | |
| rw [compile.eq_def] | |
| dsimp only | |
| split_ifs with hh | |
| Β· exact Or.inl hh | |
| Β· cases stack with | |
| | nil => exact Or.inr (empty_phaseFrontier_closed G A st Ο hf hc) | |
| | cons d rest => | |
| rcases d with β¨v,e,tβ© | |
| dsimp only | |
| split_ifs with hd | |
| Β· exact ih st rest (phaseFrontier_pop G A st v e t rest hf hd) hc | |
| (by have hh := rank_pop order st (v,e,t) rest; omega) | |
| Β· have hdec : t β st.reached β§ e β st.read β§ v β st.reached β§ G.ends e = s(v,t) := by | |
| push Not at hd | |
| exact hd | |
| rw [SearchTree.run] | |
| split_ifs with he | |
| Β· exact ih _ _ (phaseFrontier_opened G A order ho st v e t rest hf) | |
| (readConsistent_opened G st Ο hc hdec.2.2.1 hdec.2.2.2) | |
| (by have hh := rank_opened G order st (v,e,t) rest hdec.1; dsimp only at hh; omega) | |
| Β· have he' : Ο e = false := Bool.eq_false_iff.mpr he | |
| exact ih _ _ (phaseFrontier_closed G A st v e t rest hf) | |
| (readConsistent_closed G st Ο hc he') | |
| (by have hh := rank_closed order st (v,e,t) rest; dsimp only at hh; omega) | |
| omit [Fintype V] in | |
| theorem compile_append_of_success (G : BondGraph V E) (order : List (Dart V E)) | |
| (B : Set V) (fuel : β) (st : State V E) (young older : List (Dart V E)) (Ο : E β Bool) | |
| (hs : β v β ((compile G order B fuel st young).run Ο).reached, v β B) : | |
| (compile G order B fuel st (young++older)).run Ο = (compile G order B fuel st young).run Ο β§ | |
| (compile G order B fuel st (young++older)).reads Ο = (compile G order B fuel st young).reads Ο := by | |
| induction fuel generalizing st young with | |
| | zero => exact β¨rfl,rflβ© | |
| | succ n ih => | |
| simp only [compile.eq_def G order B (n+1) st] at hs β’ | |
| by_cases hh : β v β st.reached, v β B | |
| Β· simp [hh,SearchTree.run,SearchTree.reads] | |
| Β· simp only [hh,βreduceIte] at hs β’ | |
| cases young with | |
| | nil => exact (hh hs).elim | |
| | cons d rest => | |
| simp only [List.cons_append] | |
| dsimp only at hs β’ | |
| by_cases hd : d.2.2 β st.reached β¨ d.2.1 β st.read β¨ d.1 β st.reached β¨ | |
| G.ends d.2.1 β s(d.1,d.2.2) | |
| Β· simp only [hd,βreduceIte] at hs β’ | |
| exact ih st rest hs | |
| Β· simp only [hd,βreduceIte,SearchTree.run,SearchTree.reads] at hs β’ | |
| by_cases he : Ο d.2.1 = true | |
| Β· simp only [he,βreduceIte] at hs β’ | |
| have h := ih (st.opened d.2.1 d.2.2) (push G order d.2.2++rest) hs | |
| simpa only [List.append_assoc,List.cons.injEq,true_and] using h | |
| Β· simp only [he,Bool.false_eq_true,βreduceIte] at hs β’ | |
| have h := ih (st.closed d.2.1) rest hs | |
| simpa only [List.cons.injEq,true_and] using h | |
| end CriticalPercolation.LazyDFS | |
| end | |
| end | |
| end OAI | |