Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Nonlinear ICA with auxiliary variables: model, contrastive logistic loss, Assumption of Variability, conditional exponentiality

Definition
NonlinearICAAux_Basic

by Xeroth · Nov 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

contrastive-learningexponential-familyidentifiabilitynonlinear-ica

Objects of Sections 3 and 4 and Supplementary A-D of Hyvärinen, Sasaki and Turner (2019).

  1. Model (eqs. 1, 4). An auxiliary variable u∈Rm\mathbf u\in\mathbb R^mu∈Rm has a probability law μ\muμ. Given u\mathbf uu, the sources s∈Rn\mathbf s\in\mathbb R^ns∈Rn have the density p(s∣u)=exp⁡∑i=1nqi(si,u)p(\mathbf s\mid\mathbf u)=\exp\sum_{i=1}^n q_i(s_i,\mathbf u)p(s∣u)=exp∑i=1n​qi​(si​,u), so they are conditionally independent; the qiq_iqi​ are jointly measurable and ∫p(s∣u) ds=1\int p(\mathbf s\mid\mathbf u)\,d\mathbf s=1∫p(s∣u)ds=1 for every u\mathbf uu. The observation is x=f(s)\mathbf x=\mathbf f(\mathbf s)x=f(s), where f:Rn→Rn\mathbf f:\mathbb R^n\to\mathbb R^nf:Rn→Rn is invertible and both f\mathbf ff and g=f−1\mathbf g=\mathbf f^{-1}g=f−1 have continuous second derivatives (a C2C^2C2 diffeomorphism). The marginal source density ps(s)=∫p(s∣u) dμ(u)p_{\mathbf s}(\mathbf s)=\int p(\mathbf s\mid\mathbf u)\,d\mu(\mathbf u)ps​(s)=∫p(s∣u)dμ(u) is required to be a finite integral at every s\mathbf ss.
  2. Densities of the two classes (eq. 5). p(x∣u)=p(g(x)∣u) ∣det⁡Jg(x)∣p(\mathbf x\mid\mathbf u)=p(\mathbf g(\mathbf x)\mid\mathbf u)\,|\det J\mathbf g(\mathbf x)|p(x∣u)=p(g(x)∣u)∣detJg(x)∣ is the density of x~=(x,u)\tilde{\mathbf x}=(\mathbf x,\mathbf u)x~=(x,u), and p(x)=ps(g(x)) ∣det⁡Jg(x)∣p(\mathbf x)=p_{\mathbf s}(\mathbf g(\mathbf x))\,|\det J\mathbf g(\mathbf x)|p(x)=ps​(g(x))∣detJg(x)∣ is the density of x~∗=(x,u∗)\tilde{\mathbf x}^*=(\mathbf x,\mathbf u^*)x~∗=(x,u∗) with u∗\mathbf u^*u∗ independent of x\mathbf xx, both with respect to Lebesgue measure times μ\muμ. The log-density ratio is log⁡p(x∣u)−log⁡p(x)\log p(\mathbf x\mid\mathbf u)-\log p(\mathbf x)logp(x∣u)−logp(x).
  3. Logistic regression (eqs. 5, 6). The population logistic loss of a regression function r(x,u)r(\mathbf x,\mathbf u)r(x,u) is Ex~log⁡(1+e−r)+Ex~∗log⁡(1+er)∈[0,∞]\mathbb E_{\tilde{\mathbf x}}\log(1+e^{-r})+\mathbb E_{\tilde{\mathbf x}^*}\log(1+e^{r})\in[0,\infty]Ex~​log(1+e−r)+Ex~∗​log(1+er)∈[0,∞]. The constrained regression function of eq. (6) is r(x,u)=∑iψi(hi(x),u)r(\mathbf x,\mathbf u)=\sum_i\psi_i(h_i(\mathbf x),\mathbf u)r(x,u)=∑i​ψi​(hi​(x),u).
  4. Assumption of Variability (eqs. 8, 9). w(y,u)=(∂y1q1(y1,u),…,∂ynqn(yn,u),∂y12q1(y1,u),…,∂yn2qn(yn,u))∈R2n\mathbf w(\mathbf y,\mathbf u)=\big(\partial_{y_1}q_1(y_1,\mathbf u),\dots,\partial_{y_n}q_n(y_n,\mathbf u),\partial^2_{y_1}q_1(y_1,\mathbf u),\dots,\partial^2_{y_n}q_n(y_n,\mathbf u)\big)\in\mathbb R^{2n}w(y,u)=(∂y1​​q1​(y1​,u),…,∂yn​​qn​(yn​,u),∂y1​2​q1​(y1​,u),…,∂yn​2​qn​(yn​,u))∈R2n. The assumption holds if for every y∈Rn\mathbf y\in\mathbb R^ny∈Rn there are u0,…,u2n\mathbf u_0,\dots,\mathbf u_{2n}u0​,…,u2n​ with w(y,uj)−w(y,u0)\mathbf w(\mathbf y,\mathbf u_j)-\mathbf w(\mathbf y,\mathbf u_0)w(y,uj​)−w(y,u0​), j=1,…,2nj=1,\dots,2nj=1,…,2n, linearly independent.
  5. Alternative Assumption of Variability (eqs. 41, 42). w~(y,u)\tilde{\mathbf w}(\mathbf y,\mathbf u)w~(y,u) collects ∂2qi(yi,u)/∂yi∂uj\partial^2q_i(y_i,\mathbf u)/\partial y_i\partial u_j∂2qi​(yi​,u)/∂yi​∂uj​ and ∂3qi(yi,u)/∂yi2∂uj\partial^3q_i(y_i,\mathbf u)/\partial y_i^2\partial u_j∂3qi​(yi​,u)/∂yi2​∂uj​. The assumption holds if for every y\mathbf yy there are an index jjj and u1,…,u2n\mathbf u_1,\dots,\mathbf u_{2n}u1​,…,u2n​ with w~(y,ul)\tilde{\mathbf w}(\mathbf y,\mathbf u_l)w~(y,ul​) linearly independent.
  6. Conditional exponentiality (Definition 1, eq. 7). sis_isi​ is conditionally exponential of order kkk given u\mathbf uu if its conditional density p(si∣u)=eqi(si,u)/∫eqi(t,u)dtp(s_i\mid\mathbf u)=e^{q_i(s_i,\mathbf u)}/\int e^{q_i(t,\mathbf u)}dtp(si​∣u)=eqi​(si​,u)/∫eqi​(t,u)dt equals Qi(si)Zi(u)exp⁡∑j=1kq~ij(si)λij(u)\frac{Q_i(s_i)}{Z_i(\mathbf u)}\exp\sum_{j=1}^k\tilde q_{ij}(s_i)\lambda_{ij}(\mathbf u)Zi​(u)Qi​(si​)​exp∑j=1k​q~​ij​(si​)λij​(u) for all sis_isi​ and u\mathbf uu, with Qi,Zi>0Q_i,Z_i>0Qi​,Zi​>0 and q~i1,…,q~ik\tilde q_{i1},\dots,\tilde q_{ik}q~​i1​,…,q~​ik​ linearly independent functions.
  7. Objects of Theorem 3 (eqs. 10-12). λ(u)=(λij(u))(i,j)∈Rnk\boldsymbol\lambda(\mathbf u)=(\lambda_{ij}(\mathbf u))_{(i,j)}\in\mathbb R^{nk}λ(u)=(λij​(u))(i,j)​∈Rnk; q~(s)=(q~11(s1),…,q~nk(sn))\tilde{\mathbf q}(\mathbf s)=(\tilde q_{11}(s_1),\dots,\tilde q_{nk}(s_n))q~​(s)=(q~​11​(s1​),…,q~​nk​(sn​)); Lˉ\bar{\mathbf L}Lˉ is the nk×nknk\times nknk×nk matrix with entry λij(ul)−λij(u0)\lambda_{ij}(\mathbf u_l)-\lambda_{ij}(\mathbf u_0)λij​(ul​)−λij​(u0​) in row (i,j)(i,j)(i,j) and column lll; the regression function of eq. (11) is h~(x)Tv(u)+a(x)+b(u)\tilde{\mathbf h}(\mathbf x)^T\mathbf v(\mathbf u)+a(\mathbf x)+b(\mathbf u)h~(x)Tv(u)+a(x)+b(u).
  8. Partial derivatives. ∂jF(y)\partial_jF(\mathbf y)∂j​F(y) is the derivative of F:Rn→RF:\mathbb R^n\to\mathbb RF:Rn→R in the direction of the jjj-th basis vector.

