...oduces the correct output for any permitted input. Detailed correctness proofs of even moderately complex algorithms can be surprisingly long, so algorithms researchers (and writers of textbooks like =-=[CLRS01]-=-) often write informal arguments giving only an outline of the full proof. The relationship between the informal argument and the underlying proof is analogous to the relationship between an informal ...

...tire program in one line of code. We can break up the problem of proving a program or algorithm correct by approaching it one statement at a time. One technique for doing this is known as Hoare logic =-=[Hoa69]-=-, a simplified version of which is described below. 2 Hoare logic for straight-line programs The essential idea of Hoare logic is that we attach to each statement of a program a precondition (somethin...

...1 end if end while return x end procedure Why do we know this is partially correct? Because the loop won’t finish until x equals 1. It is widely believed that the loop body will eventually set x to 1 =-=[Lag85]-=-, but at the time of this writing few mathematicians expect to see a proof of this conjecture soon. Sometimes partial correctness is not so useful. Here is a “universal” partially correct algorithm, w...