Z A Formal Specifications Language Tim Racz CS

  • Slides: 15
Download presentation
Z A Formal Specifications Language Tim Racz CS 5667 November 21, 2003

Z A Formal Specifications Language Tim Racz CS 5667 November 21, 2003

Overview • Recap Z • Revisit basic set theory and first-order logic • Relations

Overview • Recap Z • Revisit basic set theory and first-order logic • Relations and Schemas • Functions • A brief discussion of proof.

Z And Formal Specifications • Used to mathematically specify and design parts of a

Z And Formal Specifications • Used to mathematically specify and design parts of a system (model-theoretic). • Also used to prove correctness (prooftheoretic). • Cannot prove correct implementation. • Z and software engineering

First-Order Logic • The study of inference. – What follows from what – What

First-Order Logic • The study of inference. – What follows from what – What can be deduced from a given set of assumptions. • Inferences and deductions are expressed in the form of arguments.

First-Order Logic • Z uses propositional calculus – Logic in which every proposition is

First-Order Logic • Z uses propositional calculus – Logic in which every proposition is either true or false. – Propositions cannot be both true and false. • Example propositions – 2 + 7 = 9 (true) – 3 > 9 (false) – The moon is made of green cheese. (false) – Emacs > Vim (true)

Predicate Calculus • Introduces types – x is a natural number (x: N) –

Predicate Calculus • Introduces types – x is a natural number (x: N) – y is a European Country (y: Europe) • Quantifiers – Restricted universal quantifier ( ) – Restricted existential quantifier ( ) – Unique existential quantifier ( 1)

Set Theory • Ways of making sets – Enumeration – Comprehension • Set Notation

Set Theory • Ways of making sets – Enumeration – Comprehension • Set Notation – An element of ( ) – Subset ( ) – Union ( ) – Intersection ( )

Relations And Schemas • A relation can be thought of as a set of

Relations And Schemas • A relation can be thought of as a set of ordered pairs. – Cross product – Notation – Domain and range • A schema groups relevant information belonging to a state description.

Relations And Schemas • Schemas are used for… – Specifying states – Specifying state

Relations And Schemas • Schemas are used for… – Specifying states – Specifying state transitions – Works like pre/postconditions • Schema notation – Decoration – Operations – Some notation can be redefined

Functions • Functions map an element from one type to another. • A function

Functions • Functions map an element from one type to another. • A function is a relation. • Types of functions – Partial – Total

Formal Proof • The proof-theoretic part of Z. • Notation – Syntactic sequent •

Formal Proof • The proof-theoretic part of Z. • Notation – Syntactic sequent • Premises • Conclusion – Comma operator

Inference Rules • Relate one or more input sequents to an output sequent. •

Inference Rules • Relate one or more input sequents to an output sequent. • Some specific rules – Introduction – Conjunction – Disjunction – Others

Applying Proofs • A proof-tree – Each leaf has form –A A • An

Applying Proofs • A proof-tree – Each leaf has form –A A • An Example – The sequent: P Λ Q P Q – Using the proof-tree.

Conclusions • Z can aid in improved quality and productivity of specification in design.

Conclusions • Z can aid in improved quality and productivity of specification in design. • Developers with some knowledge of logic and set theory can begin using Z. • Applying proofs can improve quality.

Homework • Write a Z schema to show you would add an instructor to

Homework • Write a Z schema to show you would add an instructor to the classes table in our database.