key observations about specifications
specifications must be explicit
independent development and testing
resources are finite
program specs evolve over time
testing
a form of consistency checking between implementation and spec
black box testing
you see nothing about the program’s internal mechanisms
white box testing
all program internal details are available
grey box
between white and black box testing
automated vs manual
automated:
manual
black box vs white
black
white
classification of specs
safety properties:
liveness properties:
common forms of safety properties
types: int x, java.net.Socket s, …
type-state properties: program must not read data from java.net.Socket until socket is connected
assertions: implicit, e.g. p != null before each dereference of p
pre and post conditions: double sqrt(double x) {…}
pre-condition: x >= 0
post-condition: return value ‘ret’ satisfies ret * ret = x
types
adding the specification to the implementation allows to check the implementation against the specification
checker framework
goal: statically eliminate entire classes of runtime errors via annotations
two kinds of useful invariant
loop invariant:
class invariants:
houdini algorithm