News for hackers. Stuff that matters.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by wandering2 on Friday July 22, 2016 @09:12PM (#12147880)
> I was shocked to learn that the binary search program that Bentley proved correct and subsequently tested in Chapter 5 of Programming Pearls contains a bug.

Huh? How did he prove it correct, then?

Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by feral on Friday July 22, 2016 @09:17PM (#12147898)
'Proofs' done by humans are done within a certain context; there's usually a lot that goes unstated, or is left unexamined at the finest level of detail.

Generally that isn't a problem and the 'small' details or assumptions don't 'leak' up to higher levels and do any real damage to the proof.

There's a movement to make proofs formally verified, to try move towards eliminating this issue, but that's hard, because writing out every little detail, specifying every last piece of context & assumption & step is laborious.

Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by cmdrfred on Friday July 22, 2016 @09:32PM (#12147932)
> because writing out every like detail, specifying every last piece of context & assumption & step is laborious.

Can code be written and subsequently formally verified that can then help in the process of formally verifying code?

Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by tinco on Friday July 22, 2016 @10:04PM (#12148022)
It is not the verification that is laborious, although it can be computationally intensive, it is the specification. It is making sure that whatever it is you are proving is actually exactly and completely what you desire of the function.

In this case the proof did not properly account for the full range of inputs, of at least skipped over the fact that in real hardware the integer domains are finite.

There's a lot of formal verification tools out there though, they do make it easier,easy enough to at least properly verify the correctness of a simple sorting algorithm.

Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by mnarayan01 on Friday July 22, 2016 @09:21PM (#12147904)
On an idealized machine with arbitrarily large integers I assume.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by haimez on Friday July 22, 2016 @09:30PM (#12147930)
How else do you "prove" trivial algorithms other than by removing the realities of an actual runtime environment?

I'm pretty sure you're right though. Integers must have been defined as infinite in the proof for it to have been a proof at all.

Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by mnarayan01 on Friday July 22, 2016 @10:02PM (#12148016)
If you sufficiently specify the runtime environment the proof can still work: Since the array is composed of integers, many C compilers/machine architectures will dictate a maximum size of the array s.t. there can't be overflow.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by haimez on Friday July 22, 2016 @10:19PM (#12148055)
Touche, and fair enough- although you would expect them to call out that limitation since it's both critical and highly un-general. Bytes are comparable, small, and common enough to at least accommodate an exclusionary statement in the proof.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by mark-r on Saturday July 23, 2016 @12:19AM (#12148320)
This is why I prefer to use Python for my binary searches ;-)
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by Tloewald on Saturday July 23, 2016 @03:00AM (#12148651)
A proof is only, at bottom, a convincing argument. Mathmematicians are harder to convince than most people, but they can still miss things.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by mshenfield on Friday July 22, 2016 @10:05PM (#12148026)
One possible scenario is he proved it correct assuming that the ints in the function were mathematical integers(-infinity, ... -1, 0, 1, ..., infinity). In realty all representations of numbers have an upper limit after which the representation will become corrupted or unsupported.