Trustworthy Graph Algorithms (Invited Talk)

Mohammad Abdulaziz, Kurt Mehlhorn, Tobias Nipkow

TL;DR

This paper reflects on a 30-year journey toward building trustworthy graph algorithms, charting the progression from clean C++ library design in LEDA to certifying algorithms, verified certificate checkers, and full formal verification. The centerpiece is the formal verification of Edmonds’ complex blossom-shrinking algorithm for maximum cardinality matching in the Isabelle/HOL interactive theorem prover, alongside a roadmap for extracting efficient, verified executable code.

What Problem Does This Paper Address?

Implementing complex combinatorial and graph algorithms correctly is notoriously difficult. Early releases of foundational libraries—such as LEDA (Library of Efficient Data Types and Algorithms)—suffered from subtle bugs, such as planarity tests misclassifying planar graphs.

To prevent erroneous outputs, computer scientists developed certifying algorithms, which output both a solution and an easily checkable mathematical witness (certificate) proving correctness (e.g., an odd-set cover proving a matching is maximal). While verifying the small checker programs was tractable, the core algorithms themselves remained unverified due to the daunting complexity of formalization, often estimated at several person-years of effort. This paper tackles the challenge of formally proving the correctness of one of graph theory’s most intricate algorithms: Edmonds’ blossom-shrinking matching algorithm.

Methods

The authors structure trustworthiness into five progressive levels:

  1. Clean Abstractions (LEDA): Formulating code close to mathematical pseudo-code.
  2. Certifying Algorithms: Returning witnesses alongside outputs (e.g., Kuratowski subgraphs, odd-set covers).
  3. Formal Verification of Checkers: Formally verifying checker programs in Isabelle/HOL using tools like Simpl, VCC, and AutoCorres.
  4. Formal Verification of Complex Algorithms: Fully formalizing Edmonds’ blossom-shrinking algorithm in Isabelle/HOL.
  5. Code Extraction: Translating verified logic into executable, high-performance programs via stepwise refinement.

To verify the blossom-shrinking algorithm in Isabelle/HOL, the authors adopted a modular, top-down refinement strategy using Isabelle locales:

  • Berge's Lemma: Proving that a matching is maximum if and only if no augmenting path exists.
  • Blossom Contraction and Lifting: Proving that shrinking an odd cycle (blossom) preserves the existence of augmenting paths, formalizing a constructive refinement function (refine) to lift paths from the quotient graph back to the original graph.
  • Alternating Tree Search: Formalizing the alternating forest search using a recursive state function with 10 inductive loop invariants.

Datasets

Not discussed in the paper. (As a theoretical and formal verification study, the work does not evaluate empirical benchmarks or datasets.)

Key Insights and Ideas

  • Verification Catches Spec Blindspots: Attempting to formally verify LEDA’s maximum matching checker revealed a hidden flaw: the implementation never verified whether the edges in the matching $M$ actually belonged to the graph $G$.
  • Formalization Inspires Simpler Math: Standard textbook proofs of Berge's lemma require classifying all connected components of the symmetric difference $M \oplus M'$ (into vertices, paths, and cycles). While mechanizing the proof, the authors discovered a simpler, direct proof that constructs an alternating path directly without analyzing all components.
  • Constructive Lifting Over Pure Existence: Rather than proving non-constructively that an augmenting path exists in the uncontracted graph, the authors defined an almost-executable refine function. This bridges mathematical proof with concrete algorithm design.
  • Locales Enable Incremental Refinement: Using Isabelle/HOL locales allowed the team to verify high-level algorithm logic (e.g., path augmentation loops) while abstracting subroutines, later instantiating those subroutines with verified implementations.

Key Results

  • Complete Verification in Isabelle/HOL: Formally verified the soundness and completeness of Edmonds' blossom-shrinking algorithm for finding maximum cardinality matchings.
  • Verified Inductive Invariants: Formulated and machine-checked 10 simultaneous loop invariants required to prove the correctness and termination of the alternating tree exploration.
  • Direct Proof of Berge’s Lemma: Successfully formalized a streamlined version of Berge’s Lemma, reducing proof overhead in interactive theorem proving.

Limitations and Future Work

  • Imperative Refinement Needed: The verified Isabelle/HOL implementation is functional and abstract; it currently uses non-executable constructs like Hilbert's choice operator (SOME x. P) for nondeterministic selection. These must be replaced via algorithmic refinement.
  • Bridging the Efficiency Gap: Modern imperative implementations rely on low-level optimizations (such as Union-Find data structures for cycle shrinking and direct pointer manipulations). Translating the verified logic into imperative, high-performance C/C++ code with trustworthy memory management remains an open engineering challenge.
  • End-to-End Verified Libraries: The authors highlight verified compilers (like CakeML) and monadic imperative frameworks (like Imperative-HOL) as the next steps toward realizing fully verified, highly performant algorithm libraries.

Summary updated

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