Title: Specifying Temporal Properties of Software Using the Bandera Specification Language
1Specifying Temporal Properties of Software Using
the Bandera Specification Language
U. Hawaii Kansas State Kansas State Kansas
State
- James Corbett
- Matthew Dwyer
- John Hatcliff
- Robby
http//www.cis.ksu.edu/santos/bandera
2BanderaAn open tool set for model-checking Java
source code
Slicing
Temporal Specification
Abstract Interpretation
Static Analysis
3Property Specification Problem
- Difficult to formalize a requirement in temporal
logic
Between the key being inserted and the key being
removed, the ignition can be activated at most
twice.
is rendered in LTL as...
((keyIn /\ ltgtkeyRem) -gt ((!activate /\
!keyRem) U (keyRem \/ ((activate /\ !keyRem)
U (keyRem \/ ((!activate /\ !keyRem) U
(keyRem \/ ((activate /\ !keyRem) U
(keyRem \/ (!activate U keyRem))))))))))
4Issue Checker Dependence
Checker Inputs
LTL
LTL
Temporal Specification
Model Checkers
Spin
5Issue Representation Dependence
Heap.b.head Heap.b.tail
(((_collect(heap_b) 1)\
(BoundedBuffer_col.instance_index(heap _b).head
BoundedBuffer_col.instance_inde
x(heap _b).tail) )\ ((_collect(heap _b)
3)\ (BoundedBuffer_col_0.instance_index(
heap _b).head
BoundedBuffer_col_0.instance_index(heap
_b).tail) )\ ((_collect(heap _b) 0)
TRAP))
6Issue Naming Heap-allocated Objects
Consider multiple instances of a bounded buffer
class...
Requirement
If a buffer instance becomes full, it will
eventually become non-full.
In general, a heap object has no program-level
name that persists throughout the lifetime of the
object.
7BSL Bandera Specification Language
- Propositions stated in terms of source code
features
- Temporal relationships are expressed using
field-tested specification patterns
- Heap objects are named via object quantification
Assertion Property Specification (selective
enabling)
Temporal Property Specification (via pattern
language)
Assertion Definition
Predicate Definition
8Bounded Buffer
class BoundedBuffer Object buffer int
head / next available slot / int tail
/ last available slot / int bound / max
of elements / public BoundedBuffer(int b)
public synchronized boolean isEmpty()
public synchronized void add(Object o)
public synchronized Object take ()
Add,Add
Add,Take,Take
9Bounded Buffer
public synchronized void add(Object o)
while ( tail head ) try wait()
catch (InterruptedException ex)
buffer_head o head (head1) bound
notifyAll() public synchronized Object
take() while (head ((tail1) bound))
try wait() catch
(InterruptedException ex) tail (tail1)
bound notifyAll() return
buffer_tail
10Bounded Buffer Properties
- Buffers are constructed with positive bounds
- Full buffers eventually become non-full
- Empty buffers must be added to before being taken
from - Indices always stay in range
- Elements are always added in correct position
11Reminder --- Language Structure
Assertion Property Specification (selective
enabling)
Temporal Property Specification (via pattern
language)
Assertion Definition
Predicate Definition
12Assertion Forms
class MyClass int count 0 /
_at_assert PRE foo (I gt 5) POST bar
(count gt 10) LOCATIONhere checka
(m.q.a 4) / public mymethod(int
I) here
13Assertion Checking
Requirement
/ _at_assert PRE PositiveBound (b
gt 0) /
Buffers are constructed with positive bounds
public BoundedBuffer(int b) bound b
buffer new Objectbound head 0 tail
bound-1
14Predicate Forms
15Pattern Hierarchy
(Dwyer, Avrunin, Corbett, ICSE99)
Property Patterns
Occurrence
Order
Absence
Bounded Existence
Chain Response
Precedence
Universality
Existence
Chain Precedence
Response
16Property Specification
/ _at_observable EXP Full (head
tail) /
class BoundedBuffer Object
buffer int head, tail, bound
public synchronized void add(Object o)
public synchronized Object take ()
forallbBoundedBuffer.
17Property Specification
/ _at_observable EXP Empty head
((tail1) bound) /
Requirement
Empty buffers must added to before being taken
from
class BoundedBuffer int head, tail, bound
public synchronized void add(Object o)
public synchronized Object take ()
/ _at_observable INVOKE Call /
/ _at_observable RETURN Return /
forallbBoundedBuffer.
18Quantification
- forallbBoundedBuffer.P(b)
- Quantified set (set of Bounded Buffers) is not
fixed!
- by adding a state variable (for b) that will
eventually be bound non-deterministically to each
instance
- by enabling checking of the formula only when
variable is bound to an instance
19Quantification (Contd)
(!selected U (selected P(b))) !selected
!selected
(!selected
(selected P(b)))
!selected
1 new BoundedBuffer(n)
new BoundedBuffer(n)
1 selected
!selected
2 new BoundedBuffer(m)
new BoundedBuffer(m)
new BoundedBuffer(m)
!selected
2 selected
1 selected
new BoundedBuffer(k)
3 new BoundedBuffer(k)
new BoundedBuffer(k)
new BoundedBuffer(k)
1 selected
2 selected
3 selected
!selected
20Quantification (Contd)
class heap public static BoundedBuffer
b class BoundedBuffer Object buffer
int head, tail, bound public
BoundedBuffer(int n) ... if (heap.b
null Bandera.choose())
heap.b this
class BoundedBuffer Object buffer int
head, tail, bound public
BoundedBuffer(int n) ...
21Quantification (Contd)
forallbBoundedBuffer. Full(b) leads to
!Full(b) globally
(heap.b null U (heap.b ! null
((heap.b.head heap.b.tail) -gt
ltgt(heap.b.head ! heap.b.tail)))) (heap.b
null)
22Next Steps Avionics Domain
- Case studies of avionics code leading to
domain-specific patterns - Working with Rockwell-Collins ATC as they
developing FAA coding guidelines for using OO in
avionics platforms (supplement to DO-178B) - Contains various restrictions on patterns of use
- Ultimately, use model-checking results as
evidence to help justify FAA certification
23Next Steps Richer Specifications
- Integration of BSL with the Java Modeling
Language (JML) developed by Gary Leavens at Iowa
State. - JML is also used as the specification language
for - ESC/Java (Compac)
- LOOP (Bart Jacobs)
- Compiles Java to PVS theories for complete
verification of source code. - In the long term, were interested in other forms
of verification.
24Next Steps Real-time Specifications
- Including notions of time in patterns
ltReadSensorgt responds to ltSensorInputgt within at
most ltKgt globally
where ltKgt is some number of time units
25Next Steps Other Specification Forms
- Compiling UML statecharts into Banderas
intermediate representation - Support specification of source code properties
via hierarchical state machines - Incorporate refinement checking at various levels.
inspiration from Rajeev Alur et. al.
26For more details
http//www.cis.ksu.edu/santos/bandera
- Public release of the tool set
- Tutorial with repository of simple examples
- Tutorial lecture slides
- Pattern web pages
27Property Specification
/ _at_observable EXP HeadRange head gt
0 head lt bound Exp TailRange tail gt
0 tail lt bound /
Requirement
Indices always stay in range.
class BoundedBuffer Object buffer int
head, tail, bound public
synchronized void add(Object o)
public synchronized Object take ()
forallbBoundedBuffer.
28Embedding Assertion
class BoundedBuffer Object buffer int
head, tail, bound public
BoundedBuffer(int n) public synchronized
void add(Object o)
/ _at_assertion PRE PosBound1 (n gt
0) /
public BoundedBuffer(int n) Bandera.assert(n
gt 0) ...
29Bounded Buffer
public BoundedBuffer(int b) bound b
buffer new Objectbound head 0
tail bound-1 public synchronized
boolean isEmpty() return head ((tail1)
bound)
30Test Result Assessments
Property Sliced Never-claim Stored
States
States BufferAssertions Yes - 17797 IndexRangeI
nv Yes 14 45215 IndexRangeInv,
BufferAssertions Yes 14
115387 FullToNonFull Yes 25 64687 FullToNonFull
, BufferAssertions Yes 25 154842
31Semantic Issues
_at_assert PRE ltnamegt ltexpgt
IMPLICATION holds if ltexpgt is true WHEN control
is at entry of method (true otherwise)
_at_observable INVOKE ltnamegt ltexpgt
CONJUNCTION holds if ltexpgt is true AND control
is at entry of method
32Methodology Property Specification
- Identify observables (propositions) in
requirement - Define propositions in source Java-doc comments
- Use GUI to select appropriate temporal pattern
parameterized by declared observables - Add quantification if property contains instance
propositions.