Requirements Specification and Verification Using Z
1.43k likes | 1.46k Vues
Learn about Z notation, a formal specification language based on set theory and predicate logic, used for describing complex dynamic systems. Discover its tools and importance of proof techniques in system development.
Requirements Specification and Verification Using Z
E N D
Presentation Transcript
CEIT AUT Requirements Specification and Verification Using Z A. Rasoolzadegan July, 2009
Z (pronounced `zed') - Introduction • Named after Zermelo-Fränkel set theory • A formal specification language based on set theory and first order predicate logic • Makes it easier to write mathematical description of complex dynamic systems such as software, • Originally proposed by Abrial in 1977 with the help of Steve Schuman and Bertrand Meyer • Developed further at the Programming Research Group at the Oxford University Computing Laboratory (OUCL) and elsewhere since the late 1970s,
Introduction (Cont.) • Mathematical Language • set theory • standard set operators, set comprehensions, Cartesian products, and power sets. • mathematical logic • first order predicate calculus • Schemas language • used to describe • the state of a system, • the ways in which that state may change • system properties
Introduction (Cont.) • We may refine a specification, yielding another description that is closer to executable code, • We may reason about these specifications using the proof techniques of mathematical logic, • Z is not intended for the description of non- functional properties neither for timed & concurrent behavior • Various tools for formatting, type-checking and aiding proofs in Z are available, • The ISO completed a Z standardization effort in 2002
The importance of proof • At the specification stage: • help us to understand the requirements upon a system, and • can assist us in identifying any hidden assumptions • At the design stage: • can show us not only that a design is correct, • but also why it is correct. • At the implementation stage: • help us to ensure that a piece of code behaves according to the specification • A significant contribution to quality improvement
The importance of proof (Cont.) • A specification without proofs • is untested: • it may be inconsistent; • it may describe properties that were not intended, or omit those that were; • it may make inappropriate assumptions.
The logical language of Z • Propositional Logic • Predicate Logic
Propositional Logic Propositional connectives
Propositional Logic (Cont.) • These inference rules form part of the natural deduction system that we use to conduct our proofs: modus ponens rule
The logical language of Z • Propositional Logic • Predicate Logic
Predicate Logic • Is a powerful technique to expressing the universal and existential statements (quantified predicates)
Predicate Logic (Cont.) Aspecialcase:
Predicate Logic (Cont.) A special case:
Set Theory • Mathematical objects are often seen as well-defined collections of other objects • The Z notation is based upon set theory • Specifications in Z find their meanings as operations upon sets • All the set theory we require for specification, refinement, and proof: • the notions of • set membership, • extension, • Comprehension, • the power set and • Cartesian product constructors. the set of finite subsets of a
Set Theory (Cont.) • Some axioms of Zermelo-Fraenkel set theory: • This inference rule is supported by two axioms of Zermelo-Fraenkel (specification &replacement):
Exp. Proof:
Object Definition in Z • In the Z notation, there are several ways of defining an object: • declarations, • abbreviations, • axioms, • free types and • schemas.
Object Definition in Z - Declarations • The simplest way to define an object • If the object is a given set, or basic type: • introduces a new basic type called Type • If the object is a variable: • introduces a new variable x, drawn from the set A • If this set is not Z, it must be defined elsewhere in the specification
Object Definition in Z - Abbreviations • Introduces a new name for term: • Generic abbreviations:
Object Definition in Z - Axiomatic definitions • where the predicate expresses the constraints upon the object or objects introduced in the declaration. • Axiomatic definition of the set of natural numbers:
Object Definition in Z - Axiomatic definitions Generic definitions: Exp. Generic definition to define the subset symbol:
Relations • In a formal specification, it is often necessary to describe relationships between objects • Binary Relations: • Elements of relations: • If R is a relation of type , and A is any subset of X , then denotes the domain restriction of R to A:
Relations (Cont.) • If B is any subset of Y , then denotes the range restriction of R to B: • domain subtraction of A from R • range subtraction of B from R:
Relations (Cont.) • If R is a relation of type , and A is any subset of X , then denotes the relational image of A under R: • Relational inverse: • Relational composition:
Functions • Partial functions: • Total functions:
Functions (Cont.) • Function description using Lambda notation:
Functions (Cont.) • Overriding: • Set of all finite functions from A to B:
Functions (Cont.) • Size/Cardinality:
Sequences • If X is a set, then the set of all finite sequences of objects from X is defined by the following abbreviation:
Sequences(Cont.) Filter:
Functions on sequences Usingrecursionprinciple: Exp.
Structural induction Construct a proof that filter is distributive using structural induction: Inductive hypothesis: Induction:
Proof Lemma1 & Lemma2 using the following rules: Lemma1 Lemma2
Object Definition in Z • In the Z notation, there are several ways of defining an object: • declarations, • abbreviations, • axioms, • free types and • schemas.
FreeTypes Exp. 1: Exp. 2: recursivetypedefinition Exp. 3:
FreeTypes (Cont.) axiomaticdefinition: constants constructorfunctions • Any subset of T that contains all of the constants and is closed under the constructors must be the whole of T. • A set S is closed under d and E if the image of E.S = T. under d is within S itself.
Object Definition in Z • In the Z notation, there are several ways of defining an object: • declarations, • abbreviations, • axioms, • free types and • schemas.
Schemas Exp: