Algorithm Search⌘K

Algorithmintro

Iterated elimination of dominated strategies

Also called iterated dominance, IESDS.

Repeatedly removes strictly dominated actions from a finite game until none remains. Every Nash equilibrium survives, and the result does not depend on the order.

Time
O(k^2 t) worst
Space
O(k) extra
Where
k = the total number of pure strategies of all players; t = the number of pure profiles (the size of one payoff table)
Properties
comparison baseddeterministiciterative
Origin
Hervé Moulin, 1979

Iterated elimination of dominated strategies is the procedure that removes, one at a time, a strategy of some player that another strategy beats against every remaining choice of the others, and repeats until no such strategy is left. It works on a finite normal-form game. With strict dominance it never removes a strategy that a Nash equilibrium uses, and the set that survives does not depend on the order of removal. With weak dominance, the topic of the variant section, both properties fail. A dominant strategy is the special case in which one strategy beats all the others in one step.

In plain words

Some choices are bad whatever the others do: another choice of the same player is better in every case. A sensible player never makes such a choice, so we can cross it out. Once it is gone, the other players know it is gone, and some of their own choices may now be bad in every remaining case, so we cross those out too. We repeat until nothing more can be crossed out. Sometimes one choice per player is left, and the game is solved. Often more is left, and the method only makes the game smaller. The method must compare against mixtures of choices too, not only single choices. It is safe when "better" means strictly better in every case. When "better" only means never worse, the order of crossing out changes the result.

The problem

The input is a finite game with players N={1,…,n}N = \{1, \ldots, n\}, finite sets SiS_i of pure strategies and utilities ui:S→Qu_i : S \to \mathbb{Q} on S=S1×⋯×SnS = S_1 \times \cdots \times S_n, which each player maximizes. For sets Ai⊆SiA_i \subseteq S_i, write A−iA_{-i} for the product of the AjA_j with j≠ij \neq i. A strategy a∈Aia \in A_i is strictly dominated relative to AA if some mixed strategy σi\sigma_i on AiA_i has

∑b∈Aiσi(b) ui(b,t)>ui(a,t)for every t∈A−i.\sum_{b \in A_i} \sigma_i(b)\, u_i(b, t) > u_i(a, t) \quad \text{for every } t \in A_{-i}.

If σi\sigma_i can be taken pure, aa is strictly dominated by a pure strategy. The output is a product A=A1×⋯×AnA = A_1 \times \cdots \times A_n of nonempty sets, reached from SS by removing dominated strategies one at a time, such that no strategy in AA is strictly dominated relative to AA. The game is dominance solvable if each AiA_i has one element.

The algorithm

  1. IESDS(G, DOMINATED)
  2. 1A_i ← S_i for every player i
  3. 2repeat
  4. 3for each player i and each a in A_i, in a fixed order:
  5. 4if DOMINATED(G, A, i, a) returns a witness w:
  6. 5A_i ← A_i minus {a}
  7. 6append (i, a, w) to the log and go back to L2
  8. 7until no call of line L4 returns a witness; return A and the log

The test DOMINATED decides one of three relations:

  • Strict, by a pure strategy. Look for b∈Aib \in A_i with ui(b,t)>ui(a,t)u_i(b, t) > u_i(a, t) for every t∈A−it \in A_{-i}. This is a direct comparison of two rows of the payoff table of player ii.
  • Strict, by a mixed strategy. Solve one linear program: maximize zz subject to ∑b≠axb (ui(b,t)−ui(a,t))≥z\sum_{b \neq a} x_b\,(u_i(b, t) - u_i(a, t)) \ge z for every t∈A−it \in A_{-i}, x≥0x \ge 0 and ∑bxb=1\sum_b x_b = 1. The strategy aa is dominated exactly when the optimum z∗z^* is positive, and then xx is the witness. The program is the linear program of a zero-sum game, so LP duality gives a certificate in the other case: a probability distribution qq on A−iA_{-i} against which aa is a best response.
  • Weak, by a pure strategy. Look for bb with ui(b,t)≥ui(a,t)u_i(b, t) \ge u_i(a, t) for every t∈A−it \in A_{-i} and >> for at least one tt. This is the variant whose result depends on the order.

Line L6 restarts the scan after each removal. That keeps the loop simple to analyze. An implementation may also continue the scan, since by the order independence below the result is the same for both strict tests.

Example

Take the bimatrix game below, rows T, M, B for player 1 and columns L, C, R for player 2, row payoff first.

L C R
T 4, 3 5, 1 6, 2
M 2, 1 8, 4 3, 6
B 3, 0 9, 6 2, 8

With the pure test and the order "player 1 first, strategies in order", the run is:

step rows left columns left removed witness why
1 T, M, B L, C, R column C R column payoffs 2, 6, 8 beat 1, 4, 6
2 T, M, B L, R row M T against L and R, T gets 4, 6 and M gets 2, 3
3 T, B L, R row B T T gets 4, 6 and B gets 3, 2
4 T L, R column R L against T, L gives 3 and R gives 2
5 T L none

The game is dominance solvable, and (T, L) with payoffs (4, 3) is its only Nash equilibrium, pure or mixed. In the first step no row is dominated: M is the best row against C, and T is the best row against L and R. Only after C is gone do rows M and B become dominated.

Mixed dominance. In the game with rows T, M, B and columns L, R where the row payoffs are T = (3, 0), M = (0, 3) and B = (1, 1), no pure strategy dominates B: T loses to B against R, and M loses to B against L. The mix 12T+12M\frac12 T + \frac12 M gets 3/23/2 against each column, which beats 1, so B is strictly dominated by a mixed strategy. The pure test stops at once and keeps all three rows; the mixed test removes B.

Order matters for weak dominance. Take rows T, M, B and columns L, R with payoffs (1, 1), (0, 0) in row T, (1, 1), (2, 1) in row M and (0, 0), (2, 1) in row B. M weakly dominates both T and B. If T goes first, R weakly dominates L, and the result is rows M and B against R, with payoffs (2, 1). If B goes first, L weakly dominates R, and the result is rows T and M against L, with payoffs (1, 1). If T and then B go, the result is row M against both columns. Three orders give three different games.

Correctness

The file proofs/correctness.md proves four claims for both strict tests. The loop stops after at most ∑i∣Si∣−n\sum_i |S_i| - n removals, because each pass through line L5 removes one strategy and no set becomes empty: a strategy that is alone in AiA_i cannot be dominated. When it stops, no remaining strategy is dominated relative to AA, by the exit condition of line L7. No removed strategy is played with positive probability in any Nash equilibrium, because a dominated strategy is never a best response to a profile of the others that lives in A−iA_{-i}, and a mixed strategy is a best response only if its support is inside the set of pure best responses BRi(σ−i)BR_i(\sigma_{-i}). Finally, the result is the same for every order of removal, and every Nash equilibrium of the game restricted to AA is a Nash equilibrium of the full game. Together these say that the procedure loses no equilibrium and adds none.

Proof: Iterated strict dominance stops, keeps every Nash equilibrium, adds none, and does not depend on the orderfull

Let GG be a finite game with players 1,…,n1, \ldots, n, pure strategy sets SiS_i and utilities uiu_i, which the players maximize. For a product Y=Y1×⋯×YnY = Y_1 \times \cdots \times Y_n of subsets Yi⊆SiY_i \subseteq S_i, a strategy a∈Yia \in Y_i is strictly dominated relative to YY if some mixed strategy τ\tau on YiY_i has ui(τ,t)>ui(a,t)u_i(\tau, t) > u_i(a, t) for every t∈Y−it \in Y_{-i}, where ui(τ,t)=∑bτ(b) ui(b,t)u_i(\tau, t) = \sum_b \tau(b)\, u_i(b, t). The pure test of line L4 is the case where τ\tau puts weight 1 on one strategy. Every claim below holds for both tests; where the two proofs differ, both are given.

A removed strategy has a dominator that puts no weight on it. If τ\tau dominates aa and τ(a)=p>0\tau(a) = p > 0, then p<1p < 1, since τ=a\tau = a would give ui(a,t)>ui(a,t)u_i(a, t) > u_i(a, t). Let ρ=(τ−p a)/(1−p)\rho = (\tau - p\,a)/(1 - p), a mixed strategy on YiY_i minus {a}\{a\}. For every t∈Y−it \in Y_{-i}, p ui(a,t)+(1−p) ui(ρ,t)=ui(τ,t)>ui(a,t)p\,u_i(a, t) + (1 - p)\,u_i(\rho, t) = u_i(\tau, t) > u_i(a, t), so ui(ρ,t)>ui(a,t)u_i(\rho, t) > u_i(a, t). So from now on each dominator of aa puts weight 0 on aa; the code builds its witness this way.

Termination and the exit condition

Let Φ=∑i∣Ai∣\Phi = \sum_i |A_i|. Line L1 sets Φ=∑i∣Si∣\Phi = \sum_i |S_i|. Each pass through line L5 lowers Φ\Phi by exactly 1. A strategy aa that is alone in AiA_i is never dominated, because its only possible dominator is aa itself, which was excluded above. So every AiA_i stays nonempty, Φ≥n\Phi \ge n at all times, and line L5 runs at most ∑i∣Si∣−n\sum_i |S_i| - n times. Between two passes through line L5, the scan of line L3 makes at most ∑i∣Ai∣\sum_i |A_i| calls. So the procedure stops. It stops only at line L7, after a full scan in which no call of line L4 returned a witness, so no strategy of the result AA is strictly dominated relative to AA.

No removed strategy is used by a Nash equilibrium

Let σ∗\sigma^* be a mixed Nash equilibrium of GG. We show by induction on the number of removals that the support of every σj∗\sigma^*_j stays inside AjA_j. At line L1, Aj=SjA_j = S_j. Suppose the claim holds before line L5 removes aa from AiA_i, with dominator τ\tau relative to AA. By the induction hypothesis, σ−i∗\sigma^*_{-i} puts all its weight on profiles t∈A−it \in A_{-i}, and so

ui(τ,σ−i∗)=∑t∈A−iσ−i∗(t) ui(τ,t)>∑t∈A−iσ−i∗(t) ui(a,t)=ui(a,σ−i∗),u_i(\tau, \sigma^*_{-i}) = \sum_{t \in A_{-i}} \sigma^*_{-i}(t)\, u_i(\tau, t) > \sum_{t \in A_{-i}} \sigma^*_{-i}(t)\, u_i(a, t) = u_i(a, \sigma^*_{-i}),

where the inequality is strict because the weights σ−i∗(t)\sigma^*_{-i}(t) are nonnegative and sum to 1, and each term on the left is larger. Since ui(τ,σ−i∗)u_i(\tau, \sigma^*_{-i}) is an average of the values ui(b,σ−i∗)u_i(b, \sigma^*_{-i}) with b∈Aib \in A_i, some pure bb has ui(b,σ−i∗)>ui(a,σ−i∗)u_i(b, \sigma^*_{-i}) > u_i(a, \sigma^*_{-i}). So aa is not a pure best response to σ−i∗\sigma^*_{-i}. In an equilibrium every strategy in the support of σi∗\sigma^*_i is a pure best response to σ−i∗\sigma^*_{-i} (if a strategy aa with σi∗(a)>0\sigma^*_i(a) > 0 were not, moving its weight to a best response would raise uiu_i). So σi∗(a)=0\sigma^*_i(a) = 0, and the claim holds after the removal.

A lemma: pushing a dominator into the surviving sets

Fix one run of the procedure. Number its removals 1,2,…,r1, 2, \ldots, r in order, and let AA be its result. For a removed strategy bb of player ii, let time(b)\mathrm{time}(b) be its number, and let τb\tau_b be its witness; τb\tau_b is a mixed strategy on the set ZiZ_i alive at that time, with weight 0 on bb, and it dominates bb relative to Z⊇AZ \supseteq A.

Lemma. Let X⊆A−iX \subseteq A_{-i} be a set of profiles of the others, and let σ\sigma be a mixed strategy of player ii on SiS_i. Then there is a mixed strategy σ′\sigma' on AiA_i with ui(σ′,t)≥ui(σ,t)u_i(\sigma', t) \ge u_i(\sigma, t) for every t∈Xt \in X, and with strict inequality for every t∈Xt \in X if σ\sigma puts positive weight outside AiA_i.

Proof. If the support of σ\sigma is inside AiA_i, take σ′=σ\sigma' = \sigma. Otherwise let bb be the strategy outside AiA_i in the support of σ\sigma with the smallest time(b)\mathrm{time}(b), and let σ^=σ−σ(b) b+σ(b) τb\hat\sigma = \sigma - \sigma(b)\, b + \sigma(b)\, \tau_b. This is a mixed strategy. For each t∈Xt \in X, t∈A−i⊆Z−it \in A_{-i} \subseteq Z_{-i}, so ui(τb,t)>ui(b,t)u_i(\tau_b, t) > u_i(b, t) and ui(σ^,t)=ui(σ,t)+σ(b) (ui(τb,t)−ui(b,t))>ui(σ,t)u_i(\hat\sigma, t) = u_i(\sigma, t) + \sigma(b)\,(u_i(\tau_b, t) - u_i(b, t)) > u_i(\sigma, t). The support of τb\tau_b is inside ZiZ_i, the set alive at time time(b)\mathrm{time}(b), and does not contain bb. So every strategy outside AiA_i in the support of σ^\hat\sigma was removed strictly after bb: those from τb\tau_b because they were still alive when bb was removed, and the others from σ\sigma by the choice of bb. The smallest removal time outside AiA_i in the support therefore grows by at least 1 at each step, and it is at most rr, so after at most rr steps the support is inside AiA_i. Each step raised the payoff strictly against every t∈Xt \in X, which gives the lemma. For the pure test, each τb\tau_b is pure, σ\sigma stays pure at every step, and σ′\sigma' is pure. □\square

Every equilibrium of the reduced game is an equilibrium of G

Let σ\sigma be a mixed Nash equilibrium of the game restricted to AA, so each σj\sigma_j lives on AjA_j and no deviation inside AiA_i gains. Suppose some b∈Sib \in S_i minus AiA_i had ui(b,σ−i)>ui(σ)u_i(b, \sigma_{-i}) > u_i(\sigma). Apply the lemma to the pure strategy bb with X=A−iX = A_{-i}: it gives σ′\sigma' on AiA_i with ui(σ′,t)>ui(b,t)u_i(\sigma', t) > u_i(b, t) for every t∈A−it \in A_{-i}, so ui(σ′,σ−i)>ui(b,σ−i)>ui(σ)u_i(\sigma', \sigma_{-i}) > u_i(b, \sigma_{-i}) > u_i(\sigma). That is a gain inside AiA_i, which contradicts the choice of σ\sigma. So no pure deviation of GG gains, and σ\sigma is a Nash equilibrium of GG.

Together with the previous section: the Nash equilibria of GG are exactly the Nash equilibria of the game restricted to AA.

The result does not depend on the order

Take two runs, with results AA and BB. Let the second run remove c1,c2,…c_1, c_2, \ldots in this order, where cjc_j belongs to player iji_j and is strictly dominated relative to the set YjY^j alive before its removal. We show by induction on jj that no cjc_j lies in AA.

Suppose c1,…,cj−1c_1, \ldots, c_{j-1} are not in AA. Then A⊆YjA \subseteq Y^j, since YjY^j is SS minus these strategies. Suppose c=cjc = c_j were in AiA_i, with i=iji = i_j. Its dominator σ\sigma in the second run satisfies ui(σ,t)>ui(c,t)u_i(\sigma, t) > u_i(c, t) for every t∈Y−ijt \in Y^j_{-i}, and so for every t∈A−it \in A_{-i}. The lemma for the first run with X=A−iX = A_{-i} gives σ′\sigma' on AiA_i with ui(σ′,t)≥ui(σ,t)>ui(c,t)u_i(\sigma', t) \ge u_i(\sigma, t) > u_i(c, t) for every t∈A−it \in A_{-i}. Then cc is strictly dominated relative to AA (by a pure strategy for the pure test, by the last sentence of the lemma), which contradicts the exit condition of the first run. So cj∉Ac_j \notin A.

Hence every strategy that the second run removes is outside AA, which means A⊆BA \subseteq B. Swapping the two runs gives B⊆AB \subseteq A. So A=BA = B. ■\blacksquare

Weak dominance