Formalization Note The auxiliary variable is taken in Rm\mathbb R^mRm as in Section 3.1, and the conditional densities qi(⋅,u)q_i(\cdot,\mathbf u)qi​(⋅,u) are given for every u∈Rm\mathbf u\in\mathbb R^mu∈Rm; statements quantify over all u\mathbf uu rather than over the support of μ\muμ. The finiteness of psp_{\mathbf s}ps​ and the joint measurability of the qiq_iqi​ are implicit in the paper, which takes log⁡ps\log p_{\mathbf s}logps​ and expectations freely. The logistic loss is valued in [0,∞][0,\infty][0,∞] so that no non-integrable case is silently set to 000.

Definition code
import Mathlib

/-!
Hyvärinen, Sasaki and Turner, *Nonlinear ICA Using Auxiliary Variables and Generalized
Contrastive Learning*, arXiv:1805.08651v3 (AISTATS 2019): the nonlinear ICA model with auxiliary
variables (Section 3.1, eqs. (1), (4)), the contrastive logistic-regression problem (Section 3.2,
eqs. (5), (6)), the Assumption of Variability (Section 4.2, Theorem 1, eqs. (8), (9)) and its
alternative form (Supplementary D, eqs. (41), (42)), conditional exponentiality (Section 4.1,
Definition 1, eq. (7)) and the objects of Theorem 3 (Section 4.3, eqs. (10)-(12)).

Sources live in `ℝ^n = Fin n → ℝ`, the auxiliary variable in `ℝ^m = Fin m → ℝ`, and the
mixing `x = f(s)` is an equivalence of `ℝ^n` with `g = f⁻¹ = f.symm`.
-/

open MeasureTheory
open scoped ENNReal

noncomputable section

namespace NonlinearICAAux

variable {n m k : ℕ}

