math / data /lean /OAI /Computability /PerfectCompleteness /Construction /SourceQuestionOrderLemmas.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
22.1 kB
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Data.List.FinRange
import OAI.Computability.PerfectCompleteness.Construction.HiddenChildMixture
import OAI.Computability.PerfectCompleteness.Construction.TreeCanonical
import OAI.Computability.PerfectCompleteness.Foundations.HierarchicalArrays
import OAI.Computability.PerfectCompleteness.Foundations.KeyFiniteness
import OAI.Computability.PerfectCompleteness.Machines.TupleIndexMachine
import OAI.Computability.PerfectCompleteness.Sampling.CommonProductVariationLemmas
import OAI.Computability.PerfectCompleteness.Sampling.PreliminarySampler
import OAI.Computability.PerfectCompleteness.Sampling.RationalFiniteLawLemmas
import OAI.Computability.PerfectCompleteness.Sampling.UniformDensity
import OAI.Computability.UniqueGames.Foundations.MixtureLemmas
namespace OAI
namespace PerfectCompleteness.SourceQuestionOrder
open Turing UniqueGamesTheorem.Foundations.Complexity
open scoped BigOperators Classical
noncomputable section
variable {branch : Nat β†’ Nat} {n t m : Nat}
def questionToTuple (question : PreliminarySampler.Questions branch n t m) :
Fin (TreeCanonical.locationCount branch n t) β†’ Fin m :=
fun j => question ((TreeCanonical.numbering branch n t).symm j).1
((TreeCanonical.numbering branch n t).symm j).2
def tupleToQuestion (tuple : Fin (TreeCanonical.locationCount branch n t) β†’ Fin m) :
PreliminarySampler.Questions branch n t m :=
fun leaf coordinate => tuple (TreeCanonical.numbering branch n t (leaf, coordinate))
@[simp] theorem tupleToQuestion_questionToTuple
(question : PreliminarySampler.Questions branch n t m) :
tupleToQuestion (questionToTuple question) = question := by
funext leaf coordinate
simp only [tupleToQuestion, questionToTuple, Equiv.symm_apply_apply]
@[simp] theorem questionToTuple_tupleToQuestion
(tuple : Fin (TreeCanonical.locationCount branch n t) β†’ Fin m) :
questionToTuple (tupleToQuestion (branch := branch) (n := n) (t := t) tuple) = tuple := by
funext j
simp only [questionToTuple, tupleToQuestion, Prod.mk.eta, Equiv.apply_symm_apply]
def questionTupleEquiv (branch : Nat β†’ Nat) (n t m : Nat) :
PreliminarySampler.Questions branch n t m ≃
(Fin (TreeCanonical.locationCount branch n t) β†’ Fin m) where
toFun := questionToTuple
invFun := tupleToQuestion
left_inv := tupleToQuestion_questionToTuple
right_inv := questionToTuple_tupleToQuestion
def sourceOrder (branch : Nat β†’ Nat) (n t m : Nat) :
List (PreliminarySampler.Questions branch n t m) :=
(MachineTupleOdometer.tupleOrder m (TreeCanonical.locationCount branch n t)).reverse.map
tupleToQuestion
@[simp] theorem sourceOrder_length (branch : Nat β†’ Nat) (n t m : Nat) :
(sourceOrder branch n t m).length = m ^ TreeCanonical.locationCount branch n t := by
simp only [sourceOrder, List.length_map, List.length_reverse,
MachineTupleOdometer.tupleOrder_length]
theorem sourceOrder_nodup (branch : Nat β†’ Nat) (n t m : Nat) :
(sourceOrder branch n t m).Nodup := by
apply List.Nodup.map (questionTupleEquiv branch n t m).symm.injective
apply List.nodup_reverse.mpr
exact List.nodup_ofFn.mpr
(finFunctionFinEquiv (m := m) (n := TreeCanonical.locationCount branch n t)).symm.injective
theorem mem_sourceOrder (question : PreliminarySampler.Questions branch n t m) :
question ∈ sourceOrder branch n t m := by
apply List.mem_map.mpr
refine ⟨questionToTuple question, ?_, tupleToQuestion_questionToTuple question⟩
rw [List.mem_reverse]
change questionToTuple question ∈ List.ofFn
(finFunctionFinEquiv (m := m) (n := TreeCanonical.locationCount branch n t)).symm
apply List.mem_ofFn.mpr
exact ⟨finFunctionFinEquiv (questionToTuple question), Equiv.symm_apply_apply _ _⟩
@[simp] theorem sourceOrder_toFinset (branch : Nat β†’ Nat) (n t m : Nat) :
(sourceOrder branch n t m).toFinset = Finset.univ := by
ext question
simp only [List.mem_toFinset, Finset.mem_univ, iff_true]
exact mem_sourceOrder question
theorem sum_map_sourceOrder {A : Type*} [AddCommMonoid A]
(f : PreliminarySampler.Questions branch n t m β†’ A) :
((sourceOrder branch n t m).map f).sum = βˆ‘ question, f question := by
rw [← List.sum_toFinset f (sourceOrder_nodup branch n t m), sourceOrder_toFinset]
def numberedClauseIDs (question : PreliminarySampler.Questions branch n t m) : List Nat :=
List.ofFn (fun j => (questionToTuple question j).val)
@[simp] theorem numberedClauseIDs_length
(question : PreliminarySampler.Questions branch n t m) :
(numberedClauseIDs question).length = TreeCanonical.locationCount branch n t := by
simp only [numberedClauseIDs, List.length_ofFn]
@[simp] theorem numberedClauseIDs_tupleToQuestion
(tuple : Fin (TreeCanonical.locationCount branch n t) β†’ Fin m) :
numberedClauseIDs (tupleToQuestion (branch := branch) (n := n) (t := t) tuple) =
List.ofFn (fun j => (tuple j).val) := by
simp only [numberedClauseIDs, questionToTuple_tupleToQuestion]
theorem outputBlock_all_eq_sourceOrder (branch : Nat β†’ Nat) (n t m : Nat) :
TupleEnumerationMachine.outputBlock (width := TreeCanonical.locationCount branch n t)
m (TreeCanonical.locationCount branch n t)
(fun _ => 0) =
(sourceOrder branch n t m).flatMap (fun question => encodeWords (numberedClauseIDs question)) := by
rw [TupleEnumerationMachine.outputBlock_all]
simp only [sourceOrder, List.flatMap_map,
numberedClauseIDs_tupleToQuestion]
theorem output_eq_sourceOrder (branch : Nat β†’ Nat) (n t m : Nat) :
TupleIndexMachine.output (TreeCanonical.locationCount branch n t) m =
(sourceOrder branch n t m).flatMap (fun question => encodeWords (numberedClauseIDs question)) := by
exact outputBlock_all_eq_sourceOrder branch n t m
def sourceOutputsInTime (branch : Nat β†’ Nat) (n t m : Nat) (positive : 0 < m) :
TM2OutputsInTime (TupleIndexMachine.machine (TreeCanonical.locationCount branch n t))
(encodeWord m)
(some ((sourceOrder branch n t m).flatMap
(fun question => encodeWords (numberedClauseIDs question))))
(TupleIndexMachine.totalBudget (TreeCanonical.locationCount branch n t) m) := by
exact Eq.mp
(congrArg (fun words : List Bool =>
TM2OutputsInTime (TupleIndexMachine.machine (TreeCanonical.locationCount branch n t))
(encodeWord m) (some words)
(TupleIndexMachine.totalBudget (TreeCanonical.locationCount branch n t) m))
(output_eq_sourceOrder branch n t m))
(TupleIndexMachine.outputsInTime (width := TreeCanonical.locationCount branch n t) m positive)
end
end PerfectCompleteness.SourceQuestionOrder
namespace PerfectCompleteness.TreeCardinality
open TreeSourceSpaces HierarchicalArrays
open scoped BigOperators
noncomputable section
variable {branch : Nat β†’ Nat} {n t : Nat}
def domainBound (branch : Nat β†’ Nat) (n t : Nat) : Nat :=
(7 ^ t) ^ Fintype.card (RecursiveSpaces.Slots branch n)
def functionBound (branch : Nat β†’ Nat) (n t : Nat) : Nat :=
2 ^ domainBound branch n t
theorem domain_card_le
(slots : RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Nat.card (Domain slots) ≀ domainBound branch n t := by
change Nat.card (βˆ€ leaf, LeafDomain slots leaf) ≀ _
rw [Nat.card_pi]
calc
_ ≀ ∏ _leaf : RecursiveSpaces.Slots branch n, (7 ^ t : Nat) :=
Finset.prod_le_prod (fun leaf _ =>
CanonicalKeys.card_assignment_le_seven_pow (slots leaf))
_ = domainBound branch n t := by simp [domainBound]
theorem subspace_card_le
(slots : RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot)
(V : Submodule F2 (Domain slots β†’ F2)) :
Nat.card V ≀ functionBound branch n t := by
calc
Nat.card V ≀ Nat.card (Domain slots β†’ F2) :=
Nat.card_le_card_of_injective (fun f : V => f.val) Subtype.val_injective
_ = 2 ^ Nat.card (Domain slots) := by rw [Nat.card_fun, Nat.card_zmod]
_ ≀ functionBound branch n t :=
pow_le_pow_rightβ‚€ (by decide : (1 : Nat) ≀ 2) (domain_card_le slots)
theorem H_card_le
(slots : RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Nat.card (H slots) ≀ functionBound branch n t :=
subspace_card_le slots (H slots)
theorem square_card_le
(slots : RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Nat.card (PointwiseSpaces.squareSpace (H slots)) ≀ functionBound branch n t :=
subspace_card_le slots (PointwiseSpaces.squareSpace (H slots))
def arraysBound (branch : Nat β†’ Nat) (n t : Nat) (rows : Nat β†’ Nat) : Nat :=
∏ node : Nodes branch n,
functionBound branch (Nodes.height node) t ^ rows (Nodes.height node)
theorem arrays_card_le
(slots : RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot)
(rows : Nat β†’ Nat) :
Nat.card (Arrays slots rows) ≀ arraysBound branch n t rows := by
change Nat.card (βˆ€ node : Nodes branch n,
Fin (rows (Nodes.height node)) β†’ H (nodeSlots slots node)) ≀ _
rw [Nat.card_pi]
apply Finset.prod_le_prod
intro node _
rw [Nat.card_fun, Nat.card_fin]
exact pow_le_pow_leftβ‚€ (Nat.zero_le _) (H_card_le (nodeSlots slots node)) _
theorem source_questions_card (m : Nat) :
Nat.card (PreliminarySampler.Questions branch n t m) =
m ^ (t * Fintype.card (RecursiveSpaces.Slots branch n)) := by
simp only [PreliminarySampler.Questions, Nat.card_eq_fintype_card,
Fintype.card_fun, Fintype.card_fin, ← pow_mul]
theorem source_base_card (m : Nat) :
Nat.card (PreliminarySampler.Base branch n t m) =
m ^ (t * Fintype.card (RecursiveSpaces.Slots branch n)) *
Fintype.card (RecursiveSpaces.Slots branch n) := by
rw [Nat.card_prod, source_questions_card, Nat.card_eq_fintype_card]
end
end PerfectCompleteness.TreeCardinality
namespace PerfectCompleteness.ChildBlockCardinality
open RecursiveSpaces TreeSourceSpaces HierarchicalArrays PointwiseSpaces
open UniqueGamesTheorem.Foundations.Games
noncomputable section
variable {branch : Nat β†’ Nat} {n t : Nat}
abbrev Raw (calls : Nat) (rows : Nat β†’ Nat)
(slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :=
(Fin calls β†’ squareSpace (H slots)) Γ— Arrays slots rows
instance rawFintype (calls : Nat) (rows : Nat β†’ Nat)
(slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Fintype (Raw calls rows slots) := Fintype.ofFinite _
instance rawNonempty (calls : Nat) (rows : Nat β†’ Nat)
(slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Nonempty (Raw calls rows slots) := ⟨(fun _ => 0, fun _ _ => 0)⟩
def bound (branch : Nat β†’ Nat) (n t calls : Nat) (rows : Nat β†’ Nat) : Nat :=
TreeCardinality.functionBound branch n t ^ calls *
TreeCardinality.arraysBound branch n t rows
theorem card_le (calls : Nat) (rows : Nat β†’ Nat)
(slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Nat.card (Raw calls rows slots) ≀ bound branch n t calls rows := by
rw [Nat.card_prod, Nat.card_fun, Nat.card_fin]
exact Nat.mul_le_mul
(pow_le_pow_leftβ‚€ (Nat.zero_le _) (TreeCardinality.square_card_le slots) calls)
(TreeCardinality.arrays_card_le slots rows)
theorem fintype_card_le (calls : Nat) (rows : Nat β†’ Nat)
(slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
Fintype.card (Raw calls rows slots) ≀ bound branch n t calls rows := by
simpa only [Nat.card_eq_fintype_card] using card_le calls rows slots
theorem bound_pos (calls : Nat) (rows : Nat β†’ Nat)
(slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot) :
0 < bound branch n t calls rows :=
lt_of_lt_of_le (Nat.card_pos (Ξ± := Raw calls rows slots)) (card_le calls rows slots)
def density {calls : Nat} {rows : Nat β†’ Nat}
{slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot}
(ΞΌ : FiniteDistribution (Raw calls rows slots)) : Raw calls rows slots β†’ ℝ :=
UniformDensity.density ΞΌ
theorem weight_eq {calls : Nat} {rows : Nat β†’ Nat}
{slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot}
(ΞΌ : FiniteDistribution (Raw calls rows slots)) (x : Raw calls rows slots) :
ΞΌ.weight x = (FiniteDistribution.uniform (Raw calls rows slots)).weight x * density ΞΌ x :=
UniformDensity.weight_eq ΞΌ x
theorem mean_one {calls : Nat} {rows : Nat β†’ Nat}
{slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot}
(ΞΌ : FiniteDistribution (Raw calls rows slots)) :
(FiniteDistribution.uniform (Raw calls rows slots)).expectation (density ΞΌ) = 1 :=
UniformDensity.mean_one ΞΌ
theorem density_le {calls : Nat} {rows : Nat β†’ Nat}
{slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot}
(ΞΌ : FiniteDistribution (Raw calls rows slots)) (x : Raw calls rows slots) :
density ΞΌ x ≀ (bound branch n t calls rows : ℝ) :=
(UniformDensity.density_le_card ΞΌ x).trans
(by exact_mod_cast fintype_card_le calls rows slots)
theorem second_moment_le {calls : Nat} {rows : Nat β†’ Nat}
{slots : Slots branch n β†’ Fin t β†’ MixedSupport.Slot}
(ΞΌ : FiniteDistribution (Raw calls rows slots)) :
(FiniteDistribution.uniform (Raw calls rows slots)).expectation
(fun x => (density ΞΌ x - 1) ^ 2) ≀ (bound branch n t calls rows : ℝ) ^ 2 := by
apply UniformDensity.second_moment_le
exact_mod_cast fintype_card_le calls rows slots
end
end PerfectCompleteness.ChildBlockCardinality
namespace PerfectCompleteness.ChildBlockMixture
open UniqueGamesTheorem.Foundations.Games
open scoped BigOperators
noncomputable section
section General
variable {I : Type*} [Fintype I] [DecidableEq I] [Nonempty I]
{Ξ© : I β†’ Type*} [βˆ€ i, Fintype (Ξ© i)] [βˆ€ i, Nonempty (Ξ© i)]
def component (Q : (i : I) β†’ FiniteDistribution (Ξ© i)) (chosen i : I) :
FiniteDistribution (Ξ© i) :=
if h : chosen = i then h β–Έ Q chosen else FiniteDistribution.uniform (Ξ© i)
def reference : FiniteDistribution ((i : I) β†’ Ξ© i) :=
FiniteProduct.law (fun i => FiniteDistribution.uniform (Ξ© i))
def special (Q : (i : I) β†’ FiniteDistribution (Ξ© i)) (chosen : I) :
FiniteDistribution ((i : I) β†’ Ξ© i) :=
FiniteProduct.law (component Q chosen)
def mixture (Q : (i : I) β†’ FiniteDistribution (Ξ© i)) :
FiniteDistribution ((i : I) β†’ Ξ© i) :=
HiddenChildMixture.mixture (special Q)
omit [Fintype I] [Nonempty I] in
theorem component_weight (Q : (i : I) β†’ FiniteDistribution (Ξ© i))
(chosen i : I) (x : Ξ© i) :
(component Q chosen i).weight x =
(FiniteDistribution.uniform (Ξ© i)).weight x *
FiniteProduct.factor chosen (UniformDensity.density (Q chosen)) i x := by
by_cases h : i = chosen
Β· subst i
simp only [component, FiniteProduct.factor_self]
exact UniformDensity.weight_eq (Q chosen) x
Β· simp only [component, dite_eq_right (Ne.symm h),
FiniteProduct.factor_other chosen i h, mul_one]
omit [Nonempty I] in
theorem special_weight (Q : (i : I) β†’ FiniteDistribution (Ξ© i))
(chosen : I) (x : (i : I) β†’ Ξ© i) :
(special Q chosen).weight x = (reference (Ξ© := Ξ©)).weight x *
UniformDensity.density (Q chosen) (x chosen) := by
change (∏ i, (component Q chosen i).weight (x i)) =
(∏ i, (FiniteDistribution.uniform (Ω i)).weight (x i)) * _
simp_rw [component_weight]
rw [Finset.prod_mul_distrib, FiniteProduct.product_factor]
theorem observed_variation {Ξ“ : Type*} [Fintype Ξ“]
(Q : (i : I) β†’ FiniteDistribution (Ξ© i)) (L : ℝ)
(hcard : βˆ€ i, (Fintype.card (Ξ© i) : ℝ) ≀ L)
(observe : ((i : I) β†’ Ξ© i) β†’ Ξ“) :
((mixture Q).pushforward observe).totalVariation
((reference (Ξ© := Ξ©)).pushforward observe) ≀
Real.sqrt (L ^ 2 / Fintype.card I) / 2 := by
apply HiddenChildMixture.observed_mixture_variation
(fun i => FiniteDistribution.uniform (Ξ© i)) (special Q)
(fun i => UniformDensity.density (Q i))
Β· exact special_weight Q
Β· intro i
exact UniformDensity.mean_one (Q i)
Β· intro i
exact UniformDensity.second_moment_le (Q i) L (hcard i)
end General
theorem actual_observed_variation
{I : Type*} [Fintype I] [DecidableEq I] [Nonempty I]
{branch : Nat β†’ Nat} {n t : Nat} (calls : Nat) (rows : Nat β†’ Nat)
(slots : I β†’ RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot)
(Q : (i : I) β†’ FiniteDistribution (ChildBlockCardinality.Raw calls rows (slots i)))
{Ξ“ : Type*} [Fintype Ξ“]
(observe : ((i : I) β†’ ChildBlockCardinality.Raw calls rows (slots i)) β†’ Ξ“) :
((mixture Q).pushforward observe).totalVariation
((reference (Ξ© := fun i => ChildBlockCardinality.Raw calls rows (slots i))).pushforward
observe) ≀
Real.sqrt ((ChildBlockCardinality.bound branch n t calls rows : ℝ) ^ 2 /
Fintype.card I) / 2 := by
apply observed_variation Q
intro i
exact_mod_cast ChildBlockCardinality.fintype_card_le calls rows (slots i)
end
end PerfectCompleteness.ChildBlockMixture
namespace PerfectCompleteness.ChildBlockMixture
open UniqueGamesTheorem.Foundations.Games
noncomputable section
theorem conditional_actual_observed_variation
{S I : Type*} [Fintype S] [Fintype I] [DecidableEq I] [Nonempty I]
{branch : Nat β†’ Nat} {n t : Nat} (calls : Nat) (rows : Nat β†’ Nat)
(slots : S β†’ I β†’ RecursiveSpaces.Slots branch n β†’ Fin t β†’ MixedSupport.Slot)
(ΞΌ : FiniteDistribution S)
(Q : (s : S) β†’ (i : I) β†’
FiniteDistribution (ChildBlockCardinality.Raw calls rows (slots s i)))
{Ξ“ : Type*} [Fintype Ξ“]
(observe : (Ξ£ s : S, (i : I) β†’ ChildBlockCardinality.Raw calls rows (slots s i)) β†’ Ξ“) :
((CompletionSoundness.sigmaLaw ΞΌ (fun s => mixture (Q s))).pushforward observe).totalVariation
((CompletionSoundness.sigmaLaw ΞΌ
(fun s => reference (Ξ© := fun i => ChildBlockCardinality.Raw calls rows (slots s i)))).pushforward observe) ≀
Real.sqrt ((ChildBlockCardinality.bound branch n t calls rows : ℝ) ^ 2 /
Fintype.card I) / 2 := by
refine ConditionalVariation.observed_sigma_le_const ΞΌ
(fun s => mixture (Q s))
(fun s => reference (Ξ© := fun i => ChildBlockCardinality.Raw calls rows (slots s i)))
_ ?_ observe
intro s
simpa only [FiniteDistribution.pushforward_id] using
actual_observed_variation calls rows (slots s) (Q s)
(id : ((i : I) β†’ ChildBlockCardinality.Raw calls rows (slots s i)) β†’
((i : I) β†’ ChildBlockCardinality.Raw calls rows (slots s i)))
end
end PerfectCompleteness.ChildBlockMixture
namespace PerfectCompleteness.ChildBlockContinuation
open UniqueGamesTheorem.Foundations.Games
open scoped BigOperators
noncomputable section
variable {I : Type*} [Fintype I] [DecidableEq I] [Nonempty I]
{Ξ© : I β†’ Type*} [βˆ€ i, Fintype (Ξ© i)] [βˆ€ i, Nonempty (Ξ© i)]
{T : I β†’ Type*} [βˆ€ i, Fintype (T i)]
def continuedSpecial (Q : (i : I) β†’ T i β†’ FiniteDistribution (Ξ© i))
(chosen : I) (t : T chosen) : FiniteDistribution ((i : I) β†’ Ξ© i) :=
ChildBlockMixture.special
(Function.update (fun i => FiniteDistribution.uniform (Ξ© i)) chosen (Q chosen t))
chosen
omit [Nonempty I] [βˆ€ i, Fintype (T i)] in
theorem continuedSpecial_eq_product
(Q : (i : I) β†’ T i β†’ FiniteDistribution (Ξ© i)) (chosen : I) (t : T chosen) :
continuedSpecial Q chosen t = FiniteProduct.law
(fun i => if h : chosen = i then h β–Έ Q chosen t else
FiniteDistribution.uniform (Ξ© i)) := by
unfold continuedSpecial ChildBlockMixture.special
apply congrArg (fun P : (i : I) β†’ FiniteDistribution (Ξ© i) => FiniteProduct.law P)
funext i
by_cases h : chosen = i
Β· subst i
simp only [ChildBlockMixture.component, Function.update_self]
Β· simp only [ChildBlockMixture.component, dite_eq_right h]
omit [Nonempty I] [βˆ€ i, Fintype (T i)] in
theorem continuedSpecial_weight
(Q : (i : I) β†’ T i β†’ FiniteDistribution (Ξ© i))
(chosen : I) (t : T chosen) (x : (i : I) β†’ Ξ© i) :
(continuedSpecial Q chosen t).weight x =
(ChildBlockMixture.reference (Ξ© := Ξ©)).weight x *
UniformDensity.density (Q chosen t) (x chosen) := by
unfold continuedSpecial
rw [ChildBlockMixture.special_weight, Function.update_self]
omit [Nonempty I] in
theorem average_special (P : (i : I) β†’ FiniteDistribution (T i))
(Q : (i : I) β†’ T i β†’ FiniteDistribution (Ξ© i)) (chosen : I) :
(P chosen).mixture (continuedSpecial Q chosen) =
ChildBlockMixture.special (fun i => (P i).mixture (Q i)) chosen := by
apply FiniteDistribution.eq_of_weight_eq
intro x
change (βˆ‘ t, (P chosen).weight t * (continuedSpecial Q chosen t).weight x) = _
simp_rw [continuedSpecial_weight]
rw [ChildBlockMixture.special_weight]
change (βˆ‘ t, (P chosen).weight t *
((ChildBlockMixture.reference (Ξ© := Ξ©)).weight x *
((Fintype.card (Ξ© chosen) : ℝ) * (Q chosen t).weight (x chosen)))) =
(ChildBlockMixture.reference (Ξ© := Ξ©)).weight x *
((Fintype.card (Ξ© chosen) : ℝ) *
βˆ‘ t, (P chosen).weight t * (Q chosen t).weight (x chosen))
simp only [Finset.mul_sum]
apply Finset.sum_congr rfl
intro t _
ring
theorem hidden_average (P : (i : I) β†’ FiniteDistribution (T i))
(Q : (i : I) β†’ T i β†’ FiniteDistribution (Ξ© i)) :
HiddenChildMixture.mixture (fun i => (P i).mixture (continuedSpecial Q i)) =
ChildBlockMixture.mixture (fun i => (P i).mixture (Q i)) := by
simp only [average_special, ChildBlockMixture.mixture]
theorem uniform_average (P : (i : I) β†’ FiniteDistribution (T i))
(Q : (i : I) β†’ T i β†’ FiniteDistribution (Ξ© i)) :
(FiniteDistribution.uniform I).mixture
(fun i => (P i).mixture (continuedSpecial Q i)) =
ChildBlockMixture.mixture (fun i => (P i).mixture (Q i)) := by
simp only [average_special]
apply FiniteDistribution.eq_of_weight_eq
intro x
change (βˆ‘ i, (1 / (Fintype.card I : ℝ)) *
(ChildBlockMixture.special (fun j => (P j).mixture (Q j)) i).weight x) =
(βˆ‘ i, (ChildBlockMixture.special (fun j => (P j).mixture (Q j)) i).weight x) /
(Fintype.card I : ℝ)
rw [← Finset.mul_sum]
ring
end
end PerfectCompleteness.ChildBlockContinuation
end OAI