Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Discriminative softmax models, linear similarity and diversity matrices

Definition
LinearIdentifiability_Basic

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

identifiabilitylinear-algebrarepresentation-learningsoftmax-models

Objects of Sections 2-3 and Appendix C of Roeder, Metz and Kingma (2020).

  1. Data model (Section 2.1). pD(x,y,S)p_{\mathcal D}(x,y,S)pD​(x,y,S) is an empirical (finitely supported) probability distribution over inputs x∈Xx\in Xx∈X, targets y∈Yy\in Yy∈Y and finite candidate sets S⊆YS\subseteq YS⊆Y. A pair (x,S)(x,S)(x,S) occurs in the data if pD(x,S)>0p_{\mathcal D}(x,S)>0pD​(x,S)>0, and then pD(y∣x,S)>0  ⟺  y∈Sp_{\mathcal D}(y\mid x,S)>0\iff y\in SpD​(y∣x,S)>0⟺y∈S. The input support is the set of xxx with pD(x)>0p_{\mathcal D}(x)>0pD​(x)>0 and the target support is the set of yyy with pD(y)>0p_{\mathcal D}(y)>0pD​(y)>0.
  2. Canonical discriminative form (eq. 1). For a representation f:X→RMf:X\to\mathbb R^Mf:X→RM and a context map g:Y→RMg:Y\to\mathbb R^Mg:Y→RM,
p(y∣x,S)=exp⁡(f(x)⊤g(y))∑y′∈Sexp⁡(f(x)⊤g(y′)).p(y\mid x,S)=\frac{\exp(f(x)^\top g(y))}{\sum_{y'\in S}\exp(f(x)^\top g(y'))}.p(y∣x,S)=∑y′∈S​exp(f(x)⊤g(y′))exp(f(x)⊤g(y))​.
  1. Equality of models (eq. 4). p′=p∗p'=p^*p′=p∗ means that the models (f′,g′)(f',g')(f′,g′) and (f∗,g∗)(f^*,g^*)(f∗,g∗) give the same p(y∣x,S)p(y\mid x,S)p(y∣x,S) for every (x,S)(x,S)(x,S) that occurs in the data and every y∈Sy\in Sy∈S.
  2. Linear similarity (Definition 1, eq. 3). (f′,g′)(f',g')(f′,g′) and (f∗,g∗)(f^*,g^*)(f∗,g∗) are linearly similar if f′(x)=Af∗(x)f'(x)=Af^*(x)f′(x)=Af∗(x) for all xxx and g′(y)=Bg∗(y)g'(y)=Bg^*(y)g′(y)=Bg∗(y) for all yyy, for invertible M×MM\times MM×M matrices A,BA,BA,B. For a parameterisation θ↦(fθ,gθ)\theta\mapsto(f_\theta,g_\theta)θ↦(fθ​,gθ​) of Θ\ThetaΘ, θ′∼Lθ∗\theta'\sim_L\theta^*θ′∼L​θ∗ means that (fθ′,gθ′)(f_{\theta'},g_{\theta'})(fθ′​,gθ′​) and (fθ∗,gθ∗)(f_{\theta^*},g_{\theta^*})(fθ∗​,gθ∗​) are linearly similar.
  3. Diversity matrices. For tuples (yA(i),yB(i))i=1M(y_A^{(i)},y_B^{(i)})_{i=1}^M(yA(i)​,yB(i)​)i=1M​, LLL is the M×MM\times MM×M matrix with columns g(yA(i))−g(yB(i))g(y_A^{(i)})-g(y_B^{(i)})g(yA(i)​)−g(yB(i)​) (Section 3.2). For tuples (x(i),S(i))i=0M(x^{(i)},S^{(i)})_{i=0}^M(x(i),S(i))i=0M​, the (M+1)×(M+1)(M+1)\times(M+1)(M+1)×(M+1) matrix M\mathbf MM has columns f~(x(i),S(i))\tilde f(x^{(i)},S^{(i)})f~​(x(i),S(i)) (Appendix C.1).
  4. Augmented representations (Appendix C, eqs. 10-12). Z(x,S)=log⁡∑y′∈Sexp⁡(f(x)⊤g(y′))Z(x,S)=\log\sum_{y'\in S}\exp(f(x)^\top g(y'))Z(x,S)=log∑y′∈S​exp(f(x)⊤g(y′)), f~(x,S)=[−Z(x,S);f(x)]∈RM+1\tilde f(x,S)=[-Z(x,S);f(x)]\in\mathbb R^{M+1}f~​(x,S)=[−Z(x,S);f(x)]∈RM+1 and g~(y)=[1;g(y)]∈RM+1\tilde g(y)=[1;g(y)]\in\mathbb R^{M+1}g~​(y)=[1;g(y)]∈RM+1.

