Documentation

Learning.BayesRedundancy

Bayes-mixture redundancy #

The rate (3) below is the classical Bayes-mixture redundancy bound (Hutter 2001, 2005; in the discrete-class concentration form, Lattimore–Hutter–Sunehag 2013), here proved directly in the realizable-deterministic case — no Grünwald–Mehta import. The redundancy argument:

P̄(o₁:ₙ) = Σ_i 2^{−K(i)} L_i(o₁:ₙ), L_i = ∏_t q_i(oₜ | o_{<t}). Then (1) −log P̄(o₁:ₙ) ≤ K(R)·ln 2 (mixture ≥ the R-term, L_R = 1 deterministically); (2) telescoping −log P̄ = Σ_t −log P̄(oₜ | o_{<t}); (3) per step −log P̄(oₜ | o_{<t}) ≥ 2·D_H²(δ_{oₜ}, P̄(· | o_{<t})); (4) sum + average ⇒ avg_t D_H²_t ≤ K(R)·ln 2 / (2n).

This file proves the two elementary core lemmas (steps (2) and (4) are assembled below):

Model (stated explicitly) #

Everything here is elementary (Mathlib calculus + Finset); no sorry. The deep Grünwald–Mehta Theorem 22 is not used — this is the realizable-deterministic route.

(A) Log-vs-Hellinger inequality and the point-mass identity (step 3) #

theorem BayesRedundancy.log_le_hellinger {a : ℝ} (ha : 0 < a) (_ha1 : a ≤ 1) :
2 * (1 - √a) ≤ -Real.log a

Log ≥ twice the Hellinger affinity gap. 2·(1 − √a) ≤ −log a for 0 < a ≤ 1. (In fact it holds for all a > 0; a ≤ 1 records the intended domain — a = q o a probability.) Decisive step: substitute a = (√a)², so −log a = −2·log √a, and log √a ≤ √a − 1 (Real.log_le_sub_one_of_pos) gives −log √a ≥ 1 − √a.

noncomputable def BayesRedundancy.sqHellinger {α : Type u_1} [Fintype α] (p q : α → ℝ) :

Squared Hellinger distance of two finite "distributions": (1/2) Σ_x (√(p x) − √(q x))².

