Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ )...
-
Upload
kelley-williamson -
Category
Documents
-
view
219 -
download
1
Transcript of Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ )...
![Page 1: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/1.jpg)
Logic Specification and Z Schema
3K04McMaster
![Page 2: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/2.jpg)
Basic Logic Operators
• Logical negation ( ¬ )• Logical conjunction ( Λ or & )• Logical disjunction ( V or || )• Logical implication ( → )• Logical equality ( = or ↔ )
![Page 3: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/3.jpg)
Logic Negation
• NOT p (also written as ¬p)
![Page 4: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/4.jpg)
Logic Conjunction
• p AND q (also written as p q∧ , p & q, or p·q)
![Page 5: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/5.jpg)
Logic Disjunction
• p OR q (also written as p q∨ or p + q)
![Page 6: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/6.jpg)
Logic Implication
• p implies q (also written as p → q, not p or q)
![Page 7: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/7.jpg)
Logic Equality
• p EQ q (also written as p = q, p ↔ q, or p ≡ q)
![Page 8: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/8.jpg)
First-order logic
• While propositional logic deals with simple declarative propositions, first-order logic additionally covers predicates and quantification.
• Each interpretation of first-order logic includes a domain of discourse over which the quantifiers range.
![Page 9: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/9.jpg)
Predicate• A predicate resembles a function that returns either True
or False.
• Consider the following sentences: "Socrates is a philosopher", "Plato is a philosopher".
• In propositional logic these are treated as two unrelated propositions, denoted for example by p and q.
• In first-order logic, however, the sentences can be expressed in a more parallel manner using the predicate Phil(a), which asserts that the object represented by a is a philosopher.
![Page 10: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/10.jpg)
Quantifier
• - universal quantifier; - existential quantifier
• Let Phil(a) assert a is a philosopher and let Schol(a) assert that a is a scholar
• For every a, if a is a philosopher then a is a scholar.
• If a is a philosopher then a is a scholar.
![Page 11: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/11.jpg)
Z notation
• The Z notation, is a formal specification language used for describing and modeling computing systems.
• It is targeted at the clear specification of computer programs and the formulation of proofs about the intended program behavior.
![Page 12: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/12.jpg)
Z Schemas
• The Z schema is a graphical notation for describing – State spaces– operations
![Page 13: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/13.jpg)
• The declarations part of the schema will contains:– A list of variable declarations– References to other schemas (schema inclusion)
• The predicate part of a schema contains a list of predicates, separated either by semi-colons or new lines.
![Page 14: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/14.jpg)
State Space Schemas
• Here is an example state-space schema, representing part of a system that records details about the phone numbers of staff.
Assume that NAME is a set of names, and PHONE is a set of phone numbers.
![Page 15: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/15.jpg)
Operation Schemas
• In specifying a system operation, we must consider:– The objects that are accessed by the operation;– The pre-conditions of the operation, i.e., the
things that must be true for the operation to succeed;
– The post-conditions, i.e., the things that will be true after the operation, if the pre-condition was satisfied before the operation.
![Page 16: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/16.jpg)
• Consider the ‘lookup’ operation: input a name, output a phone number.– This operation accesses the PhoneBook schema;– It does not change it;– It takes a single ‘input’, and produces a single
output;– Pre-condition: the name is known to the database.
![Page 17: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/17.jpg)
• This illustrates the following Z conventions:– Placing the name of the schema in the declaration
part ‘includes’ that schema;– ‘input’ variable names are terminated by a
question mark;– ‘output’ variables are terminated by an
exclamation mark;– The (Xi) symbol means that the PhoneBook
schema is not changed; if we write a Δ (delta) instead, it would mean that the PhoneBook schema did change.
![Page 18: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/18.jpg)
• Add a name/phone pair to the phone book.
• Appending a ‘ to a variable means “the variable after the operation is performed”.
![Page 19: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/19.jpg)
Example: Video Rental Shop
![Page 20: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/20.jpg)
Returning a video
![Page 21: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/21.jpg)
Removal of a video from the stock
![Page 22: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/22.jpg)
Find a video
![Page 23: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/23.jpg)
List all videos
![Page 24: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/24.jpg)
Example: Sale Theater tickets
![Page 25: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/25.jpg)
• Informal specification– Theater: Tickets for the first night are only sold to
friends
• Specification in Z
![Page 26: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/26.jpg)
and
![Page 27: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/27.jpg)
and
are the same as
![Page 28: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/28.jpg)
Selling tickets
![Page 29: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/29.jpg)
Then
is a schema that reports successful ticket sale.
![Page 30: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/30.jpg)
Selling tickets, but only to friends if first night performance
![Page 31: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/31.jpg)
![Page 32: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/32.jpg)
Composition of Operation Schemas
is equivalent to
![Page 33: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/33.jpg)
Example: Order Invoicing
![Page 34: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/34.jpg)
Order Invoices
![Page 35: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/35.jpg)
State
![Page 36: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/36.jpg)
![Page 37: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/37.jpg)
![Page 38: Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.](https://reader035.fdocument.pub/reader035/viewer/2022062423/56649e7a5503460f94b7b50b/html5/thumbnails/38.jpg)
A total operation for ordering