Re:The Case Against Formal Verification, 50 Years Later
by inigyou on Monday August 17, 2026 @08:11AM
(#49329597)
you have the common problems with non-uniqueness and with extra elements. Your spec is met by:
SORT(1,2,3,4,5,5,6) = 1,2,3,4,5,6
SORT(1,2,3,4,5,5,6) = 1,2,3,4,5,6,7
and a bounds checking bug unique to your formal spec because you only check inputs up to the length of the output // first 0 elements of input must occur in output
SORT(1,2,3,4,5,5,6) = empty list
// first 6 elements of input must occur in output
SORT(1,2,3,4,5,5,6) = 1,2,3,4,5,7
Re:The Case Against Formal Verification, 50 Years Later
by samus on Tuesday August 25, 2026 @12:41PM
(#49436884)
My second condition would reject the additional element, as it would not be found in the input. have to be duplicated to However, I was lazy about the `|input| = |output|` constraints. With those constraints it would not be possible to omit elements from the input in the output.
It can be fixed (feedback welcome) by adding: `forall i, j. 0 <= i < |sorted| -> |indexof_id(sorted, input[i])| = 1`, with `indexof_id` using equality by identity, which is crucial in practice.
Note that the amended definition implies quadratic runtime, which is the crucial difference between a specification and an efficient implementation.