Formalization Note The data distribution is a PMF on X×Y×Finset YX\times Y\times\mathrm{Finset}\,YX×Y×FinsetY with finite support; only its support enters the statements. The parameter space Θ\ThetaΘ appears only in Definition 1: the theorems quantify directly over the four functions f′,g′,f∗,g∗f',g',f^*,g^*f′,g′,f∗,g∗, which is equivalent to quantifying over all parameterisations and all θ′,θ∗\theta',\theta^*θ′,θ∗. A vector of RM\mathbb R^MRM is a function Fin M→R\mathrm{Fin}\,M\to\mathbb RFinM→R, and a matrix is invertible when its determinant is a unit.

Definition code
import Mathlib

/-!
Roeder, Metz and Kingma, *On Linear Identifiability of Learned Representations*,
arXiv:2007.00810v3 (2020): the data model of Section 2.1, the canonical discriminative form
(eq. (1)) of Section 2.2, the linear similarity relation of Definition 1 (Section 3.2), the matrices
of the diversity conditions (Section 3.2 and Appendix C.1), and the augmented representations of
Appendix C, eqs. (9)-(12).
-/

open Matrix

noncomputable section

namespace LinearIdentifiability

variable {X Y : Type*} {M : ℕ}

/-- Section 2.1: `p_D(x, S) > 0`, i.e. the pair `(x, S)` occurs in the data distribution
`p_D(x, y, S)` (some target `y` has positive probability together with `x` and `S`). -/
def IsSupported (pD : PMF (X × Y × Finset Y)) (x : X) (S : Finset Y) : Prop :=
  ∃ y, pD (x, y, S) ≠ 0

/-- Section 2.1: `p_D` is an empirical distribution (finitely supported) over inputs `x`, targets
`y` and finite candidate sets `S`, and `S` is the set of possible values of `y` given `x`:
`p_D(y | x, S) > 0 ⇔ y ∈ S` whenever `p_D(x, S) > 0`. -/
def IsDataDistribution (pD : PMF (X × Y × Finset Y)) : Prop :=
  pD.support.Finite ∧ ∀ x S, IsSupported pD x S → ∀ y, (pD (x, y, S) ≠ 0 ↔ y ∈ S)

/-- Section 2.1: the inputs `x` that occur in the data, `p_D(x) > 0`. -/
def inputSupport (pD : PMF (X × Y × Finset Y)) : Set X :=
  {x | ∃ S, IsSupported pD x S}

/-- Section 2.1: the targets `y` that occur in the data, `p_D(y) > 0`. -/
def targetSupport (pD : PMF (X × Y × Finset Y)) : Set Y :=
  {y | ∃ x S, pD (x, y, S) ≠ 0}

/-- Section 2.2, eq. (1): the canonical discriminative form
`p_θ(y | x, S) = exp(f(x)ᵀ g(y)) / ∑_{y' ∈ S} exp(f(x)ᵀ g(y'))`, for a representation
`f : X → ℝ^M` and a context map `g : Y → ℝ^M`. -/
def modelProb (f : X → Fin M → ℝ) (g : Y → Fin M → ℝ) (x : X) (S : Finset Y) (y : Y) : ℝ :=
  Real.exp (f x ⬝ᵥ g y) / ∑ y' ∈ S, Real.exp (f x ⬝ᵥ g y')

