Conference paper Open Access

Functional Correctness of C implementations of Dijkstra's, Kruskal's, and Prim's Algorithms

Mohan, Anshuman; Leow, Wei Xiang; Hobor, Aquinas

We develop machine-checked verifications of the full functional correctness of C implementations of the eponymous graph algorithms of Dijkstra, Kruskal, and Prim. We extend Wang et al.’s CertiGraph platform to reason about labels on edges, undirected graphs, and common spatial representations of edge-labeled graphs such as adjacency matrices and edge lists. We certify binary heaps, including Floyd’s bottom-up heap construction, heapsort, and increase/decrease priority.

Our verifications uncover subtle overflows implicit in standard textbook code, including a nontrivial bound on edge weights necessary to execute Dijkstra’s algorithm; we show that the intuitive guess fails and provide a workable refinement. We observe that the common notion that Prim’s algorithm requires a connected graph is wrong: we verify that a standard textbook implementation of Prim’s algorithm can compute minimum spanning forests without finding components first. Our verification of Kruskal’s algorithm reasons about two graphs simultaneously: the undirected graph undergoing MST construction, and the directed graph representing the forest inside union-find. Our binary heap verification exposes precise bounds for the heap to operate correctly, avoids a subtle overflow error, and shows how to recycle keys to avoid overflow.

As submitted to the CAV '21 Artifact Evaluation Committee.
Files (392.2 kB)
Name Size
CertiDPK-as-submitted.pdf
md5:3fac44747e9da81d2bf5a6afe439f713
278.7 kB Download
Dockerfile
md5:025ebfd208587e0a7ee611790cd5d424
1.9 kB Download
LICENSE
md5:54fd4474b7c450d7263078745655dc56
1.6 kB Download
README.pdf
md5:ddfbb0c10d8b8e653f00a780e2758dcb
110.0 kB Download
239
160
views
downloads
All versions This version
Views 239239
Downloads 160160
Data volume 33.7 MB33.7 MB
Unique views 211211
Unique downloads 135135

Share

Cite as