A Reference Manual
Second Edition
J. M. Spivey
Programming Research Group University of Oxford
Based on the work of J. R. Abrial, I. J. Hayes, C. A. R. Hoare, He Jifeng, C. C. Morgan, J. W. Sanders, I. H. Sørensen, J. M. Spivey, B. A. Sufrin
This edition first published 1992 by Prentice Hall International (UK) Ltd Published 1998 by J. M. Spivey Oriel College, Oxford, OX1 4EW, England c J. M. Spivey, 1989, 1992 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form. or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior permission, in writing, from the publisher. For permission in all countries contact the author.
Contents
Preface 1 Tutorial Introduction What is a formal specification? 1.1 1.2 The birthday book 1.3 Strengthening the specification 1.4 From specifications to designs Implementing the birthday book 1.5 1.6 A simple checkpointing scheme Background 2.1 Objects and types 2.1.1 Sets and set types 2.1.2 Tuples and Cartesian product types 2.1.3 Bindings and schema types 2.1.4 Relations and functions 2.2 Properties and schemas 2.2.1 Combining properties 2.2.2 Decorations and renaming 2.2.3 Combining schemas 2.3 Variables and scope 2.3.1 Nested scopes 2.3.2 Schemas with global variables 2.4 Generic constructions 2.5 Partially-defined expressions The Z Language 3.1 Syntactic conventions 3.1.1 Words, decorations and identifiers 3.1.2 Operator symbols 3.1.3 Layout 3.2 Specifications 3.2.1 Basic type definitions
vii 1 1 3 7 10 11 17 24 24 25 25 26 27 28 29 30 31 34 35 36 38 40 42 42 43 43 46 47 47
2
3
v
vi
Contents
3.2.2 Axiomatic descriptions 3.2.3 Constraints 3.2.4 Schema definitions 3.2.5 Abbreviation definitions Schema references Declarations 3.4.1 Characteristic tuples Schema texts Expressions Predicates Schema expressions Generics 3.9.1 Generic schemas 3.9.2 Generic constants Free types 3.10.1 Example: