by crote · 2w ago · 0 comments
Even if it does work, a specification will never catch every detail. Any undergrad can come up with a formal specification for a sorting algorithm and prove that some simple ones follow it. But while both a worst-case O(n log n) Timsort and a best-case O(n^2) Selection Sort might technically be guaranteed to sort your data, the two are definitely not interchangeable!
And there is no way to verify the main spec because how do you describe the GCD part? Maybe the idea of a generic verifier of finiteness looks appealling as a common task, a subroutine: here is the specific GCD part and we check finiteness with a standart checker. But it goes against the very fabric of programming, because in programming we sort of reuse logical checks, use interdependencies between variables a generic routine won't know about.