import Mathlib import OAI.Computability.VertexCover.Games.Stochastic namespace OAI section section section section section section section section section section section section section section section section section section section section section section section section section section section section namespace UniqueGames.Foundations.Games.FiniteDistribution open scoped BigOperators noncomputable section theorem iid_pushforward {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] (μ : FiniteDistribution Ω) (f : Ω → Γ) (n : Nat) : (μ.pushforward f).iid n = (μ.iid n).pushforward (fun answers i => f (answers i)) := by classical apply eq_of_weight_eq intro y simp only [iid, pushforward] rw [Fintype.prod_sum] apply Finset.sum_congr rfl intro x _ by_cases h : (fun i => f (x i)) = y · have hp : ∀ i, f (x i) = y i := congrFun h simp [hp] · rw [ite_eq_right h] have hn : ¬ ∀ i, f (x i) = y i := fun hp => h (funext hp) obtain ⟨i, hi⟩ := not_forall.mp hn apply Finset.prod_eq_zero (Finset.mem_univ i) simp [hi] def uniform (Ω : Type*) [Fintype Ω] [Nonempty Ω] : FiniteDistribution Ω where weight _ := 1 / (Fintype.card Ω : ℝ) nonnegative _ := div_nonneg zero_le_one (Nat.cast_nonneg _) normalized := by have hn : (Fintype.card Ω : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, one_div] exact mul_inv_cancel₀ hn theorem iid_uniform {Ω : Type*} [Fintype Ω] [Nonempty Ω] (n : Nat) : (uniform Ω).iid n = uniform (Fin n → Ω) := by classical apply eq_of_weight_eq intro x simp [iid, uniform, Nat.cast_pow, one_div] theorem expectation_uniform {Ω : Type*} [Fintype Ω] [Nonempty Ω] (f : Ω → ℝ) : (uniform Ω).expectation f = (∑ x, f x) / (Fintype.card Ω : ℝ) := by unfold expectation uniform rw [← Finset.mul_sum] simp [div_eq_mul_inv, mul_comm] end end UniqueGames.Foundations.Games.FiniteDistribution end end end end end end end end end end end end end end end end end end end end end end end end end end end end end OAI