Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Corollary 1 (as proved): the guarantee with an upper bound α′≥α\alpha'\ge\alphaα′≥α

Proved
OpenCategoryPAC.corollary_1

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

anomaly-detectiondkw-inequalityempirical-cdfopen-category-detectionpac-guarantee

Assume the setting of Theorem 1: score laws μ0,μa\mu_0,\mu_aμ0​,μa​ with continuous CDFs, 0<α≤10<\alpha\le10<α≤1, μm=(1−α)μ0+αμa\mu_m=(1-\alpha)\mu_0+\alpha\mu_aμm​=(1−α)μ0​+αμa​, and independent samples S0∼μ0⊗nS_0\sim\mu_0^{\otimes n}S0​∼μ0⊗n​, Sm∼μm⊗nS_m\sim\mu_m^{\otimes n}Sm​∼μm⊗n​. Assume also that the anomaly detector is admissible, F0(x)≥Fm(x)F_0(x)\ge F_m(x)F0​(x)≥Fm​(x) for all x∈Rx\in\mathbb Rx∈R. Let α′\alpha'α′ be an upper bound on the true fraction, α≤α′≤1\alpha\le\alpha'\le1α≤α′≤1, and run Algorithm 1 with α′\alpha'α′ in place of α\alphaα. Let q>0q>0q>0, ϵ∈(0,1−q)\epsilon\in(0,1-q)ϵ∈(0,1−q), δ∈(0,1)\delta\in(0,1)δ∈(0,1), and suppose

n>12ln⁡21−1−δ(1ϵ)2(2−α′α′)2.n>\frac12\ln\frac{2}{1-\sqrt{1-\delta}}\left(\frac1\epsilon\right)^2\left(\frac{2-\alpha'}{\alpha'}\right)^2.n>21​ln1−1−δ​2​(ϵ1​)2(α′2−α′​)2.

Then, with probability at least 1−δ1-\delta1−δ, if Algorithm 1 returns a threshold τ^q′\hat\tau'_qτ^q′​, that threshold achieves an alien detection rate of at least 1−η1-\eta1−η, η=q+ϵ\eta=q+\epsilonη=q+ϵ:

