introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.64 kB
import Mathlib.Data.Fintype.BigOperators
import OAI.Computability.PerfectCompleteness.Foundations.RecursiveSpaceEquivLemmas
import OAI.Computability.UniqueGames.Foundations.ValueLemmas
namespace OAI
section
namespace PerfectCompleteness.FiniteProduct
open scoped BigOperators
open UniqueGamesTheorem.Foundations.Games
noncomputable section
variable {I : Type*} [Fintype I] [DecidableEq I]
{Ξ© : I β†’ Type*} [βˆ€ i, Fintype (Ξ© i)]
def law (P : (i : I) β†’ FiniteDistribution (Ξ© i)) :
FiniteDistribution ((i : I) β†’ Ξ© i) where
weight x := ∏ i, (P i).weight (x i)
nonnegative x := Finset.prod_nonneg fun i _ => (P i).nonnegative (x i)
normalized := by
rw [← Fintype.prod_sum]
simp only [FiniteDistribution.normalized, Finset.prod_const_one]
theorem expectation_product (P : (i : I) β†’ FiniteDistribution (Ξ© i))
(f : (i : I) β†’ Ξ© i β†’ ℝ) :
(law P).expectation (fun x => ∏ i, f i (x i)) =
∏ i, (P i).expectation (f i) := by
change (βˆ‘ x : (i : I) β†’ Ξ© i, (∏ i, (P i).weight (x i)) *
(∏ i, f i (x i))) = ∏ i, βˆ‘ a, (P i).weight a * f i a
simp only [← Finset.prod_mul_distrib]
exact (Fintype.prod_sum (fun i a => (P i).weight a * f i a)).symm
def factor (i : I) (f : Ξ© i β†’ ℝ) (j : I) (a : Ξ© j) : ℝ :=
if h : j = i then f (h β–Έ a) else 1
omit [Fintype I] [βˆ€ index, Fintype (Ξ© index)] in
@[simp] theorem factor_self (i : I) (f : Ξ© i β†’ ℝ) (a : Ξ© i) :
factor i f i a = f a := by simp [factor]
omit [Fintype I] [βˆ€ index, Fintype (Ξ© index)] in
@[simp] theorem factor_other (i j : I) (h : j β‰  i) (f : Ξ© i β†’ ℝ) (a : Ξ© j) :
factor i f j a = 1 := by simp [factor, h]
omit [Fintype I] [βˆ€ index, Fintype (Ξ© index)] in
@[simp] theorem factor_function_self (i : I) (f : Ξ© i β†’ ℝ) :
factor i f i = f := by funext a; exact factor_self i f a
omit [Fintype I] [βˆ€ index, Fintype (Ξ© index)] in
@[simp] theorem factor_function_other (i j : I) (h : j β‰  i) (f : Ξ© i β†’ ℝ) :
factor i f j = fun _ => 1 := by funext a; exact factor_other i j h f a
omit [βˆ€ index, Fintype (Ξ© index)] in
theorem product_factor (i : I) (f : Ξ© i β†’ ℝ) (x : (j : I) β†’ Ξ© j) :
(∏ j, factor i f j (x j)) = f (x i) := by
classical
rw [Finset.prod_eq_single i]
Β· exact factor_self i f (x i)
Β· intro j _ h
exact factor_other i j h f (x j)
Β· simp
theorem expectation_factor_product (P : (i : I) β†’ FiniteDistribution (Ξ© i))
(i : I) (f : Ξ© i β†’ ℝ) :
(∏ j, (P j).expectation (factor i f j)) = (P i).expectation f := by
classical
rw [Finset.prod_eq_single i]
Β· congr 1
funext a
exact factor_self i f a
Β· intro j _ h
rw [factor_function_other i j h, SmallBias.expectation_const]
Β· simp
theorem expectation_eval (P : (i : I) β†’ FiniteDistribution (Ξ© i))
(i : I) (f : Ξ© i β†’ ℝ) :
(law P).expectation (fun x => f (x i)) = (P i).expectation f := by
calc
_ = (law P).expectation (fun x => ∏ j, factor i f j (x j)) := by
apply FiniteDistribution.expectation_congr
intro x
exact (product_factor i f x).symm
_ = ∏ j, (P j).expectation (factor i f j) := expectation_product P _
_ = _ := expectation_factor_product P i f
theorem expectation_eval_mul (P : (i : I) β†’ FiniteDistribution (Ξ© i))
(i j : I) (hij : i β‰  j) (f : Ξ© i β†’ ℝ) (g : Ξ© j β†’ ℝ) :
(law P).expectation (fun x => f (x i) * g (x j)) =
(P i).expectation f * (P j).expectation g := by
have hfactor : βˆ€ k,
(P k).expectation (fun a => factor i f k a * factor j g k a) =
(P k).expectation (factor i f k) * (P k).expectation (factor j g k) := by
intro k
by_cases hki : k = i
Β· subst k
simp only [factor_other j i hij, factor_function_other j i hij,
SmallBias.expectation_const, mul_one]
Β· simp only [factor_other i k hki, factor_function_other i k hki,
SmallBias.expectation_const, one_mul]
calc
_ = (law P).expectation
(fun x => ∏ k, factor i f k (x k) * factor j g k (x k)) := by
apply FiniteDistribution.expectation_congr
intro x
rw [Finset.prod_mul_distrib, product_factor i f x, product_factor j g x]
_ = ∏ k, (P k).expectation (fun a => factor i f k a * factor j g k a) :=
expectation_product P (fun k a => factor i f k a * factor j g k a)
_ = (∏ k, (P k).expectation (factor i f k)) *
(∏ k, (P k).expectation (factor j g k)) := by
simp only [hfactor, Finset.prod_mul_distrib]
_ = _ := by rw [expectation_factor_product P i f, expectation_factor_product P j g]
end
end PerfectCompleteness.FiniteProduct
end
end OAI