/-- Section 3.1-3.2, eq. (4): `p' = p*`, the two models `(f', g')` and `(f*, g*)` of the form (1)
assign the same conditional probability `p(y | x, S)` to every `(x, S)` occurring in the data and
every `y ∈ S`. -/
def ModelsAgreeOnData (pD : PMF (X × Y × Finset Y)) (f' : X → Fin M → ℝ) (g' : Y → Fin M → ℝ)
    (fstar : X → Fin M → ℝ) (gstar : Y → Fin M → ℝ) : Prop :=
  ∀ x S, IsSupported pD x S → ∀ y ∈ S, modelProb f' g' x S y = modelProb fstar gstar x S y

/-- Definition 1, eq. (3), on representation functions: `f' = A f*` and `g' = B g*` for invertible
`M × M` matrices `A` and `B`. -/
def LinearlySimilar (f' fstar : X → Fin M → ℝ) (g' gstar : Y → Fin M → ℝ) : Prop :=
  ∃ A B : Matrix (Fin M) (Fin M) ℝ, IsUnit A.det ∧ IsUnit B.det ∧
    (∀ x, f' x = A *ᵥ fstar x) ∧ (∀ y, g' y = B *ᵥ gstar y)

/-- Definition 1, eq. (3): the relation `θ' ∼_L θ*` on the parameter space `Θ`, for a
parameterisation `θ ↦ (f_θ, g_θ)`. -/
def LinSim {Θ : Type*} (f : Θ → X → Fin M → ℝ) (g : Θ → Y → Fin M → ℝ) (θ' θstar : Θ) : Prop :=
  LinearlySimilar (f θ') (f θstar) (g θ') (g θstar)

/-- Section 3.2 (diversity condition): the `M × M` matrix `L` whose `i`-th column is
`g(y_A^{(i)}) - g(y_B^{(i)})`, for tuples `(y_A^{(i)}, y_B^{(i)}) = (a i, b i)`. -/
def diffMatrix (g : Y → Fin M → ℝ) (a b : Fin M → Y) : Matrix (Fin M) (Fin M) ℝ :=
  fun j i => g (a i) j - g (b i) j

/-- Appendix C, eq. (12): the log-normaliser `Z(x, S) = log ∑_{y' ∈ S} exp(f(x)ᵀ g(y'))`. -/
def logNormalizer (f : X → Fin M → ℝ) (g : Y → Fin M → ℝ) (x : X) (S : Finset Y) : ℝ :=
  Real.log (∑ y' ∈ S, Real.exp (f x ⬝ᵥ g y'))

/-- Appendix C, eq. (10): the augmented representation `f̃(x, S) = [-Z(x, S); f(x)] ∈ ℝ^{M+1}`. -/
def augF (f : X → Fin M → ℝ) (g : Y → Fin M → ℝ) (x : X) (S : Finset Y) : Fin (M + 1) → ℝ :=
  vecCons (-logNormalizer f g x S) (f x)

/-- Appendix C, eq. (11): the augmented context map `g̃(y) = [1; g(y)] ∈ ℝ^{M+1}`. -/
def augG (g : Y → Fin M → ℝ) (y : Y) : Fin (M + 1) → ℝ :=
  vecCons 1 (g y)

/-- Appendix C.1 (diversity condition for `g`): the `(M+1) × (M+1)` matrix whose `i`-th column is
`f̃(x^{(i)}, S^{(i)})`, `i = 0, …, M`. -/
def augFMatrix (f : X → Fin M → ℝ) (g : Y → Fin M → ℝ) (xs : Fin (M + 1) → X)
    (Ss : Fin (M + 1) → Finset Y) : Matrix (Fin (M + 1)) (Fin (M + 1)) ℝ :=
  fun j i => augF f g (xs i) (Ss i) j

end LinearIdentifiability
Source
Roeder, Metz and Kingma, On Linear Identifiability of Learned Representations, arXiv:2007.00810v3 (2020), Section 2.1 (data model, p. 2), Section 2.2 (eq. (1), p. 3), Section 3.2 (Definition 1, eq. (3), diversity condition, p. 4), Appendix C (eqs. (9)-(12), p. 14) and Appendix C.1 (p. 14)
Read-back

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

