Introduction
A transformer that learns in context receives labeled examples of a task and predicts the label of a query, with no update of its weights. A widely used explanation of this ability is Bayesian: pretraining on a distribution of tasks teaches the model to predict like the posterior of that distribution, given the examples in its context [37 , 30 ] . Prior-fitted networks are trained for exactly this purpose [25 ] . Other work shows that transformers can implement learning algorithms in context, such as least squares, ridge regression and gradient descent [17 , 2 , 36 , 3 ] , and experiments find that models trained on diverse task families leave the Bayes estimator of their pretraining prior and follow such algorithms instead [33 ] .
This paper asks what Bayes-optimality in context costs, and how the cost compares with that of learning in context at all. We answer the question in exact exponents for a natural class of discrete task families. In these families there are 2 N 2^N 2 N tasks, and the posterior is a sum over all of them. The answer turns on the recent refutations of the Exponential Time Hypothesis (ETH) by OpenAI and Anthropic [28 , 11 ] . Both count the satisfying assignments of a k k k -CNF on n n n variables in time 2 n / ( log n ) 1 / 2 − o ( 1 ) 2^{n/(\log n)^{1/2-o(1)}} 2 n / ( l o g n ) 1/2 − o ( 1 ) . The companion paper [23 ] determined what these algorithms mean for proper learning. Here they supply the upper bounds for Bayesian prediction, and the hypotheses that survive them, CNF-SETH and a length form of ETH, supply the lower bounds.
The model
A class H = { h w : w ∈ { 0 , 1 } N } \mathcal{H} = \{h_w : w \in\{0,1\}^N\} H = { h w : w ∈ { 0 , 1 } N } is κ \kappa κ -local if for each input x x x the label h w ( x ) h_w(x) h w ( x ) depends only on at most κ \kappa κ bits of w w w [23 ] . Quantized models on sparse data are local. A binarized perceptron x ↦ 1 [ ⟨ σ , x ⟩ ≥ 0 ] x \mapsto1[\langle\sigma, x\rangle\ge0] x ↦ 1 [⟨ σ , x ⟩ ≥ 0 ] with σ ∈ { ± 1 } N \sigma\in\{\pm1\}^N σ ∈ { ± 1 } N is k k k -local on k k k -sparse inputs, and so are literal disjunctions, quantized embedding models on bags of k k k tokens, and Goldreich’s random local functions [16 ] .
An episode draws a task w w w uniformly from { 0 , 1 } N \{0,1\}^N { 0 , 1 } N , inputs x 1 , … , x m + 1 x_1,\ldots,x_{m+1} x 1 , … , x m + 1 independently from a distribution D D D , and labels y i = h w ( x i ) y_i = h_w(x_i) y i = h w ( x i ) , each flipped independently with probability η < 1 / 2 \eta< 1/2 η < 1/2 . An in-context learner sees the context S = ( ( x 1 , y 1 ) , … , ( x m , y m ) ) S = ((x_1,y_1),\ldots,(x_m,y_m)) S = (( x 1 , y 1 ) , … , ( x m , y m )) and the query x m + 1 x_{m+1} x m + 1 and predicts y m + 1 y_{m+1} y m + 1 ; its risk is its error probability. The Bayes in-context predictor predicts 1 when the posterior predictive p S ( x m + 1 ) = Pr [ h w ( x m + 1 ) = 1 ∣ S ] p_S(x_{m+1}) = \Pr[h_w(x_{m+1}) = 1 \mid S] p S ( x m + 1 ) = Pr [ h w ( x m + 1 ) = 1 ∣ S ] is at least 1 / 2 1/2 1/2 . It has the least risk of all in-context learners. We call the computation of p S ( x ) p_S(x) p S ( x ) for given S S S and x x x Bayesian inference in context .
Results
Three theorems make the comparison. Figure 1 summarizes them.
Figure 1. The price of Bayes-optimality. Row 1: exact or approximate (within 1/4) Bayesian inference in context for κ \kappa κ -local families (Theorems 3.1 and 4.4); the middle window is the locality window of [23 ] . Row 2: in-context learning of Goldreich’s random local functions (Theorem 6.6 and Corollary 6.7 ). The regimes are not drawn to scale.
Theorem A (Bayesian inference in context is counting; Theorems 3.1 and 4.4). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions, under the uniform prior.
Without label noise, the posterior predictive and exact posterior samples can be computed in time poly ( N , m ) ⋅ 2 O ( κ 2 N log log N / log N ) \operatorname{poly}(N,m) \cdot2^{O(\kappa^2 N \log\log N/\sqrt{\log N})} poly ( N , m ) ⋅ 2 O ( κ 2 N l o g l o g N / l o g N ) for contexts of every length m m m . With a rational noise rate a / b a/b a / b they take time poly ( N , m , log b ) ⋅ 2 O ( κ m / log m ) \operatorname{poly}(N,m,\log b) \cdot2^{O(\kappa m/\sqrt{\log m})} poly ( N , m , log b ) ⋅ 2 O ( κm / l o g m ) for m ≥ max { κ , 2 } m \ge\max\{\kappa,2\} m ≥ max { κ , 2 } . Exact Bayesian inference in context is equivalent to # κ \#\kappa # κ -SAT, up to a factor 2 in the locality.
Under CNF-SETH, for every γ > 0 \gamma> 0 γ > 0 there is κ \kappa κ such that no algorithm approximates the posterior predictive within 1 / 4 1/4 1/4 in time O ( 2 ( 1 − γ ) N ) O(2^{(1-\gamma)N}) O ( 2 ( 1 − γ ) N ) for binarized perceptrons, or for literal disjunctions, on ( K log N ) (K\log N) ( K log N ) -sparse data. The hard contexts have polynomial size and are consistent.
Under the length form E T H C l e n \mathrm{ETH}_{\mathrm{C}}^{\mathrm{len}} ETH C len of ETH, for literal disjunctions on 3-sparse data no algorithm does so in time 2 N / ( log N ) c + θ 2^{N/(\log N)^{c+\theta}} 2 N / ( l o g N ) c + θ on contexts of O ( N 2 ) O(N^2) O ( N 2 ) examples, for every θ > 0 \theta> 0 θ > 0 . At
constant locality, Bayesian inference in context is SAT parameterized by formula length, up to polylogarithmic factors in the exponent.
Part (1) is the version-space and error-profile machinery of [23 ] applied to prediction. The lower bounds come from one gadget. For a CNF F F F , add a variable a a a to every clause as ¬ a \neg a ¬ a , and add clauses that set every other variable to 0 when a a a is false; add one free variable for a a a true. The satisfying assignments are 2 # F 2^{\#F} 2 # F assignments with a = 1 a=1 a = 1 and one with a = 0 a=0 a = 0 . As a context, this formula is consistent for every F F F , and the posterior probability that a = 1 a=1 a = 1 is 2 # F / ( 2 # F + 1 ) 2^{\#F}/(2^{\#F}+1) 2 # F / ( 2 # F + 1 ) , which is 0 or at least 2 / 3 2/3 2/3 according to whether F F F is satisfiable. So the difficulty is not consistency, which is trivial here, but the posterior.
Theorem B (Learning in context is cheap; Theorems 3.3, 5.2, 5.4 and 5.5). (1) For every class with N N N -bit descriptions and every input distribution, the Bayes risk after m m m examples is at most N / ( m + 1 ) N/(m+1) N / ( m + 1 ) , and at most η + ( 1 − 2 η ) N / ( ( 1 − h ( η ) ) ( m + 1 ) ) \eta+(1-2\eta)N/((1-h(\eta))(m+1)) η + ( 1 − 2 η ) N / (( 1 − h ( η )) ( m + 1 )) with label noise η \eta η , where h h h is the binary entropy.
(2) For binarized perceptrons and literal disjunctions on k k k -sparse data, for every k k k , a linear program is a polynomial-time in-context learner with error at most ε \varepsilon ε , with probability at least 1 − δ 1-\delta 1 − δ , from O ( ( N log ( 1 / ε ) + log ( 1 / δ ) ) / ε ) O((N\log(1/\varepsilon)+\log(1/\delta))/\varepsilon) O (( N log ( 1/ ε ) + log ( 1/ δ )) / ε ) examples, for every input distribution and every task.
(3) Every κ \kappa κ -local class is linear over D κ = ∑ j ≤ κ ( N j ) D_\kappa=\sum_{j\leq\kappa}\binom{N}{j} D κ = ∑ j ≤ κ ( j N ) local Fourier features. Regression in context learns it, also agnostically, to error ε \varepsilon ε with probability 1 − δ 1-\delta 1 − δ , in time poly ( N , D κ , 1 / ε , log ( 1 / δ ) ) \operatorname{poly}(N,D_\kappa,1/\varepsilon,\log(1/\delta)) poly ( N , D κ , 1/ ε , log ( 1/ δ )) from O ( ( D κ + log ( 1 / δ ) ) / ε 2 ) O((D_\kappa+\log(1/\delta))/\varepsilon^2) O (( D κ + log ( 1/ δ )) / ε 2 ) examples.
Parts (2) and Theorem A (2) concern the same families on the same contexts. At locality K log N K\log N K log N , the Bayes predictor needs time 2 ( 1 − γ ) N 2^{(1-\gamma)N} 2 ( 1 − γ ) N under CNF-SETH, while a linear program learns the family in polynomial time with the sample efficiency of the Bayes predictor up to a logarithmic factor. The expensive part of Bayes-optimal in-context learning is the Bayes-optimality, not the learning.
The hard contexts of Theorem A are atypical for the prior: every label in them is positive. The third theorem works in the average case, over the task distribution itself. Goldreich’s function with predicate P : { 0 , 1 } k → { 0 , 1 } P:\{0,1\}^{k}\to\{0,1\} P : { 0 , 1 } k → { 0 , 1 } maps w w w and random k k k -tuples τ 1 , … , τ m \tau_1,\ldots,\tau_m τ 1 , … , τ m of indices to the bits P ( w τ j ) P(w_{\tau_j}) P ( w τ j ) [16 App16] . As a task family, its tasks are w ∈ { 0 , 1 } N w\in\{0,1\}^{N} w ∈ { 0 , 1 } N and its inputs are k k k -tuples.
Theorem C (Random local functions; Theorem 6.6 and Corollary 6.7 ). For the random local functions of a predicate of arity k k k , under the uniform distribution on k k k -tuples:
(1) the Bayes risk is at most N / ( m + 1 ) N/(m+1) N / ( m + 1 ) , and the Bayes predictor runs in time poly ( m ) ⋅ 2 O ( N log log N / log N ) \operatorname{poly}(m)\cdot2^{O(N\log\log N/\sqrt{\log N})} poly ( m ) ⋅ 2 O ( N l o g l o g N / l o g N ) ;
(2) regression in context has risk at most ε \varepsilon ε from O ( N k log ( 1 / ε ) / ε ) O(Nk\log(1/\varepsilon)/\varepsilon) O ( N k log ( 1/ ε ) / ε ) examples, in polynomial time;
(3) every in-context learner A A A yields a distinguisher for Goldreich’s generator with m + 1 m+1 m + 1 outputs that runs in the time of A A A plus O ( m k log N ) O(mk\log N) O ( mk log N ) and has advantage exactly ∣ 1 / 2 − R m ( A ) ∣ \lvert1/2-R_m(A)\rvert ∣ 1/2 − R m ( A )∣ .
So under a local pseudorandom generator hypothesis L P R G s \mathrm{LPRGs} LPRGs with stretch N s N^s N s , no polynomial-time in-context learner has risk below 1 / 6 1/6 1/6 , for large N N N , at a context length m ( N ) ≤ ⌈ N s ⌉ − 1 m(N)\leq\lceil N^s\rceil-1 m ( N ) ≤ ⌈ N s ⌉ − 1 computable in polynomial time, although at m = ⌈ N s ⌉ − 1 m=\lceil N^s\rceil-1 m = ⌈ N s ⌉ − 1 the Bayes risk is at most N 1 − s N^{1-s} N 1 − s . Under its length form L P R G c l e n \mathrm{LPRG}^{\mathrm{len}}_c LPRG c len at linear stretch, an in-context learner needs time more than 2 N / ( log N ) c − 1 2^{N/(\log N)^{c-1}} 2 N / ( l o g N ) c − 1 to reach risk below 1 / 6 1/6 1/6 from ⌈ α N ⌉ − 1 \lceil\alpha N\rceil-1 ⌈ α N ⌉ − 1 examples, for a large enough constant α \alpha α , and the Bayes predictor of (1) reaches risk 1 / α 1/\alpha 1/ α in time 2 N / ( log N ) 1 / 2 − o ( 1 ) 2^{N/(\log N)^{1/2-o(1)}} 2 N / ( l o g N ) 1/2 − o ( 1 ) . The hypothesis L P R G c l e n \mathrm{LPRG}^{\mathrm{len}}_c LPRG c len is false for c < 1 / 2 c<1/2 c < 1/2 , by the new algorithms, and open for c ≥ 1 / 2 c\geq1/2 c ≥ 1/2 .
Consequences for transformers. A polynomial-size transformer whose weights are computed in polynomial time, for example by a polynomial-time training procedure, and that writes a chain of thought of length L L L can be simulated in time polynomial in L L L and the context. The lower bounds above therefore bound L L L from below. Under CNF-SETH, such a transformer that outputs the Bayes prediction for every context of binarized perceptrons on ( K log N ) (K\log N) ( K log N ) -sparse data needs L = 2 Ω ( N ) L=2^{\Omega(N)} L = 2 Ω ( N ) for infinitely many N N N , and under E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len already locality 3 needs L = 2 N / polylog N L=2^{N/\operatorname{polylog}N} L = 2 N / polylog N for infinitely many N N N . Under LPRGs, no such transformer with a polynomial chain of thought reaches risk below 1 / 6 1/6 1/6 on random local functions, for large N N N , at a context length m ( N ) ≤ ⌈ N s ⌉ − 1 m(N)\leq\lceil N^s\rceil-1 m ( N ) ≤ ⌈ N s ⌉ − 1 computable in polynomial time (Corollary 7.1). Regression in context, the efficient alternative of Theorem B , is the kind of algorithm that transformers are known to implement [2 , 36 , 3 ] . For discrete task families with local structure, these results separate the Bayesian explanation of in-context learning from the algorithmic one, and they are consistent with the departure from the Bayes estimator that [33 ] observe on diverse task families (§ 7 ).
Techniques
Prediction as a ratio of counts. Without noise, the posterior is uniform on the version space, and p S ( x ) pS(x) pS ( x ) is the number of consistent descriptions that label x x x positive divided by the number of all consistent descriptions. For local classes both are counts of κ \kappa κ -CNFs [23 ] . With noise, two error profiles, of the context and of the context with ( x , 1 ) (x,1) ( x , 1 ) added, determine the profile of the descriptions that label x x x positive, and the posterior predictive is a ratio of two polynomials evaluated at η / ( 1 − η ) \eta/(1-\eta) η / ( 1 − η ) .
The gadget. The two-variable construction above keeps the context consistent and moves the whole difficulty into the posterior. It needs only one more variable than the formula, and one more for the factor 2, so the width reduction of [34 , 10 ] in the form of [23 ] turns it into a 2 ( 1 − γ ) N 2^{(1-\gamma)N} 2 ( 1 − γ ) N lower bound. For the length form, fresh variables split the clauses, and clauses that force them to 0 when a a a is false keep the branch a = 0 a=0 a = 0 a single assignment.
The Bayes risk. Each mistake of the Bayes predictor at least halves the posterior mass, so there are at most N N N mistakes in any episode; this is the halving argument [5 , 24 ] with posterior weights. The Bayes risk does not increase with the context length, because the posterior predictive of a fixed query is a martingale and the error of the Bayes decision is a concave function of it. Together the two facts give N / ( m + 1 ) N/(m+1) N / ( m + 1 ) . With noise, the cumulative log-loss regret of the Bayes mixture, which is at most N N N , bounds the mistakes through a Kullback–Leibler divergence.
Local Fourier features. For each input x x x , the label h w ( x ) h_w(x) h w ( x ) is a function of the at most κ \kappa κ bits of w w w in R ( x ) R(x) R ( x ) , so its Fourier expansion has at most 2 κ 2^\kappa 2 κ terms, all of degree at most κ \kappa κ . Hence h w ( x ) = ⟨ Φ ( w ) , Ψ ( x ) ⟩ h_w(x) = \langle\Phi(w), \Psi(x) \rangle h w ( x ) = ⟨ Φ ( w ) , Ψ ( x )⟩ with Φ ( w ) ∈ { ± 1 } D κ \Phi(w) \in\{\pm1\}^{D_\kappa} Φ ( w ) ∈ { ± 1 } D κ , and the class is a linear class over the features Ψ \Psi Ψ . Linear algebra learns it in the realizable case, and ℓ 1 \ell_1 ℓ 1 regression [20 ] in the agnostic case. For binarized perceptrons and literal disjunctions a halfspace in the original coordinates suffices.
Next-bit prediction. An in-context learner for random local functions predicts the last output of Goldreich’s generator from the earlier outputs. By Yao’s argument [38 ] , its advantage over 1 / 2 1/2 1/2 is the advantage of a distinguisher.
What is new
The realizable Bayes risk bound is classical [18 ] , the linearization is the Fourier expansion of a local function, and next-bit prediction is Yao’s. The posterior algorithms use only the statements of [23 ] , which in turn use the refutations [28 , 11 ] as black boxes. New are the gadget and the fine-grained lower bounds for Bayesian inference in context, the comparison with polynomial-time learning of the same families on the same contexts, the noisy Bayes risk bound in this form, the sample bound for regression on local Fourier features, the three regimes for random local functions with the hypothesis L P R G c l e n \mathrm{LPRG}^{\mathrm{len}}_c LPRG c len and its refutation below rate 1 / 2 1/2 1/2 , and the consequences for transformers.
Organization
Section 2 fixes the model and imports the results of [23 ] . Section 3 gives the algorithms for Bayesian inference in context and the bound on the Bayes risk. Section 4 proves the lower bounds. Section 5 gives the efficient in-context learners. Section 6 treats random local functions, and Section 7 draws the consequences for transformers. Section 8 discusses related work, and Section 9 lists open problems. The appendix contains all proofs in structured form.
AI disclosure. This paper was written with Claude Opus 5.5 (Anthropic), working as an agent in Claude Code. The author asked Claude to propose questions that build on [23 ] . Claude chose one of them, proved the results and wrote the text. The gadgets, the linearization and the risk bounds were checked by brute force on small instances, and separate Claude agents checked the citations and audited the proofs. The author is responsible for the content.
Preliminaries
This section fixes the model of in-context learning, imports the results of [23 ] that we use, and states the hypotheses that survive the refutation of ETH.
Local classes
We write log for log 2 \log_2 log 2 , [ n ] [n] [ n ] for { 1 , … , n } \{1,\ldots,n\} { 1 , … , n } , and w ∣ R w|_R w ∣ R for the restriction of w ∈ { 0 , 1 } N w \in\{0,1\}^N w ∈ { 0 , 1 } N to R ⊆ [ N ] R \subseteq[N] R ⊆ [ N ] . A clause is a nonempty set of literals, its width is its size, a C N F CNF C N F is a finite set of clauses, and a k k k -C N F CNF C N F has clauses of width at most k k k . The length of a C N F CNF C N F is its number of literal occurrences, and # F \#F # F is the number of satisfying assignments of F F F on its declared variables. Time is measured in the word-RAM model.
Definition 2.1 (Local class [23 Definition 2.2] ). Let N , κ ≥ 1 N,\kappa\ge1 N , κ ≥ 1 . A κ \kappa κ -local class H \mathcal{H} H on a domain X \mathcal{X} X assigns to every x ∈ X x \in\mathcal{X} x ∈ X a set R ( x ) ⊆ [ N ] R(x) \subseteq[N] R ( x ) ⊆ [ N ] with ∣ R ( x ) ∣ ≤ κ |R(x)| \le\kappa ∣ R ( x ) ∣ ≤ κ and a predicate f x : { 0 , 1 } R ( x ) → { 0 , 1 } f_x:\{0,1\}^{R(x)} \to\{0,1\} f x : { 0 , 1 } R ( x ) → { 0 , 1 } , both computable in time polynomial in N N N and the length of x x x . A description w ∈ { 0 , 1 } N w \in\{0,1\}^N w ∈ { 0 , 1 } N defines h w ( x ) = f x ( w ∣ R ( x ) ) , h_w(x) = f_x(w|_{R(x)}), h w ( x ) = f x ( w ∣ R ( x ) ) , and H = { h w : w ∈ { 0 , 1 } N } \mathcal{H} = \{h_w : w \in\{0,1\}^N\} H = { h w : w ∈ { 0 , 1 } N } .
Example 2.2 ([23 Example 2.3] ). Let X k = { x ∈ { − 1 , 0 , 1 } n : ∣ supp ( x ) ∣ ≤ k } \mathcal{X}_k = \{x \in\{-1,0,1\}^n : |\operatorname{supp}(x)| \le k\} X k = { x ∈ { − 1 , 0 , 1 } n : ∣ supp ( x ) ∣ ≤ k } , and describe a sign vector σ ∈ { ± 1 } n \sigma\in\{\pm1\}^n σ ∈ { ± 1 } n by the bits w i = ( 1 + σ i ) / 2 w_i = (1+\sigma_i)/2 w i = ( 1 + σ i ) /2 , so that N = n N=n N = n .
(a) Literal disjunctions L D k \mathrm{LD}_k LD k on X k \mathcal{X}_k X k : h σ ( x ) = 1 h_\sigma(x)=1 h σ ( x ) = 1 if and only if x i = σ i x_i=\sigma_i x i = σ i for some i ∈ supp ( x ) i \in\operatorname{supp}(x) i ∈ supp ( x ) . A positive example x x x is the clause ⋁ i ∈ supp ( x ) ( σ i = x i ) \bigvee_{i\in\operatorname{supp}(x)}(\sigma_i=x_i) ⋁ i ∈ supp ( x ) ( σ i = x i ) , so a sample of positive examples is a k k k -C N F CNF C N F .
(b) Binarized perceptrons B P k \mathrm{BP}_k BP k on X k \mathcal{X}_k X k : h σ ( x ) = 1 [ ⟨ σ , x ⟩ ≥ 0 ] h_\sigma(x)=\mathbf{1}[\langle\sigma,x\rangle\ge0] h σ ( x ) = 1 [⟨ σ , x ⟩ ≥ 0 ] .
Both are k k k -local with R ( x ) = supp ( x ) R(x)=\operatorname{supp}(x) R ( x ) = supp ( x ) . Random local functions are introduced in § 6 .
A sample or context is a sequence S = ( ( x 1 , y 1 ) , … , ( x m , y m ) ) S=((x_1,y_1),\ldots,(x_m,y_m)) S = (( x 1 , y 1 ) , … , ( x m , y m )) of labeled inputs. Its version space is VS ( S ) = { w : h w ( x i ) = y i for all i } \operatorname{VS}(S)=\{w:h_w(x_i)=y_i\text{ for all }i\} VS ( S ) = { w : h w ( x i ) = y i for all i } , the error count of w w w is e S ( w ) = ∣ { i : h w ( x i ) ≠ y i } ∣ e_S(w)=|\{i:h_w(x_i)\ne y_i\}| e S ( w ) = ∣ { i : h w ( x i ) = y i } ∣ , and the error profile is E S ( V ) = ∑ w ∈ { 0 , 1 } N V e S ( w ) E_S(V)=\sum_{w\in\{0,1\}^N}V^{e_S(w)} E S ( V ) = ∑ w ∈ { 0 , 1 } N V e S ( w ) , a polynomial of degree at most m m m whose coefficient of V j V^j V j counts the descriptions with exactly j j j errors.
In-context learning
Definition 2.3 (Episodes, learners and risk). A task family is a class H = { h w : w ∈ { 0 , 1 } N } \mathcal{H}=\{h_w:w\in\{0,1\}^N\} H = { h w : w ∈ { 0 , 1 } N } on X \mathcal{X} X together with a distribution D \mathcal{D} D on X \mathcal{X} X ; the noise rate is some η ∈ [ 0 , 1 / 2 ) \eta\in[0,1/2) η ∈ [ 0 , 1/2 ) . An episode of length m m m draws a task w w w uniformly from { 0 , 1 } N \{0,1\}^N { 0 , 1 } N , inputs x 1 , … , x m + 1 x_1,\ldots,x_{m+1} x 1 , … , x m + 1 independently from D \mathcal{D} D , and independent bits ξ 1 , … , ξ m + 1 \xi_1,\ldots,\xi_{m+1} ξ 1 , … , ξ m + 1 with Pr [ ξ i = 1 ] = η \Pr[\xi_i=1]=\eta Pr [ ξ i = 1 ] = η , and sets y i = h w ( x i ) ⊕ ξ i y_i=h_w(x_i)\oplus\xi_i y i = h w ( x i ) ⊕ ξ i . Its context is S = ( ( x i , y i ) ) i ≤ m S=((x_i,y_i))_{i\le m} S = (( x i , y i ) ) i ≤ m , its query is x m + 1 x_{m+1} x m + 1 and its target is y m + 1 y_{m+1} y m + 1 . An in-context learner is an algorithm A A A that maps a context and a query to a label, possibly using random bits. Its risk at context length m m m is R m ( A ) = Pr [ A ( S , x m + 1 ) ≠ y m + 1 ] R_m(A)=\Pr[A(S,x_{m+1})\ne y_{m+1}] R m ( A ) = Pr [ A ( S , x m + 1 ) = y m + 1 ] , the probability over the episode and the random bits of A A A .
The prior is uniform on descriptions. For quantized models this is the uniform prior on parameters; the induced prior on functions need not be uniform. Let μ = η / ( 1 − η ) \mu=\eta/(1-\eta) μ = η / ( 1 − η ) , with 0 0 = 1 0^0=1 0 0 = 1 .
Definition 2.4 (Posterior, Bayes and Gibbs predictors). For a context S S S , let ω S ( w ) = μ e S ( w ) \omega_S(w)=\mu^{e_S(w)} ω S ( w ) = μ e S ( w ) and Z S = ∑ w ω S ( w ) Z_S=\sum_w\omega_S(w) Z S = ∑ w ω S ( w ) . If Z S > 0 Z_S>0 Z S > 0 , the posterior is π S ( w ) = ω S ( w ) / Z S \pi_S(w)=\omega_S(w)/Z_S π S ( w ) = ω S ( w ) / Z S , and the posterior predictive of a query x x x is p S ( x ) = ∑ w : h w ( x ) = 1 π S ( w ) p_S(x)=\sum_{w:h_w(x)=1}\pi_S(w) p S ( x ) = ∑ w : h w ( x ) = 1 π S ( w ) . The Bayes in-context predictor is B ( S , x ) = 1 [ p S ( x ) ≥ 1 / 2 ] B(S,x)=\mathbf{1}[p_S(x)\ge1/2] B ( S , x ) = 1 [ p S ( x ) ≥ 1/2 ] . The Gibbs in-context predictor G ( S , x ) G(S,x) G ( S , x ) draws w w w from π S \pi_S π S and outputs h w ( x ) h_w(x) h w ( x ) . Bayesian inference in context is the problem of computing p S ( x ) p_S(x) p S ( x ) from S S S and x x x , and β \beta β -approximate Bayesian inference in context asks for a number within β \beta β of p S ( x ) p_S(x) p S ( x ) .
For η = 0 \eta=0 η = 0 the weight ω S \omega_S ω S is the indicator of VS ( S ) \operatorname{VS}(S) VS ( S ) , so Z S > 0 Z_S>0 Z S > 0 exactly when the context is consistent, and the posterior is uniform on the version space. Contexts that occur in episodes have Z S > 0 Z_S>0 Z S > 0 . In an episode, π S \pi_S π S is the conditional distribution of the task given the context, by Bayes’ rule, and the conditional probability that the target is 1 is
p ^ S ( x ) = ( 1 − η ) p S ( x ) + η ( 1 − p S ( x ) ) . (1) \widehat{p}_S(x)=(1-\eta)p_S(x)+\eta(1-p_S(x)). \tag*{(1)} p S ( x ) = ( 1 − η ) p S ( x ) + η ( 1 − p S ( x )) . (1)
Since η < 1 / 2 \eta< 1/2 η < 1/2 , the predictor B outputs the more likely target. Hence it minimizes the risk.
Lemma 2.5 (Bayes decision rule). For every task family, noise rate and context length m m m , every in-context learner A A A has R m ( A ) ≥ R m ( B ) R_m(A) \ge R_m(B) R m ( A ) ≥ R m ( B ) , and R m ( B ) = E [ min { p ^ S ( x m + 1 ) , 1 − p ^ S ( x m + 1 ) } ] R_m(B) = \mathbb{E}[\min\{\hat{p}_S(x_{m+1}),1-\hat{p}_S(x_{m+1})\}] R m ( B ) = E [ min { p ^ S ( x m + 1 ) , 1 − p ^ S ( x m + 1 )}] .
We write R m ∗ = R m ( B ) R_m^* = R_m(B) R m ∗ = R m ( B ) for the Bayes risk . We also use the worst-case guarantee of learning theory.
Definition 2.6 (PAC in-context learners). An in-context learner A A A for H \mathcal{H} H is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m m m examples if for every distribution D \mathcal{D} D on X \mathcal{X} X and every w w w , with probability at least 1 − δ 1-\delta 1 − δ over a context of m m m independent examples ( x , h w ( x ) ) (x,h_w(x)) ( x , h w ( x )) with x ∼ D x \sim\mathcal{D} x ∼ D and over the random bits of A A A , it satisfies Pr x ∼ D [ A ( S , x ) ≠ h w ( x ) ] ≤ ε \Pr_{x\sim\mathcal{D}}[A(S,x) \ne h_w(x)] \le\varepsilon Pr x ∼ D [ A ( S , x ) = h w ( x )] ≤ ε . It is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -agnostic from m m m examples if for every distribution D ′ \mathcal{D}' D ′ on X × { 0 , 1 } \mathcal{X} \times\{0,1\} X × { 0 , 1 } , with probability at least 1 − δ 1-\delta 1 − δ over a context of m m m independent examples from D ′ \mathcal{D}' D ′ , it satisfies Pr ( x , y ) ∼ D ′ [ A ( S , x ) ≠ y ] ≤ O P T + ε \Pr_{(x,y)\sim\mathcal{D}'}[A(S,x) \ne y] \le\mathrm{OPT}+\varepsilon Pr ( x , y ) ∼ D ′ [ A ( S , x ) = y ] ≤ OPT + ε , where O P T = min w Pr ( x , y ) ∼ D ′ [ h w ( x ) ≠ y ] \mathrm{OPT}=\min_w\Pr_{(x,y)\sim\mathcal{D}'}[h_w(x)\ne y] OPT = min w Pr ( x , y ) ∼ D ′ [ h w ( x ) = y ] .
An ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC learner has risk at most ε + δ \varepsilon+\delta ε + δ in every noiseless episode, for every input distribution, whatever the prior. An ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -agnostic learner has risk at most η + ε + δ \eta+\varepsilon+\delta η + ε + δ in every episode with noise rate η \eta η , because for each fixed task the error of h w h_w h w itself is η \eta η .
Imported results
We use the refutations of ETH [28 , 11 ] only through the following statements of [23 ] . Let T κ ( N ) = min { 2 N , 2 C 1 κ 2 g ( N ) } T_\kappa(N)=\min\{2^N,2^{C_1\kappa^2g(N)}\} T κ ( N ) = min { 2 N , 2 C 1 κ 2 g ( N ) } , where g ( N ) = N log log N / log N g(N)=N\log\log N/\sqrt{\log N} g ( N ) = N log log N / log N for N ≥ 16 N\ge16 N ≥ 16 , g ( N ) = 1 g(N)=1 g ( N ) = 1 for smaller N N N , and C 1 C_1 C 1 is the absolute constant of the counting algorithm of [11 Main Theorem and Corollary 11] .
Imported Theorem 2.7 (Version spaces are κ \kappa κ -CNFs [23 Lemma 3.1] ). Given a sample S S S of size m m m for a κ \kappa κ -local class with N N N -bit descriptions, one can compute in time poly ( N , m ) ⋅ 2 κ \operatorname{poly}(N,m)\cdot2^\kappa poly ( N , m ) ⋅ 2 κ a κ \kappa κ -CNF Γ S \Gamma_S Γ S on the variables w 1 , … , w N w_1,\ldots,w_N w 1 , … , w N with at most m 2 κ m2^\kappa m 2 κ clauses such that VS ( S ) \operatorname{VS}(S) VS ( S ) is the set of satisfying assignments of Γ S \Gamma_S Γ S .
Imported Theorem 2.8 (Counting and sampling version spaces [23 Theorem 3.2] ). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions, and let S S S be a sample of size m m m . Then ∣ VS ( S ) ∣ |\operatorname{VS}(S)| ∣ VS ( S ) ∣ can be computed deterministically in time poly ( N , m ) ⋅ 2 κ ⋅ T κ ( N ) \operatorname{poly}(N,m)\cdot2^\kappa\cdot T_\kappa(N) poly ( N , m ) ⋅ 2 κ ⋅ T κ ( N ) . If VS ( S ) ≠ ∅ \operatorname{VS}(S)\ne\varnothing VS ( S ) = ∅ , a uniformly random element of VS ( S ) \operatorname{VS}(S) VS ( S ) can be generated exactly in the same time, given uniform random integers in { 0 , … , M − 1 } \{0,\ldots,M-1\} { 0 , … , M − 1 } at cost poly ( log M ) \operatorname{poly}(\log M) poly ( log M ) .
Imported Theorem 2.9 (Error profiles [23 Lemma 2.8] ). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions, let S S S be a sample of size m m m , and let s = max { 4 κ m , m + 1 , κ 2 } s=\max\{4\kappa m,m+1,\kappa^2\} s = max { 4 κm , m + 1 , κ 2 } . The error profile E S E_S E S can be computed exactly and deterministically in time poly ( N , m ) ⋅ 2 O ( s / log s ) \operatorname{poly}(N,m)\cdot2^{O(s/\sqrt{\log s})} poly ( N , m ) ⋅ 2 O ( s / l o g s ) .
Imported Theorem 2.10 (Exponential mechanism [23 Theorem 4.6] ). In the setting of Imported Theorem 2.9, let λ > 0 \lambda>0 λ > 0 . One can sample w w w with probability proportional to e − λ e S ( w ) e^{-\lambda e_S(w)} e − λ e S ( w ) in time poly ( N , m ) ⋅ 2 O ( s / log s ) \operatorname{poly}(N,m)\cdot2^{O(s/\sqrt{\log s})} poly ( N , m ) ⋅ 2 O ( s / l o g s ) , given exact samples from explicitly given distributions on { 0 , … , m } \{0,\ldots,m\} { 0 , … , m } . Without exact sampling, the output distribution is within statistical distance ν \nu ν of the target for any ν ≥ 2 − poly ( N , m ) \nu\ge2^{-\operatorname{poly}(N,m)} ν ≥ 2 − poly ( N , m ) , in the same time.
Imported Theorem 2.10 is [23 Theorem 4.6] with privacy parameter 2 λ 2\lambda 2 λ , since the score there is m m m times the empirical error, that is e S ( w ) e_S(w) e S ( w ) . Its algorithm samples an error count j j j with probability proportional to c j e − λ j c_j e^{-\lambda j} c j e − λj , where c j c_j c j is the coefficient of V j V^j V j in E S E_S E S , and then a uniform description with exactly j j j errors.
Imported Theorem 2.11 (Perceptron gadget [23 Lemma 3.3] ). Let k ≥ 1 k \ge1 k ≥ 1 and p = max { 1 , k − 2 } p = \max\{1,k-2\} p = max { 1 , k − 2 } . Given a k k k -CNF Γ \Gamma Γ on z 1 , … , z n z_1,\ldots,z_n z 1 , … , z n with M M M clauses, none of them tautological, one can compute in polynomial time a sample S Γ S_\Gamma S Γ of M + p M+p M + p examples in { − 1 , 0 , 1 } n + p \{-1,0,1\}^{n+p} { − 1 , 0 , 1 } n + p , all labeled 1 1 1 and each with support of size at most max { 2 k − 2 , 2 } \max\{2k-2,2\} max { 2 k − 2 , 2 } , such that a sign vector σ \sigma σ is consistent with S Γ S_\Gamma S Γ as a binarized perceptron if and only if σ n + 1 = ⋯ = σ n + p = 1 \sigma_{n+1}=\cdots=\sigma_{n+p}=1 σ n + 1 = ⋯ = σ n + p = 1 and the assignment z i = 1 [ σ i = 1 ] z_i=1[\sigma_i=1] z i = 1 [ σ i = 1 ] satisfies Γ \Gamma Γ .
Imported Theorem 2.12 (Width reduction [23 Corollary 3.6] ). Under Hypothesis 2.14, for every γ ∈ ( 0 , 1 ) \gamma\in(0,1) γ ∈ ( 0 , 1 ) there are K ′ , c ′ K',c' K ′ , c ′ such that k k k -SAT with k ≤ K ′ log n k \le K'\log n k ≤ K ′ log n cannot be solved in time O ( 2 ( 1 − γ ) n ) O(2^{(1-\gamma)n}) O ( 2 ( 1 − γ ) n ) by a randomized algorithm with error probability at most 1 / 3 1/3 1/3 , even on instances with at most n c ′ n^{c'} n c ′ clauses. Under Hypothesis 2.15, there are K ′ , c ′ , ρ > 0 K',c',\rho>0 K ′ , c ′ , ρ > 0 such that k k k -SAT with k ≤ K ′ log n k \le K'\log n k ≤ K ′ log n and at most n c ′ n^{c'} n c ′ clauses cannot be solved in time O ( 2 ρ n ) O(2^{\rho n}) O ( 2 ρ n ) .
We also use the standard sample sizes for classes of VC dimension d d d , finite or infinite [4 , 35 ] . There are absolute constants C 0 , C B ≥ 1 C_0,C_B \ge1 C 0 , C B ≥ 1 such that, with probability at least 1 − δ 1-\delta 1 − δ over m m m independent examples, the following hold.
Imported Theorem 2.13 (Sample sizes). Let G \mathcal{G} G be a class of VC dimension d ≥ 1 d \ge1 d ≥ 1 .
(a) If m ≥ m V C ( d , ε , δ ) : = C B ( d log ( 2 / ε ) + log ( 2 / δ ) ) / ε m \ge m_{\mathrm{VC}}(d,\varepsilon,\delta):=C_B(d\log(2/\varepsilon)+\log(2/\delta))/\varepsilon m ≥ m VC ( d , ε , δ ) := C B ( d log ( 2/ ε ) + log ( 2/ δ )) / ε and the examples are labeled by some g ∗ ∈ G g^* \in\mathcal{G} g ∗ ∈ G , every g ∈ G g \in\mathcal{G} g ∈ G consistent with them has error at most ε \varepsilon ε .
(b) If m ≥ m U C ( d , ε , δ ) : = C 0 ( d + ln ( 1 / δ ) ) / ε 2 m \ge m_{\mathrm{UC}}(d,\varepsilon,\delta):=C_0(d+\ln(1/\delta))/\varepsilon^2 m ≥ m UC ( d , ε , δ ) := C 0 ( d + ln ( 1/ δ )) / ε 2 , every g ∈ G g \in\mathcal{G} g ∈ G has empirical error within ε / 2 \varepsilon/2 ε /2 of its error.
Hypotheses
The new algorithms need bounded clause width or linear total size, and the following hypotheses concern the opposite regime [23 ] . All are stated for randomized algorithms with error probability at most 1 / 3 1/3 1/3 .
Hypothesis 2.14 (CNF-SETH). For every γ > 0 \gamma>0 γ > 0 there is c > 0 c>0 c > 0 such that satisfiability of CNF formulas with n n n variables and at most n c n^c n c clauses, of arbitrary width, cannot be decided in time O ( 2 ( 1 − γ ) n ) O(2^{(1-\gamma)n}) O ( 2 ( 1 − γ ) n ) .
Hypothesis 2.15 (CNF-ETH). There are c , ρ > 0 c,\rho>0 c , ρ > 0 such that satisfiability of CNF formulas with n n n variables and at most n c n^c n c clauses cannot be decided in time O ( 2 ρ n ) O(2^{\rho n}) O ( 2 ρ n ) .
Hypothesis 2.16 (Length form of ETH at rate C C C [23 Hypothesis 2.14] ). For C > 0 C>0 C > 0 , the hypothesis E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len states that no randomized algorithm decides satisfiability of every CNF formula of length L L L in time 2 L / ( log L ) C 2^{L/(\log L)^C} 2 L / ( l o g L ) C , for all sufficiently large L L L .
The new algorithms decide SAT of length L L L in time 2 O ( L / log L ) 2^{O(L/\sqrt{\log L})} 2 O ( L / l o g L ) , so E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len is false for C < 1 / 2 C<1/2 C < 1/2 and open for C ≥ 1 / 2 C\ge1/2 C ≥ 1/2 [23 ] . It is the instance with an explicit rate of the polylog-slack hypotheses of [12 ] . CNF-SETH and CNF-ETH are not contradicted by the new algorithms, and by width reduction their hard instances may be taken to have width O ( log n ) O(\log n) O ( log n ) (Imported Theorem 2.12). The local pseudorandom generator hypotheses of § 6 complete the list.
Bayesian inference in context
This section shows that the Bayes and Gibbs in-context predictors of a local class are counting problems, and that they are statistically efficient for every class with short descriptions.
Algorithms
Without noise, the posterior is uniform on the version space, and the posterior predictive is a ratio of two version-space sizes. With noise, it is a ratio of two weighted sums, and two error profiles determine both.
Theorem 3.1 (Bayesian inference in context for local classes). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions, let S S S be a context of size m m m , and let x x x be a query.
(a) Without noise. If VS ( S ) ≠ ∅ \operatorname{VS}(S) \ne\varnothing VS ( S ) = ∅ , then p S ( x ) p_S(x) p S ( x ) and B ( S , x ) B(S,x) B ( S , x ) can be computed exactly and deterministically in time poly ( N , m ) ⋅ 2 κ T κ ( N ) \operatorname{poly}(N,m) \cdot2^{\kappa} T_{\kappa}(N) poly ( N , m ) ⋅ 2 κ T κ ( N ) , and the Gibbs predictor can be run exactly in the same time, given uniform random integers. This is poly ( m ) ⋅ 2 o ( N ) \operatorname{poly}(m) \cdot2^{o(N)} poly ( m ) ⋅ 2 o ( N ) when κ = o ( ( log N ) 1 / 4 / log log N ) \kappa= o((\log N)^{1/4}/\sqrt{\log\log N}) κ = o (( log N ) 1/4 / log log N ) .
(b) With noise. Let η = a / b \eta= a/b η = a / b for integers 0 < a 0 < a 0 < a , 2 a < b 2a < b 2 a < b , and let s = max { 4 κ ( m + 1 ) , m + 2 , κ 2 } s = \max\{4\kappa(m+1),m+2,\kappa^2\} s = max { 4 κ ( m + 1 ) , m + 2 , κ 2 } . Then p S ( x ) p_S(x) p S ( x ) and B ( S , x ) B(S,x) B ( S , x ) can be computed exactly in time poly ( N , m , log b ) ⋅ 2 O ( s / log s ) \operatorname{poly}(N,m,\log b) \cdot2^{O(s/\sqrt{\log s})} poly ( N , m , log b ) ⋅ 2 O ( s / l o g s ) , and the Gibbs predictor can be run in the same time, exactly given exact samples from explicitly given distributions on { 0 , … , m } \{0,\ldots,m\} { 0 , … , m } , and otherwise within statistical distance ν \nu ν for any ν ≥ 2 − poly ( N , m ) \nu\ge2^{-\operatorname{poly}(N,m)} ν ≥ 2 − poly ( N , m ) . For m ≥ max { κ , 2 } m \ge\max\{\kappa,2\} m ≥ max { κ , 2 } the time is poly ( N , m , log b ) ⋅ 2 O ( κ m / log m ) \operatorname{poly}(N,m,\log b) \cdot2^{O(\kappa m/\sqrt{\log m})} poly ( N , m , log b ) ⋅ 2 O ( κm / l o g m ) .
Proof sketch. For (a), append the example ( x , 1 ) (x,1) ( x , 1 ) to S S S to obtain S + S^{+} S + . Then p S ( x ) = ∣ VS ( S + ) ∣ / ∣ VS ( S ) ∣ p_S(x)=|\operatorname{VS}(S^{+})|/|\operatorname{VS}(S)| p S ( x ) = ∣ VS ( S + ) ∣/∣ VS ( S ) ∣ , and Imported Theorem 2.8 computes both counts; Gibbs sampling is uniform sampling from VS ( S ) \operatorname{VS}(S) VS ( S ) . For (b), write a j a_j a j and b j b_j b j for the numbers of descriptions with e S ( w ) = j e_S(w)=j e S ( w ) = j and h w ( x ) = 1 h_w(x)=1 h w ( x ) = 1 , respectively h w ( x ) = 0 h_w(x)=0 h w ( x ) = 0 . The coefficient of V j V^j V j is a j + b j a_j+b_j a j + b j in E S E_S E S and a j + b j − 1 a_j+b_{j-1} a j + b j − 1 in E S + E_{S^{+}} E S + , so the two profiles of Imported Theorem 2.9 determine all a j a_j a j and b j b_j b j recursively, starting from b − 1 = 0 b_{-1}=0 b − 1 = 0 . Then p S ( x ) = ∑ j a j μ j / ∑ j ( a j + b j ) μ j p_S(x)=\sum_j a_j\mu^j/\sum_j(a_j+b_j)\mu^j p S ( x ) = ∑ j a j μ j / ∑ j ( a j + b j ) μ j . Gibbs sampling is Imported Theorem 2.10 with e − λ = μ e^{-\lambda}=\mu e − λ = μ (Section A).
The same reduction runs in the other direction: § 4 turns # κ \#\kappa # κ -SAT into exact Bayesian inference in context. For the upper bound, any algorithm for # κ \#\kappa # κ -SAT can replace Imported Theorem 2.8.
Corollary 3.2 (Bayesian inference from counting). If # κ \#\kappa # κ -SAT on N N N variables with M M M clauses can be solved in time T ( N , M ) T(N,M) T ( N , M ) , with T T T nondecreasing, then noiseless Bayesian inference in context for every κ \kappa κ -local class with N N N -bit descriptions takes time 2 T ( N , ( m + 1 ) 2 κ ) + poly ( N , m ) ⋅ 2 κ 2T(N,(m+1)2^\kappa)+\operatorname{poly}(N,m)\cdot2^\kappa 2 T ( N , ( m + 1 ) 2 κ ) + poly ( N , m ) ⋅ 2 κ on consistent contexts of size m m m .
Proof sketch. By Imported Theorem 2.7, VS ( S ) \operatorname{VS}(S) VS ( S ) and VS ( S + ) \operatorname{VS}(S^{+}) VS ( S + ) are the solution sets of κ \kappa κ -CNFs with at most ( m + 1 ) 2 κ (m+1)2^\kappa ( m + 1 ) 2 κ clauses (Section A).
The Bayes risk
The Bayes in-context predictor learns every class with short descriptions from few examples. The bound needs no locality.
Theorem 3.3 (Bayes risk). Let H = { h w : w ∈ { 0 , 1 } N } \mathcal{H}=\{h_w:w\in\{0,1\}^{N}\} H = { h w : w ∈ { 0 , 1 } N } be any class, D \mathcal{D} D any input distribution and η ∈ [ 0 , 1 / 2 ) \eta\in[0,1/2) η ∈ [ 0 , 1/2 ) the noise rate. Let h ( η ) = − η log η − ( 1 − η ) log ( 1 − η ) h(\eta)=-\eta\log\eta-(1-\eta)\log(1-\eta) h ( η ) = − η log η − ( 1 − η ) log ( 1 − η ) , with h ( 0 ) = 0 h(0)=0 h ( 0 ) = 0 .
(a) R m + 1 ∗ ≤ R m ∗ R^*_{m+1}\le R^*_m R m + 1 ∗ ≤ R m ∗ for every m ≥ 0 m\ge0 m ≥ 0 .
(b) R m ∗ ≤ η + ( 1 − 2 η ) N ( 1 − h ( η ) ) ( m + 1 ) R^*_m\le\eta+\frac{(1-2\eta)N}{(1-h(\eta))(m+1)} R m ∗ ≤ η + ( 1 − h ( η )) ( m + 1 ) ( 1 − 2 η ) N for every m ≥ 0 m\ge0 m ≥ 0 . In particular, without noise R m ∗ ≤ N / ( m + 1 ) R^*_m\le N/(m+1) R m ∗ ≤ N / ( m + 1 ) .
(c) Without noise, the Gibbs predictor has risk at most 2 R m ∗ ≤ 2 N / ( m + 1 ) 2R^*_m\le2N/(m+1) 2 R m ∗ ≤ 2 N / ( m + 1 ) .
Proof sketch. For (a), fix the query. Its posterior predictive p ^ \hat{p} p ^ of (1) is a martingale as examples are added to the context, and the Bayes error min { p ^ , 1 − p ^ } \min\{\hat{p},1-\hat{p}\} min { p ^ , 1 − p ^ } is a concave function of p ^ \hat{p} p ^ ; Jensen’s inequality gives the claim. For (b) without noise, run the Bayes predictor on the examples of an episode in order. Each mistake leaves at most half of the version space, which starts with 2 N 2^N 2 N elements and always contains the task, so every episode has at most N N N mistakes among its first m + 1 m+1 m + 1 rounds. The expected number of these mistakes is ∑ t = 0 m R t ∗ ≥ ( m + 1 ) R m ∗ \sum_{t=0}^{m}R_t^* \ge(m+1)R_m^* ∑ t = 0 m R t ∗ ≥ ( m + 1 ) R m ∗ by (a). With noise, the log-loss regret of the Bayes mixture against the task is at most N N N bits, so the expected Kullback–Leibler divergences between the true label distribution and the predictive sum to at most N N N . A mistake of B against h w ( x ) h_w(x) h w ( x ) costs at least 1 − h ( η ) 1-\mathrm{h}(\eta) 1 − h ( η ) bits of divergence and adds 1 − 2 η 1-2\eta 1 − 2 η to the error. For (c), the Gibbs error at a query is 2 p ( 1 − p ) ≤ 2 min { p , 1 − p } 2p(1-p) \le2\min\{p,1-p\} 2 p ( 1 − p ) ≤ 2 min { p , 1 − p } (Section A). □
Without noise, the halving argument behind (b) is that of [5 , 24 ] , with posterior weights, and bounds of this kind on the Bayes and Gibbs learning curves go back to Haussler, Kearns and Schapire [18 ] . So the Bayes in-context predictor has risk ε \varepsilon ε from N / ε N/\varepsilon N / ε examples, for every class with N N N -bit descriptions and every input distribution, and Theorem 3.1 computes it in time 2 o ( N ) 2^{o(N)} 2 o ( N ) for local classes of small locality. The next section shows that, up to the rate of SAT, this computation cannot be avoided.
The hardness of Bayesian inference in context
The lower bounds rest on one gadget. It turns a CNF into a context that is consistent for every formula, together with a query whose posterior predictive reveals whether the formula is satisfiable.
The gadget
Lemma 4.1 (Bayes gadget). Let k ≥ 1 k \ge1 k ≥ 1 , and let F F F be a k k k -CNF on z 1 , … , z n z_1,\ldots,z_n z 1 , … , z n with M M M clauses, none of them tautological. Let Γ F \Gamma_F Γ F be the CNF on z 1 , … , z n , a , u z_1,\ldots,z_n,a,u z 1 , … , z n , a , u with the clauses
¬ a ∨ C ( C ∈ F ) , a ∨ ¬ z i ( i ∈ [ n ] ) , a ∨ ¬ u . \neg a \lor C \quad(C \in F), \qquad a \lor\neg z_i \quad(i \in[n]), \qquad a \lor\neg u. ¬ a ∨ C ( C ∈ F ) , a ∨ ¬ z i ( i ∈ [ n ]) , a ∨ ¬ u . Then Γ F \Gamma_F Γ F is a ( k + 1 ) (k+1) ( k + 1 ) -CNF with M + n + 1 M+n+1 M + n + 1 clauses, none of them tautological. It has 2 # F + 1 2^{\#F}+1 2 # F + 1 satisfying assignments, and exactly 2 # F 2^{\#F} 2 # F of them set a = 1 a=1 a = 1 .
Proof sketch. If a = 1 a=1 a = 1 , every clause a ∨ ⋅ a\lor\cdot a ∨ ⋅ holds, the clauses ¬ a ∨ C \neg a\lor C ¬ a ∨ C reduce to F F F , and u u u is free: 2 # F 2^{\#F} 2 # F assignments. If a = 0 a=0 a = 0 , the clauses ¬ a ∨ C \neg a\lor C ¬ a ∨ C hold and the others force z = 0 z=0 z = 0 and u = 0 u=0 u = 0 : one assignment (Section B). □
A positive example of literal disjunctions is a clause (Example 2.2 (a)), and Imported Theorem 2.11 turns a CNF into a sample of binarized perceptrons with the same solutions. The query e a e_a e a , the unit vector of the coordinate of a a a , is labeled 1 exactly by the descriptions with a = 1 a=1 a = 1 , in both classes.
Lemma 4.2 (Bayes contexts). Let k ≥ 2 k \ge2 k ≥ 2 , and let F F F be a k k k -CNF on n n n variables with M M M clauses, none of them tautological. One can compute in polynomial time:
(a) a context S F L D S_F^{\mathrm{LD}} S F LD of M + n + 1 M+n+1 M + n + 1 positive examples of L D k + 1 \mathrm{LD}_{k+1} LD k + 1 in dimension n + 2 n+2 n + 2 , and
(b) a context S F B P S_F^{\mathrm{BP}} S F BP of M + n + k M+n+k M + n + k positive examples of B P 2 k \mathrm{BP}_{2k} BP 2 k in dimension n + k + 1 n+k+1 n + k + 1 ,
both consistent, such that the query e a e_a e a has posterior predictive p S ( e a ) = 2 # F / ( 2 # F + 1 ) p_S(e_a)=2^{\#F}/(2^{\#F}+1) p S ( e a ) = 2 # F / ( 2 # F + 1 ) in both. In particular p S ( e a ) = 0 p_S(e_a)=0 p S ( e a ) = 0 if F F F is unsatisfiable, p S ( e a ) ≥ 2 / 3 p_S(e_a)\ge2/3 p S ( e a ) ≥ 2/3 otherwise, and # F = p S ( e a ) / ( 2 ( 1 − p S ( e a ) ) ) \#F=p_S(e_a)/(2(1-p_S(e_a))) # F = p S ( e a ) / ( 2 ( 1 − p S ( e a ))) .
Proof sketch. For (a), take the positive examples of the clauses of Γ F \Gamma_F Γ F . For (b), apply Imported Theorem 2.11 to Γ F \Gamma_F Γ F , a ( k + 1 ) (k+1) ( k + 1 ) -CNF, with p = k − 1 p=k-1 p = k − 1 padding coordinates. In both, the version space is in bijection with the satisfying assignments of Γ F \Gamma_F Γ F , the posterior is uniform on it, and the query is labeled by a a a (Section B).
For the length form of ETH we need locality 3 and dimension linear in the length of the formula. Splitting clauses changes the number of solutions, but not whether there is one, and that suffices.
Lemma 4.3 (Bayes contexts by length). Given a CNF F F F of length L ≥ 1 L \ge1 L ≥ 1 , one can compute in polynomial time a consistent context of positive examples of L D 3 \mathrm{LD}_3 LD 3 in dimension N ≤ 3 L + 2 N \le3L+2 N ≤ 3 L + 2 , with at most min { 5 L + 1 , 36 N 2 } \min\{5L+1,36N^2\} min { 5 L + 1 , 36 N 2 } examples, such that the query e a e_a e a has posterior predictive 0 if F F F is unsatisfiable and at least 2 / 3 2/3 2/3 otherwise. The same holds for B P 4 \mathrm{BP}_4 BP 4 in dimension N + 1 N+1 N + 1 , with one more example.
Proof sketch. Split F F F into an equisatisfiable 3-CNF F ′ F' F ′ with at most 2 L 2L 2 L variables and at most L L L clauses. Replace each clause C C C of F ′ F' F ′ by ¬ a ∨ C \lnot a \lor C ¬ a ∨ C if ∣ C ∣ ≤ 2 |C| \le2 ∣ C ∣ ≤ 2 . If C = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 C=\ell_1 \lor\ell_2 \lor\ell_3 C = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 , use a fresh variable y C y_C y C and the clauses ¬ a ∨ ℓ 1 ∨ y C \lnot a \lor\ell_1 \lor y_C ¬ a ∨ ℓ 1 ∨ y C , ¬ y C ∨ ℓ 2 ∨ ℓ 3 \lnot y_C \lor\ell_2 \lor\ell_3 ¬ y C ∨ ℓ 2 ∨ ℓ 3 and a ∨ ¬ y C a \lor\lnot y_C a ∨ ¬ y C . Add a ∨ ¬ z a \lor\lnot z a ∨ ¬ z for every variable z z z of F ′ F' F ′ and a ∨ ¬ u a \lor\lnot u a ∨ ¬ u . If a = 0 a=0 a = 0 , all variables are forced to 0, which satisfies every clause; if a = 1 a=1 a = 1 , the clauses for C C C have a solution in y C y_C y C exactly when C C C holds, and u u u is free. So the branch a = 1 a=1 a = 1 has no assignment or at least two, and the branch a = 0 a=0 a = 0 has one (Section B).
Lower bounds
Theorem 4.4 (Hardness of Bayesian inference in context). (a) Assume Hypothesis 2.14. For every γ ∈ ( 0 , 1 ) \gamma\in(0,1) γ ∈ ( 0 , 1 ) there are K K K and c γ c_\gamma c γ such that no randomized algorithm with error probability at most 1 / 3 1/3 1/3 does the following in time O ( 2 ( 1 − γ ) N ) O(2^{(1-\gamma)N}) O ( 2 ( 1 − γ ) N ) : given a consistent context of at most N c γ N^{c_\gamma} N c γ positive examples of B P ⌈ K log N ⌉ \mathrm{BP}_{\lceil K\log N\rceil} BP ⌈ K l o g N ⌉ in dimension N N N and a query, output a number within 1 / 4 1/4 1/4 of the posterior predictive. The same holds for L D ⌈ K log N ⌉ \mathrm{LD}_{\lceil K\log N\rceil} LD ⌈ K l o g N ⌉ , for computing B ( S , x ) B(S,x) B ( S , x ) , and for running the Gibbs predictor exactly or within statistical distance 1 / 6 1/6 1/6 . Under Hypothesis 2.15, there are K K K , c γ c_\gamma c γ , ρ > 0 \rho>0 ρ > 0 with the same statements for time O ( 2 ρ N ) O(2^{\rho N}) O ( 2 ρN ) .
(b) Assume E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len , and let θ > 0 \theta>0 θ > 0 . No randomized algorithm with error probability at most 1 / 3 1/3 1/3 outputs, for every consistent context of at most 36 N 2 36N^2 36 N 2 positive examples of L D 3 \mathrm{LD}_3 LD 3 in dimension N N N and every query, a number within 1 / 4 1/4 1/4 of the posterior predictive in time 2 N / ( log N ) C + θ 2^{N/(\log N)^{C+\theta}} 2 N / ( l o g N ) C + θ . The same holds for B P 4 \mathrm{BP}_4 BP 4 , for computing B ( S , x ) B(S,x) B ( S , x ) , and for running the Gibbs predictor exactly or within statistical distance 1 / 6 1/6 1/6 .
Proof sketch. For (a), take a k k k -CNF with k = ⌈ K ′ log n ⌉ k=\lceil K'\log n\rceil k = ⌈ K ′ log n ⌉ and at most n c ′ n^{c'} n c ′ clauses from Imported Theorem 2.12 for γ / 2 \gamma/2 γ /2 , and build S F B P S_F^{\mathrm{BP}} S F BP . Its dimension is N ≤ n + K ′ log n + 1 N \le n+K'\log n+1 N ≤ n + K ′ log n + 1 and its sparsity is 2 k ≤ K log N 2k \le K\log N 2 k ≤ K log N . A number within 1 / 4 1/4 1/4 of p S ( e a ) p_S(e_a) p S ( e a ) is at most 1 / 4 1/4 1/4 if F F F is unsatisfiable and at least 5 / 12 5/12 5/12 otherwise, and B ( S , e a ) = 1 B(S,e_a)=1 B ( S , e a ) = 1 exactly when F F F is satisfiable. An algorithm in time O ( 2 ( 1 − γ ) N ) O(2^{(1-\gamma)N}) O ( 2 ( 1 − γ ) N ) would decide the formula in time O ( 2 ( 1 − γ / 2 ) n ) O(2^{(1-\gamma/2)n}) O ( 2 ( 1 − γ /2 ) n ) . For (b), use Lemma 4.3: a time bound 2 N / ( log N ) C + θ 2^{N/(\log N)^{C+\theta}} 2 N / ( l o g N ) C + θ at N ≤ 3 L + 2 N \le3L+2 N ≤ 3 L + 2 is at most 2 L / ( log L ) C 2^{L/(\log L)^C} 2 L / ( l o g L ) C for large L L L (Section B).
Together with Theorem 3.1, the theorem fixes the exponent of Bayesian inference in context at constant locality, up to polylogarithmic factors.
Corollary 4.5 (Bayesian inference in context is SAT by length). Let k ≥ 3 k \ge3 k ≥ 3 be a constant. Without noise, Bayesian inference in context for k k k -local classes takes time poly ( m ) ⋅ 2 O ( N log log N / log N ) \operatorname{poly}(m)\cdot2^{O(N\log\log N/\sqrt{\log N})} poly ( m ) ⋅ 2 O ( N l o g l o g N / l o g N ) for every context length m m m . Under E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len , for every θ > 0 \theta>0 θ > 0 , approximating it within 1 / 4 1/4 1/4 needs time 2 N / ( log N ) C + θ 2^{N/(\log N)^{C+\theta}} 2 N / ( l o g N ) C + θ already for L D 3 \mathrm{LD}_3 LD 3 on contexts of at most 36 N 2 36N^2 36 N 2 examples.
Proof. The upper bound is Theorem 3.1(a) with κ \kappa κ constant, and the lower bound is Theorem 4.4(b), since L D 3 \mathrm{LD}_3 LD 3 is κ \kappa κ -local for every κ ≥ 3 \kappa\ge3 κ ≥ 3 .
Exact Bayesian inference in context computes # F \#F # F through Lemma 4.2, so it is equivalent to counting, as consistency is equivalent to satisfiability [23 Theorem 3.4] .
Theorem 4.6 (Bayesian inference in context is # k \#k # k -SAT). Let k ≥ 2 k \ge2 k ≥ 2 , and let T , T ′ T,T' T , T ′ be nondecreasing time bounds.
(i) If # k \#k # k -SAT on n n n variables with M M M clauses can be solved in time T ( n , M ) T(n,M) T ( n , M ) , then noiseless Bayesian inference in context for k k k -local classes with N N N -bit descriptions takes time 2 T ( N , ( m + 1 ) 2 k ) + poly ( N , m ) ⋅ 2 k 2T(N,(m+1)2^k)+\operatorname{poly}(N,m)\cdot2^k 2 T ( N , ( m + 1 ) 2 k ) + poly ( N , m ) ⋅ 2 k on consistent contexts of size m m m .
(ii) If noiseless Bayesian inference in context for B P 2 k \mathrm{BP}_{2k} BP 2 k , on consistent contexts of size m m m in dimension n n n , can be done exactly in time T ′ ( n , m ) T'(n,m) T ′ ( n , m ) , then # k \#k # k -SAT on n n n variables with M M M clauses can be solved in time T ′ ( n + k + 1 , M + n + k ) + poly ( n , M ) T'(n+k+1,M+n+k)+\operatorname{poly}(n,M) T ′ ( n + k + 1 , M + n + k ) + poly ( n , M ) .
Proof. Part (i) is Corollary 3.2. For (ii), delete tautological clauses, which changes no count, build S F B P S_F^{\mathrm{BP}} S F BP by Lemma 4.2, compute p = p S ( e a ) < 1 p=p_{S}(e_a)<1 p = p S ( e a ) < 1 , and output p / ( 2 ( 1 − p ) ) p/(2(1-p)) p / ( 2 ( 1 − p )) .
The hard contexts are consistent, so the lower bounds do not come from deciding consistency, which is trivial for them. They are, however, atypical for the prior: all their labels are positive, and a random task labels them so only with probability ( 2 # F + 1 ) / 2 N (2\#F+1)/2^N ( 2# F + 1 ) / 2 N . The bounds therefore concern Bayesian inference in context on every context, the guarantee that the Bayesian explanation of in-context learning attributes to a trained model, and not the Bayes risk on typical episodes. § 6 treats the latter.
Efficient in-context learning
This section shows that learning in context is cheap for local classes when Bayes-optimality is not required. For the families of the lower bounds a halfspace suffices, and every local class is a linear class over local Fourier features.
The hard families are halfspaces
Proposition 5.1 (Halfspace forms). Let σ ∈ { ± 1 } n \sigma\in\{\pm1\}^{n} σ ∈ { ± 1 } n and x ∈ { − 1 , 0 , 1 } n x \in\{-1,0,1\}^{n} x ∈ { − 1 , 0 , 1 } n with r = ∣ supp ( x ) ∣ r=\lvert\operatorname{supp}(x)\rvert r = ∣ supp ( x )∣ . Then h σ B P ( x ) = 1 [ ⟨ σ , x ⟩ ≥ 0 ] h_{\sigma}^{\mathrm{BP}}(x)=1[\langle\sigma,x\rangle\ge0] h σ BP ( x ) = 1 [⟨ σ , x ⟩ ≥ 0 ] and h σ L D ( x ) = 1 [ ⟨ σ , x ⟩ + r − 2 ≥ 0 ] h_{\sigma}^{\mathrm{LD}}(x)=1[\langle\sigma,x\rangle+r-2\ge0] h σ LD ( x ) = 1 [⟨ σ , x ⟩ + r − 2 ≥ 0 ] . If h σ B P ( x ) = 0 h_{\sigma}^{\mathrm{BP}}(x)=0 h σ BP ( x ) = 0 then ⟨ σ , x ⟩ ≤ − 1 \langle\sigma,x\rangle\le-1 ⟨ σ , x ⟩ ≤ − 1 , and if h σ L D ( x ) = 0 h_{\sigma}^{\mathrm{LD}}(x)=0 h σ LD ( x ) = 0 then ⟨ σ , x ⟩ + r − 2 = − 2 \langle\sigma,x\rangle+r-2=-2 ⟨ σ , x ⟩ + r − 2 = − 2 .
Proof sketch. The first form is the definition, and ⟨ σ , x ⟩ \langle\sigma,x\rangle ⟨ σ , x ⟩ is an integer. For literal disjunctions, if t t t coordinates of supp ( x ) \operatorname{supp}(x) supp ( x ) agree with σ \sigma σ , then ⟨ σ , x ⟩ = t − ( r − t ) \langle\sigma,x\rangle=t-(r-t) ⟨ σ , x ⟩ = t − ( r − t ) , so t ≥ 1 t\ge1 t ≥ 1 if and only if ⟨ σ , x ⟩ + r − 2 ≥ 0 \langle\sigma,x\rangle+r-2\ge0 ⟨ σ , x ⟩ + r − 2 ≥ 0 , and t = 0 t=0 t = 0 gives − 2 -2 − 2 (Section C).
Let c ( x ) = 0 c(x)=0 c ( x ) = 0 for binarized perceptrons and c ( x ) = ∣ supp ( x ) ∣ − 2 c(x)=\lvert\operatorname{supp}(x)\rvert-2 c ( x ) = ∣ supp ( x )∣ − 2 for literal disjunctions. The in-context learner A L P \mathrm{A}_{\mathrm{LP}} A LP solves the linear program
⟨ v , x i ⟩ + c ( x i ) ≥ 0 if y i = 1 , ⟨ v , x i ⟩ + c ( x i ) ≤ − 1 if y i = 0 ( i ≤ m ) (2) \langle v,x_i\rangle+c(x_i)\ge0\ \text{ if }y_i=1,\qquad\langle v,x_i\rangle+c(x_i)\le-1\ \text{ if }y_i=0\qquad(i\le m) \tag*{(2)} ⟨ v , x i ⟩ + c ( x i ) ≥ 0 if y i = 1 , ⟨ v , x i ⟩ + c ( x i ) ≤ − 1 if y i = 0 ( i ≤ m ) (2)
over v ∈ R n v\in\mathbb{R}^{n} v ∈ R n and predicts 1 [ ⟨ v , x ⟩ + c ( x ) ≥ 0 ] 1[\langle v,x\rangle+c(x)\ge0] 1 [⟨ v , x ⟩ + c ( x ) ≥ 0 ] ; if the program is infeasible it predicts 0.
Theorem 5.2 (Linear programming in context). For every k ≤ n k\le n k ≤ n , the in-context learner A L P \mathrm{A}_{\mathrm{LP}} A LP for B P k \mathrm{BP}_{k} BP k and for L D k \mathrm{LD}_{k} LD k runs in time poly ( n , m ) \operatorname{poly}(n,m) poly ( n , m ) and is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( n + 1 , ε , δ ) m_{\mathrm{VC}}(n+1,\varepsilon,\delta) m VC ( n + 1 , ε , δ ) examples, which is O ( ( n log ( 1 / ε ) + log ( 1 / δ ) ) / ε ) O((n\log(1/\varepsilon)+\log(1/\delta))/\varepsilon) O (( n log ( 1/ ε ) + log ( 1/ δ )) / ε ) . Its risk in every noiseless episode, for every input distribution, is O ( n log m / m ) O(n\log m/m) O ( n log m / m ) .
Proof sketch. If the context is consistent with σ \sigma σ , then v = σ v=\sigma v = σ is feasible by Proposition 5.1, and every feasible v v v classifies the context correctly. The classifiers x ↦ 1 [ ⟨ v , x ⟩ + c ( x ) ≥ 0 ] x\mapsto1[\langle v,x\rangle+c(x)\ge0] x ↦ 1 [⟨ v , x ⟩ + c ( x ) ≥ 0 ] are homogeneous halfspaces on ( x , c ( x ) ) ∈ R n + 1 (x,c(x))\in\mathbb{R}^{n+1} ( x , c ( x )) ∈ R n + 1 with last coefficient 1 1 1 , a class of VC dimension at most n + 1 n+1 n + 1 , so Imported Theorem 2.13(a) applies. For the risk, take ϵ = C B ( n + 2 ) log ( 2 m ) / m \epsilon=C_B(n+2)\log(2m)/m ϵ = C B ( n + 2 ) log ( 2 m ) / m and δ = 1 / m \delta=1/m δ = 1/ m (Section C). □
On the families of Theorem 4.4(a), the comparison is now complete.
Corollary 5.3 (The price of Bayes-optimality). Assume Hypothesis 2.14, let γ ∈ ( 0 , 1 ) \gamma\in(0,1) γ ∈ ( 0 , 1 ) , and let K K K and c γ c_\gamma c γ be as in Theorem 4.4(a). Consider B P ⌈ K log N ⌉ \mathrm{BP}_{\lceil K\log N\rceil} BP ⌈ K l o g N ⌉ in dimension N N N .
(a) The learner A L P \mathrm{A}_{\mathrm{LP}} A LP runs in polynomial time and has risk O ( N log m / m ) O(N\log m/m) O ( N log m / m ) in every noiseless episode.
(b) The Bayes predictor has risk at most N / ( m + 1 ) N/(m+1) N / ( m + 1 ) (Theorem 3.3).
(c) No randomized algorithm computes the Bayes predictor, or a number within 1 / 4 1/4 1/4 of the posterior predictive, on all consistent contexts of size at most N c γ N^{c_\gamma} N c γ in time O ( 2 ( 1 − γ ) N ) O(2^{(1-\gamma)N}) O ( 2 ( 1 − γ ) N ) .
The same holds for L D ⌈ K log N ⌉ \mathrm{LD}_{\lceil K\log N\rceil} LD ⌈ K l o g N ⌉ , and, with E T H C l e n \mathrm{ETH}_{C}^{\mathrm{len}} ETH C len , time 2 N / ( log N ) C + θ 2^{N/(\log N)^{C+\theta}} 2 N / ( l o g N ) C + θ and contexts of at most 36 N 2 36N^2 36 N 2 examples in (c), for L D 3 \mathrm{LD}_3 LD 3 .
So for these families a polynomial-time in-context learner matches the sample efficiency of the Bayes predictor up to a factor log m \log m log m , while the Bayes predictor itself costs time 2 ( 1 − γ ) N 2^{(1-\gamma)N} 2 ( 1 − γ ) N . In the language of [23 ] , the locality principle governs proper learning and Bayesian computation, but not improper learning: proper PAC learning of B P ⌈ K log N ⌉ \mathrm{BP}_{\lceil K\log N\rceil} BP ⌈ K l o g N ⌉ at inverse-polynomial accuracy needs time 2 ( 1 − γ ) N 2^{(1-\gamma)N} 2 ( 1 − γ ) N under CNF-SETH [23 Theorem 3.8] , and A L P \mathrm{A}_{\mathrm{LP}} A LP is improper.
Local classes are linear
For a general local class no halfspace in the input coordinates need exist, but a linear form in local Fourier features always does. For T ⊆ [ N ] T\subseteq[N] T ⊆ [ N ] let χ T ( w ) = ∏ i ∈ T ( − 1 ) w i \chi_T(w)=\prod_{i\in T}(-1)^{w_i} χ T ( w ) = ∏ i ∈ T ( − 1 ) w i , and let D κ = D κ ( N ) = ∑ j = 0 κ ( N j ) D_\kappa=D_\kappa(N)=\sum_{j=0}^{\kappa}\binom{N}{j} D κ = D κ ( N ) = ∑ j = 0 κ ( j N ) .
Theorem 5.4 (Local Fourier features). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions. For x ∈ X x\in\mathcal{X} x ∈ X and T ⊆ [ N ] T\subseteq[N] T ⊆ [ N ] with ∣ T ∣ ≤ κ |T|\le\kappa ∣ T ∣ ≤ κ , let
ψ T ( x ) = 2 − ∣ R ( x ) ∣ ∑ β ∈ { 0 , 1 } R ( x ) f x ( β ) χ T ( β ) if T ⊆ R ( x ) , ψ T ( x ) = 0 otherwise . \psi_T(x)=2^{-|R(x)|}\sum_{\beta\in\{0,1\}^{R(x)}} f_x(\beta)\chi_T(\beta)\ \text{ if }T\subseteq R(x),\qquad\psi_T(x)=0\ \text{ otherwise}. ψ T ( x ) = 2 − ∣ R ( x ) ∣ β ∈ { 0 , 1 } R ( x ) ∑ f x ( β ) χ T ( β ) if T ⊆ R ( x ) , ψ T ( x ) = 0 otherwise . and let Ψ ( x ) = ( ψ T ( x ) ) ∣ T ∣ ≤ κ \Psi(x)=(\psi_T(x))_{|T|\le\kappa} Ψ ( x ) = ( ψ T ( x ) ) ∣ T ∣ ≤ κ and Φ ( w ) = ( χ T ( w ) ) ∣ T ∣ ≤ κ \Phi(w)=(\chi_T(w))_{|T|\le\kappa} Φ ( w ) = ( χ T ( w ) ) ∣ T ∣ ≤ κ , vectors of dimension D κ D_\kappa D κ . Then h w ( x ) = ⟨ Φ ( w ) , Ψ ( x ) ⟩ h_w(x)=\langle\Phi(w),\Psi(x)\rangle h w ( x ) = ⟨ Φ ( w ) , Ψ ( x )⟩ for all w w w and x x x . The vector Ψ ( x ) \Psi(x) Ψ ( x ) has at most 2 ∣ R ( x ) ∣ 2^{|R(x)|} 2 ∣ R ( x ) ∣ nonzero entries, all in 2 − κ Z 2^{-\kappa}\mathbb{Z} 2 − κ Z , and it can be computed in time poly ( N , ∣ x ∣ ) ⋅ κ 2 κ \operatorname{poly}(N,|x|)\cdot\kappa2^\kappa poly ( N , ∣ x ∣ ) ⋅ κ 2 κ . For 1 ≤ κ ≤ N 1\le\kappa\le N 1 ≤ κ ≤ N , D κ ≤ ( e N / κ ) κ D_\kappa\le(eN/\kappa)^\kappa D κ ≤ ( e N / κ ) κ .
Proof sketch. This is the Fourier expansion of f x f_x f x on the cube { 0 , 1 } R ( x ) \{0,1\}^{R(x)} { 0 , 1 } R ( x ) [27 ] , and χ T ( w ∣ R ( x ) ) = χ T ( w ) \chi_T(w|_{R(x)})=\chi_T(w) χ T ( w ∣ R ( x ) ) = χ T ( w ) for T ⊆ R ( x ) T\subseteq R(x) T ⊆ R ( x ) . The coefficients come from 2 ∣ R ( x ) ∣ 2^{|R(x)|} 2 ∣ R ( x ) ∣ evaluations of f x f_x f x and a fast Walsh–Hadamard transform (Section C). □
The learner A l i n \mathrm{A}_{\mathrm{lin}} A lin solves the linear system ⟨ v , Ψ ( x i ) ⟩ = y i \langle v,\Psi(x_i)\rangle=y_i ⟨ v , Ψ ( x i )⟩ = y i (i ≤ m i\le m i ≤ m ) over Q \mathbb{Q} Q by Gaussian elimination and predicts 1 [ ⟨ v , Ψ ( x ) ⟩ ≥ 1 / 2 ] 1[\langle v,\Psi(x)\rangle\ge1/2] 1 [⟨ v , Ψ ( x )⟩ ≥ 1/2 ] ; if the system has no solution it predicts 0 0 0 . The learner A ℓ 1 A_{\ell_1} A ℓ 1 minimizes ∑ i ≤ m ∣ ⟨ v , Ψ ( x i ) ⟩ − y i ∣ \sum_{i\le m}|\langle v,\Psi(x_i)\rangle-y_i| ∑ i ≤ m ∣ ⟨ v , Ψ ( x i )⟩ − y i ∣ over v ∈ R D κ v\in\mathbb{R}^{D_\kappa} v ∈ R D κ by linear programming, then chooses θ ∈ [ 0 , 1 ] \theta\in[0,1] θ ∈ [ 0 , 1 ] to minimize the number of errors of x ↦ 1 [ ⟨ v , Ψ ( x ) ⟩ ≥ θ ] x\mapsto1[\langle v,\Psi(x)\rangle\ge\theta] x ↦ 1 [⟨ v , Ψ ( x )⟩ ≥ θ ] on the context, and predicts with that classifier. This is the ℓ 1 \ell_1 ℓ 1 regression of [20 ] .
Theorem 5.5 (Regression in context). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions.
(a) A l i n A_{\mathrm{lin}} A lin is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( D κ + 1 , ε , δ ) m_{\mathrm{VC}}(D_\kappa+1,\varepsilon,\delta) m VC ( D κ + 1 , ε , δ ) examples.
(b) A ℓ 1 A_{\ell_1} A ℓ 1 is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -agnostic from m U C ( D κ + 1 , ε , δ ) m_{\mathrm{UC}}(D_\kappa+1,\varepsilon,\delta) m UC ( D κ + 1 , ε , δ ) examples. In an episode with noise rate η \eta η , its risk is at most η + ε + δ \eta+\varepsilon+\delta η + ε + δ .
(c) Both run in time poly ( N , m , D κ ) ⋅ 2 κ \operatorname{poly}(N,m,D_\kappa)\cdot2^\kappa poly ( N , m , D κ ) ⋅ 2 κ . This is polynomial for constant κ \kappa κ , it is N O ( log N ) N^{O(\log N)} N O ( l o g N ) for κ = O ( log N ) \kappa=O(\log N) κ = O ( log N ) , and it is 2 o ( N ) 2^{o(N)} 2 o ( N ) times a polynomial in m m m whenever κ log ( e N / κ ) = o ( N ) \kappa\log(eN/\kappa)=o(N) κ log ( e N / κ ) = o ( N ) .
Proof sketch. For (a), v = Φ ( w ) v=\Phi(w) v = Φ ( w ) solves the system, every solution is consistent with the context, and the thresholded linear forms over Ψ \Psi Ψ have VC dimension at most D κ + 1 D_\kappa+1 D κ + 1 . For (b), for a threshold θ \theta θ uniform in [ 0 , 1 ] [0,1] [ 0 , 1 ] the expected error of 1 [ z ≥ θ ] \mathbb{1}[z\ge\theta] 1 [ z ≥ θ ] against y ∈ { 0 , 1 } y\in\{0,1\} y ∈ { 0 , 1 } is at most ∣ z − y ∣ |z-y| ∣ z − y ∣ , so the chosen classifier has at most as many errors on the context as the best h w h_w h w , whose linear form Φ ( w ) \Phi(w) Φ ( w ) is feasible for the regression. Uniform convergence over the thresholded linear forms, which contain every h w h_w h w , finishes the proof (Section C).
The price of these learners is in the examples: A l i n A_{\mathrm{lin}} A lin needs about D κ ≈ N κ D_\kappa\approx N^\kappa D κ ≈ N κ of them, where the Bayes predictor needs N N N . § 6 shows that for random local functions some such price is unavoidable for every efficient learner.
The average case: random local functions
The lower bounds of § 4 concern atypical contexts. On typical episodes, the question is whether an efficient learner can reach the Bayes risk. For random local functions it cannot, at the context lengths where the Bayes predictor already succeeds, unless Goldreich’s generator is insecure.
Random local functions and Goldreich’s generator
Definition 6.1 (Random local functions). Let k ≥ 2 k\ge2 k ≥ 2 and P : { 0 , 1 } k → { 0 , 1 } P:\{0,1\}^{k}\to\{0,1\} P : { 0 , 1 } k → { 0 , 1 } . Let X N ( k ) \mathcal{X}^{(k)}_N X N ( k ) be the set of k k k -tuples of distinct indices in [ N ] [N] [ N ] , and let D k \mathcal{D}_k D k be the uniform distribution on it. The class R L P \mathrm{RL}_P RL P on X N ( k ) \mathcal{X}^{(k)}_N X N ( k ) has the hypotheses h w ( τ ) = P ( w τ 1 , … , w τ k ) h_w(\tau)=P(w_{\tau_1},\ldots,w_{\tau_k}) h w ( τ ) = P ( w τ 1 , … , w τ k ) for w ∈ { 0 , 1 } N w\in\{0,1\}^N w ∈ { 0 , 1 } N . It is k k k -local with R ( τ ) = { τ 1 , … , τ k } R(\tau)=\{\tau_1,\ldots,\tau_k\} R ( τ ) = { τ 1 , … , τ k } . Goldreich’s generator with m m m outputs maps w w w and τ 1 , … , τ m \tau_1,\ldots,\tau_m τ 1 , … , τ m to G P , m ( τ ; w ) = ( h w ( τ 1 ) , … , h w ( τ m ) ) G_{P,m}(\tau;w)=(h_w(\tau_1),\ldots,h_w(\tau_m)) G P , m ( τ ; w ) = ( h w ( τ 1 ) , … , h w ( τ m )) [Gold00].
So an episode of the task family ( R L P , D k ) (\mathrm{RL}_P,\mathcal{D}_k) ( RL P , D k ) without noise is a run of Goldreich’s generator with m + 1 m+1 m + 1 outputs: the context is the first m m m outputs with their tuples, and the target is the last output. Security is asymptotic: a fixed algorithm must fail for all large N N N . (For a single N N N , an algorithm that stores the finite image of the generator distinguishes it quickly, so a statement about all algorithms of a given running time at one N N N would be false.)
Definition 6.2 (Pseudorandomness). Let m = m ( N ) m=m(N) m = m ( N ) . The advantage of a probabilistic algorithm A A A against G P , m G_{P,m} G P , m at dimension N N N is
adv A ( N ) = ∣ Pr [ A ( τ , G P , m ( τ ; w ) ) = 1 ] − Pr [ A ( τ , b ) = 1 ] ∣ . \operatorname{adv}_{A}(N)=\left|\Pr[A(\tau,G_{P,m}(\tau;w))=1]-\Pr[A(\tau,b)=1]\right|. adv A ( N ) = ∣ Pr [ A ( τ , G P , m ( τ ; w )) = 1 ] − Pr [ A ( τ , b ) = 1 ] ∣ . where τ \tau τ is uniform in ( X N ( k ) ) m (\mathcal{X}_{N}^{(k)})^{m} ( X N ( k ) ) m , w w w is uniform in { 0 , 1 } N \{0,1\}^{N} { 0 , 1 } N , and b b b is uniform in { 0 , 1 } m \{0,1\}^{m} { 0 , 1 } m . For a function T = T ( N ) T=T(N) T = T ( N ) , the generator G P , m G_{P,m} G P , m is T T T -pseudorandom if every probabilistic algorithm whose running time on inputs of dimension N N N is at most T ( N ) T(N) T ( N ) for all sufficiently large N N N has advantage at most 1 / 3 1/3 1/3 at all sufficiently large N N N .
A distinguisher for G P , m ′ G_{P,m'} G P , m ′ with m ′ ≤ m m'\le m m ′ ≤ m yields one for G P , m G_{P,m} G P , m with the same advantage, because it can ignore the last outputs: the first m ′ m' m ′ outputs of G P , m G_{P,m} G P , m , with their tuples, are distributed as those of G P , m ′ G_{P,m'} G P , m ′ , and a prefix of a uniform string is uniform. Pseudorandomness of random local functions is a central hypothesis of cryptography in N C 0 \mathrm{NC}^{0} NC 0 ; see the survey [App16]. At polynomial stretch m = N s m=N^{s} m = N s it needs predicates that are uncorrelated with all parities of few inputs, and for a predicate uncorrelated with all parities of fewer than t t t inputs, sum-of-squares and statistical-query lower bounds support it up to stretch N Ω ( t ) N^{\Omega(t)} N Ω ( t ) [29 , 21 , 15 ] . We use two forms of the hypothesis. The first, for every s > 1 s>1 s > 1 , is Assumption 1 of Daniely and Vardi [14 ] , which they use to prove the hardness of improper PAC learning for DNF formulas, intersections of halfspaces and other classes.
Hypothesis 6.3 (LPRGs _{\mathrm{s}} s ). For a constant s > 1 s>1 s > 1 : there are k ≥ 2 k\ge2 k ≥ 2 and P : { 0 , 1 } k → { 0 , 1 } P:\{0,1\}^{k}\to\{0,1\} P : { 0 , 1 } k → { 0 , 1 } such that G P , ⌈ N s ⌉ G_{P,\lceil N^{s}\rceil} G P , ⌈ N s ⌉ is T T T -pseudorandom for every polynomial T T T .
Hypothesis 6.4 (LPRGc l e n _{\mathrm{c}}^{\mathrm{len}} c len ). For a constant c > 0 c>0 c > 0 : there are k ≥ 2 k\ge2 k ≥ 2 , P : { 0 , 1 } k → { 0 , 1 } P:\{0,1\}^{k}\to\{0,1\} P : { 0 , 1 } k → { 0 , 1 } and α 0 ≥ 2 \alpha_{0}\ge2 α 0 ≥ 2 such that for every constant α ≥ α 0 \alpha\ge\alpha_{0} α ≥ α 0 , the generator G P , ⌈ α N ⌉ G_{P,\lceil\alpha N\rceil} G P , ⌈ α N ⌉ is 2 N / ( log N ) c 2^{N/(\log N)^{c}} 2 N / ( l o g N ) c -pseudorandom.
The second hypothesis is the analogue of E T H C l e n \mathrm{ETH}_{C}^{\mathrm{len}} ETH C len for random local functions at linear stretch. Like E T H C l e n \mathrm{ETH}_{C}^{\mathrm{len}} ETH C len , the new algorithms refute it below rate 1 / 2 1/2 1/2 .
Proposition 6.5 (LPRGc l e n _{\mathrm{c}}^{\mathrm{len}} c len fails below rate $1/2). For every k ≥ 2 k\ge2 k ≥ 2 , every P P P , every constant α ≥ 2 \alpha\ge2 α ≥ 2 and every c < 1 / 2 c<1/2 c < 1/2 , there is a deterministic algorithm that runs in time at most 2 N / ( log N ) c 2^{N/(\log N)^{c}} 2 N / ( l o g N ) c for large N N N and has advantage at least 1 − 2 − N 1-2^{-N} 1 − 2 − N against G P , ⌈ α N ⌉ G_{P,\lceil\alpha N\rceil} G P , ⌈ α N ⌉ at every N N N . Hence LPRGc l e n _{\mathrm{c}}^{\mathrm{len}} c len is false for every c < 1 / 2 c<1/2 c < 1/2 .
Proof sketch. Given ( τ , z ) (\tau,z) ( τ , z ) , decide whether the context ( ( τ j , z j ) ) j ((\tau_j,z_j))_j (( τ j , z j ) ) j is consistent with R L P \mathrm{RLP} RLP , by Imported Theorem 2.8 in time poly ( N ) ⋅ 2 O ( k 2 N log log N / log N ) \operatorname{poly}(N)\cdot2^{O(k^{2}N\log\log N/\sqrt{\log N})} poly ( N ) ⋅ 2 O ( k 2 N l o g l o g N / l o g N ) , and output 1 if it is. Outputs of the generator are always consistent. A uniform z z z is consistent with probability at most 2 N / 2 ⌈ α N ⌉ ≤ 2 − N 2^{N}/2^{\lceil\alpha N\rceil}\le2^{-N} 2 N / 2 ⌈ α N ⌉ ≤ 2 − N , since for fixed tuples at most 2 N 2^{N} 2 N strings are images (Section D).
For c ≥ 1 / 2 c\ge1/2 c ≥ 1/2 the new algorithms do not contradict LPRGc l e n _{\mathrm{c}}^{\mathrm{len}} c len , and before 2026 the best known distinguishers for suitable predicates at linear stretch took time 2 2 o ( N ) 2^{2^{o(N)}} 2 2 o ( N ) .
Three regimes
Theorem 6.6 (Three regimes for random local functions). Let k ≥ 2 k\ge2 k ≥ 2 be a constant and P : { 0 , 1 } k → { 0 , 1 } P:\{0,1\}^{k}\to\{0,1\} P : { 0 , 1 } k → { 0 , 1 } . Consider the task family ( R L P , D k ) (\mathrm{RL}_{P},\mathcal{D}_{k}) ( RL P , D k ) without noise.
(a) The Bayes risk is at most N / ( m + 1 ) N/(m+1) N / ( m + 1 ) , and the Bayes predictor runs in time poly ( m ) ⋅ 2 O ( N log log N / log N ) \operatorname{poly}(m)\cdot2^{O(N\log\log N/\sqrt{\log N})} poly ( m ) ⋅ 2 O ( N l o g l o g N / l o g N ) .
(b) The learner A l i n A_{\mathrm{lin}} A lin is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( D k ( N ) + 1 , ε , δ ) = O ( ( N k log ( 1 / ε ) + log ( 1 / δ ) ) / ε ) m_{\mathrm{VC}}(\mathcal{D}_{k}(N)+1,\varepsilon,\delta)=O((N^{k}\log(1/\varepsilon)+\log(1/\delta))/\varepsilon) m VC ( D k ( N ) + 1 , ε , δ ) = O (( N k log ( 1/ ε ) + log ( 1/ δ )) / ε ) examples and runs in time poly ( N , m ) \operatorname{poly}(N,m) poly ( N , m ) .
(c) There is an absolute constant c ∗ c_\ast c ∗ with the following property. For every in-context learner A A A and every context length m m m , there is a probabilistic algorithm A ′ A' A ′ that runs in time T A + c ∗ ( m + 1 ) k log N T_A+c_\ast(m+1)k\log N T A + c ∗ ( m + 1 ) k log N , where T A T_A T A is the running time of A A A on contexts of length m m m , and has advantage exactly ∣ 1 / 2 − R m ( A ) ∣ \lvert1/2-R_m(A)\rvert ∣ 1/2 − R m ( A )∣ against G P , m + 1 G_{P,m+1} G P , m + 1 . If m = m ( N ) m=m(N) m = m ( N ) is computable in time polynomial in N N N , then A ′ A' A ′ is a single algorithm for all N N N .
Proof sketch. Parts (a) and (b) are Theorems 3.1, 3.3 and 5.5 for this k k k -local class. For (c), A ′ A' A ′ runs A A A on the first m m m outputs and the last tuple and accepts if the prediction equals the last output. On outputs of the generator it accepts with probability 1 − R m ( A ) 1-R_m(A) 1 − R m ( A ) ; on uniform bits the last bit is independent of the rest, so it accepts with probability 1 / 2 1/2 1/2 (Section D).
Corollary 6.7 (The three regimes under the hypotheses). (a) Assume L P R G s \mathrm{LPRG}_{s} LPRG s , with predicate P P P of arity k k k . Let A A A be a polynomial-time in-context learner for ( R L P , D k ) (\mathrm{RL}_P,\mathcal{D}_k) ( RL P , D k ) and m ( N ) ≤ ⌈ N s ⌉ − 1 m(N)\le\lceil N^s\rceil-1 m ( N ) ≤ ⌈ N s ⌉ − 1 a context length computable in time polynomial in N N N . Then R m ( N ) ( A ) ≥ 1 / 6 R_{m(N)}(A)\ge1/6 R m ( N ) ( A ) ≥ 1/6 for all sufficiently large N N N . At m = ⌈ N s ⌉ − 1 m=\lceil N^s\rceil-1 m = ⌈ N s ⌉ − 1 the Bayes risk is at most N 1 − s N^{1-s} N 1 − s , and A l i n A_{\mathrm{lin}} A lin has risk at most ε \varepsilon ε from O ( N k log ( 1 / ε ) / ε ) O(N^k\log(1/\varepsilon)/\varepsilon) O ( N k log ( 1/ ε ) / ε ) examples.
(b) Assume L P R G c l e n \mathrm{LPRG}^{\mathrm{len}}_{c} LPRG c len , with predicate P P P of arity k k k and constant α 0 \alpha_0 α 0 . Let α ≥ max { α 0 , 7 } \alpha\ge\max\{\alpha_0,7\} α ≥ max { α 0 , 7 } be a constant and m ( N ) = ⌈ α N ⌉ − 1 m(N)=\lceil\alpha N\rceil-1 m ( N ) = ⌈ α N ⌉ − 1 . Every in-context learner that runs in time 2 N / ( log N ) c − 1 2^{N/(\log N)^{c-1}} 2 N / ( l o g N ) c − 1 on contexts of length m ( N ) m(N) m ( N ) has R m ( N ) ( A ) ≥ 1 / 6 R_{m(N)}(A)\ge1/6 R m ( N ) ( A ) ≥ 1/6 for all sufficiently large N N N , while the Bayes predictor has risk at most 1 / α < 1 / 6 1/\alpha<1/6 1/ α < 1/6 and runs in time 2 O ( N log log N / log N ) 2^{O(N\log\log N/\sqrt{\log N})} 2 O ( N l o g l o g N / l o g N ) .
So, at context length ⌈ α N ⌉ − 1 \lceil\alpha N\rceil-1 ⌈ α N ⌉ − 1 , the time needed for risk below 1 / 6 1/6 1/6 on random local functions has exponent between N / ( log N ) c N/(\log N)^c N / ( log N ) c under L P R G c l e n \mathrm{LPRG}^{\mathrm{len}}_c LPRG c len and O ( N log log N / log N ) O(N\log\log N/\sqrt{\log N}) O ( N log log N / log N ) , which is N / polylog N N/\operatorname{polylog}N N / polylog N on both sides when c c c is a constant at least 1 / 2 1/2 1/2 . The Bayes predictor of the refutations is optimal up to polylogarithmic factors in the exponent. Between N s N^s N s and N k N^k N k examples the complexity is open; the thresholds of refutation and recovery for planted constraint satisfaction problems, near N t / 2 N^{t/2} N t /2 for predicates uncorrelated with all parities of fewer than t t t inputs, suggest where polynomial time begins [15 , 21 ] .
Consequences for transformers
The lower bounds above hold for every algorithm. This section states them for transformers that write a chain of thought, and it compares the two explanations of in-context learning.
Chains of thought
We model a trained transformer only by its cost. A sequence model with p p p parameters maps a sequence of ℓ \ell ℓ tokens to a next token. We assume that this map can be computed in time ( p + ℓ ) c M (p+\ell)^{c_M} ( p + ℓ ) c M for a constant c M c_M c M , as it can for a transformer with p p p parameters of polynomial precision and polynomially many layers and heads. The model answers a context and a query, encoded with poly ( N ) \operatorname{poly}(N) poly ( N ) tokens per example, after generating a chain of thought of at most L L L tokens. Generating L L L tokens from a prompt of ℓ \ell ℓ tokens takes time at most ( L + 1 ) ( p + ℓ + L ) c M ≤ ( p + ℓ + L ) c M + 1 (L+1)(p+\ell+L)^{c_M}\le(p+\ell+L)^{c_M+1} ( L + 1 ) ( p + ℓ + L ) c M ≤ ( p + ℓ + L ) c M + 1 .
The hypotheses we use are statements about algorithms, so the models must be produced by an algorithm too. A family ( M N ) (M_N) ( M N ) of sequence models is uniform if a fixed deterministic algorithm outputs the parameters of M N M_N M N in time polynomial in N N N , for example a polynomial-time training procedure run with a fixed random seed. Let L ( N ) L(N) L ( N ) be the largest length of a chain of thought of M N M_N M N on the inputs under consideration.
Corollary 7.1 (Chain-of-thought lengths). Let ( M N ) (M_N) ( M N ) be a uniform family of sequence models with p ( N ) ≤ N O ( 1 ) p(N)\le N^{O(1)} p ( N ) ≤ N O ( 1 ) parameters, as above.
(a) Assume Hypothesis 2.14, and let γ \gamma γ , K K K , c γ c_{\gamma} c γ be as in Theorem 4.4(a). If M N M_N M N outputs B ( S , x ) \mathrm{B}(S,x) B ( S , x ) for every consistent context of at most N c γ N^{c_{\gamma}} N c γ examples of B P ⌈ K log N ⌉ \mathrm{BP}_{\lceil K\log N\rceil} BP ⌈ K l o g N ⌉ in dimension N N N and every query, then L ( N ) > 2 ( 1 − γ ) N / ( c M + 1 ) − N O ( 1 ) L(N)>2^{(1-\gamma)N/(c_M+1)}-N^{O(1)} L ( N ) > 2 ( 1 − γ ) N / ( c M + 1 ) − N O ( 1 ) for infinitely many N N N . So L ( N ) = 2 Ω ( N ) L(N)=2^{\Omega(N)} L ( N ) = 2 Ω ( N ) for infinitely many N N N .
(b) Assume E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len and let θ > 0 \theta>0 θ > 0 . If M N M_N M N outputs B ( S , x ) \mathrm{B}(S,x) B ( S , x ) for every consistent context of at most 36 N 2 36N^2 36 N 2 examples of L D 3 \mathrm{LD}_3 LD 3 in dimension N N N and every query, then L ( N ) ≥ 2 N / ( log N ) C + 6 L(N)\ge2^{N/(\log N)^{C+6}} L ( N ) ≥ 2 N / ( l o g N ) C + 6 for infinitely many N N N .
(c) Assume L P R G S \mathrm{LPRG}_S LPRG S with predicate P P P , and let m ( N ) ≤ ⌈ N s ⌉ − 1 m(N)\le\lceil N^s\rceil-1 m ( N ) ≤ ⌈ N s ⌉ − 1 be computable in time polynomial in N N N . If L ( N ) ≤ N O ( 1 ) L(N)\le N^{O(1)} L ( N ) ≤ N O ( 1 ) , then M M M has risk at least 1 / 6 1/6 1/6 on ( R L P , D k ) (\mathrm{RL}_P,\mathcal{D}_k) ( RL P , D k ) at context length m ( N ) m(N) m ( N ) for all sufficiently large N N N .
(d) Assume L P R G c l e n \mathrm{LPRG}^{\mathrm{len}}_c LPRG c len with predicate P P P , and let α \alpha α and m ( N ) m(N) m ( N ) be as in Corollary 6.7 (b). If L ( N ) ≤ 2 N / ( ( c M + 2 ) ( log N ) c ) L(N)\le2^{N/((c_M+2)(\log N)^{c})} L ( N ) ≤ 2 N / (( c M + 2 ) ( l o g N ) c ) for all sufficiently large N N N , then M M M has risk at least 1 / 6 1/6 1/6 on ( R L P , D k ) (\mathrm{RL}_P,\mathcal{D}_k) ( RL P , D k ) at context length m ( N ) m(N) m ( N ) for all sufficiently large N N N .
Proof sketch. Computing the parameters and then simulating M N M_N M N is an algorithm of time N O ( 1 ) + ( p + ℓ + L ) c M + 1 N^{O(1)}+(p+\ell+L)^{c_M+1} N O ( 1 ) + ( p + ℓ + L ) c M + 1 , and on the inputs considered the prompt length ℓ \ell ℓ is polynomial in N N N . In (a) and (b), an algorithm that computes B ( S , x ) \mathrm{B}(S,x) B ( S , x ) on all these contexts is excluded below the times of Theorem 4.4; solving for L L L gives the bounds. Parts (c) and (d) are Corollary 6.7 for the simulation (Section D).
For families with arbitrary trained weights, parts (c) and (d) hold under the versions of the generator hypotheses that allow non-uniform distinguishers, such as circuits of the stated size, and parts (a) and (b) would need non-uniform versions of CNF-SETH and E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len . Conversely, transformers that generate a chain of thought can simulate Turing machines [31 , 26 ] , so the algorithm of Theorem 3.1 can in principle run in a chain of thought of subexponential length for locality o ( ( log N ) 1 / 4 / log log N ) o((\log N)^{1/4}/\sqrt{\log\log N}) o (( log N ) 1/4 / log log N ) . Before the refutation of ETH, the best known algorithms for the Bayes prediction of L D 3 \mathrm{LD}_3 LD 3 took time 2 Ω ( N ) 2^{\Omega(N)} 2 Ω ( N ) ; under E T H C l e n \mathrm{ETH}^{\mathrm{len}}_C ETH C len , a uniform family that computes it needs chains of thought of length 2 N / ( log N ) C + 6 2^{N/(\log N)^{C+6}} 2 N / ( l o g N ) C + 6 for infinitely many N N N .
Bayesian and algorithmic in-context learning
Two explanations of in-context learning are current. The Bayesian one holds that a model trained on a task distribution predicts like its posterior [37 , 25 , 30 ] . The algorithmic one holds that the model runs a learning algorithm on its context, such as least squares, ridge regression or gradient descent [17 , 2 , 36 , 3 ] . Raventós, Paul, Chen and Ganguli [33 ] find both in one setting: trained on few regression tasks, a transformer follows the Bayes estimator of its pretraining distribution; trained on many, it leaves that estimator and follows ridge regression, which lets it solve new tasks.
For discrete task families with local structure, our results give the computational side of this picture. The Bayes estimator over 2 N 2^N 2 N tasks is a counting problem: computing it on all contexts costs time 2 N / polylog N 2^{N/\operatorname{polylog}N} 2 N / polylog N at constant locality and 2 ( 1 − γ ) N 2^{(1-\gamma)N} 2 ( 1 − γ ) N at logarithmic locality under the surviving hypotheses (Theorem 4.4), and on random local functions no efficient learner reaches the Bayes risk at the context lengths where the Bayes estimator does (Corollary 6.7 ). The algorithmic alternative is efficient: least squares over local Fourier features learns every κ \kappa κ -local family from N O ( κ ) N^{O(\kappa)} N O ( κ ) examples (Theorem 5.5), and for binarized perceptrons and literal disjunctions a linear program learns from O ( N log ( 1 / ε ) / ε ) O(N\log(1/\varepsilon)/\varepsilon) O ( N log ( 1/ ε ) / ε ) examples (Theorem 5.2). In-context least squares and ridge regression are known to be implementable by transformers [2 , 3 ] , which use Ψ ( x ) \Psi(x) Ψ ( x ) as the representation of an input. A polynomial-size model produced by a polynomial-time training procedure can therefore be an efficient in-context learner for such a family, but, unless the hypotheses fail, not a Bayes estimator for it. The setting of [33 ] differs from ours: its discrete pretraining distributions are explicit lists of regression tasks, for which the Bayes estimator is a finite mixture whose cost is linear in the number of tasks. Our results concern exponentially many tasks with local structure, where the cost of the mixture is the cost of counting.
Related work
The refutation of ETH and learning. OpenAI [28 ] and Anthropic [11 ] refuted ETH by counting the solutions of k k k -CNFs in time 2 n / ( log n ) 1 / 2 − o ( 1 ) 2^{n/(\log n)^{1/2-o(1)}} 2 n / ( l o g n ) 1/2 − o ( 1 ) , by polynomial interpolation and by signed sums of tensor networks. The companion paper [23 ] derived the locality principle for proper learning, error-profile algorithms for exact empirical risk minimization, agnostic and private learning, the transitions in locality, accuracy and treewidth, and a ledger of the conditional lower bounds of learning theory; we use its statements as black boxes. Bhattacharjee [6 ] runs the algorithm of [28 ] over arbitrary commutative Q \mathbb{Q} Q -algebras, which gives weighted counting with several linear statistics at once.
In-context learning. Garg, Tsipras, Liang and Valiant [17 ] trained transformers to learn simple function classes in context. Akyürek et al. [2 ] , von Oswald et al. [36 ] and Bai et al. [3 ] showed that transformers can implement gradient descent, least squares, ridge regression and algorithm selection in context, with statistical guarantees. Xie, Raghunathan, Liang and Ma [37 ] explained in-context learning as implicit Bayesian inference, prior-fitted networks [25 ] are trained to approximate posterior predictives, and Panwar, Ahuja and Goyal [30 ] compared trained transformers with Bayes predictors on several task families. Raventós, Paul, Chen and Ganguli [33 ] observed the transition from the Bayes estimator of the pretraining distribution to ridge regression as task diversity grows. Bhattamishra et al. [8 ] studied in-context learning of discrete function classes. Pérez, Barceló and Marinkovic [31 ] and Merrill and Sabharwal [26 ] studied the computational power of transformers with intermediate generation. These works concern what in-context learners compute and how well they generalize; the present paper concerns the computational cost of Bayes-optimal in-context prediction.
Bayesian learning curves, halving and version spaces. The halving algorithm goes back to Barzdin and Freivald and to Littlestone [5 , 24 ] . Haussler, Kearns and Schapire [18 ] bounded the learning curves of the Bayes and Gibbs algorithms by information gain and VC dimension. The log-loss regret of Bayes mixtures is standard [9 ] . Sampling by self-reducibility is due to Jerrum, Valiant and Vazirani [19 ] .
Proper and improper learning. Pitt and Valiant [32 ] showed that proper learning can be NP-hard when improper learning is easy, as for k k k -term DNF and k k k -CNF; Corollary 5.3 is a fine-grained, exponential-time form of this contrast for Bayes prediction. The ℓ 1 \ell_1 ℓ 1 regression algorithm is that of Kalai, Klivans, Mansour and Servedio [20 ] . Daniely, Linial and Shalev-Shwartz [13 ] showed that more data speeds up improper learning of halfspaces over sparse vectors, which complements the sample price of Theorem 5.5.
Local pseudorandom generators. Goldreich proposed random local functions as one-way functions [16 ] ; Applebaum’s survey [App16] covers their use as pseudorandom generators.
O’Donnell and Witmer [29 ] gave evidence for polynomial stretch, and Kothari, Mori, O’Donnell and Witmer [21 ] and Feldman, Perkins and Vempala [15 ] proved sum-of-squares and statistical-query lower bounds for refuting and solving random and planted constraint satisfaction problems. Daniely and Vardi [14 ] derived hardness of improper PAC learning from local pseudorandom generators. Learning parity with noise is solved by the algorithm of Blum, Kalai and Wasserman [7 ] . The step from prediction to distinguishing is Yao’s [38 ] .
Open problems
Open Problem 1 (Typical contexts for natural families). The worst-case lower bounds of Theorem 4.4 use atypical contexts, and the average-case bounds of Corollary 6.7 use random local functions. Is Bayesian inference in context hard on typical episodes of binarized perceptrons or literal disjunctions on sparse data, for natural input distributions, at locality O ( log N ) O(\log N) O ( log N ) ?
Open Problem 2 (Approximate Bayesian inference). Our lower bounds exclude additive error 1 / 4 1/4 1/4 on all contexts. With label noise, the posterior is a Gibbs measure at inverse temperature ln ( ( 1 − η ) / η ) \ln((1-\eta)/\eta) ln (( 1 − η ) / η ) . Is there a noise rate below which approximating the posterior predictive becomes easy, for example by Markov chain methods, and does the threshold depend on the locality?
Open Problem 3 (Between N s N^{s} N s and N k N^{k} N k examples). For random local functions of arity k k k , polynomial-time learning needs more than N s N^{s} N s examples under LPRGs and succeeds from O ( N k ) O(N^{k}) O ( N k ) . What is the time needed from N 1 + β N^{1+\beta} N 1 + β examples, as a function of β \beta β ? Spectral refutation trades density for time on random instances; can it be combined with the algorithms of the refutation of ETH to beat 2 N / log N 2^{N/\sqrt{\log N}} 2 N / l o g N at superlinear context length?
Open Problem 4 (The locality window). By Theorem 4.6 , the complexity of exact Bayesian inference in context at locality between ( log N ) 1 / 4 (\log N)^{1/4} ( log N ) 1/4 and K log N K\log N K log N is that of # k \#k # k -SAT for k = ( log N ) Θ ( 1 ) k=(\log N)^{\Theta(1)} k = ( log N ) Θ ( 1 ) , the window of [23 Open Problem 1] . Is approximate Bayesian inference in context easier there than exact counting?
Open Problem 5 (Bayes risk without Bayes inference). For binarized perceptrons on ( K log N ) (K\log N) ( K log N ) -sparse data, ALP has risk O ( N log m / m ) O(N\log m/m) O ( N log m / m ) and the Bayes risk is at most N / ( m + 1 ) N/(m+1) N / ( m + 1 ) . Can a polynomial-time in-context learner achieve risk R m ∗ + ϵ R^{*}_{m}+\epsilon R m ∗ + ϵ for every input distribution and every ϵ > 0 \epsilon>0 ϵ > 0 , with m m m polynomial in N / ϵ N/\epsilon N / ϵ , or is the Bayes risk itself hard to reach for this family?
Proofs for Sections 2 and 3
The proofs are hierarchical in the style of Lamport [22 ] : each step is a claim with its own proof, and Q.E.D. marks the step that concludes its level.
The Bayes decision rule
Lemma 2.5 (Bayes decision rule). For every task family, noise rate and context length m m m , every in-context learner A A A has R m ( A ) ≥ R m ( B ) R_m(A) \ge R_m(\mathrm{B}) R m ( A ) ≥ R m ( B ) , and R m ( B ) = E [ min { p ^ S ( x m + 1 ) , 1 − p ^ S ( x m + 1 ) } ] R_m(\mathrm{B}) = \mathbb{E}[\min\{\hat{p}_S(x_{m+1}),1-\hat{p}_S(x_{m+1})\}] R m ( B ) = E [ min { p ^ S ( x m + 1 ) , 1 − p ^ S ( x m + 1 )}] .
Proof of Lemma 2.5. ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 1. Condition on the inputs x 1 , … , x m + 1 x_1,\ldots,x_{m+1} x 1 , … , x m + 1 and the labels y 1 , … , y m y_1,\ldots,y_m y 1 , … , y m . Then the task has distribution π S \pi_S π S , and Pr [ y m + 1 = 1 ∣ S , x m + 1 ] = p ^ S ( x m + 1 ) \Pr[y_{m+1}=1\mid S,x_{m+1}]=\hat{p}_S(x_{m+1}) Pr [ y m + 1 = 1 ∣ S , x m + 1 ] = p ^ S ( x m + 1 ) .
Proof: The inputs are independent of the task and of the noise. Given the inputs, the probability of the labels y 1 , … , y m y_1,\ldots,y_m y 1 , … , y m under task w w w is ∏ i ≤ m η [ h w ( x i ) ≠ y i ] ( 1 − η ) [ h w ( x i ) = y i ] = ( 1 − η ) m μ e S ( w ) \prod_{i\le m}\eta^{[h_w(x_i)\ne y_i]}(1-\eta)^{[h_w(x_i)=y_i]}=(1-\eta)^m\mu^{e_S(w)} ∏ i ≤ m η [ h w ( x i ) = y i ] ( 1 − η ) [ h w ( x i ) = y i ] = ( 1 − η ) m μ e S ( w ) , and the prior is uniform, so the posterior is proportional to ω S ( w ) \omega_S(w) ω S ( w ) . The target is h w ( x m + 1 ) ⊕ ξ m + 1 h_w(x_{m+1})\oplus\xi_{m+1} h w ( x m + 1 ) ⊕ ξ m + 1 with ξ m + 1 \xi_{m+1} ξ m + 1 independent of everything else, so it is 1 with probability ∑ w π S ( w ) [ ( 1 − η ) h w ( x m + 1 ) + η ( 1 − h w ( x m + 1 ) ) ] = p ^ S ( x m + 1 ) \sum_w\pi_S(w)[(1-\eta)h_w(x_{m+1})+\eta(1-h_w(x_{m+1}))]=\hat{p}_S(x_{m+1}) ∑ w π S ( w ) [( 1 − η ) h w ( x m + 1 ) + η ( 1 − h w ( x m + 1 ))] = p ^ S ( x m + 1 ) .
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 2. For every in-context learner A A A , the conditional error probability given S S S and x m + 1 x_{m+1} x m + 1 is at least min { p ^ , 1 − p ^ } \min\{\hat{p},1-\hat{p}\} min { p ^ , 1 − p ^ } , with p ^ = p ^ S ( x m + 1 ) \hat{p}=\hat{p}_S(x_{m+1}) p ^ = p ^ S ( x m + 1 ) , and B attains it.
Proof: Given S S S and x m + 1 x_{m+1} x m + 1 , the output of A A A depends only on its own random bits, which are independent of the target. If A A A outputs 1 with conditional probability q q q , it errs with probability q ( 1 − p ^ ) + ( 1 − q ) p ^ ≥ min { p ^ , 1 − p ^ } q(1-\hat{p})+(1-q)\hat{p}\ge\min\{\hat{p},1-\hat{p}\} q ( 1 − p ^ ) + ( 1 − q ) p ^ ≥ min { p ^ , 1 − p ^ } . Since p ^ − 1 / 2 = ( 1 − 2 η ) ( p S ( x m + 1 ) − 1 / 2 ) \hat{p}-1/2=(1-2\eta)(p_S(x_{m+1})-1/2) p ^ − 1/2 = ( 1 − 2 η ) ( p S ( x m + 1 ) − 1/2 ) and η < 1 / 2 \eta<1/2 η < 1/2 , the predictor B outputs 1 exactly when p ^ ≥ 1 / 2 \hat{p}\ge1/2 p ^ ≥ 1/2 , so its conditional error is min { p ^ , 1 − p ^ } \min\{\hat{p},1-\hat{p}\} min { p ^ , 1 − p ^ } .
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 3. Q.E.D.
Proof: Take expectations in ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 2.
Algorithms
Theorem 3.1 (Bayesian inference in context for local classes). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions, let S S S be a context of size m m m , and let x x x be a query.
(a) Without noise. If VS ( S ) ≠ ∅ \operatorname{VS}(S)\ne\emptyset VS ( S ) = ∅ , then p S ( x ) p_S(x) p S ( x ) and B ( S , x ) \mathrm{B}(S,x) B ( S , x ) can be computed exactly and deterministically in time poly ( N , m ) ⋅ 2 κ ⋅ T κ ( N ) \operatorname{poly}(N,m)\cdot2^\kappa\cdot T_\kappa(N) poly ( N , m ) ⋅ 2 κ ⋅ T κ ( N ) , and the Gibbs predictor can be run exactly in the same time, given uniform random integers. This is poly ( m ) ⋅ 2 o ( N ) \operatorname{poly}(m)\cdot2^{o(N)} poly ( m ) ⋅ 2 o ( N ) when κ = o ( ( log N ) 1 / 4 / log log N ) \kappa=o((\log N)^{1/4}/\sqrt{\log\log N}) κ = o (( log N ) 1/4 / log log N ) .
(b) With noise. Let η = a / b \eta=a/b η = a / b for integers 0 < a 0<a 0 < a , 2 a < b 2a<b 2 a < b , and let s = max { 4 κ ( m + 1 ) , m + 2 , κ 2 } s=\max\{4\kappa(m+1),m+2,\kappa^2\} s = max { 4 κ ( m + 1 ) , m + 2 , κ 2 } . Then p S ( x ) p_S(x) p S ( x ) and B ( S , x ) \mathrm{B}(S,x) B ( S , x ) can be computed exactly in time poly ( N , m , log b ) ⋅ 2 O ( s / log s ) \operatorname{poly}(N,m,\log b)\cdot2^{O(s/\sqrt{\log s})} poly ( N , m , log b ) ⋅ 2 O ( s / l o g s ) , and the Gibbs predictor can be run in the same time, exactly given exact samples from explicitly given distributions on { 0 , … , m } \{0,\ldots,m\} { 0 , … , m } , and otherwise within statistical distance ν \nu ν for any ν ≥ 2 − poly ( N , m ) \nu\ge2^{-\operatorname{poly}(N,m)} ν ≥ 2 − poly ( N , m ) . For m ≥ max { κ , 2 } m\ge\max\{\kappa,2\} m ≥ max { κ , 2 } the time is poly ( N , m , log b ) ⋅ 2 O ( κ m / log m ) \operatorname{poly}(N,m,\log b)\cdot2^{O(\kappa m/\sqrt{\log m})} poly ( N , m , log b ) ⋅ 2 O ( κm / l o g m ) .
Proof of Theorem 3.1. ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 1. Let: S + S^+ S + be S S S followed by the example ( x , 1 ) (x,1) ( x , 1 ) . Then ω S + ( w ) = ω S ( w ) μ [ h w ( x ) ≠ 1 ] \omega_{S^+}(w)=\omega_S(w)\mu^{[h_w(x)\ne1]} ω S + ( w ) = ω S ( w ) μ [ h w ( x ) = 1 ] for every w w w .
Proof: The error count of w w w on S + S^+ S + is e S ( w ) + [ h w ( x ) ≠ 1 ] e_S(w)+[h_w(x)\ne1] e S ( w ) + [ h w ( x ) = 1 ] .
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 2. Part (a) holds.
⟨ 2 ⟩ \langle2\rangle ⟨ 2 ⟩ 1. p S ( x ) = ∣ VS ( S + ) ∣ / ∣ VS ( S ) ∣ p_S(x)=|\operatorname{VS}(S^+)|/|\operatorname{VS}(S)| p S ( x ) = ∣ VS ( S + ) ∣/∣ VS ( S ) ∣ .
Proof: For η = 0 \eta=0 η = 0 the posterior is uniform on VS ( S ) \operatorname{VS}(S) VS ( S ) , and the descriptions in VS ( S ) \operatorname{VS}(S) VS ( S ) with h w ( x ) = 1 h_w(x)=1 h w ( x ) = 1 are exactly those in VS ( S + ) \operatorname{VS}(S^+) VS ( S + ) . ⟨2⟩2. p S ( x ) p_S(x) p S ( x ) and B ( S , x ) \mathrm{B}(S,x) B ( S , x ) can be computed in time poly ( N , m ) ⋅ 2 κ ⋅ T κ ( N ) \operatorname{poly}(N,m)\cdot2^\kappa\cdot T_\kappa(N) poly ( N , m ) ⋅ 2 κ ⋅ T κ ( N ) .
Proof: Theorem 2.8 computes both counts, for samples of sizes m m m and m + 1 m+1 m + 1 . Both are integers below 2 N + 1 2^{N+1} 2 N + 1 , so the quotient and its comparison with 1 / 2 1/2 1/2 take polynomial time.
⟨2⟩3. The Gibbs predictor runs exactly in the same time.
Proof: Theorem 2.8 draws a uniform element w w w of V S ( S ) \mathrm{VS}(S) VS ( S ) , which is a draw from π S \pi_S π S , and h w ( x ) h_w(x) h w ( x ) is computable in polynomial time.
⟨2⟩4. If κ = o ( ( log N ) 1 / 4 / log log N ) \kappa=o((\log N)^{1/4}/\sqrt{\log\log N}) κ = o (( log N ) 1/4 / log log N ) , the time is poly ( m ) ⋅ 2 o ( N ) \operatorname{poly}(m)\cdot2^{o(N)} poly ( m ) ⋅ 2 o ( N ) .
Proof: Then κ 2 g ( N ) = κ 2 N log log N / log N = o ( N ) \kappa^2g(N)=\kappa^2N\log\log N/\sqrt{\log N}=o(N) κ 2 g ( N ) = κ 2 N log log N / log N = o ( N ) and 2 κ = 2 o ( N ) 2^\kappa=2^{o(N)} 2 κ = 2 o ( N ) , and poly ( N ) = 2 o ( N ) \operatorname{poly}(N)=2^{o(N)} poly ( N ) = 2 o ( N ) .
⟨2⟩5. Q.E.D.
⟨1⟩3. Part (b) holds.
⟨2⟩1. Let: , for j ∈ { 0 , … , m } j\in\{0,\ldots,m\} j ∈ { 0 , … , m } , a j a_j a j and b j b_j b j be the numbers of descriptions w w w with e S ( w ) = j e_S(w)=j e S ( w ) = j and h w ( x ) = 1 h_w(x)=1 h w ( x ) = 1 , respectively h w ( x ) = 0 h_w(x)=0 h w ( x ) = 0 , and Let: b − 1 = a m + 1 = 0 b_{-1}=a_{m+1}=0 b − 1 = a m + 1 = 0 . Let: c j c_j c j and c j + c_j^+ c j + be the coefficients of V j V^j V j in E S E_S E S and E S + E_{S^+} E S + . Then c j = a j + b j c_j=a_j+b_j c j = a j + b j for 0 ≤ j ≤ m 0\le j\le m 0 ≤ j ≤ m and c j + = a j + b j − 1 c_j^+=a_j+b_{j-1} c j + = a j + b j − 1 for 0 ≤ j ≤ m + 1 0\le j\le m+1 0 ≤ j ≤ m + 1 .
Proof: By ⟨1⟩1 with V V V in place of μ \mu μ : a description with h w ( x ) = 1 h_w(x)=1 h w ( x ) = 1 contributes V e S ( w ) V^{e_S(w)} V e S ( w ) to E S + E_{S^+} E S + , and one with h w ( x ) = 0 h_w(x)=0 h w ( x ) = 0 contributes V e S ( w ) + 1 V^{e_S(w)+1} V e S ( w ) + 1 .
⟨2⟩2. The numbers a j , b j a_j,b_j a j , b j for 0 ≤ j ≤ m 0\le j\le m 0 ≤ j ≤ m are determined by the coefficients: a j = c j + − b j − 1 a_j=c_j^+-b_{j-1} a j = c j + − b j − 1 and b j = c j − a j b_j=c_j-a_j b j = c j − a j , in the order j = 0 , 1 , … , m j=0,1,\ldots,m j = 0 , 1 , … , m .
Proof: By ⟨2⟩1 and induction on j j j , starting from b − 1 = 0 b_{-1}=0 b − 1 = 0 .
⟨2⟩3. p S ( x ) = ∑ j = 0 m a j μ j / ∑ j = 0 m c j μ j p_S(x)=\sum_{j=0}^{m}a_j\mu^j/\sum_{j=0}^{m}c_j\mu^j p S ( x ) = ∑ j = 0 m a j μ j / ∑ j = 0 m c j μ j , and the denominator is positive.
Proof: ∑ w : h w ( x ) = 1 ω S ( w ) = ∑ j a j μ j \sum_{w:h_w(x)=1}\omega_S(w)=\sum_j a_j\mu^j ∑ w : h w ( x ) = 1 ω S ( w ) = ∑ j a j μ j and Z S = ∑ j c j μ j Z_S=\sum_j c_j\mu^j Z S = ∑ j c j μ j . Since μ > 0 \mu>0 μ > 0 and ∑ j c j = 2 N \sum_jc_j=2^N ∑ j c j = 2 N , Z S > 0 Z_S>0 Z S > 0 .
⟨2⟩4. p S ( x ) p_S(x) p S ( x ) and B ( S , x ) \mathrm{B}(S,x) B ( S , x ) can be computed in time poly ( N , m , log b ) ⋅ 2 O ( s / log s ) \operatorname{poly}(N,m,\log b)\cdot2^{O(s/\sqrt{\log s})} poly ( N , m , log b ) ⋅ 2 O ( s / l o g s ) .
Proof: Theorem 2.9 computes E S E_S E S and E S + E_{S^+} E S + ; the parameter of the second is s s s , and that of the first is at most s s s . With μ = a / ( b − a ) \mu=a/(b-a) μ = a / ( b − a ) , multiplying numerator and denominator by ( b − a ) m (b-a)^m ( b − a ) m turns them into the integers ∑ j a j a j ( b − a ) m − j \sum_j a_ja^j(b-a)^{m-j} ∑ j a j a j ( b − a ) m − j and ∑ j c j a j ( b − a ) m − j \sum_j c_ja^j(b-a)^{m-j} ∑ j c j a j ( b − a ) m − j , which have O ( N + m log b ) O(N+m\log b) O ( N + m log b ) bits, since a j , c j ≤ 2 N a_j,c_j\le2^N a j , c j ≤ 2 N . Computing them, the quotient and its comparison with 1 / 2 1/2 1/2 takes time poly ( N , m , log b ) \operatorname{poly}(N,m,\log b) poly ( N , m , log b ) .
⟨2⟩5. The Gibbs predictor runs in time poly ( N , m , log b ) ⋅ 2 O ( s / log s ) \operatorname{poly}(N,m,\log b)\cdot2^{O(s/\sqrt{\log s})} poly ( N , m , log b ) ⋅ 2 O ( s / l o g s ) , exactly given exact samples from explicitly given distributions on { 0 , … , m } \{0,\ldots,m\} { 0 , … , m } , and otherwise within statistical distance ν \nu ν .
Proof: Apply Theorem 2.10 with λ = ln ( 1 / μ ) > 0 \lambda=\ln(1/\mu)>0 λ = ln ( 1/ μ ) > 0 . It samples w w w with probability proportional to e − λ e S ( w ) = μ e S ( w ) = ω S ( w ) e^{-\lambda e_S(w)}=\mu^{e_S(w)}=\omega_S(w) e − λ e S ( w ) = μ e S ( w ) = ω S ( w ) , that is, from π S \pi_S π S ; output h w ( x ) h_w(x) h w ( x ) . The distributions on { 0 , … , m } \{0,\ldots,m\} { 0 , … , m } that it samples from have weights c j μ j c_j\mu^j c j μ j , or, after scaling by ( b − a ) m (b-a)^m ( b − a ) m , the integers c j a j ( b − a ) m − j c_ja^j(b-a)^{m-j} c j a j ( b − a ) m − j with O ( N + m log b ) O(N+m\log b) O ( N + m log b ) bits, and computing them adds a factor poly ( N , m , log b ) \operatorname{poly}(N,m,\log b) poly ( N , m , log b ) .
⟨2⟩6. If m ≥ max { κ , 2 } m\ge\max\{\kappa,2\} m ≥ max { κ , 2 } then s / log s ≤ 8 κ m / log m s/\sqrt{\log s}\le8\kappa m/\sqrt{\log m} s / log s ≤ 8 κm / log m .
Proof: Here 4 κ ( m + 1 ) ≤ 8 κ m 4\kappa(m+1)\le8\kappa m 4 κ ( m + 1 ) ≤ 8 κm , m + 2 ≤ 2 m ≤ 8 κ m m+2\le2m\le8\kappa m m + 2 ≤ 2 m ≤ 8 κm and κ 2 ≤ κ m \kappa^2\le\kappa m κ 2 ≤ κm , so s ≤ 8 κ m s\le8\kappa m s ≤ 8 κm , and s ≥ m s\ge m s ≥ m gives log s ≥ log m \log s\ge\log m log s ≥ log m .
⟨2⟩7. Q.E.D.
⟨1⟩4. Q.E.D.
Corollary 3.2 (Bayesian inference from counting). If #\kappa -SAT on N N N variables with M M M clauses can be solved in time T ( N , M ) T(N,M) T ( N , M ) , with T T T nondecreasing, then noiseless Bayesian inference in context for every κ \kappa κ -local class with N N N -bit descriptions takes time 2 T ( N , ( m + 1 ) 2 κ ) + poly ( N , m ) ⋅ 2 κ 2T(N,(m+1)2^\kappa)+\operatorname{poly}(N,m)\cdot2^\kappa 2 T ( N , ( m + 1 ) 2 κ ) + poly ( N , m ) ⋅ 2 κ on consistent contexts of size m m m .
Proof of Corollary 3.2. ⟨1⟩1. ∣ VS ( S ) ∣ |\operatorname{VS}(S)| ∣ VS ( S ) ∣ and ∣ VS ( S + ) ∣ |\operatorname{VS}(S^+)| ∣ VS ( S + ) ∣ are the numbers of satisfying assignments of κ \kappa κ -CNFs Γ S \Gamma_S Γ S and Γ S + \Gamma_{S^+} Γ S + on N N N variables with at most ( m + 1 ) 2 κ (m+1)2^\kappa ( m + 1 ) 2 κ clauses each, computable in time poly ( N , m ) ⋅ 2 κ \operatorname{poly}(N,m)\cdot2^\kappa poly ( N , m ) ⋅ 2 κ .
Proof: Imported Theorem 2.7 for the samples S S S and S + S^+ S + .
⟨1⟩2. Q.E.D.
Proof: Count both with the assumed algorithm, in time T ( N , ( m + 1 ) 2 κ ) T(N,(m+1)2^\kappa) T ( N , ( m + 1 ) 2 κ ) each because T T T is nondecreasing, and output the quotient, which is p S ( x ) p_S(x) p S ( x ) by ⟨2⟩1 of the proof of Theorem 3.1.
The Bayes risk
Theorem 3.3 (Bayes risk). Let H = { h w : w ∈ { 0 , 1 } N } \mathcal{H}=\{h_w:w\in\{0,1\}^N\} H = { h w : w ∈ { 0 , 1 } N } be any class, D \mathcal{D} D any input distribution and η ∈ [ 0 , 1 / 2 ) \eta\in[0,1/2) η ∈ [ 0 , 1/2 ) the noise rate. Let h ( η ) = − η log η − ( 1 − η ) log ( 1 − η ) h(\eta)=-\eta\log\eta-(1-\eta)\log(1-\eta) h ( η ) = − η log η − ( 1 − η ) log ( 1 − η ) , with h ( 0 ) = 0 h(0)=0 h ( 0 ) = 0 .
(a) R m + 1 ∗ ≤ R m ∗ R^*_{m+1}\le R^*_m R m + 1 ∗ ≤ R m ∗ for every m ≥ 0 m\ge0 m ≥ 0 .
(b) R m ∗ ≤ η + ( 1 − 2 η ) N ( 1 − h ( η ) ) ( m + 1 ) R^*_m\le\eta+\frac{(1-2\eta)N}{(1-h(\eta))(m+1)} R m ∗ ≤ η + ( 1 − h ( η )) ( m + 1 ) ( 1 − 2 η ) N for every m ≥ 0 m\ge0 m ≥ 0 . In particular, without noise R m ∗ ≤ N / ( m + 1 ) R^*_m\le N/(m+1) R m ∗ ≤ N / ( m + 1 ) .
(c) Without noise, the Gibbs predictor has risk at most 2 R m ∗ ≤ 2 N / ( m + 1 ) 2R^*_m\le2N/(m+1) 2 R m ∗ ≤ 2 N / ( m + 1 ) .
Proof of Theorem 3.3. ⟨1⟩1. Let: an infinite episode draw w w w uniformly, inputs x 1 , x 2 , … x_1,x_2,\ldots x 1 , x 2 , … independently from D \mathcal{D} D and noise bits ξ 1 , ξ 2 , … \xi_1,\xi_2,\ldots ξ 1 , ξ 2 , … , with y t = h w ( x t ) ⊕ ξ t y_t=h_w(x_t)\oplus\xi_t y t = h w ( x t ) ⊕ ξ t , and Let: S t S_t S t be its first t t t examples. Let ( x , y ) (x,y) ( x , y ) be one more example of the same task, independent of the sequence given w w w . Then R t ∗ = Pr [ B ( S t , x t + 1 ) ≠ y t + 1 ] = Pr [ B ( S t , x ) ≠ y ] R^*_t=\Pr[\mathrm{B}(S_t,x_{t+1})\ne y_{t+1}]=\Pr[\mathrm{B}(S_t,x)\ne y] R t ∗ = Pr [ B ( S t , x t + 1 ) = y t + 1 ] = Pr [ B ( S t , x ) = y ] for every t ≥ 0 t\ge0 t ≥ 0 .
Proof: ( w , S t , x t + 1 , y t + 1 ) (w,S_t,x_{t+1},y_{t+1}) ( w , S t , x t + 1 , y t + 1 ) and ( w , S t , x , y ) (w,S_t,x,y) ( w , S t , x , y ) both have the distribution of an episode of length t t t with its task.
⟨1⟩2. Part (a) holds.
⟨2⟩1. Let: q t = Pr [ y = 1 ∣ S t , x ] q_t=\Pr[y=1\mid S_t,x] q t = Pr [ y = 1 ∣ S t , x ] . Then q t = p ^ S t ( x ) q_t=\hat{p}_{S_t}(x) q t = p ^ S t ( x ) and R t ∗ = E [ min { q t , 1 − q t } ] R^*_t=\mathbb{E}[\min\{q_t,1-q_t\}] R t ∗ = E [ min { q t , 1 − q t }] .
Proof: By ⟨1⟩1 and Lemma 2.5.
⟨2⟩2. E [ q t + 1 ∣ S t , x ] = q t \mathbb{E}[q_{t+1}\mid S_t,x]=q_t E [ q t + 1 ∣ S t , x ] = q t .
Proof: The tower property, since ( S t , x ) (S_t,x) ( S t , x ) is a function of ( S t + 1 , x ) (S_{t+1},x) ( S t + 1 , x ) .
⟨2⟩3. E [ min { q t + 1 , 1 − q t + 1 } ∣ S t , x ] ≤ min { q t , 1 − q t } \mathbb{E}[\min\{q_{t+1},1-q_{t+1}\}\mid S_t,x]\le\min\{q_t,1-q_t\} E [ min { q t + 1 , 1 − q t + 1 } ∣ S t , x ] ≤ min { q t , 1 − q t } .
Proof: The function q ↦ min { q , 1 − q } q\mapsto\min\{q,1-q\} q ↦ min { q , 1 − q } is concave; apply the conditional Jensen inequality and ⟨2⟩2.
⟨2⟩4. Q.E.D.
Proof: Take expectations in ⟨2⟩3 and use ⟨2⟩1.
⟨1⟩3. Without noise, in every infinite episode the predictions y ^ t = B ( S t − 1 , x t ) \hat{y}_t=\mathrm{B}(S_{t-1},x_t) y ^ t = B ( S t − 1 , x t ) are wrong for at most N N N indices t ≥ 1 t\ge1 t ≥ 1 .
⟨2⟩1. ∣ VS ( S 0 ) ∣ = 2 N |\operatorname{VS}(S_0)|=2^N ∣ VS ( S 0 ) ∣ = 2 N , VS ( S t ) ⊆ VS ( S t − 1 ) \operatorname{VS}(S_t)\subseteq\operatorname{VS}(S_{t-1}) VS ( S t ) ⊆ VS ( S t − 1 ) , and w ∈ VS ( S t ) w\in\operatorname{VS}(S_t) w ∈ VS ( S t ) for all t t t .
Proof: Without noise every label is h w ( x t ) h_w(x_t) h w ( x t ) .
⟨2⟩2. If y ^ t ≠ y t \hat{y}_t\ne y_t y ^ t = y t , then ∣ VS ( S t ) ∣ ≤ ∣ VS ( S t − 1 ) ∣ / 2 |\operatorname{VS}(S_t)|\le|\operatorname{VS}(S_{t-1})|/2 ∣ VS ( S t ) ∣ ≤ ∣ VS ( S t − 1 ) ∣/2 .
Proof: Let p = p S t − 1 ( x t ) p=p_{S_{t-1}}(x_t) p = p S t − 1 ( x t ) , the fraction of VS ( S t − 1 ) \operatorname{VS}(S_{t-1}) VS ( S t − 1 ) that labels x t x_t x t positive. If y t = 1 y_t=1 y t = 1 and y ^ t = 0 \hat{y}_t=0 y ^ t = 0 , then p < 1 / 2 p<1/2 p < 1/2 and ∣ VS ( S t ) ∣ = p ∣ VS ( S t − 1 ) ∣ |\operatorname{VS}(S_t)|=p|\operatorname{VS}(S_{t-1})| ∣ VS ( S t ) ∣ = p ∣ VS ( S t − 1 ) ∣ . If y t = 0 y_t=0 y t = 0 and y ^ t = 1 \hat{y}_t=1 y ^ t = 1 , then p ≥ 1 / 2 p\ge1/2 p ≥ 1/2 and ∣ V S ( S t ) ∣ = ( 1 − p ) ∣ V S ( S t − 1 ) ∣ |\mathrm{VS}(S_t)|=(1-p)|\mathrm{VS}(S_{t-1})| ∣ VS ( S t ) ∣ = ( 1 − p ) ∣ VS ( S t − 1 ) ∣ .
⟨2⟩3. Q.E.D.
Proof: After r r r mistakes, 1 ≤ ∣ V S ( S t ) ∣ ≤ 2 N − r 1 \le|\mathrm{VS}(S_t)| \le2^{N-r} 1 ≤ ∣ VS ( S t ) ∣ ≤ 2 N − r by ⟨2⟩1 and ⟨2⟩2, so r ≤ N r \le N r ≤ N .
⟨1⟩4. With noise rate η > 0 \eta> 0 η > 0 , ∑ t = 1 m + 1 ( R t − 1 ∗ − η ) ≤ ( 1 − 2 η ) N / ( 1 − h ( η ) ) \sum_{t=1}^{m+1}(R^*_{t-1}-\eta) \le(1-2\eta)N/(1-h(\eta)) ∑ t = 1 m + 1 ( R t − 1 ∗ − η ) ≤ ( 1 − 2 η ) N / ( 1 − h ( η )) .
⟨2⟩1. Let: P v ( y 1.. T ) = ∏ t ≤ T ( 1 − η ) [ y t = h v ( x t ) ] η [ y t ≠ h v ( x t ) ] P_v(y_{1..T})=\prod_{t\le T}(1-\eta)^{[y_t=h_v(x_t)]}\eta^{[y_t\ne h_v(x_t)]} P v ( y 1.. T ) = ∏ t ≤ T ( 1 − η ) [ y t = h v ( x t )] η [ y t = h v ( x t )] for each description v v v , given the inputs, and Q = 2 − N ∑ v P v Q=2^{-N}\sum_v P_v Q = 2 − N ∑ v P v . Then Q ( y 1.. t ) / Q ( y 1.. t − 1 ) Q(y_{1..t})/Q(y_{1..t-1}) Q ( y 1.. t ) / Q ( y 1.. t − 1 ) is p ^ t \hat p_t p ^ t if y t = 1 y_t=1 y t = 1 and 1 − p ^ t 1-\hat p_t 1 − p ^ t if y t = 0 y_t=0 y t = 0 , where p ^ t = p ^ S t − 1 ( x t ) \hat p_t=\hat p_{S_{t-1}}(x_t) p ^ t = p ^ S t − 1 ( x t ) .
Proof: Q ( y 1.. t ) / Q ( y 1.. t − 1 ) Q(y_{1..t})/Q(y_{1..t-1}) Q ( y 1.. t ) / Q ( y 1.. t − 1 ) is the conditional probability of y t y_t y t given the inputs and y 1.. t − 1 y_{1..t-1} y 1.. t − 1 in the mixture, which is the predictive probability of ⟨1⟩1 of the proof of Lemma 2.5.
⟨2⟩2. ∑ t = 1 m + 1 log P w ( y t ∣ x t ) Q ( y t ∣ S t − 1 , x t ) ≤ N \sum_{t=1}^{m+1}\log\frac{P_w(y_t\mid x_t)}{Q(y_t\mid S_{t-1},x_t)}\le N ∑ t = 1 m + 1 log Q ( y t ∣ S t − 1 , x t ) P w ( y t ∣ x t ) ≤ N in every episode, where P w ( y t ∣ x t ) P_w(y_t\mid x_t) P w ( y t ∣ x t ) is the t t t -th factor of P w P_w P w and Q ( y t ∣ S t − 1 , x t ) Q(y_t\mid S_{t-1},x_t) Q ( y t ∣ S t − 1 , x t ) is the quotient of ⟨2⟩1.
Proof: The sum telescopes to log ( P w ( y 1.. m + 1 ) / Q ( y 1.. m + 1 ) ) \log(P_w(y_{1..m+1})/Q(y_{1..m+1})) log ( P w ( y 1.. m + 1 ) / Q ( y 1.. m + 1 )) , and Q ≥ 2 − N P w Q\ge2^{-N}P_w Q ≥ 2 − N P w .
⟨2⟩3. Let: q t = ( 1 − η ) h w ( x t ) + η ( 1 − h w ( x t ) ) q_t=(1-\eta)h_w(x_t)+\eta(1-h_w(x_t)) q t = ( 1 − η ) h w ( x t ) + η ( 1 − h w ( x t )) and K L t = K L ( Bern ( q t ) ∥ Bern ( p ^ t ) ) \mathrm{KL}_t=\mathrm{KL}(\operatorname{Bern}(q_t)\mathbin\Vert\operatorname{Bern}(\hat p_t)) KL t = KL ( Bern ( q t ) ∥ Bern ( p ^ t )) in bits. Then ∑ t = 1 m + 1 E [ K L t ] ≤ N \sum_{t=1}^{m+1}\mathbb{E}[\mathrm{KL}_t]\le N ∑ t = 1 m + 1 E [ KL t ] ≤ N .
Proof: Given w w w , all inputs and y 1.. t − 1 y_{1..t-1} y 1.. t − 1 , the label y t y_t y t is 1 with probability q t q_t q t , so the conditional expectation of the t t t -th term of ⟨2⟩2 is K L t \mathrm{KL}_t KL t . All terms are finite because p ^ t ∈ [ η , 1 − η ] \hat p_t\in[\eta,1-\eta] p ^ t ∈ [ η , 1 − η ] .
⟨2⟩4. If y ^ t ≠ h w ( x t ) \hat y_t\ne h_w(x_t) y ^ t = h w ( x t ) , then K L t ≥ 1 − h ( η ) \mathrm{KL}_t\ge1-h(\eta) KL t ≥ 1 − h ( η ) .
Proof: For fixed q q q , the divergence K L ( Bern ( q ) ∥ Bern ( p ) ) \mathrm{KL}(\operatorname{Bern}(q)\mathbin\Vert\operatorname{Bern}(p)) KL ( Bern ( q ) ∥ Bern ( p )) decreases in p p p on ( 0 , q ] (0,q] ( 0 , q ] and increases on [ q , 1 ) [q,1) [ q , 1 ) . At p = 1 / 2 p=1/2 p = 1/2 it equals 1 − h ( q ) 1-h(q) 1 − h ( q ) , and h ( q ) = h ( η ) h(q)=h(\eta) h ( q ) = h ( η ) for q ∈ { η , 1 − η } q\in\{\eta,1-\eta\} q ∈ { η , 1 − η } . If h w ( x t ) = 1 h_w(x_t)=1 h w ( x t ) = 1 and y ^ t = 0 \hat y_t=0 y ^ t = 0 , then q t = 1 − η > 1 / 2 > p ^ t q_t=1-\eta>1/2>\hat p_t q t = 1 − η > 1/2 > p ^ t . If h w ( x t ) = 0 h_w(x_t)=0 h w ( x t ) = 0 and y ^ t = 1 \hat y_t=1 y ^ t = 1 , then q t = η < 1 / 2 ≤ p ^ t q_t=\eta<1/2\le\hat p_t q t = η < 1/2 ≤ p ^ t . In both cases 1 / 2 1/2 1/2 lies between q t q_t q t and p ^ t \hat p_t p ^ t .
⟨2⟩5. Pr [ y ^ t ≠ y t ] = η + ( 1 − 2 η ) Pr [ y ^ t ≠ h w ( x t ) ] \Pr[\hat y_t\ne y_t]=\eta+(1-2\eta)\Pr[\hat y_t\ne h_w(x_t)] Pr [ y ^ t = y t ] = η + ( 1 − 2 η ) Pr [ y ^ t = h w ( x t )] .
Proof: Given w w w , S t − 1 S_{t-1} S t − 1 and x t x_t x t , the noise bit ξ t \xi_t ξ t is independent and y ^ t \hat y_t y ^ t is fixed; the prediction is wrong with probability η \eta η if y ^ t = h w ( x t ) \hat y_t=h_w(x_t) y ^ t = h w ( x t ) and 1 − η 1-\eta 1 − η otherwise.
⟨2⟩6. Q.E.D.
Proof: By ⟨1⟩1, R t − 1 ∗ = Pr [ y ^ t ≠ y t ] R^*_{t-1}=\Pr[\hat y_t\ne y_t] R t − 1 ∗ = Pr [ y ^ t = y t ] . By ⟨2⟩5 and ⟨2⟩4, R t − 1 ∗ − η ≤ ( 1 − 2 η ) E [ K L t ] / ( 1 − h ( η ) ) R^*_{t-1}-\eta\le(1-2\eta)\mathbb{E}[\mathrm{KL}_t]/(1-h(\eta)) R t − 1 ∗ − η ≤ ( 1 − 2 η ) E [ KL t ] / ( 1 − h ( η )) ; sum and use ⟨2⟩3.
⟨1⟩5. Part (b) holds.
Proof: Without noise, ⟨1⟩3 and ⟨1⟩1 give ∑ t = 1 m + 1 R t − 1 ∗ ≤ N \sum_{t=1}^{m+1}R^*_{t-1}\le N ∑ t = 1 m + 1 R t − 1 ∗ ≤ N , which is the case η = 0 \eta=0 η = 0 of the inequality of ⟨1⟩4. In both cases, part (a) gives R m ∗ ≤ R t − 1 ∗ R^*_m\le R^*_{t-1} R m ∗ ≤ R t − 1 ∗ for t ≤ m + 1 t\le m+1 t ≤ m + 1 , so ( m + 1 ) ( R m ∗ − η ) ≤ ( 1 − 2 η ) N / ( 1 − h ( η ) ) (m+1)(R^*_m-\eta)\le(1-2\eta)N/(1-h(\eta)) ( m + 1 ) ( R m ∗ − η ) ≤ ( 1 − 2 η ) N / ( 1 − h ( η )) .
⟨1⟩6. Part (c) holds.
Proof: Without noise, let p = p S ( x ) p=p_S(x) p = p S ( x ) for the context S S S and query x x x of an episode. Given S S S and x x x , the task and the description drawn by G are independent draws from π S \pi_S π S , so G errs with probability 2 p ( 1 − p ) ≤ 2 min { p , 1 − p } 2p(1-p)\le2\min\{p,1-p\} 2 p ( 1 − p ) ≤ 2 min { p , 1 − p } , and B errs with probability min { p , 1 − p } \min\{p,1-p\} min { p , 1 − p } by Lemma 2.5. Take expectations and use part (b).
⟨1⟩7. Q.E.D.
Proofs for Section 4
The gadgets
Lemma 4.1 (Bayes gadget). Let k ≥ 1 k \ge1 k ≥ 1 , and let F F F be a k k k -CNF on z 1 , … , z n z_1,\ldots,z_n z 1 , … , z n with M M M clauses, none of them tautological. Let Γ F \Gamma_F Γ F be the CNF on z 1 , … , z n , a , u z_1,\ldots,z_n,a,u z 1 , … , z n , a , u with the clauses
¬ a ∨ C ( C ∈ F ) , a ∨ ¬ z i ( i ∈ [ n ] ) , a ∨ ¬ u . \neg a \lor C \quad(C \in F), \qquad a \lor\neg z_i \quad(i \in[n]), \qquad a \lor\neg u. ¬ a ∨ C ( C ∈ F ) , a ∨ ¬ z i ( i ∈ [ n ]) , a ∨ ¬ u . Then Γ F \Gamma_F Γ F is a ( k + 1 ) (k+1) ( k + 1 ) -CNF with M + n + 1 M+n+1 M + n + 1 clauses, none of them tautological. It has 2 # F + 1 2\#F+1 2# F + 1 satisfying assignments, and exactly 2 # F 2\#F 2# F of them set a = 1 a=1 a = 1 .
Proof of Lemma 4.1. ⟨1⟩1. Γ F \Gamma_F Γ F is a ( k + 1 ) (k+1) ( k + 1 ) -CNF with M + n + 1 M+n+1 M + n + 1 clauses, none of them tautological.
Proof: A clause ¬ a ∨ C \neg a \lor C ¬ a ∨ C has width ∣ C ∣ + 1 ≤ k + 1 \lvert C\rvert+1 \le k+1 ∣ C ∣ + 1 ≤ k + 1 and is tautological only if C C C is, because a a a does not occur in C C C . The clauses a ∨ ¬ z i a \lor\neg z_i a ∨ ¬ z i and a ∨ ¬ u a \lor\neg u a ∨ ¬ u have width 2 ≤ k + 1 2 \le k+1 2 ≤ k + 1 and are not tautological. The M + n + 1 M+n+1 M + n + 1 clauses are distinct.
⟨1⟩2. The satisfying assignments with a = 1 a=1 a = 1 are the assignments ( z , 1 , u ) (z,1,u) ( z , 1 , u ) with z z z satisfying F F F and u ∈ { 0 , 1 } u \in\{0,1\} u ∈ { 0 , 1 } ; there are 2 # F 2\#F 2# F of them.
Proof: With a = 1 a=1 a = 1 the clauses a ∨ ¬ z i a \lor\neg z_i a ∨ ¬ z i and a ∨ ¬ u a \lor\neg u a ∨ ¬ u hold and ¬ a ∨ C \neg a \lor C ¬ a ∨ C is equivalent to C C C .
⟨1⟩3. Exactly one satisfying assignment has a = 0 a=0 a = 0 , namely z = 0 n z=0^n z = 0 n , u = 0 u=0 u = 0 .
Proof: With a = 0 a=0 a = 0 the clauses ¬ a ∨ C \neg a \lor C ¬ a ∨ C hold, a ∨ ¬ z i a \lor\neg z_i a ∨ ¬ z i forces z i = 0 z_i=0 z i = 0 , and a ∨ ¬ u a \lor\neg u a ∨ ¬ u forces u = 0 u=0 u = 0 .
⟨1⟩4. Q.E.D.
Lemma 4.2 (Bayes contexts). Let k ≥ 2 k \ge2 k ≥ 2 , and let F F F be a k k k -CNF on n n n variables with M M M clauses, none of them tautological. One can compute in polynomial time:
(a) a context S F L D S_F^{\mathrm{LD}} S F LD of M + n + 1 M+n+1 M + n + 1 positive examples of L D k + 1 \mathrm{LD}_{k+1} LD k + 1 in dimension n + 2 n+2 n + 2 , and
(b) a context S F B P S_F^{\mathrm{BP}} S F BP of M + n + k M+n+k M + n + k positive examples of B P 2 k \mathrm{BP}_{2k} BP 2 k in dimension n + k + 1 n+k+1 n + k + 1 ,
both consistent, such that the query e a e_a e a has posterior predictive p S ( e a ) = 2 # F / ( 2 # F + 1 ) p_{S}(e_a)=2\#F/(2\#F+1) p S ( e a ) = 2# F / ( 2# F + 1 ) in both. In particular p S ( e a ) = 0 p_S(e_a)=0 p S ( e a ) = 0 if F F F is unsatisfiable, p S ( e a ) ≥ 2 / 3 p_S(e_a)\ge2/3 p S ( e a ) ≥ 2/3 otherwise, and # F = p S ( e a ) / ( 2 ( 1 − p S ( e a ) ) ) \#F=p_S(e_a)/(2(1-p_S(e_a))) # F = p S ( e a ) / ( 2 ( 1 − p S ( e a ))) .
Proof of Lemma 4.2. ⟨1⟩1. Part (a) holds, with a bijection between V S ( S F L D ) \mathrm{VS}(S_F^{\mathrm{LD}}) VS ( S F LD ) and the satisfying assignments of Γ F \Gamma_F Γ F that preserves the value of a a a .
Proof: Index the n + 2 n+2 n + 2 coordinates by z 1 , … , z n , a , u z_1,\ldots,z_n,a,u z 1 , … , z n , a , u . For each clause D D D of Γ F \Gamma_F Γ F , let x D x_D x D have entry + 1 +1 + 1 at the variables that occur positively in D D D , − 1 -1 − 1 at those that occur negatively, and 0 0 0 elsewhere; it is well defined because D D D is not tautological, and ∣ supp ( x D ) ∣ = ∣ D ∣ ≤ k + 1 \lvert\operatorname{supp}(x_D)\rvert=\lvert D\rvert\le k+1 ∣ supp ( x D )∣ = ∣ D ∣ ≤ k + 1 . By Example 2.2 (a), h σ ( x D ) = 1 h_\sigma(x_D)=1 h σ ( x D ) = 1 if and only if the assignment with value ( 1 + σ i ) / 2 (1+\sigma_i)/2 ( 1 + σ i ) /2 at coordinate i i i satisfies D D D . So σ ↦ ( ( 1 + σ i ) / 2 ) i \sigma\mapsto((1+\sigma_i)/2)_i σ ↦ (( 1 + σ i ) /2 ) i maps V S ( S F L D ) \mathrm{VS}(S_F^{\mathrm{LD}}) VS ( S F LD ) bijectively onto the satisfying assignments of Γ F \Gamma_F Γ F , and the coordinate of a a a is + 1 +1 + 1 exactly when a = 1 a=1 a = 1 .
⟨1⟩2. Part (b) holds, with a bijection between V S ( S F B P ) \mathrm{VS}(S_F^{\mathrm{BP}}) VS ( S F BP ) and the satisfying assignments of Γ F \Gamma_F Γ F that preserves the value of a a a .
Proof: Γ F \Gamma_F Γ F is a ( k + 1 ) (k+1) ( k + 1 ) -CNF without tautological clauses on n + 2 n+2 n + 2 variables (Lemma 4.1). Imported Theorem 2.11 with k + 1 ≥ 3 k+1 \ge3 k + 1 ≥ 3 in place of k k k gives p = k − 1 p=k-1 p = k − 1 padding coordinates, M + n + 1 + ( k − 1 ) = M + n + k M+n+1+(k-1)=M+n+k M + n + 1 + ( k − 1 ) = M + n + k examples in dimension n + 2 + k − 1 = n + k + 1 n+2+k-1=n+k+1 n + 2 + k − 1 = n + k + 1 , all labeled 1 1 1 , with supports of size at most 2 ( k + 1 ) − 2 = 2 k 2(k+1)-2=2k 2 ( k + 1 ) − 2 = 2 k . A sign vector is consistent if and only if its padding coordinates are 1 1 1 and the assignment 1 [ σ i = 1 ] \mathbf{1}[\sigma_i=1] 1 [ σ i = 1 ] of the first n + 2 n+2 n + 2 coordinates satisfies Γ F \Gamma_F Γ F ; this is a bijection, and it reads a a a off the coordinate of a a a . ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 3. In both contexts, h ( e a ) = 1 h(e_a)=1 h ( e a ) = 1 exactly for the descriptions whose assignment has a = 1 a=1 a = 1 .
Proof: For literal disjunctions, supp ( e a ) = { a } \operatorname{supp}(e_a)=\{a\} supp ( e a ) = { a } , so h σ ( e a ) = 1 h_\sigma(e_a)=1 h σ ( e a ) = 1 if and only if σ a = 1 \sigma_a=1 σ a = 1 . For binarized perceptrons, ⟨ σ , e a ⟩ = σ a ≥ 0 \langle\sigma,e_a\rangle=\sigma_a\ge0 ⟨ σ , e a ⟩ = σ a ≥ 0 if and only if σ a = 1 \sigma_a=1 σ a = 1 .
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 4. p S ( e a ) = 2 # F / ( 2 # F + 1 ) p_S(e_a)=2^{\#F}/(2^{\#F}+1) p S ( e a ) = 2 # F / ( 2 # F + 1 ) in both contexts, and both are consistent.
Proof: Without noise the posterior is uniform on the version space, which by ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 1 and ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 2 is in bijection with the 2 # F + 1 ≥ 1 2^{\#F}+1\ge1 2 # F + 1 ≥ 1 satisfying assignments of Γ F \Gamma_F Γ F , of which 2 # F 2^{\#F} 2 # F have a = 1 a=1 a = 1 (Lemma 4.1). Apply ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 3.
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 5. Q.E.D.
Proof: If # F = 0 \#F=0 # F = 0 the predictive is 0, and if # F ≥ 1 \#F\ge1 # F ≥ 1 it is 2 # F / ( 2 # F + 1 ) ≥ 2 / 3 2^{\#F}/(2^{\#F}+1)\ge2/3 2 # F / ( 2 # F + 1 ) ≥ 2/3 . Solving p = 2 # F / ( 2 # F + 1 ) p=2^{\#F}/(2^{\#F}+1) p = 2 # F / ( 2 # F + 1 ) gives # F = p / ( 2 ( 1 − p ) ) \#F=p/(2(1-p)) # F = p / ( 2 ( 1 − p )) . The constructions take polynomial time.
Lemma 4.3 (Bayes contexts by length). Given a CNF F F F of length L ≥ 1 L\ge1 L ≥ 1 , one can compute in polynomial time a consistent context of positive examples of LD3 _3 3 in dimension N ≤ 3 L + 2 N\le3L+2 N ≤ 3 L + 2 , with at most min { 5 L + 1 , 36 N 2 } \min\{5L+1,36N^2\} min { 5 L + 1 , 36 N 2 } examples, such that the query e a e_a e a has posterior predictive 0 if F F F is unsatisfiable and at least 2 / 3 2/3 2/3 otherwise. The same holds for BP4 _4 4 in dimension N + 1 N+1 N + 1 , with one more example.
Proof of Lemma 4.3. ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 1. One can compute in polynomial time a 3-CNF F ′ F' F ′ without tautological clauses, with n ≤ 2 L n\le2L n ≤ 2 L variables and M ≤ L M\le L M ≤ L clauses, that is satisfiable if and only if F F F is.
Proof: Delete the tautological clauses of F F F and the variables that no longer occur; this changes neither satisfiability nor the bounds. Replace each clause ℓ 1 ∨ ⋯ ∨ ℓ r \ell_1\lor\cdots\lor\ell_r ℓ 1 ∨ ⋯ ∨ ℓ r with r ≥ 4 r\ge4 r ≥ 4 by the r − 2 r-2 r − 2 clauses ℓ 1 ∨ ℓ 2 ∨ t 1 \ell_1\lor\ell_2\lor t_1 ℓ 1 ∨ ℓ 2 ∨ t 1 , ¬ t 1 ∨ ℓ 3 ∨ t 2 \neg t_1\lor\ell_3\lor t_2 ¬ t 1 ∨ ℓ 3 ∨ t 2 , … \ldots … , ¬ t r − 3 ∨ ℓ r − 1 ∨ ℓ r \neg t_{r-3}\lor\ell_{r-1}\lor\ell_r ¬ t r − 3 ∨ ℓ r − 1 ∨ ℓ r with r − 3 r-3 r − 3 fresh variables. An assignment that satisfies the clause extends to one that satisfies the chain: set t j = 1 t_j=1 t j = 1 for the indices j j j before the clause of the chain that contains the first true literal, and t j = 0 t_j=0 t j = 0 after it. If every ℓ i \ell_i ℓ i is false, the chain forces t 1 = 1 t_1=1 t 1 = 1 , then t 2 = 1 t_2=1 t 2 = 1 , and so on, and its last clause fails. The occurring variables number at most L L L , the fresh ones at most ∑ C max { 0 , ∣ C ∣ − 3 } ≤ L \sum_C\max\{0,\lvert C\rvert-3\}\le L ∑ C max { 0 , ∣ C ∣ − 3 } ≤ L , and the clauses at most ∑ C max { 1 , ∣ C ∣ − 2 } ≤ L \sum_C\max\{1,\lvert C\rvert-2\}\le L ∑ C max { 1 , ∣ C ∣ − 2 } ≤ L . No new clause is tautological.
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 2. Let: Γ ′ \Gamma' Γ ′ be the CNF on the variables z z z of F ′ F' F ′ , one fresh variable y C y_C y C for each clause C C C of F ′ F' F ′ of width 3, and two more variables a , u a,u a , u , with the clauses: ¬ a ∨ C \neg a\lor C ¬ a ∨ C for each clause C C C of F ′ F' F ′ of width at most 2; ¬ a ∨ ℓ 1 ∨ y C \neg a\lor\ell_1\lor y_C ¬ a ∨ ℓ 1 ∨ y C , ¬ y C ∨ ℓ 2 ∨ ℓ 3 \neg y_C\lor\ell_2\lor\ell_3 ¬ y C ∨ ℓ 2 ∨ ℓ 3 and a ∨ ¬ y C a\lor\neg y_C a ∨ ¬ y C for each clause C = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 C=\ell_1\lor\ell_2\lor\ell_3 C = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 ; a ∨ ¬ z a\lor\neg z a ∨ ¬ z for each variable z z z of F ′ F' F ′ ; and a ∨ ¬ u a\lor\neg u a ∨ ¬ u . Then Γ ′ \Gamma' Γ ′ is a 3-CNF without tautological clauses on N ≤ n + M + 2 ≤ 3 L + 2 N\le n+M+2\le3L+2 N ≤ n + M + 2 ≤ 3 L + 2 variables with at most min { 5 L + 1 , 36 N 2 } \min\{5L+1,36N^2\} min { 5 L + 1 , 36 N 2 } clauses.
Proof: The fresh variables are distinct, and F ′ F' F ′ has no tautological clause. Let F 0 F_0 F 0 be F F F without its tautological clauses, L 0 ≤ L L_0\le L L 0 ≤ L its length, and n 0 ≤ N n_0\le N n 0 ≤ N the number of its variables. The bounds of ⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 1 hold with L 0 L_0 L 0 in place of L L L , so Γ ′ \Gamma' Γ ′ has at most 3 M + n + 1 ≤ 5 L 0 + 1 3M+n+1\le5L_0+1 3 M + n + 1 ≤ 5 L 0 + 1 clauses. The clauses of F 0 F_0 F 0 of width at most 2 are distinct and not tautological, so there are at most 2 n 0 + 4 ( n 0 2 ) ≤ 2 N 2 2n_0+4\binom{n_0}{2}\le2N^2 2 n 0 + 4 ( 2 n 0 ) ≤ 2 N 2 of them, of total length at most 4 N 2 4N^2 4 N 2 . A clause of F 0 F_0 F 0 of width r ≥ 3 r\ge3 r ≥ 3 gives Γ ′ \Gamma' Γ ′ at least r / 3 r/3 r /3 variables of its own: one variable y C y_C y C if r = 3 r=3 r = 3 , and r − 3 r-3 r − 3 chain variables and r − 2 r-2 r − 2 variables y C y_C y C if r ≥ 4 r\ge4 r ≥ 4 . So these clauses have total length at most 3 N 3N 3 N . Hence L 0 ≤ 4 N 2 + 3 N ≤ 7 N 2 L_0\le4N^2+3N\le7N^2 L 0 ≤ 4 N 2 + 3 N ≤ 7 N 2 and 5 L 0 + 1 ≤ 36 N 2 5L_0+1\le36N^2 5 L 0 + 1 ≤ 36 N 2 .
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 3. Exactly one satisfying assignment of Γ ′ \Gamma' Γ ′ has a = 0 a=0 a = 0 .
Proof: With a = 0 a=0 a = 0 the clauses a ∨ ¬ z a\lor\neg z a ∨ ¬ z , a ∨ ¬ y C a\lor\neg y_C a ∨ ¬ y C and a ∨ ¬ u a\lor\neg u a ∨ ¬ u force all other variables to 0. The all-zero assignment of them satisfies ¬ a ∨ ⋯ \neg a\lor\cdots ¬ a ∨ ⋯ through ¬ a \neg a ¬ a and ¬ y C ∨ ℓ 2 ∨ ℓ 3 \neg y_C\lor\ell_2\lor\ell_3 ¬ y C ∨ ℓ 2 ∨ ℓ 3 through ¬ y C \neg y_C ¬ y C .
⟨ 1 ⟩ \langle1\rangle ⟨ 1 ⟩ 4. The number A A A of satisfying assignments of Γ ′ \Gamma' Γ ′ with a = 1 a=1 a = 1 is 0 if F ′ F' F ′ is unsatisfiable and at least 2 otherwise.
Proof: With a = 1 a=1 a = 1 , the clauses with the literal a a a hold, ¬ a ∨ C \neg a\lor C ¬ a ∨ C reduces to C C C , and the two clauses of a clause C C C of width 3 reduce to ( ℓ 1 ∨ y C ) ∧ ( ¬ y C ∨ ℓ 2 ∨ ℓ 3 ) (\ell_1 \lor y_C) \land(\lnot y_C \lor\ell_2 \lor\ell_3) ( ℓ 1 ∨ y C ) ∧ ( ¬ y C ∨ ℓ 2 ∨ ℓ 3 ) . For a fixed z z z , this has a solution y C y_C y C if and only if z z z satisfies C C C : if ℓ 1 \ell_1 ℓ 1 is true, y C = 0 y_C = 0 y C = 0 works; if ℓ 1 \ell_1 ℓ 1 is false, y C y_C y C must be 1, which works if and only if ℓ 2 ∨ ℓ 3 \ell_2 \lor\ell_3 ℓ 2 ∨ ℓ 3 holds. So the assignments with a = 1 a = 1 a = 1 exist only for z z z satisfying F ′ F' F ′ , each such z z z has at least one choice of every y C y_C y C , and u u u is free.
⟨1⟩5. The positive examples of LD3 _3 3 for the clauses of Γ ′ \Gamma' Γ ′ form a consistent context in dimension N N N with at most min { 5 L + 1 , 36 N 2 } \min\{5L+1,36N^2\} min { 5 L + 1 , 36 N 2 } examples, and the query e a e_a e a has posterior predictive A / ( A + 1 ) A/(A+1) A / ( A + 1 ) , which is 0 if F F F is unsatisfiable and at least 2 / 3 2/3 2/3 otherwise.
Proof. As in ⟨1⟩1 and ⟨1⟩3–⟨1⟩4 of the proof of Lemma 4.2, the version space is in bijection with the satisfying assignments of Γ ′ \Gamma' Γ ′ , and e a e_a e a is labeled by a a a . Apply ⟨1⟩3, ⟨1⟩4 and ⟨1⟩1.
⟨1⟩6. Q.E.D.
Proof. For BP4 _4 4 , apply Imported Theorem 2.11 to Γ ′ \Gamma' Γ ′ with k = 3 k = 3 k = 3 : one padding coordinate and one more example, supports of size at most 4, and the same bijection, as in ⟨1⟩2 of the proof of Lemma 4.2. All steps take polynomial time.
Lower bounds
Theorem 4.4 (Hardness of Bayesian inference in context). (a) Assume Hypothesis 2.14. For every γ ∈ ( 0 , 1 ) \gamma\in(0,1) γ ∈ ( 0 , 1 ) there are K K K and c γ c_\gamma c γ such that no randomized algorithm with error probability at most 1 / 3 1/3 1/3 does the following in time O ( 2 ( 1 − γ ) N ) O(2^{(1-\gamma)N}) O ( 2 ( 1 − γ ) N ) : given a consistent context of at most N c γ N^{c_\gamma} N c γ positive examples of BP⌈ K log N ⌉ _{\lceil K \log N\rceil} ⌈ K l o g N ⌉ in dimension N N N and a query, output a number within 1 / 4 1/4 1/4 of the posterior predictive. The same holds for LD⌈ K log N ⌉ _{\lceil K \log N\rceil} ⌈ K l o g N ⌉ , for computing B ( S , x ) B(S,x) B ( S , x ) , and for running the Gibbs predictor exactly or within statistical distance 1 / 6 1/6 1/6 . Under Hypothesis 2.15, there are K K K , c γ c_\gamma c γ , ρ > 0 \rho> 0 ρ > 0 with the same statements for time O ( 2 ρ N ) O(2^{\rho N}) O ( 2 ρN ) .
(b) Assume E T H C l e n \mathrm{ETH}_{C}^{\mathrm{len}} ETH C len , and let θ > 0 \theta> 0 θ > 0 . No randomized algorithm with error probability at most 1 / 3 1/3 1/3 outputs, for every consistent context of at most 36 N 2 36N^2 36 N 2 positive examples of LD3 _3 3 in dimension N N N and every query, a number within 1 / 4 1/4 1/4 of the posterior predictive in time 2 N / ( log N ) C + θ 2^{N/(\log N)^{C+\theta}} 2 N / ( l o g N ) C + θ . The same holds for BP4 _4 4 , for computing B ( S , x ) B(S,x) B ( S , x ) , and for running the Gibbs predictor exactly or within statistical distance 1 / 6 1/6 1/6 .
Proof of Theorem 4.4. ⟨1⟩1. If an algorithm A A A outputs a number within 1 / 4 1/4 1/4 of p S ( e a ) p_S(e_a) p S ( e a ) , with error probability at most 1 / 3 1/3 1/3 , on a context S S S of Lemma 4.2 or Lemma 4.3, then one run of A A A decides the satisfiability of F F F with error probability at most 1 / 3 1/3 1/3 . The same holds for an algorithm that computes B ( S , e a ) B(S,e_a) B ( S , e a ) , and for O ( 1 ) O(1) O ( 1 ) runs of the Gibbs predictor, exact or within statistical distance 1 / 6 1/6 1/6 .
Proof. The predictive is 0 if F F F is unsatisfiable and at least 2 / 3 2/3 2/3 otherwise, so a number within 1 / 4 1/4 1/4 of it is at most 1 / 4 1/4 1/4 in the first case and at least 5 / 12 5/12 5/12 in the second; answer “satisfiable” when it exceeds 1 / 3 1/3 1/3 . B ( S , e a ) = 1 B(S,e_a)=1 B ( S , e a ) = 1 exactly when the predictive is at least 1 / 2 1/2 1/2 , that is, when F ′ F' F ′ is satisfiable. A run of the Gibbs predictor outputs 1 with probability at most 1 / 6 1/6 1/6 in the first case and at least 1 / 2 1/2 1/2 in the second; twelve runs and the answer “satisfiable” when at least four of them output 1 err with probability less than 1 / 7 1/7 1/7 in the first case and at most 299 / 4096 < 1 / 13 299/4096 < 1/13 299/4096 < 1/13 in the second.
⟨1⟩2. Part (a) holds under Hypothesis 2.14.
⟨2⟩1. Let: K ′ , c ′ K',c' K ′ , c ′ be given by Imported Theorem 2.12 for γ / 2 \gamma/2 γ /2 , and Let: K = 2 K ′ K = 2K' K = 2 K ′ and c γ = c ′ + 1 c_\gamma= c'+1 c γ = c ′ + 1 . Assume: an algorithm A A A that does what part (a) excludes, in time O ( 2 ( 1 − γ ) N ) O(2^{(1-\gamma)N}) O ( 2 ( 1 − γ ) N ) .
⟨2⟩2. Given a k k k -CNF F F F on n n n variables with k ≤ K ′ log n k \le K' \log n k ≤ K ′ log n and at most n c ′ n^{c'} n c ′ clauses, with n n n large, Let: k 0 = max { 2 , ⌊ K ′ log n ⌋ } k_0 = \max\{2,\lfloor K' \log n\rfloor\} k 0 = max { 2 , ⌊ K ′ log n ⌋} , delete the tautological clauses of F F F , and build S F B P S_F^{\mathrm{BP}} S F BP by Lemma 4.2 with k 0 k_0 k 0 in place of k k k . Then S F B P S_F^{\mathrm{BP}} S F BP is a consistent context of at most N c γ N^{c\gamma} N c γ positive examples of B P ⌈ K log N ⌉ \mathrm{BP}_{\lceil K\log N\rceil} BP ⌈ K l o g N ⌉ in dimension N = n + k 0 + 1 N=n+k_0+1 N = n + k 0 + 1 .
Proof: F F F is a k 0 k_0 k 0 -CNF. The supports have size at most 2 k 0 ≤ 2 K ′ log n ≤ K log N 2k_0 \le2K'\log n \le K\log N 2 k 0 ≤ 2 K ′ log n ≤ K log N , and the context has at most n c ′ + n + k 0 ≤ N c ′ + 1 n^{c'}+n+k_0 \le N^{c'+1} n c ′ + n + k 0 ≤ N c ′ + 1 examples for large n n n .
⟨2⟩3. Running A \mathcal{A} A on ( S F B P , e a ) (S_F^{\mathrm{BP}},e_a) ( S F BP , e a ) decides F F F in time O ( 2 ( 1 − γ / 2 ) n ) O(2^{(1-\gamma/2)n}) O ( 2 ( 1 − γ /2 ) n ) with error probability at most 1 / 3 1/3 1/3 .
Proof: By ⟨1⟩1. The time is poly ( n ) + O ( 2 ( 1 − γ ) ( n + K ′ log n + 1 ) ) = O ( 2 ( 1 − γ ) n n K ′ ) \operatorname{poly}(n)+O(2^{(1-\gamma)(n+K'\log n+1)})=O(2^{(1-\gamma)n}n^{K'}) poly ( n ) + O ( 2 ( 1 − γ ) ( n + K ′ l o g n + 1 ) ) = O ( 2 ( 1 − γ ) n n K ′ ) , which is O ( 2 ( 1 − γ / 2 ) n ) O(2^{(1-\gamma/2)n}) O ( 2 ( 1 − γ /2 ) n ) .
⟨2⟩4. The same argument applies to L D ⌈ K log N ⌉ \mathrm{LD}_{\lceil K\log N\rceil} LD ⌈ K l o g N ⌉ with S F L D S_F^{\mathrm{LD}} S F LD of dimension n + 2 n+2 n + 2 and supports of size at most k 0 + 1 ≤ K log N k_0+1\le K\log N k 0 + 1 ≤ K log N , and to B and the Gibbs predictor by ⟨1⟩1.
⟨2⟩5. Q.E.D.
Proof: ⟨2⟩3 contradicts Imported Theorem 2.12.
⟨1⟩3. Part (a) holds under Hypothesis 2.15.
Proof: Imported Theorem 2.12 gives K ′ K' K ′ , c ′ c' c ′ , ρ ′ \rho' ρ ′ for time O ( 2 ρ ′ n ) O(2^{\rho'n}) O ( 2 ρ ′ n ) . With K = 2 K ′ K=2K' K = 2 K ′ , c γ = c ′ + 1 c_\gamma=c'+1 c γ = c ′ + 1 and ρ = ρ ′ / 2 \rho=\rho'/2 ρ = ρ ′ /2 , the construction of ⟨1⟩2 turns an algorithm in time O ( 2 ρ N ) O(2^{\rho N}) O ( 2 ρN ) into one in time O ( 2 ρ n n K ′ ) = O ( 2 ρ ′ n ) O(2^{\rho n}n^{K'})=O(2^{\rho'n}) O ( 2 ρ n n K ′ ) = O ( 2 ρ ′ n ) .
⟨1⟩4. Part (b) holds.
⟨2⟩1. Assume: an algorithm A \mathcal{A} A that, for all sufficiently large N N N , does what part (b) excludes in time 2 f ( N ) 2^{f(N)} 2 f ( N ) , where f ( N ) = N / ( log N ) C + θ f(N)=N/(\log N)^{C+\theta} f ( N ) = N / ( log N ) C + θ .
⟨2⟩2. Given a CNF F F F of length L L L , build the context of Lemma 4.3, of dimension N F ≤ 3 L + 2 N_F\le3L+2 N F ≤ 3 L + 2 , and run A \mathcal{A} A . This decides the satisfiability of F F F with error probability at most 1 / 3 1/3 1/3 .
Proof: By ⟨1⟩1.
⟨2⟩3. The time is at most 2 L / ( log L ) C 2^{L/(\log L)^C} 2 L / ( l o g L ) C for all sufficiently large L L L .
Proof: The context has dimension N F ≤ 3 L + 2 N_F\le3L+2 N F ≤ 3 L + 2 and at most 36 N F 2 36N_F^2 36 N F 2 examples, so it is an input of the kind that A \mathcal{A} A handles. Below any fixed dimension there are only finitely many such contexts, because their size is bounded, so on them A \mathcal{A} A takes time O ( 1 ) O(1) O ( 1 ) . The function f f f is nondecreasing for N ≥ e C + θ N\ge e^{C+\theta} N ≥ e C + θ . For large L L L , f ( 3 L + 2 ) ≤ 4 L / ( log L ) C + θ ≤ L / ( 2 ( log L ) C ) f(3L+2)\le4L/(\log L)^{C+\theta}\le L/(2(\log L)^C) f ( 3 L + 2 ) ≤ 4 L / ( log L ) C + θ ≤ L / ( 2 ( log L ) C ) once ( log L ) θ ≥ 8 (\log L)^\theta\ge8 ( log L ) θ ≥ 8 , so the time is poly ( L ) + O ( 1 ) + 2 L / ( 2 ( log L ) C ) ≤ 2 L / ( log L ) C \operatorname{poly}(L)+O(1)+2^{L/(2(\log L)^C)}\le2^{L/(\log L)^C} poly ( L ) + O ( 1 ) + 2 L / ( 2 ( l o g L ) C ) ≤ 2 L / ( l o g L ) C .
⟨2⟩4. The same holds for B P 4 \mathrm{BP}_4 BP 4 in dimension N F + 1 N_F+1 N F + 1 , and for B and the Gibbs predictor.
Proof: By Lemma 4.3 and ⟨1⟩1. The B P 4 \mathrm{BP}_4 BP 4 context has dimension N F + 1 N_F+1 N F + 1 and at most 36 N F 2 + 1 ≤ 36 ( N F + 1 ) 2 36N_F^2+1\le36(N_F+1)^2 36 N F 2 + 1 ≤ 36 ( N F + 1 ) 2 examples, and the extra dimension changes f ( 3 L + 2 ) f(3L+2) f ( 3 L + 2 ) to f ( 3 L + 3 ) f(3L+3) f ( 3 L + 3 ) .
⟨2⟩5. Q.E.D.
Proof: ⟨2⟩2–⟨2⟩4 contradict E T H C l e n \mathrm{ETH}_{C}^{\mathrm{len}} ETH C len .
⟨1⟩5. Q.E.D.
Proofs for Section 5
Halfspaces in context
Proposition 5.1 (Halfspace forms). Let σ ∈ { ± 1 } n \sigma\in\{\pm1\}^n σ ∈ { ± 1 } n and x ∈ { − 1 , 0 , 1 } n x\in\{-1,0,1\}^n x ∈ { − 1 , 0 , 1 } n with r = ∣ supp ( x ) ∣ r=\lvert\operatorname{supp}(x)\rvert r = ∣ supp ( x )∣ . Then h σ B P ( x ) = 1 [ ⟨ σ , x ⟩ ≥ 0 ] h_\sigma^{\mathrm{BP}}(x)=1[\langle\sigma,x\rangle\ge0] h σ BP ( x ) = 1 [⟨ σ , x ⟩ ≥ 0 ] and h σ L D ( x ) = 1 [ ⟨ σ , x ⟩ + r − 2 ≥ 0 ] h_\sigma^{\mathrm{LD}}(x)=1[\langle\sigma,x\rangle+r-2\ge0] h σ LD ( x ) = 1 [⟨ σ , x ⟩ + r − 2 ≥ 0 ] . If h σ B P ( x ) = 0 h_\sigma^{\mathrm{BP}}(x)=0 h σ BP ( x ) = 0 then ⟨ σ , x ⟩ ≤ − 1 \langle\sigma,x\rangle\le-1 ⟨ σ , x ⟩ ≤ − 1 , and if h σ L D ( x ) = 0 h_\sigma^{\mathrm{LD}}(x)=0 h σ LD ( x ) = 0 then ⟨ σ , x ⟩ + r − 2 = − 2 \langle\sigma,x\rangle+r-2=-2 ⟨ σ , x ⟩ + r − 2 = − 2 .
Proof of Proposition 5.1. ⟨1⟩1. The statements for BP hold. Proof. h σ B P ( x ) = 1 [ ⟨ σ , x ⟩ ≥ 0 ] h_{\sigma}^{\mathrm{BP}}(x)=\mathbf{1}[\langle\sigma,x\rangle\ge0] h σ BP ( x ) = 1 [⟨ σ , x ⟩ ≥ 0 ] is the definition, and ⟨ σ , x ⟩ \langle\sigma,x\rangle ⟨ σ , x ⟩ is an integer, so it is at most − 1 -1 − 1 when it is negative.
⟨1⟩2. Let: t t t be the number of i ∈ supp ( x ) i\in\operatorname{supp}(x) i ∈ supp ( x ) with x i = σ i x_i=\sigma_i x i = σ i . Then ⟨ σ , x ⟩ = 2 t − r \langle\sigma,x\rangle=2t-r ⟨ σ , x ⟩ = 2 t − r .
Proof. Each i ∈ supp ( x ) i\in\operatorname{supp}(x) i ∈ supp ( x ) contributes σ i x i = + 1 \sigma_i x_i=+1 σ i x i = + 1 if x i = σ i x_i=\sigma_i x i = σ i and − 1 -1 − 1 otherwise.
⟨1⟩3. Q.E.D.
Proof. By definition h σ L D ( x ) = 1 [ t ≥ 1 ] h_{\sigma}^{\mathrm{LD}}(x)=\mathbf{1}[t\ge1] h σ LD ( x ) = 1 [ t ≥ 1 ] . By ⟨1⟩2, t ≥ 1 t\ge1 t ≥ 1 if and only if ⟨ σ , x ⟩ + r − 2 = 2 t − 2 ≥ 0 \langle\sigma,x\rangle+r-2=2t-2\ge0 ⟨ σ , x ⟩ + r − 2 = 2 t − 2 ≥ 0 , and t = 0 t=0 t = 0 gives − 2 -2 − 2 .
Theorem 5.2 (Linear programming in context). For every k ≤ n k\le n k ≤ n , the in-context learner A L P \mathrm{ALP} ALP for B P k \mathrm{BP}_k BP k and for L D k \mathrm{LD}_k LD k runs in time poly ( n , m ) \operatorname{poly}(n,m) poly ( n , m ) and is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( n + 1 , ε , δ ) m_{\mathrm{VC}}(n+1,\varepsilon,\delta) m VC ( n + 1 , ε , δ ) examples, which is O ( ( n log ( 1 / ε ) + log ( 1 / δ ) ) / ε ) O((n\log(1/\varepsilon)+\log(1/\delta))/\varepsilon) O (( n log ( 1/ ε ) + log ( 1/ δ )) / ε ) . Its risk in every noiseless episode, for every input distribution, is O ( n log m / m ) O(n\log m/m) O ( n log m / m ) .
Proof of Theorem 5.2. ⟨1⟩1. If the context is consistent with σ \sigma σ , then v = σ v=\sigma v = σ satisfies (2) .
Proof. By Proposition 5.1: a positive example has ⟨ σ , x i ⟩ + c ( x i ) ≥ 0 \langle\sigma,x_i\rangle+c(x_i)\ge0 ⟨ σ , x i ⟩ + c ( x i ) ≥ 0 , and a negative one has ⟨ σ , x i ⟩ ≤ − 1 \langle\sigma,x_i\rangle\le-1 ⟨ σ , x i ⟩ ≤ − 1 with c = 0 c=0 c = 0 for BP, and ⟨ σ , x i ⟩ + c ( x i ) = − 2 \langle\sigma,x_i\rangle+c(x_i)=-2 ⟨ σ , x i ⟩ + c ( x i ) = − 2 for LD.
⟨1⟩2. Every solution v v v of (2) classifies every example of the context correctly.
Proof. Positive examples get value at least 0 0 0 and negative ones at most − 1 < 0 -1<0 − 1 < 0 .
⟨1⟩3. Let: G = { x ↦ 1 [ ⟨ v , x ⟩ + c ( x ) ≥ 0 ] : v ∈ R n } \mathcal{G}=\{x\mapsto\mathbf{1}[\langle v,x\rangle+c(x)\ge0]:v\in\mathbb{R}^{n}\} G = { x ↦ 1 [⟨ v , x ⟩ + c ( x ) ≥ 0 ] : v ∈ R n } . It contains every h σ h_{\sigma} h σ and has VC dimension at most n + 1 n+1 n + 1 .
Proof. It contains h σ h_{\sigma} h σ by Proposition 5.1. Every element is x ↦ 1 [ ⟨ ( v , 1 ) , ( x , c ( x ) ) ⟩ ≥ 0 ] x\mapsto\mathbf{1}[\langle(v,1),(x,c(x))\rangle\ge0] x ↦ 1 [⟨( v , 1 ) , ( x , c ( x ))⟩ ≥ 0 ] , the restriction of a homogeneous halfspace in R n + 1 \mathbb{R}^{n+1} R n + 1 to the image of x ↦ ( x , c ( x ) ) x\mapsto(x,c(x)) x ↦ ( x , c ( x )) , and homogeneous halfspaces in R n + 1 \mathbb{R}^{n+1} R n + 1 have VC dimension n + 1 n+1 n + 1 .
⟨1⟩4. A L P \mathrm{ALP} ALP runs in time poly ( n , m ) \operatorname{poly}(n,m) poly ( n , m ) .
Proof. (2) is a linear program with n n n variables and m m m constraints whose coefficients are in { − 1 , 0 , 1 } \{-1,0,1\} { − 1 , 0 , 1 } and whose right-hand sides are integers of absolute value at most n + 2 n+2 n + 2 . Linear programming in polynomial time decides feasibility and finds a rational solution.
⟨1⟩5. A L P \mathrm{ALP} ALP is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( n + 1 , ε , δ ) m_{\mathrm{VC}}(n+1,\varepsilon,\delta) m VC ( n + 1 , ε , δ ) examples.
Proof. In the realizable case, ⟨1⟩1 and ⟨1⟩2 show that the output is an element of G \mathcal{G} G consistent with the context. Apply Imported Theorem 2.13(a) with ⟨1⟩3.
⟨1⟩6. Q.E.D.
Proof. For the risk, let ε m = C B ( n + 2 ) log ( 2 m ) / m \varepsilon_m=C_B(n+2)\log(2m)/m ε m = C B ( n + 2 ) log ( 2 m ) / m and δ m = 1 / m \delta_m=1/m δ m = 1/ m . If ε m ≥ 1 \varepsilon_m\ge1 ε m ≥ 1 there is nothing to prove. Otherwise ε m ≥ 1 / m \varepsilon_m\ge1/m ε m ≥ 1/ m , so log ( 2 / ε m ) ≤ log ( 2 m ) \log(2/\varepsilon_m)\le\log(2m) log ( 2/ ε m ) ≤ log ( 2 m ) and m V C ( n + 1 , ε m , δ m ) ≤ C B ( n + 2 ) log ( 2 m ) / ε m = m m_{\mathrm{VC}}(n+1,\varepsilon_m,\delta_m)\le C_B(n+2)\log(2m)/\varepsilon_m=m m VC ( n + 1 , ε m , δ m ) ≤ C B ( n + 2 ) log ( 2 m ) / ε m = m . By ⟨1⟩5 the risk is at most ε m + δ m = O ( n log m / m ) \varepsilon_m+\delta_m=O(n\log m/m) ε m + δ m = O ( n log m / m ) .
Local Fourier features and regression
Theorem 5.4 (Local Fourier features). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions. For x ∈ X x\in\mathcal{X} x ∈ X and T ⊆ [ N ] T\subseteq[N] T ⊆ [ N ] with ∣ T ∣ ≤ κ |T|\le\kappa ∣ T ∣ ≤ κ , let
ψ T ( x ) = { 2 − ∣ R ( x ) ∣ ∑ β ∈ { 0 , 1 } R ( x ) f x ( β ) χ T ( β ) if T ⊆ R ( x ) , 0 otherwise , \psi_T(x)=
\begin{cases}
2^{-|R(x)|}\sum_{\beta\in\{0,1\}^{R(x)}}f_x(\beta)\chi_T(\beta) & \text{if }T\subseteq R(x),\\
0 & \text{otherwise},
\end{cases} ψ T ( x ) = { 2 − ∣ R ( x ) ∣ ∑ β ∈ { 0 , 1 } R ( x ) f x ( β ) χ T ( β ) 0 if T ⊆ R ( x ) , otherwise , and let Ψ ( x ) = ( ψ T ( x ) ) ∣ T ∣ ≤ κ \Psi(x)=(\psi_T(x))_{|T|\le\kappa} Ψ ( x ) = ( ψ T ( x ) ) ∣ T ∣ ≤ κ and Φ ( w ) = ( χ T ( w ) ) ∣ T ∣ ≤ κ \Phi(w)=(\chi_T(w))_{|T|\le\kappa} Φ ( w ) = ( χ T ( w ) ) ∣ T ∣ ≤ κ , vectors of dimension D κ D_\kappa D κ . Then h w ( x ) = ⟨ Φ ( w ) , Ψ ( x ) ⟩ h_w(x)=\langle\Phi(w),\Psi(x)\rangle h w ( x ) = ⟨ Φ ( w ) , Ψ ( x )⟩ for all w w w and x x x . The vector Ψ ( x ) \Psi(x) Ψ ( x ) has at most 2 ∣ R ( x ) ∣ 2^{|R(x)|} 2 ∣ R ( x ) ∣ nonzero entries, all in 2 − N Z 2^{-N}\mathbb{Z} 2 − N Z , and it can be computed in time poly ( N , ∣ x ∣ ) ⋅ κ 2 κ \operatorname{poly}(N,|x|)\cdot\kappa2^\kappa poly ( N , ∣ x ∣ ) ⋅ κ 2 κ . For 1 ≤ κ ≤ N 1\le\kappa\le N 1 ≤ κ ≤ N , D κ ≤ ( e N / κ ) κ D_\kappa\le(eN/\kappa)^\kappa D κ ≤ ( e N / κ ) κ .
Proof of Theorem 5.4. ⟨1⟩1. For every x x x and every β ∈ { 0 , 1 } R ( x ) \beta\in\{0,1\}^{R(x)} β ∈ { 0 , 1 } R ( x ) , f x ( β ) = ∑ T ⊆ R ( x ) ψ T ( x ) χ T ( β ) f_x(\beta)=\sum_{T\subseteq R(x)}\psi_T(x)\chi_T(\beta) f x ( β ) = ∑ T ⊆ R ( x ) ψ T ( x ) χ T ( β ) .
Proof: This is the Fourier expansion of a function on { 0 , 1 } R ( x ) \{0,1\}^{R(x)} { 0 , 1 } R ( x ) [27 Chapter 1] : the characters χ T \chi_T χ T , T ⊆ R ( x ) T\subseteq R(x) T ⊆ R ( x ) , are orthonormal for the uniform measure, and ψ T ( x ) \psi_T(x) ψ T ( x ) is the coefficient of χ T \chi_T χ T .
⟨1⟩2. h w ( x ) = ⟨ Φ ( w ) , Ψ ( x ) ⟩ h_w(x)=\langle\Phi(w),\Psi(x)\rangle h w ( x ) = ⟨ Φ ( w ) , Ψ ( x )⟩ .
Proof: For T ⊆ R ( x ) T\subseteq R(x) T ⊆ R ( x ) we have χ T ( w ∣ R ( x ) ) = χ T ( w ) \chi_T(w|_{R(x)})=\chi_T(w) χ T ( w ∣ R ( x ) ) = χ T ( w ) . So by ⟨1⟩1, h w ( x ) = f x ( w ∣ R ( x ) ) h_w(x)=f_x(w|_{R(x)}) h w ( x ) = f x ( w ∣ R ( x ) ) equals ∑ T ⊆ R ( x ) ψ T ( x ) χ T ( w ) \sum_{T\subseteq R(x)}\psi_T(x)\chi_T(w) ∑ T ⊆ R ( x ) ψ T ( x ) χ T ( w ) . Every T ⊆ R ( x ) T\subseteq R(x) T ⊆ R ( x ) has ∣ T ∣ ≤ κ |T|\le\kappa ∣ T ∣ ≤ κ , and ψ T ( x ) = 0 \psi_T(x)=0 ψ T ( x ) = 0 for the other T T T with ∣ T ∣ ≤ κ |T|\le\kappa ∣ T ∣ ≤ κ .
⟨1⟩3. Ψ ( x ) \Psi(x) Ψ ( x ) has at most 2 ∣ R ( x ) ∣ 2^{|R(x)|} 2 ∣ R ( x ) ∣ nonzero entries, all in 2 − κ Z 2^{-\kappa}\mathbb{Z} 2 − κ Z , and it can be computed in time poly ( N , ∣ x ∣ ) ⋅ κ 2 κ \operatorname{poly}(N,|x|)\cdot\kappa2^\kappa poly ( N , ∣ x ∣ ) ⋅ κ 2 κ .
Proof: Only T ⊆ R ( x ) T\subseteq R(x) T ⊆ R ( x ) give nonzero entries. Each entry is 2 − ∣ R ( x ) ∣ 2^{-|R(x)|} 2 − ∣ R ( x ) ∣ times an integer. Compute R ( x ) R(x) R ( x ) , the 2 ∣ R ( x ) ∣ 2^{|R(x)|} 2 ∣ R ( x ) ∣ values of f x f_x f x , each in time poly ( N , ∣ x ∣ ) \operatorname{poly}(N,|x|) poly ( N , ∣ x ∣ ) , and the Walsh–Hadamard transform of the value table in O ( ∣ R ( x ) ∣ 2 ∣ R ( x ) ∣ ) O(|R(x)|2^{|R(x)|}) O ( ∣ R ( x ) ∣ 2 ∣ R ( x ) ∣ ) operations.
⟨1⟩4. Q.E.D.
Proof: For 1 ≤ κ ≤ N 1\le\kappa\le N 1 ≤ κ ≤ N and j ≤ κ j\le\kappa j ≤ κ we have ( κ / N ) κ ≤ ( κ / N ) j (\kappa/N)^\kappa\le(\kappa/N)^j ( κ / N ) κ ≤ ( κ / N ) j , so ( κ / N ) κ ∑ j ≤ κ ( N j ) ≤ ∑ j ≤ N ( N j ) ( κ / N ) j = ( 1 + κ / N ) N ≤ e κ (\kappa/N)^\kappa\sum_{j\le\kappa}\binom{N}{j}\le\sum_{j\le N}\binom{N}{j}(\kappa/N)^j=(1+\kappa/N)^N\le e^\kappa ( κ / N ) κ ∑ j ≤ κ ( j N ) ≤ ∑ j ≤ N ( j N ) ( κ / N ) j = ( 1 + κ / N ) N ≤ e κ .
Theorem 5.5 (Regression in context). Let H \mathcal{H} H be κ \kappa κ -local with N N N -bit descriptions.
(a) A l i n A_{\mathrm{lin}} A lin is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( D κ + 1 , ε , δ ) m_{\mathrm{VC}}(D_\kappa+1,\varepsilon,\delta) m VC ( D κ + 1 , ε , δ ) examples.
(b) A ℓ 1 A_{\ell_1} A ℓ 1 is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -agnostic from m U C ( D κ + 1 , ε , δ ) m_{\mathrm{UC}}(D_\kappa+1,\varepsilon,\delta) m UC ( D κ + 1 , ε , δ ) examples. In an episode with noise rate η \eta η , its risk is at most η + ε + δ \eta+\varepsilon+\delta η + ε + δ .
(c) Both run in time poly ( N , m , D κ ) ⋅ 2 κ \operatorname{poly}(N,m,D_\kappa)\cdot2^\kappa poly ( N , m , D κ ) ⋅ 2 κ . This is polynomial for constant κ \kappa κ , it is N O ( log N ) N^{O(\log N)} N O ( l o g N ) for κ = O ( log N ) \kappa=O(\log N) κ = O ( log N ) , and it is 2 o ( N ) 2^{o(N)} 2 o ( N ) times a polynomial in m m m whenever κ log ( e N / κ ) = o ( N ) \kappa\log(eN/\kappa)=o(N) κ log ( e N / κ ) = o ( N ) .
Proof of Theorem 5.5. ⟨1⟩1. Let: G Ψ = { x ↦ 1 [ ⟨ v , Ψ ( x ) ⟩ ≥ θ ] : v ∈ R D κ , θ ∈ R } \mathcal{G}_\Psi=\{x\mapsto1[\langle v,\Psi(x)\rangle\ge\theta]:v\in\mathbb{R}^{D_\kappa},\theta\in\mathbb{R}\} G Ψ = { x ↦ 1 [⟨ v , Ψ ( x )⟩ ≥ θ ] : v ∈ R D κ , θ ∈ R } . It has VC dimension at most D κ + 1 D_\kappa+1 D κ + 1 , and it contains every h w h_w h w .
Proof: Its elements are affine halfspaces in R D κ \mathbb{R}^{D_\kappa} R D κ composed with Ψ \Psi Ψ . By Theorem 5.4, h w ( x ) = ⟨ Φ ( w ) , Ψ ( x ) ⟩ ∈ { 0 , 1 } h_w(x)=\langle\Phi(w),\Psi(x)\rangle\in\{0,1\} h w ( x ) = ⟨ Φ ( w ) , Ψ ( x )⟩ ∈ { 0 , 1 } , so h w ( x ) = 1 [ ⟨ Φ ( w ) , Ψ ( x ) ⟩ ≥ 1 / 2 ] h_w(x)=1[\langle\Phi(w),\Psi(x)\rangle\ge1/2] h w ( x ) = 1 [⟨ Φ ( w ) , Ψ ( x )⟩ ≥ 1/2 ] .
⟨1⟩2. Part (a) holds.
Proof: In the realizable case v = Φ ( w ) v=\Phi(w) v = Φ ( w ) solves the system, so Gaussian elimination over Q \mathbb{Q} Q finds a solution v v v . Every solution has ⟨ v , Ψ ( x i ) ⟩ = y i ∈ { 0 , 1 } \langle v,\Psi(x_i)\rangle=y_i\in\{0,1\} ⟨ v , Ψ ( x i )⟩ = y i ∈ { 0 , 1 } , so the output 1 [ ⟨ v , Ψ ( ⋅ ) ⟩ ≥ 1 / 2 ] ∈ G Ψ 1[\langle v,\Psi(\cdot)\rangle\ge1/2]\in\mathcal{G}_\Psi 1 [⟨ v , Ψ ( ⋅ )⟩ ≥ 1/2 ] ∈ G Ψ is consistent with the context. Apply Imported Theorem 2.13(a) with ⟨1⟩1.
⟨1⟩3. Part (b) holds.
⟨2⟩1. Let: D ′ D' D ′ be a distribution on X × { 0 , 1 } \mathcal{X}\times\{0,1\} X × { 0 , 1 } , let w ∗ w^* w ∗ minimize the error of h w h_w h w under D ′ D' D ′ , and let v ^ \hat v v ^ be the regression solution. Then ∑ i ∣ ⟨ v ^ , Ψ ( x i ) ⟩ − y i ∣ ≤ ∑ i [ h w ∗ ( x i ) ≠ y i ] \sum_i|\langle\hat v,\Psi(x_i)\rangle-y_i|\le\sum_i[h_{w^*}(x_i)\ne y_i] ∑ i ∣ ⟨ v ^ , Ψ ( x i )⟩ − y i ∣ ≤ ∑ i [ h w ∗ ( x i ) = y i ] .
Proof: Φ ( w ∗ ) \Phi(w^*) Φ ( w ∗ ) is a feasible point with ∣ ⟨ Φ ( w ∗ ) , Ψ ( x i ) ⟩ − y i ∣ = [ h w ∗ ( x i ) ≠ y i ] |\langle\Phi(w^*),\Psi(x_i)\rangle-y_i|=[h_{w^*}(x_i)\ne y_i] ∣ ⟨ Φ ( w ∗ ) , Ψ ( x i )⟩ − y i ∣ = [ h w ∗ ( x i ) = y i ] , by Theorem 5.4.
⟨2⟩2. Let z ∈ R z\in\mathbb{R} z ∈ R , y ∈ { 0 , 1 } y\in\{0,1\} y ∈ { 0 , 1 } and z ˉ = min { max { z , 0 } , 1 } \bar z=\min\{\max\{z,0\},1\} z ˉ = min { max { z , 0 } , 1 } . If θ \theta θ is uniform in [ 0 , 1 ] [0,1] [ 0 , 1 ] , then Pr θ [ 1 [ z ≥ θ ] ≠ y ] = ∣ z ˉ − y ∣ ≤ ∣ z − y ∣ \Pr_\theta[1[z\ge\theta]\ne y]=|\bar z-y|\le|z-y| Pr θ [ 1 [ z ≥ θ ] = y ] = ∣ z ˉ − y ∣ ≤ ∣ z − y ∣ .
Proof: If y = 1 y=1 y = 1 , the error event is θ > z \theta>z θ > z ; if y = 0 y=0 y = 0 , it is θ ≤ z \theta\le z θ ≤ z .
⟨2⟩3. The classifier g g g chosen by A ℓ 1 A_{\ell_1} A ℓ 1 makes at most as many errors on the context as h w ∗ h_{w^*} h w ∗ .
Proof: By ⟨2⟩2 and ⟨2⟩1, the average over θ ∈ [ 0 , 1 ] \theta\in[0,1] θ ∈ [ 0 , 1 ] of the number of errors of 1 [ ⟨ v ^ , Ψ ( ⋅ ) ⟩ ≥ θ ] 1[\langle\hat v,\Psi(\cdot)\rangle\ge\theta] 1 [⟨ v ^ , Ψ ( ⋅ )⟩ ≥ θ ] is at most the number of errors of h w ∗ h_{w^*} h w ∗ , so some θ \theta θ achieves at most that number. The number of errors is a step function of θ \theta θ that changes only at the values ⟨ v ^ , Ψ ( x i ) ⟩ \langle\hat v,\Psi(x_i)\rangle ⟨ v ^ , Ψ ( x i )⟩ , and on each piece its value is attained at the right end of the piece, at 0 or at 1; so the minimum over [ 0 , 1 ] [0,1] [ 0 , 1 ] is attained at one of at most m + 2 m+2 m + 2 candidates, which A ℓ 1 A_{\ell_1} A ℓ 1 tries.
⟨2⟩4. With probability at least 1 − δ 1-\delta 1 − δ , g g g has error at most OPT + ε \operatorname{OPT}+\varepsilon OPT + ε under D ′ D' D ′ .
Proof: By Imported Theorem 2.13(b) and ⟨1⟩1, with probability at least 1 − δ 1-\delta 1 − δ every element of G Ψ \mathcal{G}_{\Psi} G Ψ , in particular g g g and h w ∗ h_{w^*} h w ∗ , has empirical error within ε / 2 \varepsilon/2 ε /2 of its error. Then the error of g g g is at most its empirical error plus ε / 2 \varepsilon/2 ε /2 , which by ⟨2⟩3 is at most the empirical error of h w ∗ h_{w^*} h w ∗ plus ε / 2 \varepsilon/2 ε /2 , which is at most OPT + ε \operatorname{OPT}+\varepsilon OPT + ε .
⟨2⟩5. q.e.d.
Proof: For an episode with noise rate η \eta η and a fixed task w w w , the examples are independent draws from the distribution of ( x , h w ( x ) ⊕ ξ ) (x,h_w(x)\oplus\xi) ( x , h w ( x ) ⊕ ξ ) , under which h w h_w h w has error η \eta η , so OPT ≤ η \operatorname{OPT}\leq\eta OPT ≤ η , and the query with its target is one more draw. By ⟨2⟩4 the risk is at most η + ε + δ \eta+\varepsilon+\delta η + ε + δ .
⟨1⟩4. Part (c) holds.
Proof: Computing Ψ ( x 1 ) , … , Ψ ( x m ) \Psi(x_1),\ldots,\Psi(x_m) Ψ ( x 1 ) , … , Ψ ( x m ) takes time m ⋅ poly ( N ) ⋅ κ 2 κ m\cdot\operatorname{poly}(N)\cdot\kappa2^\kappa m ⋅ poly ( N ) ⋅ κ 2 κ by Theorem 5.4. Gaussian elimination over Q \mathbb{Q} Q and linear programming with D κ + m D_\kappa+m D κ + m variables and O ( m ) O(m) O ( m ) constraints, with entries in 2 − κ Z 2^{-\kappa}\mathbb{Z} 2 − κ Z of polynomial size, take time poly ( D κ , m ) \operatorname{poly}(D_\kappa,m) poly ( D κ , m ) , and the threshold search takes time poly ( m , D κ ) \operatorname{poly}(m,D_\kappa) poly ( m , D κ ) . Since D κ ≤ ( e N / κ ) κ = 2 κ log ( e N / κ ) D_\kappa\leq(eN/\kappa)^\kappa=2^{\kappa\log(eN/\kappa)} D κ ≤ ( e N / κ ) κ = 2 κ l o g ( e N / κ ) , this is polynomial for constant κ \kappa κ , N O ( log N ) N^{O(\log N)} N O ( l o g N ) for κ = O ( log N ) \kappa=O(\log N) κ = O ( log N ) , and 2 o ( N ) poly ( m ) 2^{o(N)}\operatorname{poly}(m) 2 o ( N ) poly ( m ) when κ log ( e N / κ ) = o ( N ) \kappa\log(eN/\kappa)=o(N) κ log ( e N / κ ) = o ( N ) , since then also 2 κ = 2 o ( N ) 2^\kappa=2^{o(N)} 2 κ = 2 o ( N ) .
⟨1⟩5. q.e.d.
Proofs for Sections 6 and 7
Proposition 6.5 (LPRGc l e n _c^{\mathrm{len}} c len fails below rate 1 / 2 1/2 1/2 ). For every k ≥ 2 k\geq2 k ≥ 2 , every P P P , every constant α ≥ 2 \alpha\geq2 α ≥ 2 and every c < 1 / 2 c<1/2 c < 1/2 , there is a deterministic algorithm that runs in time at most 2 N / ( log N ) c 2^{N/(\log N)^c} 2 N / ( l o g N ) c for large N N N and has advantage at least 1 − 2 − N 1-2^{-N} 1 − 2 − N against G P , ⌈ α N ⌉ G_{P,\lceil\alpha N\rceil} G P , ⌈ α N ⌉ at every N N N . Hence LPRGc l e n _c^{\mathrm{len}} c len is false for every c < 1 / 2 c<1/2 c < 1/2 .
Proof of Proposition 6.5. ⟨1⟩1. Let: m = ⌈ α N ⌉ ≥ 2 N m=\lceil\alpha N\rceil\geq2N m = ⌈ α N ⌉ ≥ 2 N , and Let: the algorithm A A A , on input ( τ , z ) (\tau,z) ( τ , z ) , form the context S = ( ( τ j , z j ) ) j ≤ m S=((\tau_j,z_j))_{j\leq m} S = (( τ j , z j ) ) j ≤ m of R L P \mathrm{RL}_P RL P , compute ∣ V S ( S ) ∣ |\mathrm{VS}(S)| ∣ VS ( S ) ∣ , and output 1 if and only if ∣ V S ( S ) ∣ > 0 |\mathrm{VS}(S)|>0 ∣ VS ( S ) ∣ > 0 . Then A A A is deterministic and runs in time poly ( N ) ⋅ 2 O ( N log log N / log N ) \operatorname{poly}(N)\cdot2^{O(N\log\log N/\sqrt{\log N})} poly ( N ) ⋅ 2 O ( N l o g l o g N / l o g N ) .
Proof: R L P \mathrm{RL}_P RL P is k k k -local, so Imported Theorem 2.8 takes time poly ( N , m ) ⋅ 2 k ⋅ 2 2 1 / 2 k 2 g ( N ) \operatorname{poly}(N,m)\cdot2^k\cdot2^{2^{1/2}k^2g(N)} poly ( N , m ) ⋅ 2 k ⋅ 2 2 1/2 k 2 g ( N ) , with k k k and α \alpha α constant.
⟨1⟩2. On outputs of the generator, A A A outputs 1 with probability 1.
Proof: The task w w w lies in V S ( S ) \mathrm{VS}(S) VS ( S ) .
⟨1⟩3. On uniform z z z , A A A outputs 1 with probability at most 2 − N 2^{-N} 2 − N .
Proof: For fixed τ \tau τ , V S ( S ) ≠ ∅ \mathrm{VS}(S)\neq\varnothing VS ( S ) = ∅ means that z z z is one of the at most 2 N 2^N 2 N strings G P , m ( τ ; w ′ ) G_{P,m}(\tau;w') G P , m ( τ ; w ′ ) , and z z z is uniform among 2 m ≥ 2 2 N 2^m\geq2^{2N} 2 m ≥ 2 2 N strings.
⟨1⟩4. q.e.d.
Proof: The advantage of A A A is at least 1 − 2 − N > 1 / 3 1-2^{-N}>1/3 1 − 2 − N > 1/3 at every N N N . For c < 1 / 2 c<1/2 c < 1/2 , the exponent N log log N / log N N\log\log N/\sqrt{\log N} N log log N / log N is o ( N / ( log N ) c ) o(N/(\log N)^c) o ( N / ( log N ) c ) , so the time of A A A is at most 2 N / ( log N ) c 2^{N/(\log N)^c} 2 N / ( l o g N ) c -pseudorandom, for any k k k , P P P and α ≥ 2 \alpha\geq2 α ≥ 2 , and no choice of α 0 \alpha_0 α 0 in LPRGc l e n _c^{\mathrm{len}} c len works.
:::
Theorem 6.6 (Three regimes for random local functions). Let k ≥ 2 k\geq2 k ≥ 2 be a constant and P : { 0 , 1 } k → { 0 , 1 } P:\{0,1\}^k\to\{0,1\} P : { 0 , 1 } k → { 0 , 1 } . Consider the task family ( R L P , D k ) (\mathrm{RL}_P,D_k) ( RL P , D k ) without noise.
(a) The Bayes risk is at most N / ( m + 1 ) N/(m+1) N / ( m + 1 ) , and the Bayes predictor runs in time poly ( m ) ⋅ 2 O ( N log log N / log N ) \operatorname{poly}(m)\cdot2^{O(N\log\log N/\sqrt{\log N})} poly ( m ) ⋅ 2 O ( N l o g l o g N / l o g N ) .
(b) The learner A l i n \mathrm{A}_{\mathrm{lin}} A lin is ( ε , δ ) (\varepsilon,\delta) ( ε , δ ) -PAC from m V C ( D k ( N ) + 1 , ε , δ ) = O ( ( N k log ( 1 / ε ) + log ( 1 / δ ) ) / ε ) m_{\mathrm{VC}}(D_k(N)+1,\varepsilon,\delta)=O((N^k\log(1/\varepsilon)+\log(1/\delta))/\varepsilon) m VC ( D k ( N ) + 1 , ε , δ ) = O (( N k log ( 1/ ε ) + log ( 1/ δ )) / ε ) examples and runs in time poly ( N , m ) \operatorname{poly}(N,m) poly ( N , m ) .
(c) There is an absolute constant c ∗ c_* c ∗ with the following property. For every in-context learner A A A and every context length m m m , there is a probabilistic algorithm A ′ A' A ′ that runs in time T A + c ∗ ( m + 1 ) k log N T_A+c_*(m+1)^k\log N T A + c ∗ ( m + 1 ) k log N , where T A T_A T A is the running time of A A A on contexts of length m m m , and has advantage exactly ∣ 1 / 2 − R m ( A ) ∣ |1/2-R_m(A)| ∣1/2 − R m ( A ) ∣ against G P , m + 1 G_{P,m+1} G P , m + 1 . If m = m ( N ) m=m(N) m = m ( N ) is computable in time polynomial in N N N , then A ′ A' A ′ is a single algorithm for all N N N .
Proof of Theorem 6.6. ⟨1⟩1. Part (a) holds.
Proof: Theorem 3.3(b) without noise, and Theorem 3.1(a) with κ = k \kappa=k κ = k constant, where poly ( N , m ) ⋅ 2 k ⋅ T k ( N ) = poly ( m ) ⋅ 2 O ( N log log N / log N ) \operatorname{poly}(N,m)\cdot2^k\cdot T_k(N)=\operatorname{poly}(m)\cdot2^{O(N\log\log N/\sqrt{\log N})} poly ( N , m ) ⋅ 2 k ⋅ T k ( N ) = poly ( m ) ⋅ 2 O ( N l o g l o g N / l o g N ) .
⟨1⟩2. Part (b) holds.
Proof: Theorem 5.5(a) with κ = k \kappa=k κ = k , where D k ( N ) ≤ ( e N / k ) k = O ( N k ) D_k(N)\le(eN/k)^k=O(N^k) D k ( N ) ≤ ( e N / k ) k = O ( N k ) , so m V C ( D k ( N ) + 1 , ε , δ ) = O ( ( N k log ( 1 / ε ) + log ( 1 / δ ) ) / ε ) m_{\mathrm{VC}}(D_k(N)+1,\varepsilon,\delta)=O((N^k\log(1/\varepsilon)+\log(1/\delta))/\varepsilon) m VC ( D k ( N ) + 1 , ε , δ ) = O (( N k log ( 1/ ε ) + log ( 1/ δ )) / ε ) and the time is poly ( N , m ) \operatorname{poly}(N,m) poly ( N , m ) .
⟨1⟩3. Part (c) holds.
⟨2⟩1. Let: A ′ A' A ′ , on input ( τ 1 , … , τ m + 1 , z 1 , … , z m + 1 ) (\tau_1,\ldots,\tau_{m+1},z_1,\ldots,z_{m+1}) ( τ 1 , … , τ m + 1 , z 1 , … , z m + 1 ) , run A A A on the context ( ( τ j , z j ) ) j ≤ m ((\tau_j,z_j))_{j\le m} (( τ j , z j ) ) j ≤ m and the query τ m + 1 \tau_{m+1} τ m + 1 , and output 1 if and only if the prediction equals z m + 1 z_{m+1} z m + 1 . Then A ′ A' A ′ runs in time T A + c ∗ ( m + 1 ) k log N T_A+c_*(m+1)^k\log N T A + c ∗ ( m + 1 ) k log N for an absolute constant c ∗ c_* c ∗ , and if m ( N ) m(N) m ( N ) is computable in time polynomial in N N N , A ′ A' A ′ is one algorithm for all N N N .
Proof: Besides running A A A , A ′ A' A ′ copies its input, which has O ( ( m + 1 ) k log N ) O((m+1)^k\log N) O (( m + 1 ) k log N ) bits, and compares two bits. The number m m m is read off the length of the input.
⟨2⟩2. On outputs of the generator, A ′ A' A ′ outputs 1 with probability 1 − R m ( A ) 1-R_m(A) 1 − R m ( A ) .
Proof: For uniform w w w and independent uniform tuples, ( τ , G P , m + 1 ( τ ; w ) ) (\tau,G_{P,m+1}(\tau;w)) ( τ , G P , m + 1 ( τ ; w )) is a noiseless episode of length m m m of the task family ( R L P , D k ) (\mathrm{RL}_P,D_k) ( RL P , D k ) , with target z m + 1 z_{m+1} z m + 1 .
⟨2⟩3. On uniform z z z , A ′ A' A ′ outputs 1 with probability 1 / 2 1/2 1/2 .
Proof: z m + 1 z_{m+1} z m + 1 is uniform and independent of the context, of the query and of the random bits of A A A .
⟨2⟩4. Q.E.D.
Proof: The advantage of A ′ A' A ′ is ∣ 1 − R m ( A ) − 1 / 2 ∣ = ∣ 1 / 2 − R m ( A ) ∣ |1-R_m(A)-1/2|=|1/2-R_m(A)| ∣1 − R m ( A ) − 1/2∣ = ∣1/2 − R m ( A ) ∣ by ⟨2⟩2 and ⟨2⟩3.
⟨1⟩4. Q.E.D.
Corollary 6.7 (The three regimes under the hypotheses).
(a) Assume L P R G s \mathrm{LPRG}_s LPRG s , with predicate P P P of arity k k k . Let A A A be a polynomial-time in-context learner for ( R L P , D k ) (\mathrm{RL}_P,D_k) ( RL P , D k ) and m ( N ) ≤ ⌈ N s ⌉ − 1 m(N)\le\lceil N^s\rceil-1 m ( N ) ≤ ⌈ N s ⌉ − 1 a context length computable in time polynomial in N N N . Then R m ( N ) ( A ) ≥ 1 / 6 R_{m(N)}(A)\ge1/6 R m ( N ) ( A ) ≥ 1/6 for all sufficiently large N N N . At m = ⌈ N s ⌉ − 1 m=\lceil N^s\rceil-1 m = ⌈ N s ⌉ − 1 the Bayes risk is at most N 1 − s N^{1-s} N 1 − s , and A l i n A_{\mathrm{lin}} A lin has risk at most ε \varepsilon ε from O ( N k log ( 1 / ε ) / ε ) O(N^k\log(1/\varepsilon)/\varepsilon) O ( N k log ( 1/ ε ) / ε ) examples.
(b) Assume L P R G α 0 l e n \mathrm{LPRG}^{\mathrm{len}}_{\alpha_0} LPRG α 0 len , with predicate P P P of arity k k k and constant α 0 \alpha_0 α 0 . Let α ≥ max { α 0 , 7 } \alpha\ge\max\{\alpha_0,7\} α ≥ max { α 0 , 7 } be a constant and m ( N ) = ⌈ α N ⌉ − 1 m(N)=\lceil\alpha N\rceil-1 m ( N ) = ⌈ α N ⌉ − 1 . Every in-context learner that runs in time 2 N / ( log N ) c − 1 2^{N}/(\log N)^{c-1} 2 N / ( log N ) c − 1 on contexts of length m ( N ) m(N) m ( N ) has R m ( N ) ( A ) ≥ 1 / 6 R_{m(N)}(A)\ge1/6 R m ( N ) ( A ) ≥ 1/6 for all sufficiently large N N N , while the Bayes predictor has risk at most 1 / α < 1 / 6 1/\alpha<1/6 1/ α < 1/6 and runs in time 2 O ( N log log N / log N ) 2^{O(N\log\log N/\sqrt{\log N})} 2 O ( N l o g l o g N / l o g N ) .
Proof of Corollary 6.7 . ⟨1⟩1. Part (a) holds.
⟨2⟩1. Let: A ′ ′ A'' A ′′ , on an input with ⌈ N s ⌉ \lceil N^s\rceil ⌈ N s ⌉ outputs, compute m ( N ) m(N) m ( N ) and run the algorithm A ′ A' A ′ of Theorem 6.6(c) on the first m ( N ) + 1 m(N)+1 m ( N ) + 1 outputs and their tuples. Then A ′ ′ A'' A ′′ is one algorithm, it runs in time polynomial in N N N , and its advantage against G P , ⌈ N s ⌉ G_{P,\lceil N^s\rceil} G P , ⌈ N s ⌉ is ∣ 1 / 2 − R m ( N ) ( A ) ∣ |1/2-R_{m(N)}(A)| ∣1/2 − R m ( N ) ( A ) ∣ .
Proof. A A A runs in time polynomial in its input, whose length is polynomial in N N N because m ( N ) ≤ N s m(N)\le N^s m ( N ) ≤ N s , and m ( N ) m(N) m ( N ) is computable in polynomial time. The first m ( N ) + 1 m(N)+1 m ( N ) + 1 outputs of G P , ⌈ N s ⌉ G_{P,\lceil N^s\rceil} G P , ⌈ N s ⌉ with their tuples are distributed as G P , m ( N ) + 1 G_{P,m(N)+1} G P , m ( N ) + 1 , and those of a uniform string are uniform, so the advantage is that of A ′ A' A ′ .
⟨2⟩2. R m ( N ) ( A ) ≥ 1 / 6 R_{m(N)}(A)\ge1/6 R m ( N ) ( A ) ≥ 1/6 for all sufficiently large N N N .
Proof. By LPRGs _s s the advantage of A ′ ′ A'' A ′′ is at most 1 / 3 1/3 1/3 for all large N N N , so ∣ 1 / 2 − R m ( N ) ( A ) ∣ ≤ 1 / 3 |1/2-R_{m(N)}(A)|\le1/3 ∣1/2 − R m ( N ) ( A ) ∣ ≤ 1/3 .
⟨2⟩3. Q.E.D.
Proof. At m = ⌈ N s ⌉ − 1 m=\lceil N^s\rceil-1 m = ⌈ N s ⌉ − 1 , Theorem 6.6(a) gives R m ∗ ≤ N / ⌈ N s ⌉ ≤ N 1 − s R_m^*\le N/\lceil N^s\rceil\le N^{1-s} R m ∗ ≤ N / ⌈ N s ⌉ ≤ N 1 − s , and Theorem 6.6(b) with δ = ε / 2 \delta=\varepsilon/2 δ = ε /2 and ε / 2 \varepsilon/2 ε /2 in place of ε \varepsilon ε gives the claim for A l i n A_{\mathrm{lin}} A lin .
⟨1⟩2. Part (b) holds.
Proof. Here m ( N ) + 1 = ⌈ α N ⌉ m(N)+1=\lceil\alpha N\rceil m ( N ) + 1 = ⌈ α N ⌉ is computable in polynomial time. The algorithm A ′ A' A ′ of Theorem 6.6(c) for A A A runs in time 2 N / ( log N ) c − 1 + c ∗ ⌈ α N ⌉ k log N ≤ 2 N / ( log N ) c 2^{N/(\log N)^{c-1}}+c_*\lceil\alpha N\rceil^k\log N\le2^{N/(\log N)^c} 2 N / ( l o g N ) c − 1 + c ∗ ⌈ α N ⌉ k log N ≤ 2 N / ( l o g N ) c for large N N N , so by LPRGc l e n ^{\mathrm{len}}_c c len with this α ≥ α 0 \alpha\ge\alpha_0 α ≥ α 0 its advantage ∣ 1 / 2 − R m ( N ) ( A ) ∣ |1/2-R_{m(N)}(A)| ∣1/2 − R m ( N ) ( A ) ∣ is at most 1 / 3 1/3 1/3 for all large N N N , and R m ( N ) ( A ) ≥ 1 / 6 R_{m(N)}(A)\ge1/6 R m ( N ) ( A ) ≥ 1/6 . The Bayes risk is at most N / ( m ( N ) + 1 ) = N / ⌈ α N ⌉ ≤ 1 / α ≤ 1 / 7 N/(m(N)+1)=N/\lceil\alpha N\rceil\le1/\alpha\le1/7 N / ( m ( N ) + 1 ) = N / ⌈ α N ⌉ ≤ 1/ α ≤ 1/7 , and the time of the Bayes predictor is that of Theorem 6.6(a) with m = O ( N ) m=O(N) m = O ( N ) .
⟨1⟩3. Q.E.D.
Corollary 7.1 (Chain-of-thought lengths). Let ( M N ) (M_N) ( M N ) be a uniform family of sequence models with p ( N ) ≤ N O ( 1 ) p(N)\le N^{O(1)} p ( N ) ≤ N O ( 1 ) parameters, as above.
(a) Assume Hypothesis 2.14, and let γ \gamma γ , K K K , c γ c_\gamma c γ be as in Theorem 4.4(a). If M N M_N M N outputs B ( S , x ) \mathrm{B}(S,x) B ( S , x ) for every consistent context of at most N c γ N^{c_\gamma} N c γ examples of B P ⌈ K log N ⌉ \mathrm{BP}_{\lceil K\log N\rceil} BP ⌈ K l o g N ⌉ in dimension N N N and every query, then L ( N ) > 2 ( 1 − γ ) N / ( c M + 1 ) − N O ( 1 ) L(N)>2^{(1-\gamma)N/(c_M+1)}-N^{O(1)} L ( N ) > 2 ( 1 − γ ) N / ( c M + 1 ) − N O ( 1 ) for infinitely many N N N . So L ( N ) = 2 Ω ( N ) L(N)=2^{\Omega(N)} L ( N ) = 2 Ω ( N ) for infinitely many N N N .
(b) Assume ETHC l e n ^{\mathrm{len}}_C C len and let θ > 0 \theta>0 θ > 0 . If M N M_N M N outputs B ( S , x ) \mathrm{B}(S,x) B ( S , x ) for every consistent context of at most 36 N 2 36N^2 36 N 2 examples of L D 3 \mathrm{LD}_3 LD 3 in dimension N N N and every query, then L ( N ) ≥ 2 N / ( log N ) c + 6 L(N)\ge2^{N/(\log N)^{c+6}} L ( N ) ≥ 2 N / ( l o g N ) c + 6 for infinitely many N N N .
(c) Assume LPRGs _s s with predicate P P P , and let m ( N ) ≤ ⌈ N s ⌉ − 1 m(N)\le\lceil N^s\rceil-1 m ( N ) ≤ ⌈ N s ⌉ − 1 be computable in time polynomial in N N N . If L ( N ) ≤ N O ( 1 ) L(N)\le N^{O(1)} L ( N ) ≤ N O ( 1 ) , then M M M has risk at least 1 / 6 1/6 1/6 on ( R L P , D k ) (\mathrm{RL}_P,D_k) ( RL P , D k ) at context length m ( N ) m(N) m ( N ) for all sufficiently large N N N .
(d) Assume LPRGc l e n ^{\mathrm{len}}_c c len with predicate P P P , and let α \alpha α and m ( N ) m(N) m ( N ) be as in Corollary 6.7 (b). If L ( N ) ≤ 2 N / ( ( c M + 2 ) ( log N ) c ) L(N)\le2^{N/((c_M+2)(\log N)^c)} L ( N ) ≤ 2 N / (( c M + 2 ) ( l o g N ) c ) for all sufficiently large N N N , then M M M has risk at least 1 / 6 1/6 1/6 on ( R L P , D k ) (\mathrm{RL}_P,D_k) ( RL P , D k ) at context length m ( N ) m(N) m ( N ) for all sufficiently large N N N .
Proof of Corollary 7.1. ⟨1⟩1. Let: S S S be the algorithm that, given an input of dimension N N N , computes the parameters of M N M_N M N and generates its chain of thought and answer. On a prompt of length ℓ \ell ℓ it runs in time at most N O ( 1 ) + ( p + ℓ + L ( N ) ) c M + 1 N^{O(1)}+(p+\ell+L(N))^{c_M+1} N O ( 1 ) + ( p + ℓ + L ( N ) ) c M + 1 , and on the inputs of each part ℓ ≤ N O ( 1 ) \ell\le N^{O(1)} ℓ ≤ N O ( 1 ) .
Proof: The family is uniform, each of the at most L ( N ) + 1 L(N)+1 L ( N ) + 1 generated tokens takes time at most ( p + ℓ + L ( N ) ) c M (p+\ell+L(N))^{c_M} ( p + ℓ + L ( N ) ) c M , and in every part the contexts have polynomially many examples: at most N c γ N^{c_\gamma} N c γ in (a), at most 36 N 2 36N^2 36 N 2 in (b), and m ( N ) ≤ N s m(N)\le N^s m ( N ) ≤ N s in (c) and (d).
⟨1⟩2. Part (a) holds.
Proof: Suppose that L ( N ) ≤ 2 ( 1 − γ ) N / ( c M + 1 ) − p ( N ) − ℓ max ( N ) L(N)\le2^{(1-\gamma)N/(c_M+1)}-p(N)-\ell_{\max}(N) L ( N ) ≤ 2 ( 1 − γ ) N / ( c M + 1 ) − p ( N ) − ℓ m a x ( N ) for all large N N N , where ℓ max ( N ) ≤ N O ( 1 ) \ell_{\max}(N)\le N^{O(1)} ℓ m a x ( N ) ≤ N O ( 1 ) is the largest prompt length. Then S S S computes B ( S , x ) \mathrm{B}(S,x) B ( S , x ) on all the contexts of Theorem 4.4(a) in time N O ( 1 ) + 2 ( 1 − γ ) N = O ( 2 ( 1 − γ ) N ) N^{O(1)} + 2^{(1-\gamma)N} = O(2^{(1-\gamma)N}) N O ( 1 ) + 2 ( 1 − γ ) N = O ( 2 ( 1 − γ ) N ) , which that theorem excludes.
⟨1⟩3. Part (b) holds.
Proof: Suppose that L ( N ) < 2 N / ( log N ) c + θ L(N) < 2^{N/(\log N)^{c+\theta}} L ( N ) < 2 N / ( l o g N ) c + θ for all large N N N . Then the time of S S S is at most N O ( 1 ) + ( N O ( 1 ) + 2 N / ( log N ) c + θ ) c M + 1 ≤ 2 ( c M + 2 ) N / ( log N ) c + θ ≤ 2 N / ( log N ) c + θ / 2 N^{O(1)} + (N^{O(1)} + 2^{N/(\log N)^{c+\theta}})^{c_M+1} \leq2^{(c_M+2)N/(\log N)^{c+\theta}} \leq2^{N/(\log N)^{c+\theta/2}} N O ( 1 ) + ( N O ( 1 ) + 2 N / ( l o g N ) c + θ ) c M + 1 ≤ 2 ( c M + 2 ) N / ( l o g N ) c + θ ≤ 2 N / ( l o g N ) c + θ /2 for large N N N , which Theorem 4.4(b) with θ / 2 \theta/2 θ /2 in place of θ \theta θ excludes.
⟨1⟩4. Part (c) holds.
Proof: With L ( N ) ≤ N O ( 1 ) L(N) \leq N^{O(1)} L ( N ) ≤ N O ( 1 ) , S S S is a polynomial-time in-context learner; apply Corollary 6.7 (a).
⟨1⟩5. Q.E.D.
Proof: For part (d), if L ( N ) ≤ 2 N / ( ( c M + 2 ) ( log N ) c ) L(N) \leq2^{N/((c_M+2)(\log N)^c)} L ( N ) ≤ 2 N / (( c M + 2 ) ( l o g N ) c ) for all large N N N , the time of S S S on contexts of length m ( N ) = O ( N ) m(N) = O(N) m ( N ) = O ( N ) is at most N O ( 1 ) + ( N O ( 1 ) + 2 N / ( ( c M + 2 ) ( log N ) c ) ) c M + 1 N^{O(1)} + (N^{O(1)} + 2^{N/((c_M+2)(\log N)^c)})^{c_M+1} N O ( 1 ) + ( N O ( 1 ) + 2 N / (( c M + 2 ) ( l o g N ) c ) ) c M + 1 , which is at most 2 N / ( log N ) c − 1 2^{N/(\log N)^{c-1}} 2 N / ( l o g N ) c − 1 for large N N N . Apply Corollary 6.7 (b).