Algorithm Search⌘K

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 AA under which ℓ1\ell_1 minimization, basis pursuit, recovers every ss-sparse vector from y=Axy = Ax. It looks only at the null space of AA: no nonzero vector that AA maps to 0 may put half or more of its ℓ1\ell_1 mass on ss 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 ss. 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 A∈Rm×nA \in \mathbb{R}^{m \times n} (or Cm×n\mathbb{C}^{m \times n}) and 1≤s≤n1 \le s \le n. For S⊆{1,…,n}S \subseteq \{1, \dots, n\} let vSv_S keep the entries of vv in SS and set the others to 0, and let ScS^c be the complement. AA has the null space property of order ss if

∥vS∥1<∥vSc∥1for every v∈ker⁡A∖{0} and every S with ∣S∣≤s.\|v_S\|_1 < \|v_{S^c}\|_1 \quad\text{for every } v \in \ker A \setminus \{0\} \text{ and every } S \text{ with } |S| \le s.

Adding ∥vS∥1\|v_S\|_1 to both sides gives the equivalent form ∥vS∥1<12∥v∥1\|v_S\|_1 < \tfrac12\|v\|_1. So with the null space constant

θs(A)=max⁡v∈ker⁡A∖{0} max⁡∣S∣≤s∥vS∥1∥v∥1,\theta_s(A) = \max_{v \in \ker A \setminus \{0\}}\ \max_{|S| \le s}\frac{\|v_S\|_1}{\|v\|_1},

the property holds exactly when θs(A)<12\theta_s(A) < \tfrac12. The inner maximum is the sum of the ss largest ∣vi∣|v_i|. If AA is injective, there is no such vv, and the property holds for every ss. The property depends only on ker⁡A\ker A, so it does not change when AA is replaced by GAGA for an invertible GG.

Theorem (Donoho and Huo 2001, Gribonval and Nielsen 2003, Cohen, Dahmen and DeVore 2009). Every ss-sparse xx is the unique solution of min⁡∥z∥1\min\|z\|_1 subject to Az=AxAz = Ax if and only if AA has the null space property of order ss.

Proof. Assume the property. Let xx have support SS with ∣S∣≤s|S| \le s, and let z≠xz \ne x with Az=AxAz = Ax. Then v=x−zv = x - z is a nonzero null vector, and

∥z∥1=∥xS−vS∥1+∥vSc∥1≥∥x∥1−∥vS∥1+∥vSc∥1>∥x∥1.\|z\|_1 = \|x_S - v_S\|_1 + \|v_{S^c}\|_1 \ge \|x\|_1 - \|v_S\|_1 + \|v_{S^c}\|_1 > \|x\|_1.

Conversely, let v∈ker⁡A∖{0}v \in \ker A \setminus \{0\} and ∣S∣≤s|S| \le s. The vector x=vSx = v_S is ss-sparse and z=−vScz = -v_{S^c} satisfies Az=AxAz = Ax, because A(vS+vSc)=0A(v_S + v_{S^c}) = 0. Also z≠xz \ne x, because v≠0v \ne 0. If xx is the unique minimizer, then ∥vS∥1=∥x∥1<∥z∥1=∥vSc∥1\|v_S\|_1 = \|x\|_1 < \|z\|_1 = \|v_{S^c}\|_1. □\square

The proof of the converse gives a certificate of failure: if ∥vS∥1≥∥vSc∥1\|v_S\|_1 \ge \|v_{S^c}\|_1, the ss-sparse vector vSv_S and the vector −vSc-v_{S^c} have the same measurements, and the second one has no larger ℓ1\ell_1 norm.

Stable and robust forms. AA has the stable null space property of order ss with constant 0<ρ<10 < \rho < 1 if ∥vS∥1≤ρ∥vSc∥1\|v_S\|_1 \le \rho\|v_{S^c}\|_1 for all v∈ker⁡Av \in \ker A and ∣S∣≤s|S| \le s; this is θs≤ρ/(1+ρ)\theta_s \le \rho/(1 + \rho). It gives an error bound for vectors that are only close to sparse: the solution x♯x^\sharp of basis pursuit satisfies ∥x−x♯∥1≤2(1+ρ)1−ρσs(x)1\|x - x^\sharp\|_1 \le \frac{2(1 + \rho)}{1 - \rho}\sigma_s(x)_1, where σs(x)1\sigma_s(x)_1 is the ℓ1\ell_1 error of the best ss-term approximation of xx. The robust form adds a term τ∥Av∥\tau\|Av\| on the right and covers noisy measurements. Cohen, Dahmen and DeVore showed that a bound of this type, called instance optimality in ℓ1\ell_1, holds for some decoder if and only if a null space property of order 2s2s holds.

