Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 5: impossibility theorem for the separate space

Proved
OODLearnable.impossibility_separate_space

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

impossibility-theoremslearnabilityood-detectionpac-learningvc-dimension

Let X⊆Rd\mathcal X\subseteq\mathbb R^dX⊆Rd, let ℓ\ellℓ be a loss with ℓ(y1,y2)=0\ell(y_1,y_2)=0ℓ(y1​,y2​)=0 iff y1=y2y_1=y_2y1​=y2​, and let H\mathcal HH be a hypothesis space that is separate for OOD (Assumption 1). Let ϕ\phiϕ map the ID labels to 111 and the OOD label K+1K+1K+1 to 222. If

VCdim(ϕ∘H)<+∞andsup⁡h∈H∣{x∈X:h(x)∈Y}∣=+∞,{\rm VCdim}(\phi\circ\mathcal H)<+\infty\qquad\text{and}\qquad\sup_{h\in\mathcal H}\big|\{x\in\mathcal X:h(x)\in\mathcal Y\}\big|=+\infty,VCdim(ϕ∘H)<+∞andh∈Hsup​​{x∈X:h(x)∈Y}​=+∞,

then OOD detection is not learnable in the separate space DXYs\mathscr D^s_{XY}DXYs​ for H\mathcal HH.

So, unlike supervised learning, a finite VC dimension does not guarantee learnability of OOD detection even when ID and OOD supports are disjoint.

