Time-frequency dictionaries, Alltop sequence, basis pursuit and OMP for compressed sensing radar
DefinitionCompressedSensingRadar_BasicObjects of Sections II-III and Appendix A of Herman and Strohmer (2008).
- Vectors. On , , and . is the number of nonzero coefficients of , and is -sparse if .
- Dictionaries. A dictionary is a matrix with atoms . Its coherence is . Its atoms are unit-norm if for all . is the spectral norm. For , is the subdictionary of the columns in . The statement means for every .
- Basis pursuit (eq. 5). solves BP for the data if and whenever . BP recovers from if is its unique solution. In the noise-aware program of footnote 1, minimises subject to for every .
- Orthogonal matching pursuit. A run of steps on starts from . At step it selects an index maximising , with ties broken arbitrarily. Then is any minimiser of among the supported on . OMP recovers if every run of steps on ends at .
- Time-frequency shifts (eq. 10). . is the cyclic unit shift ( iff ) and . For , , and for a coefficient vector . .
- Gabor dictionary (eqs. 7, 8, 11). For a probe , has atoms . The block atoms are the columns of , .
- Alltop sequence (eq. 12). , . is the Gabor dictionary of .
- Random signals (Section III-E). The nonzero coefficients of a random signal are independent circularly symmetric complex Gaussians of mean and variance : real and imaginary parts are independent . For a fixed support , the probability that BP recovers from is computed with supported on . For a random -sparse signal the support is moreover a uniformly random -subset. For a random -column subdictionary, the probability is the fraction of -subsets with .
Formalization Note Indices run over and as in the paper. The coherence of a dictionary with fewer than two atoms is . A probability of an event is the Gaussian measure of the set of coefficient values for which holds.
import Mathlib
/-!
Herman and Strohmer, *High-Resolution Radar via Compressed Sensing*, arXiv:0803.2257v2 (2008),
IEEE Trans. Signal Process. 57(6) (2009): sparse vectors, basis pursuit and orthogonal matching
pursuit (Section II and the cited Tropp 2004), the coherence of a dictionary (Section III-B), the
time-frequency shift basis and its Gabor dictionary (Section III-C), the Alltop sequence
(Section III-D), and the random signal and random subdictionary models of Section III-E and
Appendix A.
-/
open MeasureTheory ProbabilityTheory
noncomputable section
namespace CompressedSensingRadar
section Vectors
variable {ι : Type*} [Fintype ι]
/-- The Hermitian inner product `⟨x, y⟩ = ∑ₙ conj(xₙ) yₙ` on `ℂ^ι` (Section III-B). -/
def ip (x y : ι → ℂ) : ℂ := ∑ n, star (x n) * y n
/-- The Euclidean norm `‖x‖₂ = (∑ₙ |xₙ|²)^{1/2}`. -/
def norm2 (x : ι → ℂ) : ℝ := Real.sqrt (∑ n, ‖x n‖ ^ 2)
/-- The `ℓ¹` norm `‖x‖₁ = ∑ₙ |xₙ|`, the objective of basis pursuit, eq. (5). -/
def norm1 (x : ι → ℂ) : ℝ := ∑ n, ‖x n‖
/-- The number of nonzero coefficients of `s`. -/
def suppCard (s : ι → ℂ) : ℕ := {i | s i ≠ 0}.ncard
/-- Section II: `s` is `K`-sparse if at most `K` of its coefficients are nonzero. -/
def IsSparse (K : ℕ) (s : ι → ℂ) : Prop := suppCard s ≤ K
end Vectors
section Dictionaries
variable {m ι : Type*} [Fintype m] [Fintype ι]
/-- The `i`-th atom (column) `φᵢ` of a dictionary `Φ = (φ₀ | ⋯ | φ_{M-1})`. -/
def atom (Φ : Matrix m ι ℂ) (i : ι) : m → ℂ := fun p => Φ p i
/-- Section III-B: the atoms of `Φ` have unit norm, `‖φᵢ‖₂ = 1`, the standing assumption under
which the coherence is used. -/
def HasUnitAtoms (Φ : Matrix m ι ℂ) : Prop := ∀ i, norm2 (atom Φ i) = 1
/-- Section III-B: the coherence `μ(Φ) = max_{i ≠ i'} |⟨φᵢ, φᵢ'⟩|` (this is `0` if `Φ` has fewer
than two atoms). -/
def coherence (Φ : Matrix m ι ℂ) : ℝ :=
⨆ (i : ι) (i' : ι) (_ : i ≠ i'), ‖ip (atom Φ i) (atom Φ i')‖
/-- The spectral norm `‖A‖ = max_{‖v‖₂ ≤ 1} ‖Av‖₂` (Appendix A, Proposition 1). -/
def specNorm {k : Type*} [Fintype k] (A : Matrix m k ℂ) : ℝ :=
sSup ((fun v => norm2 (A.mulVec v)) '' {v | norm2 v ≤ 1})
/-- Appendix A, Proposition 2: the least singular value of `A` is at least `c`, i.e.
`c ‖v‖₂ ≤ ‖Av‖₂` for every `v`. -/
def LeastSingValGe {k : Type*} [Fintype k] (A : Matrix m k ℂ) (c : ℝ) : Prop :=
∀ v : k → ℂ, c * norm2 v ≤ norm2 (A.mulVec v)
/-- Appendix A: the subdictionary `Φ_T` of the columns `φⱼ`, `j ∈ T`. -/
def subdict (Φ : Matrix m ι ℂ) (T : Finset ι) : Matrix m T ℂ := fun p j => Φ p j
/-- Appendix A, Proposition 1: the Gram matrix `X* X` of the subdictionary `X = Φ_T`. -/
def subGram (Φ : Matrix m ι ℂ) (T : Finset ι) : Matrix T T ℂ :=
(subdict Φ T).conjTranspose * subdict Φ T
/-- Eq. (5): `s` solves basis pursuit `min ‖s'‖₁ s.t. Φ s' = y`. -/
def IsBPSolution (Φ : Matrix m ι ℂ) (y : m → ℂ) (s : ι → ℂ) : Prop :=
Φ.mulVec s = y ∧ ∀ s' : ι → ℂ, Φ.mulVec s' = y → norm1 s ≤ norm1 s'
/-- Basis pursuit recovers `s` from the observation `y`: `s` is the unique solution of eq. (5). -/
def BPRecovers (Φ : Matrix m ι ℂ) (y : m → ℂ) (s : ι → ℂ) : Prop :=
∀ s' : ι → ℂ, IsBPSolution Φ y s' ↔ s' = s
/-- Footnote 1 of Section II: `s` solves the noise-aware basis pursuit
`min ‖s'‖₁ s.t. |(Φ s' - y)ₙ| ≤ ε` for every `n`. -/
def IsNoisyBPSolution (Φ : Matrix m ι ℂ) (y : m → ℂ) (ε : ℝ) (s : ι → ℂ) : Prop :=
(∀ n, ‖(Φ.mulVec s - y) n‖ ≤ ε) ∧
∀ s' : ι → ℂ, (∀ n, ‖(Φ.mulVec s' - y) n‖ ≤ ε) → norm1 s ≤ norm1 s'
/-- Orthogonal matching pursuit (Section II; Tropp 2004, Algorithm 3), run for `t` steps on `y`:
`x 0 = 0`; at step `k < t` the index `lam k` maximises `|⟨φⱼ, y - Φ x_k⟩|` over all `j` (any
choice among ties), and `x (k+1)` minimises `‖y - Φ x‖₂` over the `x` supported on
`{lam 0, …, lam k}` (any minimiser). -/
def IsOMPRun (Φ : Matrix m ι ℂ) (y : m → ℂ) (t : ℕ) (lam : ℕ → ι) (x : ℕ → ι → ℂ) : Prop :=
x 0 = 0 ∧ ∀ k < t,
(∀ j, ‖ip (atom Φ j) (y - Φ.mulVec (x k))‖ ≤ ‖ip (atom Φ (lam k)) (y - Φ.mulVec (x k))‖) ∧
(∀ i, (∀ l ≤ k, lam l ≠ i) → x (k + 1) i = 0) ∧
(∀ x' : ι → ℂ, (∀ i, (∀ l ≤ k, lam l ≠ i) → x' i = 0) →
norm2 (y - Φ.mulVec (x (k + 1))) ≤ norm2 (y - Φ.mulVec x'))
/-- Orthogonal matching pursuit recovers `s` from `y`: every run of `‖s‖₀` steps (the number of
nonzero coefficients of `s`) ends at `s`. -/
def OMPRecovers (Φ : Matrix m ι ℂ) (y : m → ℂ) (s : ι → ℂ) : Prop :=
∀ (lam : ℕ → ι) (x : ℕ → ι → ℂ), IsOMPRun Φ y (suppCard s) lam x → x (suppCard s) = s
end Dictionaries
section TimeFrequency
variable (N : ℕ)
/-- Section III-C: the `N`-th root of unity `ω_N = e^{2πi/N}`. -/
def omega : ℂ := Complex.exp (2 * Real.pi * Complex.I / N)
/-- Section III-C: the unit-shift operator `T`, `T_{p,q} = 1` if `p ≡ q + 1 (mod N)` and `0`
otherwise. -/
def shiftMat : Matrix (Fin N) (Fin N) ℂ :=
fun p q => if (p : ℕ) = ((q : ℕ) + 1) % N then 1 else 0
/-- Section III-C: the modulation operator `M = diag(ω_N^0, …, ω_N^{N-1})`. -/
def modMat : Matrix (Fin N) (Fin N) ℂ := Matrix.diagonal fun p => omega N ^ (p : ℕ)
/-- Eq. (10): the `i`-th time-frequency shift `Hᵢ = M^{i mod N} T^{⌊i/N⌋}`, `0 ≤ i < N²`. -/
def tfShift (i : Fin (N ^ 2)) : Matrix (Fin N) (Fin N) ℂ :=
modMat N ^ ((i : ℕ) % N) * shiftMat N ^ ((i : ℕ) / N)
/-- Eq. (6): the matrix `H = ∑ᵢ sᵢ Hᵢ` with coefficient vector `s ∈ ℂ^{N²}`. -/
def tfSynth (s : Fin (N ^ 2) → ℂ) : Matrix (Fin N) (Fin N) ℂ := ∑ i, s i • tfShift N i
/-- Section III-A: the Frobenius inner product `⟨A, B⟩_F = trace(A* B)`. -/
def frobIp (A B : Matrix (Fin N) (Fin N) ℂ) : ℂ := (A.conjTranspose * B).trace
/-- Eqs. (7)-(8): the Gabor dictionary `Φ = (φ₀ | ⋯ | φ_{N²-1}) ∈ ℂ^{N×N²}` generated by the
probe `f`, with atoms `φᵢ = Hᵢ f`. -/
def gaborDict (f : Fin N → ℂ) : Matrix (Fin N) (Fin (N ^ 2)) ℂ :=
fun p i => (tfShift N i).mulVec f p
/-- Eq. (11): the `j`-th column `φⱼ^{(k)}` of the block `Φ^{(k)} = D_k W_N`, where
`D_k = diag(f_k, …, f_{N-1}, f_0, …, f_{k-1})` and `W_N = (ω_N^{pq})`; its `p`-th entry is
`f_{(p+k) mod N} ω_N^{pj}`. -/
def blockAtom (f : Fin N → ℂ) (k j : Fin N) : Fin N → ℂ :=
fun p => f (p + k) * omega N ^ ((p : ℕ) * (j : ℕ))
/-- Eq. (12): the Alltop sequence `fₙ = N^{-1/2} e^{2πi n³/N}`, `n = 0, …, N-1`. -/
def alltop : Fin N → ℂ :=
fun n => ((Real.sqrt N)⁻¹ : ℂ) * Complex.exp (2 * Real.pi * Complex.I * ((n : ℕ) ^ 3 : ℂ) / N)
end TimeFrequency
section Random
variable {n M : ℕ}
/-- Section III-E: the law of the coefficients of a random signal. Coordinate `(i, 0)` is the real
part and `(i, 1)` the imaginary part of coefficient `i`; all are independent `N(0, 1/2)`, so each
coefficient is a circularly symmetric complex Gaussian of zero mean and unit variance. -/
def gaussCoeffs (M : ℕ) : Measure (Fin M × Fin 2 → ℝ) :=
Measure.pi fun _ => gaussianReal 0 2⁻¹
/-- Section III-E: the signal with support `T` whose coefficients on `T` are given by `w`. -/
def maskedSignal (T : Finset (Fin M)) (w : Fin M × Fin 2 → ℝ) : Fin M → ℂ :=
fun i => if i ∈ T then (w (i, 0) : ℂ) + (w (i, 1) : ℂ) * Complex.I else 0
/-- Appendix A, Proposition 2: the probability that basis pursuit recovers a random signal `s`
with fixed support `T` (independent standard complex Gaussian coefficients on `T`) from
`y = Φ s`. -/
def bpProbOnSupport (Φ : Matrix (Fin n) (Fin M) ℂ) (T : Finset (Fin M)) : ℝ :=
(gaussCoeffs M).real {w | BPRecovers Φ (Φ.mulVec (maskedSignal T w)) (maskedSignal T w)}
/-- Section III-E: the probability that basis pursuit recovers a random `K`-sparse signal `s`
from `y = Φ s`. The support is a uniformly random `K`-subset of the `M` indices and the nonzero
coefficients are independent standard complex Gaussians. -/
def bpProbRandom (Φ : Matrix (Fin n) (Fin M) ℂ) (K : ℕ) : ℝ :=
(∑ T ∈ (Finset.univ : Finset (Fin M)).powersetCard K, bpProbOnSupport Φ T) /
((Finset.univ : Finset (Fin M)).powersetCard K).card
open Classical in
/-- Appendix A, Proposition 1: for a random `K`-column subdictionary `X = Φ_T` (every `K`-subset
`T` equally likely), the probability `P{‖X* X - I‖ ≥ δ}`. -/
def illCondProb (Φ : Matrix (Fin n) (Fin M) ℂ) (K : ℕ) (δ : ℝ) : ℝ :=
(((Finset.univ : Finset (Fin M)).powersetCard K).filter
fun T => δ ≤ specNorm (subGram Φ T - 1)).card /
((Finset.univ : Finset (Fin M)).powersetCard K).card
end Random
end CompressedSensingRadar
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
The file sets up ambient data used by every declaration below. Here , and denote arbitrary finite index sets, possibly empty. Vectors are complex-valued functions on such an index set, and matrices have rows indexed by and columns indexed by . Throughout, , , , are natural numbers, and is allowed.
Inner product (ip). For ,
It is conjugate-linear in the first argument. If it equals .
Euclidean norm (norm2). For ,
norm (norm1). For ,
Support size (suppCard). For , is the number of indices with , a natural number.
Sparsity (IsSparse). " is -sparse" means , that is, at most coefficients are nonzero. The zero vector is -sparse for every , including .
Atom (atom). For and , is the -th column of , with entries .
Unit atoms (HasUnitAtoms). has unit atoms if for every column index . This holds vacuously if is empty. It can never hold if is nonempty and is empty, since then every column has norm .
Coherence (coherence). The coherence is a real number , defined as an iterated supremum of over pairs . Pairs with contribute the supremum of an empty family, which is taken to be . Since all the terms are , the result is
when has at least two columns, and when it has at most one column. Unit-norm columns are not assumed in this definition.
Spectral norm (specNorm). For , is the supremum of over all with . This set is bounded, so the supremum is a genuine maximum. If the only vector is , and the value is .
Least singular value bound (LeastSingValGe). For and real , the statement is
It holds trivially for every when .
Subdictionary (subdict). For a finite set of column indices, is the matrix whose columns are for , indexed by the elements of .
Sub-Gram matrix (subGram). This is the matrix , where is the conjugate transpose. Its entry is .
Basis pursuit solution (IsBPSolution). is a basis pursuit solution for , with , if both of the following hold:
- ;
- for every with .
In other words, is a minimiser of over the affine set . It need not be the unique minimiser.
Basis pursuit recovery (BPRecovers). For every , is a basis pursuit solution for if and only if . Equivalently, is the unique -minimiser subject to . Two consequences:
- This forces , so the statement is false whenever .
- No sparsity of is assumed.
Noise-aware basis pursuit solution (IsNoisyBPSolution). For real , is a solution if both of the following hold:
- for every row index ;
- for every satisfying the same entrywise bound.
The constraint is entrywise, i.e. an bound on the residual, not an bound. If no vector is feasible (unless ), so no solution exists.
OMP run (IsOMPRun). The data are:
- an integer ;
- an index sequence ;
- a vector sequence .
These form a -step OMP run on if and, for every , all three of the following hold:
- maximises the correlation with the current residual:
Ties may be broken arbitrarily. 2. vanishes outside . 3. for every that vanishes outside . Any minimiser is allowed.
The definition also leaves several things open:
- The indices are not required to be distinct.
- The atoms are not required to be normalised.
- for and for are unconstrained.
- If , the only condition is .
OMP recovery (OMPRecovers). Let . For every -step OMP run on , the final iterate satisfies . Some consequences:
- is an arbitrary vector, not tied to .
- If then , and the statement reduces to , which always holds.
- If there are no index sequences at all, so the statement holds vacuously.
Root of unity (omega). . When the division by zero evaluates to , so .
Cyclic shift (shiftMat). , with indices . Its entries are if and otherwise. For the matrix is empty.
Modulation (modMat). .
Time-frequency shift (tfShift). For ,
Time-frequency synthesis (tfSynth). For ,
Frobenius inner product (frobIp). For complex matrices ,
Gabor dictionary (gaborDict). For a probe , is the matrix whose -th column is . No normalisation of is assumed.
Block atom (blockAtom). For and , the vector has entries
The exponent is the ordinary integer product, not reduced mod .
Alltop sequence (alltop). For ,
The cube is taken as an integer and is not reduced mod . No assumption that is prime, or , is made.
Gaussian coefficients (gaussCoeffs). This is a probability measure on , i.e. on real arrays . It is the product of independent real Gaussians, each with mean and variance . Here is intended as the real part and as the imaginary part of coefficient .
Masked signal (maskedSignal). For and , is given by
The coordinates of outside are ignored.
Recovery probability on a fixed support (bpProbOnSupport). For and , this is the real number obtained by applying the Gaussian measure above to the set of such that basis pursuit recovers from , where is the masked signal of . Recovery means that is the unique -minimiser subject to . Measurability of this set is not asserted; if it failed, the value would be its outer measure.
Recovery probability for a random sparse signal (bpProbRandom). This is the arithmetic mean of the fixed-support recovery probability over all -element subsets :
If there are no such subsets, and the value is .
Ill-conditioning probability (illCondProb). For , and real , this is the fraction of -element subsets satisfying
where the norm is the spectral norm and is the identity. The inequality is non-strict. Edge cases:
- If the value is .
- If the only subset is , the spectral norm is , and the value is if and otherwise.
- Unit-norm columns are not assumed.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.