Top Banner
1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z - Schema Calculus
23

1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

1

Formal Specifications for Complex Systems (236368)

Tutorial #2

Z introduction and notation (contd.);

Birthday book example (Chapter 1 in the book);

Z - Schema Calculus

Page 2: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 2

סימונים

Page 3: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 3

פנקס ימי הולדת

:אנו רוצים מערכת ש

תתעד ימי הולדת של אנשים•

תוכל לתת תזכורות כאשר התאריך המיועד יגיע •

Page 4: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 4

העולם של המערכת

נתונות לנו שתי קבוצות: אחת של שמות ואחת של תאריכי לידה.

כרגע לא מעניין אותנו מה הפורמט של כל אחד מהפריטים (שם , תאריך .לידה)

Basic sets: [ NAME , DATE ]

Page 5: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 5

The state space

┌─── BirthdayBook ────────

├────────────────────

└────────────────────

Page 6: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 6

לדוגמאknown = { John, Mike, Susan }

birthday = { John ↦ 25-Mar,Mike ↦ 20-Dec,Susan ↦ 20-Dec }

Page 7: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 7

הבחנות

מספר הרשומות במערכת לא מוגבל•

אין הגדרה לסדר של הרשומות•

אין הגדרה לפורמט של שם ותאריך•

לכל אדם במערכת יש יום הולדת בודד (למה ?)•

שני אנשים יכולים לחלוק את אותו תאריך יום הולדת•

יתכן וחלק מהאנשים אינם נמצאים בספר ימי ההולדת שלנו •(למה ?)

Page 8: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 8

הוספת יום הולדת חדש

┌─── AddBirthday ───────────────

├───────────────────────────

└───────────────────────────

Page 9: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 9

(המשך)הוספת יום הולדת חדש

known’ = known { name? }הינו מצפים כי לאחר הפעולה יתקיים:

למעשה ניתן להוכיח זאת.

domלטובת ההוכחה נשתמש בשני חוקים הישימים ל

dom( f g ) = ( dom f ) ( dom g )

dom { a ↦ b } = { a }

Page 10: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 10

(המשך)הוספת יום הולדת חדש

:known’ = known { name? }להלן ההוכחה ש

Page 11: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 11

חיפושמציאת יום ההולדת של אדם מסוים

┌─── FindBirthday ───────────────

├───────────────────────────

└───────────────────────────

Page 12: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 12

הגדרת תזכורת(מציאת כל האנשים שיום הולדתם חל ביום

מסויים)

┌─── Remind ──────────────────

├───────────────────────────

└───────────────────────────

Page 13: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 13

המצב ההתחלתי

┌─── InitBirthdayBook ──────

├────────────────────

└────────────────────

┌─── InitBirthdayBook ──────

├────────────────────

└────────────────────

טיפול בתור מצב

טיפול בתור פעולה

Page 14: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 14

Zed:תחשיב סכמות ,

היום:שינוי שמות•הסתרת משתנים•נרמול סכמות•

בשיעור הבא:הרכבת סכמות• של סכמת פעולהpreחישוב •צמצום פרדיקטים עם כמתים•

Page 15: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 15

הנה התוצאה של S[a/x, b/y]הסכמה •החלפת

.b ב-y, וכל מופע של a ב-x כל מופע של

,S[a/x, b/yיתכנו "התנגשויות", למשל: •a/z] ,

או אם מחליפים שם בשם קיים.

שמות מתנגשים חייבים להיות מאותו •טיפוס.

)renamingשינוי שמות (

Page 16: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 16

)1שינוי שמות (דוגמא

┌─── Sum ────

x?, y?, z!: ℕ

├──────────

z! = x? + y?└───────────

┌─── Sum ────

├──────────

└───────────

Sum[a?/x?]

Page 17: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 17

)2שינוי שמות (דוגמא

┌─── Sum ────

x?, y?, z!: ℕ

├──────────

z! = x? + y?└───────────

┌─── Sum ────

├──────────

└───────────

Sum[x?/y?]

Page 18: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 18

)3שינוי שמות (דוגמא

┌─── Sum ────

x?, y?, z!: ℕ

├──────────

z! = x? + y?└───────────

┌─── Sum ────

├──────────

└───────────

Sum[a?/x?, a?/y?]

Page 19: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 19

הסתרת משתנים

•S\(x,y,z)-הנה הסכמה שמתקבלת מ S על ידי הסתרת המשתנים x, y, z.

הסתרת משתנים מתבצעת על ידי העברתם מהחלק של ההכרזות (החלק •העליון בסכמה) לחלק של התנאים (החלק התחתון בסכמה).

" ). לכל משתנה שמועבר לחלק של התנאים נוסיף את הכמת קיים ( "•

Page 20: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 20

)1הסתרת משתנים (דוגמא

┌─── Power ──── y! :ℕ z? : 1..10 ├────────── y! = z? * z? y! < 5└───────────

zאנו רוצים להחביא את

┌─── Power ────

├──────────

└───────────

Power\(z?)

Page 21: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 21

נרמול סכמות

יש לטפל במשתנים שתחום ההגדרה שלהם הוא תת תחום.•

בעצם הגדרת המשתנה יש פרדיקט שמגביל את הערכים אותם יכול לקבל •המשתנה

כל משתנה כנ"ל יש להגדיר מחדש כשייך לתחום המקסימאלי שלו.•

יש להוסיף פרדיקט המגביל את ערכי המשתנה לתת התחום המקורי שלו.•

")הנרמול בעל חשיבות ממעלה ראשונה בפעולות שלילה ("•

Page 22: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 22

)1נרמול סכמות (דוגמא

┌─── Example ────

├──────────

└───────────

┌─── Example ──── a? :ℕ y! :ℤ

├──────────

y! = a?└───────────

Page 23: 1 Formal Specifications for Complex Systems (236368) Tutorial #2 Z introduction and notation (contd.); Birthday book example (Chapter 1 in the book); Z.

236368 Emilia Katz, Shahar Dag 23

)2נרמול סכמות (דוגמא

┌─── Example ──── ├──────────

└───────────

┌─── Example ──── a? : 1..10 y! :ℤ

├──────────

y! = a?└───────────