Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 1 (Condition 1 part): learnability in a priori-unknown space implies the linear condition

Proved
OODLearnable.learnable_implies_linear_condition

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

impossibility-theoremslearnabilityood-detectionpac-learningvc-dimension

Let D\mathscr DD be a priori-unknown space of domains over 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. If OOD detection is learnable in D\mathscr DD for H\mathcal HH, then the linear condition (Condition 1) holds: for every DXY∈DD_{XY}\in\mathscr DDXY​∈D and every α∈[0,1)\alpha\in[0,1)α∈[0,1),

inf⁡h∈HRDα(h)=(1−α)inf⁡h∈HRDin(h)+αinf⁡h∈HRDout(h).\inf_{h\in\mathcal H}R^\alpha_D(h)=(1-\alpha)\inf_{h\in\mathcal H}R^{\rm in}_D(h)+\alpha\inf_{h\in\mathcal H}R^{\rm out}_D(h).h∈Hinf​RDα​(h)=(1−α)h∈Hinf​RDin​(h)+αh∈Hinf​RDout​(h).

This is the necessary condition from which the paper's impossibility theorems are derived.

Formalization Note Lemma 1 of the paper asserts that Conditions 1 and 4 hold; only the Condition 1 part is stated here (Condition 4, the multi-linear condition, is not formalized). 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 learnable_implies_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 𝒟) (hL : IsLearnable ℓ 𝒟 H) :
    LinearCondition ℓ 𝒟 H := by sorry

end OODLearnable
Source
Fang, Li, Lu, Dong, Han and Liu, Is Out-of-Distribution Detection Learnable?, NeurIPS 2022, arXiv:2210.14707v3, Appendix F, Lemma 1 (Condition 1 part), pp. 26-28; Condition 1 stated in Section 4, p. 5
Read-back

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

Setting. Fix a dimension d≥0d \ge 0d≥0 and an arbitrary subset X⊆Rd\mathcal X \subseteq \mathbb R^dX⊆Rd, which serves as the feature space. Its measurable sets are the traces on X\mathcal XX of Borel sets of Rd\mathbb R^dRd. Fix K∈NK \in \mathbb NK∈N; K=0K = 0K=0 is allowed.

  • Labels. The full label set is Yall={1,…,K+1}\mathcal Y_{\text{all}} = \{1,\dots,K+1\}Yall​={1,…,K+1}. The labels 1,…,K1,\dots,K1,…,K are the in-distribution (ID) labels, and K+1K+1K+1 is the out-of-distribution (OOD) label.
  • Loss. The loss is a function ℓ:Yall×Yall→[0,∞)\ell : \mathcal Y_{\text{all}} \times \mathcal Y_{\text{all}} \to [0,\infty)ℓ:Yall​×Yall​→[0,∞) (finite, nonnegative values) satisfying ℓ(y1,y2)=0  ⟺  y1=y2\ell(y_1,y_2) = 0 \iff y_1 = y_2ℓ(y1​,y2​)=0⟺y1​=y2​.
  • Hypotheses. HHH is an arbitrary set of functions h:X→Yallh : \mathcal X \to \mathcal Y_{\text{all}}h:X→Yall​. Each h∈Hh \in Hh∈H is assumed measurable, meaning every level set h−1({y})h^{-1}(\{y\})h−1({y}) is a measurable subset of X\mathcal XX. HHH may be empty.

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 XX;
  • πout∈[0,1)\pi^{\text{out}} \in [0,1)πout∈[0,1).

If K=0K = 0K=0 or X=∅\mathcal X = \varnothingX=∅, no domain exists.

For h:X→Yallh : \mathcal X \to \mathcal Y_{\text{all}}h:X→Yall​ and α∈R\alpha \in \mathbb Rα∈R, define the following risks, valued 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), RDα(h)=max⁡(1−α,0) RDin(h)+max⁡(α,0) RDout(h),RD(h)=RDπout(h).R^{\alpha}_D(h) = \max(1-\alpha,0)\, R^{\text{in}}_D(h) + \max(\alpha,0)\, R^{\text{out}}_D(h), \qquad R_D(h) = R^{\pi^{\text{out}}}_D(h).RDα​(h)=max(1−α,0)RDin​(h)+max(α,0)RDout​(h),RD​(h)=RDπout​(h).
  • The integrals are Lebesgue integrals of nonnegative functions, so they are always defined but may be +∞+\infty+∞.
  • Arithmetic is in [0,∞][0,\infty][0,∞], with the convention 0⋅∞=00\cdot\infty = 00⋅∞=0.

Hypothesis on the domain space. D\mathcal DD is a set of domains that is prior-unknown. That is, for every D∈DD \in \mathcal DD∈D and every α∈[0,1)\alpha \in [0,1)α∈[0,1), the domain Dα=(DXIYI,DXO,α)D^\alpha = (D_{X_IY_I}, D_{X_O}, \alpha)Dα=(DXI​YI​​,DXO​​,α) also belongs to D\mathcal DD. This is the same domain with its prior replaced by α\alphaα.

Learnability hypothesis. It is assumed that OOD detection is learnable in D\mathcal DD for HHH: there exist an algorithm AAA and a real sequence (εn)n∈N(\varepsilon_n)_{n\in\mathbb N}(εn​)n∈N​ with the properties below. The algorithm assigns to every nnn and every sample S∈(X×{1,…,K})nS \in (\mathcal X \times \{1,\dots,K\})^nS∈(X×{1,…,K})n a function An(S):X→YallA_n(S) : \mathcal X \to \mathcal Y_{\text{all}}An​(S):X→Yall​; no measurability in SSS is imposed on AAA itself.

  1. An(S)∈HA_n(S) \in HAn​(S)∈H for every n≥1n \ge 1n≥1 and every sample SSS.
  2. ε\varepsilonε is non-increasing.
  3. εn→0\varepsilon_n \to 0εn​→0. Together with (2), this forces εn≥0\varepsilon_n \ge 0εn​≥0.
  4. For every D∈DD \in \mathcal DD∈D and every n≥1n \ge 1n≥1, both of the following hold, where DXIYInD^n_{X_IY_I}DXI​YI​n​ is the nnn-fold product of DXIYID_{X_IY_I}DXI​YI​​ (the law of an i.i.d. sample of size nnn):
    • 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​;
    • the expected risk satisfies
∫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).

The infimum is taken in [0,∞][0,\infty][0,∞] and equals +∞+\infty+∞ if H=∅H = \varnothingH=∅.

Conclusion. Under all these assumptions, D\mathcal DD and HHH satisfy the linear condition: for every D∈DD \in \mathcal DD∈D and every α∈[0,1)\alpha \in [0,1)α∈[0,1),

inf⁡h∈HRDα(h)  =  (1−α) inf⁡h∈HRDin(h)  +  α inf⁡h∈HRDout(h).\inf_{h\in H} R^{\alpha}_D(h) \;=\; (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​RDin​(h)+αh∈Hinf​RDout​(h).
  • This is an equality in [0,∞][0,\infty][0,∞], and each of the three infima is taken separately over HHH.
  • The value α=1\alpha = 1α=1 is not covered.
  • The prior πout\pi^{\text{out}}πout of DDD plays no role in the conclusion.
  • If no domains exist (e.g. K=0K = 0K=0 or X=∅\mathcal X = \varnothingX=∅), then D\mathcal DD is empty and the conclusion holds vacuously.
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