1 Formal Specifications for Complex Systems (236368) Tutorial #1 Course site : T.A. :Emilia Katz Reception hours: Wednesday 15:30 – 16:30 Taub 641
Emilia Katz, Shahar Dag2 General Information The course is about: Formally expressing requirements -Statements, not proofs Homework submission: In pairs -From previous years experience, we recommend both partners to participate in every homework solution, in order to succeed in the exam -Formal and exact writing of the solutions is required -List all your assumptions (everything you had to assume for your solution) -There might be one “wet” homework No midterm exam. Recommendation: solve midterm exams from previous years before the final exam
Emilia Katz, Shahar Dag3 Today: Logic – reminder Zed – notation, conventions, examples
Emilia Katz, Shahar Dag4 Reminder – FOL See reminder on Logic and Set Theory on course web-page Now: a couple of examples
Emilia Katz, Shahar Dag5 Example 1 Define the predicate prime(x) using logic and the predicate integer(x):
Emilia Katz, Shahar Dag6 Example 2 יש להגדיר בעזרת לוגיקה וסימוני קבוצות, את קבוצת כל המספרים הראשוניים שאינם גדולים מ x primes_upto(x) איך פותרים את אותה הבעיה בעזרת לוגיקה בלבד?
Emilia Katz, Shahar Dag7 דוגמאות – שעשועי לוגיקה הגדר בעזרת לוגיקה את המשפט: "לכל אדם יש אב" בצורה דומה נגדיר בעזרת לוגיקה את המשפט: "לכל אדם יש אם אנושית" איך נגדיר כי לכל אדם אב ואם אנושיים הנשואים זה לזו.
Emilia Katz, Shahar Dag8 Zed Notation נראה היום: מספרים Numbers)) פעולות לוגיות (Logic) פונקציות (Functions) פעולות על קבוצות (Sets & expressions) יחסים (Relations) נראה בהמשך: סכמות (Schema notation) סימונים (Conventions) (ראה תקציר של Zed באתר הקורס)
Emilia Katz, Shahar Dag9 מספרים מספרים שלמים, טבעיים וטבעיים ללא אפס פעולות חשבון כמו שאנחנו מכירים אותם יחסים בין מספרים פונקצית העוקב
Emilia Katz, Shahar Dag10 פעולות מוגדרות מראש suc : ℕ → ℕsuc(n) = n+1{ (1, 2) (2 3), (3, 4) …. } suc k (n) = n+k pred : ℕ ↛ ℕpred(n) = n-1{ (1, 0) (2, 1) (3, 2) …. } pred k (n) = n-k למה פנק' חלקית?
Emilia Katz, Shahar Dag11 פעולות לוגיות - סימון לכל x מסוג T הפרדיקט p מתקיים קיים x מסוג T המקיים את הפרדיקט p קיים בדיוק x אחד מסוג T המקיים את הפרדיקט p
Emilia Katz, Shahar Dag12 פונקציות dom(f) A dom(f) = A dom(f) A, One-to-one dom(f) = A, One-to-one dom(f) A, ran(f)=B dom(f) = A, ran(f)=B
Emilia Katz, Shahar Dag13 פונקציות - דוגמאות (1) A = {a, b, c, d, e} B = {1, 2, 3, 4, 5} {(a 1) (b 2) (c 2)} (2) A = {a, b, c} B = {1, 2, 3, 4, 5} {(a 1) (b 2) (c 2)} (3) A = {a, b, c, d, e} B = {1, 2, 3, 4, 5} {(a 1) (b 2) (c 3)} (4) A = {a, b, c} B = {1, 2, 3, 4, 5} {(a 1) (b 2) (c 3)} (5) A = {a, b, c, d, e} B = {1, 2, 3} {(a 1) (b 2) (c 3)} (6) A = {a, b, c} B = {1, 2} {(a 1) (b 2) (c 2)}
Emilia Katz, Shahar Dag14 פעולות על קבוצות
Emilia Katz, Shahar Dag15 יחסים A={1, 2, 3} B={a, b, c} R={ (1, a) (1, b) (3,c) } Not necessarily a function R;R; … ;R (n times)
Emilia Katz, Shahar Dag16 יחסים (המשך) X = {1, 2, 3, 4, 5} Y = {a, b, c, d, e} Z = {א, ב, ג, ד} Q = {(1, a)(2, b)(3, c)(4, d)(5, e)} R = {(a, א)(b, ב)(c, ג)(d, ד)} What does this mean? Q;R = ?
Emilia Katz, Shahar Dag17 יחסים (המשך) הסבר לא מדויק בסימון: R = {(1, a)(2, b)(3, c)(4, d)(5, e)} A = {1, 2, 3, 6} result is: A = {1, 2, 3} result is: A = {b, c, d} result is:
Emilia Katz, Shahar Dag18 סדרות סידרה היא למעשה פונקציה שהתחום שלה הוא תת קבוצה רציפה { 1.. N } של המספרים הטבעיים. seq(A) ≜ { f : N ↛ A | dom f = 1.. #f } (שימו לב שכאן אנו מגדירים אוסף של סדרות בהתאם לכל פונקציות המיפוי האפשריות) למשל הוא בעצם הפונקציה { 1↦m, 2 ↦i, 3↦f, 4↦r, 5↦a, 6↦t } ( או ברישום חלופי: { (1, m) (2, i) (3, f) (4, r) (5, a) (6, t) }) אם נסמן סידרה זו ב S אזי S(1) יחזיר את האות m, S(2) יחזיר את האות i וכך הלאה.
Emilia Katz, Shahar Dag19 סדרות (המשך) חשוב: מאפשר מימוש מערכים מערך חד מימדי s(i) מערך דו מימדי s(i)(j) חשוב: tail ו front מחזירים סדרות ועל כן יש לשמור על תקינות ה domain שלהן (ב tail יש לתקן את ה "אינדקס")
Emilia Katz, Shahar Dag20 פעולות על סדרות - דוגמאות נגדיר את הסדרות הבאות: S =, T = אזי: S(3) = head S = tail S = last S = front S = S ⌢ T =