1 / 13

Intro to Z Language

Intro to Z Language. Z is a “specification” language based on typed sets , relations , and functions to express: What are the functionalities of the system And what the desired results are But without stating the “how” part.

doris
Télécharger la présentation

Intro to Z Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro to Z Language • Z is a “specification” language based on typed sets, relations, and functions to express: • What are the functionalities of the system • And what the desired results are • But without stating the “how” part. • Thus Z is a declarativelanguage - - meaning that it is non-procedural (not like Java or C) • Z “notation” developed at the Programming Research Group at Oxford University for recording, in precise way, some of the many decisions that are made in the course of software development.

  2. Z Alphabet and Lexical elements • Z has both forms: • textand • graphical • Z identifiers are constructed from letters, digits, and the “_” character. • Upper and lower case are distinct • No length restriction (cool but nuts!) • First character must be a letter; it may also be a special symbol (state change) or (no state change). • May end with special characters of ?, !, ' .

  3. Z-Schema • A schema is a structuring mechanism, a diagrammatic presentation, that allows the specification of: a) data b) operations that access that data • The Z- schema may be defined in two ways: • graphical form • text form

  4. Z- Schema Forms • The Graphical form: schema name declarative or “signature” part predicate part • The Text form : schema name = [ declarative part I predicate part ]

  5. Z-Schema “Parts” • The declarative or the “signature” part: • Introduces the identifiers (or variables) • And assigns them the set type • Each line statement is “assumed” to be terminated with ; • The predicate part refers to the identifiers in the declaration part or some global identifier in other schemas • The predicates, when there is more than one, are logical “conjunctions”, /\, of the predicates.

  6. Examples of Schemas Graphical form: - Schema is named B_Team B_Team Member : [students] Team : IP students • Member is of type “students” • (which is defined elsewhere) • Team is a subset (type) of the • power set of students # (Team) < 11 - Cardinality of Team is < 11 Text form: B_Team = [ Member: students; Team: IP students I # (Team) < 11 ]

  7. Z types and declarations • Z is “strongly” typed --- that is , every identifier must be declared. • Z has 3 “types” : • built-in : Z (integers), N (natural numbers), N1 ( positive integers) • basic: application dependent set (assumed to be pre-defined) • free type : enumerations • ( note that real numbers and characters are not part of built-in) • Basic type may be written in bracket, [ ] : • [ students ] , [ employees ] , [ books ] • Or [ students, employees, books ] • but we often just use these and not clearly (or forget to) define them ! • Freetype may be written as enumerations: • Students ::= { William I Shilpa I Harish I Carolyn I Amed I Joel } • and then identifiers x and y may be declared: • x , y : Students • Z allows one to “build up” the data types for declarations and usage.

  8. Global constant and variable • Global constant is declared with the “==“ symbol: minimum == 0 • Global “variable” that has some constant associated with it may be declared via an “axiomatic description” : age : N age < 150 The global “variable”, age, is really some “constant” that has a value less than 150 and age may be used globally. Axiomatic description is like the schema without the top and bottom lines.

  9. More Sophisticated Types • The variables in the signature may introduce any set theoretic type, including any higher order functions. The symbols used to depict relations and different types of functions are : • a relation • a partial function • a total function • a partial injection • a total injection • a partial surjection • a total surjection • a bijection

  10. A Z simple schema example • The schema is titled Library Books and describes the book status Library_Books Library_Books -books, in_lib, and checked_out are of type, power set of Books; -lent_to is of the type, partial function from Books to Person; -on_shelf is a partial function from Books to Shelves books , in_lib, checked_out : IP Books lent_to : Books Person on_shelf : Books Shelves In_lib = dom (on_shelf) Checked_out = dom (lent_to) books = in_lib U checked_out • -in_lib is the domain of on_shelf; • -checked_out is the domain of • of lent_to; • books is the sum of in_lib • and checked_out

  11. Z- Schema inclusion • A feature of Z-schema is that it allows the incremental and independent development of schema(s) • There is a mechanism for one schema to refer to another schema via schema inclusion. • Schema inclusion is accomplished by stating the name of the referred to schema in the signature part of the referring schema. • The result of schema inclusion is that : • the refered to schema’s signature portion is included into the signature portion of the referring schema, and • the predicate portion of the referred to schema is logically conjoined with the predicates of the referring schema The schema inclusion is a bit like the “inheritance” or “include” functions

  12. Schema Inclusion Example Temp_Users SPSU_Users ::= Students I Faculty I Administrators temp_u, users : IP SPSU_Users n_of_days : N1 exp_days : users n_of_days Note : exp_days is a total function temp_u users temp_u = { u: users I ran(exp_days) < 30 u } Users Note :Temp_Users is included in the Users schema. So we can use all the terms from Temp_Users Temp_Users reg_u : IP SPSU_Users reg_u = { u : users I ran(exp_days) >= 30 u } users = temp_u U reg_u

  13. GeneralGuidelinefor Z-Schema Specification • Static portion: • The states (or variables and constants) the system can have. • Invariant characteristics • “Dynamic” portion: • The functions (operations) that the system performs • The relationships among the inputs, outputs and other variables • The change of states in terms of “pre” and “post” conditions

More Related