No Title Programming With Invariants Complex algorithms are easier to code if we design them around invariants - facts that we know to be true at particular points in execution.
Informal invariants are just comments.
Invariants can be formalized using proof rules , which also can be viewed as an axiomatic semantics for the programming language. Automated theorem provers can be used to help produce precise, formal proofs of program correctness. A standard approach to this problem is to use two pointers, starting at the ends of the slice and moving towards the middle, exchanging elements when necessary. Being More Careful Formalizing Proofs of Correctness Prove formulas involving assertions about program variables. The formula says that if the precondition P is true before the execution of S then the postcondition Q will be true after the execution of S .