78
Modal Logics תתתתתתת תתתתתתתLectures of Doron Peled Bar Ilan University

Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

  • View
    215

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Modal Logicsלוגיקות מודליות

Lectures of Doron PeledBar Ilan University

Page 2: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

לוגיקות מודליות

עד כה דנו בלוגיקה סטטית: תכונה התקיימהאו לא התקיימה.

נרצה לדון בלוגיקות דינמיות: קיום התכונהיכול להשתנות, למשל בזמן.

:עבור נכונות של שימוש נרחב ללוגיקות כאלו בבינה Multiagent systemsתכניות,

מלכותית, בכלכלה וכולי.

Page 3: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

דוגמאות

:ראש הממשלה הוא כעת לוגיקה של זמן זה לא היה נכון, ויהיה בעבר, אהוד אולמרט

שבו זה לא יהיה נכון.עתידגם לוגיקה של מקום: בבאר שבע חם ויבש, אבל

באלסקה קר ורטוב.( לוגיקה של ידעknowledge:) רובוט A

45המשחק כדורגל יודע שהכדור נמצא ב אינו יודע איפה הכדור Bמעלות ימינה, רובוט

)לא רואה אותו(.

Page 4: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

שימושים

.הוכחת נכונות של מערכות חומרה ותכנהלמערכות כאלו יש התנהגות המשנה את

אחר כך x=1המצב שלהם בזמן. בתחילה רק עולה, אחר כך הוא מגיע xהערך של

ואחר כך יורד.100לערך הוכחת הנכונות תשתמש בטענות לוגיות המאפשרות לבטא את השינוי של המצב

בזמן.

Page 5: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

שימושים נוספים

לוגיקות של ידע

העובדה שידע מסויים נתון או אינו נתון במערכת יכול לסייע בהבנת ותכנון המערכת. רובוטים למשל,

או לא "לדעת" נתונים מסוימים. יכולים "לדעת"במיוחד אם אותם נתונים היו או לא היו ברי הסקה מהנתונים שקיבלו )דרך חיישנים שונים, או כתנאי

התחלה להפעלתם(.

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

בתחרות ומנצלים חוסר ידע מסויים(.

Page 6: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

עולמות שונים לוגיקה מודלית:

p,q

p

יש לנו עולמות שונים, בכל עולם מתקימות תכונות שונות )פסוקיות או מסדר ראשון(.

יכולים ליצג קיום של מוצר מסוים.p, qלמשל,

במקום לציין את השלילה של תכונה,

פשוט לא נציין אותה. כלומר הצומת הריקה

תקיים ¬p, ¬q

Page 7: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

עולמות שונים לוגיקה מודלית:

p,q

p

יש גם קשר בין העולמות שיסומן על ידי קשתות.

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

למצב.

קשת בין צומת אחת לשניה יכולה לציין שהרובוט המתואר על ידי הצומת הראשונה מכיר את כל האינפורמציה הרשומה על ידי הרובוט המתואר על ידי המצב השני.

Page 8: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

לוגיקה מודלית

יכולה לתאר את התכונות המאפינות את המצבים השונים והקשר ביניהם.

תחביר:

::= p | ¬ | (/\) | (\/) | [] | <>.P הינו משתנה פסוקי מאוסף משתנים פסוקיים pכאשר

((=)\/)אפשר להגדיר קשרים חדשים, למשל

דוגמאות:

(p[]<>p)((p/\<>q)[]<>(p/\[]q))

Page 9: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

סמנטיקה, לא פורמלי

.)נוסחא מתפרשת מעל עולם )צומת ,לנוסחאות שהן נוסחאות אטומיות )פסוקיות

