1 / 40

adam bakewell university of birmingham

adam bakewell university of birmingham. model checking for unsafety. model checking for safety. e. g. button : bool, wait, crash : com |- macro NorthSouth 0 in macro EastWest 1 in new nat ns := 0 in new nat ew := 0 in let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in

noelle-bell
Download Presentation

adam bakewell university of birmingham

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. adam bakewell university of birmingham

  2. model checking for unsafety

  3. model checking for safety

  4. e g • button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1}; • if timer > 0 then { • off(EastWest); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1}; • on(EastWest) } }; • off(EastWest); on(NorthSouth); • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1 }; • if timer > 0 then { • off(NorthSouth); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1 }; • on(NorthSouth) } }; • off(NorthSouth); on(EastWest) }

  5. state explosion

  6. state explosion

  7. state explosion

  8. state explosion

  9. button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer – 1 }; • off(EastWest); on(NorthSouth); • off(NorthSouth); on(EastWest) } 0001 traces e g

  10. button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • if timer > 0 then { • off(EastWest); • on(EastWest) } }; • off(EastWest); on(NorthSouth); • off(NorthSouth); on(EastWest) } 0056 traces e g

  11. button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1}; • if timer > 0 then { • off(EastWest); • on(EastWest) } }; • off(EastWest); on(NorthSouth); • off(NorthSouth); on(EastWest) } 0075 traces e g

  12. button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1}; • if timer > 0 then { • off(EastWest); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1}; • on(EastWest) } }; • off(EastWest); on(NorthSouth); • off(NorthSouth); on(EastWest) } 0095 traces e g

  13. button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1}; • if timer > 0 then { • off(EastWest); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1}; • on(EastWest) } }; • off(EastWest); on(NorthSouth); • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1 }; • if timer > 0 then { • off(NorthSouth); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1 }; • on(NorthSouth) } }; • off(NorthSouth); on(EastWest) } 3785 traces e g

  14. abstraction • The answer: abstract the model and check only the remaining tricky part not taken out by the general proven principle embodied by the abstraction • The skill: abstraction design and application • but, wait a minute… • Could we just abstract the program and leave everything else the same?

  15. clipping • Clip subterms not containing targets

  16. clipping • Clip subterms not containing targets

  17. clipping • Clip subterms not containing targets

  18. clipping • Clip subterms not containing targets

  19. clipping • Clip subterms not containing targets

  20. clipping • Clip subterms not containing targets

  21. clipping • Clip subterms not containing targets

  22. X() X(v) X() X() X(u,w) X(v,z) X() X(v) X(y) X() stumping • Replace clipped subterms with stump X(v1,..,vn)

  23. e g button : bool, wait, crash : com |- new bool ns . X1(ns); new bool ew . X2(ew); if X3(ns) then crash else X4(ew) while 1 do { new nat timer . X5(timer); new nat zebra . X6(zebra); while X7(timer) do { X8(timer,wait); if button then { X9(zebra,wait); if X10(timer) then { X11(ew,wait); if X12(ns) then crash else X13(ew)}}}; X14(ew); if X15(ew) then crash else X16(ns) • button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1}; • if timer > 0 then { • off(EastWest); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1}; • on(EastWest) } }; • off(EastWest); on(NorthSouth); • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1 }; • if timer > 0 then { • off(NorthSouth); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1 }; • on(NorthSouth) } }; • off(NorthSouth); on(EastWest) } new nat timer . X17(timer); new nat zebra . X18(zebra); while X19(timer) do { X20(timer,wait); if button then { X21(zebra,wait); if X22(timer) then { X23(ns,wait); if X24(ew) then crash else X25(ns)}}}; X26(ns); if X27(ns) then crash else X28(ew) }

  24. e g button : bool, wait, crash : com |- new bool ns . X1(ns); new bool ew . X2(ew); if X3(ns) then crash else X4(ew) while 1 do { new nat timer . X5(timer); new nat zebra . X6(zebra); while X7(timer) do { X8(timer,wait); if button then { X9(zebra,wait); if X10(timer) then { X11(ew,wait); if X12(ns) then crash else X13(ew)}}}; X14(ew); if X15(ew) then crash else X16(ns) • button : bool, • wait, crash : com • |- • macro NorthSouth 0 in macro EastWest 1 in • new nat ns := 0 in new nat ew := 0 in • let off be fun d:nat . if d=NorthSouth then ns := 0 else ew := 0 in • let on be fun d:nat . assert (if d=NorthSouth then ew=0 else ns=0) crash; • if d=NorthSouth then ns := 1 else ew := 1 in • on(EastWest); • while 1 do { • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1}; • if timer > 0 then { • off(EastWest); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1}; • on(EastWest) } }; • off(EastWest); on(NorthSouth); • new nat timer := 10 in • new nat zebra := 0 in • while timer > 0 do { • wait; • timer := timer - 1; • if button then { • zebra := zebra + 1; • new nat timer1 := zebra in • while timer > 0 & timer1 > 0 do { • wait; • timer1 := timer1 - 1; • timer := timer – 1 }; • if timer > 0 then { • off(NorthSouth); • new nat timer2 := 3 in • while timer2 > 0 do { • wait; • timer2 := timer2 – 1 }; • on(NorthSouth) } }; • off(NorthSouth); on(EastWest) } new nat timer . X17(timer); new nat zebra . X18(zebra); while X19(timer) do { X20(timer,wait); if button then { X21(zebra,wait); if X22(timer) then { X23(ns,wait); if X24(ew) then crash else X25(ns)}}}; X26(ns); if X27(ns) then crash else X28(ew) }

  25. button : bool, wait, crash : com |- new bool ns . X1(ns); new bool ew . X2(ew); if X3(ns) then crash else X4(ew) while 1 do { new nat timer . X5(timer); new nat zebra . X6(zebra); while X7(timer) do { X8(timer,wait); if button then { X9(zebra,wait); if X10(timer) then { X11(ew,wait); if X12(ns) then crash else X13(ew)}}}; X14(ew); if X15(ew) then crash else X16(ns) e g new nat timer . X17(timer); new nat zebra . X18(zebra); while X19(timer) do { X20(timer,wait); if button then { X21(zebra,wait); if X22(timer) then { X23(ns,wait); if X24(ew) then crash else X25(ns)}}}; X26(ns); if X27(ns) then crash else X28(ew) }

  26. clipping safety property safe X() X(v) X() X() safe X(u,w) X(v,z) X() X(v) X(y) X()

  27. clipping unsafety property unsafe if path has no stump X() X(v) X() unsafe X() X(u,w) X(v,z) X() X(v) X X(y) X()

  28. clipping unknown safety property unknown if path has a stump X() X(v) X() unsafe X() X(u,w) X(v,z) X() X(v) X X(y) X()

  29. Clipping safety property proof • Every trace to target assert in unclipped model – plus stump moves – appears in clipped model • i.e. X(v1,..,vn) overapproximates (M where fv(M)={v1,..,vn}) • With non-denotational models the stumps would be a language extension – model pieces in the program - with denotational (e.g. game) models they are just id’s

  30. button : bool, wait, crash : com |- new bool ns . X1(ns); new bool ew . X2(ew); if X3(ns) then crash else X4(ew) CEX: .q,X1.q,X1.ok,X2.q,X2.ok,X3.q,X3.tt,crash.q unknown safety! e g

  31. X(v) X() X() X() X(u,w) X(v,z) X() X(v) X() X(y) grow back 1. Choose stump X(v1,..,vn) from CEX

  32. grow back 2. Get subterm M replaced by stump X(v) X() X() X() X(v,z) X() X(v) X() X(y)

  33. X(v) X() X() X() X(u) X(v,z) X() X(w) X() X(v) X() X(y) grow back 3. clip M (target some leaf) and graft

  34. CEGAR model check X() X(v) clip X() X() X(u,w) X(v,z) X() X(v) X(y) X() grow-back analyse X1,X2,…

  35. new bool ns . X1(ns); new bool ew . X2(ew); if X3(ns) then crash else X4(ew) CEX: .q,X1.q,X1.ok,X2.q,X2.ok,X3.q,X3.tt,crash.q e g new bool ns . X1(ns); new bool ew . X2(ew); if ns != 0 then crash else X4(ew) CEX:X1.q,X1.0.1,ns.1,ns.ok,X1.0.ok,X1.ok,X2.q,X2.ok,X3.q,X3.tt,crash.q new bool ns . X1(ns); new bool ew := 0; if X3(ns) then crash else X4(ew) CEX: X1.q,X1.ok,X3.q,X3.tt,crash.q new bool ns := 0; new bool ew . X2(ew); if X3(ns) then crash else X4(ew) CEX: X2.q,X2.ok,X3.q,X3.tt,crash.q new bool ns := 0; new bool ew := 0; if X3(ns) then crash else X4(ew) CEX: X3.q,X3.tt,crash.q new bool ns := 0; new bool ew . X2(ew); if ns != 0 then crash else X4(ew) SAFE new bool ns . X1(ns); new bool ew := 0; if ns != 0 then crash else X4(ew) CEX:X1.q,X1.0.1,ns.1,ns.ok,X1.0.ok, X1.ok,X3.q,X3.tt,crash.q new bool ns := 0; new bool ew := 0; if ns != 0 then crash else X4(ew) SAFE

  36. strategy • Find minimal (un)safe clipping by BFS • Optimize: prioritize grow-back for: • Conditional nearest crash • Assignment to ids in conditionals on crash path

  37. button : bool, wait, crash : com |- new nat ns := 0 in new nat ew . X2(ew) in if ns = 1 then crash else X4(ew); while 1 do { new nat timer . X5(timer); new nat zebra . X6(zebra); while X7(timer) do { X8(timer,wait); if button then X9(zebra,timer,wait); if X10(timer) then { X11(ew,wait); if ns = 1 then crash else X13(ew) } }; ew := 0; if ew = 1 then crash else X16(ns); SAFE with 8 grow-backs e g new nat timer . X17(timer); new nat zebra . X18(zebra); while X19(timer) do { X20(timer,wait); if button then X21(zebra,timer,wait); if X22(timer) then { X23(ns,wait); if ew = 1 then crash else X25(ns) } }; ns := 0; if ns = 1 then crash else X28(ew) }

  38. button : bool, wait, crash : com |- new nat ns := 0 in new nat ew . X2(ew) in if ns = 1 then crash else ew := 1; while 1 do { new nat timer := 10; new nat zebra := 0; while timer > 0 do { wait; timer := timer – 1; if button then X9(zebra,timer,wait); if X10(timer) then { X11(ew,wait); if X12(ns) then crash else X13(ew) } }; if ew = 1 then crash else X15(ns); X16(ew); variant: UNSAFE with 9 grow-backs e g new nat timer . X17(timer); new nat zebra . X18(zebra); while X19(timer) do { X20(timer,wait); if button then X21(zebra,timer,wait); if X22(timer) then { X23(ns,wait); if ew = 1 then crash else X25(ns) } }; ns := 0; if ns = 1 then crash else X28(ew) }

  39. button : bool, wait, crash : com |- new nat ns := 0 in new nat ew := 0 in if ns = 1 then crash else ew := 1; while 1 do { new nat timer . X5(timer); new nat zebra . X6(zebra); while X7(timer) do { X8(timer,wait); if button then X9(zebra,timer,wait); if X10(timer) then { ew := 0; wait; if ns = 1 then crash else ew := 1 } }; ew := 0; if ew = 1 then crash else ns := 1; cf. ns/ew clipping - extra detail: good or bad? e g new nat timer . X17(timer); new nat zebra . X18(zebra); while X19(timer) do { X20(timer,wait); if button then X21(zebra,timer,wait); if X22(timer) then { ns := 0; wait; if ew = 1 then crash else ns := 1 } }; ns := 0; if ns = 1 then crash else ew := 1 }

  40. to do • Stumping is useful only if • model#(X(v1,..,vn)) << model#(M) • Conditionals over ints have big models • Predicate abstract them? • Non-bool stumps have big models • Data abstract them?

More Related