Download data/lean/OAI/Computability/PerfectCompleteness/Sampling/CutSamplerLocality.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.15 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/CutSamplerLocality.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/PerfectCompleteness/Sampling/CutSamplerLocality.lean
-
curl -L -o CutSamplerLocality.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/CutSamplerLocality.lean
7.15 kB
| import OAI.Computability.PerfectCompleteness.Construction.FactoredFunctionsLemmas | |
| import OAI.Computability.PerfectCompleteness.Sampling.CutSamplerRefinement | |
| namespace OAI | |
| section | |
| namespace PerfectCompleteness.CutSamplerLocality | |
| open scoped BigOperators Classical | |
| open RecursiveSpaces DescendantSpaces RecursiveSampler PointwiseSpaces | |
| open CutSamplerRefinement | |
| noncomputable section | |
| universe u w | |
| variable {branch : Nat β Nat} {n m : Nat} | |
| def View : {n m : Nat} β (p : Path branch n (m + 1)) β | |
| (A : Slots branch n β Type u) β (clean : Fin (branch m) β Prop) β Type u | |
| | _, m, .refl _, A, clean => | |
| (i : {i : Fin (branch m) // Β¬ clean i}) β Assignment (childFamily A i.val) | |
| | _, _, .step i p, A, clean => | |
| ((j : OffPath i) β Assignment (childFamily A j.val)) Γ | |
| View p (childFamily A i) clean | |
| def view : {n m : Nat} β (p : Path branch n (m + 1)) β | |
| (A : Slots branch n β Type u) β (clean : Fin (branch m) β Prop) β | |
| Assignment A β View p A clean | |
| | _, _, .refl _, A, _, x => fun i => childRestriction A i.val x | |
| | _, _, .step i p, A, clean, x => | |
| (fun j => childRestriction A j.val x, | |
| view p (childFamily A i) clean (childRestriction A i x)) | |
| def subTape (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (i : Fin (branch n)) (p : Path branch n m) | |
| (A : Slots branch (n + 1) β Type u) | |
| (tape : CutSamplerRefinement.Tape π repeats (.step i p) A) | |
| (h : Fin (repeats (n + 1))) (b : Bool) : | |
| CutSamplerRefinement.Tape π repeats p (childFamily A i) := | |
| fun j => tape (Sum.inr ((h, b), j)) | |
| def ZeroAtClean (π : Type w) [Field π] (repeats : Nat β Nat) : | |
| {n m : Nat} β (p : Path branch n (m + 1)) β (A : Slots branch n β Type u) β | |
| (clean : Fin (branch m) β Prop) β CutSamplerRefinement.Tape π repeats p A β Prop | |
| | _, _, .refl _, _, clean, tape => β i, clean i β tape () i = 0 | |
| | _ + 1, _, .step i p, A, clean, tape => | |
| β h b, ZeroAtClean π repeats p (childFamily A i) clean | |
| (subTape π repeats i p A tape h b) | |
| theorem evaluate_refl (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (A : Slots branch (m + 1) β Type u) | |
| (tape : CutSamplerRefinement.Tape π repeats (.refl (m + 1)) A) : | |
| CutSamplerRefinement.evaluate π repeats (.refl (m + 1)) A tape = | |
| UniformChildSum.recursiveSum A (tape ()) := rfl | |
| theorem evaluate_step (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (i : Fin (branch n)) (p : Path branch n m) | |
| (A : Slots branch (n + 1) β Type u) | |
| (tape : CutSamplerRefinement.Tape π repeats (.step i p) A) : | |
| CutSamplerRefinement.evaluate π repeats (.step i p) A tape = | |
| RecursiveSampler.combine π A i (repeats (n + 1)) | |
| (fun j => tape (Sum.inl j)) | |
| (fun h => CutSamplerRefinement.evaluate π repeats p (childFamily A i) | |
| (subTape π repeats i p A tape h false)) | |
| (fun h => CutSamplerRefinement.evaluate π repeats p (childFamily A i) | |
| (subTape π repeats i p A tape h true)) := rfl | |
| theorem evaluate_eq_of_view_eq (π : Type w) [Field π] | |
| (repeats : Nat β Nat) (p : Path branch n (m + 1)) : | |
| β (A : Slots branch n β Type u) (clean : Fin (branch m) β Prop) | |
| (tape : CutSamplerRefinement.Tape π repeats p A), | |
| ZeroAtClean π repeats p A clean tape β | |
| β x y : Assignment A, view p A clean x = view p A clean y β | |
| (CutSamplerRefinement.evaluate π repeats p A tape).val x = | |
| (CutSamplerRefinement.evaluate π repeats p A tape).val y := by | |
| induction n generalizing m with | |
| | zero => | |
| have h := p.height_le | |
| omega | |
| | succ n ih => | |
| cases p with | |
| | refl => | |
| intro A clean tape hzero x y hview | |
| have heval (z : Assignment A) : | |
| (UniformChildSum.recursiveSum (π := π) A (tape ())).val z = | |
| β i : Fin (branch n), (tape () i).val (childRestriction A i z) := by | |
| have hsum := congrFun | |
| (UniformChildSum.childSum_apply (π := π) (childRestriction A) | |
| (fun i => space π branch n (childFamily A i)) (tape ())) z | |
| simp only [Finset.sum_apply, PointwiseSpaces.pullback_apply] at hsum | |
| refine hsum.trans ?_ | |
| refine Finset.sum_congr (ΞΉ := Fin (branch n)) ?_ ?_ | |
| Β· ext i | |
| simp only [Finset.mem_univ] | |
| Β· intro i _ | |
| rfl | |
| rw [evaluate_refl, heval x, heval y] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| by_cases hi : clean i | |
| Β· rw [hzero i hi] | |
| rfl | |
| Β· exact congrArg (tape () i).val (congrFun hview β¨i, hiβ©) | |
| | step i p => | |
| intro A clean tape hzero x y hview | |
| have hout : β j : OffPath i, childRestriction A j.val x = childRestriction A j.val y := | |
| congrFun (congrArg Prod.fst hview) | |
| have hin : view p (childFamily A i) clean (childRestriction A i x) = | |
| view p (childFamily A i) clean (childRestriction A i y) := | |
| congrArg Prod.snd hview | |
| rw [evaluate_step] | |
| simp only [RecursiveSampler.combine, RecursiveSampler.combineFunction, | |
| Finset.sum_apply, Pi.add_apply, Pi.mul_apply, PointwiseSpaces.pullback_apply] | |
| change | |
| (β j : OffPath i, (tape (Sum.inl j)).val (childRestriction A j.val x)) + | |
| (β h, (CutSamplerRefinement.evaluate π repeats p (childFamily A i) | |
| (subTape π repeats i p A tape h false)).val (childRestriction A i x) * | |
| (CutSamplerRefinement.evaluate π repeats p (childFamily A i) | |
| (subTape π repeats i p A tape h true)).val (childRestriction A i x)) = | |
| (β j : OffPath i, (tape (Sum.inl j)).val (childRestriction A j.val y)) + | |
| (β h, (CutSamplerRefinement.evaluate π repeats p (childFamily A i) | |
| (subTape π repeats i p A tape h false)).val (childRestriction A i y) * | |
| (CutSamplerRefinement.evaluate π repeats p (childFamily A i) | |
| (subTape π repeats i p A tape h true)).val (childRestriction A i y)) | |
| congr 1 | |
| Β· exact Finset.sum_congr rfl (fun j _ => congrArg (tape (Sum.inl j)).val (hout j)) | |
| Β· apply Finset.sum_congr rfl | |
| intro h _ | |
| rw [ih p (childFamily A i) clean (subTape π repeats i p A tape h false) | |
| (hzero h false) _ _ hin, | |
| ih p (childFamily A i) clean (subTape π repeats i p A tape h true) | |
| (hzero h true) _ _ hin] | |
| theorem evaluate_factors (π : Type w) [Field π] | |
| (repeats : Nat β Nat) (p : Path branch n (m + 1)) | |
| (A : Slots branch n β Type u) (clean : Fin (branch m) β Prop) | |
| (tape : CutSamplerRefinement.Tape π repeats p A) | |
| (hzero : ZeroAtClean π repeats p A clean tape) : | |
| (CutSamplerRefinement.evaluate π repeats p A tape).val β | |
| FactoredFunctions.factoringSpace (view p A clean) := | |
| evaluate_eq_of_view_eq π repeats p A clean tape hzero | |
| end | |
| end PerfectCompleteness.CutSamplerLocality | |
| end | |
| end OAI | |