Download data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerComposition.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.75 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerComposition.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerComposition.lean
-
curl -L -o SamplerComposition.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerComposition.lean
7.75 kB
| import OAI.Computability.PerfectCompleteness.Foundations.HierarchicalFrozenTablesLemmas | |
| import OAI.Computability.PerfectCompleteness.Sampling.BucketUniformLemmas | |
| namespace OAI | |
| section | |
| namespace PerfectCompleteness.SamplerComposition | |
| open PointwiseSpaces RecursiveSpaces DescendantSpaces RecursiveSampler | |
| noncomputable section | |
| universe u w | |
| variable {branch : Nat β Nat} {n m k : Nat} | |
| def ExpansionSpace (π : Type w) [Field π] (repeats : Nat β Nat) : | |
| {n m k : Nat} β (p : Path branch n m) β (q : Path branch m k) β | |
| (A : Slots branch n β Type u) β DrawIndex repeats p β Type (max u w) | |
| | _, _, _, .refl _, q, A, _ => RecursiveSampler.Tape π repeats q A | |
| | n + 1, _, _, .step i p, q, A, j => | |
| match j with | |
| | Sum.inl j => squareSpace (space π branch n (childFamily A j.val)) | |
| | Sum.inr j => ExpansionSpace π repeats p q (childFamily A i) j.2 | |
| abbrev ExpandedTape (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n β Type u) := | |
| (j : DrawIndex repeats p) β ExpansionSpace π repeats p q A j | |
| def zeroFactor (π : Type w) [Field π] (repeats : Nat β Nat) : | |
| {n m k : Nat} β (p : Path branch n m) β (q : Path branch m k) β | |
| (A : Slots branch n β Type u) β (j : DrawIndex repeats p) β | |
| ExpansionSpace π repeats p q A j | |
| | _, _, _, .refl _, q, A, _ => zeroTape π repeats q A | |
| | n + 1, _, _, .step i p, q, A, j => | |
| match j with | |
| | Sum.inl j => (0 : squareSpace (space π branch n (childFamily A j.val))) | |
| | Sum.inr j => zeroFactor π repeats p q (childFamily A i) j.2 | |
| def zeroExpandedTape (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n β Type u) : | |
| ExpandedTape π repeats p q A := zeroFactor π repeats p q A | |
| def expandedSubTape (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (i : Fin (branch n)) (p : Path branch n m) (q : Path branch m k) | |
| (A : Slots branch (n + 1) β Type u) | |
| (t : ExpandedTape π repeats (.step i p) q A) | |
| (h : Fin (repeats (n + 1))) (b : Bool) : | |
| ExpandedTape π repeats p q (childFamily A i) := fun j => t (.inr ((h, b), j)) | |
| def expand (π : Type w) [Field π] (repeats : Nat β Nat) : | |
| {n m k : Nat} β (p : Path branch n m) β (q : Path branch m k) β | |
| (A : Slots branch n β Type u) β RecursiveSampler.Tape π repeats (p.append q) A β | |
| ExpandedTape π repeats p q A | |
| | _, _, _, .refl _, _, _, t => fun _ => t | |
| | _n + 1, _, _, .step i p, q, A, t => fun j => | |
| match j with | |
| | Sum.inl j => t (.inl j) | |
| | Sum.inr j => expand π repeats p q (childFamily A i) | |
| (subTape π repeats i (p.append q) A t j.1.1 j.1.2) j.2 | |
| def flatten (π : Type w) [Field π] (repeats : Nat β Nat) : | |
| {n m k : Nat} β (p : Path branch n m) β (q : Path branch m k) β | |
| (A : Slots branch n β Type u) β ExpandedTape π repeats p q A β | |
| RecursiveSampler.Tape π repeats (p.append q) A | |
| | _, _, _, .refl _, _, _, t => t () | |
| | _n + 1, _, _, .step i p, q, A, t => fun j => | |
| match j with | |
| | Sum.inl j => t (.inl j) | |
| | Sum.inr j => flatten π repeats p q (childFamily A i) | |
| (expandedSubTape π repeats i p q A t j.1.1 j.1.2) j.2 | |
| theorem flatten_expand (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) : | |
| β (q : Path branch m k) (A : Slots branch n β Type u) | |
| (t : RecursiveSampler.Tape π repeats (p.append q) A), | |
| flatten π repeats p q A (expand π repeats p q A t) = t := by | |
| induction p with | |
| | refl n => intro q A t; rfl | |
| | @step n m i p ih => | |
| intro q A t | |
| funext j | |
| cases j with | |
| | inl j => rfl | |
| | inr j => | |
| exact congrFun | |
| (ih q (childFamily A i) (subTape π repeats i (p.append q) A t j.1.1 j.1.2)) j.2 | |
| theorem expand_flatten (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) : | |
| β (q : Path branch m k) (A : Slots branch n β Type u) | |
| (t : ExpandedTape π repeats p q A), | |
| expand π repeats p q A (flatten π repeats p q A t) = t := by | |
| induction p with | |
| | refl n => | |
| intro q A t | |
| funext j | |
| cases j | |
| rfl | |
| | @step n m i p ih => | |
| intro q A t | |
| funext j | |
| cases j with | |
| | inl j => rfl | |
| | inr j => | |
| exact congrFun | |
| (ih q (childFamily A i) (expandedSubTape π repeats i p q A t j.1.1 j.1.2)) j.2 | |
| def expandEquiv (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n β Type u) : | |
| RecursiveSampler.Tape π repeats (p.append q) A β ExpandedTape π repeats p q A where | |
| toFun := expand π repeats p q A | |
| invFun := flatten π repeats p q A | |
| left_inv := flatten_expand π repeats p q A | |
| right_inv := expand_flatten π repeats p q A | |
| def collapseFactor (π : Type w) [Field π] (repeats : Nat β Nat) : | |
| {n m k : Nat} β (p : Path branch n m) β (q : Path branch m k) β | |
| (A : Slots branch n β Type u) β (j : DrawIndex repeats p) β | |
| ExpansionSpace π repeats p q A j β DrawSpace π repeats p A j | |
| | _, _, _, .refl _, q, A, _ => RecursiveSampler.evaluate π repeats q A | |
| | _, _, _, .step i p, q, A, j => | |
| match j with | |
| | Sum.inl _ => fun t => t | |
| | Sum.inr j => collapseFactor π repeats p q (childFamily A i) j.2 | |
| def collapseExpanded (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n β Type u) : | |
| ExpandedTape π repeats p q A β RecursiveSampler.Tape π repeats p A := | |
| fun t j => collapseFactor π repeats p q A j (t j) | |
| def collapseSuffix (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n β Type u) : | |
| RecursiveSampler.Tape π repeats (p.append q) A β RecursiveSampler.Tape π repeats p A := | |
| collapseExpanded π repeats p q A β expandEquiv π repeats p q A | |
| theorem evaluate_collapseExpanded (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) : | |
| β (q : Path branch m k) (A : Slots branch n β Type u) | |
| (t : ExpandedTape π repeats p q A), | |
| RecursiveSampler.evaluate π repeats p A (collapseExpanded π repeats p q A t) = | |
| RecursiveSampler.evaluate π repeats (p.append q) A (flatten π repeats p q A t) := by | |
| induction p with | |
| | refl n => intro q A t; rfl | |
| | @step n m i p ih => | |
| intro q A t | |
| have hl := funext fun h : Fin (repeats (n + 1)) => | |
| ih q (childFamily A i) (expandedSubTape π repeats i p q A t h false) | |
| have hr := funext fun h : Fin (repeats (n + 1)) => | |
| ih q (childFamily A i) (expandedSubTape π repeats i p q A t h true) | |
| exact congrArgβ | |
| (fun (left right : Fin (repeats (n + 1)) β space π branch n (childFamily A i)) => | |
| combine π A i (repeats (n + 1)) (fun j => t (.inl j)) left right) hl hr | |
| theorem evaluate_collapseSuffix (π : Type w) [Field π] (repeats : Nat β Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n β Type u) | |
| (t : RecursiveSampler.Tape π repeats (p.append q) A) : | |
| RecursiveSampler.evaluate π repeats p A (collapseSuffix π repeats p q A t) = | |
| RecursiveSampler.evaluate π repeats (p.append q) A t := | |
| (evaluate_collapseExpanded π repeats p q A (expand π repeats p q A t)).trans | |
| (congrArg (RecursiveSampler.evaluate π repeats (p.append q) A) | |
| (flatten_expand π repeats p q A t)) | |
| end | |
| end PerfectCompleteness.SamplerComposition | |
| end | |
| end OAI | |