Book contents
- Frontmatter
- Contents
- Preface
- List of symbols
- 0 Introduction
- 1 Weakest preconditions
- 2 Annotation, recursion and repetition
- 3 Healthiness laws
- 4 Semantics of recursion
- 5 Ramifications
- 6 Relational semantics
- 7 Determinacy and disjunctivity
- 8 Syntactic criteria
- 9 Operational semantics of recursion
- 10 Procedure substitutions
- 11 Induction and semantic equality
- 12 Induction and refinement
- 13 The strong preorder
- 14 Temporal operators
- 15 Predicative fairness
- 16 Solutions of exercises
- References
- Index of concepts and identifiers
2 - Annotation, recursion and repetition
Published online by Cambridge University Press: 11 March 2010
- Frontmatter
- Contents
- Preface
- List of symbols
- 0 Introduction
- 1 Weakest preconditions
- 2 Annotation, recursion and repetition
- 3 Healthiness laws
- 4 Semantics of recursion
- 5 Ramifications
- 6 Relational semantics
- 7 Determinacy and disjunctivity
- 8 Syntactic criteria
- 9 Operational semantics of recursion
- 10 Procedure substitutions
- 11 Induction and semantic equality
- 12 Induction and refinement
- 13 The strong preorder
- 14 Temporal operators
- 15 Predicative fairness
- 16 Solutions of exercises
- References
- Index of concepts and identifiers
Summary
This chapter is devoted to the introduction of annotations, procedures, recursion and repetitions, all concepts highly relevant to programming practice and programming methodology. In 2.1 we introduce Hoare triples as a specification method. Hoare triples are used in 2.2 for correctness proofs by annotation. In 2.3 and 2.4 we treat procedures in a programming language like Pascal. The specification and invocation rules are discussed in Section 2.3. The correctness of recursive procedures is treated in Section 2.4. The methods presented here are not new but deserve to be promoted.
In Section 2.5 we present and prove an abstract version of the rule for total correctness of recursive procedures. In 2.6 we introduce homomorphisms, functions from commands to predicate transformers that satisfy the standard laws of wp and wlp. Homomorphisms are used in 2.7 to give Hoare's Induction Rule for conditional correctness of recursive procedures, and a related rule for the necessity of preconditions. Finally, in Section 2.8, the results on recursive procedures are specialized to the repetition.
With respect to recursive procedures, this chapter is not ‘well-founded’. We only postulate some properties and proof rules, but the definition of the semantics of recursion (i.e., of the functions wp and wlp) and the proof of the postulates are postponed to Chapter 4.
Specification with Hoare triples
Weakest preconditions provide the easiest way to present predicate–transformation semantics. The formalism of Hoare triples, however, is completely equivalent and more convenient for program derivations and proofs of program correctness.
- Type
- Chapter
- Information
- Programs, Recursion and Unbounded Choice , pp. 32 - 57Publisher: Cambridge University PressPrint publication year: 1992