Скачать презентацию CIS 842 Specification and Verification of Reactive Systems Скачать презентацию CIS 842 Specification and Verification of Reactive Systems

844a9445af601873ff928d01ad8e2e66.ppt

  • Количество слайдов: 46

CIS 842: Specification and Verification of Reactive Systems Lecture OVERVIEW: Course Overview Copyright 2001 CIS 842: Specification and Verification of Reactive Systems Lecture OVERVIEW: Course Overview Copyright 2001 -2004, Matt Dwyer, John Hatcliff, and Robby. The syllabus and all lectures for this course are copyrighted materials and may not be used in other course settings outside of Kansas State University in their current form or modified form without the express written permission of one of the copyright holders. During this course, students are prohibited from selling notes to or being paid for taking notes by any person or commercial firm without the express written permission of one of the copyright holders. CIS 842: Course Overview

Software is. . . …one of the most complex man made artifacts “I believe Software is. . . …one of the most complex man made artifacts “I believe the [spreadsheet product] I’m working on now is far more complex than a 747 (jumbo jet airliner)” -- Chris Peters (Microsoft, 1992) “It’s different [from other engineering disciplines] in that we take on novel tasks every time. The number of times [civil engineers] make mistakes is very small. And at first you think, what’s wrong with us? It’s because it’s like we’re building the first skyscraper every time. ” -- Bill Gates (Microsoft, 1992) CIS 842: Course Overview 2

Software is. . . …one of the most complex man made artifacts Microsoft Word Software is. . . …one of the most complex man made artifacts Microsoft Word is … 1 million lines of code Microsoft NT … 16 million lines of code Even pacemakers have 100 thousand lines of code … …but perhaps software complexity shouldn’t even be measured in terms of lines of code, but instead, in terms of number of states CIS 842: Course Overview 3

States >> SLOC n The size of a system is sometimes more accurately expressed States >> SLOC n The size of a system is sometimes more accurately expressed using semantic point of view n n the number of different states a system can reach … an integer has 4. 2 billion possible values … an object with 2 ints and a boolean field has 40 thousand quadrillion values How about Windows NT? CIS 842: Course Overview 4

Software is… …critical to the conduct of modern life. n n n Process Control Software is… …critical to the conduct of modern life. n n n Process Control (oil, gas, water, …) Transportation (air traffic control, …) Health Care (patient monitoring, device control …) Finance (automatic trading, bank security …) Defense (intelligence, weapons control, …) Manufacturing (precision milling, assembly, …) Failing software costs money and lives! CIS 842: Course Overview 5

Failing Software Costs Money n n Thousands of dollars for each minute of factory Failing Software Costs Money n n Thousands of dollars for each minute of factory down-time Huge losses of monetary and intellectual investment n n Rocket boost failure (e. g. , Arianne 5) Business failures associated with buggy software (Ashton-Tate d. Base) CIS 842: Course Overview 6

Failing Software Costs Lives n Potential problems are obvious: n n n Software used Failing Software Costs Lives n Potential problems are obvious: n n n Software used to control nuclear power plants Air-traffic control systems Spacecraft launch vehicle control …. A well-known and tragic example n Therac-25 radiation machine failures CIS 842: Course Overview 7

Software is. . . …becoming the dominant component of society’s infrastructure. In the future… Software is. . . …becoming the dominant component of society’s infrastructure. In the future… n Everything will be monitored/controlled n n These systems may not have manual backup n n networked watches, clothes, … autonomous vehicles, intelligent highways, … virtual X rather than physical X no workarounds for y 2 k-like problems Failures will be very costly and dangerous CIS 842: Course Overview 8

Software is. . . …what you’ll be building after graduation. n You’ll be developing Software is. . . …what you’ll be building after graduation. n You’ll be developing systems in 2020+ n n in the context we just mentioned Given the importance of software n n n you may be regulated, licensed you may be liable for errors your job may depend on your ability to produce reliable systems CIS 842: Course Overview 9

Current Software Development Methods Are Insufficient n Testing n n Systematic Inspections n n Current Software Development Methods Are Insufficient n Testing n n Systematic Inspections n n samples execution behavior, misses some don’t scale very well, although they are thorough Rigorous development processes n helping but most organizations don’t apply them Formal methods are becoming more popular CIS 842: Course Overview 10

Software Failures NASA Mars Pathfinder Mission n Rover’s watchdog timer observed tasks missing their Software Failures NASA Mars Pathfinder Mission n Rover’s watchdog timer observed tasks missing their deadlines due to delays caused by a priority inversion problem. Each such missed deadline led to a system reset and a one-day delay in retransmission of data which wasted valuable mission time. This type of error could have been detected using model -checking. CIS 842: Course Overview 11

Software Failures Ariane 5 Rocket n n Ariane 5 software reused old code from Software Failures Ariane 5 Rocket n n Ariane 5 software reused old code from Ariane 4 that was not respecified and retested in new environment Code in question performed floating point calculations Ariane 5 (being more powerful than Ariane 4) caused unanticipated floating-point exception (which would have never occurred on Ariane 4), causing an exception to be thrown which was not caught Triggered automatic destruction: $500 million loss CIS 842: Course Overview 12

Software Failures Therac-25 Radiation Machine n n Reusing a shared variables for different purposes Software Failures Therac-25 Radiation Machine n n Reusing a shared variables for different purposes and a race condition on that variable led to a situation where lethal doses of radiation were given. Several deaths resulted from this software error. CIS 842: Course Overview 13

Reasoning About Concurrent Systems Is Hard n n n Very hard to predict all Reasoning About Concurrent Systems Is Hard n n n Very hard to predict all possible ways in which thread execution steps can be interleaved. Often hard to determine/predict what sequences of actions the environment of a system may generate. If you’re not convinced, let’s consider a few very small examples… CIS 842: Course Overview 14

Reasoning About Concurrent Systems is Hard class Job extends Thread { Container objref; Object Reasoning About Concurrent Systems is Hard class Job extends Thread { Container objref; Object x; public Job incr () { synchronized (objref) { objref. counter = objref. counter + 1; } return this; } public void setref(Container o) { objref = o; } public void run() { for (int i=0; i++; i<3) { incr(); } } } class Container { public int counter; } class Apprentice { public static void main(String[] args) { Container c 1 = new Container(); Container c 2 = new Container(); Job j 1 = new Job(); Job j 2 = new Job(); j 1. setref(c 2); j 2. setref(c 1); j 1. start(); j 2. start(); j 1. setref(c 1); } } } Does the value of counter ever decrease? CIS 842: Course Overview Source: J. S. Moore, George Porter “Proving Properties of Java Threads”. 15