Formalization Note Cardinalities and the supremum are taken in N∪{∞}\mathbb N\cup\{\infty\}N∪{∞}. Supports in the definition of DXYs\mathscr D^s_{XY}DXYs​ are topological supports in X\mathcal XX. The feature space is X⊆Rd\mathcal X\subseteq\mathbb R^dX⊆Rd with the Borel structure; every hypothesis in H\mathcal HH is assumed measurable (the paper's implicit convention, needed for the risks to be defined).

Preamble
import Mathlib
import Definitions.Def_OODLearnable_Basic

open MeasureTheory Filter Topology
open scoped ENNReal NNReal
Formal statement
namespace OODLearnable

theorem impossibility_separate_space {dim : ℕ} {𝒳 : Set (EuclideanSpace ℝ (Fin dim))} {K : ℕ}
    (ℓ : Fin (K + 1) → Fin (K + 1) → ℝ≥0) (hℓ : IsOODLoss ℓ)
    (H : Set (𝒳 → Fin (K + 1))) (hHmeas : ∀ h ∈ H, Measurable h) (hA1 : SeparateForOOD H)
    (hVC : vcDim (phiComp H) < ⊤)
    (hsup : (⨆ h ∈ H, {x | h x ≠ Fin.last K}.encard) = ⊤) :
    ¬ IsLearnable ℓ (separateSpace : Set (Domain 𝒳 K)) H := by sorry

end OODLearnable
Source
Fang, Li, Lu, Dong, Han and Liu, Is Out-of-Distribution Detection Learnable?, NeurIPS 2022, arXiv:2210.14707v3, Section 4, Theorem 5 and Assumption 1, p. 6; proof in Appendix H (Lemmas 3-5), pp. 31-35
Read-back

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

Setting. Fix natural numbers ddd (the ambient dimension) and KKK (the number of in-distribution classes), and an arbitrary subset X⊆Rd\mathcal X \subseteq \mathbb R^dX⊆Rd. X\mathcal XX carries the subspace topology and the Borel σ\sigmaσ-algebra it induces. No condition is placed on X\mathcal XX: it may be empty, finite, non-measurable, and so on.

The label set is {1,…,K+1}\{1,\dots,K+1\}{1,…,K+1}:

  • labels 1,…,K1,\dots,K1,…,K are the in-distribution (ID) labels;
  • K+1K+1K+1 is the out-of-distribution (OOD) label.

The data. The theorem takes the following objects and hypotheses.

  • The loss. A loss ℓ:{1,…,K+1}×{1,…,K+1}→[0,∞)\ell:\{1,\dots,K+1\}\times\{1,\dots,K+1\}\to[0,\infty)ℓ:{1,…,K+1}×{1,…,K+1}→[0,∞) such that ℓ(y1,y2)=0  ⟺  y1=y2\ell(y_1,y_2)=0 \iff y_1=y_2ℓ(y1​,y2​)=0⟺y1​=y2​ for all labels y1,y2y_1,y_2y1​,y2​. The first argument is the predicted label and the second is the true label.
  • The hypothesis class. A set HHH of functions h:X→{1,…,K+1}h:\mathcal X\to\{1,\dots,K+1\}h:X→{1,…,K+1} such that:
    • Measurability. Every h∈Hh\in Hh∈H is measurable, with the Borel σ\sigmaσ-algebra on X\mathcal XX and the discrete σ\sigmaσ-algebra on labels.
    • Separate for OOD. For every x∈Xx\in\mathcal Xx∈X there is some h∈Hh\in Hh∈H with h(x)=K+1h(x)=K+1h(x)=K+1. If X≠∅\mathcal X\neq\emptysetX=∅, this forces H≠∅H\neq\emptysetH=∅.
    • Finite VC dimension of the binarized class. Let φ(y)=1\varphi(y)=1φ(y)=1 if y=K+1y=K+1y=K+1 and φ(y)=0\varphi(y)=0φ(y)=0 otherwise, and let φ∘H={φ∘h:h∈H}\varphi\circ H=\{\varphi\circ h : h\in H\}φ∘H={φ∘h:h∈H}. A finite set C⊆XC\subseteq\mathcal XC⊆X is shattered if for every g:X→{0,1}g:\mathcal X\to\{0,1\}g:X→{0,1} there is h∈Hh\in Hh∈H with φ(h(x))=g(x)\varphi(h(x))=g(x)φ(h(x))=g(x) for all x∈Cx\in Cx∈C. (The empty set is shattered exactly when H≠∅H\neq\emptysetH=∅.) The VC dimension is the supremum of ∣C∣|C|∣C∣ over shattered finite CCC; it is 000 if none exists. The hypothesis requires it to be a finite natural number.
    • Unbounded ID regions. The following holds, where ∣⋅∣|\cdot|∣⋅∣ is cardinality in {0,1,2,… }∪{∞}\{0,1,2,\dots\}\cup\{\infty\}{0,1,2,…}∪{∞}:
sup⁡h∈H ∣{x∈X:h(x)≠K+1}∣=∞.\sup_{h\in H}\ \bigl|\{x\in\mathcal X : h(x)\neq K+1\}\bigr| = \infty.h∈Hsup​ ​{x∈X:h(x)=K+1}​=∞.
That is, either some $h\in H$ assigns ID labels to infinitely many points, or these finite counts are unbounded. This hypothesis cannot hold if $\mathcal X$ is finite (including empty). It also cannot hold if $K=0$, since then every $h$ takes only the value $K+1$ and the supremum is $0$. So whenever all hypotheses hold, $K\ge 1$ and $\mathcal X$ is infinite.

Domains. A domain DDD consists of three pieces:

  • a probability measure DXIYID_{X_IY_I}DXI​YI​​ on X×{1,…,K}\mathcal X\times\{1,\dots,K\}X×{1,…,K};
  • a probability measure DXOD_{X_O}DXO​​ on X\mathcal XX;
  • a number πout∈[0,1)\pi^{\mathrm{out}}\in[0,1)πout∈[0,1).

Write DXID_{X_I}DXI​​ for the first marginal of DXIYID_{X_IY_I}DXI​YI​​.

The separate space Ds\mathscr D^sDs is the set of all domains with

supp⁡DXI∩supp⁡DXO=∅.\operatorname{supp} D_{X_I}\cap \operatorname{supp} D_{X_O}=\emptyset.suppDXI​​∩suppDXO​​=∅.

Here supports are taken in the subspace topology of X\mathcal XX: a point is in the support if every open neighbourhood of it has positive measure. There is no restriction on πout\pi^{\mathrm{out}}πout; in particular πout=0\pi^{\mathrm{out}}=0πout=0 is allowed.

Risks. For a function h:X→{1,…,K+1}h:\mathcal X\to\{1,\dots,K+1\}h:X→{1,…,K+1}, with values in [0,∞][0,\infty][0,∞], define

RDin(h)=∫ℓ(h(x),y) dDXIYI(x,y),RDout(h)=∫ℓ(h(x),K+1) dDXO(x),R^{\mathrm{in}}_D(h)=\int \ell(h(x),y)\,dD_{X_IY_I}(x,y),\qquad R^{\mathrm{out}}_D(h)=\int \ell(h(x),K+1)\,dD_{X_O}(x),RDin​(h)=∫ℓ(h(x),y)dDXI​YI​​(x,y),RDout​(h)=∫ℓ(h(x),K+1)dDXO​​(x), RD(h)=(1−πout) RDin(h)+πout RDout(h).R_D(h)=(1-\pi^{\mathrm{out}})\,R^{\mathrm{in}}_D(h)+\pi^{\mathrm{out}}\,R^{\mathrm{out}}_D(h).RD​(h)=(1−πout)RDin​(h)+πoutRDout​(h).

Algorithms and learnability. An algorithm AAA assigns to each n∈Nn\in\mathbb Nn∈N and each sample S∈(X×{1,…,K})nS\in(\mathcal X\times\{1,\dots,K\})^nS∈(X×{1,…,K})n a function An(S):X→{1,…,K+1}A_n(S):\mathcal X\to\{1,\dots,K+1\}An​(S):X→{1,…,K+1}. The samples contain ID data only, and no measurability of AAA is required. The training law DXIYInD^n_{X_IY_I}DXI​YI​n​ is the nnn-fold product of DXIYID_{X_IY_I}DXI​YI​​.

Conclusion. OOD detection is not learnable in Ds\mathscr D^sDs for HHH. That is, there do not exist an algorithm AAA and a real sequence (εn)(\varepsilon_n)(εn​) satisfying all of the following:

  1. An(S)∈HA_n(S)\in HAn​(S)∈H for every n≥1n\ge1n≥1 and every sample SSS;
  2. ε\varepsilonε is non-increasing and εn→0\varepsilon_n\to0εn​→0;
  3. for every domain D∈DsD\in\mathscr D^sD∈Ds and every n≥1n\ge 1n≥1, the map S↦RD(An(S))S\mapsto R_D(A_n(S))S↦RD​(An​(S)) is almost-everywhere measurable with respect to DXIYInD^n_{X_IY_I}DXI​YI​n​, and
∫RD(An(S)) dDXIYIn(S) ≤ inf⁡h∈HRD(h)+max⁡(εn,0).\int R_D(A_n(S))\,dD^n_{X_IY_I}(S)\ \le\ \inf_{h\in H} R_D(h)+\max(\varepsilon_n,0).∫RD​(An​(S))dDXI​YI​n​(S) ≤ h∈Hinf​RD​(h)+max(εn​,0).
Human review
  • Endorsed by Shuze Chen · Nov 23, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 23, 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