For weak dominance by a pure strategy, termination and the exit condition hold with the same proof. The section on equilibria of GG fails: in the first order of the example of the page, the equilibrium (T, L) is removed. The section on the reduced game still holds with weak inequalities: the lemma, with ≥\ge in place of >>, gives ui(σ′,σ−i)≥ui(b,σ−i)>ui(σ)u_i(\sigma', \sigma_{-i}) \ge u_i(b, \sigma_{-i}) > u_i(\sigma) for a gaining bb, the same contradiction. So every equilibrium of the reduced game is an equilibrium of GG, and since the reduced game is finite, Nash's theorem gives it an equilibrium: at least one equilibrium of GG survives every order. The order section fails, because the step "ui(σ′,t)≥ui(σ,t)≥ui(c,t)u_i(\sigma', t) \ge u_i(\sigma, t) \ge u_i(c, t) with one strict" does not transfer from Y−ijY^j_{-i} to the smaller set A−iA_{-i}: the profile with the strict inequality may be gone.

Complexity

Let k=∑i∣Si∣k = \sum_i |S_i| and let t=∣S∣t = |S| be the number of pure profiles, so the input holds ntn t numbers. For the pure test, one call for the pair (a,b)(a, b) of player ii compares ∣A−i∣≤t/∣Si∣|A_{-i}| \le t / |S_i| pairs of payoffs. One full scan of line L3 tries at most ∣Si∣2|S_i|^2 pairs for player ii, which costs at most ∣Si∣⋅t|S_i| \cdot t comparisons, and k tk\,t in total. There are at most k−n+1k - n + 1 scans, so the time is O(k2t)O(k^2 t) comparisons in the worst case, in the word-RAM model with payoffs of bounded size. For a bimatrix game with mm rows and nn columns this is O((m+n)2mn)O((m + n)^2 m n). The extra space is O(k)O(k) for the sets AiA_i and the log.

The mixed test solves one LP with ∣Ai∣|A_i| variables and ∣A−i∣|A_{-i}| constraints per call, so the whole procedure runs in time polynomial in the input size and its bit length LL with any polynomial LP method, such as the ellipsoid method or an interior point method (Conitzer and Sandholm 2005). The simplex method is fast in practice but exponential in the worst case. The reference code solves the small LP by trying every vertex, which is exponential and meant only for the games of its tests.

Properties

  • Equilibria survive. Every mixed Nash equilibrium of GG has its support inside the result, and every equilibrium of the reduced game is an equilibrium of GG. So a dominance solvable game has exactly one Nash equilibrium, and it is pure.
  • Order independence. For strict dominance, by pure or by mixed strategies, every order of removal gives the same AA (Conitzer and Sandholm 2005; Osborne and Rubinstein, Section 4.2).
  • Mixed is stronger than pure. The mixed test removes every strategy that the pure test removes, and sometimes more, as in the example. The result of the mixed test is always contained in the result of the pure test.
  • Rationalizability. With two players, the strategies that survive mixed strict dominance are exactly the rationalizable ones of Bernheim and Pearce (1984). With three or more players this holds when beliefs about the others may be correlated; the LP certificate qq above is such a correlated belief.
  • Common knowledge. Each round of removal uses one more level of "each player knows that the others are rational". The game is solved only if rationality is common knowledge up to the number of rounds.

Variants and improvements

  • Weak dominance. Remove weakly dominated strategies. The result depends on the order, as the example shows, and it can remove Nash equilibria: in the first order of the example, the pure equilibrium (T, L) is lost. Every equilibrium of the reduced game is still an equilibrium of GG, so at least one equilibrium always survives. Conitzer and Sandholm (2005) proved that deciding if some order of weak removals eliminates a given strategy is NP-complete, and so is deciding if some order leaves one profile, both with and without mixed dominators. Gilboa, Kalai and Zemel (1993) had proved a version of these results for dominance by pure strategies.
  • Simultaneous removal. Remove in each round all strategies that are weakly dominated relative to the current sets. This fixes one order, so the result is unique, and it is a common way to state weak iterated dominance.
  • Dominance in succinct games. In Bayesian games and other games given succinctly, iterated dominance by pure strategies can need exponentially many rounds (Conitzer and Sandholm 2005).
  • Extensive games. Backward induction in a finite game of perfect information removes, at each node, the moves that are worse for the mover; it is related to iterated weak dominance in the normal form, and it gives a subgame perfect equilibrium.

When to use it

Run strict elimination first on any game you want to solve. It is exact, it never loses an equilibrium, and it can shrink the game a lot before an expensive method such as support enumeration or the Lemke-Howson algorithm. Use the pure test when speed matters and the mixed test when you have an LP solver, since it removes more. Use weak dominance only with a stated order, and only when you accept that some equilibria may be lost.

Pitfalls

  • Testing only pure dominators. A strategy that no pure strategy dominates can still be dominated by a mix, as B in the example. A program that tests only pure strategies is correct but removes less; say which test it uses.
  • Weak for strict. Writing ≥\ge in place of >> in the pure test turns the procedure into weak elimination, which depends on the order and can lose equilibria.
  • Dominance relative to the full game. After a removal, the test must use the current sets A−iA_{-i} of the other players. A strategy that is not dominated against all of S−iS_{-i} can become dominated against A−iA_{-i}, as rows M and B in the example.
  • Floating point. The test >> compares exact payoffs. With floats, two equal sums can compare unequal, and a strategy can be removed by a tie. Keep payoffs rational, as the code does with Fraction.
  • Reading survival as play. The surviving set is what rationality alone allows. A game where nothing is dominated, such as matching pennies, is not solved by the method at all.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

agtgame.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Shared helper of the algorithmic game theory pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Finite games in normal form, with exact payoffs and exact equilibrium checks.

A game is a pair (sizes, pay). sizes is a tuple (k_1, ..., k_n) of the numbers of pure
strategies of the n players; the pure strategies of player i are 0, ..., k_i - 1. pay is a
dict that maps each profile, a tuple s = (s_1, ..., s_n), to a tuple of n Fraction
utilities, which each player maximizes. A cost game passes the utilities u = -c.

A mixed profile sigma is a list of n lists; sigma[i][a] is the probability, a Fraction,
that player i plays a. A distribution on profiles (for correlated and coarse correlated
equilibria) is a dict from profiles to Fraction; missing profiles have probability 0.

All checks are exact: there is no tolerance anywhere. There is no LP and no equilibrium
algorithm in this module.
"""

from fractions import Fraction
from itertools import product


def profiles(sizes):
    """Return the list of all pure profiles, in lexicographic order."""
    return list(product(*(range(k) for k in sizes)))


def from_bimatrix(A, B):
    """Return the game of the bimatrix (A, B): the row player gets A[r][c], the column player B[r][c]."""
    m, n = len(A), len(A[0])
    if len(B) != m or any(len(row) != n for row in A) or any(len(row) != n for row in B):
        raise ValueError("A and B must be m by n matrices of the same shape")
    pay = {(r, c): (Fraction(A[r][c]), Fraction(B[r][c])) for r in range(m) for c in range(n)}
    return (m, n), pay


def random_game(rng, sizes, lo, hi):
    """Return a game with integer utilities drawn uniformly from lo to hi (inclusive), as Fraction."""
    sizes = tuple(sizes)
    pay = {s: tuple(Fraction(rng.randint(lo, hi)) for _ in sizes) for s in profiles(sizes)}
    return sizes, pay


def _replace(s, i, a):
    return s[:i] + (a,) + s[i + 1:]


def _weight(sigma, s, skip=None):
    w = Fraction(1)
    for k, a in enumerate(s):
        if k != skip:
            w *= sigma[k][a]
            if w == 0:
                return w
    return w


def expected_utility(game, i, sigma):
    """Return u_i(sigma), the expected utility of player i when the players draw independently."""
    sizes, pay = game
    return sum((_weight(sigma, s) * pay[s][i] for s in profiles(sizes)), Fraction(0))


def deviation_payoffs(game, i, sigma):
    """Return the list of u_i(a, sigma_-i) for every pure strategy a of player i."""
    sizes, pay = game
    out = [Fraction(0)] * sizes[i]
    for s in profiles(sizes):
        w = _weight(sigma, s, skip=i)
        if w:
            out[s[i]] += w * pay[s][i]
    return out


def pure_best_responses(game, i, sigma):
    """Return the sorted list of the pure strategies of player i that maximize u_i(a, sigma_-i)."""
    d = deviation_payoffs(game, i, sigma)
    best = max(d)
    return [a for a, v in enumerate(d) if v == best]


def max_gain(game, sigma):
    """Return the largest gain of any player from a pure deviation: max_i (max_a u_i(a, sigma_-i) - u_i(sigma)).

    The result is never negative, because u_i(sigma) is an average of the deviation payoffs.
    """
    sizes, _ = game
    gain = Fraction(0)
    for i in range(len(sizes)):
        d = deviation_payoffs(game, i, sigma)
        u = sum((p * v for p, v in zip(sigma[i], d)), Fraction(0))
        gain = max(gain, max(d) - u)
    return gain


def is_distribution(p):
    """Return True if p (a sequence, or a dict of probabilities) is nonnegative and sums to exactly 1."""
    vals = list(p.values()) if isinstance(p, dict) else list(p)
    return all(v >= 0 for v in vals) and sum(vals, Fraction(0)) == 1


def _is_mixed_profile(game, sigma):
    sizes, _ = game
    return len(sigma) == len(sizes) and all(
        len(sigma[i]) == k and is_distribution(sigma[i]) for i, k in enumerate(sizes))


def is_nash(game, sigma):
    """Return True if sigma is a mixed Nash equilibrium: no pure deviation gains for any player."""
    return _is_mixed_profile(game, sigma) and max_gain(game, sigma) == 0


def is_epsilon_nash(game, sigma, eps):
    """Return True if no player gains more than eps by a pure deviation (the additive form)."""
    return _is_mixed_profile(game, sigma) and max_gain(game, sigma) <= eps


def _check_dist(game, dist):
    sizes, _ = game
    allowed = set(profiles(sizes))
    return all(s in allowed for s in dist) and is_distribution(dist)


def is_correlated(game, dist):
    """Return True if dist is a correlated equilibrium.

    For every player i and every pair a, b of its pure strategies, the sum over the profiles s
    with s_i = a of dist(s) (u_i(s) - u_i(b, s_-i)) is at least 0.
    """
    sizes, pay = game
    if not _check_dist(game, dist):
        return False
    for i, k in enumerate(sizes):
        for a in range(k):
            rows = [(q, s) for s, q in dist.items() if s[i] == a and q]
            for b in range(k):
                if b != a and sum((q * (pay[s][i] - pay[_replace(s, i, b)][i]) for q, s in rows), Fraction(0)) < 0:
                    return False
    return True


def is_coarse_correlated(game, dist):
    """Return True if dist is a coarse correlated equilibrium.

    For every player i and every pure strategy b, E_{s ~ dist} u_i(s) >= E_{s ~ dist} u_i(b, s_-i).
    """
    sizes, pay = game
    if not _check_dist(game, dist):
        return False
    for i, k in enumerate(sizes):
        here = sum((q * pay[s][i] for s, q in dist.items()), Fraction(0))
        for b in range(k):
            if sum((q * pay[_replace(s, i, b)][i] for s, q in dist.items()), Fraction(0)) > here:
                return False
    return True


def pure_nash_brute(game):
    """Return the list of all pure Nash equilibria, found by checking every profile."""
    sizes, pay = game
    out = []
    for s in profiles(sizes):
        if all(pay[s][i] >= pay[_replace(s, i, b)][i] for i in range(len(sizes)) for b in range(sizes[i])):
            out.append(s)
    return out
iterated_elimination_of_dominated_strategies.py 158 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/iterated-elimination-of-dominated-strategies/. The authors are listed in prov/M509ET.jsonl.
"""Iterated elimination of dominated strategies in a finite normal-form game.

A game is the pair (sizes, pay) of the helper agtgame: pay maps each profile to a tuple of
Fraction utilities, which the players maximize. The surviving strategies are returned as a
list of sorted lists, one per player.

Three dominance tests are given:
- strict dominance by a pure strategy (a direct comparison),
- strict dominance by a mixed strategy (one small linear program, solved here exactly by
  checking every vertex, which is only meant for the small games of the tests),
- weak dominance by a pure strategy, whose iterated result depends on the order.
"""

from fractions import Fraction
from itertools import combinations, product


def _contexts(alive, i):
    """The profiles of the other players that are still alive, as tuples with a hole at i."""
    return list(product(*(alive[k] if k != i else [None] for k in range(len(alive)))))


def _put(t, i, a):
    return t[:i] + (a,) + t[i + 1:]


def dominated_by_pure(game, alive, i, a):
    """Return a strategy b in alive[i] with u_i(b, t) > u_i(a, t) for every alive t, or None."""
    _, pay = game
    ctx = _contexts(alive, i)
    for b in alive[i]:
        if b != a and all(pay[_put(t, i, b)][i] > pay[_put(t, i, a)][i] for t in ctx):
            return b
    return None


def weakly_dominated_by_pure(game, alive, i, a):
    """Return b in alive[i] with u_i(b, t) >= u_i(a, t) for every alive t and > for one, or None."""
    _, pay = game
    ctx = _contexts(alive, i)
    for b in alive[i]:
        if b == a:
            continue
        d = [pay[_put(t, i, b)][i] - pay[_put(t, i, a)][i] for t in ctx]
        if all(x >= 0 for x in d) and any(x > 0 for x in d):
            return b
    return None


def _solve(M, rhs):
    """Solve the square system M x = rhs exactly; return None if M is singular."""
    k = len(M)
    A = [list(row) + [r] for row, r in zip(M, rhs)]
    for col in range(k):
        piv = next((r for r in range(col, k) if A[r][col] != 0), None)
        if piv is None:
            return None
        A[col], A[piv] = A[piv], A[col]
        for r in range(k):
            if r != col and A[r][col] != 0:
                f = A[r][col] / A[col][col]
                A[r] = [x - f * y for x, y in zip(A[r], A[col])]
    return [A[r][k] / A[r][r] for r in range(k)]


def maximin(D):
    """Return (z, x) with x in the simplex over the rows of D maximizing z = min_c sum_r x_r D[r][c].

    This is the linear program max z subject to sum_r x_r D[r][c] >= z for every column c,
    x >= 0 and sum_r x_r = 1. Its optimum is at a vertex, where R of the C + R inequalities are
    tight (R rows, C columns). The function tries every choice of R tight inequalities, which
    is exponential and only meant for small matrices.
    """
    R, C = len(D), len(D[0])
    best = None
    # Unknowns: x_0, ..., x_{R-1}, z. Inequality j < C: sum_r x_r D[r][j] - z >= 0.
    # Inequality C + r: x_r >= 0. The equality sum_r x_r = 1 is always tight.
    rows = [[D[r][c] for r in range(R)] + [Fraction(-1)] for c in range(C)]
    rows += [[Fraction(int(r == q)) for q in range(R)] + [Fraction(0)] for r in range(R)]
    eq = [Fraction(1)] * R + [Fraction(0)]
    for tight in combinations(range(C + R), R):
        sol = _solve([rows[j] for j in tight] + [eq], [Fraction(0)] * R + [Fraction(1)])
        if sol is None:
            continue
        x, z = sol[:R], sol[R]
        if all(v >= 0 for v in x) and all(sum(x[r] * D[r][c] for r in range(R)) >= z for c in range(C)):
            if best is None or z > best[0]:
                best = (z, x)
    return best


def mixed_dominance(game, alive, i, a):
    """Decide if a is strictly dominated by a mixed strategy on the alive strategies.

    Returns ("dominated", sigma), where sigma is a dict from the other alive strategies of
    player i to probabilities with sum_b sigma_b u_i(b, t) > u_i(a, t) for every alive t, or
    ("best response", q), where q is a dict from alive contexts t to probabilities such that a
    is a best response of player i to the belief q (Pearce's lemma, by LP duality).
    """
    _, pay = game
    ctx = _contexts(alive, i)
    rivals = [b for b in alive[i] if b != a]
    if not rivals:
        return "best response", {ctx[0]: Fraction(1)}
    D = [[pay[_put(t, i, b)][i] - pay[_put(t, i, a)][i] for t in ctx] for b in rivals]
    z, x = maximin(D)
    if z > 0:
        return "dominated", {b: p for b, p in zip(rivals, x) if p}
    # The dual: a belief q over the contexts with sum_t q_t D[b][t] <= 0 for every rival b.
    w, q = maximin([[-D[b][t] for b in range(len(rivals))] for t in range(len(ctx))])
    assert -w == z, "the primal and dual values differ"
    return "best response", {t: p for t, p in zip(ctx, q) if p}


def dominated_by_mixed(game, alive, i, a):
    """Return a mixed strategy (a dict) that strictly dominates a, or None."""
    kind, cert = mixed_dominance(game, alive, i, a)
    return cert if kind == "dominated" else None


TESTS = {"pure": dominated_by_pure, "mixed": dominated_by_mixed, "weak": weakly_dominated_by_pure}


def iterated_elimination(game, rule="pure", pick=None):
    """Remove dominated strategies until none is left, and return (alive, log).

    rule is "pure" or "mixed" (strict dominance) or "weak" (weak dominance by a pure strategy).
    pick chooses which dominated strategy to remove when several are: it gets the list of
    (player, strategy) pairs and returns one of them. By default the first pair in the order
    of players and strategies is removed. log lists (player, strategy, witness) in the order of
    removal.
    """
    test = TESTS[rule]
    sizes, _ = game
    alive = [list(range(k)) for k in sizes]  # @line L1
    log = []
    while True:  # @line L2
        found = []
        for i in range(len(sizes)):  # @line L3
            for a in alive[i]:
                w = test(game, alive, i, a)  # @line L4
                if w is not None:
                    found.append((i, a, w))
                    if pick is None:
                        break
            if found and pick is None:
                break
        if not found:  # @line L7
            return alive, log
        if pick is None:
            i, a, w = found[0]
        else:
            i, a = pick([(i, a) for i, a, _ in found])
            w = next(x for j, b, x in found if (j, b) == (i, a))
        alive[i].remove(a)  # @line L5
        log.append((i, a, w))  # @line L6
test_iterated_elimination_of_dominated_strategies.py 270 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/iterated-elimination-of-dominated-strategies/. The authors are listed in prov/M509ET.jsonl.

import random
from fractions import Fraction as F

import agtgame
from agtgame import (deviation_payoffs, expected_utility, from_bimatrix, is_coarse_correlated,
                     is_correlated, is_distribution, is_epsilon_nash, is_nash, max_gain, profiles,
                     pure_best_responses, pure_nash_brute, random_game)
from iterated_elimination_of_dominated_strategies import (
    dominated_by_mixed, dominated_by_pure, iterated_elimination, maximin, mixed_dominance,
    weakly_dominated_by_pure)

H = F(1, 2)
T3 = F(1, 3)

PD = from_bimatrix([[3, 0], [5, 1]], [[3, 5], [0, 1]])  # 0 = cooperate, 1 = defect
PENNIES = from_bimatrix([[1, -1], [-1, 1]], [[-1, 1], [1, -1]])
RPS_A = [[0, -1, 1], [1, 0, -1], [-1, 1, 0]]
RPS = from_bimatrix(RPS_A, [[-x for x in row] for row in RPS_A])
BOS = from_bimatrix([[2, 0], [0, 1]], [[1, 0], [0, 2]])
# Chicken, strategy 0 = dare (D), 1 = chicken (C).
CHICKEN = from_bimatrix([[0, 7], [2, 6]], [[0, 2], [7, 6]])


# ---------------------------------------------------------------- the helper agtgame


def test_profiles_and_shapes():
    assert profiles((2, 3)) == [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)]
    assert len(profiles((2, 3, 4))) == 24
    sizes, pay = from_bimatrix([[1, 2, 3]], [[4, 5, 6]])
    assert sizes == (1, 3) and pay[(0, 2)] == (F(3), F(6))
    g1 = random_game(random.Random(7), (2, 2, 2), -3, 3)
    g2 = random_game(random.Random(7), (2, 2, 2), -3, 3)
    assert g1 == g2 and all(-3 <= v <= 3 and isinstance(v, F) for t in g1[1].values() for v in t)


def test_expected_utility_matches_brute_force():
    rng = random.Random(11)
    for _ in range(30):
        sizes = tuple(rng.randint(1, 3) for _ in range(rng.randint(2, 3)))
        game = random_game(rng, sizes, -5, 5)
        sigma = []
        for k in sizes:
            w = [rng.randint(0, 4) for _ in range(k)]
            if sum(w) == 0:
                w[0] = 1
            sigma.append([F(x, sum(w)) for x in w])
        for i in range(len(sizes)):
            brute = sum(F(1) * game[1][s][i] * _prod(sigma[k][s[k]] for k in range(len(s)))
                        for s in profiles(sizes))
            assert expected_utility(game, i, sigma) == brute
            d = deviation_payoffs(game, i, sigma)
            assert sum(p * v for p, v in zip(sigma[i], d)) == brute
            best = max(d)
            assert pure_best_responses(game, i, sigma) == [a for a in range(sizes[i]) if d[a] == best]
        assert max_gain(game, sigma) >= 0


def _prod(xs):
    out = F(1)
    for x in xs:
        out *= x
    return out


def test_check_values_of_nash():
    assert is_nash(PENNIES, [[H, H], [H, H]])
    assert not is_nash(PENNIES, [[F(1), F(0)], [H, H]])
    assert pure_nash_brute(PENNIES) == []
    assert is_nash(RPS, [[T3] * 3, [T3] * 3]) and expected_utility(RPS, 0, [[T3] * 3, [T3] * 3]) == 0
    mixed = [[F(2, 3), T3], [T3, F(2, 3)]]
    assert is_nash(BOS, mixed)
    assert expected_utility(BOS, 0, mixed) == F(2, 3) == expected_utility(BOS, 1, mixed)
    assert pure_nash_brute(BOS) == [(0, 0), (1, 1)]
    chick = [[T3, F(2, 3)], [T3, F(2, 3)]]
    assert is_nash(CHICKEN, chick) and expected_utility(CHICKEN, 0, chick) == F(14, 3)
    assert pure_nash_brute(PD) == [(1, 1)]


def test_epsilon_nash_and_distributions():
    sigma = [[F(1), F(0)], [F(1), F(0)]]  # both cooperate in the prisoner's dilemma
    assert max_gain(PD, sigma) == 2
    assert is_epsilon_nash(PD, sigma, F(2)) and not is_epsilon_nash(PD, sigma, F(199, 100))
    assert not is_nash(PD, [[H, F(1, 3)], [H, H]])  # not a distribution
    assert is_distribution([H, H]) and not is_distribution([H, F(2, 3)])
    assert not is_distribution({(0, 0): F(3, 2), (1, 1): -H})


def test_correlated_and_coarse_correlated():
    third = {(1, 1): T3, (0, 1): T3, (1, 0): T3}
    assert is_correlated(CHICKEN, third) and is_coarse_correlated(CHICKEN, third)
    assert all(sum(q * CHICKEN[1][s][i] for s, q in third.items()) == 5 for i in (0, 1))
    best = {(0, 1): F(1, 4), (1, 0): F(1, 4), (1, 1): H}
    assert is_correlated(CHICKEN, best)
    assert all(sum(q * CHICKEN[1][s][i] for s, q in best.items()) == F(21, 4) for i in (0, 1))
    assert not is_correlated(CHICKEN, {(1, 1): F(1)})
    # The product of the mixed equilibrium is a correlated equilibrium.
    x = [T3, F(2, 3)]
    prod = {(r, c): x[r] * x[c] for r in range(2) for c in range(2)}
    assert is_correlated(CHICKEN, prod)
    # Rock-paper-scissors: uniform on the six profiles without a tie is a CCE but not a CE.
    six = {(r, c): F(1, 6) for r in range(3) for c in range(3) if r != c}
    assert is_coarse_correlated(RPS, six) and not is_correlated(RPS, six)
    assert not is_correlated(CHICKEN, {(5, 5): F(1)})


def test_every_ce_is_a_cce_on_random_games():
    rng = random.Random(3)
    for _ in range(200):
        game = random_game(rng, (rng.randint(2, 3), rng.randint(2, 3)), 0, 4)
        ps = profiles(game[0])
        w = [rng.randint(0, 3) for _ in ps]
        if sum(w) == 0:
            continue
        dist = {s: F(x, sum(w)) for s, x in zip(ps, w)}
        if is_correlated(game, dist):
            assert is_coarse_correlated(game, dist)
        # Pure equilibria are correlated equilibria.
        for s in pure_nash_brute(game):
            assert is_correlated(game, {s: F(1)})


# ---------------------------------------------------------------- the elimination


def test_prisoners_dilemma_is_solved():
    alive, log = iterated_elimination(PD)
    assert alive == [[1], [1]]
    assert [(i, a) for i, a, _ in log] == [(0, 0), (1, 0)]


THREE = from_bimatrix([[4, 5, 6], [2, 8, 3], [3, 9, 2]], [[3, 1, 2], [1, 4, 6], [0, 6, 8]])


def test_trace_of_the_page():
    alive, log = iterated_elimination(THREE)
    assert alive == [[0], [0]]
    assert [(i, a, w) for i, a, w in log] == [(1, 1, 2), (0, 1, 0), (0, 2, 0), (1, 2, 0)]


MIXED_ONLY = from_bimatrix([[3, 0], [0, 3], [1, 1]], [[1, 0], [0, 1], [1, 0]])


def test_mixed_dominance_without_pure_dominance():
    alive = [[0, 1, 2], [0, 1]]
    assert dominated_by_pure(MIXED_ONLY, alive, 0, 2) is None
    assert dominated_by_mixed(MIXED_ONLY, alive, 0, 2) == {0: H, 1: H}
    kind, belief = mixed_dominance(MIXED_ONLY, alive, 0, 0)
    assert kind == "best response"
    assert iterated_elimination(MIXED_ONLY, "pure")[0] == [[0, 1, 2], [0, 1]]
    assert iterated_elimination(MIXED_ONLY, "mixed")[0][0] == [0, 1]


def _check_certificate(game, alive, i, a):
    _, pay = game
    kind, cert = mixed_dominance(game, alive, i, a)
    others = [b for b in alive[i] if b != a]
    ctx = agt_contexts(alive, i)
    if kind == "dominated":
        assert is_distribution(cert) and set(cert) <= set(others)
        for t in ctx:
            assert sum(p * pay[put(t, i, b)][i] for b, p in cert.items()) > pay[put(t, i, a)][i]
    else:
        assert is_distribution(cert) and set(cert) <= set(ctx)
        ua = sum(q * pay[put(t, i, a)][i] for t, q in cert.items())
        for b in others:
            assert sum(q * pay[put(t, i, b)][i] for t, q in cert.items()) <= ua
    return kind


def agt_contexts(alive, i):
    from iterated_elimination_of_dominated_strategies import _contexts
    return _contexts(alive, i)


def put(t, i, a):
    return t[:i] + (a,) + t[i + 1:]


def test_certificates_on_random_games():
    rng = random.Random(5)
    for _ in range(120):
        sizes = (rng.randint(2, 4), rng.randint(2, 3)) if rng.random() < 0.7 else (2, 2, 2)
        game = random_game(rng, sizes, 0, 6)
        alive = [list(range(k)) for k in sizes]
        for i in range(len(sizes)):
            for a in alive[i]:
                kind = _check_certificate(game, alive, i, a)
                if dominated_by_pure(game, alive, i, a) is not None:
                    assert kind == "dominated"


def test_maximin_value_against_a_grid():
    rng = random.Random(9)
    for _ in range(40):
        cols = rng.randint(1, 4)
        D = [[F(rng.randint(-4, 4)) for _ in range(cols)] for _ in range(2)]
        z, x = maximin(D)
        grid = max(min(F(k, 60) * D[0][c] + F(60 - k, 60) * D[1][c] for c in range(len(D[0])))
                   for k in range(61))
        assert z >= grid and is_distribution(x)


def _restricted_pure_nash(game, alive):
    sizes, pay = game
    out = []
    import itertools
    for s in itertools.product(*alive):
        if all(pay[s][i] >= pay[put(s, i, b)][i] for i in range(len(sizes)) for b in alive[i]):
            out.append(s)
    return out


def test_order_does_not_matter_for_strict_dominance():
    rng = random.Random(1)
    for trial in range(60):
        sizes = (rng.randint(2, 4), rng.randint(2, 4)) if trial % 3 else (2, 3, 2)
        game = random_game(rng, sizes, 0, 5)
        for rule in ("pure", "mixed"):
            base, _ = iterated_elimination(game, rule)
            for seed in range(3):
                r = random.Random(seed)
                other, _ = iterated_elimination(game, rule, pick=lambda c: r.choice(c))
                assert other == base
            # Every pure Nash equilibrium survives, and the equilibria of the reduced game
            # are exactly the pure equilibria of the original game.
            pne = pure_nash_brute(game)
            assert all(all(s[i] in base[i] for i in range(len(sizes))) for s in pne)
            assert _restricted_pure_nash(game, base) == pne
        assert all(set(m) <= set(p) for m, p in zip(iterated_elimination(game, "mixed")[0],
                                                     iterated_elimination(game, "pure")[0]))


WEAK = from_bimatrix([[1, 0], [1, 2], [0, 2]], [[1, 0], [1, 1], [0, 1]])


def _priority(order):
    return lambda c: min(c, key=lambda p: order.index(p) if p in order else len(order))


def test_weak_dominance_depends_on_the_order():
    # Rows T, M, B are 0, 1, 2 and columns L, R are 0, 1.
    first, _ = iterated_elimination(WEAK, "weak", pick=_priority([(0, 0), (1, 0)]))
    assert first == [[1, 2], [1]]
    assert all(WEAK[1][(r, 1)] == (F(2), F(1)) for r in first[0])
    other, _ = iterated_elimination(WEAK, "weak", pick=_priority([(0, 2), (1, 1)]))
    assert other == [[0, 1], [0]]
    assert all(WEAK[1][(r, 0)] == (F(1), F(1)) for r in other[0])
    third, _ = iterated_elimination(WEAK, "weak")
    assert third == [[1], [0, 1]]
    assert weakly_dominated_by_pure(WEAK, [[0, 1, 2], [0, 1]], 0, 0) == 1
    assert dominated_by_pure(WEAK, [[0, 1, 2], [0, 1]], 0, 0) is None


def test_nothing_to_remove():
    for g in (PENNIES, RPS, BOS, CHICKEN):
        for rule in ("pure", "mixed", "weak"):
            alive, log = iterated_elimination(g, rule)
            assert alive == [list(range(k)) for k in g[0]] and log == []


def test_helper_has_no_algorithm():
    names = {n for n in dir(agtgame) if not n.startswith("_")}
    assert names >= {"profiles", "from_bimatrix", "random_game", "expected_utility",
                     "deviation_payoffs", "pure_best_responses", "max_gain", "is_nash",
                     "is_epsilon_nash", "is_distribution", "is_correlated",
                     "is_coarse_correlated", "pure_nash_brute"}

History

The removal of dominated strategies is part of the classical analysis of games in normal form; Osborne and Rubinstein (1994, Chapter 4) give the standard modern account. Moulin (1979) called a game dominance solvable when iterated removal of dominated strategies leaves one outcome, and used it for voting rules. Bernheim (1984) and Pearce (1984) defined rationalizability, and Pearce proved the lemma that a strategy is never a best response exactly when a mixed strategy strictly dominates it. Gilboa, Kalai and Zemel (1993) studied the complexity of the procedure and proved questions about the weak version NP-complete for pure dominators. Conitzer and Sandholm (2005) gave one LP for mixed dominance, path independence and polynomial time for strict iterated dominance, and NP-completeness for weak iterated dominance with and without mixed dominators.

References

  1. Martin J. Osborne and Ariel Rubinstein, A Course in Game Theory, MIT Press, 1994, Chapter 4, Section 4.2 (iterated elimination of strictly dominated actions, and its link to rationalizability) and Section 4.3 (weakly dominated actions)
  2. Yoav Shoham and Kevin Leyton-Brown, Multiagent Systems, Algorithmic, Game-Theoretic, and Logical Foundations, Cambridge University Press, 2009, Chapter 4 (computing solution concepts of normal-form games), the section on domination and iterated removal
  3. The complexity of eliminating dominated strategies, the NP-completeness of questions about the iterated elimination of weakly dominated strategies, with dominance by pure strategies
  4. Vincent Conitzer and Tuomas Sandholm, Complexity of (iterated) dominance, Proceedings of the 6th ACM Conference on Electronic Commerce (EC 2005), 88-97, one LP decides dominance by a mixed strategy; iterated strict dominance is path independent and polynomial; deciding if a strategy can be removed by iterated weak dominance is NP-complete
  5. Rationalizable strategic behavior and the problem of perfection, the lemma that a strategy is never a best response if and only if a mixed strategy strictly dominates it
  6. Rationalizable strategic behavior, the definition of rationalizable strategies
  7. Dominance solvable voting schemes, the definition of a dominance solvable game

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example