cfahlgren1's picture
download
raw
3.46 kB
import Mathlib.Data.Fintype.Pi
import OAI.Computability.BinPacking.Information.GameDecoder
namespace OAI
namespace BinPackingGames.Reduction.FiniteNoise
open scoped BigOperators
open BinPackingGames.Foundations.Hastad (noiseWeight)
def realizedBit {D : Nat} (z : Fin D) : Bool := decide (z.val = 0)
def realizedNoise {A : Type*} {D : Nat} (z : A → Fin D) : A → Bool :=
fun a => realizedBit (z a)
theorem realizedBit_eq_true_iff {D : Nat} (positive : 0 < D) (z : Fin D) :
realizedBit z = true ↔ z = ⟨0, positive⟩ := by
simp [realizedBit, Fin.ext_iff]
theorem coordinate_fiber_sum {D : Nat} (positive : 0 < D) (b : Bool) :
(∑ z : Fin D, if realizedBit z = b then (D : ℝ)⁻¹ else 0) =
if b then (D : ℝ)⁻¹ else 1 - (D : ℝ)⁻¹ := by
have hd : (D : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt positive
have ht : (∑ z : Fin D, if realizedBit z = true then (D : ℝ)⁻¹ else 0) =
(D : ℝ)⁻¹ := by
simp_rw [realizedBit_eq_true_iff positive]
simp
have htotal :
(∑ z : Fin D, if realizedBit z = false then (D : ℝ)⁻¹ else 0) +
(∑ z : Fin D, if realizedBit z = true then (D : ℝ)⁻¹ else 0) = 1 := by
rw [← Finset.sum_add_distrib]
have he (z : Fin D) :
(if realizedBit z = false then (D : ℝ)⁻¹ else 0) +
(if realizedBit z = true then (D : ℝ)⁻¹ else 0) = (D : ℝ)⁻¹ := by
cases realizedBit z <;> simp
simp_rw [he]
simp [hd]
cases b <;> simp only [Bool.false_eq_true, ite_false, ite_true]
· linarith
· exact ht
variable {A : Type*} [Fintype A] [DecidableEq A]
theorem noiseWeight_eq_fiber_sum {D : Nat} (positive : 0 < D) (μ : A → Bool) :
noiseWeight ((D : ℝ)⁻¹) μ =
∑ z : A → Fin D,
∏ a, if realizedBit (z a) = μ a then (D : ℝ)⁻¹ else 0 := by
rw [← Fintype.prod_sum (fun (a : A) (z : Fin D) =>
if realizedBit z = μ a then (D : ℝ)⁻¹ else 0)]
unfold noiseWeight
apply Finset.prod_congr rfl
intro a _
exact (coordinate_fiber_sum positive (μ a)).symm
omit [DecidableEq A] in
theorem fiber_product_eq_indicator {D : Nat} (z : A → Fin D) (μ : A → Bool) :
(∏ a, if realizedBit (z a) = μ a then (D : ℝ)⁻¹ else 0) =
if realizedNoise z = μ then ((D : ℝ)⁻¹) ^ Fintype.card A else 0 := by
classical
by_cases h : realizedNoise z = μ
· rw [ite_eq_left h]
have ha (a : A) : realizedBit (z a) = μ a := congrFun h a
simp [ha]
· rw [ite_eq_right h]
obtain ⟨a, ha⟩ := Function.ne_iff.mp h
apply Finset.prod_eq_zero (Finset.mem_univ a)
exact ite_eq_right ha
theorem expect_realizedNoise {D : Nat} (positive : 0 < D) (H : (A → Bool) → ℝ) :
(𝔼 z : A → Fin D, H (realizedNoise z)) =
∑ μ : A → Bool, noiseWeight ((D : ℝ)⁻¹) μ * H μ := by
classical
symm
simp_rw [noiseWeight_eq_fiber_sum positive, Finset.sum_mul]
rw [Finset.sum_comm]
simp_rw [fiber_product_eq_indicator]
have he (z : A → Fin D) :
(∑ μ : A → Bool,
(if realizedNoise z = μ then ((D : ℝ)⁻¹) ^ Fintype.card A else 0) * H μ) =
((D : ℝ)⁻¹) ^ Fintype.card A * H (realizedNoise z) := by
simp [eq_comm]
simp_rw [he]
rw [Fintype.expect_eq_sum_div_card]
simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow]
rw [div_eq_mul_inv, inv_pow]
rw [← Finset.mul_sum]
exact mul_comm _ _
end BinPackingGames.Reduction.FiniteNoise
end OAI

Xet Storage Details

Size:
3.46 kB
·
Xet hash:
2e581f1702d90af7e14459de27c3c4f459957d8cdfbb45e11a1ea2350998c463

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.