symbolic model checking for large software specifications

50
Symbolic Model Checking for Large Software Specifications David Notkin ([email protected]) Dept. of Computer Science & Engineering University of Washington April 2001

Upload: arnold

Post on 25-Feb-2016

48 views

Category:

Documents


2 download

DESCRIPTION

Symbolic Model Checking for Large Software Specifications. David Notkin ([email protected]) Dept. of Computer Science & Engineering University of Washington April 2001. William Chan (1972-1999). Recipient of 2000 ACM Doctoral Dissertation Award Honorable Mention. Other Collaborators. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Symbolic Model Checking for  Large Software Specifications

Symbolic Model Checking for Large Software SpecificationsDavid Notkin ([email protected])Dept. of Computer Science & EngineeringUniversity of WashingtonApril 2001

Page 2: Symbolic Model Checking for  Large Software Specifications

William Chan (1972-1999)

Recipient of 2000 ACM Doctoral Dissertation Award Honorable

Mention

Page 3: Symbolic Model Checking for  Large Software Specifications

Other CollaboratorsRichard AndersonPaul BeameSteve BurnsFrancesmary ModugnoDavid Jones (Boeing)Jon D. ReeseWilliam Warner (Boeing)

Page 4: Symbolic Model Checking for  Large Software Specifications

MotivationHow to increase confidence in correctness of safety-critical software?Existing techniques are limited to some degree

Inspection Syntactic check Simulation/testing Theorem proving

Symbolic model checking successful for industrial hardware

Effective also for software? Many people’s conjecture: No

Page 5: Symbolic Model Checking for  Large Software Specifications

Temporal-Logic Model Checking [Clarke & Emerson 81]

M odelChecker FALSE

(w ith counterexam ple)

TRUE

StateM achine

Behaviora lP roperty

Some properties expressible in temporal logics Error states not reached (invariant)

Ex: AG ¬Err Today’s focus Eventually ack for each request (liveness)

AG (Req AF Ack) Always possible to restart machine (possibility)

AG EF Restart

Page 6: Symbolic Model Checking for  Large Software Specifications

Two Approaches to Model Checking

Explicit Conventional state-space search: depth-first,

breadth-first, etc. Needs substantial manual abstraction and

state reductionSymbolic Can search huge state spaces (e.g. 1020) Practical for many industrial hardware circuits Provably bad for certain arithmetic operations Not believed to work well for software

Page 7: Symbolic Model Checking for  Large Software Specifications

Software Experts Say“The time and space complexity of the symbolic approach is affected…by the regularity of specification. Software requirements specifications lack this necessary regular structure…” [Heimdahl & Leveson 96]

Page 8: Symbolic Model Checking for  Large Software Specifications

And say…“[Symbolic model checking] works well for hardware designs with regular logical structures…However, it is less likely to achieve similar reductions in software specifications whose logical structures are less regular.” [Cheung & Kramer 99]

Page 9: Symbolic Model Checking for  Large Software Specifications

Model Checking Co-Inventor Says

“…[symbolic model checkers] are often able to exploit the regularity…in many hardware designs. Because software typically lacks this regularity, [symbolic] model checking seems much less helpful for software verification.” [Emerson 97]

Page 10: Symbolic Model Checking for  Large Software Specifications

ContributionsCase Studies: successfully analyzed state-machine specifications of

TCAS II (aircraft collision avoidance system) [FSE 96, TSE 98]

Electrical power distribution (EPD) system on Boeing 777 [ICSE 99, TSE 01]

Optimizations: obtained orders-of-magnitude speedup [ISSTA 98, ICSE 99, TSE 01]

Developed intuitions about efficiency Enabled difficult analyses

Extension: handle complicated arithmetic Combine with a constraint-satisfaction engine [CAV 97] Not addressed today

Page 11: Symbolic Model Checking for  Large Software Specifications

OutlineBackground Symbolic model checking and state-

