Definition
Floyd's Rule ( Hoare Calculus)
Floyd’s rule or forward assignment provides a way to reason about assignment
in a forward direction, meaning it calculates the strongest postcondition from a given precondition . It is defined as: where
is a fresh variable representing the value of before the assignment.
Mechanics
Unlike the backward assignment rule, Floyd’s rule tracks the “history” of the variable:
asserts that the precondition held for the old value . asserts that the new value of is the result of evaluating using the old value .
The existential quantifier
Example:
Given the triple
By substituting
Complexity
Floyd’s rule is generally more complex to apply manually than the backward rule because it introduces quantifiers. However, it is the more “natural” way to think about program execution as a forward transformation of state.