Hacker News new | ask | show | jobs
by itissid 1043 days ago
Overheard at the watercooler: The only way a CS guy knows how to prove an algorithm works/does not work is to find counterexamples.
4 comments

My real analysis instructor drily pointed out “You really like proof by contradiction huh” and my defense was that my main life skill is spotting why plausible-seeming things don’t work correctly
Seems hard to prove that an algorithm works by finding counterexamples.
I think most bugs are the result of someone's attempt to do just that. As is test-driven development I suppose.

Then again proving code works isn't everything either. There's a reason Knuth once stated "Beware of bugs in the above code; I have only proved it correct, not tried it."

Type checking is a nice intermediate, though not all languages allow all properties you care about to be encoded in types.

Just express it as an n-state Turing machine and see if it halts within BB(n) steps. /s
And, if n is large enough, then I can retire today.
Watercooler guy has never heard of Mathematical Engineering or Edsger Dijkstra. If he had then he'd know that proof by construction is the method par excellence for showing an algorithm is correct.
I would've picked proof by induction for CS peeps!