TLDR: This research paper formally verifies minimax search algorithms, including those with alpha-beta pruning and transposition tables, using the Dafny verification system. It introduces a novel witness-based correctness criterion for depth-limited search with transposition tables. The study successfully verified the NegamaxTTW algorithm, providing a formal guarantee of its correctness. However, a variant by Marsland (NegamaxTTM) was shown to be incorrect through a concrete counterexample, illustrating the subtle challenges in implementing and verifying optimized game search algorithms.
In the realm of artificial intelligence for games, algorithms like minimax and its optimized counterpart, alpha-beta pruning, are fundamental for determining optimal moves. These algorithms work by exploring a ‘game tree’ – a representation of all possible game states and moves – to find the best strategy, assuming perfect play from all participants. While these algorithms are widely used, ensuring their absolute correctness, especially with complex optimizations, can be a significant challenge.
A recent research paper, titled “Formal Verification of Minimax Algorithms,” delves into this very challenge, presenting a rigorous approach to formally verify a range of minimax search algorithms. The authors, Wieger Wesselink, Kees Huizing, and Huub van de Wetering from Eindhoven University of Technology, utilized the Dafny verification system to achieve this. Dafny is a programming language and verifier designed specifically for writing provably correct programs, leveraging formal logic to ensure that code behaves exactly as intended.
<
Understanding the Core Algorithms
The paper begins by outlining the basics of game tree search. Minimax evaluates game states, with one player aiming to maximize their score and the opponent striving to minimize it. Negamax is a clever reformulation of minimax that exploits symmetry between players, unifying the maximizing and minimizing roles into a single recursive structure. These foundational algorithms are then extended with crucial optimizations.
Alpha-beta pruning is a well-known technique that significantly boosts the efficiency of minimax. It works by intelligently cutting off branches of the game tree that are guaranteed not to influence the final decision, thus avoiding unnecessary computations. Another powerful optimization is the use of transposition tables. These tables store previously computed search results for specific game states, preventing redundant calculations when the same state is encountered multiple times during the search. This is particularly common in games where different sequences of moves can lead to the identical board positions.
The Verification Challenge and a New Criterion
While these optimizations are vital for practical game AI, they introduce considerable complexity. Transposition tables, in particular, are known to be subtle and prone to errors, especially in depth-limited searches where only a portion of the game tree is explored. The paper highlights that even minor implementation differences can lead to incorrect behavior.
To address this, the researchers introduced a novel ‘witness-based correctness criterion’ for depth-limited search algorithms that incorporate transposition tables. This criterion formalizes the intuitive idea that any value returned by the algorithm must be justifiable by the exact evaluation of some fully explored subtree, referred to as a ‘witness.’ This provides a robust framework for reasoning about the correctness of these intricate algorithms.
Applying the Criterion: Success and a Counterexample
The research applied this new correctness notion to two representative algorithms: NegamaxTTW (a version inspired by community sources like Wikipedia) and NegamaxTTM (a variant from Marsland). The results were illuminating.
The NegamaxTTW algorithm was successfully verified using Dafny. This marks, to the authors’ knowledge, the first formal proof of correctness for a depth-limited, transposition-table-based negamax search with alpha-beta pruning. The verification process involved crafting suitable loop invariants and managing Dafny’s interaction with its underlying SMT solver, a testament to the complexity of formal verification.
In contrast, the NegamaxTTM algorithm was found to violate the witness-based correctness criterion. The researchers meticulously constructed a counterexample demonstrating how this variant could produce an incorrect result. The root cause was identified as the reuse of a ‘lower bound’ value, computed within a narrow alpha-beta window, in a subsequent search with a wider window. This reuse led to incorrect pruning of a child node, ultimately yielding an unexpected and incorrect return value. This finding underscores the critical importance of precise semantics and rigorous verification in algorithm design.
Also Read:
- LLMCHECKER: A Formal Method for Verifying Large Language Model Outputs
- Advancing GUI Testing with LLM Agents: Addressing Soundness and Consistency
Broader Impact and Future Directions
Beyond these specific case studies, the team developed and verified over 15 variations of minimax and negamax algorithms, ranging from basic recursive definitions to highly optimized versions. All verification artifacts, including Dafny proofs and Python implementations, are publicly available on GitHub. The most complex verification, that of NegamaxTTW, was completed in approximately 4 seconds using Dafny 4.10.0.
This work powerfully demonstrates the potential of formal verification in ensuring the correctness of complex game tree search algorithms, especially those with optimizations like transposition tables. It highlights how even small algorithmic changes can invalidate correctness arguments, emphasizing the need for precision. The authors propose future work including the formalization of other search algorithms like SSS* and MTD(f), and extending correctness reasoning to quantum variants of game tree search. You can read the full research paper here: Formal Verification of Minimax Algorithms.