μa((τ^q′,∞))≥1−η.\mu_a\big((\hat\tau'_q,\infty)\big)\ge1-\eta.μa​((τ^q′​,∞))≥1−η.

So knowing an upper bound on the alien fraction suffices, at the price of a more conservative threshold.

Formalization Note As in Theorem 1, the printed claim that Algorithm 1 returns a threshold is not proved and is false in general. The statement gives the guarantee for the returned threshold whenever one is returned, as an upper bound δ\deltaδ on the probability of the failure event. α′≤1\alpha'\le1α′≤1 is the paper's implicit reading of α′\alpha'α′ as an upper bound on a fraction.

Preamble
import Mathlib
import Definitions.Def_OpenCategoryPAC_Basic

open MeasureTheory ProbabilityTheory Filter Topology
Formal statement
namespace OpenCategoryPAC

theorem corollary_1 (μ0 μa μm : Measure ℝ) [IsProbabilityMeasure μ0]
    [IsProbabilityMeasure μa] [IsProbabilityMeasure μm] (α α' : ℝ) (hα0 : 0 < α)
    (hαα' : α ≤ α') (hα'1 : α' ≤ 1)
    (hm : μm = mixture α μ0 μa) (hF0 : Continuous (cdf μ0)) (hFa : Continuous (cdf μa))
    (hadm : IsAdmissible μ0 μm)
    (q ε δ : ℝ) (hq : 0 < q) (hε0 : 0 < ε) (hε1 : ε < 1 - q) (hδ0 : 0 < δ) (hδ1 : δ < 1)
    (n : ℕ) (hn : sampleSizeBound α' ε δ < n) :
    sampleLaw μ0 μm n
        {s | ∃ τ : ℝ, IsAlgThreshold α' q s.1 s.2 τ ∧ detectionRate μa τ < 1 - (q + ε)} ≤
      ENNReal.ofReal δ := by sorry

end OpenCategoryPAC
Source
Liu, Garrepalli, Dietterich, Fern and Hendrycks, Open Category Detection with PAC Guarantees, arXiv:1808.00529v1 (ICML 2018), Section 5, Corollary 1, p. 4; proof in Appendix B, p. 8
Read-back

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

Let μ0\mu_0μ0​, μa\mu_aμa​, μm\mu_mμm​ be three probability measures on R\mathbb{R}R. These are the laws of the nominal, alien, and mixture anomaly scores. Write F0F_0F0​, FaF_aFa​, FmF_mFm​ for their cumulative distribution functions, with F(t)=μ((−∞,t])F(t) = \mu((-\infty, t])F(t)=μ((−∞,t]). Let α,α′\alpha, \alpha'α,α′ be real numbers, and let q,ε,δq, \varepsilon, \deltaq,ε,δ be real numbers. Let nnn be a natural number. The theorem assumes all of the following:

  • Mixture weights: 0<α≤α′≤10 < \alpha \le \alpha' \le 10<α≤α′≤1. Here α\alphaα is the true alien proportion. The algorithm below is run with α′\alpha'α′, not α\alphaα.
  • Mixture law: μm=(1−α) μ0+α μa\mu_m = (1-\alpha)\,\mu_0 + \alpha\,\mu_aμm​=(1−α)μ0​+αμa​. Consequently Fm=(1−α)F0+αFaF_m = (1-\alpha)F_0 + \alpha F_aFm​=(1−α)F0​+αFa​.
  • Continuity: F0F_0F0​ and FaF_aFa​ are continuous functions on R\mathbb{R}R. Nothing is assumed directly about the continuity of FmF_mFm​.
  • Admissibility: Fm(t)≤F0(t)F_m(t) \le F_0(t)Fm​(t)≤F0​(t) for every t∈Rt \in \mathbb{R}t∈R. Given the mixture identity and α>0\alpha > 0α>0, this is the same as Fa(t)≤F0(t)F_a(t) \le F_0(t)Fa​(t)≤F0​(t) for all ttt.
  • Parameters: 0<q0 < q0<q, 0<ε<1−q0 < \varepsilon < 1 - q0<ε<1−q (which in particular forces q<1q < 1q<1), and 0<δ<10 < \delta < 10<δ<1.
  • Sample size: nnn is strictly larger than the bound evaluated at α′\alpha'α′ (not at α\alphaα):
n  >  12 ln⁡ ⁣(21−1−δ)(1ε)2(2−α′α′)2.n \;>\; \frac{1}{2}\,\ln\!\left(\frac{2}{1-\sqrt{1-\delta}}\right)\left(\frac{1}{\varepsilon}\right)^{2}\left(\frac{2-\alpha'}{\alpha'}\right)^{2}.n>21​ln(1−1−δ​2​)(ε1​)2(α′2−α′​)2.

For δ∈(0,1)\delta \in (0,1)δ∈(0,1) the logarithm's argument exceeds 222, so the bound is positive and n≥1n \ge 1n≥1.

Random sample. A sample is a pair (x,y)(x, y)(x,y) with x=(x1,…,xn)∈Rnx = (x_1,\dots,x_n) \in \mathbb{R}^nx=(x1​,…,xn​)∈Rn and y=(y1,…,yn)∈Rny = (y_1,\dots,y_n) \in \mathbb{R}^ny=(y1​,…,yn​)∈Rn. Both vectors have the same length nnn. It is drawn from the product law Pn=μ0⊗n⊗μm⊗nP_n = \mu_0^{\otimes n} \otimes \mu_m^{\otimes n}Pn​=μ0⊗n​⊗μm⊗n​. So the xix_ixi​ are i.i.d. with law μ0\mu_0μ0​, the yjy_jyj​ are i.i.d. with law μm\mu_mμm​, and the two vectors are independent.

Estimates. From the sample, define the empirical CDFs

F^0(t)=1n #{i:xi≤t},F^m(t)=1n #{j:yj≤t}.\hat F_0(t) = \frac{1}{n}\,\#\{i : x_i \le t\}, \qquad \hat F_m(t) = \frac{1}{n}\,\#\{j : y_j \le t\}.F^0​(t)=n1​#{i:xi​≤t},F^m​(t)=n1​#{j:yj​≤t}.

The alien-CDF estimate, computed with weight α′\alpha'α′, is

F^a(t)=F^m(t)−(1−α′) F^0(t)α′.\hat F_a(t) = \frac{\hat F_m(t) - (1-\alpha')\,\hat F_0(t)}{\alpha'}.F^a​(t)=α′F^m​(t)−(1−α′)F^0​(t)​.

Let S={x1,…,xn}∪{y1,…,yn}S = \{x_1,\dots,x_n\} \cup \{y_1,\dots,y_n\}S={x1​,…,xn​}∪{y1​,…,yn​} be the pooled set of observed scores.

Threshold. A real number τ\tauτ is called an algorithm threshold for (x,y)(x,y)(x,y) when τ\tauτ is the largest element of {u∈S:F^a(u)≤q}\{u \in S : \hat F_a(u) \le q\}{u∈S:F^a​(u)≤q}. This means three things hold:

  • τ∈S\tau \in Sτ∈S;
  • F^a(τ)≤q\hat F_a(\tau) \le qF^a​(τ)≤q;
  • every u∈Su \in Su∈S with F^a(u)≤q\hat F_a(u) \le qF^a​(u)≤q satisfies u≤τu \le \tauu≤τ.

Such a τ\tauτ is unique when it exists. If no element of SSS satisfies F^a(u)≤q\hat F_a(u) \le qF^a​(u)≤q, no threshold exists.

Detection rate. The detection rate of τ\tauτ is μa((τ,∞))\mu_a((\tau, \infty))μa​((τ,∞)), the alien mass strictly above τ\tauτ.

Conclusion. The theorem asserts the following inequality. When the event below is not measurable, the left side is the outer measure.

Pn({(x,y):∃ τ an algorithm threshold for (x,y) with μa((τ,∞))<1−(q+ε)})  ≤  δ.P_n\Big(\big\{(x,y) : \exists\, \tau \text{ an algorithm threshold for } (x,y) \text{ with } \mu_a((\tau,\infty)) < 1 - (q+\varepsilon)\big\}\Big) \;\le\; \delta.Pn​({(x,y):∃τ an algorithm threshold for (x,y) with μa​((τ,∞))<1−(q+ε)})≤δ.

In words, the probability is at most δ\deltaδ that two things happen together: the threshold exists, and its alien detection rate is strictly below 1−q−ε1 - q - \varepsilon1−q−ε. Samples for which no threshold exists are not counted in this event.

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