machine specificationsCase studies TCAS II and EPDOptimizations Two techniques to improve efficiency

Page 12: Symbolic Model Checking for  Large Software Specifications

Invariant Checking as Set Manipulations

Compute Yi+1 = Pre (Yi) Yi

Check if Yn Init =

Y 0 = E rrY 1...Y n-1Y n = Y n-1Y n = Y n-1

In it

States thatcan reach an

Error S tate

ErrorS tates

Backward breadth-first search

Page 13: Symbolic Model Checking for  Large Software Specifications

Explicit vs. Implicit (Symbolic Sets)

All even numbers between 0 and 127 Explicit representation

0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126.

Implicit (symbolic) representation ¬x0 (x0: least significant bit)

Need efficient Boolean-function representation

Page 14: Symbolic Model Checking for  Large Software Specifications

Symbolic Model Checking [Burch et al. 90, Coudert et al. 89]

Define Boolean state variables X e.g., define xn-1, xn-2, …, x0 for an n-bit integer.A state set becomes a Boolean function S(X) e.g., x0 for the set of n-bit even integers.Set operations (,)become Boolean operations (,)Transition relation: R(X,X).Compute predecessors also using Boolean operations Pre (S) = X’. S(X’) R(X,X’)

Page 15: Symbolic Model Checking for  Large Software Specifications

Binary Decision Diagrams (BDDs) [Bryant 86]

DAGs, evaluated like binary decision trees.Efficiency depends on BDD size

Usually small; some large hardware circuits can be handled

Some well-known limitations

e.g., exponential size fora > bc

Few theoretical results known

Performance unpredictable

01

1 1

1 10

10

1 1

0

0

x1

x4

x3

x2

O dd Parity

Page 16: Symbolic Model Checking for  Large Software Specifications

Symbolic Model Checking Ineffective for Software?

This common view may be true for software like multi-threaded programs, but…

Hardware SoftwareData Simple Complex

States Finite InfiniteConcurrency Synchronous Asynchronou

sStrategy Symbolic

searchAbstraction and explicit

search

Page 17: Symbolic Model Checking for  Large Software Specifications

Consider Safety-Critical Software

Most costly bugs in specificationUse analyzable formal specification State-machine specifications Intuitive to domain experts like

aircraft engineers Statecharts [Harel 87], RSML

[Leveson et al. 94], SCR [Parnas et al.], etc.

Page 18: Symbolic Model Checking for  Large Software Specifications

Model-Check the Spec!

Symbolic model checking good for such specs?Develop more intuitions about efficiency? Optimize analyses?How to handle arithmetic?

Hardware Spec Multi-threaded

CodeData Simple Simple (except

arithmetic)Often

complexStates Finite Finite (except

arithmetic)Possibly infinite

Concurrency Synchronous Synchronous Asynchronous

Page 19: Symbolic Model Checking for  Large Software Specifications

RoadmapBackgroundCase studies: TCAS II and EPD Brief descriptions Results of analysesOptimizations

Page 20: Symbolic Model Checking for  Large Software Specifications

Case Study 1: TCAS IITraffic Alert and Collision Avoidance System Reduce mid-air collisions

Warns pilots of traffic Issues resolution advisories

Required on most commercial aircraft “One of the most complex systems on

commercial aircraft.”400-page specification reverse-engineered from pseudo-codeWritten in RSML by Leveson et al., based on statecharts

Page 21: Symbolic Model Checking for  Large Software Specifications

Case Study 2: EPD SystemElectrical Power Distribution system used on Boeing 777Distribute power from sources to buses via circuit breakers

Tolerate failures in power sources and circuit breakersPrototype specification in statechartsAnalysis joint with Jones and Warner of Boeing

LG en RG en ...

LM ain R m ain ...

power sources

power buses

circu it breakers

LG en R G en ...

LM ain Rm ain ...

Page 22: Symbolic Model Checking for  Large Software Specifications

Model Check the Specifications

M odelC hecker FALSE

