Buckets:
cfahlgren1/math / lean /OAI /Computability /PerfectCompleteness /Foundations /OriginalTerminalSplitLemmas.lean
| import Mathlib.Logic.Equiv.Prod | |
| import OAI.Computability.PerfectCompleteness.Foundations.TerminalCalls | |
| import OAI.Computability.PerfectCompleteness.Sampling.SamplerCompositionLaws | |
| import OAI.Computability.UniqueGames.Foundations.SamplingLemmas | |
| namespace OAI | |
| section | |
| namespace PerfectCompleteness.OriginalTerminalSplit | |
| open RecursiveSpaces DescendantSpaces RecursiveSampler TerminalCalls SamplerComposition | |
| open UniqueGamesTheorem.Foundations.Games | |
| open scoped Classical | |
| noncomputable section | |
| universe u w | |
| variable {branch : Nat โ Nat} {n m k : Nat} | |
| theorem expansionSpace_terminal (๐ : Type w) [Field ๐] | |
| (repeats : Nat โ Nat) (p : Path branch n m) : | |
| โ (q : Path branch m k) (A : Slots branch n โ Type u) | |
| (terminal : TerminalIndex repeats p), | |
| ExpansionSpace ๐ repeats p q A (drawIndex repeats p terminal) = | |
| RecursiveSampler.Tape ๐ repeats q (p.family A) := by | |
| induction p with | |
| | refl n => intro q A terminal; rfl | |
| | step i p ih => | |
| intro q A terminal | |
| exact ih q (childFamily A i) terminal.2 | |
| theorem expansionSpace_exterior (๐ : 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), ยฌ IsTerminal repeats p j โ | |
| ExpansionSpace ๐ repeats p q A j = DrawSpace ๐ repeats p A j := by | |
| induction p with | |
| | refl n => | |
| intro q A j hj | |
| exact False.elim (hj True.intro) | |
| | step i p ih => | |
| intro q A j hj | |
| cases j with | |
| | inl j => rfl | |
| | inr j => exact ih q (childFamily A i) j.2 hj | |
| variable (๐ : Type w) [Field ๐] (repeats : Nat โ Nat) | |
| (p : Path branch n m) (q : Path branch m k) (A : Slots branch n โ Type u) | |
| abbrev ExteriorIndex := {j : DrawIndex repeats p // ยฌ IsTerminal repeats p j} | |
| abbrev ExteriorTape := (j : ExteriorIndex repeats p) โ DrawSpace ๐ repeats p A j.val | |
| abbrev TerminalTape := | |
| TerminalIndex repeats p โ RecursiveSampler.Tape ๐ repeats q (p.family A) | |
| def terminalFactorEquiv (terminal : TerminalIndex repeats p) : | |
| ExpansionSpace ๐ repeats p q A (drawIndex repeats p terminal) โ | |
| RecursiveSampler.Tape ๐ repeats q (p.family A) := | |
| Equiv.cast (expansionSpace_terminal ๐ repeats p q A terminal) | |
| def exteriorFactorEquiv (j : ExteriorIndex repeats p) : | |
| ExpansionSpace ๐ repeats p q A j.val โ DrawSpace ๐ repeats p A j.val := | |
| Equiv.cast (expansionSpace_exterior ๐ repeats p q A j.val j.property) | |
| def terminalTapeEquiv : | |
| ((j : {j : DrawIndex repeats p // IsTerminal repeats p j}) โ | |
| ExpansionSpace ๐ repeats p q A j.val) โ TerminalTape ๐ repeats p q A := | |
| ((Equiv.piCongrLeft | |
| (fun j : {j : DrawIndex repeats p // IsTerminal repeats p j} => | |
| ExpansionSpace ๐ repeats p q A j.val) | |
| (terminalSubtypeEquiv repeats p)).symm).trans | |
| (Equiv.piCongrRight (terminalFactorEquiv ๐ repeats p q A)) | |
| def splitExpanded : ExpandedTape ๐ repeats p q A โ | |
| TerminalTape ๐ repeats p q A ร ExteriorTape ๐ repeats p A := | |
| (Equiv.piEquivPiSubtypeProd (IsTerminal repeats p) | |
| (ExpansionSpace ๐ repeats p q A)).trans | |
| (Equiv.prodCongr (terminalTapeEquiv ๐ repeats p q A) | |
| (Equiv.piCongrRight (exteriorFactorEquiv ๐ repeats p q A))) | |
| def splitTape : RecursiveSampler.Tape ๐ repeats (p.append q) A โ | |
| TerminalTape ๐ repeats p q A ร ExteriorTape ๐ repeats p A := | |
| (expandEquiv ๐ repeats p q A).trans (splitExpanded ๐ repeats p q A) | |
| @[simp] theorem splitExpanded_terminal_apply | |
| (x : ExpandedTape ๐ repeats p q A) (terminal : TerminalIndex repeats p) : | |
| (splitExpanded ๐ repeats p q A x).1 terminal = | |
| terminalFactorEquiv ๐ repeats p q A terminal (x (drawIndex repeats p terminal)) := rfl | |
| @[simp] theorem splitExpanded_exterior_apply | |
| (x : ExpandedTape ๐ repeats p q A) (j : ExteriorIndex repeats p) : | |
| (splitExpanded ๐ repeats p q A x).2 j = | |
| exteriorFactorEquiv ๐ repeats p q A j (x j.val) := rfl | |
| variable [Finite ๐] [hA : โ s, Finite (A s)] | |
| local instance familyFinite : โ s, Finite (p.family A s) := | |
| fun s => hA (p.slotEmbedding s) | |
| def terminalLaw : FiniteDistribution (TerminalTape ๐ repeats p q A) := | |
| FiniteProduct.law (fun _ : TerminalIndex repeats p => | |
| RecursiveSampler.tapeLaw ๐ repeats q (p.family A)) | |
| def exteriorLaw : FiniteDistribution (ExteriorTape ๐ repeats p A) := | |
| FiniteProduct.law (fun j : ExteriorIndex repeats p => | |
| FiniteDistribution.uniform (DrawSpace ๐ repeats p A j.val)) | |
| theorem terminalLaw_uniform : | |
| terminalLaw ๐ repeats p q A = FiniteDistribution.uniform (TerminalTape ๐ repeats p q A) := by | |
| simp only [terminalLaw, RecursiveSampler.tapeLaw_eq_uniform, UniformLinearImage.law_uniform] | |
| theorem exteriorLaw_uniform : | |
| exteriorLaw ๐ repeats p A = FiniteDistribution.uniform (ExteriorTape ๐ repeats p A) := | |
| UniformLinearImage.law_uniform | |
| theorem split_tapeLaw : | |
| (RecursiveSampler.tapeLaw ๐ repeats (p.append q) A).pushforward | |
| (splitTape ๐ repeats p q A) = | |
| (terminalLaw ๐ repeats p q A).product (exteriorLaw ๐ repeats p A) := by | |
| rw [RecursiveSampler.tapeLaw_eq_uniform, FiniteDistribution.pushforward_equiv, | |
| terminalLaw_uniform, exteriorLaw_uniform] | |
| apply FiniteDistribution.eq_of_weight_eq | |
| intro x | |
| change 1 / (Fintype.card (RecursiveSampler.Tape ๐ repeats (p.append q) A) : โ) = | |
| (1 / (Fintype.card (TerminalTape ๐ repeats p q A) : โ)) * | |
| (1 / (Fintype.card (ExteriorTape ๐ repeats p A) : โ)) | |
| rw [Fintype.card_congr (splitTape ๐ repeats p q A), Fintype.card_prod] | |
| simp only [Nat.cast_mul, one_div, mul_inv] | |
| end | |
| end PerfectCompleteness.OriginalTerminalSplit | |
| end | |
| section | |
| namespace PerfectCompleteness.OriginalScalarReconstruction | |
| open RecursiveSpaces DescendantSpaces RecursiveSampler TerminalCalls SamplerComposition | |
| open OriginalTerminalSplit | |
| open scoped Classical | |
| noncomputable section | |
| universe u w | |
| variable {branch : Nat โ Nat} {n m k : Nat} | |
| variable (๐ : Type w) [Field ๐] (repeats : Nat โ Nat) | |
| (p : Path branch n m) (A : Slots branch n โ Type u) | |
| abbrev TerminalValues := TerminalIndex repeats p โ space ๐ branch m (p.family A) | |
| def terminalValueEquiv : | |
| ((j : {j : DrawIndex repeats p // IsTerminal repeats p j}) โ | |
| DrawSpace ๐ repeats p A j.val) โ TerminalValues ๐ repeats p A := | |
| ((Equiv.piCongrLeft | |
| (fun j : {j : DrawIndex repeats p // IsTerminal repeats p j} => | |
| DrawSpace ๐ repeats p A j.val) | |
| (terminalSubtypeEquiv repeats p)).symm).trans | |
| (Equiv.piCongrRight (terminalSpaceEquiv ๐ repeats p A)) | |
| def prefixSplit : RecursiveSampler.Tape ๐ repeats p A โ | |
| TerminalValues ๐ repeats p A ร ExteriorTape ๐ repeats p A := | |
| (Equiv.piEquivPiSubtypeProd (IsTerminal repeats p) (DrawSpace ๐ repeats p A)).trans | |
| (Equiv.prodCongr (terminalValueEquiv ๐ repeats p A) (Equiv.refl _)) | |
| def reconstruct (values : TerminalValues ๐ repeats p A) | |
| (exterior : ExteriorTape ๐ repeats p A) : space ๐ branch n A := | |
| RecursiveSampler.evaluate ๐ repeats p A ((prefixSplit ๐ repeats p A).symm (values, exterior)) | |
| theorem collapseFactor_terminal : | |
| โ (q : Path branch m k) (A : Slots branch n โ Type u) | |
| (terminal : TerminalIndex repeats p) | |
| (x : ExpansionSpace ๐ repeats p q A (drawIndex repeats p terminal)), | |
| terminalSpaceEquiv ๐ repeats p A terminal | |
| (collapseFactor ๐ repeats p q A (drawIndex repeats p terminal) x) = | |
| RecursiveSampler.evaluate ๐ repeats q (p.family A) | |
| (terminalFactorEquiv ๐ repeats p q A terminal x) := by | |
| induction p with | |
| | refl n => intro q A terminal x; rfl | |
| | step i p ih => | |
| intro q A terminal x | |
| exact ih q (childFamily A i) terminal.2 x | |
| theorem collapseFactor_exterior : | |
| โ (q : Path branch m k) (A : Slots branch n โ Type u) | |
| (j : DrawIndex repeats p) (hj : ยฌ IsTerminal repeats p j) | |
| (x : ExpansionSpace ๐ repeats p q A j), | |
| collapseFactor ๐ repeats p q A j x = | |
| exteriorFactorEquiv ๐ repeats p q A โจj, hjโฉ x := by | |
| induction p with | |
| | refl n => | |
| intro q A j hj x | |
| exact False.elim (hj True.intro) | |
| | step i p ih => | |
| intro q A j hj x | |
| cases j with | |
| | inl j => rfl | |
| | inr j => exact ih q (childFamily A i) j.2 hj x | |
| theorem prefixSplit_collapseExpanded (q : Path branch m k) | |
| (x : ExpandedTape ๐ repeats p q A) : | |
| prefixSplit ๐ repeats p A (collapseExpanded ๐ repeats p q A x) = | |
| (fun terminal => RecursiveSampler.evaluate ๐ repeats q (p.family A) | |
| ((splitExpanded ๐ repeats p q A x).1 terminal), | |
| (splitExpanded ๐ repeats p q A x).2) := by | |
| apply Prod.ext | |
| ยท funext terminal | |
| exact collapseFactor_terminal ๐ repeats p q A terminal (x (drawIndex repeats p terminal)) | |
| ยท funext j | |
| exact collapseFactor_exterior ๐ repeats p q A j.val j.property (x j.val) | |
| theorem reconstruct_original (q : Path branch m k) | |
| (x : RecursiveSampler.Tape ๐ repeats (p.append q) A) : | |
| reconstruct ๐ repeats p A | |
| (fun terminal => RecursiveSampler.evaluate ๐ repeats q (p.family A) | |
| ((splitTape ๐ repeats p q A x).1 terminal)) | |
| (splitTape ๐ repeats p q A x).2 = | |
| RecursiveSampler.evaluate ๐ repeats (p.append q) A x := by | |
| have hsplit := prefixSplit_collapseExpanded ๐ repeats p A q | |
| (expandEquiv ๐ repeats p q A x) | |
| change prefixSplit ๐ repeats p A (collapseSuffix ๐ repeats p q A x) = | |
| (fun terminal => RecursiveSampler.evaluate ๐ repeats q (p.family A) | |
| ((splitTape ๐ repeats p q A x).1 terminal), | |
| (splitTape ๐ repeats p q A x).2) at hsplit | |
| unfold reconstruct | |
| rw [โ hsplit, Equiv.symm_apply_apply] | |
| exact evaluate_collapseSuffix ๐ repeats p q A x | |
| end | |
| end PerfectCompleteness.OriginalScalarReconstruction | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 9.92 kB
- Xet hash:
- 24fc32d78c2158ed7c37c1bb93a2d3acf42cb740b4f6f6105d50b2d31b00878e
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.