מסדר ראשון(, יש את הפרוש הרגיל מעל העולם.

יש את ¬/\, \/, לקשרים הלוגיים הרגילים הפרוש הרגיל.

מסמן שהתכונה נכונה לכל העולמות ][הקשר הישיגים מהעולם הנוכחי על ידי קשת.

מסמן שהתכונה נכונה לפחות לעולם ><הקשר אחד הישיג מהעולם הנוכחים על ידי קשת.

Page 10: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מה מתקיים בעולם של הצומת הימנית תחתונה?

p,q

p

p, ¬q, p/\¬q, p\/q… ,

><p, []q

והצומת השמאלית התחתונה?

¬p, ¬ q, ¬(p\/q), []p, <>[]q.

Page 11: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

סמנטיקה, פורמלי

Kripkeנגדיר מבנה (W, R, L, P)P – a set of propositionsW – a set of “states” (or “worlds”).R – a relation RWxW “accessibility

relation”L: W2P Assigns the set of

propositions that hold in each state.

Page 12: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

עולמות שונים לוגיקה מודלית:

s1

p,q

s2

p

s3

P={p,q}

W={s1,s2,s3}

R={(s1,s1),(s1,s2),(s2,s1), (s3,s1),(s3,s2)}

L(s1)={p,q}, L(s2)={p},L(s3)=

Page 13: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

כעת אפשר להגדיר את המשמעות בצורה רקורסיבית. המשמעות מוגדרת לכל מצב

)עולם(

x|==p iff pL(x) x|== iff x|=/= x|==/\ iff x|== and x|== x|==\/ iff x|== or x|== x|==[] iff for each yW such that

R(x,y), y|== x|==<> iff there exists yW such

that R(x,y), y|==

Page 14: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

אם בכל מצב שקולה )=( ל- נוסחא מתקיימת אם ורק אם ובכל עולם

מתקיימת

[]=<> <>=[] [](p/\q)=([]p/\[]q) <>(p\/q)=(<>p\/<>q)

אבלo [](p\/q)([]p\/[]q)o <>(p/\q)(<>p/\<>q)

למה? האם הגרירה בכיוון מסויים מתקיימת?

Page 15: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

אי שוויונות שלא מתקיימים

[](p\/q)([]p\/[]q) כן מתקיים אבל

<>(p/\q)(<>p/\<>q) כן מתקיים אבל

q

p

Page 16: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

עבור נוסחה מודלית

ברת סיפוק(satisfiable) אם מתקיימת עבור מצב מסויים במודל מסויים.

אינה ברת סיפוק(unsatisfiable) אינה מתקיימת עבור כל מצב בכל מודל.

נכונה\מתקיימת במודל, אם מתקיימת עבור כלהמצבים במודל.

Valid )אם מתקיימת בכל מודל )בכל מצב ==|Valid במשפחה של מודלים המקיימים הגבלה

|==מסויימת )כפי שנראה בהמשך(. גם כאן נסמן בהנחה שמשפחת המודלים ידועה.

Page 17: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

אקסיומות וכללי היסק

כל האקסיומות וMP.מתורת הפסוקים עבור כל המודלים(valid):

K []()([][])

GENכלל היסק: []

Page 18: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

עבור משפחות מודלים

T [] Reflexive: w,(w,w)R

D []<> Serial: wW w’W (w,w’)R

4 [][][] Transitive: w,w’,w’’W(w,w’)R/\ (w’,w’’)R (w,w’’)R

5 <>[]<> Euclidean: w,w’,w’’W(w,w’)R/\ (w,w’’)R (w’,w’’)R

Page 19: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מבנה היררכי של משפחות. חץ פרושו שההיררכיה הראשונה בעלת יותר מבנים ופחות

מההיררכיה השניהvalidתכונות בה

K

K4 K5 KD KT=KDT

K45 KD5 KD4

KD45

KT4=KTD4

KT5=KT45=KDT5=KDT45

Page 20: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מודלים לינארים

טרנזיטיבי)כל זוג מצבים מסודר )סדר לינאריאין מעגלים

