hoare-calculus

Definition

Implication (Rule of Consequence)

The rule of consequence allows for the strengthening of the precondition and the weakening of the postcondition. It is formally expressed as:

where:

  • means that is stronger than (it restricts the state space more).
  • means that is weaker than (it is a more general requirement).

Intuition

If a program is correct with respect to a precondition and postcondition , then it is also correct if:

  1. We start in a “stricter” state that satisfies .
  2. We end in a state that satisfies a more “lenient” condition .

This rule is essential for connecting different steps in a Hoare proof, as it allows matching the postcondition of one command with the precondition of the next, even if they are not syntactically identical.

Semantic Requirement

The implications and are often proven using the semantics of the underlying logic (e.g. predicate logic) rather than the rules of the Hoare calculus itself.