Long division verified via Hoare logic

The long-division algorithm is either boring or funny, depending on your viewpoint. The code itself, written in C-like syntax, implements long division for N-bit unsigned integers, playing with shifts and bitwise operations. The proof of correctness is demonstrated via Hoare logic using axioms for assignments, composition, conditionals, and while-loops. Finding the right loop invariant is the key challenge, which gets technical but eventually boils down to a simple intuition about bits. Observations are made on the trickiness of proving invariants. The author humorously describes the process, making an insightful journey through formal verification that might amuse an expert or perplex a novice.

https://www.cofault.com/2025/02/long-story-of-division.html

To top