Equations
Instances For
    theorem BayesRedundancy.sqHellinger_nonneg {α : Type u_1} [Fintype α] (p q : α → ℝ) :

    Squared Hellinger distance is nonnegative (a half-sum of squares); no hypothesis on p, q.

    theorem BayesRedundancy.hellinger_point_mass {α : Type u_1} [Fintype α] [DecidableEq α] (q : α → ℝ) (o : α) (hq : ∀ (x : α), 0 ≤ q x) (hsum : ∑ x : α, q x = 1) :
    sqHellinger (fun (x : α) => if x = o then 1 else 0) q = 1 - √(q o)

    Point-mass identity. For a pmf q (q ≥ 0, Σ q = 1) and a point o, the squared Hellinger distance to the point mass δ_o is D_H²(δ_o, q) = 1 − √(q o). Combined with log_le_hellinger this is step (3): −log (q o) ≥ 2·(1 − √(q o)) = 2·D_H²(δ_o, q).

    theorem BayesRedundancy.neg_log_ge_two_hellinger {α : Type u_1} [Fintype α] [DecidableEq α] (q : α → ℝ) (o : α) (hq : ∀ (x : α), 0 ≤ q x) (hsum : ∑ x : α, q x = 1) (hpos : 0 < q o) :
    2 * sqHellinger (fun (x : α) => if x = o then 1 else 0) q ≤ -Real.log (q o)

    Step (3), assembled. For a pmf q and a realised symbol o, the prequential log-loss dominates twice the squared Hellinger distance to the point mass: 2·D_H²(δ_o, q) ≤ −log (q o) (when 0 < q o).

    (B) Bayes-mixture regret (step 1) #

    noncomputable def BayesRedundancy.Pbar {ι : Type u_1} [Fintype ι] (L w : ι → ℝ) :

    The (sub-)mixture likelihood P̄ = Σ_i w i · L i over a finite hypothesis class.

    Equations
    Instances For
      theorem BayesRedundancy.mixture_regret {ι : Type u_1} [Fintype ι] (L w : ι → ℝ) (R : ι) (hL : ∀ (i : ι), 0 ≤ L i) (hw : ∀ (i : ι), 0 ≤ w i) :
      w R * L R ≤ Pbar L w

      Mixture dominates a single term. w_R · L_R ≤ P̄ — the mixture is at least the true rule's contribution (one nonnegative term of the sum).

      theorem BayesRedundancy.mixture_regret_log {ι : Type u_1} [Fintype ι] (L w : ι → ℝ) (R : ι) (hL : ∀ (i : ι), 0 ≤ L i) (hw : ∀ (i : ι), 0 ≤ w i) (hwR : 0 < w R) (hLR : 0 < L R) :
      -Real.log (Pbar L w) ≤ -Real.log (w R) - Real.log (L R)

      Mixture regret (log form). −log P̄ ≤ −log w_R − log L_R. (Note: the all-nonneg hypotheses hL, hw are needed — mixture_regret requires every term ≥ 0 for P̄ ≥ w_R·L_R.)

      theorem BayesRedundancy.mixture_regret_log_realizable {ι : Type u_1} [Fintype ι] (L w : ι → ℝ) (R : ι) (hL : ∀ (i : ι), 0 ≤ L i) (hw : ∀ (i : ι), 0 ≤ w i) (hwR : 0 < w R) (hLR : L R = 1) :

      Realizable-deterministic specialisation. With L_R = 1 (the true rule predicts the data with likelihood 1), the regret is −log P̄ ≤ −log w_R.

      theorem BayesRedundancy.mixture_regret_kolmogorov {ι : Type u_1} [Fintype ι] (L w : ι → ℝ) (R : ι) (k : ℕ) (hL : ∀ (i : ι), 0 ≤ L i) (hw : ∀ (i : ι), 0 ≤ w i) (hwR : w R = 2 ^ (-↑k)) (hLR : L R = 1) :
      -Real.log (Pbar L w) ≤ ↑k * Real.log 2

      Kolmogorov-weight specialisation (step 1, final form). With the prior weight w_R = 2^{−k} (k = K(R), a Kraft sub-distribution) and L_R = 1, the mixture regret is the codelength bound −log P̄ ≤ k · log 2 = K(R) · ln 2.

      (C) Prequential telescoping + averaging ⇒ the Bayes-mixture redundancy rate (eq. 3) (steps #

      2 + 4)

      The realizable-deterministic route to rate (3), assembling steps 1 and 3.

      Prequential model (stated precisely) #

      What is proved (no sorry) #

      telescope (step 2): −log Pbarₚ n = ∑_{t<n} −log condPred t (ω t) (log-ratios telescope, Pbarₚ 0 = ∑ w = 1); cumulative_hellinger and average_hellinger_rate (step 4): combining step 3 per t with step 1, ∑_{t<n} D_H²_t ≤ K(R)·ln2 / 2, hence some step has D_H²_t ≤ K(R)·ln2 / (2n) — rate (3), proved, not assumed.

      noncomputable def BayesRedundancy.Lik {A : Type u_1} {ι : Type u_2} (q : ι → ℕ → A → ℝ) (ω : ℕ → A) (i : ι) (t : ℕ) :

      Prefix likelihood L_i(t) = ∏_{s<t} q_i(ω_s | ω_{<s}).

      Equations
      Instances For
        noncomputable def BayesRedundancy.Pbarₚ {A : Type u_1} {ι : Type u_2} [Fintype ι] (q : ι → ℕ → A → ℝ) (w : ι → ℝ) (ω : ℕ → A) (t : ℕ) :

        Mixture prefix mass P̄(t) = ∑_i w_i L_i(t).

        Equations
        Instances For
          noncomputable def BayesRedundancy.condPred {A : Type u_1} {ι : Type u_2} [Fintype ι] (q : ι → ℕ → A → ℝ) (w : ι → ℝ) (ω : ℕ → A) (t : ℕ) (x : A) :

          Conditional predictive pmf cond_t(x) = [∑_i w_i L_i(t) q_i(x)] / P̄(t).

          Equations
          Instances For
            theorem BayesRedundancy.Lik_nonneg {A : Type u_1} {ι : Type u_2} {q : ι → ℕ → A → ℝ} {ω : ℕ → A} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (i : ι) (t : ℕ) :
            0 ≤ Lik q ω i t
            theorem BayesRedundancy.Lik_realizable {A : Type u_1} {ι : Type u_2} {q : ι → ℕ → A → ℝ} {ω : ℕ → A} {R : ι} (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (t : ℕ) :
            Lik q ω R t = 1

            Realizable-deterministic: the true rule's likelihood is identically 1.

            theorem BayesRedundancy.telescope {A : Type u_1} {ι : Type u_2} [Fintype ι] {q : ι → ℕ → A → ℝ} {w : ι → ℝ} {ω : ℕ → A} {R : ι} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (hw : ∀ (i : ι), 0 ≤ w i) (hwR : 0 < w R) (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (hsumw : ∑ i : ι, w i = 1) (n : ℕ) :
            -Real.log (Pbarₚ q w ω n) = ∑ t ∈ Finset.range n, -Real.log (condPred q w ω t (ω t))

            Step 2 — telescoping. −log P̄(n) = ∑_{t<n} −log cond_t(ω_t). The per-step log-ratios log cond_t(ω_t) = log P̄(t+1) − log P̄(t) telescope; P̄(0) = ∑ w = 1 normalises.

            theorem BayesRedundancy.cumulative_hellinger {A : Type u_1} [Fintype A] [DecidableEq A] {ι : Type u_2} [Fintype ι] {q : ι → ℕ → A → ℝ} {w : ι → ℝ} {ω : ℕ → A} {R : ι} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (hw : ∀ (i : ι), 0 ≤ w i) (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (hsumw : ∑ i : ι, w i = 1) (hqsum : ∀ (i : ι) (s : ℕ), ∑ x : A, q i s x = 1) (k : ℕ) (hwR : w R = 2 ^ (-↑k)) (n : ℕ) :
            ∑ t ∈ Finset.range n, sqHellinger (fun (x : A) => if x = ω t then 1 else 0) (condPred q w ω t) ≤ ↑k * Real.log 2 / 2

            Step 4 — cumulative rate. Combining step 3 (2·D_H²_t ≤ −log cond_t(ω_t)) per step with the telescope and step 1 (−log P̄(n) ≤ K(R)·ln2), the cumulative squared Hellinger is bounded: ∑_{t<n} D_H²(δ_{ω_t}, cond_t) ≤ K(R)·ln2 / 2. This is the Bayes-mixture redundancy rate (eq. 3), proved.

            theorem BayesRedundancy.average_hellinger_rate {A : Type u_1} [Fintype A] [DecidableEq A] {ι : Type u_2} [Fintype ι] {q : ι → ℕ → A → ℝ} {w : ι → ℝ} {ω : ℕ → A} {R : ι} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (hw : ∀ (i : ι), 0 ≤ w i) (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (hsumw : ∑ i : ι, w i = 1) (hqsum : ∀ (i : ι) (s : ℕ), ∑ x : A, q i s x = 1) (k : ℕ) (hwR : w R = 2 ^ (-↑k)) (n : ℕ) (hn : 0 < n) :
            ∃ t ∈ Finset.range n, sqHellinger (fun (x : A) => if x = ω t then 1 else 0) (condPred q w ω t) ≤ ↑k * Real.log 2 / (2 * ↑n)

            Step 4 — averaged rate (3). Some step has small squared Hellinger: ∃ t < n, D_H²(δ_{ω_t}, cond_t) ≤ K(R)·ln2 / (2n) (a minimal term is below the average).

            (D) Error times: an n-free ceiling on the number of high-error steps #

            A pigeonhole on top of the cumulative bound. Since the total squared Hellinger error over the first n steps is at most K(R)·ln2 / 2 — a quantity that does not grow with n — the steps at which the predictor errs by more than a fixed ε cannot be many: there are fewer than K(R)·ln2 / (2ε) of them, uniformly in n. Beyond that finite budget of error times the mixture predicts within ε forever after; the exceptional steps may, however, occur anywhere in time.

            The bound carries no separation hypothesis — that is its entire point. On hypothesis classes where per-step separation is vacuous, and a chronological discovery rate is provably unavailable (no bound of the form "after step T all steps are good"), this counting statement is what survives: the error times are budgeted, but not scheduled.

            noncomputable def BayesRedundancy.errorTimes {A : Type u_1} [Fintype A] [DecidableEq A] {ι : Type u_2} [Fintype ι] (q : ι → ℕ → A → ℝ) (w : ι → ℝ) (ω : ℕ → A) (ε : ℝ) (n : ℕ) :

            The error times: the steps t < n at which the mixture's one-step squared Hellinger error against the realised symbol exceeds ε.

            Equations
            Instances For
              theorem BayesRedundancy.errorTimes_card_mul_le {A : Type u_1} [Fintype A] [DecidableEq A] {ι : Type u_2} [Fintype ι] {q : ι → ℕ → A → ℝ} {w : ι → ℝ} {ω : ℕ → A} {R : ι} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (hw : ∀ (i : ι), 0 ≤ w i) (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (hsumw : ∑ i : ι, w i = 1) (hqsum : ∀ (i : ι) (s : ℕ), ∑ x : A, q i s x = 1) (k : ℕ) (hwR : w R = 2 ^ (-↑k)) (ε : ℝ) (n : ℕ) :
              ↑(errorTimes q w ω ε n).card * ε ≤ ↑k * Real.log 2 / 2

              Bounded number of error times — robust form. The number of steps at which the one-step squared Hellinger error exceeds ε, times ε, is at most the description length K(R)·ln2 / 2: |{t < n : D_H²ₜ > ε}| · ε ≤ K(R)·ln2 / 2.

              The right-hand side is free of n, so the count is bounded uniformly in the horizon. Proof: every term indexed by an error time exceeds ε (pigeonhole), the omitted terms are nonnegative (sqHellinger_nonneg), and the total is bounded by the cumulative redundancy bound (step (4)). No hypothesis on ε, and — crucially — no separation hypothesis.

              theorem BayesRedundancy.errorTimes_card_le {A : Type u_1} [Fintype A] [DecidableEq A] {ι : Type u_2} [Fintype ι] {q : ι → ℕ → A → ℝ} {w : ι → ℝ} {ω : ℕ → A} {R : ι} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (hw : ∀ (i : ι), 0 ≤ w i) (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (hsumw : ∑ i : ι, w i = 1) (hqsum : ∀ (i : ι) (s : ℕ), ∑ x : A, q i s x = 1) (k : ℕ) (hwR : w R = 2 ^ (-↑k)) {ε : ℝ} (hε : 0 < ε) (n : ℕ) :
              ↑(errorTimes q w ω ε n).card ≤ ↑k * Real.log 2 / (2 * ε)

              Bounded number of error times — quantitative form. For ε > 0,

              |{t < n : D_H²(δ_{ωₜ}, condₜ) > ε}| ≤ K(R)·ln2 / (2ε),

              uniformly in n. The predictor's stock of ε-error times is finite and paid for by the description length of the true rule alone; nothing is asserted about when they occur. Carries no separation hypothesis.

              theorem BayesRedundancy.errorTimes_card_lt {A : Type u_1} [Fintype A] [DecidableEq A] {ι : Type u_2} [Fintype ι] {q : ι → ℕ → A → ℝ} {w : ι → ℝ} {ω : ℕ → A} {R : ι} (hq : ∀ (i : ι) (s : ℕ) (x : A), 0 ≤ q i s x) (hw : ∀ (i : ι), 0 ≤ w i) (hreal : ∀ (s : ℕ), q R s (ω s) = 1) (hsumw : ∑ i : ι, w i = 1) (hqsum : ∀ (i : ι) (s : ℕ), ∑ x : A, q i s x = 1) (k : ℕ) (hk : 0 < k) (hwR : w R = 2 ^ (-↑k)) {ε : ℝ} (hε : 0 < ε) (n : ℕ) :
              ↑(errorTimes q w ω ε n).card < ↑k * Real.log 2 / (2 * ε)

              Bounded number of error times — strict form. For ε > 0 and a true rule of positive description length k = K(R) > 0, the count is strictly below the budget:

              |{t < n : D_H²(δ_{ωₜ}, condₜ) > ε}| < K(R)·ln2 / (2ε),

              uniformly in n. Strictness comes from the defining inequality of the error times being strict when the set is nonempty; when it is empty the count is 0, below the positive right-hand side. Carries no separation hypothesis.

              Axiom audit #

              Each guard fails lake build if the theorem's axiom set ever drifts from the standard [propext, Classical.choice, Quot.sound].