File size: 5,098 Bytes
ea76aac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | import Mathlib
import OAI.Computability.MaxCut.PCP.ContextLoad
namespace OAI
noncomputable section
namespace MaxCutGames.Foundations.Hastad
open scoped BigOperators
open Finset
variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
def support (s : Cube I) : Finset I := Finset.univ.filter fun i => s i = true
def noiseWeight (ε : ℝ) (μ : Cube I) : ℝ :=
∏ i, if μ i then ε else 1 - ε
omit [DecidableEq I] in
theorem noiseWeight_nonneg {ε : ℝ} (hε : 0 ≤ ε) (hε' : ε ≤ 1) (μ : Cube I) :
0 ≤ noiseWeight ε μ := by
apply Finset.prod_nonneg
intro i _
split <;> linarith
theorem noiseWeight_sum (ε : ℝ) : (∑ μ : Cube I, noiseWeight ε μ) = 1 := by
unfold noiseWeight
rw [← Fintype.prod_sum (fun (_ : I) (b : Bool) => if b then ε else 1 - ε)]
simp []
theorem noise_walsh (ε : ℝ) (s : Cube I) :
(∑ μ, noiseWeight ε μ * walsh s μ) = (1 - 2 * ε) ^ (support s).card := by
unfold noiseWeight walsh
simp only [← Finset.prod_mul_distrib]
rw [← Fintype.prod_sum (fun i b =>
(if b then ε else 1 - ε) * bitSign (s i && b))]
have hc (i : I) : (∑ b : Bool,
(if b then ε else 1 - ε) * bitSign (s i && b)) =
if s i then 1 - 2 * ε else 1 := by
cases s i <;> simp [bitSign] ; ring
simp_rw [hc]
simp [support, Finset.prod_ite]
/-- The third queried Boolean table is `g * (f ∘ π) * μ` in sign notation. -/
def thirdQuery (π : J → I) (f : Cube I) (g μ : Cube J) : Cube J :=
cubeXor g (cubeXor (fun y => f (π y)) μ)
/-- Walsh autocorrelation, proved by expanding the explicit basis. -/
theorem walsh_autocorrelation (B : Cube J → ℝ) (h : Cube J) :
(𝔼 g, B g * B (cubeXor g h)) =
∑ s, coefficient B s ^ 2 * walsh s h := by
conv_lhs =>
enter [2, g, 2]
rw [← walsh_inversion B (cubeXor g h)]
simp_rw [Finset.mul_sum, walsh_xor]
rw [Finset.expect_sum_comm]
apply Finset.sum_congr rfl
intro s _
have hterm : (fun g => B g * (coefficient B s * (walsh s g * walsh s h))) =
(fun g => (coefficient B s * walsh s h) * (B g * walsh s g)) := by
funext g
ring
rw [hterm, ← Finset.mul_expect]
change (coefficient B s * walsh s h) * coefficient B s = _
ring
def projectedCoefficient (π : J → I) (A : Cube I → ℝ) (s : Cube J) : ℝ :=
𝔼 f, A f * walsh s (fun y => f (π y))
def testBias (ε : ℝ) (π : J → I) (A : Cube I → ℝ) (B : Cube J → ℝ) : ℝ :=
𝔼 f, ∑ μ, noiseWeight ε μ * A f *
(𝔼 g, B g * B (thirdQuery π f g μ))
theorem testBias_fourier (ε : ℝ) (π : J → I)
(A : Cube I → ℝ) (B : Cube J → ℝ) :
testBias ε π A B = ∑ s,
projectedCoefficient π A s * coefficient B s ^ 2 *
(1 - 2 * ε) ^ (support s).card := by
unfold testBias thirdQuery
simp_rw [walsh_autocorrelation, Finset.mul_sum]
conv_lhs =>
enter [2, f]
rw [Finset.sum_comm]
rw [Finset.expect_sum_comm]
apply Finset.sum_congr rfl
intro s _
have hterm (f : Cube I) :
(∑ μ, noiseWeight ε μ * A f *
(coefficient B s ^ 2 * walsh s (cubeXor (fun y => f (π y)) μ))) =
(A f * walsh s (fun y => f (π y))) * coefficient B s ^ 2 *
(1 - 2 * ε) ^ (support s).card := by
simp_rw [walsh_xor]
have heq (μ : Cube J) : noiseWeight ε μ * A f *
(coefficient B s ^ 2 * (walsh s (fun y => f (π y)) * walsh s μ)) =
((A f * walsh s (fun y => f (π y))) * coefficient B s ^ 2) *
(noiseWeight ε μ * walsh s μ) := by ring
simp_rw [heq]
rw [← Finset.mul_sum, noise_walsh]
simp_rw [hterm, ← Finset.expect_mul]
rfl
def testAcceptance (ε : ℝ) (π : J → I)
(A : Cube I → Bool) (B : Cube J → Bool) : ℝ :=
𝔼 f, ∑ μ, noiseWeight ε μ *
(𝔼 g, if A f ^^ B g ^^ B (thirdQuery π f g μ) then 0 else 1)
theorem threeBit_indicator (a b c : Bool) :
(if a ^^ b ^^ c then (0 : ℝ) else 1) =
(1 + bitSign a * bitSign b * bitSign c) / 2 := by
cases a <;> cases b <;> cases c <;> norm_num [bitSign]
/-- Actual acceptance is one half plus one half of the three-answer correlation. -/
theorem testAcceptance_eq (ε : ℝ) (π : J → I)
(A : Cube I → Bool) (B : Cube J → Bool) :
testAcceptance ε π A B =
(1 + testBias ε π (fun f => bitSign (A f)) (fun g => bitSign (B g))) / 2 := by
unfold testAcceptance testBias
simp_rw [threeBit_indicator, div_eq_mul_inv,
← Finset.expect_mul, Finset.expect_add_distrib]
simp only [Fintype.expect_const]
have hterm (f : Cube I) (μ : Cube J) :
noiseWeight ε μ * ((1 + 𝔼 g,
bitSign (A f) * bitSign (B g) * bitSign (B (thirdQuery π f g μ))) * 2⁻¹) =
(noiseWeight ε μ + noiseWeight ε μ * bitSign (A f) *
(𝔼 g, bitSign (B g) * bitSign (B (thirdQuery π f g μ)))) * 2⁻¹ := by
simp_rw [mul_assoc (bitSign (A f)), ← Finset.mul_expect]
ring
simp_rw [hterm, ← Finset.sum_mul, Finset.sum_add_distrib, noiseWeight_sum,
← Finset.expect_mul, Finset.expect_add_distrib]
simp
end MaxCutGames.Foundations.Hastad
end
end OAI
|