3 comments

[ 197 ms ] story [ 1174 ms ] thread
IIRC this book unfortunately only proves correctness directly and not runtime. Its runtime proofs are based off an abstraction of the algorithm suitable for direct manipulation by proofs rather than the actual implementation in code.

Does anybody know of any languages that let you prove properties about the runtime of a function directly implemented in the language?

Eiffel is the language you are looking for. It's pre-conditions and post-conditions prove the properties of the code that you actually are executing.

The book that does the equivalent but with the properties checked at runtime is: Object Structures (like data structures but with objects).

Here is the link:

https://openlibrary.org/works/OL2979696W/Object_structures?e...

Some algorithms such as binary search give an incorrect view of the overall cost. The search has a prerequisite of sorting. So, the assumption is, the data is sorted once, and searched several times, making the sorting cost insignificant.

What if the data is used for only a single lookup? For this case, actually a sequential search would have lower cost compared to sorting and binary search. Infact, sequential search may beat sorting and binary search for upto about 100 lookups. So I think it is important to consider overall cost.