Setting (common to all declarations below). XXX and YYY are arbitrary types: XXX is the space of inputs xxx and YYY the space of targets yyy. No structure, finiteness or nonemptiness is assumed of them. MMM is an arbitrary natural number, and M=0M = 0M=0 is allowed. Vectors in RM\mathbb{R}^MRM have coordinates indexed by {0,…,M−1}\{0,\dots,M-1\}{0,…,M−1}. u⋅v=∑jujvju \cdot v = \sum_{j} u_j v_ju⋅v=∑j​uj​vj​ is the standard dot product, which is 000 when M=0M=0M=0. A "probability mass function" pDp_DpD​ on X×Y×F(Y)X \times Y \times \mathcal{F}(Y)X×Y×F(Y) is a function that:

  • is defined on the triples (x,y,S)(x, y, S)(x,y,S), where F(Y)\mathcal{F}(Y)F(Y) is the set of finite subsets S⊆YS \subseteq YS⊆Y;
  • takes values in [0,∞][0,\infty][0,∞];
  • has values summing to 111.

IsSupported. Given a probability mass function pDp_DpD​ on triples (x,y,S)(x,y,S)(x,y,S) with x∈Xx \in Xx∈X, y∈Yy \in Yy∈Y, SSS a finite subset of YYY, an input x∈Xx \in Xx∈X and a finite set S⊆YS \subseteq YS⊆Y, the pair (x,S)(x,S)(x,S) is called supported exactly when there exists some y∈Yy \in Yy∈Y with

pD(x,y,S)≠0.p_D(x,y,S) \neq 0.pD​(x,y,S)=0.

The witness yyy ranges over all of YYY; nothing requires y∈Sy \in Sy∈S.

IsDataDistribution. A probability mass function pDp_DpD​ on triples (x,y,S)(x,y,S)(x,y,S) (with x∈Xx\in Xx∈X, y∈Yy\in Yy∈Y, SSS a finite subset of YYY) is called a data distribution exactly when both of the following hold:

  1. The set of triples (x,y,S)(x,y,S)(x,y,S) with pD(x,y,S)≠0p_D(x,y,S) \neq 0pD​(x,y,S)=0 is finite.
  2. For every x∈Xx \in Xx∈X and every finite S⊆YS \subseteq YS⊆Y such that (x,S)(x,S)(x,S) is supported, i.e. pD(x,y0,S)≠0p_D(x,y_0,S)\neq 0pD​(x,y0​,S)=0 for some y0∈Yy_0 \in Yy0​∈Y, and for every y∈Yy \in Yy∈Y:
pD(x,y,S)≠0  ⟺  y∈S.p_D(x,y,S) \neq 0 \iff y \in S.pD​(x,y,S)=0⟺y∈S.

Consequences:

  • For a supported pair (x,S)(x,S)(x,S), every element of SSS receives positive mass and no element outside SSS does.
  • In particular, SSS is nonempty for every supported pair.
  • No condition is imposed on unsupported pairs (x,S)(x,S)(x,S). On those, pDp_DpD​ is zero for every yyy by definition.

The condition is stated directly on the joint masses pD(x,y,S)p_D(x,y,S)pD​(x,y,S), not on a conditional distribution.

inputSupport. For a probability mass function pDp_DpD​ on triples (x,y,S)(x,y,S)(x,y,S) (x∈Xx\in Xx∈X, y∈Yy\in Yy∈Y, SSS a finite subset of YYY), the input support is the set

{ x∈X  :  ∃ S finite⊆Y, ∃ y∈Y, pD(x,y,S)≠0 }.\{\, x \in X \;:\; \exists\, S \text{ finite} \subseteq Y,\ \exists\, y \in Y,\ p_D(x,y,S) \neq 0 \,\}.{x∈X:∃S finite⊆Y, ∃y∈Y, pD​(x,y,S)=0}.

These are the inputs xxx for which some pair (x,S)(x,S)(x,S) is supported, i.e. which carry positive marginal mass.

targetSupport. For a probability mass function pDp_DpD​ on triples (x,y,S)(x,y,S)(x,y,S) (x∈Xx\in Xx∈X, y∈Yy\in Yy∈Y, SSS a finite subset of YYY), the target support is the set

{ y∈Y  :  ∃ x∈X, ∃ S finite⊆Y, pD(x,y,S)≠0 }.\{\, y \in Y \;:\; \exists\, x \in X,\ \exists\, S \text{ finite} \subseteq Y,\ p_D(x,y,S) \neq 0 \,\}.{y∈Y:∃x∈X, ∃S finite⊆Y, pD​(x,y,S)=0}.

These are the targets carrying positive marginal mass. No requirement that y∈Sy \in Sy∈S is built in here.

modelProb. Given:

  • a representation f:X→RMf : X \to \mathbb{R}^Mf:X→RM;
  • a context map g:Y→RMg : Y \to \mathbb{R}^Mg:Y→RM;
  • an input x∈Xx \in Xx∈X;
  • a finite set S⊆YS \subseteq YS⊆Y;
  • a target y∈Yy \in Yy∈Y;

the model probability is the real number

pf,g(y∣x,S)  =  exp⁡(f(x)⋅g(y))∑y′∈Sexp⁡(f(x)⋅g(y′)).p_{f,g}(y \mid x, S) \;=\; \frac{\exp\big(f(x)\cdot g(y)\big)}{\sum_{y' \in S} \exp\big(f(x)\cdot g(y')\big)}.pf,g​(y∣x,S)=∑y′∈S​exp(f(x)⋅g(y′))exp(f(x)⋅g(y))​.

Edge cases:

  • yyy is not required to lie in SSS. If y∉Sy \notin Sy∈/S the formula is still evaluated, and the result can exceed 111.
  • If S=∅S = \varnothingS=∅, the denominator is 000 and the value is defined to be 000, by the convention that division by zero yields 000.
  • If M=0M = 0M=0, every dot product is 000 and the value is 1/∣S∣1/|S|1/∣S∣, which is 000 when S=∅S=\varnothingS=∅.

ModelsAgreeOnData. Given:

  • a probability mass function pDp_DpD​ on triples (x,y,S)(x,y,S)(x,y,S) (x∈Xx\in Xx∈X, y∈Yy\in Yy∈Y, SSS a finite subset of YYY);
  • two pairs of maps f′,f∗:X→RMf', f^* : X \to \mathbb{R}^Mf′,f∗:X→RM and g′,g∗:Y→RMg', g^* : Y \to \mathbb{R}^Mg′,g∗:Y→RM;

the models agree on the data exactly when, for every x∈Xx \in Xx∈X and every finite S⊆YS \subseteq YS⊆Y such that pD(x,y0,S)≠0p_D(x,y_0,S)\neq 0pD​(x,y0​,S)=0 for some y0∈Yy_0 \in Yy0​∈Y, and for every y∈Sy \in Sy∈S,

exp⁡(f′(x)⋅g′(y))∑y′∈Sexp⁡(f′(x)⋅g′(y′))  =  exp⁡(f∗(x)⋅g∗(y))∑y′∈Sexp⁡(f∗(x)⋅g∗(y′)).\frac{\exp\big(f'(x)\cdot g'(y)\big)}{\sum_{y' \in S} \exp\big(f'(x)\cdot g'(y')\big)} \;=\; \frac{\exp\big(f^*(x)\cdot g^*(y)\big)}{\sum_{y' \in S} \exp\big(f^*(x)\cdot g^*(y')\big)}.∑y′∈S​exp(f′(x)⋅g′(y′))exp(f′(x)⋅g′(y))​=∑y′∈S​exp(f∗(x)⋅g∗(y′))exp(f∗(x)⋅g∗(y))​.

Scope of the condition:

  • pDp_DpD​ is not required to satisfy the data-distribution condition.
  • Nothing is required for pairs (x,S)(x,S)(x,S) outside the support.
  • Nothing is required for targets y∉Sy \notin Sy∈/S.

LinearlySimilar. Given maps f′,f∗:X→RMf', f^* : X \to \mathbb{R}^Mf′,f∗:X→RM and g′,g∗:Y→RMg', g^* : Y \to \mathbb{R}^Mg′,g∗:Y→RM, the pair (f′,g′)(f',g')(f′,g′) is linearly similar to (f∗,g∗)(f^*,g^*)(f∗,g∗) exactly when there exist real M×MM\times MM×M matrices AAA and BBB with det⁡A≠0\det A \neq 0detA=0 and det⁡B≠0\det B \neq 0detB=0 such that