(w ith counterexam ple)

TRUE

Booleanencoding

Behaviora lP roperty

Spec

(w ith sim pleabstraction)

Page 23: Symbolic Model Checking for  Large Software Specifications

Translation to SMV

0 1

x[c]/y

0 1

y

A

B

VARA: {0,1};x: boolean;y: boolean;

ASSIGNinit (A):= 0;next (A):= case A=0 & x & c : 1; 1 : A; esac;init (y) := 0;next (y) := A=0 & x & c;

Page 24: Symbolic Model Checking for  Large Software Specifications

Analyses and ResultsUsed and modified SMV [McMillan 93]

Optimizations crucial for successful model checking

TCAS II EPD SystemState space 230 bits, 1060 states 90 bits, 1027

statesPrior verification inspection,

static analysissimulation

Problems we found

inconsistent outputs, safety violations, etc.

violations of fault tolerance

Page 25: Symbolic Model Checking for  Large Software Specifications

Some Formulas CheckedTCAS II Descent inhibition

AG (Alt < 1000 Descend) Output agreement

AG (GoalRate 0 Descent)EPD system AG (NoFailures

(LMain RMain LBackup RBackup)) AG (AtMostOneFailure (LMain RMain)) AG (AtMostTwoFailures (LBackup

RBackup))

Page 26: Symbolic Model Checking for  Large Software Specifications

A Counterexample FoundA single failure can cause a bus to lose power

1. Power-up sequence; normal operation2. A circuit breaker fails3. Other circuit breakers reconfigured to

maintain power4. User changes some inputs5. The first circuit breaker recovers6. User turns off a generator7. A bus loses power

This error does not exist in onboard system

Page 27: Symbolic Model Checking for  Large Software Specifications

RoadmapBackgroundCase studiesOptimizations Pruning backward search Restructuring to increase regularity

Page 28: Symbolic Model Checking for  Large Software Specifications

Environmental Model

m acrostep

m icrosteps

inputs outputs

Synchrony hypothesis No new inputs within macrostep Macrostep encoded as a sequence of transitions Statecharts, Esterel [Berry & Gonthier 92], Lustre

[Halbwachs et al. 92], etc.

Page 29: Symbolic Model Checking for  Large Software Specifications

Synchronization in Statecharts

0 1

x[c]/y

0 1

y

A

B

Event-drivenLabel: trigger[guard]/action

Page 30: Symbolic Model Checking for  Large Software Specifications

Forward vs. Backward Search

Generally unclear which is betterForward search Often good for low-level hardware But always bad for us; large BDDsFocus on backward search

Page 31: Symbolic Model Checking for  Large Software Specifications

A Disadvantage of Backward Search

Visiting unreachable states

Y 0Y 1

Y 2

R eachable S tates

Page 32: Symbolic Model Checking for  Large Software Specifications

Use Known Invariants for Pruning

Need known invariants that are small as BDDs and effective in reducing BDD size

Y 0Y 1

Y 2

Reachable S tates

Invariant

Page 33: Symbolic Model Checking for  Large Software Specifications

Optimization 1: Mutual Exclusion of Transitions

0 1

x[c]/y

0 1

y

A

B

Many “concurrent” transitions are sequential Determine using

static analysisUse this to prune backward search

Page 34: Symbolic Model Checking for  Large Software Specifications

Overall Effects on TCAS II

0123456789

10

Min.

P1 P2 P3 P4 P5 P6

Without pruningWith pruning

>> 1 hour

Page 35: Symbolic Model Checking for  Large Software Specifications

Initial EPD Analyses FailedEven though it has fewer states than TCAS II

Main difference in synchronization

TCAS II EPD SystemState space 230 bits, 1060

states90 bits, 1027

states

Page 36: Symbolic Model Checking for  Large Software Specifications

Oblivious Synchronization (used in TCAS II)

A

B

0 1

x[c]/y

x[c]/yx[c]/y x[c]/y

