cfahlgren1's picture
download
raw
4.04 kB
import Mathlib
import OAI.Computability.MaxCut.Encoding.ThreeBitTest
namespace OAI
/-!
# Realizing the existing Håstad noise law with a finite uniform tape
A tape contains one element of `Fin D` per coordinate. The corresponding noise
bit is true exactly when that element has value zero. For `D > 0`, its law is
exactly `Foundations.Hastad.noiseWeight ((D : ℝ)⁻¹)`.
The construction also permits an empty coordinate type and `D = 1`.
-/
namespace MaxCutGames.Reduction.FiniteNoise
open scoped BigOperators
open MaxCutGames.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]
/-- The two fibers of a coordinate have their actual normalized finite counts. -/
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]
/-- Product distributivity computes the mass of every complete Boolean noise vector. -/
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
/-- Exact pushforward law for every observable, using the existing noise weight. -/
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 MaxCutGames.Reduction.FiniteNoise
end OAI

Xet Storage Details

Size:
4.04 kB
·
Xet hash:
7d5df1ed0e0d59750672e9ce3b24d0b09b13f07468e63044d682d419a916aa84

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