Lably
Skip to content

Hoare logic

Rules to verify computer program correctness

  • 8 min read
  • 3 chapters

Related on Lably

Through Correctness (computer science), Mathematical logic and Flowchart

Hoare triple

The central feature of Hoare logic is the Hoare triple. A triple describes how the execution of a piece of code changes the state of the computation. A Hoare triple is of the form

{P}C{Q}

where P and Q are assertions and C is a command. P is named the precondition and Q the postcondition: when the precondition is met, executing the command establishes the postcondition. Assertions are formulae in predicate logic.

Hoare logic provides axioms and inference rules for all the constructs of a simple imperative programming language. In addition to the rules for the simple language in Hoare's original paper, rules for other language constructs have been developed since then by Hoare and many other researchers. There are rules for concurrency, procedures, jumps, and pointers.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication