Trustworthy Graph Algorithms

Mohammad Abdulaziz, Kurt Mehlhorn, Tobias Nipkow

In the realm of high-performance computing, algorithmic "correctness" is frequently assumed but rarely proven. For decades, the LEDA (Library of Efficient Data types and Algorithms) has served as a cornerstone for graph theory applications. However, even prestigious libraries are not immune to subtle bugs. Early versions of LEDA encountered errors in planarity tests and geometric primitives, often stemming from floating-point inaccuracies or overlooked edge cases. This paper chronicles the 30-year evolution of LEDA from a standard software collection to a formally verified framework, culminating in the verification of Edmonds' blossom-shrinking algorithm.

Bridging the Trust Gap

The fundamental challenge in software engineering is the "trust gap"—the distance between a high-level mathematical proof and the complex C++ code executed on a machine. To bridge this gap, the authors propose a five-level hierarchy of trustworthiness:

  1. The Library Level: Establishing a clean, well-documented library.
  2. Certifying Algorithms: Designing algorithms that produce a "witness" (certificate) alongside the result.
  3. Formal Verification of Checkers: Using theorem provers to ensure the checker (which validates the witness) is correct.
  4. Formal Verification of Complex Algorithms: Proving the correctness of the algorithm itself (e.g., Blossom-shrinking) within a logic system.
  5. Verified Code Extraction: Automatically generating executable code from the proven mathematical model.
Figure 1: Comparison between a standard program (top) and a certifying program with a checker (bottom). The certifying program produces a witness $w$ which the Checker $C$ uses to verify the output $y$ for input $x$.

Certifying Algorithms and Checkers

A certifying algorithm does more than solve a problem; it provides evidence of its success. For instance, a planarity tester might output a Kuratowski subgraph to prove a graph is non-planar. This shifts the burden of proof from a massive, complex algorithm to a much simpler "checker" program. As shown in Figure 1, the checker takes the input, the output, and the witness to either accept or reject the result. This approach significantly reduces the TCB (Trusted Computing Base).

Formalizing the Blossom-Shrinking Algorithm

The technical centerpiece of this work is the formal verification of the blossom-shrinking algorithm for maximum cardinality matching using Isabelle/HOL. This involved formalizing Berge’s Lemma and the intricate "lifting" process, where an augmenting path found in a shrunken graph is mapped back to the original structure.

Interestingly, the process of formalization yielded unexpected benefits. While the authors previously believed their checkers were simple enough to be "evidently" correct, formal logic revealed a flaw: a matching checker had failed to verify that the edges in the matching actually existed in the original graph. Furthermore, the rigor of Isabelle/HOL led to a new proof of Berge’s Lemma that is shorter and more direct than standard textbook versions.

Results and Future Outlook

The authors successfully completed the formal verification of the blossom-shrinking algorithm, contributing a significant foundation of graph theory to the Isabelle/HOL environment. While the algorithm is now "almost executable," challenges remain. The effort-to-code ratio is high; fully verifying a 330-line C++ implementation can require years of manual effort.

Future work aims to bridge the efficiency gap, ensuring that verified code performs as well as hand-optimized C++. Additionally, the authors look toward verified memory management and the ultimate goal: a fully verified LEDA library providing mathematical certainty for every algorithm it contains.

Summary updated

BibTeX
@inproceedings{abdulaziz2019trustworthy,
  author = {Mohammad Abdulaziz and Kurt Mehlhorn and Tobias Nipkow},
  title = {{Trustworthy Graph Algorithms}},
  booktitle = {MFCS},
  year = {2019},
  url = {https://openreview.net/forum?id=tv_zykXjxDG},
}
Figure