introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
8.6 kB
import OAI.Computability.PerfectCompleteness.Machines.MetadataFreeTapeLemmas
import OAI.Computability.PerfectCompleteness.Sampling.SamplerCardinalityLemmas
namespace OAI
section
namespace PerfectCompleteness.MetadataFreeLaw
open RecursiveSpaces DescendantSpaces TreeSourceSpaces
open MetadataFreeSampler MetadataFreeTape
open UniqueGamesTheorem.Foundations.Games
open scoped BigOperators Classical
noncomputable section
variable {branch : Nat β†’ Nat} {n d t v m : Nat}
theorem tape_weight_eq (clauses : Fin m β†’ SourceClause.NormalizedClause v)
(rows repeats : Nat β†’ Nat) (p : Path branch n d) :
βˆ€ (q : PreliminarySampler.Questions branch n t m)
(Ο‰ : WholeArraySampler.Tape rows repeats p (sourceSlots clauses q)),
(WholeArraySampler.tapeLaw rows repeats p (sourceSlots clauses q)).weight Ο‰ =
(WholeArraySampler.tapeLaw rows repeats p (dummyTreeSlots (sourceSigns clauses q))).weight
(tapeEquiv clauses rows repeats p q Ο‰) := by
induction p with
| refl n =>
intro q Ο‰
rfl
| @step n d i p ih =>
intro q Ο‰
change (∏ k : WholeArraySampler.StepIndex i,
(WholeArraySampler.componentLaw rows repeats i p (sourceSlots clauses q) k).weight (Ο‰ k)) =
∏ k : WholeArraySampler.StepIndex i,
(WholeArraySampler.componentLaw rows repeats i p
(dummyTreeSlots (sourceSigns clauses q)) k).weight
(tapeEquiv clauses rows repeats (.step i p) q Ο‰ k)
apply Finset.prod_congr rfl
intro k _
rcases k with u | (u | j)
Β· rfl
Β· cases u
exact ih (fun leaf k => q (i, leaf) k) (Ο‰ (.inr (.inl ())))
Β· rfl
theorem tapeLaw_transport (clauses : Fin m β†’ SourceClause.NormalizedClause v)
(rows repeats : Nat β†’ Nat) (p : Path branch n d)
(q : PreliminarySampler.Questions branch n t m) :
(WholeArraySampler.tapeLaw rows repeats p (sourceSlots clauses q)).transport
(tapeEquiv clauses rows repeats p q) =
WholeArraySampler.tapeLaw rows repeats p (dummyTreeSlots (sourceSigns clauses q)) := by
apply FiniteDistribution.eq_of_weight_eq
intro Ο‰
change (WholeArraySampler.tapeLaw rows repeats p (sourceSlots clauses q)).weight
((tapeEquiv clauses rows repeats p q).symm Ο‰) = _
simpa only [Equiv.apply_symm_apply] using
tape_weight_eq clauses rows repeats p q ((tapeEquiv clauses rows repeats p q).symm Ο‰)
abbrev SignedOutcome (signs : SignTuple branch n t) (rows repeats : Nat β†’ Nat) :=
Ξ£ leaf : Slots branch n,
WholeArraySampler.Tape rows repeats (GeometricPath.leafPath leaf) (dummyTreeSlots signs) Γ—
PreliminarySampler.Choice rows leaf
def signedLaw (signs : SignTuple branch n t) (rows repeats : Nat β†’ Nat)
(hn : 0 < n) (hbranch : βˆ€ k < n, 0 < branch k)
(hrows : βˆ€ k, 0 < rows (k + 1)) : FiniteDistribution (SignedOutcome signs rows repeats) :=
CompletionSoundness.sigmaLaw (GeometricPath.law n hbranch) fun leaf =>
(WholeArraySampler.tapeLaw rows repeats (GeometricPath.leafPath leaf) (dummyTreeSlots signs)).product
(PreliminarySampler.choiceLaw leaf hn hrows)
def signedRationalLaw (signs : SignTuple branch n t) (rows repeats : Nat β†’ Nat)
(hn : 0 < n) (hbranch : βˆ€ k < n, 0 < branch k) (hrows : βˆ€ k, 0 < rows (k + 1)) :
RationalFiniteLaw.RationalLaw (signedLaw signs rows repeats hn hbranch hrows) :=
RationalFiniteLaw.sigma (SamplerRationality.pathLaw hbranch) fun leaf =>
RationalFiniteLaw.product
(SamplerRationality.wholeArrayTapeLaw rows repeats (GeometricPath.leafPath leaf)
(dummyTreeSlots signs))
(SamplerRationality.choiceLaw leaf hn hrows)
theorem signedLaw_positive (signs : SignTuple branch n t) (rows repeats : Nat β†’ Nat)
(hn : 0 < n) (hbranch : βˆ€ k < n, 0 < branch k) (hrows : βˆ€ k, 0 < rows (k + 1))
(e : SignedOutcome signs rows repeats) :
0 < (signedLaw signs rows repeats hn hbranch hrows).weight e :=
RationalFiniteLaw.real_positive (signedRationalLaw signs rows repeats hn hbranch hrows) e
def encodeOutcome (clauses : Fin m β†’ SourceClause.NormalizedClause v) (rows repeats : Nat β†’ Nat)
(e : PreliminarySampler.Raw clauses branch n t rows repeats) :
SignedOutcome (sourceSigns clauses e.1.1) rows repeats :=
⟨e.1.2, tapeEquiv clauses rows repeats (GeometricPath.leafPath e.1.2) e.1.1 e.2.1, e.2.2⟩
theorem raw_weight_eq [NeZero m] (clauses : Fin m β†’ SourceClause.NormalizedClause v)
(rows repeats : Nat β†’ Nat) (hn : 0 < n)
(hbranch : βˆ€ k < n, 0 < branch k) (hrows : βˆ€ k, 0 < rows (k + 1))
(e : PreliminarySampler.Raw clauses branch n t rows repeats) :
(PreliminarySampler.law clauses rows repeats hn hbranch hrows).weight e =
(1 / (Fintype.card (PreliminarySampler.Questions branch n t m) : ℝ)) *
(signedLaw (sourceSigns clauses e.1.1) rows repeats hn hbranch hrows).weight
(encodeOutcome clauses rows repeats e) := by
change ((1 / (Fintype.card (PreliminarySampler.Questions branch n t m) : ℝ)) *
(GeometricPath.law n hbranch).weight e.1.2) *
((WholeArraySampler.tapeLaw rows repeats (GeometricPath.leafPath e.1.2)
(sourceSlots clauses e.1.1)).weight e.2.1 *
(PreliminarySampler.choiceLaw e.1.2 hn hrows).weight e.2.2) =
(1 / (Fintype.card (PreliminarySampler.Questions branch n t m) : ℝ)) *
((GeometricPath.law n hbranch).weight e.1.2 *
((WholeArraySampler.tapeLaw rows repeats (GeometricPath.leafPath e.1.2)
(dummyTreeSlots (sourceSigns clauses e.1.1))).weight
(tapeEquiv clauses rows repeats (GeometricPath.leafPath e.1.2) e.1.1 e.2.1) *
(PreliminarySampler.choiceLaw e.1.2 hn hrows).weight e.2.2))
rw [tape_weight_eq clauses rows repeats (GeometricPath.leafPath e.1.2) e.1.1 e.2.1]
exact mul_assoc _ _ _
theorem raw_weight_rational [NeZero m] (clauses : Fin m β†’ SourceClause.NormalizedClause v)
(rows repeats : Nat β†’ Nat) (hn : 0 < n)
(hbranch : βˆ€ k < n, 0 < branch k) (hrows : βˆ€ k, 0 < rows (k + 1))
(e : PreliminarySampler.Raw clauses branch n t rows repeats) :
(PreliminarySampler.law clauses rows repeats hn hbranch hrows).weight e =
(1 / (Fintype.card (PreliminarySampler.Questions branch n t m) : ℝ)) *
((signedRationalLaw (sourceSigns clauses e.1.1) rows repeats hn hbranch hrows).weights
(encodeOutcome clauses rows repeats e) : ℝ) := by
rw [raw_weight_eq, (signedRationalLaw (sourceSigns clauses e.1.1)
rows repeats hn hbranch hrows).cast_weight]
def rawEquiv (clauses : Fin m β†’ SourceClause.NormalizedClause v) (rows repeats : Nat β†’ Nat) :
PreliminarySampler.Raw clauses branch n t rows repeats ≃
(Ξ£ q : PreliminarySampler.Questions branch n t m,
SignedOutcome (sourceSigns clauses q) rows repeats) where
toFun e := ⟨e.1.1, encodeOutcome clauses rows repeats e⟩
invFun y := ⟨(y.1, y.2.1),
(tapeEquiv clauses rows repeats (GeometricPath.leafPath y.2.1) y.1).symm y.2.2.1,
y.2.2.2⟩
left_inv := by
rintro ⟨⟨q, leaf⟩, Ο‰, choice⟩
simp only [encodeOutcome]
exact congrArg
(fun tape : WholeArraySampler.Tape rows repeats (GeometricPath.leafPath leaf)
(sourceSlots clauses q) =>
(⟨(q, leaf), tape, choice⟩ : PreliminarySampler.Raw clauses branch n t rows repeats))
((tapeEquiv clauses rows repeats (GeometricPath.leafPath leaf) q).symm_apply_apply Ο‰)
right_inv := by
rintro ⟨q, leaf, Ο‰, choice⟩
simp only [encodeOutcome, Equiv.apply_symm_apply]
theorem rawLaw_transport [NeZero m] (clauses : Fin m β†’ SourceClause.NormalizedClause v)
(rows repeats : Nat β†’ Nat) (hn : 0 < n)
(hbranch : βˆ€ k < n, 0 < branch k) (hrows : βˆ€ k, 0 < rows (k + 1)) :
(PreliminarySampler.law (t := t) clauses rows repeats hn hbranch hrows).transport
(rawEquiv clauses rows repeats) =
CompletionSoundness.sigmaLaw PreliminarySampler.questionsLaw
(fun q => signedLaw (sourceSigns clauses q) rows repeats hn hbranch hrows) := by
apply FiniteDistribution.eq_of_weight_eq
rintro ⟨q, leaf, Ο‰, choice⟩
change (PreliminarySampler.law clauses rows repeats hn hbranch hrows).weight
⟨(q, leaf), (tapeEquiv clauses rows repeats (GeometricPath.leafPath leaf) q).symm Ο‰,
choice⟩ =
(1 / (Fintype.card (PreliminarySampler.Questions branch n t m) : ℝ)) *
(signedLaw (sourceSigns clauses q) rows repeats hn hbranch hrows).weight ⟨leaf, Ο‰, choice⟩
rw [raw_weight_eq]
simp only [encodeOutcome, Equiv.apply_symm_apply]
end
end PerfectCompleteness.MetadataFreeLaw
end
end OAI