Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 3: overlap between ID and OOD breaks the linear condition

Proved
OODLearnable.overlap_breaks_linear_condition

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​, let H\mathcal HH be a hypothesis space and let D\mathscr DD be a priori-unknown space. Suppose some DXY∈DD_{XY}\in\mathscr DDXY​∈D has overlap between ID and OOD (Definition 4) and satisfies

inf⁡h∈HRDin(h)=0,inf⁡h∈HRDout(h)=0.\inf_{h\in\mathcal H}R^{\rm in}_D(h)=0,\qquad\inf_{h\in\mathcal H}R^{\rm out}_D(h)=0.h∈Hinf​RDin​(h)=0,h∈Hinf​RDout​(h)=0.

Then Condition 1 does not hold in D\mathscr DD, and OOD detection is not learnable in D\mathscr DD for H\mathcal HH.

Formalization Note Definition 4 asks that DX≪μ~D_X\ll\tilde\muDX​≪μ~​ and uses the Radon-Nikodym derivatives of both DXID_{X_{\rm I}}DXI​​ and DXOD_{X_{\rm O}}DXO​​; the formal definition requires DXI≪μ~D_{X_{\rm I}}\ll\tilde\muDXI​​≪μ~​ and DXO≪μ~D_{X_{\rm O}}\ll\tilde\muDXO​​≪μ~​, which is equivalent when πout>0\pi^{\rm out}>0πout>0 and is what the derivatives need when πout=0\pi^{\rm out}=0πout=0. 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 overlap_breaks_linear_condition {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)
    (𝒟 : Set (Domain 𝒳 K)) (h𝒟 : IsPriorUnknown 𝒟) (D : Domain 𝒳 K) (hD : D ∈ 𝒟)
    (hov : HasOverlap D) (hin : (⨅ h ∈ H, riskIn ℓ D h) = 0)
    (hout : (⨅ h ∈ H, riskOut ℓ D h) = 0) :
    ¬ LinearCondition ℓ 𝒟 H ∧ ¬ IsLearnable ℓ 𝒟 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, Definition 4 and Theorem 3, pp. 5-6; proof in Appendix G.1, pp. 29-31
Read-back

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

Setting. Fix a dimension d∈Nd \in \mathbb{N}d∈N and an arbitrary subset X⊆Rd\mathcal{X} \subseteq \mathbb{R}^dX⊆Rd. The feature space is X\mathcal{X}X with the σ-algebra it inherits from the Borel σ-algebra of Rd\mathbb{R}^dRd.

Fix K∈NK \in \mathbb{N}K∈N, which may be 000. The full label set is Yall={1,…,K+1}\mathcal{Y}_{\text{all}} = \{1, \dots, K+1\}Yall​={1,…,K+1}:

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

Labels carry the discrete σ-algebra.

Domains. A domain DDD is a triple (DXIYI,DXO,πout)(D_{X_IY_I}, D_{X_O}, \pi^{\text{out}})(DXI​YI​​,DXO​​,πout) where:

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

The ID marginal DXID_{X_I}DXI​​ is the pushforward of DXIYID_{X_IY_I}DXI​YI​​ onto X\mathcal{X}X. If K=0K = 0K=0 or X=∅\mathcal{X} = \emptysetX=∅, no probability measure on X×{1,…,K}\mathcal{X}\times\{1,\dots,K\}X×{1,…,K} exists. In that case no domain exists, and the theorem holds vacuously.

Risks. For a hypothesis h:X→{1,…,K+1}h : \mathcal{X} \to \{1,\dots,K+1\}h:X→{1,…,K+1} and a loss ℓ\ellℓ, all risks are lower Lebesgue integrals taking values in [0,∞][0,\infty][0,∞]:

