unfold noiseWeight walsh
simp only [←Finset.prod_mul_distrib]
rw [←Fintype.prod_sum (fun i b =>
(if b then ε else1 - ε) * bitSign (s i && b))]
have hc (i : I) : (∑b : Bool,
(if b then ε else1 - ε) * bitSign (s i && b)) =
if s i then1 - 2 * ε else1:=by
cases s i <;> simp [bitSign] ; ring
simp_rw [hc]
simp [support, Finset.prod_ite]
theoremwalsh_autocorrelation (B : CubeJ→ℝ) (h : CubeJ) :
(𝔼 g, B g * B (cubeXor g h)) =
∑ s, coefficient B s ^ 2 * walsh s h :=by
proof · 14
lines
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 _
havehterm : (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
theoremtestBias_fourier (ε : ℝ) (π : J→I)
(A : CubeI→ℝ) (B : CubeJ→ℝ) :
testBias ε π AB = ∑ s,
projectedCoefficient π A s * coefficient B s ^ 2 *
(1 - 2 * ε) ^ (support s).card :=by
proof · 22
lines
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 : CubeI) :
(∑ μ, 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 (μ : CubeJ) : 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