Definitionadvanced
Null space property
Also called NSP.
A matrix has the null space property of order s if every null space vector has less L1 mass on any s entries than off them, which is exactly what basis pursuit needs.
The null space property is the exact condition on a matrix under which minimization, basis pursuit, recovers every -sparse vector from . It looks only at the null space of : no nonzero vector that maps to 0 may put half or more of its mass on entries. It is weaker than the restricted isometry property, which also gives recovery but is only sufficient, and it is weaker than a bound on the mutual coherence, which is cheap to check but gives recovery only for small . Like the restricted isometry property, it is NP-hard to check in general. The Donoho-Tanner phase transition describes for which sizes a random Gaussian matrix has it.
Definition
Let (or ) and . For let keep the entries of in and set the others to 0, and let be the complement. has the null space property of order if
Adding to both sides gives the equivalent form . So with the null space constant
the property holds exactly when . The inner maximum is the sum of the largest . If is injective, there is no such , and the property holds for every . The property depends only on , so it does not change when is replaced by for an invertible .
Theorem (Donoho and Huo 2001, Gribonval and Nielsen 2003, Cohen, Dahmen and DeVore 2009). Every -sparse is the unique solution of subject to if and only if has the null space property of order .
Proof. Assume the property. Let have support with , and let with . Then is a nonzero null vector, and
Conversely, let and . The vector is -sparse and satisfies , because . Also , because . If is the unique minimizer, then .
The proof of the converse gives a certificate of failure: if , the -sparse vector and the vector have the same measurements, and the second one has no larger norm.
Stable and robust forms. has the stable null space property of order with constant if for all and ; this is . It gives an error bound for vectors that are only close to sparse: the solution of basis pursuit satisfies , where is the error of the best -term approximation of . The robust form adds a term on the right and covers noisy measurements. Cohen, Dahmen and DeVore showed that a bound of this type, called instance optimality in , holds for some decoder if and only if a null space property of order holds.
Checking it on a small matrix. The function is convex, and the set is a polytope, so the maximum in is reached at a vertex of that polytope. A vertex lies in a face of the ball with support and spans the null space of the columns , which must then have dimension 1; this needs . So an exhaustive check is:
NSP-CONSTANT(A, s)- 1
r ← rank(A), θ ← 0 - 2
for each set T of at most r + 1 columns - 3
if the null space of A_T has dimension 1 and is spanned by v with support exactly T - 4
θ ← max(θ, (sum of the s largest |v_i|) / ‖v‖₁) - 5
return θ ▷ the property of order s holds if and only if θ < 1/2
The number of sets grows exponentially with , and this is not an accident: Tillmann and Pfetsch (2014) proved that deciding the null space property is NP-hard when the rational matrix and are both part of the input. The implementation does the check in exact rational arithmetic, and its tests compare the result with an exhaustive minimization over all basic solutions of .
Examples and non-examples
A matrix. Let
The null space is spanned by . Every entry has absolute value 1, so one entry carries of the mass and two entries carry . So and has the property of order 1: basis pursuit recovers every 1-sparse vector. But , so the property of order 2 fails. The certificate is and : both give , and . Basis pursuit returns , not .
A row of ones. has the null vector , with exactly half of its mass on one entry. So and the property of order 1 fails, at the boundary: and give the same measurement and the same norm, so the minimizer is not unique.
Identity and Hadamard. For in , with the Sylvester Hadamard matrix , the exact check gives and . So the property of order 1 holds and the property of order 2 fails, again at the boundary: the null vector says that and the sum of the first and third Hadamard columns, , are the same vector.
Coherence implies the property. Let the columns have norm 1 and coherence . For , the equation gives , so and . Hence , which is below when , the classical coherence condition. In the Hadamard example , the bound gives , and the exact value is .
Restricted isometry implies the property. By the theorem above, every condition on that gives exact recovery of all -sparse vectors by basis pursuit implies the null space property of order . Cai and Zhang (2014) proved that is enough, and that the constant cannot be improved. The converse is false: the property is invariant under , and a badly conditioned can make every restricted isometry constant large without changing the null space.
Non-example: a sparse null vector. If some null vector has at most nonzero entries, then some of them carry at least half of its mass, and the property of order fails. So the property of order needs , and therefore .
Related definitions
- Restricted isometry property. A condition on all -column submatrices. It implies the null space property and also stability under noise, and random matrices with of order have it.
- Mutual coherence. A cheap sufficient condition, .
- Spark. The least number of dependent columns. is the condition for uniqueness of the sparsest solution, which is necessary for the null space property but not sufficient.
- Neighborliness. The property of order holds if and only if the image of the ball, a convex polytope, is centrally -neighborly: every set of vertices that does not contain an antipodal pair spans a face. Donoho used this form to count when random matrices have the property; see the Donoho-Tanner phase transition.
- Nonuniform recovery. Recovery of one fixed -sparse vector, with its sign pattern, needs only a dual certificate for that vector, not the property for all of them. Results such as the Candes-Romberg-Tao theorem are of this kind.
Code
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/null-space-property/. The authors are listed in prov/PPTQNH.jsonl.
"""Exact brute force check of the null space property of a small rational matrix.
A matrix is a list of m rows of length n with integer or Fraction entries.
The null space constant of order s is
theta_s(A) = max over nonzero v with A v = 0 of (sum of the s largest |v_i|) / ||v||_1.
A has the null space property of order s if and only if theta_s(A) < 1/2.
The function in the maximum is convex and the set {v : A v = 0, ||v||_1 <= 1}
is a polytope, so the maximum is reached at a vertex. Each vertex spans the
one dimensional null space of A restricted to its support, and its support
has at most rank(A) + 1 entries. The check enumerates those supports with
exact Fraction arithmetic. It takes time exponential in n: use it on tiny
matrices only.
"""
from fractions import Fraction
from itertools import combinations
def _rref(rows):
"""Reduced row echelon form (in place on a copy). Returns (matrix, pivot columns)."""
a = [[Fraction(v) for v in row] for row in rows]
m = len(a)
t = len(a[0]) if a else 0
pivots = []
r = 0
for c in range(t):
p = next((i for i in range(r, m) if a[i][c] != 0), None)
if p is None:
continue
a[r], a[p] = a[p], a[r]
piv = a[r][c]
a[r] = [v / piv for v in a[r]]
for i in range(m):
if i != r and a[i][c] != 0:
f = a[i][c]
a[i] = [x - f * y for x, y in zip(a[i], a[r])]
pivots.append(c)
r += 1
if r == m:
break
return a, pivots
def rank(a):
return len(_rref(a)[1])
def null_vector(a, cols):
"""The null vector of A restricted to the columns cols, if that null space has dimension 1.
Returns a list of Fractions indexed like cols, or None.
"""
sub = [[row[j] for j in cols] for row in a]
red, pivots = _rref(sub)
t = len(cols)
free = [c for c in range(t) if c not in pivots]
if len(free) != 1:
return None
f = free[0]
v = [Fraction(0)] * t
v[f] = Fraction(1)
for i, c in enumerate(pivots):
v[c] = -red[i][f]
return v
def top_mass(v, s):
"""The sum of the s largest absolute values of v."""
return sum(sorted((abs(x) for x in v), reverse=True)[:s])
def nsp_constant(a, s):
"""Return (theta_s, v): the exact null space constant and a null vector that attains it.
If A is injective, there is no nonzero null vector; then theta is 0 and v is None.
"""
n = len(a[0])
r = rank(a) # @line L1
theta, best = Fraction(0), None
for t in range(1, min(n, r + 1) + 1):
for cols in combinations(range(n), t): # @line L2
w = null_vector(a, cols) # @line L3
if w is None or any(x == 0 for x in w):
continue
v = [Fraction(0)] * n
for j, x in zip(cols, w):
v[j] = x
ratio = top_mass(v, s) / sum(abs(x) for x in v) # @line L4
if ratio > theta:
theta, best = ratio, v
return theta, best # @line L5
def has_nsp(a, s):
"""True if A has the null space property of order s."""
return nsp_constant(a, s)[0] < Fraction(1, 2)
def failure_certificate(a, s):
"""If the property fails, return (x, z): x is s-sparse, A x = A z, z != x and ||z||_1 <= ||x||_1.
Then l1 minimization cannot return x as its unique solution. Returns None if the property holds.
"""
theta, v = nsp_constant(a, s)
if theta < Fraction(1, 2):
return None
order = sorted(range(len(v)), key=lambda i: -abs(v[i]))[:s]
x = [v[i] if i in order else Fraction(0) for i in range(len(v))]
z = [Fraction(0) if i in order else -v[i] for i in range(len(v))]
return x, z
test_null_space_property.py 136 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/null-space-property/. The authors are listed in prov/PPTQNH.jsonl.
import random
from fractions import Fraction
from itertools import combinations
from null_space_property import _rref, failure_certificate, has_nsp, nsp_constant, rank
HALF = Fraction(1, 2)
def matvec(a, x):
return [sum(Fraction(p) * q for p, q in zip(row, x)) for row in a]
def l1(v):
return sum(abs(x) for x in v)
def kernel_basis(a):
red, pivots = _rref(a)
n = len(a[0])
basis = []
for f in (c for c in range(n) if c not in pivots):
v = [Fraction(0)] * n
v[f] = Fraction(1)
for i, c in enumerate(pivots):
v[c] = -red[i][f]
basis.append(v)
return basis
def bp_solutions(a, y):
"""All basic solutions of A z = y (supports with independent columns), and the l1 minimum.
l1 minimization is a linear program, and its minimum is reached at one of
these basic solutions, so this is an exact brute force solver for tiny A.
"""
n = len(a[0])
r = rank(a)
sols = []
for t in range(0, r + 1):
for cols in combinations(range(n), t):
sub = [[row[j] for j in cols] + [yi] for row, yi in zip(a, y)]
red, pivots = _rref(sub)
if t in pivots or len(pivots) != t:
continue # inconsistent, or the columns are dependent
z = [Fraction(0)] * n
for i, c in enumerate(pivots):
z[cols[c]] = red[i][t]
sols.append(z)
best = min(l1(z) for z in sols)
return best, [z for z in sols if l1(z) == best]
def test_hand_example():
a = [[1, 0, 1], [0, 1, 1]]
theta1, v = nsp_constant(a, 1)
assert theta1 == Fraction(1, 3)
assert matvec(a, v) == [0, 0]
assert has_nsp(a, 1)
theta2, _ = nsp_constant(a, 2)
assert theta2 == Fraction(2, 3)
assert not has_nsp(a, 2)
x, z = failure_certificate(a, 2)
assert [abs(t) for t in x] == [1, 1, 0] and [abs(t) for t in z] == [0, 0, 1]
assert matvec(a, x) == matvec(a, z)
assert l1(z) < l1(x)
def test_boundary_and_injective_cases():
# One row of ones: v = (1, -1, 0) has half its mass on one entry, so order 1 fails (not strictly).
assert nsp_constant([[1, 1, 1]], 1)[0] == HALF
assert not has_nsp([[1, 1, 1]], 1)
# An injective matrix has no nonzero null vector.
eye = [[1 if i == j else 0 for j in range(3)] for i in range(3)]
assert nsp_constant(eye, 2) == (0, None)
assert has_nsp(eye, 3)
def test_identity_and_hadamard():
# [I | H/2] in R^4 has coherence 1/2 < 1/(2s - 1) for s = 1, so order 1 holds.
# Order 2 fails: e1 + e3 - (h1 + h2)/2 = 0 has half its mass on two entries.
h = [[1, 1, 1, 1], [1, -1, 1, -1], [1, 1, -1, -1], [1, -1, -1, 1]]
a = [[Fraction(int(i == j)) for j in range(4)] + [Fraction(v, 2) for v in h[i]] for i in range(4)]
theta1, _ = nsp_constant(a, 1)
assert theta1 < HALF
theta2, _ = nsp_constant(a, 2)
assert theta2 >= HALF
assert not has_nsp(a, 2)
def test_constant_bounds_random_null_vectors():
rng = random.Random(1)
for _ in range(6):
a = [[rng.randint(-3, 3) for _ in range(6)] for _ in range(3)]
basis = kernel_basis(a)
for s in (1, 2):
theta, v = nsp_constant(a, s)
assert matvec(a, v) == [0, 0, 0]
assert theta <= s * nsp_constant(a, 1)[0]
for _ in range(100):
coef = [Fraction(rng.randint(-9, 9), rng.randint(1, 9)) for _ in basis]
w = [sum(c * b[i] for c, b in zip(coef, basis)) for i in range(6)]
if l1(w) == 0:
continue
top = sum(sorted((abs(t) for t in w), reverse=True)[:s])
assert top / l1(w) <= theta
def test_property_decides_l1_recovery():
# If the property of order s holds, l1 minimization returns every s-sparse
# vector as its unique solution; if it fails, the certificate shows a
# vector with the same measurements and no larger l1 norm.
rng = random.Random(2)
seen = {True: 0, False: 0}
for _ in range(8):
a = [[rng.randint(-3, 3) for _ in range(6)] for _ in range(4)]
for s in (1, 2):
ok = has_nsp(a, s)
seen[ok] += 1
if ok:
for _ in range(6):
x = [Fraction(0)] * 6
for i in rng.sample(range(6), s):
x[i] = Fraction(rng.choice([-1, 1]) * rng.randint(1, 5))
best, argmins = bp_solutions(a, matvec(a, x))
assert best == l1(x)
assert argmins and all(z == x for z in argmins)
else:
x, z = failure_certificate(a, s)
assert sum(1 for t in x if t != 0) <= s
assert matvec(a, x) == matvec(a, z)
assert z != x and l1(z) <= l1(x)
assert seen[True] > 0 and seen[False] > 0
References
- Albert Cohen, Wolfgang Dahmen and Ronald DeVore, Compressed sensing and best k-term approximation, Journal of the American Mathematical Society 22(1), 2009, pages 211 to 231 (the null space property, its name, and its equivalence with instance optimality in l1)
- Remi Gribonval and Morten Nielsen, Sparse representations in unions of bases, IEEE Transactions on Information Theory 49(12), 2003, pages 3320 to 3325 (the condition on the null space for l1 minimization to recover every s-sparse vector)
- Andreas M. Tillmann and Marc E. Pfetsch, The computational complexity of the restricted isometry property, the nullspace property, and related concepts in compressed sensing, IEEE Transactions on Information Theory 60(2), 2014, pages 1248 to 1259 (testing the null space property is NP-hard)
- T. Tony Cai and Anru Zhang, Sparse representation of a polytope and recovery of sparse signals and low-rank matrices, IEEE Transactions on Information Theory 60(1), 2014, pages 122 to 132 (delta_2s < 1/sqrt(2) is enough for exact recovery, and the constant is sharp)
- Simon Foucart and Holger Rauhut, A Mathematical Introduction to Compressive Sensing, Birkhauser, 2013, the chapter on basis pursuit (the null space property and its stable and robust forms)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag PPTQNH Edit this page History Report an error Markdown