Documentation

CslibFrontier.Computability.PropertyTesting.Monotonicity.LocalEmbedding

Local Hypercube Embeddings for Monotonicity Testing and Negative Sensitivity #

This module formalizes local embeddings and relaxed local embeddings of finite product distributions ([m]^n, μ₁^(⊗ n)) into the Boolean hypercube ({0, 1}^(n · r), U), together with monotonicity-distance preservation, expected square-root negative sensitivity pullbacks, statistical-distance stability, generic Cslib.PCP.LocalTest pullback and repetition amplification, and concrete instantiation with Cslib.BitString.edgeTest.

Main definitions #

Main results #

Distance to monotonicity and negative sensitivity #

noncomputable def Cslib.BitString.probDist {α : Type u_1} [Fintype α] (f g : α → Bool) (μ : PMF α) :

The disagreement probability Δ(f, g; μ) = μ({x | f x ≠ g x}) between two Boolean functions with respect to a probability mass function μ on a finite type α.

theorem Cslib.BitString.probDist_eq_sum {α : Type u_1} [Fintype α] (f g : α → Bool) (μ : PMF α) :
probDist f g μ = ∑ x : α, if f x ≠ g x then (μ x).toReal else 0
theorem Cslib.BitString.probDist_nonneg {α : Type u_1} [Fintype α] (f g : α → Bool) (μ : PMF α) :
0 ≤ probDist f g μ
theorem Cslib.BitString.probDist_le_one {α : Type u_1} [Fintype α] (f g : α → Bool) (μ : PMF α) :
probDist f g μ ≤ 1
theorem Cslib.BitString.probDist_self {α : Type u_1} [Fintype α] (f : α → Bool) (μ : PMF α) :
probDist f f μ = 0
theorem Cslib.BitString.probDist_comm {α : Type u_1} [Fintype α] (f g : α → Bool) (μ : PMF α) :
probDist f g μ = probDist g f μ
theorem Cslib.BitString.probDist_triangle {α : Type u_1} [Fintype α] (f g h : α → Bool) (μ : PMF α) :
probDist f h μ ≤ probDist f g μ + probDist g h μ
noncomputable def Cslib.BitString.distToMonotone {α : Type u_1} [Fintype α] [PartialOrder α] (f : α → Bool) (μ : PMF α) :

The distance to monotonicity ε(f; μ) = min_{g monotone} Δ(f, g; μ) of a Boolean function f : α → Bool on a finite partial order α under μ.

theorem Cslib.BitString.distToMonotone_le {α : Type u_1} [Fintype α] [PartialOrder α] {f g : α → Bool} (hg : Monotone g) (μ : PMF α) :
theorem Cslib.BitString.exists_monotone_probDist_eq_distToMonotone {α : Type u_1} [Fintype α] [PartialOrder α] (f : α → Bool) (μ : PMF α) :
∃ (g : α → Bool), Monotone g ∧ probDist f g μ = distToMonotone f μ
theorem Cslib.BitString.distToMonotone_nonneg {α : Type u_1} [Fintype α] [PartialOrder α] (f : α → Bool) (μ : PMF α) :
theorem Cslib.BitString.distToMonotone_of_monotone {α : Type u_1} [Fintype α] [PartialOrder α] {f : α → Bool} (hf : Monotone f) (μ : PMF α) :
noncomputable def Cslib.BitString.negSensCoords {n m : ℕ} (f : (Fin n → Fin m) → Bool) (x : Fin n → Fin m) :

The set of negatively sensitive coordinates of f : [m]^n → {0, 1} at x.

theorem Cslib.BitString.mem_negSensCoords {n m : ℕ} {f : (Fin n → Fin m) → Bool} {x : Fin n → Fin m} {i : Fin n} :
i ∈ negSensCoords f x ↔ ∃ (v : Fin m), x i < v ∧ f x = true ∧ f (Function.update x i v) = false ∨ v < x i ∧ f x = false ∧ f (Function.update x i v) = true
noncomputable def Cslib.BitString.cubeNegSensCoords {n : ℕ} (f : (Fin n → Bool) → Bool) (x : Fin n → Bool) :

