program-proofing

Definition

Program Proofing

Program proofing (or program verification) is the formal process of proving that a program is correct with respect to a formal specification.

Methods

Hoare Calculus

Decompose correctness assertions into simpler ones using inference rules until only true statements and valid formulas remain. This method uses the Hoare calculus directly.

Definition

Hoare Calculus

The Hoare calculus is a calculus for reasoning about the correctness of programs. It uses Hoare triples together with axioms and inference rules to show that a program transforms states satisfying a precondition into states satisfying a postcondition.

Link to original

Weakest Precondition

Calculate the weakest formula such that holds, and show that the given precondition implies .

Definition

Weakest Precondition

The weakest precondition of a program and a postcondition is the most general (least restrictive) formula such that the Hoare triple is totally correct.

Equivalently, characterises exactly the states from which terminates in a state satisfying .

If a precondition implies , then is totally correct.

Link to original

Strongest Postcondition

Calculate the strongest formula such that holds, and show that implies the desired postcondition .

Definition

Strongest Postcondition

The strongest postcondition of a program and a precondition is the most specific (most restrictive) formula such that the Hoare triple is partially correct.

Equivalently, it is the set of states reached by executing from states satisfying :

If a postcondition is implied by , then is partially correct.

Link to original