Run-time Verification
Oleg Sokolsky
CIS 673 Fall 2006
Run-time Verification Oleg Sokolsky CIS 673 Fall 2006 Outline - - PowerPoint PPT Presentation
Run-time Verification Oleg Sokolsky CIS 673 Fall 2006 Outline Motivation and overview Why run-time verification Formal methods and run-time verification Property specification Incremental property checking MaC
CIS 673 Fall 2006
Run-time verification
► Motivation and overview
► MaC framework ► Applications
Run-time verification
► Run of a large system – real or simulated –
► How do we make sense of a simulation run? ► Different aspects may be interesting:
► Each of these questions is a property that needs
Run-time verification
► Behavioral
► Timing
► Quality of service
Run-time verification
► By direct observation
► By a custom checker
► By a checker for a suitable property specification
Run-time verification
► Specification
► Verification
► Satisfaction relation ► Model checking
Run-time verification
► Describe evolving systems, that go through
► Behavioral properties
► Quantitative properties
Run-time verification
Run-time verification
► “Garbage in, garbage out”
► Only small models can be exhaustively analyzed
► Only simple models can be refined into code
Run-time verification
► Compared to model checking, there is no model
► Trace extraction is easier than model extraction
► Property checking on a trace is easier than over
► Obviously, a weaker result is proved
Run-time verification
Run-time verification
► Formulas in a temporal logic ► Always evaluated over a finite execution trace ► Safety properties
► Liveness properties
trace ► We will consider safety properties only
Run-time verification
► Satisfaction relation
► Simple algorithm, linear in the trace length ► At each step, trace becomes longer
► Furthermore, traces are too big to store ► Need a different approach
Run-time verification
► In fact, we do not need to check the whole trace
► Keep a checker state
► Upon each observation, update
► When a “verdict”
checker state
Run-time verification
► Checker state need not be all boolean ► Auxiliary variables can store
► Predicates over auxiliary variables can be used
► “Verdict” states can also report values stored in
Run-time verification
► Ultimately, properties determine what
► System requirements are high-level and
► Run-time observations are low-level and
– Software: variable assignments, function calls, exceptions, etc. – Network: send, receive, route packets, update routing tables, etc. ► Need an abstraction layer to match the two
Run-time verification
► Too much information is just too much!
► Too little information is a problem, too
Run-time verification
► Simulation of a railroad crossing ► Requirement: train in crossing => gate is down ► Observations:
Run-time verification
► Motivation and overview ► MaC framework
► Applications
Run-time verification
► Designed at U. Penn since 1998 ► Components:
► Prototype implementation
Run-time verification
Program
Program
MaC Compilers Properties in MaC Language
Monitor Checker
MaC Verifiers
low-level information high-level information
Filter
Instrumentor
alarms
feedback
SADL MEDL PEDL
Run-time verification
► PEDL: Primitive Event Definition Language – abstraction ► MEDL: Meta Event Definition Language – abstract transformation ► SADL: Steering Action Definition Language – feedback
Run-time verification
► Natural distinction for monitoring properties:
► Motivations for the distinction:
► What is the value between trace states?
Run-time verification
► The war is a condition ► Battles are events
► Events change the state of conditions
1337 1453 1346 1356 1415
Battle of Crecy Battle of Poitiers Battle of Agincourt Fall of Paris Fall of Bordeaux Declaration
1436
Run-time verification
► LEC: 2-sorted logic: events and conditions ► Syntax: ► Operator [., .) pairs events to define an interval ► Operators start and end define the events at the
2 1 2 1 2 1 2 1 2 1
e1 e2 [e1, e2) start([e1, e2)) [e1,e2) end([e1,e2))
Run-time verification
► Interval operator: [e1,e2)
► When operator
false false true
e1 e2
Time
[e1,e2) [e1,e2) [e1,e2) c = false c = false c = true
e when c e
Time
e
Run-time verification
► Formally, a model M = (S, τ, LC, LE)
► M, t ╞ c means a condition c being true in a
► M, t ╞ e means an event e occurring in a model M
Run-time verification
► An execution trace M = (S, τ, LC, LE) is viewed as
► Each world has descriptions of:
LC(s0, (position == 0) ) = true τ(s0) = 0 LE(s0, startTrain) = defined LC(s0, (position >= 50) ) = false
LC(s0, (position == 0) ) = false τ(s0) = 0.1 LE(s0, raiseGate) = defined LC(s0, (position >= 50) ) = false
Run-time verification
next slide
Run-time verification
Run-time verification
► Primitive Event Definition Language ► Low-level specification ► Dependent on underlying applications ► Principles
► Reason only about the current state in the
Run-time verification
► Declaration of monitored variables ► Definitions of primitive conditions
► Definitions of primitive events
Run-time verification
Abstraction
export event gateDown, raiseGate; export condition cross; monobj Train.position; monmeth Gate.up(); monmeth Gate.down(); condition cross = (30 < RRC.position) && (RRC.position < 50); event gateDown = endM(Gate.down()); event raiseGate = startM(Gate.up()); position = 0 position = 20 position = 30 ret Gate.down() position = 50 call Gate.up() position = 60 gateDown raiseGate
cross
System PEDL
Run-time verification
► Meta Event Definition Language ► Express requirements using the events and
► Describe the safety requirements
► Independent of the monitored system
Run-time verification
PEDL MEDL
import event gateDown, gateUp, raiseGate, lowerGate; import conditions cross; condition gateClosed = [gateDown, raiseGate); property safeRRC = cross gateClosed; gateDown raiseGate
cross Violation gateClosed cross
Railroad Crossing Property: - If train is crossing, then gate must be closed
Run-time verification
► Timestamps of events
► Event attributes
► Auxiliary variables
var int raiseCnt gateUp { raiseCnt’ = raiseCnt + 1 } alarm svcGate = start( raiseCnt > 1000 )
Run-time verification
► Event attributes allow us to propagate quantitative
► Some events have implicit attributes
► In general, we can associate any value in the
event newTrain(int tr, real w) = StartM(addTrain(t,weight)) {tr:=t,w:=weight} ► An event attribute can be used in expressions as newTrain { totalWght’ = totalWght + newTrain.w }
Run-time verification
► Static phase
► Dynamic phase
Property Compile Internal representation
static phase
Load
dynamic phase
ER / Checker
Run-time verification
► Each event and condition is a node
► Composition is represented by operator nodes
► Graphs cannot have algebraic loops e1=e1||e2
e1=start([e2, end[e1 when c, e3))) OK
condition event event2
event1 event1 || event2
Run-time verification
► Auxiliary variables and their updates are also
► Variable node stores the value of the variable
e { x’ = y + 1 } ► If an event triggers update of a variable, it cannot
► Algebraic loops are disallowed
x’ x’ = y + 1 y e
Run-time verification
export event gateDown, raiseGate; export condition cross; monobj Train.position; monmeth Gate.up(); monmeth Gate.down(); condition cross = (30 < RRC.position) && (RRC.position < 50); event gateDown = endM(Gate.down()); event raiseGate = startM(Gate.up());
raiseGate gateDown cross Gate.down() startM( Gate.up() ) endM(Gate.down()) 30 < position < 50 Gate.up() Train.position
Run-time verification
import event gateDown, gateUp, raiseGate, lowerGate; import conditions cross; condition gateClosed = [gateDown, raiseGate); property safeRRC = cross gateClosed;
gateClosed cross gateClosed safeRRC [gateDown,raiseGate) cross gateDown raiseGate
Run-time verification
► Consider an update on a monitored variable
– The evaluation in ER starts from the node representing Train.position, then, goes upward to the root – If the value cross changes and is exported, ER sends cross to Checker – The other two trees are not evaluated
position = 0 position = 20 position = 40 Gate.down() position = 55 Gate.up() position = 60
Gate.down() raiseGate startM( Gate.up() ) endM(Gate.down()) gateDown cross 30 < position < 50 Gate.up() Train.position
Run-time verification
► On each event received from ER,
– The evaluation starts from leaves (from the node corresponding to events received from ER) – Traverses upward to the root
► At roots, check for violations
– If an occurred event is in the alarm list, notify users – If a false condition is in the property list, notify users
startGD endGD
cross
cross = true cross = false
[gateDown,raiseGate) gateClosed cross gateClosed safeRRC
Violation gateDown cross
cross gateDown raiseGate
Run-time verification
► Steering
► Support for dynamic properties
Run-time verification
► Steering provides feedback from the monitor to
► Steering actions triggered by events SEviolation { invoke change2SC }
► SADL (Steering Action Definition Language)
Run-time verification
action invocation received steering condition satisfied violation
action executed
action invoked
detection
event received
Run-time verification
► Steering is not a recovery/adaptation mechanism
► System should be ready to receive feedback
► When can a system be effectively steered?
decreases
Run-time verification
► What if we have two tracks instead of one?
safeTrack1 = cross1 gateClosed safeTrack2 = cross2 gateClosed
► Works for toy examples
Run-time verification
► We introduce indexed names and implicitly
► New data type indexSet supports adding and
► Values are added by incoming events
indexSet tracks import event addTrack(tId t) property trackSafe(tId t) = cross(t) gateClosed addTrack { tracks.add( addTrack.t ) }
Run-time verification
► Explicit quantification and aggregation over index
► First-order temporal logics are highly
► At run time, we work with concrete values and
► In practice, dynamic MEDL has been sufficient
Run-time verification
► Motivation and overview ► MaC framework ► Applications
Run-time verification
► Verisim is an instantiation of the MaC
Run-time verification
► Routing for a wireless network without the aid of
► Connections are low-bandwidth, lossy, and
► Unique routing assumptions:
► Ad-hoc On-demand Distance Vectors (AODV)
Run-time verification
Run-time verification
Run-time verification
► Rules
► Can be stated as a state machine and model
Run-time verification
Configuration Parameters: OTcl Traffic Model: OTcl Topology: OTcl Scenario
P
N src/sink
P
N src/sink
P
N src/sink
Protocol Agents Network Model Traffic Agents Instrumented Protocol Code P : C++
Run-time verification
► Conventional analysis:
► Drawbacks:
Run-time verification
Node’s own sequence number never decreases
Monotone Seq No.
Route request for d should have seq. no. either 0 or the last seq. no. recorded for d
RREQ Seq No.
A route is sent along the best unexpired route
Node reply
Reply to route request should have hops field set to 0
Destination reply
A packet is forwarded along best unexpired route
Correct forward
Along every route to node d, (-seq_nod, hopsd) strictly decreases lexicographically
Loop Invariant
Broken route RREP is forwarded with the same seq. no.
Forward Route Err.
If broken route is detected, RREP increases seq. no.
Detect Route Err.
When a packer reaches destination, it should not be forwarded
Destination stops
Run-time verification
Run-time verification
► Bugs found
► Simulator is more efficient than checker on
Run-time verification
► Collaboration with NRL ► Construction of global
– F repulsive if r < R; else attractive – Pattern forms in close proximity
► Vulnerable to turbulence
– Size < 6’’, weight 50 – 70 gr
► Need external impulse to
Unmanned air vehicle (UAV) Using Artificial Physics, MAVs form a hexagonal lattice sensing grid
Run-time verification
MAV MAV MAV
Run-time verification
► Pattern formation:
► Pattern alarm: alerts count increases sharply
Run-time verification
► Monitor cannot address
– commands are broadcast
► Two steering actions are
– After a pattern alarm, repulsion between close MAVs is suspended. MAVs are drawn together – After a fixed interval, repulsion is restored, restarting the formation process Global MaC on UAV “suspend repulsion!”
Run-time verification
ReqSpec HexPattern import event MAValert, startPgm; var long currInterval; var int count0, count1, count2, prevAvg, currAvg; event startPeriod = start(time(MAValert) - currInterval > 10000); property NoPattern = (currAvg <= prevAvg*1.15 + 100) || (prevAvg == -1); startPgm -> { currInterval = time(startPgm); count0 = 0; prevAvg = -1; currAvg = -1; } startPeriod -> { currInterval = currInterval + 10000; prevAvg = currAvg; currAvg = (curr0+curr1+curr2)/3; count2 = count1; count1 = count0; count0 = 0; } MAValert -> { count0 = count0 + 1; } End
Run-time verification
suspend repulsion repulsion restore disruption
Run-time verification
► Simplex architecture for control systems provides
► Case study
Run-time verification
Experimental Controller Experimental Controller Decision Module Experimental Controller
J N I
monitor
Safety Controller
angle, track
Device Drivers Switching logic
volts steer
Run-time verification
► Analysis of logical and quality of service
► Specifying properties in a language with formal
► MaC is an architecture for monitoring and
► Several case studies testify to MaC’s utility
Run-time verification
►
[KKL+04] Java-MaC: a rigorous run-time assurance tool for Java programs, M. Kim, S. Kannan, I. Lee, O. Sokolsky, M. Viswanathan, Formal Methods in Systems Design,
– Comprehensive introduction to basic MaC
►
[SLS05] RT-MaC: Runtime monitoring and checking of quantitative and probabilistic properties, U. Sammapun, I. Lee and O. Sokolsky, Proceedings of the 11th IEEE International Conference on Embedded and Real-Time Computing Systems and Applications (RTCSA '05), August 2005
– MaC extensions for real-time and probability
►
[SSL05] Run-time checking of dynamic properties, O. Sokolsky, U. Sammapun, I. Lee, and J. Kim, Proceedings of the Fifth Workshop on Runtime Verification (RV '05), July 2005
– MaC extensions for dynamic properties
►
[BGK02] Verisim: Formal analysis of network simulations, K. Bhargavan, C. A. Gunter,
– Case study of AODV protocol simulation
►
[GSS99] Distributed spatial control, global monitoring and steering of mobile physical agents, D. Gordon, W. Spears, O. Sokolsky, and I. Lee. Proceedings of the IEEE International Conference on Information, Intelligence, and Systems, pp. 681-688, November 1999.
– Case study of MAV simulation