SE381-05 (Week 3, lecture 1)
Logistics
Reminder - Homework 1 due tomorrow
Submit via WebCT if possible
Questions?
Introduction to Z
Faculty schedule system example (FacSched01)
System maintains information on teaching assignments
What can you figure out from reading it?
[Section 1]
Variable declarations
Funny looking "P" - like an array or set?
Course described as "within" a set
Idea that we're keeping track of professors and sections they teach
Wierd arrows in state schema
[Section 2]
Formal way -- e.g., add professor to list with set union
Cardinality of relationships -- e.g., professors to sections
Funny "P" notation
Funny triangles in "delete professor"
Differences between ":" and "::=", etc.
"dom" and "ran"?
Z types
Given sets (basic types)
Example: PROF, COURSE, SECTION
Free types
Sets (that are also types) defined by enumerating values
Similar to an "enum" in C++ (not in Java)
Example: academic departments
More advanced kinds of free type definitions not covered here
Z operators
Arithmetic operators (text, pages 72 & 301)
Set operators (text, pages 73 & 300)
Also see Z "reference card"
Axiomatic descriptions
Used to define "global" variables (and functions)
Components
Above the line -- variable name : type (or set)
Declaration note . . .
Variable value is drawn from set of values (maybe a type)
mycourse : COURSE
Be careful when "set" expression is complex
Below the line -- predicates
What is a predicate, anyway?
What if there is more than one predicate?
Implicitly, they are ANDed together logically
What if there are no predicates (no line)?
Default predicate = "true"
Normalized declarations
Simple declarations are "variable : type"
Possibly followed by predicates "below the line"
Meaning
Variable's type is "type"
Variable's value is drawn from the full set represented by "type"
Declarations can also be "variable : set" (also with predicates)
If "set" is not a type, then . . .
Variable's type is the type of "set"
There is an implicit predicate that the variable's value is in "set"
Normalized declarations make explicit the implicit type and predicates
Declaration notes
A particular "global" variable has only one value throughout a Z specification
Unlike a C++ data object, which can take on different values at different times
There is no time in Z !! . . .
Well, there are ways to represent "before" and "after" states . . .
In Z notation itself, the ordering of declarations does not matter . . .
. . . but in Z/EVES, variables need to be defined before use, and . . .
. . . ordering of declarations and other elements may affect how the theorem prover works
Schemas
Z mechanism for encapsulating "state" (and related operations)
What does "state" (and "state variables") mean, anyway?
Notation looks something like an axiomatic description
Above the line: declarations
Below the line: predicates
Additional features
Top and bottom lines enclosing the schema content
Schema name in the top line
Types of schemas
State schema
Declarations: state variables for the schema
Predicates: invariants (what's an invariant?)
To be continued . . .