Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For an example of what mafibre is talking about: even proving that a BubbleSort implementation is correct is quite tricky.

First of all, you need to correctly define the specification. Saying "the returned list is sorted" isn't enough because that would also accept lists that have nothing to do with the input, like [1,2,3,4,5]. Also saying that the list only contains elements from the input is also not enough because that would accept a returned list with duplicated or missing elements. To really make a specification that models what you want you need to say that the returned list is a sorted permutation of the input list.

Then, once you manage to get a formal specification that is actually what you want prout invariantving it is also hard. In the bubble sort case you need to figure you need to write down the proofs in detail, down to the point when you use the fact that comparison is a transitive relation.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: