Download data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerCompositionLaws.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.02 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerCompositionLaws.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerCompositionLaws.lean
-
curl -L -o SamplerCompositionLaws.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/SamplerCompositionLaws.lean
7.02 kB
| import OAI.Computability.PerfectCompleteness.Sampling.CutSamplerReplayTransportLemmas | |
| import OAI.Computability.PerfectCompleteness.Sampling.SamplerComposition | |
| namespace OAI | |
| section | |
| namespace PerfectCompleteness.SamplerComposition | |
| open PointwiseSpaces RecursiveSpaces DescendantSpaces RecursiveSampler | |
| open UniqueGamesTheorem.Foundations.Games | |
| noncomputable section | |
| universe u w | |
| variable {branch : Nat β Nat} {n m k : Nat} | |
| variable (π : Type w) [Field π] | |
| instance expansionSpaceNonempty (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) (j : DrawIndex repeats p) : | |
| Nonempty (ExpansionSpace π repeats p q A j) := | |
| β¨zeroFactor π repeats p q A jβ© | |
| instance expandedTapeNonempty (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) : | |
| Nonempty (ExpandedTape π repeats p q A) := | |
| β¨zeroExpandedTape π repeats p q Aβ© | |
| variable [Finite π] | |
| theorem expansionSpace_finite (repeats : Nat β Nat) (p : Path branch n m) : | |
| β (q : Path branch m k) (A : Slots branch n β Type u), | |
| (β s, Finite (A s)) β β j : DrawIndex repeats p, | |
| Finite (ExpansionSpace π repeats p q A j) := by | |
| induction p with | |
| | refl n => | |
| intro q A hA j | |
| let : β s, Finite (A s) := hA | |
| let : β d : DrawIndex repeats q, Fintype (DrawSpace π repeats q A d) := | |
| fun d => drawSpaceFintype π repeats q A d | |
| change Finite (RecursiveSampler.Tape π repeats q A) | |
| infer_instance | |
| | @step n m i p ih => | |
| intro q A hA j | |
| cases j with | |
| | inl j => | |
| let : β s, Finite (childFamily A j.val s) := fun s => hA (j.val, s) | |
| change Finite (squareSpace (space π branch n (childFamily A j.val))) | |
| infer_instance | |
| | inr j => | |
| exact ih q (childFamily A i) (fun s => hA (i, s)) j.2 | |
| instance expansionSpaceFinite (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] | |
| (j : DrawIndex repeats p) : Finite (ExpansionSpace π repeats p q A j) := | |
| expansionSpace_finite π repeats p q A (fun _ => inferInstance) j | |
| instance expansionSpaceFintype (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] | |
| (j : DrawIndex repeats p) : Fintype (ExpansionSpace π repeats p q A j) := | |
| Fintype.ofFinite _ | |
| instance expandedTapeFintype (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] : | |
| Fintype (ExpandedTape π repeats p q A) := | |
| @Pi.instFintype (DrawIndex repeats p) (ExpansionSpace π repeats p q A) | |
| (drawIndexDecidableEq repeats p) (drawIndexFintype repeats p) | |
| (fun j => expansionSpaceFintype π repeats p q A j) | |
| def expandedTapeLaw (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] : | |
| FiniteDistribution (ExpandedTape π repeats p q A) := by | |
| letI : β j : DrawIndex repeats p, Fintype (ExpansionSpace π repeats p q A j) := | |
| fun j => expansionSpaceFintype π repeats p q A j | |
| letI : β j : DrawIndex repeats p, Nonempty (ExpansionSpace π repeats p q A j) := | |
| fun j => expansionSpaceNonempty π repeats p q A j | |
| exact FiniteProduct.law (fun j => FiniteDistribution.uniform (ExpansionSpace π repeats p q A j)) | |
| theorem expandedTapeLaw_eq_uniform (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] : | |
| expandedTapeLaw π repeats p q A = FiniteDistribution.uniform (ExpandedTape π repeats p q A) := by | |
| let : β j : DrawIndex repeats p, Fintype (ExpansionSpace π repeats p q A j) := | |
| fun j => expansionSpaceFintype π repeats p q A j | |
| let : β j : DrawIndex repeats p, Nonempty (ExpansionSpace π repeats p q A j) := | |
| fun j => expansionSpaceNonempty π repeats p q A j | |
| exact UniformLinearImage.law_uniform | |
| theorem expand_tapeLaw (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] : | |
| (tapeLaw π repeats (p.append q) A).pushforward (expandEquiv π repeats p q A) = | |
| expandedTapeLaw π repeats p q A := by | |
| rw [tapeLaw_eq_uniform, expandedTapeLaw_eq_uniform, | |
| β FiniteDistribution.transport_eq_pushforward] | |
| exact UniformConditioning.uniform_transport (expandEquiv π repeats p q A) | |
| def factorLaw (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] | |
| (j : DrawIndex repeats p) : FiniteDistribution (DrawSpace π repeats p A j) := | |
| (FiniteDistribution.uniform (ExpansionSpace π repeats p q A j)).pushforward | |
| (collapseFactor π repeats p q A j) | |
| theorem collapseExpanded_expandedTapeLaw (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] : | |
| (expandedTapeLaw π repeats p q A).pushforward (collapseExpanded π repeats p q A) = | |
| FiniteProduct.law (factorLaw π repeats p q A) := by | |
| let : β j : DrawIndex repeats p, Fintype (ExpansionSpace π repeats p q A j) := | |
| fun j => expansionSpaceFintype π repeats p q A j | |
| let : β j : DrawIndex repeats p, Nonempty (ExpansionSpace π repeats p q A j) := | |
| fun j => expansionSpaceNonempty π repeats p q A j | |
| exact FiniteProduct.pushforward_map _ (collapseFactor π repeats p q A) | |
| theorem collapseSuffix_tapeLaw (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] : | |
| (tapeLaw π repeats (p.append q) A).pushforward (collapseSuffix π repeats p q A) = | |
| FiniteProduct.law (factorLaw π repeats p q A) := by | |
| calc | |
| _ = ((tapeLaw π repeats (p.append q) A).pushforward | |
| (expandEquiv π repeats p q A)).pushforward (collapseExpanded π repeats p q A) := | |
| (FiniteDistribution.pushforward_comp _ _ _).symm | |
| _ = _ := by rw [expand_tapeLaw, collapseExpanded_expandedTapeLaw] | |
| theorem law_append (repeats : Nat β Nat) (p : Path branch n m) | |
| (q : Path branch m k) (A : Slots branch n β Type u) [β s, Finite (A s)] | |
| [Fintype (space π branch n A)] : | |
| RecursiveSampler.law π repeats (p.append q) A = | |
| (FiniteProduct.law (factorLaw π repeats p q A)).pushforward | |
| (RecursiveSampler.evaluate π repeats p A) := by | |
| calc | |
| _ = ((tapeLaw π repeats (p.append q) A).pushforward | |
| (collapseSuffix π repeats p q A)).pushforward | |
| (RecursiveSampler.evaluate π repeats p A) := by | |
| rw [FiniteDistribution.pushforward_comp] | |
| unfold RecursiveSampler.law | |
| congr 1 | |
| funext t | |
| exact (evaluate_collapseSuffix π repeats p q A t).symm | |
| _ = _ := by rw [collapseSuffix_tapeLaw] | |
| end | |
| end PerfectCompleteness.SamplerComposition | |
| end | |
| end OAI | |