Documentation

CslibFrontier.Foundations.BooleanAnalysis.LongCode

The long code, odd Boolean functions, folding, and projections of characters #

The long code of a label a : ι is the dictator r ↦ r a, the evaluation Function.eval a on ι → Bool (BitString.longCode) Arora and Barak, Chapter 22. It is the Hadamard encoding of the unit vector of a (BitString.longCode_eq_hadamardCode), so a table within relative distance 1/4 of a long code determines its label (BitString.eq_of_hammingDist_longCode_lt).

A Boolean function B : (ι → Bool) → Bool is odd (BitString.IsOdd) when complementing its input complements its output, B (f + 1) = !B f; in ±1 notation this is F (-x) = -F x, and such functions are also called self-dual. In PCP constructions, odd long code tables are called folded. Every long code is odd (BitString.isOdd_longCode), every table can be folded around a coordinate into an odd one (BitString.foldTable), and the Fourier coefficients of an odd function vanish on every set of even cardinality (BitString.IsOdd.fourierCoeff_of_even), in particular on ∅ (BitString.IsOdd.fourierCoeff_empty).

For a map π : β → γ, the mod-2 projection BitString.projectSet π T of T : Finset β is the set of points of γ with an odd number of preimages in T. Pulling a character back along π projects its frequency set: chi T (f ∘ π) = chi (projectSet π T) f (BitString.chi_comp_eq_chi_projectSet) Håstad.

Main definitions #

Main results #

References #

The long code #

def Cslib.BitString.longCode {ι : Type u_1} (a : ι) :
(ι → Bool) → Bool

The long code of a label a : ι: the dictator r ↦ r a on ι → Bool, that is, the evaluation Function.eval a Arora and Barak, Chapter 22. It is the Hadamard encoding of the unit vector of a (longCode_eq_hadamardCode).

@[simp]
theorem Cslib.BitString.longCode_apply {ι : Type u_1} (a : ι) (r : ι → Bool) :
longCode a r = r a

The long code of a reads the bit of r at a.

The long code of a is the Hadamard encoding of the unit vector of a.

theorem Cslib.BitString.eq_of_hammingDist_longCode_lt {ι : Type u_1} [Fintype ι] [DecidableEq ι] {f : (ι → Bool) → Bool} {a b : ι} (ha : ↑(hammingDist f (longCode a)) / 2 ^ Fintype.card ι < 1 / 4) (hb : ↑(hammingDist f (longCode b)) / 2 ^ Fintype.card ι < 1 / 4) :
a = b

Unique decoding of the long code: a Boolean function within relative distance less than 1/4 of the long codes of a and of b forces a = b.

Odd functions and folding #

theorem Cslib.BitString.signVal_longCode {α : Type u_2} (x : α) (f : α → Bool) :

In ±1 notation, the long code longCode x is the singleton character chi ℝ {x}.

def Cslib.BitString.IsOdd {α : Type u_2} (B : (α → Bool) → Bool) :

A Boolean function B : (α → Bool) → Bool is odd when complementing the input (f + fun _ => true) complements the output. In ±1 notation this says F (-x) = -F x; such functions are also called self-dual, and odd long code tables are called folded.

theorem Cslib.BitString.isOdd_longCode {α : Type u_2} (x : α) :

Every long code longCode x is odd.

def Cslib.BitString.foldTable {α : Type u_2} (x₀ : α) (B : (α → Bool) → Bool) (f : α → Bool) :

Folding a table around the coordinate x₀ : α: it reads B f when f x₀ = false and !B (f + fun _ => true) when f x₀ = true.

theorem Cslib.BitString.isOdd_foldTable {α : Type u_2} (x₀ : α) (B : (α → Bool) → Bool) :
IsOdd (foldTable x₀ B)

Folding any table produces an odd table.

theorem Cslib.BitString.IsOdd.foldTable_eq {α : Type u_2} {B : (α → Bool) → Bool} (hB : IsOdd B) (x₀ : α) :
foldTable x₀ B = B

Folding an odd table leaves it unchanged.

theorem Cslib.BitString.IsOdd.fourierCoeff_of_even {α : Type u_2} [Fintype α] [DecidableEq α] {B : (α → Bool) → Bool} (hB : IsOdd B) {S : Finset α} (hS : Even S.card) :
fourierCoeff (fun (f : α → Bool) => signVal (B f)) S = 0

An odd function has Fourier coefficient 0 on every set of even cardinality.

theorem Cslib.BitString.IsOdd.fourierCoeff_empty {α : Type u_2} [Fintype α] [DecidableEq α] {B : (α → Bool) → Bool} (hB : IsOdd B) :
fourierCoeff (fun (f : α → Bool) => signVal (B f)) ∅ = 0

An odd function has zero empty Fourier coefficient: its ±1 values at f and f + fun _ => true cancel. This is the case S = ∅ of IsOdd.fourierCoeff_of_even.

The subcube test on the long code #

def Cslib.BitString.longCodeSubcubeAccept {α : Type u_2} (B : (α → Bool) → Bool) (f h : α → Bool) :

