Yao's Principle for Online Lower Bounds
Upper bounds for randomized algorithms are proved by analysing one algorithm. Lower bounds are harder: they must hold for every randomized algorithm, that is, for every probability distribution over deterministic algorithms, an infinite family with no structure to grab. Yao's principle (Yao, 1977) turns the problem around. Instead of fighting every randomized algorithm, pick one probability distribution over inputs and show that every deterministic algorithm does badly on average. Deterministic algorithms against a fixed input distribution are much easier to analyse, and the principle says the result transfers.
The game behind it
Take a finite online problem: finitely many deterministic algorithms (for example, all strategies on sequences of a fixed length) and finitely many request sequences . Define the payoff matrix
A randomized algorithm is a probability vector over the rows; an oblivious adversary choosing a sequence at random is a probability vector over the columns. Von Neumann's minimax theorem for finite zero-sum games says
The left side is the best expected ratio a randomized algorithm can guarantee against an oblivious adversary. The right side is the best an input distribution can force on deterministic algorithms. So any distribution gives a lower bound, , on the randomized ratio, and the best distribution gives exactly the right value.
Yao's principle (online form). Let be a probability distribution over request sequences such that for every deterministic online algorithm
Then no randomized online algorithm is better than -competitive in the strict sense against an oblivious adversary. If there are such distributions with arbitrarily large, the same holds for the non-strict ratio.
Proof
A randomized algorithm is a distribution over deterministic algorithms . Average the hypothesis over and swap the two expectations (both are over independent choices):
If were -competitive, for every ; averaging over gives . With this forces . If can be made arbitrarily large, dividing by it shows , so for every fixed .
Note the form: the hypothesis compares ratios of expectations, , not expectations of ratios. Both forms are valid lower-bound tools (the matrix form above uses expected ratios), but they must not be mixed: showing for a distribution where varies does not prove the online form's hypothesis.
The minimax theorem at work: ski rental with
Ski rental with buying price is a finite game if seasons are cut at days. Rows are the buying days (day 13 means "never within the horizon"), columns the season lengths. The program solves both sides of the minimax equation as linear programs: the algorithm's side (choose to minimize the worst column) and the adversary's side (choose to maximize the best row). They agree, and the value equals the formula from Randomized Ski Rental.
import numpy as np
from scipy.optimize import linprog
B, horizon = 4, 12
days = range(1, horizon + 1)
def cost(j, D): # buy on the morning of day j if the season is still on
return D if D < j else (j - 1) + B
M = np.array([[cost(j, D) / min(D, B) for D in days] for j in range(1, horizon + 2)])
m, n = M.shape
# algorithm: minimize v subject to sum_i p_i M[i, j] <= v for every column j
res_p = linprog(np.r_[np.zeros(m), 1], A_ub=np.c_[M.T, -np.ones(n)], b_ub=np.zeros(n),
A_eq=[np.r_[np.ones(m), 0]], b_eq=[1], bounds=[(0, None)] * m + [(None, None)],
method="highs")
# adversary: maximize w subject to sum_j q_j M[i, j] >= w for every row i
res_q = linprog(np.r_[np.zeros(n), -1], A_ub=np.c_[-M, np.ones(m)], b_ub=np.zeros(m),
A_eq=[np.r_[np.ones(n), 0]], b_eq=[1], bounds=[(0, None)] * n + [(None, None)],
method="highs")
p = res_p.x[:m]
print(f"algorithm's guarantee min_p max_D = {res_p.x[-1]:.4f}")
print(f"adversary's bound max_q min_j = {res_q.x[-1]:.4f}")
print(f"formula 1/(1 - (1 - 1/B)^B) = {1 / (1 - (1 - 1 / B) ** B):.4f}")
print("optimal Pr[buy on day j], j = 1..4:", " ".join(f"{x:.4f}" for x in p[:4]))algorithm's guarantee min_p max_D = 1.4629
adversary's bound max_q min_j = 1.4629
formula 1/(1 - (1 - 1/B)^B) = 1.4629
optimal Pr[buy on day j], j = 1..4: 0.1543 0.2057 0.2743 0.3657
The algorithm's optimal distribution puts all its weight on days 1 to 4, each day times as likely as the one before. An optimal adversary mixes short seasons () with long ones (; all long seasons look the same to strategies that buy by day , so the solver may pick any of them).
A first lower bound: paging with pages
Here is the distribution behind the lower bound of The Harmonic Lower Bound for Randomized Paging: requests uniformly at random from pages. Whatever a deterministic algorithm keeps in its slots, the next page is the missing one with probability , so every deterministic algorithm has the same expected cost, about over requests. OPT misses much less often: after a miss it evicts the page requested furthest in the future, and the next miss comes only after all other pages have been requested again, a coupon-collector wait of about requests.
import random
def opt_misses(reqs, k):
"""Belady with precomputed next-use times (linear time after the first pass)."""
nxt, last = [0] * len(reqs), {}
for t in range(len(reqs) - 1, -1, -1):
nxt[t] = last.get(reqs[t], len(reqs))
last[reqs[t]] = t
cache, misses = {}, 0 # page -> time of its next request
for t, p in enumerate(reqs):
if p not in cache:
misses += 1
if len(cache) == k:
del cache[max(cache, key=cache.get)]
cache[p] = nxt[t]
return misses
def fifo_misses(reqs, k):
cache, misses = [], 0
for p in reqs:
if p not in cache:
misses += 1
if len(cache) == k:
cache.pop(0)
cache.append(p)
return misses
rng = random.Random(5)
n = 60000
print(" k E[ALG]/n 1/(k+1) E[OPT]/n ratio H_k")
for k in [2, 4, 8]:
reqs = [rng.randrange(k + 1) for _ in range(n)]
alg, opt = fifo_misses(reqs, k), opt_misses(reqs, k)
H = sum(1 / i for i in range(1, k + 1))
print(f"{k:2} {alg / n:8.4f} {1 / (k + 1):7.4f} {opt / n:8.4f} {alg / opt:5.3f} {H:.3f}") k E[ALG]/n 1/(k+1) E[OPT]/n ratio H_k
2 0.3366 0.3333 0.2241 1.502 1.500
4 0.2006 0.2000 0.0966 2.077 2.083
8 0.1100 0.1111 0.0407 2.702 2.718
FIFO stands in for every deterministic algorithm; any other would show the same miss rate up to noise. The measured ratio matches , so by Yao's principle no randomized paging algorithm beats against an oblivious adversary. The careful version of this argument, with the renewal process behind OPT's misses, is in the lesson on the randomized lower bound.
How to use the principle
- Choose the distribution to make every deterministic algorithm equal. If all deterministic algorithms have the same expected cost, there is nothing left to analyse (paging above). In general, equalizing the best responses is exactly what the optimal in the minimax theorem does.
- Compute or bound separately. OPT sees the sampled sequence, so this is an offline question.
- Make the expected optimum grow if you want a non-strict bound: use longer and longer sequences.
Yao's principle gives lower bounds only against oblivious adversaries, which is the right target: against adaptive adversaries, randomized lower bounds follow from deterministic ones (Oblivious and Adaptive Adversaries).
Test yourself
Yao's principle reduces a lower bound for randomized online algorithms to what?
- An upper bound for one deterministic algorithm
- A lower bound on the expected cost of every deterministic algorithm on one input distribution
- A bound on the running time
- An adaptive adversary argument
Every deterministic algorithm has on a distribution with . What does Yao's principle give?
- No randomized algorithm is better than 2-competitive in the strict sense
- No randomized algorithm is better than 2-competitive in the non-strict sense
- Every randomized algorithm is 2-competitive
- Nothing, the expected optimum is too small
Why is the uniform distribution over pages convenient for a paging lower bound?
- OPT has no misses on it
- Every deterministic algorithm misses with probability exactly per request once its cache is full
- LRU becomes optimal
- It forces the adversary to be adaptive