The set of negatively sensitive coordinates of f : {0, 1}^n → {0, 1} at x.

theorem Cslib.BitString.mem_cubeNegSensCoords {n : ℕ} {f : (Fin n → Bool) → Bool} {x : Fin n → Bool} {i : Fin n} :
noncomputable def Cslib.BitString.negSensitivity {n m : ℕ} (f : (Fin n → Fin m) → Bool) (x : Fin n → Fin m) :

The negative sensitivity s_f^-(x) of f : [m]^n → {0, 1} at x: the number of coordinates i : Fin n for which there exists y differing from x only on coordinate i such that (x, y) violates monotonicity (x < y and f x > f y, or y < x and f y > f x).

theorem Cslib.BitString.negSensitivity_eq_card {n m : ℕ} (f : (Fin n → Fin m) → Bool) (x : Fin n → Fin m) :
noncomputable def Cslib.BitString.cubeNegSensitivity {n : ℕ} (f : (Fin n → Bool) → Bool) (x : Fin n → Bool) :

The negative sensitivity s_f^-(x) on the Boolean hypercube Fin n → Bool.

theorem Cslib.BitString.negSensitivity_le_dim {n m : ℕ} (f : (Fin n → Fin m) → Bool) (x : Fin n → Fin m) :

Local embeddings and relaxed local embeddings #

structure Cslib.BitString.RelaxedLocalEmbedding (m r : ℕ) (μ₁ : PMF (Fin m)) (μ₂ : PMF (Fin r → Bool)) :

A probability distribution ([m], μ₁) can be r-locally embedded in ({0, 1}^r, μ₂) via a monotone map φ : {0, 1}^r → [m], a finite probability space (Ω, P), and monotone maps Ψ_ω : [m] → {0, 1}^r satisfying the pushforward, inverse-sampling, and right-inverse (φ ∘ Ψ_ω = id) conditions.

  • Ω : Type

    The underlying finite randomness space Ω.

  • instFintypeΩ : Fintype self.Ω

    Finiteness of Ω.

  • P : PMF self.Ω

    The probability distribution P on Ω.

  • φ : (Fin r → Bool) → Fin m

    The monotone map φ : {0, 1}^r → [m].

  • Ψ : self.Ω → Fin m → Fin r → Bool

    The family of monotone maps Ψ_ω : [m] → {0, 1}^r.

  • φ_mono : Monotone self.φ

    φ is monotone.

  • Ψ_mono (ω : self.Ω) : Monotone (self.Ψ ω)

    Each Ψ ω is monotone.

  • map_φ : PMF.map self.φ μ₂ = μ₁

    Sampling x ~ μ₂, φ x is distributed as μ₁.

  • bind_Ψ : (μ₁.bind fun (y : Fin m) => PMF.map (fun (ω : self.Ω) => self.Ψ ω y) self.P) = μ₂

    Sampling y ~ μ₁ and ω ~ P, Ψ ω y is distributed as μ₂.

  • left_inv (ω : self.Ω) (y : Fin m) : self.φ (self.Ψ ω y) = y

    For every ω ∈ Ω, φ ∘ Ψ ω = id on [m].

@[instance_reducible]
def Cslib.BitString.instFintypeRelaxedLocalEmbeddingΩ {m r : ℕ} {μ₁ : PMF (Fin m)} {μ₂ : PMF (Fin r → Bool)} (E : RelaxedLocalEmbedding m r μ₁ μ₂) :

Scoped Fintype instance on the randomness space E.Ω of a relaxed local embedding.

@[reducible, inline]
abbrev Cslib.BitString.LocalEmbedding (m r : ℕ) (μ₁ : PMF (Fin m)) :

([m], μ₁) can be r-locally embedded (into the uniform hypercube ({0, 1}^r, U)).

def Cslib.BitString.CanRelaxedLocallyEmbed (m r : ℕ) (μ₁ : PMF (Fin m)) (μ₂ : PMF (Fin r → Bool)) :

Predicate asserting that ([m], μ₁) can be r-locally embedded in ({0, 1}^r, μ₂).

def Cslib.BitString.CanLocallyEmbed (m r : ℕ) (μ₁ : PMF (Fin m)) :