f′(x)=A f∗(x)for every x∈X,g′(y)=B g∗(y)for every y∈Y.f'(x) = A\, f^*(x) \quad \text{for every } x \in X, \qquad g'(y) = B\, g^*(y) \quad \text{for every } y \in Y.f′(x)=Af∗(x)for every x∈X,g′(y)=Bg∗(y)for every y∈Y.

Notes:

  • The equalities are required on all of XXX and all of YYY, not only on any data support.
  • AAA and BBB are independent invertible matrices; no relation between them (such as B=A−⊤B = A^{-\top}B=A−⊤) is imposed.
  • When M=0M = 0M=0 the condition holds trivially for all maps.

LinSim. Given:

  • a parameter type Θ\ThetaΘ, which is arbitrary;
  • parameterised maps θ↦fθ:X→RM\theta \mapsto f_\theta : X \to \mathbb{R}^Mθ↦fθ​:X→RM and θ↦gθ:Y→RM\theta \mapsto g_\theta : Y \to \mathbb{R}^Mθ↦gθ​:Y→RM;

two parameters θ′,θ∗∈Θ\theta', \theta^* \in \Thetaθ′,θ∗∈Θ satisfy θ′∼Lθ∗\theta' \sim_L \theta^*θ′∼L​θ∗ exactly when there exist real M×MM\times MM×M matrices A,BA, BA,B with det⁡A≠0\det A \neq 0detA=0 and det⁡B≠0\det B \neq 0detB=0 such that

fθ′(x)=A fθ∗(x)  for all x∈X,gθ′(y)=B gθ∗(y)  for all y∈Y.f_{\theta'}(x) = A\, f_{\theta^*}(x) \ \text{ for all } x\in X, \qquad g_{\theta'}(y) = B\, g_{\theta^*}(y) \ \text{ for all } y \in Y.fθ′​(x)=Afθ∗​(x)  for all x∈X,gθ′​(y)=Bgθ∗​(y)  for all y∈Y.

As with LinearlySimilar, AAA and BBB are unrelated, and when M=0M=0M=0 every pair of parameters is related.

diffMatrix. Given:

  • a context map g:Y→RMg : Y \to \mathbb{R}^Mg:Y→RM;
  • two MMM-tuples of targets a=(a0,…,aM−1)a = (a_0,\dots,a_{M-1})a=(a0​,…,aM−1​) and b=(b0,…,bM−1)b = (b_0,\dots,b_{M-1})b=(b0​,…,bM−1​) in YYY;

this is the real M×MM \times MM×M matrix LLL with entries

Lj,i=g(ai)j−g(bi)j,i,j∈{0,…,M−1}.L_{j,i} = g(a_i)_j - g(b_i)_j, \qquad i,j \in \{0,\dots,M-1\}.Lj,i​=g(ai​)j​−g(bi​)j​,i,j∈{0,…,M−1}.

Its iii-th column is the vector g(ai)−g(bi)g(a_i) - g(b_i)g(ai​)−g(bi​). The definition only builds the matrix: it does not assert invertibility, distinctness of aia_iai​ and bib_ibi​, or membership of the targets in any support. For M=0M=0M=0 it is the empty matrix.

logNormalizer. Given f:X→RMf : X \to \mathbb{R}^Mf:X→RM, g:Y→RMg : Y \to \mathbb{R}^Mg:Y→RM, an input x∈Xx \in Xx∈X and a finite set S⊆YS \subseteq YS⊆Y, the log-normaliser is

Z(x,S)=log⁡∑y′∈Sexp⁡(f(x)⋅g(y′)).Z(x,S) = \log \sum_{y' \in S} \exp\big(f(x)\cdot g(y')\big).Z(x,S)=logy′∈S∑​exp(f(x)⋅g(y′)).

If S=∅S = \varnothingS=∅ the sum is 000 and the value is defined to be 000, by the convention log⁡0=0\log 0 = 0log0=0.