מתאים לתאור ביצוע של תכנית )שינוי ממצבלמצב(.

X=0 X=0X=2X=1X=1

Page 21: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

חידה

שלשה ילדים משחקים בחוץ. חלק מתלכלכים על מצחם בבוץ, אבל לא יודעים

זאת.עובר אב של אחד מהם ואומר:

"לפחות אחד מכם מלוכלך בבוץ על מצחו, מי יודע שמצחו מלוכלך?"

אף ילד לא עונה. הוא שואל שוב, ואף ילד לא עונה, בפעם השלישית שהוא שואל, כל הילדים עונים יחד

שראשם שלהם מלוכלך.הכיצד?

Page 22: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

הנחות

הילדים לא משקרים1.

כל ילד אינו רואה את מצחו שלו2.

כל ילד חכם ויכול להסיק כל היסק לוגי 3.הגיוני ממה שהוא רואה.

Page 23: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

לא יכול להבחין בין המקרים

Page 24: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

אוסף העולמות האפשרייםm-muddy, n-not muddy

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Page 25: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

רלציות שקילות בין עולמותכתום נסמן את העולם האמיתי:

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

Page 26: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

שמשתתף אומר Kc סימון מודאלי לידע )סוכן(

c ש-יודע .מתקיים

נניחmc פרושו שמשתתף c-מלוכלך ו ¬mc פרושו אינו מלוכלך.cשמתתף

Ka(mb/\mc)

KcKa mb

Kc(ma/\Ka mb)

בדוגמא שלנו, רוציםKxmx .עבור אחד המשתתפים

:סימון נוסף C-אומר ש ,הינו ידע משותף, כלומר וכל משתתף יודע שכל כל משתתף יודע את

וכולי.משתתף יודע את

Page 27: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

משמש בדומה לכמת ][ בלוגיקה Kaהכמת מודלית

ההבדל הינו שיש לנו מספר רלציות ביןצמתים ולא רק רלציה אחת. לכן, לכל רלציה

יש את הכמת שלה. כל רלציהRa ,בין צמתים הינה רצלית שקילות

כלומר רפלקסיבית, טרנזיטיבית וסימטרית.אין את הדואלי >< ל-][. אבל אפשר לכתוב

¬Ka¬

Page 28: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

סמנטיקה

s|==p iff ps s|==/\ iff s|== and s|== s|==¬ iff s|=/= s|==Ka iff r (s,r) Ra, r|== s|==C iff Ka and KaKb, KcKa etc.

Page 29: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

תכונה

Kx(/\) Kx/\Kx

אבל לא מתקיים Kx(\/) Kx\/Kx

Page 30: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

בעולם האמיתי?cמה יודע

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

Page 31: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

אינו יכול להבחין בין המצבים השקולים cמשתתף )Kc)ma/\mb לכן: Rcלפי

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

Page 32: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

)Ka)mb/\mcבעולמות אלו?בעולמות הירוקים:a ומה יודע

)Ka)mb/\¬mc : בעולמות הכחולים)KcKa )mb לכן:

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

ידע על קשת משותף לשני הצמתים המחוברים

אליו

Page 33: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

KcKaKb ?

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

Kb)¬ma/\¬mc(

Kb)ma/\¬mc(

Kb)¬ma/\mc(

Kb)ma/\mc(

Page 34: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

KcKaKbtrue

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

Kb)na/\¬nc(

Kb)ma/\¬nc(

Kb)¬na/\mc(

Kb)ma/\mc(

KaKbmc

KaKb¬mc

Page 35: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:n, b:n, c:n

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rc

Rb

Rb

Rb

Rb

Ra

Ra

Ra

Ra

Rc

Rc

Kb)¬ma/\¬mc(

Kb)ma/\¬mc(

Kb)¬ma/\mc(

Kb)ma/\mc(

KaKbmc

KaKb¬mc

אחרי הצהרת האבמה שהאב אמר הינו ידע משותף )כי כולם שמעו את

זה יחד ונכחו שהאחרים שמעו וכולי(.

Page 36: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

אחרי הצהרת האב)C)ma\/mb\/mc בעולם האמיתי כולם יודעים גם

a:m, b:m, c:m a:n, b:n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rb

Rb

Rb

Ra

Ra

Ra

Rc

Rc

