Download data/lean/OAI/Probability/CriticalPercolation/Exploration/LocalNode.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.89 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/LocalNode.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Exploration/LocalNode.lean
-
curl -L -o LocalNode.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/LocalNode.lean
4.89 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.Tagged | |
| namespace OAI | |
| section | |
| section | |
| open Set MeasureTheory ProbabilityTheory | |
| open scoped Classical | |
| open Real | |
| open Set Real | |
| open scoped Topology | |
| open scoped BigOperators | |
| open Set | |
| namespace CriticalPercolation.OrderedQuery | |
| open QueryTree MarkedTree | |
| variable {E I : Type*} (t : I β QueryTree E) | |
| abbrev LocalNode := (i : I) Γ (t i).Node | |
| def coord (a : LocalNode t) : E := (t a.1).bit a.2 | |
| def algorithm (i : I) : MarkedTree E (LocalNode t) := | |
| (t i).marked.map (Sigma.mk i) | |
| def raw (order : List I) : MarkedTree E (LocalNode t) := | |
| sequence (order.map (algorithm t)) | |
| lemma tagged_algorithm (i : I) : (algorithm t i).Tagged (coord t) := by | |
| apply tagged_map | |
| exact tagged_marked (t i) | |
| lemma tagged_raw (order : List I) : (raw t order).Tagged (coord t) := by | |
| apply tagged_sequence | |
| intro s hs | |
| rcases List.mem_map.mp hs with β¨i, _, rflβ© | |
| exact tagged_algorithm t i | |
| lemma trace_algorithm (i : I) (Ο : E β Bool) : | |
| (algorithm t i).trace Ο = | |
| ((t i).pathNodes Ο).map (fun n => ((t i).bit n, Sigma.mk i n)) := by | |
| simp [algorithm, trace_map, trace_marked, List.map_map, Function.comp_def] | |
| lemma bits_trace_algorithm (i : I) (Ο : E β Bool) : | |
| ((algorithm t i).trace Ο).map Prod.fst = (t i).reads Ο := by | |
| rw [trace_algorithm, List.map_map] | |
| exact map_bit_pathNodes (t i) Ο | |
| lemma index_mem_trace_algorithm (i : I) (Ο : E β Bool) (x : E Γ LocalNode t) | |
| (h : x β (algorithm t i).trace Ο) : x.2.1 = i := by | |
| rw [trace_algorithm] at h | |
| rcases List.mem_map.mp h with β¨n, _, rflβ© | |
| rfl | |
| lemma mem_trace_algorithm_self (i : I) (n : (t i).Node) (Ο : E β Bool) : | |
| ((t i).bit n, Sigma.mk i n) β (algorithm t i).trace Ο β (t i).visits n Ο := by | |
| rw [trace_algorithm] | |
| constructor | |
| Β· intro h | |
| rcases List.mem_map.mp h with β¨m, hm, hmnβ© | |
| have he : m = n := by | |
| exact eq_of_heq (Sigma.mk.inj_iff.mp (congrArg Prod.snd hmn)).2 | |
| subst m | |
| exact (mem_pathNodes (t i) Ο n).mp hm | |
| Β· intro h | |
| exact List.mem_map.mpr β¨n, (mem_pathNodes (t i) Ο n).mpr h, rflβ© | |
| lemma trace_raw (order : List I) (Ο : E β Bool) : | |
| (raw t order).trace Ο = (order.map (fun i => (algorithm t i).trace Ο)).flatten := by | |
| simp [raw, trace_sequence, List.map_map, Function.comp_def] | |
| lemma index_mem_trace_raw (order : List I) (Ο : E β Bool) (x : E Γ LocalNode t) | |
| (h : x β (raw t order).trace Ο) : x.2.1 β order := by | |
| rw [trace_raw, List.mem_flatten] at h | |
| rcases h with β¨xs, hxs, hxβ© | |
| rcases List.mem_map.mp hxs with β¨i, hi, rflβ© | |
| rwa [index_mem_trace_algorithm t i Ο x hx] | |
| lemma mem_bits_trace_raw (order : List I) (Ο : E β Bool) (e : E) : | |
| e β ((raw t order).trace Ο).map Prod.fst β β i β order, e β (t i).reads Ο := by | |
| rw [trace_raw] | |
| simp only [List.map_flatten, List.mem_flatten, List.mem_map] | |
| constructor | |
| Β· rintro β¨xs, β¨ys, β¨i, hi, rflβ©, rflβ©, heβ© | |
| exact β¨i, hi, by simpa only [bits_trace_algorithm] using heβ© | |
| Β· rintro β¨i, hi, heβ© | |
| refine β¨_, β¨_, β¨i, hi, rflβ©, rflβ©, ?_β© | |
| simpa only [bits_trace_algorithm] using he | |
| lemma trace_raw_append (pre post : List I) (Ο : E β Bool) : | |
| (raw t (pre++post)).trace Ο = (raw t pre).trace Ο ++ (raw t post).trace Ο := by | |
| simp [trace_raw] | |
| variable [DecidableEq E] [Fintype E] | |
| def combined (order : List I) : MarkedTree E (LocalNode t) := | |
| (raw t order).cached (fun _ => none) | |
| lemma combined_valid (order : List I) : (combined t order).bare.Valid β := | |
| cached_empty_valid _ | |
| omit [Fintype E] in | |
| lemma combined_tagged (order : List I) : (combined t order).Tagged (coord t) := | |
| tagged_cached _ _ (tagged_raw t order) _ | |
| lemma trace_combined (order : List I) (Ο : E β Bool) : | |
| (combined t order).trace Ο = select β ((raw t order).trace Ο) := by | |
| rw [combined, trace_cached_select] | |
| Β· simp [domain] | |
| Β· intro e b h; simp at h | |
| lemma fresh_local_node (pre post : List I) (i : I) (n : (t i).Node) (Ο : E β Bool) | |
| (hi : i β pre) (hi' : i β post) (hv : (t i).Valid β ) : | |
| ((t i).bit n, Sigma.mk i n) β (combined t (pre++i::post)).trace Ο β | |
| (t i).visits n Ο β§ β j β pre, (t i).bit n β (t j).reads Ο := by | |
| rw [trace_combined] | |
| have he : (raw t (pre++i::post)).trace Ο = | |
| (raw t pre).trace Ο ++ (algorithm t i).trace Ο ++ (raw t post).trace Ο := by | |
| rw [trace_raw_append] | |
| simp [raw, MarkedTree.sequence, trace_append, List.append_assoc] | |
| rw [he, mem_select_block] | |
| Β· rw [mem_trace_algorithm_self] | |
| simp only [Finset.empty_union, List.mem_toFinset, mem_bits_trace_raw, not_exists, not_and] | |
| Β· exact fun h => hi (index_mem_trace_raw t pre Ο _ h) | |
| Β· exact fun h => hi' (index_mem_trace_raw t post Ο _ h) | |
| Β· rw [bits_trace_algorithm] | |
| exact reads_nodup (t i) β hv Ο | |
| end CriticalPercolation.OrderedQuery | |
| end | |
| end | |
| end OAI | |