cfahlgren1's picture
download
raw
4.03 kB
import Mathlib
import OAI.Computability.MinUncut.Model
namespace OAI
section
noncomputable section
namespace MinUncutGames.Foundations.Hastad
open scoped BigOperators
open Finset
abbrev Cube (I : Type*) := I → Bool
def bitSign (b : Bool) : ℝ := if b then -1 else 1
@[simp] theorem bitSign_sq (b : Bool) : bitSign b ^ 2 = 1 := by
cases b <;> norm_num [bitSign]
theorem bitSign_xor (b c : Bool) :
bitSign (b ^^ c) = bitSign b * bitSign c := by
cases b <;> cases c <;> norm_num [bitSign]
def cubeXor {I : Type*} (x y : Cube I) : Cube I := fun i => x i ^^ y i
def walsh {I : Type*} [Fintype I] [DecidableEq I] (s x : Cube I) : ℝ :=
∏ i, bitSign (s i && x i)
theorem walsh_symm {I : Type*} [Fintype I] [DecidableEq I] (s x : Cube I) :
walsh s x = walsh x s := by
simp [walsh, Bool.and_comm]
@[simp] theorem walsh_sq {I : Type*} [Fintype I] [DecidableEq I] (s x : Cube I) :
walsh s x ^ 2 = 1 := by
simp [walsh, ← Finset.prod_pow]
theorem walsh_xor {I : Type*} [Fintype I] [DecidableEq I] (s x y : Cube I) :
walsh s (cubeXor x y) = walsh s x * walsh s y := by
simp only [walsh, ← Finset.prod_mul_distrib]
apply Finset.prod_congr rfl
intro i _
simp only [cubeXor]
cases s i <;> cases x i <;> cases y i <;> norm_num [bitSign]
theorem coordinate_orthogonality (s t : Bool) :
(∑ x : Bool, bitSign (s && x) * bitSign (t && x)) =
if s = t then 2 else 0 := by
cases s <;> cases t <;> norm_num [bitSign, Fintype.sum_bool]
theorem walsh_sum_orthogonality {I : Type*} [Fintype I] [DecidableEq I]
(s t : Cube I) :
(∑ x, walsh s x * walsh t x) =
if s = t then (Fintype.card (Cube I) : ℝ) else 0 := by
classical
simp only [walsh, ← Finset.prod_mul_distrib]
rw [← Fintype.prod_sum (fun (i : I) (b : Bool) =>
bitSign (s i && b) * bitSign (t i && b))]
simp only [coordinate_orthogonality]
by_cases h : s = t
· subst t
simp
· rw [ite_eq_right h]
obtain ⟨i, hi⟩ := Function.ne_iff.mp h
apply Finset.prod_eq_zero (Finset.mem_univ i)
exact ite_eq_right hi
theorem walsh_orthogonality {I : Type*} [Fintype I] [DecidableEq I]
(s t : Cube I) :
(𝔼 x, walsh s x * walsh t x) = if s = t then 1 else 0 := by
classical
rw [Fintype.expect_eq_sum_div_card, walsh_sum_orthogonality]
split_ifs <;> simp
def coefficient {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → ℝ) (s : Cube I) : ℝ :=
𝔼 x, f x * walsh s x
theorem walsh_inversion {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → ℝ) (x : Cube I) :
(∑ s, coefficient f s * walsh s x) = f x := by
classical
unfold coefficient
simp_rw [Finset.expect_mul]
rw [← Finset.expect_sum_comm]
have h (y : Cube I) :
(∑ s, (f y * walsh s y) * walsh s x) =
f y * (if y = x then (Fintype.card (Cube I) : ℝ) else 0) := by
simp only [mul_assoc, ← Finset.mul_sum]
congr 1
simp_rw [walsh_symm (x := y), walsh_symm (x := x)]
exact walsh_sum_orthogonality y x
simp_rw [h]
rw [Fintype.expect_eq_sum_div_card]
simp
theorem walsh_inner {I : Type*} [Fintype I] [DecidableEq I] (f g : Cube I → ℝ) :
(∑ s, coefficient f s * coefficient g s) = 𝔼 x, f x * g x := by
classical
unfold coefficient
simp_rw [Finset.mul_expect]
rw [← Finset.expect_sum_comm]
apply Finset.expect_congr rfl
intro x _
have h : (∑ s, (𝔼 y, f y * walsh s y) * (g x * walsh s x)) =
g x * (∑ s, coefficient f s * walsh s x) := by
simp only [Finset.mul_sum, coefficient]
apply Finset.sum_congr rfl
intro s _
ring
rw [h, walsh_inversion]
ring
theorem walsh_parseval {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → ℝ) :
(∑ s, coefficient f s ^ 2) = 𝔼 x, f x ^ 2 := by
simpa [pow_two] using walsh_inner f f
theorem sign_parseval {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → Bool) :
(∑ s, coefficient (fun x => bitSign (f x)) s ^ 2) = 1 := by
rw [walsh_parseval]
simp
end MinUncutGames.Foundations.Hastad
end
end
end OAI

Xet Storage Details

Size:
4.03 kB
·
Xet hash:
2fabff4e9a4d73db2c5069f30f4905ab22ccfa5f7d72701dfca33c65332b1156

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