Reasoning About Concurrent Systems is Hard 1 2 3 4 5 6 7 8 Reasoning About Concurrent Systems is Hard 1 2 3 4 5 6 7 8 9 10 11 Boolean array b(0; 1) integer k, i, j; comment process i, with i either 0 or 1 and j = 1 – i; C 0: b(i) : = false; C 1: if k != i then begin C 2: if not (b(j) then go to C 2; else k : = i; go to C 1 end; else critical section b(i) : = true; remainder of program; go to C 0; end Consider two processes 0 and 1 each running the pseudo-code above. Does the code guarantee mutual exclusion of the critical section (i. e. , does the code ensure that the two processes can never be in the respective critical sections at the same time)? CIS 842: Course Overview Source: Comm. of the ACM, Vol. 9, No. 1, p. 45 16

For You To Do… n n Pause the lecture. Study the examples on the For You To Do… n n Pause the lecture. Study the examples on the previous two slides, answer the question given at the bottom of each slide and be able to justify your answer. CIS 842: Course Overview 17

Classes of Requirements n Safety Requirement n n The system never reaches a “bad Classes of Requirements n Safety Requirement n n The system never reaches a “bad state” Liveness Requirement n The system eventually arrives at a “good state” Requirements for concurrent systems often take one of these two forms. CIS 842: Course Overview 18

Safety Requirements The system never reaches a “bad state” n n n The system Safety Requirements The system never reaches a “bad state” n n n The system never reaches a state where the current value of the counter is less its value in a previous state. The system never reaches a state where both process are in their critical regions at the same time. Any invariant… n Variable x is always greater than 5 n n “bad state” In other words, the system never reaches a state where x is not greater than 5 The system never reaches a deadlocked state CIS 842: Course Overview 19

Liveness Requirements The system eventually reaches a “good state” n n n The system Liveness Requirements The system eventually reaches a “good state” n n n The system eventually reaches a point where it terminates (no further step is possible). If a button is pushed, the system eventually reaches a state where an acknowledgement is sent. A enabled process is not infinitely delayed in execution (freedom from livelock and starvation). Any process that wishes to enter its critical section will eventually succeed. A process that has a resource will eventually release it. Identify the good states in each of the above requirements. CIS 842: Course Overview 20

Goal: Increase Software Reliability Trends: Size, complexity, concurrency, distributed Cost of software engineer……………. Cost Goal: Increase Software Reliability Trends: Size, complexity, concurrency, distributed Cost of software engineer……………. Cost of CPU cycle………………. . Future: Automated Fault Detection CIS 842: Course Overview 21

The Dream void add(Object o) { buffer[head] = o; head = (head+1)%size; } Object The Dream void add(Object o) { buffer[head] = o; head = (head+1)%size; } Object take() { … tail=(tail+1)%size; return buffer[tail]; } OK Program Property 1: … Property 2: … … or Checker Error trace Requirement CIS 842: Course Overview 22

Model Checking OK Finite-state model or Model Checker (F W) Temporal logic formula CIS Model Checking OK Finite-state model or Model Checker (F W) Temporal logic formula CIS 842: Course Overview Error trace Line Line … Line 5: … 12: … 15: … 21: … 25: … 27: … 41: … 47: … 23

A Success In Hardware n Every major hardware manufacturer uses model-checking in their quality A Success In Hardware n Every major hardware manufacturer uses model-checking in their quality assurance process n n AT&T, Cadence, Fujitsu, HP, IBM, Intel, Motorola, NEC, SGI, Siemens, Sun Example successes n n n Gigamax distributed muli-processor IEEE Futurebus+ standard Cray SV 1 Supercomputer memory arbiter CIS 842: Course Overview 24

Why Try to Use Model Checking for Software? n Automatically check, e. g. , Why Try to Use Model Checking for Software? n Automatically check, e. g. , n invariants, simple safety & liveness properties n absence of dead-lock and live-lock n complex event-sequencing properties “Between the window open and the window close, button X can be pushed at most twice. ” In contrast to testing, gives complete coverage by exhaustively exploring all paths in system, n It’s been used for years with good success in hardware and protocol design This suggests that model-checking can complement existing software quality assurance techniques. n CIS 842: Course Overview 25

Software Model-checking Efforts n Lucent/Bell Labs (Spin) NASA (Java Path. Finder) Microsoft Research (SLAM) Software Model-checking Efforts n Lucent/Bell Labs (Spin) NASA (Java Path. Finder) Microsoft Research (SLAM) IBM (CANVAS) UC Berkeley (BLAST) Kansas State (Bandera) n …several other projects from academia n n n CIS 842: Course Overview 26

Spin n Developed at Lucent/Bell Labs by Gerard Holzmann n n http: //netlib. bell-labs. Spin n Developed at Lucent/Bell Labs by Gerard Holzmann n n http: //netlib. bell-labs. com/netlib/spin/whatispin. html Most widely-used model-checking tool Designed primarily for protocol verification Been used in major industrial telephony applications (e. g. Path. Star) Winner of the 2001 ACM Software Award n n for software that has had a lasting influence, reflected in contributions to concepts, in commercial acceptance, or both. Unix, TCP/IP, Apache were previous recipients. CIS 842: Course Overview 27

Java Path. Finder (JPF) n Developed at NASA Ames Automated Software Engineering Lab n Java Path. Finder (JPF) n Developed at NASA Ames Automated Software Engineering Lab n n http: //ase. arc. nasa. gov/visser/jpf/ Works directly on Java byte-code Includes several interesting heuristic search strategies Being in several case-studies involving safety and mission-critical software CIS 842: Course Overview 28

SLAM n Developed at Microsoft Research n n http: //www. research. microsoft. com/projects/slam/ Works SLAM n Developed at Microsoft Research n n http: //www. research. microsoft. com/projects/slam/ Works on sequential C code Targeted toward verification of Windows device drivers Includes interesting automated abstraction and refinement facilities CIS 842: Course Overview 29

Canvas n Developed at IBM’s T. J. Watson Research Center n n n http: Canvas n Developed at IBM’s T. J. Watson Research Center n n n http: //researchweb. watson. ibm. com/menage/canvas/ Targeted toward verification of Java components Includes interesting automated abstraction techniques CIS 842: Course Overview 30

Bandera n Developed at Kansas State University n n n http: //www. cis. ksu. Bandera n Developed at Kansas State University n n n http: //www. cis. ksu. edu/bandera Translates concurrent Java programs to model descriptions that can be processed by several different model-checkers (including Spin and JPF) Includes a number of interesting modelreduction techniques including slicing and data abstraction, as well as other facilities for property specification and counter-example visualization CIS 842: Course Overview 31

How does one describe systems to a model-checker? n Hand-coded model built using the How does one describe systems to a model-checker? n Hand-coded model built using the high-level system description language of a modelchecking tool n n Source Code n n We will use this approach with Spin We will use this approach with Bandera Other possibilities n n formal requirements, partial behavioral descriptions (UML collaboration diagrams & sequence charts), etc. we will not consider these in detail in this course CIS 842: Course Overview 32

SPIN Example #define N 5 #define I 3 #define L 10 Fragment of Promela SPIN Example #define N 5 #define I 3 #define L 10 Fragment of Promela specification of Leader Election protocol mtype = { one, two, winner }; chan q[N] = [L] of { mtype, byte}; byte nr_leaders = 0; proctype node (chan in, out; byte mynumber) { bit Active = 1, know_winner = 0; byte nr, maximum = mynumber, neighbour. R; xr in; xs out; end: CIS 842: Course Overview /* nr of processes (use 5 for demos) */ /* node given the smallest number */ /* size of buffer (>= 2*N) */ printf("MSC: %dn", mynumber); out!one(mynumber); do : : in? one(nr) -> if : : Active -> if : : nr != maximum -> out!two(nr); neighbour. R = nr : : else -> assert(nr == N); know_winner = 1; out!winner, nr; fi : : else -> out!one(nr) fi 33

How does one describe systems to a model-checker? n Temporal Logic n n n How does one describe systems to a model-checker? n Temporal Logic n n n Temporal Specification Patterns n n pattern-based approach to constructing specifications Automata (“never claims”) n n n Linear Temporal Logic (LTL) Computation Tree Logic (CTL) graphical textual Other graphical notations n n Timeline Editor (from Lucent) Graphical Interval Logic CIS 842: Course Overview 34

LTL Examples Requirement: For any state, a request (for some resource) will eventually be LTL Examples Requirement: For any state, a request (for some resource) will eventually be acknowledged Formal LTL Specification [](requested -> <> acknowledged) Requirement: An upwards travelling elevator at the second floor does not changes its direction when it has passengers waiting to go to the fifth floor Formal LTL Specification CIS 842: Course Overview []((floor=2 && direction=up && button 5 pressed) -> [direction=up U floor=5]) 35

Specification Pattern Examples Requirement: If a buffer becomes full, it will eventually become non-full. Specification Pattern Examples Requirement: If a buffer becomes full, it will eventually become non-full. Requirement: Empty buffers must added to before being taken from Bandera Specification: Full. To. Non. Full: forall[b: Bounded. Buffer]. {!Full(b)} responds to {Full(b)} globally; No. Take. While. Empty: forall[b: Bounded. Buffer]. {take. Return(b)} is absent after {Empty(b)} until {add. Call(b)}; CIS 842: Course Overview 36

SPIN Never-claim Example Requirement: LTL formalization: Never-claim formalization: CIS 842: Course Overview Eventually, the SPIN Never-claim Example Requirement: LTL formalization: Never-claim formalization: CIS 842: Course Overview Eventually, the system will arrive at a state where there is always exactly one leader. <>[]one. Leader #define one. Leader (nr_leaders == 1) never { T 0_init: /* !(<>[]one. Leader) */ if : : (1) -> goto T 0_init : : (! ((one. Leader))) -> goto accept_S 5 fi; accept_S 5: if : : (1) -> goto T 0_init fi; accept_all: skip } 37

Timeline Edit w/ Automaton Trigger event Required event …with condition “Monitoring” automaton CIS 842: Timeline Edit w/ Automaton Trigger event Required event …with condition “Monitoring” automaton CIS 842: Course Overview 38

When is Model-checking Applied? Requirements Analysis Hand-crafted design models using e. g. , Spin When is Model-checking Applied? Requirements Analysis Hand-crafted design models using e. g. , Spin Design Automatically generated models using Bandera, SLAM, etc. Code and Unit Test Hand-translated models from code and apply e. g. , Spin Subsystem Test Software Development Stages CIS 842: Course Overview System Test 39

When is Model-checking Applied? n Many opportunities n Requirements analysis n n Design n When is Model-checking Applied? n Many opportunities n Requirements analysis n n Design n e. g. , checking properties of design notations such as UML statecharts crafting design models in the input notations of model-checking tools such as Spin Code unit testing n n n e. g. , checking properties of message sequence charts check code directly using Bandera, JPF, etc. create a hand-crafted model by inspecting the code (less common these days) Code integration testing n n again, check code directly using Bandera, etc. (less common because model-checking is expensive and is best applied to code units) checking that code conforms to interface specifications (hot research area) CIS 842: Course Overview 40

Course Objectives n n n Understand the challenges involved with designing concurrent/reactive software Be Course Objectives n n n Understand the challenges involved with designing concurrent/reactive software Be able to formalize typical requirements of concurrent systems in the various specification formalisms processed by model-checking tools Be able to effectively apply a modeling tool like Spin in the process of designing concurrent systems Be able to effectively apply a tool like Bandera or JPF to check properties of concurrent Java implementations Know the basic algorithms and implementation strategies for explicit-state model-checking to the point where you could code your own simple model-checker CIS 842: Course Overview 41

In this course. . . n You will study various tools and techniques for In this course. . . n You will study various tools and techniques for debugging and verifying properties of concurrent systems (software, in particular). n n BOGOR: an extensible model-checker designed for checking OO software Bandera: tool set designed for model-checking concurrent Java software CIS 842: Course Overview 42

In this course. . . n You will learn the basic algorithms and data In this course. . . n You will learn the basic algorithms and data structures used in a model-checker n n n You will program several versions of Bogor Programming assignments using Java You will study the formal semantics of various abstraction and slicing techniques used for software model-checking CIS 842: Course Overview 43

In this course. . . n In mini-project components, you will apply Bogor to In this course. . . n In mini-project components, you will apply Bogor to check properties of medium-size Java systems. n n Formalize system requirements in e. g. , Bandera’s specification language Identify appropriate code units and test harnesses for to be used in checking Perform abstractions and other model-reduction techniques required for obtaining a tractable model Write multiple documents describing each phase of the project CIS 842: Course Overview 44

Summary n n n Software is becoming pervasive and very complex Model-checking is an Summary n n n Software is becoming pervasive and very complex Model-checking is an effective technique for modeling, debugging, and verifying properties of concurrent systems Multiple projects are attempting to apply modelchecking throughout the development process We will learn the basic principles of explicit state model-checking and methods for applying it effectively to real-world concurrent software Explore current research topics that may impact the future of software model-checking CIS 842: Course Overview 45

Acknowledgements n n See course web page for interesting short articles about the famous Acknowledgements n n See course web page for interesting short articles about the famous software failures mentioned in this lecture. See The Temporal Logic of Reactive and Concurrent Systems: Specification by Manna and Pnueli (Springer-Verlag) for an excellent and extensive discussion on safety and liveness properties (pp. 302 -337). CIS 842: Course Overview 46