A precondition of a function is a condition on its arguments that the caller must make true before the call. A postcondition is a condition on the result (and on the arguments) that the function makes true when it returns, provided the precondition held.
Examples
Example 1.5 (The specification of a maximum)
For a function largest(t): the precondition is “t is a non-empty list of numbers”; the postcondition is “the result is an element of t, and no element of t is larger”. The empty list is excluded because it has no largest element: the specification forces the author to decide this case instead of leaving it to chance.
Example 1.11 (Tests for leap_year)
One year of each kind: , , , ; the edge of the precondition: , which is not a leap year. Sam’s original function fails exactly one of these five tests, the one for . Any set of tests that misses the third kind misses her bug, however many years it contains.