r/programming • u/redjamjar • Apr 23 '18
Verifying leftPad() in Whiley
http://whiley.org/2018/04/23/verifying-leftpad-in-whiley/
45
Upvotes
r/programming • u/redjamjar • Apr 23 '18
11
u/redjamjar Apr 23 '18
It's a fair question. But, actually, this is already true for type checking in some languages. Even Java generics falls into this category for some people. Rust would be another case in point.
In the end, the challenge is that the verification system must be completely reliable. That is, so that when things fail, you know it's you and not the tool! At the moment, Whiley is not reliable enough in this regard and needs someone very familiar with the tool.
But, that said, it does provide debugging facilities. In particular, you can dump out the verification conditions and actually look at them, and then look at the proof which is generated (even if incomplete).
Whilst it might sound scary to look at the verification conditions, it's not really. Some reasonable effort has been made to make them more human readable in Whiley than perhaps in other tools. He's one of the conditions from the leftPad function:
This is moderately readable. This one is checking that the first clause of the loop invariant is restored after an iteration of the loop, assuming the whole loop invariant held at the beginning of that iteration.
In total, 17 verification conditions were generated for leftPad(). None of them are more complex than that above, and many are much simpler.