0 1

y[A in 1]

y[A in 0]y[A in 0] y[A in 1]

y signals completion of machine A Macrostep length: 2 x y stable

Page 37: Symbolic Model Checking for  Large Software Specifications

Non-Oblivious Synchronization (used in EPD)

0 1

x[c]/y

0 1

y

A

B

y signals state change in machine AMacrostep length: 1 or 2

x y stable x stable

Page 38: Symbolic Model Checking for  Large Software Specifications

Oblivious Synchronization: General Case

Event sequence always identical Thus, every macrostep has the same length

x y,z w z

x y,z w z

x y,z w z

Page 39: Symbolic Model Checking for  Large Software Specifications

Backward Search for Oblivious Synchronization

Yields small BDDs

x y,z w z

x y,z w z

x y,z w z

Page 40: Symbolic Model Checking for  Large Software Specifications

Non-Oblivious Synchronization: General Case

Macrosteps may have different lengths.

x y,z w z

x w z

x

Page 41: Symbolic Model Checking for  Large Software Specifications

Backward Search for Non-Oblivious Synchronization

Larger BDDs

x y,z w z

x w z

x

Page 42: Symbolic Model Checking for  Large Software Specifications

Optimization 2: Restoring Regularity in State Sets [ICSE 99]

Automatic semantics-preserving transformationAdd stuttering statesPreserve most properties, e.g., invariants and eventualities [Lamport 83, Browne et al. 89]

Page 43: Symbolic Model Checking for  Large Software Specifications

New Backward SearchMake every macrostep equal in

length. Smaller BDDsIncrease # states and # state

variablesIncrease # iterations to reach

fixed points

Page 44: Symbolic Model Checking for  Large Software Specifications

Effects on BDD Size for Reached States

without transformation7137009400600006900001100000space out

with transformation459319027038056010002000…1200015000210003200068000 peak size

Page 45: Symbolic Model Checking for  Large Software Specifications

Summary of OptimizationsPruning backward search. Mutual exclusion of transitions/events

Semantics-preserving transformation to restore regularity Synchronization matters

Exploit high-level knowledgeCombine with static analysisResult in dramatic improvements and make hard analyses feasible

Page 46: Symbolic Model Checking for  Large Software Specifications

Other Optimizations [ISSTA 98]

Partition transition relation in various ways Use multiple BDDs for transition relation

Abstract automatically be dependency analysis Remove part of system that can’t affect

resultImprove counter-example search Avoid work in forward search

Page 47: Symbolic Model Checking for  Large Software Specifications

SummaryBDD-based model checking for state-machine specifications

Two significant data points Discovered errors not found by other static/dynamic

analyses Need to pay attention to BDD blowup

Exploit high-level knowledge of system Dramatic improvements possible

Combine BDDs and constraint satisfaction for complicated arithmetic

Not addressed today; primarily theoretical Hope is to broaden the range of systems that can be

handled

Page 48: Symbolic Model Checking for  Large Software Specifications

Some Lessons LearnedFocus on restricted models that people care aboutExploit high-level knowledge to improve analysis Synchronization, environmental assumptions, etc. In addition to low-level BDD tricks

Combine static analysis and symbolic model checkingHelp understand system behaviors In addition to verification/falsification

Page 49: Symbolic Model Checking for  Large Software Specifications

How General are the Techniques?

Optimizations specific to events, macrosteps, and the synchrony hypothesis Maybe applicable to synchronous

programming languagesCombining forward static analysis and backward symbolic search Seems promising

Constraint-satisfaction approach Applicable if environment not constrained

Page 50: Symbolic Model Checking for  Large Software Specifications

Future WorkApply model checking to mainstream software Bridge gap between model and code Integrate with OO modeling techniques Combine structural and behavioral analyses

Support system understanding directly e.g., infer temporal properties

Investigate symbolic model checking vs. conventional program analysis Combine ideas from two areas

Increase reliability and productivity