augF. Given f:X→RMf : X \to \mathbb{R}^Mf:X→RM, g:Y→RMg : Y \to \mathbb{R}^Mg:Y→RM, x∈Xx \in Xx∈X and a finite S⊆YS \subseteq YS⊆Y, the augmented representation is the vector in RM+1\mathbb{R}^{M+1}RM+1 (coordinates indexed 0,…,M0,\dots,M0,…,M) given by

f~(x,S)=(−Z(x,S)f(x)),Z(x,S)=log⁡∑y′∈Sexp⁡(f(x)⋅g(y′)).\tilde f(x,S) = \begin{pmatrix} -Z(x,S) \\ f(x) \end{pmatrix}, \qquad Z(x,S) = \log \sum_{y' \in S} \exp\big(f(x)\cdot g(y')\big).f~​(x,S)=(−Z(x,S)f(x)​),Z(x,S)=logy′∈S∑​exp(f(x)⋅g(y′)).

The coordinates are as follows:

  • Coordinate 000 is −Z(x,S)-Z(x,S)−Z(x,S).
  • Coordinates 1,…,M1,\dots,M1,…,M are f(x)0,…,f(x)M−1f(x)_0,\dots,f(x)_{M-1}f(x)0​,…,f(x)M−1​.

When S=∅S = \varnothingS=∅, coordinate 000 equals 000.

augG. Given g:Y→RMg : Y \to \mathbb{R}^Mg:Y→RM and y∈Yy \in Yy∈Y, the augmented context vector in RM+1\mathbb{R}^{M+1}RM+1 (coordinates indexed 0,…,M0,\dots,M0,…,M) is

g~(y)=(1g(y)).\tilde g(y) = \begin{pmatrix} 1 \\ g(y) \end{pmatrix}.g~​(y)=(1g(y)​).

Coordinate 000 is 111, and coordinates 1,…,M1,\dots,M1,…,M are g(y)0,…,g(y)M−1g(y)_0,\dots,g(y)_{M-1}g(y)0​,…,g(y)M−1​.

augFMatrix. Given:

  • f:X→RMf : X \to \mathbb{R}^Mf:X→RM and g:Y→RMg : Y \to \mathbb{R}^Mg:Y→RM;
  • an (M+1)(M+1)(M+1)-tuple of inputs x(0),…,x(M)∈Xx^{(0)},\dots,x^{(M)} \in Xx(0),…,x(M)∈X;
  • an (M+1)(M+1)(M+1)-tuple of finite sets S(0),…,S(M)⊆YS^{(0)},\dots,S^{(M)} \subseteq YS(0),…,S(M)⊆Y;

this is the real (M+1)×(M+1)(M+1)\times(M+1)(M+1)×(M+1) matrix whose (j,i)(j,i)(j,i) entry is the jjj-th coordinate of f~(x(i),S(i))\tilde f(x^{(i)}, S^{(i)})f~​(x(i),S(i)), for i,j∈{0,…,M}i,j \in \{0,\dots,M\}i,j∈{0,…,M}. Equivalently, its iii-th column is

f~(x(i),S(i))=(−log⁡∑y′∈S(i)exp⁡(f(x(i))⋅g(y′))f(x(i))).\tilde f(x^{(i)},S^{(i)}) = \begin{pmatrix} -\log \sum_{y' \in S^{(i)}} \exp\big(f(x^{(i)})\cdot g(y')\big) \\ f(x^{(i)}) \end{pmatrix}.f~​(x(i),S(i))=(−log∑y′∈S(i)​exp(f(x(i))⋅g(y′))f(x(i))​).

In particular, row 000 holds the negated log-normalisers and rows 1,…,M1,\dots,M1,…,M hold the vectors f(x(i))f(x^{(i)})f(x(i)). The definition only builds the matrix: it does not assert invertibility, does not require the pairs (x(i),S(i))(x^{(i)},S^{(i)})(x(i),S(i)) to be supported by any distribution, and does not require the sets S(i)S^{(i)}S(i) to be nonempty. An empty S(i)S^{(i)}S(i) puts 000 in row 000 of column iii.

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