Baseline and closure operators, pseudo phases, myopic criterion and polar noise components
DefinitionArxiv0812_1178_BasicObjects of Sections 2-3 and Appendices A, C and E of Meimon, Mugnier and Le Besnerais (2008).
- Array and baselines. A complete non-redundant array has telescopes . Its baselines are the pairs with . The canonical closure phases are indexed by the pairs with .
- Closure phases (eq. 10). For phases on ordered pairs of telescopes, . The canonical closures are , .
- Baseline operator (eqs. 37-38). is the matrix with . is with its first column (telescope ) removed, an matrix.
- Closure operator (eq. 39). , the matrix with for . Its generalized inverse is .
- Object phases (eq. 5). For object coefficients and a complex Fourier matrix , componentwise.
- Pseudo phases (eqs. 24-25). and for an integer vector .
- Myopic model and criterion (eqs. 34-35). (componentwise) with . With , the statistic is . The criterion is over finitely many instants .
- Polar noise (eqs. 52-54). For and , set , and , componentwise.
Formalization Note Telescope is index of . and are written entrywise with rows and columns indexed by pairs of telescopes, not by the recursive block layout of eqs. (37)-(39). The two coincide once baselines are ordered lexicographically (); this was checked for . Phases are real numbers; "modulo " is written as "up to times an integer vector". is Mathlib's matrix inverse, which is the true inverse because is invertible.
import Mathlib
/-!
Meimon, Mugnier and Le Besnerais, *A self-calibration approach for optical long baseline
interferometry imaging*, arXiv:0812.1178v1 (2008): the baselines and closure phases of a complete
array (Sec. 2.A, 2.C), the baseline and closure operators `B`, `C` (Appendix A), the generalized
inverse `C†` and the pseudo-phase data (Sec. 3.B), the myopic model and goodness-of-fit criterion
(Sec. 3.C, eqs. (34)-(35)), and the radial and tangential noise components of a polar Gaussian
model (Appendix E.A, eqs. (52)-(54)).
Telescopes `T_1, …, T_{N_t}` are indexed by `Fin n`, with `T_1` the index `0`.
-/
open Matrix
noncomputable section
namespace Arxiv0812_1178
/-- Sec. 2.A, eq. (4): the `N_b = N_t(N_t-1)/2` baselines `(k,l)`, `k < l`, of a complete
non-redundant array of `n` telescopes. -/
abbrev Baseline (n : ℕ) := {p : Fin n × Fin n // p.1 < p.2}
/-- Sec. 2.C: index set of the canonical closure phases `β_{1kl}`, `1 < k < l` (pairs `(k,l)` of
telescopes other than `T_1`, which is the index `0`). -/
abbrev ClosureIdx (n : ℕ) := {p : Fin n × Fin n // 0 < p.1.1 ∧ p.1 < p.2}
/-- Appendix A, eqs. (37)-(38): the `N_b × N_t` baseline operator `B`, with
`(B ϖ)_{kl} = ϖ_l - ϖ_k` (eqs. (6)-(7)). Rows are indexed by baselines rather than by the recursive
block layout of eq. (38); the two agree after ordering baselines lexicographically. -/
def baselineOp (n : ℕ) : Matrix (Baseline n) (Fin n) ℝ :=
fun b j => (if j = b.1.2 then 1 else 0) - (if j = b.1.1 then 1 else 0)
/-- Appendix C: `B̄`, the baseline operator with its first column (telescope `T_1`) removed;
column `j` of `B̄` is column `j + 1` of `B`. -/
def baselineOpBar (n : ℕ) : Matrix (Baseline n) (Fin (n - 1)) ℝ :=
fun b j => baselineOp n b ⟨j.1 + 1, by have := j.2; omega⟩
/-- Appendix A, eq. (39) and Sec. 2.C: the closure operator `C = [-B_{N_t-1} | Id]`, written by
rows: `(C φ)_{kl} = φ_{1k} + φ_{kl} - φ_{1l}` for `1 < k < l`. -/
def closureOp (n : ℕ) : Matrix (ClosureIdx n) (Baseline n) ℝ :=
fun c b =>
(if b.1.1.1 = 0 ∧ b.1.2 = c.1.1 then 1 else 0) + (if b.1 = c.1 then 1 else 0) -
(if b.1.1.1 = 0 ∧ b.1.2 = c.1.2 then 1 else 0)
/-- Sec. 3.B and Appendix B: the generalized inverse `C† = Cᵀ (C Cᵀ)⁻¹`. -/
def closurePinv (n : ℕ) : Matrix (Baseline n) (ClosureIdx n) ℝ :=
(closureOp n)ᵀ * (closureOp n * (closureOp n)ᵀ)⁻¹
/-- Sec. 2.C, eq. (10): the three-telescope closure phase `β_{klm} = φ_{kl} + φ_{lm} + φ_{mk}` of
a family of phases `φ_{kl}` indexed by ordered pairs of telescopes. -/
def closurePhase {n : ℕ} (φ : Fin n → Fin n → ℝ) (k l m : Fin n) : ℝ :=
φ k l + φ l m + φ m k
/-- Sec. 2.C: the canonical closure phases `β_{1kl}`, `1 < k < l`, grouped in a vector. -/
def canonicalClosure {n : ℕ} (φ : Fin n → Fin n → ℝ) (c : ClosureIdx n) : ℝ :=
closurePhase φ ⟨0, lt_of_le_of_lt (Nat.zero_le _) c.1.1.2⟩ c.1.1 c.1.2
/-- Sec. 2.A: the vector `(φ_{kl})_{k<l}` of the baseline phases. -/
def baselineVec {n : ℕ} (φ : Fin n → Fin n → ℝ) : Baseline n → ℝ :=
fun b => φ b.1.1 b.1.2
/-- Sec. 2.A, eq. (5): the object visibility phases `φ(x,t) = arg(H(t) x)` for the discretized
object `x` (real coefficients) and the discrete-continuous Fourier matrix `H(t)`. -/
def objPhase {n : ℕ} {P : Type*} [Fintype P] (H : Matrix (Baseline n) P ℂ) (x : P → ℝ) :
Baseline n → ℝ :=
fun b => Complex.arg ((H *ᵥ fun p => (x p : ℂ)) b)
/-- Sec. 3.B, eq. (24): the pseudo visibility phase data `φ^data(t) = C† β^data(t)`. -/
def pseudoPhase (n : ℕ) (βdata : ClosureIdx n → ℝ) : Baseline n → ℝ :=
closurePinv n *ᵥ βdata
/-- Sec. 3.B, eq. (25): `φ^ker(t) = (C† C - Id) φ(x,t) + 2π C† κ`, for the integer vector `κ`
produced by the `2π` wrapping of the closure phases. -/
def kerPhase (n : ℕ) (φ : Baseline n → ℝ) (κ : ClosureIdx n → ℤ) : Baseline n → ℝ :=
(closurePinv n * closureOp n - 1) *ᵥ φ + closurePinv n *ᵥ (fun c => 2 * Real.pi * κ c)
/-- Sec. 3.C, eq. (34): the myopic model `y_m(x, α(t)) = H(t) x · exp(i B̄ α(t))`
(componentwise product), with `α(t) ∈ ℝ^{N_t-1}` the phase aberrations. -/
def myopicModel {n : ℕ} {P : Type*} [Fintype P] (H : Matrix (Baseline n) P ℂ) (x : P → ℝ)
(α : Fin (n - 1) → ℝ) : Baseline n → ℂ :=
fun b => (H *ᵥ fun p => (x p : ℂ)) b *
Complex.exp (Complex.I * ((baselineOpBar n *ᵥ α) b : ℂ))
/-- Sec. 3.C, display before eq. (35): the χ² statistic over the real and imaginary parts of
`y^data(t) - y_m - ȳ^noise(t)`, weighted by `R_{y^noise(t)}⁻¹`; the stacked real vector is
`[Re r; Im r]`, indexed by `Baseline n ⊕ Baseline n`. -/
def chi2 {n : ℕ} (ydata ybar : Baseline n → ℂ)
(R : Matrix (Baseline n ⊕ Baseline n) (Baseline n ⊕ Baseline n) ℝ) (ym : Baseline n → ℂ) :
ℝ :=
let r : Baseline n → ℂ := ydata - ym - ybar
let v : Baseline n ⊕ Baseline n → ℝ := Sum.elim (fun b => (r b).re) (fun b => (r b).im)
v ⬝ᵥ (R⁻¹ *ᵥ v)
/-- Sec. 3.C, eq. (35): the myopic goodness-of-fit criterion
`J^data(x, α) = ∑_t χ²_{y(t)}(x, α(t))` over the finite set `T` of measurement instants, for the
pseudo complex visibilities `y^data(t)`, noise means `ȳ^noise(t)` and noise covariances
`R_{y^noise(t)}`. -/
def myopicCrit {n : ℕ} {T P : Type*} [Fintype T] [Fintype P]
(H : T → Matrix (Baseline n) P ℂ) (ydata ybar : T → Baseline n → ℂ)
(R : T → Matrix (Baseline n ⊕ Baseline n) (Baseline n ⊕ Baseline n) ℝ)
(x : P → ℝ) (α : T → Fin (n - 1) → ℝ) : ℝ :=
∑ t, chi2 (ydata t) (ybar t) (R t) (myopicModel (H t) x (α t))
/-- Appendix E.A, eqs. (52)-(54): for polar data `a^data = ā + a^noise`, `φ^data = φ̄ + φ^noise`,
the complex noise `y^noise = a^data e^{i φ^data} - ā e^{i φ̄}` (componentwise). -/
def polarNoise {ι : Type*} (abar phibar anoise phinoise : ι → ℝ) (i : ι) : ℂ :=
((abar i + anoise i : ℝ) : ℂ) * Complex.exp (Complex.I * ((phibar i + phinoise i : ℝ) : ℂ)) -
(abar i : ℂ) * Complex.exp (Complex.I * (phibar i : ℂ))
/-- Appendix E.A, eq. (54): the radial component `y^n_rad = Re(y^noise e^{-i φ̄})`. -/
def radNoise {ι : Type*} (abar phibar anoise phinoise : ι → ℝ) (i : ι) : ℝ :=
(polarNoise abar phibar anoise phinoise i * Complex.exp (-(Complex.I * (phibar i : ℂ)))).re
/-- Appendix E.A, eq. (54): the tangential component `y^n_tan = Im(y^noise e^{-i φ̄})`. -/
def tanNoise {ι : Type*} (abar phibar anoise phinoise : ι → ℝ) (i : ι) : ℝ :=
(polarNoise abar phibar anoise phinoise i * Complex.exp (-(Complex.I * (phibar i : ℂ)))).im
end Arxiv0812_1178
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Baseline n. For a natural number (the number of telescopes, indexed ), this is the set of ordered pairs of indices with strictly increasing entries:
It has elements. It is empty when or .
ClosureIdx n. For a natural number , this is the set of index pairs that avoid index and are strictly increasing:
It has elements and is a subset of . It is empty when .
baselineOp n (written ). This is the real matrix with rows indexed by and columns indexed by . Its entries are
where is if the condition holds and otherwise. Because , row has in column , in column , and elsewhere. Hence for any ,
When the matrix has no rows.
baselineOpBar n (written ). This is the real matrix with rows indexed by and columns indexed by . Here the number of columns is computed in the natural numbers, so it is when . The entries are
In other words, is with the column for index deleted, and column of corresponds to telescope . For , define . Then
closureOp n (written ). This is the real matrix with rows indexed by and columns indexed by . For a row with and a column with , the entry is
So for any ,
When the matrix has no rows.
closurePinv n (written ). This is the real matrix with rows indexed by and columns indexed by , defined by
The inverse follows the convention that a square matrix with determinant zero has "inverse" equal to the zero matrix; otherwise it is the true inverse. When , is the empty matrix and has no columns.
closurePhase (written ). The input is an arbitrary real-valued function of ordered pairs . No relation such as or is assumed. For any three indices , not necessarily distinct, the closure phase is
canonicalClosure. For an arbitrary function on ordered pairs as above, this is the vector indexed by whose entries are
The last term is , the value at the reversed pair. It is not .
baselineVec. For an arbitrary function on ordered pairs, this is the vector in obtained by restricting to increasing pairs:
objPhase (written ). The inputs are:
- an arbitrary finite index set ;
- an arbitrary complex matrix with rows indexed by and columns indexed by ;
- a real vector , regarded as complex.
The output is the vector in given by
Here is the principal argument with values in , with the convention .
pseudoPhase. For a real vector , this is the vector
with as defined above.
kerPhase. The inputs are a real vector and an integer vector . The output is
where is the identity matrix on . No relation between and is imposed.
myopicModel (written ). The inputs are:
- a finite index set ;
- a complex matrix with rows indexed by and columns indexed by ;
- a real vector ;
- a real vector , with computed in the natural numbers.
The output is the complex vector indexed by given componentwise by
Explicitly,
chi2 (written ). The inputs are:
- complex vectors ;
- an arbitrary real square matrix indexed by two disjoint copies of . No symmetry, positive-definiteness, or invertibility is assumed.
Form the residual and the stacked real vector . Then
If , then is taken to be the zero matrix, and so regardless of the data.
myopicCrit (written ). The inputs are:
- an arbitrary finite set and a finite set ;
- for each , a complex matrix (rows , columns );
- for each , complex vectors ;
- for each , a real square matrix indexed by two copies of ;
- a single real vector , shared across all ;
- for each , a vector .
The criterion is
with as defined above, including the zero-inverse convention for singular . When is empty, .
polarNoise (written ). The inputs are an arbitrary index type and four arbitrary real families on . No sign or range restrictions are imposed, so amplitudes may be negative. For each ,
radNoise. With the same inputs as polarNoise, for each ,
This equals .
tanNoise. With the same inputs as polarNoise, for each ,
This equals .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.