Predicate asserting that ([m], μ₁) can be r-locally embedded in ({0, 1}^r, U).

Lifted functions on {0, 1}^{n × r} and {0, 1}^{n · r} #

def Cslib.BitString.blockMap {m r n : ℕ} (φ : (Fin r → Bool) → Fin m) (x : Fin n → Fin r → Bool) :
Fin n → Fin m

Blockwise coordinate map Φ : ({0, 1}^r)^n → [m]^n applying φ to each r-bit block.

def Cslib.BitString.flatBlockMap {m r n : ℕ} (φ : (Fin r → Bool) → Fin m) (x : Fin (n * r) → Bool) :
Fin n → Fin m

Flattened blockwise map {0, 1}^{n · r} → [m]^n using BitString.block.

def Cslib.BitString.liftedFunction {m r n : ℕ} (φ : (Fin r → Bool) → Fin m) (f : (Fin n → Fin m) → Bool) :
(Fin n → Fin r → Bool) → Bool

The lifted Boolean function g(x(1), …, x(n)) = f(φ(x(1)), …, φ(x(n))) on ({0, 1}^r)^n.

theorem Cslib.BitString.liftedFunction_apply {m r n : ℕ} (φ : (Fin r → Bool) → Fin m) (f : (Fin n → Fin m) → Bool) (x : Fin n → Fin r → Bool) :
liftedFunction φ f x = f fun (i : Fin n) => φ (x i)
def Cslib.BitString.liftedFunctionFlat {m r n : ℕ} (φ : (Fin r → Bool) → Fin m) (f : (Fin n → Fin m) → Bool) :
(Fin (n * r) → Bool) → Bool

The lifted Boolean function on Fin (n * r) → Bool.

theorem Cslib.BitString.liftedFunctionFlat_apply {m r n : ℕ} (φ : (Fin r → Bool) → Fin m) (f : (Fin n → Fin m) → Bool) (x : Fin (n * r) → Bool) :
liftedFunctionFlat φ f x = f fun (i : Fin n) => φ fun (j : Fin r) => x (finProdFinEquiv (i, j))
theorem Cslib.BitString.blockMap_mono {m r n : ℕ} {φ : (Fin r → Bool) → Fin m} (hφ : Monotone φ) :
theorem Cslib.BitString.flatBlockMap_mono {m r n : ℕ} {φ : (Fin r → Bool) → Fin m} (hφ : Monotone φ) :
theorem Cslib.BitString.monotone_liftedFunction {m r n : ℕ} {φ : (Fin r → Bool) → Fin m} {f : (Fin n → Fin m) → Bool} (hφ : Monotone φ) (hf : Monotone f) :

If f is monotone and φ is monotone, then the lifted function g is monotone.

theorem Cslib.BitString.monotone_liftedFunctionFlat {m r n : ℕ} {φ : (Fin r → Bool) → Fin m} {f : (Fin n → Fin m) → Bool} (hφ : Monotone φ) (hf : Monotone f) :

Flattened version of monotonicity preservation.

Distance preservation #

theorem Cslib.BitString.distToMonotone_le_liftedFunction {m r n : ℕ} {μ₁ : PMF (Fin m)} {μ₂ : PMF (Fin r → Bool)} (E : RelaxedLocalEmbedding m r μ₁ μ₂) (f : (Fin n → Fin m) → Bool) :

Under any relaxed r-local embedding of ([m], μ₁) in ({0, 1}^r, μ₂), the lifted function g satisfies ε(f; μ₁^{⊗ n}) ≤ ε(g; μ₂^{⊗ n}).

Flattened uniform-cube distance preservation: if ([m], μ₁) is r-locally embedded, then ε(f; μ₁^{⊗ n}) ≤ ε(g; U^{⊗ (n·r)}).

Negative sensitivity pullback #

theorem Cslib.BitString.cubeNegSensitivity_liftedFunctionFlat_le {m r n : ℕ} {φ : (Fin r → Bool) → Fin m} (hφ : Monotone φ) (f : (Fin n → Fin m) → Bool) (x : Fin (n * r) → Bool) :

