Weakest precondition
Definition
Let be a command of an imperative language with a set of states and an operational semantics. Let be a predicate on , identified with the set of states that satisfy it. The weakest precondition is the set of states with this property. Every run of from terminates, and it ends in a state satisfying . Equivalently, is the predicate such that:
- every run of from a state satisfying terminates in a state satisfying ;
- every predicate with property 1 implies .
Remarks
Example: for the assignment , one has , the substitution of for in , provided is always defined. So is , that is, . Property 1 holds since from the new value is positive, and property 2 holds since any state with ends with .
Non-example: the predicate satisfies property 1 for and , but not property 2, since also works. So is a precondition but not the weakest one.
Other standard rules are and . For a loop, is a least fixed point and in practice is approximated with an invariant. The weakest liberal precondition drops the termination requirement and matches partial correctness: the Hoare triple is valid exactly when implies .
Reading path
To understand this page from the ground up, read these 14 pages in order. The foundations come first.
Show the path as a graph
- no evidence level
- Binary relation concept
- Proposition concept
- Substitution concept
- Operational semantics concept
- Conjunction definition
- Disjunction definition
- Implication definition
- Negation definition
- Predicate definition
- Biconditional definition
- Propositional logic concept
- Predicate logic concept
- Hoare logic concept
- Weakest precondition definition
Further reading
About this page
| Tag | 4H635X7K1E |
|---|---|
| URI | m2://4H635X7K1E |
| Kind | definition |
| Writing | W0 stub |
| MSC | 68Q60, 03B70 |
| Defines | Weakest precondition |
| Uses | Hoare logic, Operational semantics, Substitution |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
What links here
No page links to this page yet.