Hoare logic
Builds on Predicate logicOperational semanticsSubstitutionSoundness
Definition
Consider the while language, whose commands are , where ranges over integer expressions and over boolean expressions in the program variables. Assertions are formulas of first-order predicate logic over the integers whose free variables may include the program variables. A Hoare triple is an expression . Runs of commands are given by the operational semantics of the language. The triple is valid if, for every state satisfying , every terminating run of from ends in a state satisfying . Hoare logic is the proof system whose derivable triples are generated by these rules.
- Skip: .
- Assignment: , where is the substitution of for in .
- Composition: from and derive .
- Conditional: from and derive .
- While: from derive .
- Consequence: from , and , where the implications are true in the integers, derive .
Remarks
Example: is derivable. Rule 2 gives , and rule 6 applies since implies .
Non-example: is not valid, since from the state the command ends with . It is not derivable either, because Hoare logic is sound: every derivable triple is valid.
The triples above express partial correctness: is valid, because the loop never terminates. Total correctness, written , also requires termination, and its while rule needs a variant that decreases in a well-founded order. Stephen Cook proved that the system is relatively complete: every valid triple is derivable if all true assertions of the integers may be used in rule 6.
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
- Soundness 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 definition
Further reading
About this page
| Tag | 34XG5YRMPH |
|---|---|
| URI | m2://34XG5YRMPH |
| Kind | definition |
| Writing | W0 stub |
| MSC | 68Q60, 03B70 |
| Defines | Hoare logic |
| Uses | Predicate logic, Operational semantics, Substitution, Soundness |
| 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.