1 / 45

Lecture 10 Z MDA for Graphical User Interface

Lecture 10 Z MDA for Graphical User Interface. Review Lecture 9 Proposition, First Order Logic. Roadmap for Today Z background Z language constructs and syntax Z schema. Z Background. History Invented at 70s, program research group @ oxford, J. R . Abrial ,

ellis
Download Presentation

Lecture 10 Z MDA for Graphical User Interface

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. Lecture 10ZMDA for Graphical User Interface

  2. Review Lecture 9 Proposition, First Order Logic Roadmap for Today • Z background • Z language constructs and syntax • Z schema

  3. Z Background • History • Invented at 70s, program research group @ oxford, J. R. Abrial, • 2002, standardized by ISO • Why Z • Easy to find faults • High school math • Precise • A list of related tools: Type Checker, Z deduction system • Community Z Tools (CZT) project • Tools for developing and checking Z specifications in Microsoft word • Latex style tools

  4. Types and Sets

  5. Basic Vocabulary of Z • Z: typed first-order predicate logic • Three basic elements • Sets, Set Operations, Logic • Sets may be enumerated: { red, yellow, green }

  6. Z Types and Sets • Every Zexpression (arithmetic, set) has a type that can be determined • A type is either • a given set, or • a compound type built up from simpler types using a type constructor A set is not necessarily a type, but a type is a set • There are a few predefined sets: Z , N , N1 • All sets must contain elements of the same type • The only predefined type is Z • N is a set, but all of its elements are members of Z

  7. Predicates, Equations • There is no Boolean type in Z: • Predicates are not expressions, they are assertions about values. • Equations are not expressions, they are predicates that equate to values.

  8. Built in Operators

  9. Set

  10. Set

  11. Set

  12. Set

  13. Types

  14. Compound Type

  15. Possible Set Definitions Note All types are disjoint (not for sets that are used as types) All terms have a unique type

  16. Defining types and abbreviations [CHAR] introduce a basic data type by enclosing its name in square brackets COLOR ::= red | green | blue introduce a free type by enumerating its elements TEXT == seq CHAR introduce an abbreviation by using “==“ Convention: upcase

  17. Normalization • Normalization: stating the types (not just the sets) of each variable SMALL = { 1, 2, 3 } BIG = { 100, 200, 300} s, b: Z s: SMALL; b: BIG s  SMALL b  BIG un-normalized (declaration with sets) normalized

  18. Normalization

  19. Expressions • Sets • union: { 1, 2, 3}  {3, 4} = { 1, 2, 3, 4} • difference: {1, 2, 3, 4} \ { 2, 3} = { 1, 4} • intersection: {1, 2, 3, 4}  {2, 3} = { 2, 3} • cardinality: # { red, white, blue} = 3 • Arithmetic • mathematical tool-kit contains standard operators: +, -, * • Integer division only 13 div 5 = 2 13 mod 5 = 3

  20. Variables, Special Sets: Relations, Sequences, Function

  21. Variables

  22. Declarations and Variables • Variables are declared as being of a type or set: i: Z color: { red, yellow, green } • Variables may be constrained when defined: size: N size > 640

  23. Axiomatic Definitions

  24. Axiomatic definitions Declarations above the line iroot: N → N • a: N• iroot(a)*iroot(a)  a < (iroot(a)+1) * (iroot(a)+1) Z paragraph Predicates below the line

  25. Tuples and Records • Cartesian product types (or cross product types) can be used to describe tuples: DAY == 1..31; MONTH == 1..12; YEAR == Z DATE == DAY × MONTH × YEAR landing, birth: DATE landing = (20, 7, 1969) birth = (7, 4, 1949)

  26. Relations • A set of tuples defines a relation [NAME] ID == N DEPT ::= admin | man | rsrch EMPLOYEE == ID × NAME × DEPT Employee: P EMPLOYEE Employee = { ( 111, Larry, admin ) ( 222, Curly, man ) ( 333, Mo, rsrch ) }

  27. Binary Relations • A set of 2-tuples (pairs) defines a binary relation [NAME] PHONE == 0..9999 phone: NAME  PHONE phone = { groucho | 1234, harpo | 2345, chico | 3456 }

  28. Domain and Range • Recall this binary relation: phone = { groucho | 1234, harpo | 2345, chico | 3456 } domphone = { groucho, harpo, chico } ran phone = { 1234, 2345, 3456 }

  29. Operators for Relations • Restriction { groucho, harpo } <| phone = { groucho | 1234, harpo | 2345 } phone |> (3000..3999) = { chico | 3456 } • Overriding phone + { groucho | 5555 } = { groucho | 5555, harpo | 2345, chico | 3456 } • Inverse phone ~ = { 5555 |groucho, 2345 |harpo, 3456 | chico }

  30. Sequences • sequences are functions, which are relations, which are sets week day == {1 |Monday, 2 | Tuesday, 3 |Wednesday, 4 | Thursday, 5 |Friday} weekday == <Monday, Tuesday, Wednesday, Thursday, Friday>

  31. Sequence operations head: head (<Good, Fair, Poor>) = Good last: last (<Good, Fair, Poor>) = Poor tail: tail (<Good, Fair, Poor>) = <Fair,Poor> front: front (<Good, Fair, Poor>) = <Good, Fair> Concatenation: week == <Sunday> weekday <Saturday>

  32. Functions

  33. Lambda Expression Function isqr isqr == {i: Z• i i*i} (def using set) isqr == ( i: Z • i*i ) (lambda expression) isqr: Z → N  i: Z •isqr i = i*i

  34. Z Schema

  35. Z Schema • The Z schema is a 2-dimensional graphical notation for describing: – state spaces – operations • Definition: A vertical-form schema is either of the form

  36. Z Schema Or • In the latter case, the predicate part is assumed to be ‘true’.

  37. Z Schema • The declarations part of the schema will contain: – a list of variable declarations; and – references to other schemas (this is called schema inclusion) • Variable declarations have the usual form: x1; x2; : : : ; xn : T; • The predicate part of a schema contains a list of predicates, separated either by semi-colons or new lines.

  38. Schema

  39. State and Operation Schema States A state is a variable assignment A schema describes a set of states Operations To describe an operation, a schema must describe pairs of states (pre/post) Variables are decorated with ‘ to refer to their value in the post state

  40. State Schema • The value of tel will be a partial function from NAME to PHONE, i.e., it will associate names with phone numbers

  41. Operation Schemas • In specifying a system operation, we must consider: • the objects that are known to remain unchanged by the operation • the objects that may be altered by the operation • pre-conditions • post-conditions

  42. Example: Phonebook Lookup Analyze the problem: • Accesses the PhoneBookschema • It does not change it • Takes a single ‘input’ —a name • Produces a single output —a phone number • Pre-condition: the name is known to the database.

  43. Example: Phonebook Lookup

  44. To Do • Proposal (due 10/10 4:00pm) • Reading assignment - Wed 10/12 in class • Alloy?

  45. Wild & Crazy Ideas Career Paths of Software Engineers? Where will we be in the future? Can I code at 60?

More Related