Kb)¬ma/\mb/\¬mc(

Kb)ma/\¬mc(

Kb)¬ma/\mc(

Kb)ma/\mc(

KaKbmc

KaKb¬mc

Ka)ma/\¬mb/\¬nc(

Ka)¬ma/\¬mb/\mc(

אבל אף אחד לא מודיע שהוא יודע שיש

לו בוץ על המצח

Page 37: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

בפעם השניה שהאב שואל, המצבים המקווקוים אינם יכולים לתאר את המציאות ולכן ירדו, עם הקשתות

המתאימות

a:m, b:m, c:m a:¬n, b:¬n, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:m, b:n, c:n a:n, b:m, c:n

a:m, b:m, c:n

Rc

Rb

Rb

Rb

Ra

Ra

Ra

Rc

Rc

Kb)¬na/\mb/\¬nc(

Kb)ma/\¬nc(

Kb)¬na/\mc(

Kb)ma/\mc(

KaKbmc

KaKb¬n

c

Ka)ma/\¬nb/\¬nc(

Ka)na/\nb/\mc(

Page 38: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מכיון שאף אחד לא הודיע שמצחו מלוכלך, בפעם השניה שהאב שואל, המצב הוא הבא:

a:m, b:m, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:m, b:m, c:n

Rc

Rb

Ra

Ka)ma/\¬mb/\mc(/\Kc)ma/\¬mb/\mc(

Kb)¬ma/\mb/\mc(/\Kc)¬ma/\mb/\mc(

Ka)ma/\mb/\¬mc(/\Kb)ma/\mb/\¬mc(

Page 39: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מכיון שגם בפעם השניה אף אחד לא ידע שמצחו מלוכלך, בפעם השלישית ימחקו העולמות המקווקוים

a:m, b:m, c:m

a:n, b:m, c:m

a:m, b:n, c:m

a:m, b:m, c:n

Rc

Rb

Ra

Ka)ma/\¬mb/\mc(/\Kc)ma/\¬mb/\mc(

Kb)¬ma/\mb/\mc(/\Kc)¬ma/\mb/\mc(

Ka)ma/\mb/\¬mc(/\Kb)ma/\mb/\¬mc(

Page 40: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מכיון שגם בפעם השניה אף אחד לא ידע שמצחו מלוכלך, בפעם השלישית ימחקו העולמות המקווקוים

a:m, b:m, c:m

ועכשיו שלשת הילדים יודעים שמצחם מלוכלך

Page 41: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

לוגיקה של ידע יורשת את תכונותיה מהלוגיקה

KT45

אם אני יודע על גרירה, ואני יודע שצידה הימני מתקיים, אני יודע גם שצידה השמאלי מתקיים )או, בקיצור, אני