Pointwise negative-sensitivity bound: for any monotone φ : {0, 1}^r → [m] and f : [m]^n → {0, 1}, s_g^-(x) ≤ r · s_f^-(Φ(x)).

theorem Cslib.BitString.expect_sqrt_cubeNegSensitivity_le {m r n : ℕ} {μ₁ : PMF (Fin m)} {μ₂ : PMF (Fin r → Bool)} (E : RelaxedLocalEmbedding m r μ₁ μ₂) (f : (Fin n → Fin m) → Bool) :
∑ x : Fin (n * r) → Bool, ((Probability.PMF.iid μ₂ n) (blocksEquiv x)).toReal * √↑(cubeNegSensitivity (liftedFunctionFlat E.φ f) x) ≤ √↑r * ∑ y : Fin n → Fin m, ((Probability.PMF.iid μ₁ n) y).toReal * √↑(negSensitivity f y)

Expected square-root negative sensitivity pullback under a relaxed local embedding: under any relaxed r-local embedding (r > 0), E_{x ~ μ₂^{⊗ n}}[√s_g^-(x)] ≤ √r · E_{y ~ μ₁^{⊗ n}}[√s_f^-(y)].

Statistical-distance perturbation lemmas #

theorem Cslib.BitString.abs_expect_sub_le_mul_dist {α : Type u_1} [Fintype α] (μ ν : PMF α) (h : α → ℝ) {B : ℝ} (h0 : ∀ (x : α), 0 ≤ h x) (hB : ∀ (x : α), h x ≤ B) :
|∑ x : α, (μ x).toReal * h x - ∑ x : α, (ν x).toReal * h x| ≤ B * dist μ ν

Changing the distribution from μ to ν changes the expectation of any [0, B]-valued function by at most B · dist μ ν.

theorem Cslib.BitString.abs_probDist_sub_le_dist {α : Type u_1} [Fintype α] (f g : α → Bool) (μ ν : PMF α) :
|probDist f g μ - probDist f g ν| ≤ dist μ ν

Changing the distribution from μ to ν changes probDist f g by at most dist μ ν.

theorem Cslib.BitString.abs_distToMonotone_sub_le_dist {α : Type u_1} [Fintype α] [PartialOrder α] (f : α → Bool) (μ ν : PMF α) :

Changing the distribution from μ to ν changes distToMonotone f by at most dist μ ν.

