Alpha-Beta Pruning via Monadic Continuations

Martín Escardó, Paulo OlivaarXiv 2026

TL;DR

Alpha-beta pruning is a classic AI algorithm that speeds up game-tree search by ignoring branches that can’t possibly improve a player's outcome. Here, Escardó and Oliva show how to build and formally verify this foundational algorithm cleanly in functional programming using only standard, off-the-shelf monads—yielding a modular, compositional implementation that slashes Tic-Tac-Toe search evaluations by 39x without awkward type gymnastics.

What Problem Does This Paper Address?

If you're writing a game-playing AI, minimax search finds the best move by assuming your opponent plays optimally. Because checking every possible future board is painfully slow, alpha-beta pruning tracks two bounds ($\alpha$ and $\beta$, representing the best guaranteed scores for the maximising and minimising players) to chop off irrelevant branches early.

Fig. 1. The example game tree. Each node shows its optimal outcome. The outcomes in grey are those that the alpha-beta search of Section 3 does not evaluate.

In functional programming (like Haskell), you can express exhaustive minimax elegantly by composing players as "quantifiers" using the continuation monad (an abstraction that represents computations in terms of "what happens next"). However, adding stateful optimizations like alpha-beta bounds into this clean, compositional pipeline gets messy:

  1. Polluted Move Types: Previous attempts stuffed $\alpha$ and $\beta$ directly into the data type of moves (turning a simple Move into (Move, Alpha, Beta)), breaking clean separation of concerns.
  2. Broken Laziness for Optimal Plays: Usually, functional approaches switch to a related tool called the selection monad when they want the actual winning sequence of moves rather than just the final score. Unfortunately, passing $\alpha$-$\beta$ bounds down the tree blocks the lazy evaluation that makes the selection monad fast, forcing it to recalculate subgames over and over. To fix this, prior work had to invent custom, generalized continuation monads.

The authors ask: can we get fast, verified alpha-beta pruning—computing both scores and winning move sequences—using just standard monads while leaving move types untouched?

Methods

Instead of inventing new monads or altering move types, the authors layer two standard functional abstractions:

  • Continuation + Reader Monads: In a standard continuation monad $K_R X \equiv (X \to R) \to R$, $X$ is the type of available moves and $R$ is the game outcome. The authors replace the plain outcome $R$ with a "monadic outcome" $TR$, where $T$ is the reader monad—an abstraction designed to pass read-only environments (here, the $(\alpha, \beta)$ pair) down a computation. Move types stay pure; the outcome type handles the bookkeeping.
  • Local Bound Updates & Short-Circuiting: As a player evaluates a list of moves, Haskell’s local function updates $\alpha$ or $\beta$ for subsequent sibling branches, while a takeUntil helper halts evaluation of the list the moment a score crosses the pruning threshold.
  • Path-Extended Outcomes: To find the actual sequence of moves (optimal play) without touching the sluggish selection monad, they simply change the outcome type from Score to a pair: (Score, Path). A custom tie-breaker (pickMax/pickMin) ensures taking the first move that achieves the best value, preventing bounds from pruned subgames from overwriting genuine optimal paths.
  • History-Dependent Sequencing: For real board games where legal moves depend on past moves, they swap standard monadic sequence for a history-dependent product of quantifiers (hsequence) that feeds the partial play so far into the next round's quantifier.

Datasets

Not discussed in the paper. Instead of training or benchmark datasets, the authors evaluate their algorithmic formulation on two deterministic game trees:

  • A 4-ply, 36-leaf toy game tree adapted from Wikipedia's alpha-beta pruning entry.
  • The complete game tree of Tic-Tac-Toe.

Key Insights and Ideas

  • Put the state in the outcome, not the moves: By shifting $\alpha$ and $\beta$ into a Reader monad wrapped around the outcome ($K_{TR}X$), the local quantifiers (individual rounds) can be upgraded from exhaustive search to alpha-beta search without changing how they are composed into a global game.
  • The ordinary continuation monad is enough: You don't need the selection monad or bespoke polymorphic continuation monads to extract optimal plays. Pairing the score with the path inside $R$—provided you handle tie-breaking carefully around pruned bounds—solves the recalculation bottleneck with zero new theoretical machinery.
  • Compositional proofs scale effortlessly: Because the correctness proof works by induction on the game tree using local quantifier properties, proving it for simple, history-free games automatically carries over to complex, history-dependent board games where move types and game lengths vary dynamically.

Key Results

  • Toy Game Tree: Exhaustive continuation search evaluated all 36 leaf paths to find the optimal value (6); the Reader-monad alpha-beta version found both the optimal value and path (6, [1,0,0,0]) while evaluating only the 18 essential plays.
  • Tic-Tac-Toe: Exhaustive search evaluated all $9! =$ 362,880 full plays. The monadic alpha-beta search computed the exact same optimal draw outcome and play (0, [0,4,1,2,6,3,5,7,8]) while evaluating only 9,335 plays—roughly a 39-fold reduction.
  • Formal Verification: All core theorems and corollaries proving that monadic alpha-beta search matches exhaustive minimax (even on trees with arbitrary move types and history-dependent lengths) are machine-checked and formalized in the Agda proof assistant (TypeTopology library).

Limitations and Future Work

The authors do not include a dedicated limitations section, though a few technical constraints are noted in the text: every non-final game position must have a non-empty list of moves, outcomes must map to values with a decidable strict weak order, and exact equality with exhaustive minimax requires either starting with initial $(\alpha, \beta)$ bounds strictly wider than all possible game outcomes, or verifying after the run that the computed result lies strictly between the chosen initial bounds (as happened in their Tic-Tac-Toe setup). For future work, the authors position this verified, standard-monad construction as a foundation for developing broader compositional approaches to adversarial search.

Summary updated

BibTeX
@misc{escardo2026alpha,
  author = {Martín Escardó and Paulo Oliva},
  title = {{Alpha-Beta Pruning via Monadic Continuations}},
  year = {2026},
  eprint = {2611.32320},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.32320},
}
Figure