Migration from Tal’s BooleanFunc.py
If you’ve used Avishay Tal’s BooleanFunc.py toolkit (from CS 294-92 at UC Berkeley), this guide maps his functions to boofun equivalents. The coverage is ~90%; a few generic utilities (tqdm, binary_search) are available from standard Python.
Quick Start
# Tal's BooleanFunc
f = BooleanFunc("x0&x1 ^ x2")
f.real_fourier()
f.sensitivity(5)
f.decision_tree()
# boofun equivalent
import boofun as bf
f = bf.create("x0 and x1 ^ x2", n=3) # symbolic (like Tal's from_str)
f = bf.create([0, 0, 0, 1, 1, 0, 1, 0]) # or truth table
f.fourier() # WHT coefficients
f.sensitivity_at(5) # sensitivity at input 5
from boofun.analysis.complexity import D
D(f) # decision tree depth
Fourier Analysis
Tal |
boofun |
Notes |
|---|---|---|
|
|
Returns array of WHT coefficients |
|
|
GF(2) / ANF coefficients |
|
|
Single coefficient |
|
|
Fourier degree |
|
|
Algebraic degree over GF(2) |
|
|
E[f] in ±1 convention |
|
|
L1 spectral norm |
|
|
W^k = sum f_hat(S)^2 by degree |
|
|
Zero out degree > d |
|
|
Noisy influence |
|
|
sum f_hat(S)^2/ |
from boofun.analysis.fourier import (
spectral_norm, fourier_weight_distribution, fourier_level_lp_norm,
fourier_tail_profile, truncate_to_degree, annealed_influence,
normalized_influence,
)
from boofun.analysis.gf2 import gf2_fourier_transform, gf2_degree
Complexity Measures
Tal |
boofun |
Notes |
|---|---|---|
|
|
Sensitivity at input x |
|
|
Max sensitivity |
|
|
Min sensitivity |
|
|
= total influence |
|
|
t-th moment |
|
|
Block sensitivity |
|
|
Returns (size, vars) |
|
|
Certificate complexity |
|
|
Min certificate |
|
|
Decision tree depth |
|
|
Variable influence |
|
|
Total influence |
from boofun.analysis.complexity import D, s, bs, C
D(f) # Decision tree depth
s(f) # Max sensitivity
bs(f) # Block sensitivity
C(f) # Certificate complexity
Restrictions and Composition
Tal |
boofun |
Notes |
|---|---|---|
|
|
Fix single variable |
|
|
Fix multiple variables |
|
|
XOR shift: f(x XOR s) |
|
|
Compose on disjoint blocks |
P-Biased Analysis
Tal |
boofun |
Notes |
|---|---|---|
|
|
E_{mu_p}[f] (exact, ±1 convention) |
|
|
Single p-biased Fourier coeff |
|
|
P-biased average sensitivity |
|
|
Via Fourier with normalization |
|
|
Parity coefficient under bias |
from boofun.analysis.p_biased import (
p_biased_expectation, p_biased_fourier_coefficient,
p_biased_average_sensitivity, p_biased_total_influence_fourier,
PBiasedAnalyzer,
)
Special Functions
Tal |
boofun |
Notes |
|---|---|---|
|
|
From |
|
|
Binomial coefficient |
|
|
From |
|
|
From |
|
|
From |
|
|
From |
|
|
From |
|
|
From |
from boofun.utils.math import popcnt, poppar, over, krawchouk
from boofun.utils.number_theory import prime_sieve, factor, is_prime
Construction
Tal |
boofun |
Notes |
|---|---|---|
|
|
From list |
|
|
Symbolic expression |
|
|
Symmetric functions |
|
|
Random function |
|
|
Expression parsing |
(no equivalent) |
|
GF(2) polynomials |
What boofun Adds
Features in boofun not in Tal’s BooleanFunc.py:
Multiple representations: truth table, Fourier, ANF, BDD, DNF/CNF, circuits, LTF
Automatic conversion between representations via conversion graph
Query complexity: R(f), Q(f), Ambainis bound, spectral adversary
Property testing: BLR, junta, monotonicity with probability bounds
Hypercontractivity: KKL, Bonami, Friedgut, global hypercontractivity
Cryptographic analysis: nonlinearity, bent functions, Walsh spectrum, LAT/DDT
Invariance principle: Gaussian analysis, Berry-Esseen, Majority is Stablest
Visualization: influence plots, Fourier spectrum, hypercube, dashboards
Family tracking: asymptotic growth analysis across function families
Monte Carlo estimation: sampling-based analysis for large n
Not in boofun (use standard Python)
Tal |
Alternative |
|---|---|
|
|
|
|
|
|
|
|