Checking it on a small matrix. The function v↦max⁡∣S∣≤s∥vS∥1v \mapsto \max_{|S| \le s}\|v_S\|_1 is convex, and the set {v∈ker⁡A:∥v∥1≤1}\{v \in \ker A : \|v\|_1 \le 1\} is a polytope, so the maximum in θs\theta_s is reached at a vertex of that polytope. A vertex lies in a face of the ℓ1\ell_1 ball with support TT and spans the null space of the columns ATA_T, which must then have dimension 1; this needs ∣T∣≤rank⁡(A)+1|T| \le \operatorname{rank}(A) + 1. So an exhaustive check is:

  1. NSP-CONSTANT(A, s)
  2. 1r ← rank(A), θ ← 0
  3. 2for each set T of at most r + 1 columns
  4. 3if the null space of A_T has dimension 1 and is spanned by v with support exactly T
  5. 4θ ← max(θ, (sum of the s largest |v_i|) / ‖v‖₁)
  6. 5return θ ▷ the property of order s holds if and only if θ < 1/2

The number of sets TT grows exponentially with nn, 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 ss are both part of the input. The implementation does the check in exact rational arithmetic, and its tests compare the result with an exhaustive ℓ1\ell_1 minimization over all basic solutions of Az=yAz = y.

Examples and non-examples

A 2×32 \times 3 matrix. Let

A=(101011).A = \begin{pmatrix}1 & 0 & 1\\ 0 & 1 & 1\end{pmatrix}.

The null space is spanned by v=(1,1,−1)v = (1, 1, -1). Every entry has absolute value 1, so one entry carries 13\tfrac13 of the mass and two entries carry 23\tfrac23. So θ1=13<12\theta_1 = \tfrac13 < \tfrac12 and AA has the property of order 1: basis pursuit recovers every 1-sparse vector. But θ2=23\theta_2 = \tfrac23, so the property of order 2 fails. The certificate is x=v{1,2}=(1,1,0)x = v_{\{1,2\}} = (1, 1, 0) and z=−v{3}=(0,0,1)z = -v_{\{3\}} = (0, 0, 1): both give y=(1,1)y = (1, 1), and ∥z∥1=1<2=∥x∥1\|z\|_1 = 1 < 2 = \|x\|_1. Basis pursuit returns zz, not xx.

A row of ones. A=(1 1 1)A = (1\ 1\ 1) has the null vector (1,−1,0)(1, -1, 0), with exactly half of its mass on one entry. So θ1=12\theta_1 = \tfrac12 and the property of order 1 fails, at the boundary: x=e1x = e_1 and z=e2z = e_2 give the same measurement and the same ℓ1\ell_1 norm, so the minimizer is not unique.

Identity and Hadamard. For A=[ I∣12H ]A = [\,I \mid \tfrac12H\,] in R4\mathbb{R}^4, with the 4×44 \times 4 Sylvester Hadamard matrix HH, the exact check gives θ1=13\theta_1 = \tfrac13 and θ2=12\theta_2 = \tfrac12. So the property of order 1 holds and the property of order 2 fails, again at the boundary: the null vector (−1,−1,0,0,1,0,1,0)(-1, -1, 0, 0, 1, 0, 1, 0) says that e1+e2e_1 + e_2 and the sum of the first and third Hadamard columns, 12(h1+h3)\tfrac12(h_1 + h_3), are the same vector.

Coherence implies the property. Let the columns have norm 1 and coherence μ\mu. For v∈ker⁡Av \in \ker A, the equation ⟨ai,Av⟩=0\langle a_i, Av\rangle = 0 gives vi=−∑j≠i⟨ai,aj⟩vjv_i = -\sum_{j \ne i}\langle a_i, a_j\rangle v_j, so ∣vi∣≤μ(∥v∥1−∣vi∣)|v_i| \le \mu(\|v\|_1 - |v_i|) and ∣vi∣≤μ1+μ∥v∥1|v_i| \le \frac{\mu}{1 + \mu}\|v\|_1. Hence θs≤sμ1+μ\theta_s \le \frac{s\mu}{1 + \mu}, which is below 12\tfrac12 when (2s−1)μ<1(2s - 1)\mu < 1, the classical coherence condition. In the Hadamard example μ=12\mu = \tfrac12, the bound gives θ1≤13\theta_1 \le \tfrac13, and the exact value is 13\tfrac13.

Restricted isometry implies the property. By the theorem above, every condition on δ2s\delta_{2s} that gives exact recovery of all ss-sparse vectors by basis pursuit implies the null space property of order ss. Cai and Zhang (2014) proved that δ2s<1/2\delta_{2s} < 1/\sqrt2 is enough, and that the constant cannot be improved. The converse is false: the property is invariant under A↦GAA \mapsto GA, and a badly conditioned GG 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 2s2s nonzero entries, then some ss of them carry at least half of its mass, and the property of order ss fails. So the property of order ss needs spark⁡(A)>2s\operatorname{spark}(A) > 2s, and therefore m≥2sm \ge 2s.

  • Restricted isometry property. A condition on all 2s2s-column submatrices. It implies the null space property and also stability under noise, and random matrices with mm of order slog⁡(n/s)s\log(n/s) have it.
  • Mutual coherence. A cheap sufficient condition, (2s−1)μ<1(2s - 1)\mu < 1.
  • Spark. The least number of dependent columns. spark⁡(A)>2s\operatorname{spark}(A) > 2s 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 ss holds if and only if the image AB1nAB_1^n of the ℓ1\ell_1 ball, a convex polytope, is centrally ss-neighborly: every set of ss 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 ss-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.

null_space_property.pyI0RawGitHub
# 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

  1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. 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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/PPTQNH/text.yaml