AFTD Auto-Formalizing Theoretical Domains

BoolBLR.BLR_completeness

theoremverifiedformalizationimported Lean

Completeness of the BLR linearity test. Let $n$ be a natural number and let $f : \{0,1\}^n \to \{0,1\}$ be linear, meaning that $f(x \oplus y) = f(x) \oplus f(y)$ for all $x, y \in \{0,1\}^n$. Then the BLR acceptance probability of $f$ equals $1$; that is, when $x$ and $y$ are drawn uniformly and independently from $\{0,1\}^n$, the test always accepts.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open Finset BoolFourier in
lemma BoolBLR.BLR_completeness {n : ℕ}
    (f : hypercube n → Bool)
    (hlin : is_linear_bool f) :
  BLR_accept_prob f = 1
Formalizes
Completeness of the BLR linearity test, as formalized in TCSlib (`BoolBLR.BLR_completeness`)
Lean proof
By Prastik Mohanraj, from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Copyright (c) 2026 Prastik Mohanraj. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.
Verified
07 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 6
  • BoolFourier.expectationFor $f : \{0,1\}^n \to \mathbb{R}$, the uniform expectation is \[ \mathbb{E}[f] = \frac{1}{2^n} \sum_{x \in \{0,1\}^n} f(x). \]
  • BoolBLR.is_linear_boolA function $f : \{0,1\}^n \to \{0,1\}$ is linear if for all $x, y \in \{0,1\}^n$ we have \[ f(x \oplus y) = f(x) \oplus f(y), \]…
  • BoolBLR.BLR_completeness_aux_h_lift_linearMultiplicativity of the sign lift of an XOR-homomorphism. Let $f : \{0,1\}^n \to \{0,1\}$ be a function that respects componentwise XOR,…
  • BoolBLR.BLR_accept_probThe BLR acceptance probability of $f : \{0,1\}^n \to \{0,1\}$ is…
  • BoolFourier.hypercubeThe Boolean hypercube of dimension $n$ is the type $\{0,1\}^n$, defined as an abbreviation for BooleanAnalysis.BoolCube $n$.
  • BoolBLR.BLR_completeness_aux_h_linearLinearity gives additivity on XOR. Let $f : \{0,1\}^n \to \{0,1\}$ be a linear function, meaning that $f(x \oplus y) = f(x) \oplus f(y)$…

Lean source view module on GitHub

set_option autoImplicit true inset_option relaxedAutoImplicit true inopen Finset BoolFourier in/-- Shows that every Boolean linear function passes the BLR test with probability one. **Source:** [OD14, §1.6]. -/lemma BoolBLR.BLR_completeness {n : ℕ}    (f : hypercube n → Bool)    (hlin : is_linear_bool f) :  BLR_accept_prob f = 1 := by  -- Restate linearity in convenient form.  -- Lift to the ±1 world: linearity becomes multiplicativity.  unfold BLR_accept_prob;  -- Each indicator becomes 1, and 2^n · 2^n / 2^n / 2^n = 1.  unfold expectation; norm_num [ (BLR_completeness_aux_h_lift_linear f (BLR_completeness_aux_h_linear f hlin)) ] ;-- Pr [ BLR accepts f ] ≤ 1 - ε if f is ε-far from any linear function
See it in the graphDiscuss this resultChallenge it