The long-code subcube test predicate (Arora and Barak, Chapter 18, Exercise 16(d)): on random f, h : α → Bool, if B f = false, check that B (fun i => f i && h i) = false (where fun i => f i && h i is a uniformly random point in the subcube {g | ∀ i, g i ≤ f i}); equivalently, B (fun i => f i && h i) ≤ B f (B f || !B (fun i => f i && h i)).

@[simp]

Every long code passes longCodeSubcubeAccept on every query pair (f, h).

theorem Cslib.BitString.chi_and_eq_chi_filter {α : Type u_2} (S : Finset α) (f h : α → Bool) :
(chi ℝ S fun (i : α) => f i && h i) = chi ℝ ({i ∈ S | f i = true}) h

Evaluating the character chi ℝ S at fun i => f i && h i restricts the frequency set S to {i ∈ S | f i} on h.

noncomputable def Cslib.BitString.longCodeSubcubeProb {α : Type u_2} [DecidableEq α] [Fintype α] (B : (α → Bool) → Bool) :

The long-code subcube test acceptance probability (Arora and Barak, Chapter 18, Exercise 16(d)): the probability over independent uniform f, h : α → Bool that longCodeSubcubeAccept B f h = true.

@[simp]

Completeness of the long-code subcube test (Arora and Barak, Chapter 18, Exercise 16(d)): every long code passes the subcube test with probability 1.

theorem Cslib.BitString.expect_and_eq_expect_filter_le {α : Type u_2} [DecidableEq α] [Fintype α] (f : α → Bool) (φ : (α → Bool) → ℝ) :
(Finset.univ.expect fun (h : α → Bool) => φ fun (i : α) => f i && h i) = {g : α → Bool | ∀ (i : α), g i ≤ f i}.expect fun (g : α → Bool) => φ g

For fixed f : α → Bool, the bitwise conjunction fun i => f i && h i with a uniform h : α → Bool is uniformly distributed on the subcube {g : α → Bool | ∀ i, g i ≤ f i}: each g in the subcube has fiber {h | ∀ i, (h + g) i ≤ !f i}, a coset of {k | ∀ i, k i ≤ !f i}.

theorem Cslib.BitString.longCodeSubcubeProb_eq_expect_filter_le {α : Type u_2} [DecidableEq α] [Fintype α] (B : (α → Bool) → Bool) :
longCodeSubcubeProb B = Finset.univ.expect fun (f : α → Bool) => {g : α → Bool | ∀ (i : α), g i ≤ f i}.expect fun (g : α → Bool) => bitVal ℝ (B f || !B g)

The acceptance probability of the long-code subcube test equals the expectation over uniform f : α → Bool and uniform g in the subcube {g : α → Bool | ∀ i, g i ≤ f i} of bitVal ℝ (B f || !B g).

theorem Cslib.BitString.expect_chi_and {α : Type u_2} [DecidableEq α] [Fintype α] (S : Finset α) :
(Finset.univ.expect fun (f : α → Bool) => Finset.univ.expect fun (h : α → Bool) => chi ℝ S fun (i : α) => f i && h i) = (1 / 2) ^ S.card

Averaging chi ℝ S (fun i => f i && h i) over independent uniform f, h : α → Bool yields (1 / 2) ^ #S, the probability that f vanishes on S.

theorem Cslib.BitString.longCodeSubcubeProb_hadamardCode {α : Type u_2} [DecidableEq α] [Fintype α] {s : α → Bool} (hs : s ≠ 0) :
longCodeSubcubeProb (hadamardCode s) = 3 / 4 + (1 / 2) ^ ({i : α | s i = true}.card + 1)

Acceptance probability of the long-code subcube test on a nonzero linear function (Arora and Barak, Chapter 18, Exercise 16(d)): for any s : α → Bool with s ≠ 0, the Hadamard codeword hadamardCode s passes the subcube test with probability 3 / 4 + (1 / 2) ^ (#{i | s i} + 1).

theorem Cslib.BitString.longCodeSubcubeProb_hadamardCode_le {α : Type u_2} [DecidableEq α] [Fintype α] {s : α → Bool} (hs : 2 ≤ {i : α | s i = true}.card) :

Soundness of the long-code subcube test against linear functions of weight at least 2 (Arora and Barak, Chapter 18, Exercise 16(d)): if 2 ≤ #{i | s i}, then hadamardCode s passes the subcube test with probability at most 7 / 8.

theorem Cslib.BitString.longCodeSubcubeProb_le_of_linear {α : Type u_2} [DecidableEq α] [Fintype α] {B : (α → Bool) → Bool} (hlin : ∀ (f g : α → Bool), B (f + g) = (B f ^^ B g)) (hB0 : B ≠ 0) (hnotLC : ∀ (x : α), B ≠ longCode x) :

Soundness of the long-code subcube test against nonzero non-dictator linear functions (Arora and Barak, Chapter 18, Exercise 16(d)): if B : (α → Bool) → Bool is a linear function (∀ f g, B (f + g) = (B f ^^ B g)) that is nonzero and not a long-code codeword, then B passes the subcube test with probability at most 7 / 8.