יודע להסיק!(

Ka() (Ka Ka)כל מה שאני יודע מתקיים גם בעולם שלי

Kaאני יודע מה אני יודע

Ka KaKaאני יודע מה אני לא יודע

¬Ka Ka¬Ka

Page 42: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

עוד חידה

כובעים אדומים.3 כובעים לבנים ו-2יש בערמה

שלשה נתינים באים אל המלך.

המלך שם על ראש כל אחד כובע ושואל אותם לפי הסדר אם הם יודעים מה הצבע על ראשם

)אין להם מראה והם לא מגלים אחד לשני(.

הראשון אומר "איני יודע".

השני אומר "איני יודע".

השלישי יודע, מה הצבע של כובעו?

Page 43: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

נסמן

R2לאיש השני כובע אדום – W1לאיש הראשון כובע לבן –

וכולי.

.W2הינו שקול ל- R2¬ למעשה

Page 44: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR RRW

RWWWWR WRW

WRR

R3

R3

R2

R2

R1

R1 R1

R3R2

גרף העולמות האפשריים עם רלציות השקילויות

Page 45: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR RRW

RWWWWR WRW

WRR

R3

R3

R2

R2

R1

R1 R1

R3R2

אחרי שהראשון אמר שהוא לא יודע איזה C¬R1כובע על ראשו,

Page 46: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR RRW

WWR WRW

WRR

R3R2R1

R1 R1

R3R2

אחרי שהראשון אמר שהוא לא יודע איזה C¬R1כובע על ראשו,

Page 47: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR RRW

WWR WRW

WRR

R3R2R1

R1 R1

R3R2

עכשיו נשאל השני והוא אינו יודע. זה שולל את המצבים המקווקוים

Page 48: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR

WWR

WRR

R2R1

R1

R2

כעת נשאל השלישי, אבל בכל עולם שבו .R3הוא יכול להיות מתקיים

Page 49: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

בתחילה ובנוסחאות:

={C(R1\/R2\/R3),C(R1K2R1),

C(R1K3R1),

C(R2K1R2),

C(R2K3R2),

C(R3K1R3),

C(R3K2R3),

C(¬R1K2¬R1),

C(¬R1K3¬R1),

C(¬R2K1¬R2),

C(¬R2K3¬R2),

C(¬R3K1¬R3),

C(¬R3K2¬R3){

Page 50: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR RRW

WWR WRW

WRR

R3R2R1

R1 R1

R3R2

אחרי שהראשון אמר שהוא לא יודע איזה C¬R1כובע על ראשו,

{C)¬K1R1/\¬K1¬R1(}|-- C)R2\/R3(

Page 51: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

RRR

RWR

WWR

WRR

R2R1

R1

R2

אחרי שהשני לא יודע איזה כובע על ראשו

{C)R2\/R3(, C)¬K2R2/\¬K2¬R2(}|--K3R3

Page 52: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Temporal logic

Dynamic, speaks about several “worlds” and the relation between them.

Our “worlds” are the states in an execution.

There is a linear relation between them, each two sequences in our execution are ordered.

Interpretation: over an execution, later over all executions.

Page 53: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מודלים לינארים

טרנזיטיבי)כל זוג מצבים מסודר )סדר לינאריאין מעגלים

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

שלה. תכונה מתקיימת בתכנית אם היא מתקיימת בכל

הביצועים.

X=0 X=0X=2X=1X=1

Page 54: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

LTL: Syntax

::= () | ¬ | /\ \/ U |O | p

“box”, “always”, “forever”“diamond”, “eventually”, “sometimes”O “nexttime”U“until”Propositions p, q, r, … Each represents some

state property (x>y+1, z=t, at_CR, etc.)

Page 55: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Semantics over suffixes of execution

O

U

Page 56: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Can discard some operators

Instead of <>p, write true U p. Instead of []p, we can write ¬(<>¬p),

or ¬(true U ¬p).Because []p=¬¬[]p.¬[]p means it is not true that p holds forever, or at some point ¬p holds or <>¬p.

Page 57: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Combinations

[]<>p “p will happen infinitely often”

<>[]p “p will happen from some point forever”.

([]<>p) ([]<>q) “If p happens infinitely often, then q also happens infinitely often”.

Page 58: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Some relations:

[](/\)=([])/\([]) But <>(/\)(<>)/\(<>)

<>(\/)=(<>)\/(<>) But [](\/)([])\/([])

Page 59: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

What about

([]<>)/\([]<>)=[]<>(/\)?

([]<>)\/([]<>)=[]<>(\/)?

(<>[])/\(<>[])=<>[](/\)?

(<>[])\/(<>[])=<>[](\/)?

No, just

Yes!!!

Yes!!!

No, just

Page 60: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Formal semantic definition

Let be a sequence s0 s1 s2 … Let i be a suffix of : si si+1 si+2 … (0 = ) i |= p, where p a proposition, if si|=p. i |= /\ if i |= and i |= . i |= \/ if i |= or i |= . i |= ¬ if it is not the case that i |= . i |= <> if for some ji, j |= . i |= [] if for each ji, j |= . i |= U if for some ji, j|=

and for each ik<j, k |=.

Page 61: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Then we interpret:

For a state:s|=p as in propositional logic.

For an execution:|= is interpreted over a sequence, as in previous slide.

For a system/program:P|=holds if |= for every sequence of P.

Page 62: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Spring Example

s1 s3s2

pull

release

releaseextended

malfunction

extended

r0 = s1 s2 s1 s2 s1 s2 s1 …

r1 = s1 s2 s3 s3 s3 s3 s3 …

r2 = s1 s2 s1 s2 s3 s3 s3 …

Page 63: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

LTL satisfaction by a single sequence

malfunction

s1 s3s2pull

release

releaseextende

dextended

r2 = s1 s2 s1 s2 s3 s3 s3 …

r2 |= extended ??

r2 |= O extended ??

r2 |= O O extended ??

r2 |= <> extended ??

r2 |= [] extended ??

r2 |= <>[] extended ??

r2 |= ¬ <>[] extended ??

r2 |= (¬extended) U malfunction ??

r2 |= [](¬extended->O extended) ??

Page 64: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

LTL satisfaction by a system

malfunction

s1 s3s2pull

release

releaseextende

dextended

P |= extended ??

P |= O extended ??

P |= O O extended ??

P |= <> extended ??

P|= [] extended ??

P |= <>[] extended ??

P |= ¬ <>[] extended ??

P |= (¬extended) U malfunction ??

P |= [](¬extended->O extended) ??

Page 65: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

More specifications

[] (PC0=NC0 <> PC0=CR0) [] (PC0=NC0 U Turn=0) Try at home:

- The processes alternate in entering their critical sections.- Each process enters its critical section infinitely often.

Page 66: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Proof system

><¬p<-->[]¬p [](pq)([]p[]q) []p(p/\O[]p) O¬p<-->¬Op [](pOp)(p[]p) (pUq)<-->(q\/(p/\O(pUq))) (pUq)<>q

+ propositional logic axiomatization.

+ proof rule: _p_ []p

Page 67: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Traffic light example

Green Yellow Red Always has exactly one light:

[](¬(gr/\ye)/\¬(ye/\re)/\¬(re/\gr)/\(gr\/ye\/re))

Correct change of color:

[]((grU ye)\/(yeU re)\/(reU gr))

Page 68: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Another kind of traffic light

GreenYellowRedYellowFirst attempt:

[](((gr\/re) U ye)\/(ye U (gr\/re)))

Correct specification:[]( (gr(gr U (ye /\ ( ye U re ))))

/\(re(re U (ye /\ ( ye U gr ))))

/\(ye(ye U (gr \/ re))))

Needed only when wecan start with yellow

Page 69: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

L0:While True do NC0:wait(Turn=0); CR0:Turn=1endwhile ||L1:While True do NC1:wait(Turn=1); CR1:Turn=0endwhile

T0:PC0=L0PC0:=NC0T1:PC0=NC0/\Turn=0 PC0:=CR0T2:PC0=CR0 (PC0,Turn):=(L0,1)T3:PC1=L1PC1=NC1T4:PC1=NC1/\Turn=1 PC1:=CR1T5:PC1=CR1 (PC1,Turn):=(L1,0)

Initially: PC0=L0/\PC1=L1

Example: The program

Is this the only reasonable way to model this program?

Page 70: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

The state graph:Successor relation between reachable states.

Turn=0L0,L1

Turn=0L0,NC1

Turn=0NC0,L1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=0CR0,L1

Turn=1L0,CR1

Turn=1NC0,CR1

Turn=1L0,NC1

Turn=1NC0,NC1

Turn=1NC0,L1

Turn=1L0,L1T0 T0T3 T3

T1 T4T3

T0 T3

T0

T0 T4T1 T3

T2

T2

T5

T5

Page 71: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Always ¬)PC0=CR0/\PC1=CR1((Mutual exclusion)

Turn=0L0,L1

Turn=0L0,NC1

Turn=0NC0,L1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=0CR0,L1

Turn=1L0,CR1

Turn=1NC0,CR1

Turn=1L0,NC1

Turn=1NC0,NC1

Turn=1NC0,L1

Turn=1L0,L1

Page 72: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Always if Turn=0 then at some point Turn=1

Turn=0L0,L1

Turn=0L0,NC1

Turn=0NC0,L1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=0CR0,L1

Turn=1L0,CR1

Turn=1NC0,CR1

Turn=1L0,NC1

Turn=1NC0,NC1

Turn=1NC0,L1

Turn=1L0,L1

Page 73: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Always if Turn=0 then at some point Turn=1

Turn=0L0,L1

Turn=0L0,NC1

Turn=0NC0,L1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=0CR0,L1

Turn=1L0,CR1

Turn=1NC0,CR1

Turn=1L0,NC1

Turn=1NC0,NC1

Turn=1NC0,L1

Turn=1L0,L1

Page 74: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Interleaving semantics:Execute one transition at a time.

Turn=0L0,L1

Turn=0L0,NC1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=1L0,CR1

Turn=1L0,NC1

Need to check the property

for every possible interleaving!

Page 75: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Interleaving semantics:Execute one transition at a time.

Turn=0L0,L1

Turn=0L0,NC1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=1L0,CR1

Turn=1L0,NC1

Need to check the property

for every possible interleaving!

Page 76: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

Interleaving semantics

Turn=0L0,L1

Turn=0L0,NC1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=1L0,CR1

Turn=1L0,NC1

Turn=0L0,L1

Turn=0L0,NC1

Page 77: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

(][Turn=0 ><Turn=1)

Turn=0L0,L1

Turn=0L0,NC1

Turn=0NC0,L1

Turn=0CR0,NC1

Turn=0NC0,NC1

Turn=0CR0,L1

Turn=1L0,CR1

Turn=1NC0,CR1

Turn=1L0,NC1

Turn=1NC0,NC1

Turn=1NC0,L1

Turn=1L0,L1

Page 78: Modal Logics לוגיקות מודליות Lectures of Doron Peled Bar Ilan University

מה ניתן לעשות עם זה?

הוכחה בלוגיקה שתכונות של תכנית מתקיימות )נכונות שלתכנית(.

הוכחה אלגוריתמית אוטומטיתModel Checking

השיטה זיכתה את ממציאיה בפרסTuring שהוא הפרס זכה 1996החשוב ביותר במדעי המחשב השנה )ולפני כן ב

מדען ישראלי, אמיר פנואלי בפרס זה על הצגת הלוגיקה הטמפורלית:

"For seminal work introducing temporal logic into computing science and for outstanding contributions to program and system verification."