theorem Cslib.BitString.dist_coin {p p' : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (hp'0 : 0 ≤ p') (hp'1 : p' ≤ 1) :

Statistical distance between two biased coins PMF.coin equals |p - p'|.

Generic LocalTest pullback and concrete edge-tester instantiation #

def Cslib.BitString.pullbackLocalTest {m r n : ℕ} {R : Type u_1} {Q : Type u_2} (φ : (Fin r → Bool) → Fin m) (T : PCP.LocalTest (Fin (n * r) → Bool) R Q Bool) :
PCP.LocalTest (Fin n → Fin m) R Q Bool

Pull back a LocalTest on the Boolean hypercube {0, 1}^{n · r} along φ^{⊗ n} to a LocalTest on [m]^n with the exact same randomness space R and query index type Q.

theorem Cslib.BitString.acceptProb_pullbackLocalTest {m r n : ℕ} {R : Type u_1} {Q : Type u_2} [Fintype R] (φ : (Fin r → Bool) → Fin m) (T : PCP.LocalTest (Fin (n * r) → Bool) R Q Bool) (f : (Fin n → Fin m) → Bool) :

Pulling back a LocalTest preserves acceptance probability on f vs the lifted function liftedFunctionFlat φ f.

theorem Cslib.BitString.pullbackLocalTest_sound_and_complete {m r n : ℕ} {R : Type u_1} {Q : Type u_2} [Fintype R] {μ₁ : PMF (Fin m)} (E : LocalEmbedding m r μ₁) (T : PCP.LocalTest (Fin (n * r) → Bool) R Q Bool) {ε ρ : ℝ} (hcomp : ∀ (g : (Fin (n * r) → Bool) → Bool), Monotone g → T.acceptProb g = 1) (hsound : ∀ (g : (Fin (n * r) → Bool) → Bool), ε ≤ distToMonotone g (Probability.PMF.uniformOfFintype (Fin (n * r) → Bool)) → 1 - T.acceptProb g ≥ ρ) :
(∀ (f : (Fin n → Fin m) → Bool), Monotone f → (pullbackLocalTest E.φ T).acceptProb f = 1) ∧ ∀ (f : (Fin n → Fin m) → Bool), ε ≤ distToMonotone f (Probability.PMF.iid μ₁ n) → 1 - (pullbackLocalTest E.φ T).acceptProb f ≥ ρ

Given any local monotonicity tester T on the uniform hypercube {0, 1}^{n · r} that always accepts monotone functions and rejects ε-far functions with probability at least ρ, an r-local embedding of ([m], μ₁) yields a local tester on [m]^n with the exact same query type Q that always accepts monotone functions and rejects functions ε-far under μ₁^{⊗ n} with probability at least ρ.

theorem Cslib.BitString.pullback_edgeTest_sound_and_complete {m r n : ℕ} (hn : 0 < n) (hr : 0 < r) {μ₁ : PMF (Fin m)} (E : LocalEmbedding m r μ₁) {ε : ℝ} :
(∀ (f : (Fin n → Fin m) → Bool), Monotone f → (pullbackLocalTest E.φ (edgeTest (Fin (n * r)))).acceptProb f = 1) ∧ ∀ (f : (Fin n → Fin m) → Bool), ε ≤ distToMonotone f (Probability.PMF.iid μ₁ n) → 1 - (pullbackLocalTest E.φ (edgeTest (Fin (n * r)))).acceptProb f ≥ ε / ↑(n * r)

Concrete unconditional instantiation of pullbackLocalTest_sound_and_complete with the Cslib.BitString.edgeTest (2-query edge tester), proving non-vacuity and yielding a 2-query monotonicity tester over ([m]^n, μ₁^{⊗ n}) with rejection probability at least ε / (n · r).

theorem Cslib.BitString.repeatAll_pullbackLocalTest_sound_and_complete {m r n : ℕ} {R : Type u_1} {Q : Type u_2} [Fintype R] {μ₁ : PMF (Fin m)} (E : LocalEmbedding m r μ₁) (T : PCP.LocalTest (Fin (n * r) → Bool) R Q Bool) {ε ρ : ℝ} (hρ0 : 0 < ρ) {k : ℕ} (hk : 2 ≤ ↑k * ρ) (hcomp : ∀ (g : (Fin (n * r) → Bool) → Bool), Monotone g → T.acceptProb g = 1) (hsound : ∀ (g : (Fin (n * r) → Bool) → Bool), ε ≤ distToMonotone g (Probability.PMF.uniformOfFintype (Fin (n * r) → Bool)) → 1 - T.acceptProb g ≥ ρ) :
(∀ (f : (Fin n → Fin m) → Bool), Monotone f → ((pullbackLocalTest E.φ T).repeatAll k).acceptProb f = 1) ∧ ∀ (f : (Fin n → Fin m) → Bool), ε ≤ distToMonotone f (Probability.PMF.iid μ₁ n) → 1 - ((pullbackLocalTest E.φ T).repeatAll k).acceptProb f ≥ 2 / 3

Repeating a pulled-back local tester k times (k ≥ 2 / ρ) preserves one-sided completeness and boosts rejection probability on ε-far functions to at least 2 / 3.

theorem Cslib.BitString.localEmbedding_dist_and_sqrt_negSensitivity {m r n : ℕ} (hr : 0 < r) {μ₁ : PMF (Fin m)} (E : LocalEmbedding m r μ₁) (f : (Fin n → Fin m) → Bool) :

Given an r-local embedding (r > 0) of ([m], μ₁) into ({0, 1}^r, U), the lifted function g = liftedFunctionFlat E.φ f satisfies both ε(f; μ₁^{⊗ n}) ≤ ε(g; U^{⊗ (nr)}) and (1 / √r) · E_{U^{⊗ (nr)}}[√s_g^-] ≤ E_{μ₁^{⊗ n}}[√s_f^-].