/-- Section 3.1 (p. 3): a map `ℝ^n → ℝ^n` that is invertible, has continuous second derivatives,
and whose inverse has continuous second derivatives. -/
def IsC2Diffeo (e : (Fin n → ℝ) ≃ (Fin n → ℝ)) : Prop :=
  ContDiff ℝ 2 e ∧ ContDiff ℝ 2 e.symm

/-- Eq. (4) (Section 3.1, p. 3): the conditional log-density of the sources,
`log p(s | u) = ∑ᵢ qᵢ(sᵢ, u)`. -/
def condLogDensityS (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (s : Fin n → ℝ) (u : Fin m → ℝ) : ℝ :=
  ∑ i, q i (s i) u

/-- Section 3.1, eqs. (1) and (4) (p. 3): the nonlinear ICA model with auxiliary variables. The
auxiliary variable `u ∈ ℝ^m` has law `μ`; given `u`, the sources `s ∈ ℝ^n` have the density
`exp (∑ᵢ qᵢ(sᵢ, u))` (integrable with integral `1` for every `u`); the observation is
`x = f(s)` with `f` a `C²` diffeomorphism. The `qᵢ` are jointly measurable, and the marginal
density of the sources, `p_s(s) = ∫ exp (∑ᵢ qᵢ(sᵢ, u)) dμ(u)`, is a finite integral at every `s`
(its logarithm is used in the proofs of Theorems 1 and 3, Supplementary A and C). -/
def IsAuxICAModel (μ : Measure (Fin m → ℝ)) (q : Fin n → ℝ → (Fin m → ℝ) → ℝ)
    (f : (Fin n → ℝ) ≃ (Fin n → ℝ)) : Prop :=
  IsC2Diffeo f ∧ (∀ i, Measurable (fun p : ℝ × (Fin m → ℝ) => q i p.1 p.2)) ∧
    (∀ u, Integrable (fun s => Real.exp (condLogDensityS q s u)) ∧
      ∫ s, Real.exp (condLogDensityS q s u) = 1) ∧
    (∀ s, Integrable (fun u => Real.exp (condLogDensityS q s u)) μ)

/-- Supplementary A (p. 11): the marginal density of the sources, `p_s(s) = ∫ p(s | u) dμ(u)`. -/
def margDensityS (μ : Measure (Fin m → ℝ)) (q : Fin n → ℝ → (Fin m → ℝ) → ℝ)
    (s : Fin n → ℝ) : ℝ :=
  ∫ u, Real.exp (condLogDensityS q s u) ∂μ

/-- Supplementary A (p. 11): the absolute Jacobian determinant `|det J g(x)|` of a map
`g : ℝ^n → ℝ^n`. -/
def absJacDet (g : (Fin n → ℝ) → (Fin n → ℝ)) (x : Fin n → ℝ) : ℝ :=
  |LinearMap.det ((fderiv ℝ g x : (Fin n → ℝ) →L[ℝ] (Fin n → ℝ)) :
    (Fin n → ℝ) →ₗ[ℝ] (Fin n → ℝ))|

/-- Supplementary A (p. 11): the conditional density of the observation given the auxiliary
variable, `p(x | u) = p(g(x) | u) |det J g(x)|` with `g = f⁻¹`; it is the density of the pair
`x̃ = (x, u)` of eq. (5) with respect to Lebesgue measure times the law of `u`. -/
def condDensityX (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (f : (Fin n → ℝ) ≃ (Fin n → ℝ))
    (x : Fin n → ℝ) (u : Fin m → ℝ) : ℝ :=
  Real.exp (condLogDensityS q (f.symm x) u) * absJacDet f.symm x

/-- Supplementary A (p. 11): the marginal density of the observation,
`p(x) = p_s(g(x)) |det J g(x)|`; it is the density of the pair `x̃* = (x, u*)` of eq. (5), with
`u*` independent of `x`, with respect to Lebesgue measure times the law of `u`. -/
def margDensityX (μ : Measure (Fin m → ℝ)) (q : Fin n → ℝ → (Fin m → ℝ) → ℝ)
    (f : (Fin n → ℝ) ≃ (Fin n → ℝ)) (x : Fin n → ℝ) : ℝ :=
  margDensityS μ q (f.symm x) * absJacDet f.symm x

/-- Supplementary A (p. 11): the difference of the log-densities of the two classes `x̃` and `x̃*`
of eq. (5), `log p(x, u) - log p(x) - log p(u) = log p(x | u) - log p(x)`. -/
def logRatio (μ : Measure (Fin m → ℝ)) (q : Fin n → ℝ → (Fin m → ℝ) → ℝ)
    (f : (Fin n → ℝ) ≃ (Fin n → ℝ)) (x : Fin n → ℝ) (u : Fin m → ℝ) : ℝ :=
  Real.log (condDensityX q f x u) - Real.log (margDensityX μ q f x)

/-- Section 3.2 (p. 3): the population logistic loss of a regression function `r(x, u)` that
discriminates `x̃ = (x, u)` (class 1, posterior `1 / (1 + exp (-r))`) from `x̃* = (x, u*)`
(class 0), the two classes having equal weight:
`E_{x̃} log (1 + e^{-r}) + E_{x̃*} log (1 + e^{r})`, valued in `[0, ∞]`. -/
def logisticLoss (μ : Measure (Fin m → ℝ)) (q : Fin n → ℝ → (Fin m → ℝ) → ℝ)
    (f : (Fin n → ℝ) ≃ (Fin n → ℝ)) (r : (Fin n → ℝ) × (Fin m → ℝ) → ℝ) : ℝ≥0∞ :=
  ∫⁻ p, (ENNReal.ofReal (Real.log (1 + Real.exp (-r p)) * condDensityX q f p.1 p.2) +
      ENNReal.ofReal (Real.log (1 + Real.exp (r p)) * margDensityX μ q f p.1))
    ∂((volume : Measure (Fin n → ℝ)).prod μ)

/-- Eq. (6) (Section 3.2, p. 3): the regression function `r(x, u) = ∑ᵢ ψᵢ(hᵢ(x), u)`. -/
def regFun (ψ : Fin n → ℝ → (Fin m → ℝ) → ℝ) (h : (Fin n → ℝ) → (Fin n → ℝ))
    (x : Fin n → ℝ) (u : Fin m → ℝ) : ℝ :=
  ∑ i, ψ i (h x i) u

/-- Eq. (9) (Theorem 1, p. 5): `w(y, u) ∈ ℝ^{2n}`, the first derivatives `∂qᵢ(yᵢ, u)/∂yᵢ`
(left block) followed by the second derivatives `∂²qᵢ(yᵢ, u)/∂yᵢ²` (right block). -/
def wVec (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (y : Fin n → ℝ) (u : Fin m → ℝ) :
    Fin n ⊕ Fin n → ℝ :=
  Sum.elim (fun i => deriv (fun s => q i s u) (y i))
    (fun i => iteratedDeriv 2 (fun s => q i s u) (y i))

/-- Theorem 1, Assumption 3, eq. (8) (p. 5), the Assumption of Variability: for every
`y ∈ ℝ^n` there are `2n + 1` values `u₀, …, u_{2n}` such that the `2n` vectors
`w(y, u_j) - w(y, u₀)`, `j = 1, …, 2n`, are linearly independent. -/
def Variability (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) : Prop :=
  ∀ y : Fin n → ℝ, ∃ u₀ : Fin m → ℝ, ∃ us : Fin (2 * n) → (Fin m → ℝ),
    LinearIndependent ℝ (fun j => wVec q y (us j) - wVec q y u₀)

/-- Eq. (42) (Supplementary D, p. 13): `w̃(y, u)`, the derivatives with respect to the
coordinate `u_j` of the entries of `w(y, u)`: `∂²qᵢ(yᵢ, u)/∂yᵢ∂u_j` (left block) and
`∂³qᵢ(yᵢ, u)/∂yᵢ²∂u_j` (right block). -/
def wAltVec (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (y : Fin n → ℝ) (u : Fin m → ℝ) (j : Fin m) :
    Fin n ⊕ Fin n → ℝ :=
  Sum.elim (fun i => fderiv ℝ (fun u' => deriv (fun s => q i s u') (y i)) u (Pi.single j 1))
    (fun i => fderiv ℝ (fun u' => iteratedDeriv 2 (fun s => q i s u') (y i)) u (Pi.single j 1))

/-- Supplementary D, eq. (41) (p. 13), the Alternative Assumption of Variability: for every
`y ∈ ℝ^n` there are an index `j` of the auxiliary variable and `2n` values `u₁, …, u_{2n}`
such that the vectors `w̃(y, u_l)` (derivatives in `u_j`) are linearly independent. -/
def AltVariability (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) : Prop :=
  ∀ y : Fin n → ℝ, ∃ j : Fin m, ∃ us : Fin (2 * n) → (Fin m → ℝ),
    LinearIndependent ℝ (fun l => wAltVec q y (us l) j)

/-- Definition 1 (p. 4): the conditional density `p(sᵢ | u)` of the single source `sᵢ` in the
model of eq. (4), `exp qᵢ(sᵢ, u) / ∫ exp qᵢ(t, u) dt`. -/
def condMarginal (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (i : Fin n) (u : Fin m → ℝ) (s : ℝ) : ℝ :=
  Real.exp (q i s u) / ∫ t, Real.exp (q i t u)

/-- Definition 1, eq. (7) (p. 4), with its data named: `sᵢ` is conditionally exponential of
order `k` given `u` with base `Qᵢ > 0`, normaliser `Zᵢ > 0`, linearly independent sufficient
statistics `q̃ᵢ₁, …, q̃ᵢₖ` and natural parameters `λᵢ₁(u), …, λᵢₖ(u)`:
`p(sᵢ | u) = Qᵢ(sᵢ) / Zᵢ(u) · exp (∑ⱼ q̃ᵢⱼ(sᵢ) λᵢⱼ(u))`. -/
def IsCondExpWith (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (i : Fin n) (Q : ℝ → ℝ)
    (Z : (Fin m → ℝ) → ℝ) (qt : Fin k → ℝ → ℝ) (lam : Fin k → (Fin m → ℝ) → ℝ) : Prop :=
  (∀ s, 0 < Q s) ∧ (∀ u, 0 < Z u) ∧ LinearIndependent ℝ qt ∧
    ∀ u s, condMarginal q i u s = Q s / Z u * Real.exp (∑ j, qt j s * lam j u)

/-- Definition 1 (p. 4): `sᵢ` is conditionally exponential of order `k` given `u`. -/
def IsCondExp (q : Fin n → ℝ → (Fin m → ℝ) → ℝ) (i : Fin n) (k : ℕ) : Prop :=
  ∃ (Q : ℝ → ℝ) (Z : (Fin m → ℝ) → ℝ) (qt : Fin k → ℝ → ℝ) (lam : Fin k → (Fin m → ℝ) → ℝ),
    IsCondExpWith q i Q Z qt lam

/-- Theorem 2 (ii) (p. 5): the vector `(λᵢⱼ(u))_{(i,j)} ∈ ℝ^{nk}` of all natural parameters. -/
def lamVec (lam : Fin n → Fin k → (Fin m → ℝ) → ℝ) (u : Fin m → ℝ) : Fin n × Fin k → ℝ :=
  fun p => lam p.1 p.2 u

/-- Eq. (12) (Theorem 3, p. 6): the vector of all sufficient statistics
`(q̃₁₁(s₁), q̃₁₂(s₁), …, q̃ₙₖ(sₙ))`. -/
def sstatVec (qt : Fin n → Fin k → ℝ → ℝ) (s : Fin n → ℝ) : Fin n × Fin k → ℝ :=
  fun p => qt p.1 p.2 (s p.1)

/-- Eq. (10) (Theorem 3, Assumption 3, p. 5): the `nk × nk` matrix `L̄` with row `(i, j)` and
column `l` equal to `λᵢⱼ(u_l) - λᵢⱼ(u₀)`. -/
def lamBar (lam : Fin n → Fin k → (Fin m → ℝ) → ℝ) (u₀ : Fin m → ℝ)
    (us : Fin n × Fin k → (Fin m → ℝ)) : Matrix (Fin n × Fin k) (Fin n × Fin k) ℝ :=
  fun p l => lam p.1 p.2 (us l) - lam p.1 p.2 u₀

/-- Eq. (11) (Theorem 3, p. 5): the regression function `h̃(x)ᵀ v(u) + a(x) + b(u)` with
`h̃ : ℝ^n → ℝ^{nk}` and `v : ℝ^m → ℝ^{nk}`. -/
def regExp (ht : (Fin n → ℝ) → (Fin n × Fin k → ℝ)) (v : (Fin m → ℝ) → (Fin n × Fin k → ℝ))
    (a : (Fin n → ℝ) → ℝ) (b : (Fin m → ℝ) → ℝ) (x : Fin n → ℝ) (u : Fin m → ℝ) : ℝ :=
  ∑ p, ht x p * v u p + a x + b u

/-- Supplementary A (p. 11): the partial derivative `∂F(y)/∂y_j` of `F : ℝ^n → ℝ`. -/
def partialDeriv (F : (Fin n → ℝ) → ℝ) (j : Fin n) (y : Fin n → ℝ) : ℝ :=
  fderiv ℝ F y (Pi.single j 1)

end NonlinearICAAux
Source
Hyvärinen, Sasaki and Turner, Nonlinear ICA Using Auxiliary Variables and Generalized Contrastive Learning, arXiv:1805.08651v3 (AISTATS 2019), Sections 3.1-3.2 (eqs. (1), (4)-(6)), Section 4.1 Definition 1 (eq. (7)), Section 4.2 Theorem 1 (eqs. (8)-(9)), Section 4.3 (eqs. (10)-(12)), Supplementary A and D (eqs. (41)-(42)), pp. 3-6, 11-13
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Throughout, n,m,kn, m, kn,m,k are natural numbers (any of them may be 000). Rn\mathbb{R}^nRn means real nnn-tuples s=(s1,…,sn)s = (s_1,\dots,s_n)s=(s1​,…,sn​) with the product Lebesgue measure. For n=0n = 0n=0 this is a one-point space of measure 111. A family q=(qi)i=1nq = (q_i)_{i=1}^nq=(qi​)i=1n​ always denotes arbitrary functions qi:R×Rm→Rq_i : \mathbb{R}\times\mathbb{R}^m \to \mathbb{R}qi​:R×Rm→R, written qi(t,u)q_i(t,u)qi​(t,u), with no regularity unless a definition imposes it. Whenever a derivative is taken of a function that is not differentiable at the relevant point, the value used is 000. A Bochner integral of a non-integrable function is likewise taken to be 000.

IsC2Diffeo. For a bijection e:Rn→Rne : \mathbb{R}^n \to \mathbb{R}^ne:Rn→Rn given together with its inverse e−1e^{-1}e−1, this is the property that eee and e−1e^{-1}e−1 are both twice continuously differentiable (C2C^2C2) on all of Rn\mathbb{R}^nRn.

condLogDensityS. For s∈Rns \in \mathbb{R}^ns∈Rn and u∈Rmu \in \mathbb{R}^mu∈Rm,

ℓq(s,u)  =  ∑i=1nqi(si,u).\ell_q(s,u) \;=\; \sum_{i=1}^n q_i(s_i, u).ℓq​(s,u)=i=1∑n​qi​(si​,u).

This is the empty sum 000 when n=0n = 0n=0.

IsAuxICAModel. Take a measure μ\muμ on Rm\mathbb{R}^mRm, a family qqq, and a bijection fff of Rn\mathbb{R}^nRn. Nothing requires μ\muμ to be a probability measure, finite, or σ\sigmaσ-finite, and μ=0\mu = 0μ=0 is allowed. The property is the conjunction of four conditions:

  1. fff satisfies IsC2Diffeo.
  2. Each map (t,u)↦qi(t,u)(t,u) \mapsto q_i(t,u)(t,u)↦qi​(t,u) is Borel measurable on R×Rm\mathbb{R}\times\mathbb{R}^mR×Rm.
  3. For every u∈Rmu \in \mathbb{R}^mu∈Rm, the function s↦eℓq(s,u)s \mapsto e^{\ell_q(s,u)}s↦eℓq​(s,u) is Lebesgue integrable on Rn\mathbb{R}^nRn and ∫Rneℓq(s,u) ds=1\int_{\mathbb{R}^n} e^{\ell_q(s,u)}\,ds = 1∫Rn​eℓq​(s,u)ds=1.
  4. For every s∈Rns \in \mathbb{R}^ns∈Rn, the function u↦eℓq(s,u)u \mapsto e^{\ell_q(s,u)}u↦eℓq​(s,u) is μ\muμ-integrable. This holds automatically if μ\muμ is finite and the integrand is bounded, and trivially if μ=0\mu = 0μ=0.

No condition links fff to qqq or μ\muμ.

margDensityS.

ps(s)  =  ∫Rmeℓq(s,u) dμ(u).p_s(s) \;=\; \int_{\mathbb{R}^m} e^{\ell_q(s,u)}\,d\mu(u).ps​(s)=∫Rm​eℓq​(s,u)dμ(u).

This equals 000 if the integrand is not μ\muμ-integrable, and in particular when μ=0\mu = 0μ=0.

absJacDet. For an arbitrary map g:Rn→Rng : \mathbb{R}^n \to \mathbb{R}^ng:Rn→Rn and a point xxx, this is ∣det⁡Dg(x)∣|\det Dg(x)|∣detDg(x)∣, the absolute determinant of the (Fréchet) derivative of ggg at xxx. Edge cases:

  • If ggg is not differentiable at xxx, the derivative is taken to be the zero map. The value is then 000 when n≥1n \ge 1n≥1.
  • When n=0n = 0n=0 the value is always 111.

condDensityX. With g=f−1g = f^{-1}g=f−1,

p(x∣u)  =  eℓq(g(x),u)⋅∣det⁡Dg(x)∣.p(x\mid u) \;=\; e^{\ell_q(g(x),u)}\cdot|\det Dg(x)|.p(x∣u)=eℓq​(g(x),u)⋅∣detDg(x)∣.

margDensityX. With g=f−1g = f^{-1}g=f−1,

p(x)  =  ps(g(x))⋅∣det⁡Dg(x)∣.p(x) \;=\; p_s(g(x))\cdot|\det Dg(x)|.p(x)=ps​(g(x))⋅∣detDg(x)∣.

Here psp_sps​ is the margDensityS above, built from μ\muμ.

logRatio.

log⁡p(x∣u)−log⁡p(x).\log p(x\mid u) - \log p(x).logp(x∣u)−logp(x).

The logarithm follows the convention log⁡0=0\log 0 = 0log0=0 (and log⁡y=log⁡∣y∣\log y = \log|y|logy=log∣y∣ for y<0y < 0y<0, which does not arise here). So when either density is 000, including the junk cases above, the corresponding term is 000 rather than −∞-\infty−∞.

logisticLoss. For an arbitrary function r:Rn×Rm→Rr : \mathbb{R}^n\times\mathbb{R}^m \to \mathbb{R}r:Rn×Rm→R, with no measurability required, this is the [0,∞][0,\infty][0,∞]-valued lower Lebesgue integral

∫Rn×Rm[log⁡ ⁣(1+e−r(x,u)) p(x∣u)  +  log⁡ ⁣(1+er(x,u)) p(x)]  d(λn⊗μ)(x,u).\int_{\mathbb{R}^n\times\mathbb{R}^m}\Big[\log\!\big(1+e^{-r(x,u)}\big)\,p(x\mid u) \;+\; \log\!\big(1+e^{r(x,u)}\big)\,p(x)\Big]\;d(\lambda^n\otimes\mu)(x,u).∫Rn×Rm​[log(1+e−r(x,u))p(x∣u)+log(1+er(x,u))p(x)]d(λn⊗μ)(x,u).
  • λn\lambda^nλn is Lebesgue measure on Rn\mathbb{R}^nRn.
  • Each of the two products is truncated at 000 from below; both products are in fact nonnegative.
  • The integral is taken against the product of λn\lambda^nλn and μ\muμ itself.
  • There is no factor 12\tfrac1221​ or other normalisation.

regFun. Given functions ψi:R×Rm→R\psi_i : \mathbb{R}\times\mathbb{R}^m \to \mathbb{R}ψi​:R×Rm→R and h:Rn→Rnh : \mathbb{R}^n \to \mathbb{R}^nh:Rn→Rn,

r(x,u)  =  ∑i=1nψi(h(x)i,u),r(x,u) \;=\; \sum_{i=1}^n \psi_i\big(h(x)_i, u\big),r(x,u)=i=1∑n​ψi​(h(x)i​,u),

where h(x)ih(x)_ih(x)i​ is the iii-th coordinate of h(x)h(x)h(x).

wVec. For y∈Rny \in \mathbb{R}^ny∈Rn and u∈Rmu \in \mathbb{R}^mu∈Rm, this is the vector w(y,u)∈R2nw(y,u) \in \mathbb{R}^{2n}w(y,u)∈R2n whose two blocks are indexed by i=1,…,ni = 1,\dots,ni=1,…,n:

  • first block, entry iii: ∂qi∂t(yi,u)\dfrac{\partial q_i}{\partial t}(y_i,u)∂t∂qi​​(yi​,u);
  • second block, entry iii: ∂2qi∂t2(yi,u)\dfrac{\partial^2 q_i}{\partial t^2}(y_i,u)∂t2∂2qi​​(yi​,u).

Both are ordinary derivatives of t↦qi(t,u)t \mapsto q_i(t,u)t↦qi​(t,u) at t=yit = y_it=yi​, with the value 000 wherever the derivative does not exist.

Variability. The property holds if, for every y∈Rny \in \mathbb{R}^ny∈Rn, there exist points u0,u1,…,u2n∈Rmu_0, u_1, \dots, u_{2n} \in \mathbb{R}^mu0​,u1​,…,u2n​∈Rm such that the 2n2n2n vectors

w(y,u1)−w(y,u0),  …,  w(y,u2n)−w(y,u0)w(y,u_1)-w(y,u_0),\;\dots,\;w(y,u_{2n})-w(y,u_0)w(y,u1​)−w(y,u0​),…,w(y,u2n​)−w(y,u0​)

are linearly independent in R2n\mathbb{R}^{2n}R2n. They then form a basis, and in particular are pairwise distinct and nonzero. The points may depend on yyy. For n=0n = 0n=0 the family is empty and the property holds for every qqq.

wAltVec. For y∈Rny \in \mathbb{R}^ny∈Rn, u∈Rmu \in \mathbb{R}^mu∈Rm and an index j∈{1,…,m}j \in \{1,\dots,m\}j∈{1,…,m}, this is the vector w~(y,u;j)∈R2n\tilde w(y,u;j) \in \mathbb{R}^{2n}w~(y,u;j)∈R2n with two blocks indexed by iii:

  • first block, entry iii: the derivative at uuu, in the direction of the jjj-th unit vector eje_jej​, of u′↦∂qi∂t(yi,u′)u' \mapsto \frac{\partial q_i}{\partial t}(y_i,u')u′↦∂t∂qi​​(yi​,u′);
  • second block, entry iii: the same for u′↦∂2qi∂t2(yi,u′)u' \mapsto \frac{\partial^2 q_i}{\partial t^2}(y_i,u')u′↦∂t2∂2qi​​(yi​,u′).

Each entry is the full (Fréchet) derivative in u′u'u′ applied to eje_jej​. It is 000 whenever that map is not Fréchet-differentiable at uuu, even if the partial derivative in uju_juj​ exists. The inner ttt-derivatives also use the 000-junk convention.

AltVariability. The property holds if, for every y∈Rny \in \mathbb{R}^ny∈Rn, there exist an index j∈{1,…,m}j \in \{1,\dots,m\}j∈{1,…,m} and points u1,…,u2n∈Rmu_1,\dots,u_{2n} \in \mathbb{R}^mu1​,…,u2n​∈Rm such that the 2n2n2n vectors

w~(y,u1;j),  …,  w~(y,u2n;j)\tilde w(y,u_1;j),\;\dots,\;\tilde w(y,u_{2n};j)w~(y,u1​;j),…,w~(y,u2n​;j)

are linearly independent in R2n\mathbb{R}^{2n}R2n. The same jjj is used for all lll, though jjj and the ulu_lul​ may depend on yyy. Edge cases:

  • If m=0m = 0m=0, no index jjj exists and the property is false for every qqq (and every nnn).
  • If n=0n = 0n=0 and m≥1m \ge 1m≥1, it is true for every qqq.

condMarginal. For iii, uuu and s∈Rs \in \mathbb{R}s∈R, this is

pi(s∣u)  =  eqi(s,u)∫Reqi(t,u) dt.p_i(s\mid u) \;=\; \frac{e^{q_i(s,u)}}{\int_{\mathbb{R}} e^{q_i(t,u)}\,dt}.pi​(s∣u)=∫R​eqi​(t,u)dteqi​(s,u)​.

It is simply the normalised exponential of qi(⋅,u)q_i(\cdot,u)qi​(⋅,u) alone, not an integral of the joint density over the other coordinates. If t↦eqi(t,u)t \mapsto e^{q_i(t,u)}t↦eqi​(t,u) is not integrable, the denominator is 000 and the value is 000 (division by zero yields 000).

IsCondExpWith. For an index iii, this is a property of the data Q:R→RQ : \mathbb{R}\to\mathbb{R}Q:R→R, Z:Rm→RZ : \mathbb{R}^m\to\mathbb{R}Z:Rm→R, q~1,…,q~k:R→R\tilde q_1,\dots,\tilde q_k : \mathbb{R}\to\mathbb{R}q~​1​,…,q~​k​:R→R and λ1,…,λk:Rm→R\lambda_1,\dots,\lambda_k : \mathbb{R}^m \to \mathbb{R}λ1​,…,λk​:Rm→R. It holds when all four conditions below hold:

  1. Q(s)>0Q(s) > 0Q(s)>0 for all sss.
  2. Z(u)>0Z(u) > 0Z(u)>0 for all uuu.
  3. q~1,…,q~k\tilde q_1,\dots,\tilde q_kq~​1​,…,q~​k​ are linearly independent as elements of the vector space of all functions R→R\mathbb{R}\to\mathbb{R}R→R.
  4. For all u∈Rmu \in \mathbb{R}^mu∈Rm and s∈Rs \in \mathbb{R}s∈R,
pi(s∣u)  =  Q(s)Z(u)exp⁡ ⁣(∑j=1kq~j(s) λj(u)).p_i(s\mid u) \;=\; \frac{Q(s)}{Z(u)}\exp\!\Big(\sum_{j=1}^k \tilde q_j(s)\,\lambda_j(u)\Big).pi​(s∣u)=Z(u)Q(s)​exp(j=1∑k​q~​j​(s)λj​(u)).

No measurability or variability is required of Q,Z,q~j,λjQ, Z, \tilde q_j, \lambda_jQ,Z,q~​j​,λj​. Because the right side is strictly positive, condition 4 forces t↦eqi(t,u)t \mapsto e^{q_i(t,u)}t↦eqi​(t,u) to be integrable for every uuu. For k=0k = 0k=0, condition 3 is vacuous and condition 4 reads pi(s∣u)=Q(s)/Z(u)p_i(s\mid u) = Q(s)/Z(u)pi​(s∣u)=Q(s)/Z(u).

IsCondExp. For an index iii and an order kkk, this holds if there exist QQQ, ZZZ, q~1,…,q~k\tilde q_1,\dots,\tilde q_kq~​1​,…,q~​k​ and λ1,…,λk\lambda_1,\dots,\lambda_kλ1​,…,λk​ of the above types satisfying IsCondExpWith.

lamVec. For functions λij:Rm→R\lambda_{ij} : \mathbb{R}^m\to\mathbb{R}λij​:Rm→R with i≤ni \le ni≤n and j≤kj \le kj≤k, this is the vector in Rn×k\mathbb{R}^{n\times k}Rn×k (indexed by pairs (i,j)(i,j)(i,j)) with entries λij(u)\lambda_{ij}(u)λij​(u).

sstatVec. For functions q~ij:R→R\tilde q_{ij} : \mathbb{R}\to\mathbb{R}q~​ij​:R→R, this is the vector indexed by pairs (i,j)(i,j)(i,j) with entries q~ij(si)\tilde q_{ij}(s_i)q~​ij​(si​). Each entry depends only on the iii-th coordinate of s∈Rns \in \mathbb{R}^ns∈Rn.

lamBar. Take a point u0u_0u0​ and points ul∈Rmu_l \in \mathbb{R}^mul​∈Rm, one for each pair l∈{1..n}×{1..k}l \in \{1..n\}\times\{1..k\}l∈{1..n}×{1..k}. The result is the square matrix Lˉ\bar LLˉ, with rows and columns both indexed by such pairs, whose entries are

Lˉ(i,j), l  =  λij(ul)−λij(u0).\bar L_{(i,j),\,l} \;=\; \lambda_{ij}(u_l) - \lambda_{ij}(u_0).Lˉ(i,j),l​=λij​(ul​)−λij​(u0​).

regExp. For h~:Rn→Rn×k\tilde h : \mathbb{R}^n \to \mathbb{R}^{n\times k}h~:Rn→Rn×k, v:Rm→Rn×kv : \mathbb{R}^m \to \mathbb{R}^{n\times k}v:Rm→Rn×k, a:Rn→Ra : \mathbb{R}^n\to\mathbb{R}a:Rn→R and b:Rm→Rb : \mathbb{R}^m\to\mathbb{R}b:Rm→R,

∑ph~(x)p v(u)p  +  a(x)  +  b(u),\sum_{p} \tilde h(x)_p\,v(u)_p \;+\; a(x) \;+\; b(u),p∑​h~(x)p​v(u)p​+a(x)+b(u),

where the sum runs over all pairs p=(i,j)p = (i,j)p=(i,j).

partialDeriv. For F:Rn→RF : \mathbb{R}^n\to\mathbb{R}F:Rn→R, an index jjj and a point yyy, this is DF(y) ejDF(y)\,e_jDF(y)ej​, the Fréchet derivative of FFF at yyy applied to the jjj-th unit vector. It equals 000 whenever FFF is not Fréchet-differentiable at yyy, even if the partial derivative ∂F/∂yj\partial F/\partial y_j∂F/∂yj​ exists there.

Human review
  • Endorsed by Shuze Chen · Nov 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 24, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me