RDin(h)=∫ℓ(h(x),y) dDXIYI(x,y),RDout(h)=∫ℓ(h(x),K+1) dDXO(x).R^{\text{in}}_D(h) = \int \ell(h(x), y)\, dD_{X_IY_I}(x,y), \qquad R^{\text{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).

For α∈[0,1]\alpha \in [0,1]α∈[0,1]:

RDα(h)=(1−α)RDin(h)+αRDout(h).R^\alpha_D(h) = (1-\alpha) R^{\text{in}}_D(h) + \alpha R^{\text{out}}_D(h).RDα​(h)=(1−α)RDin​(h)+αRDout​(h).

The risk of DDD is RD(h)=RDπout(h)R_D(h) = R^{\pi^{\text{out}}}_D(h)RD​(h)=RDπout​(h). An infimum over h∈Hh \in Hh∈H is taken in [0,∞][0,\infty][0,∞], so it equals +∞+\infty+∞ when H=∅H = \emptysetH=∅.

Hypotheses of the theorem.

  1. ℓ:{1,…,K+1}2→[0,∞)\ell : \{1,\dots,K+1\}^2 \to [0,\infty)ℓ:{1,…,K+1}2→[0,∞) satisfies ℓ(y1,y2)=0\ell(y_1,y_2) = 0ℓ(y1​,y2​)=0 if and only if y1=y2y_1 = y_2y1​=y2​.
  2. HHH is a set of functions X→{1,…,K+1}\mathcal{X} \to \{1,\dots,K+1\}X→{1,…,K+1}, each of which is measurable.
  3. D\mathcal{D}D is a set of domains that is prior-unknown. That is, for every D′∈DD' \in \mathcal{D}D′∈D and every α∈[0,1)\alpha \in [0,1)α∈[0,1), the domain (DXIYI′,DXO′,α)(D'_{X_IY_I}, D'_{X_O}, \alpha)(DXI​YI​′​,DXO​′​,α) also lies in D\mathcal{D}D.
  4. D∈DD \in \mathcal{D}D∈D is a domain that has overlap. This means there is a σ-finite measure μ\muμ on X\mathcal{X}X with DXI≪μD_{X_I} \ll \muDXI​​≪μ and DXO≪μD_{X_O} \ll \muDXO​​≪μ, such that
μ{x:fI(x)>0 and fO(x)>0}>0,fI=dDXIdμ, fO=dDXOdμ.\mu\{x : f_I(x) > 0 \text{ and } f_O(x) > 0\} > 0, \qquad f_I = \tfrac{dD_{X_I}}{d\mu},\ f_O = \tfrac{dD_{X_O}}{d\mu}.μ{x:fI​(x)>0 and fO​(x)>0}>0,fI​=dμdDXI​​​, fO​=dμdDXO​​​.
  1. inf⁡h∈HRDin(h)=0\inf_{h \in H} R^{\text{in}}_D(h) = 0infh∈H​RDin​(h)=0 and inf⁡h∈HRDout(h)=0\inf_{h \in H} R^{\text{out}}_D(h) = 0infh∈H​RDout​(h)=0.
    • These are infima, which need not be attained.
    • Together they force H≠∅H \neq \emptysetH=∅.
    • They concern only the given DDD; its own πout\pi^{\text{out}}πout plays no role in them.

Conclusion. Both of the following hold.

(a) The Linear Condition fails for (ℓ,D,H)(\ell, \mathcal{D}, H)(ℓ,D,H). There exist some D′∈DD' \in \mathcal{D}D′∈D and some α∈[0,1)\alpha \in [0,1)α∈[0,1) such that

inf⁡h∈HRD′α(h)≠(1−α)inf⁡h∈HRD′in(h)+αinf⁡h∈HRD′out(h).\inf_{h\in H} R^\alpha_{D'}(h) \neq (1-\alpha)\inf_{h\in H} R^{\text{in}}_{D'}(h) + \alpha \inf_{h\in H} R^{\text{out}}_{D'}(h).h∈Hinf​RD′α​(h)=(1−α)h∈Hinf​RD′in​(h)+αh∈Hinf​RD′out​(h).

(b) OOD detection is not learnable in D\mathcal{D}D for HHH. An algorithm AAA assigns to each n∈Nn \in \mathbb{N}n∈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}. No measurability of AAA itself is required. Part (b) says there is no pair consisting of an algorithm AAA and a sequence ε:N→R\varepsilon : \mathbb{N} \to \mathbb{R}ε:N→R satisfying all of the following:

  • An(S)∈HA_n(S) \in HAn​(S)∈H for every n≥1n \ge 1n≥1 and every sample SSS. Nothing is required at n=0n = 0n=0.
  • ε\varepsilonε is non-increasing and ε(n)→0\varepsilon(n) \to 0ε(n)→0.
  • For every D′∈DD' \in \mathcal{D}D′∈D 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 the nnn-fold product measure DXIYI′ nD'^{\,n}_{X_IY_I}DXI​YI​′n​, and
∫RD′(An(S)) dDXIYI′ n(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).

Here max⁡(ε(n),0)=ε(n)\max(\varepsilon(n), 0) = \varepsilon(n)max(ε(n),0)=ε(n), because a non-increasing sequence tending to 000 is non-negative.

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