cfahlgren1/math / lean /OAI /Computability /PerfectCompleteness /Foundations /OriginalTerminalSplitLemmas.lean
cfahlgren1's picture
download
raw
9.92 kB
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.