Formal Specification

Definition: A specification is a very precise description of the possible effects of a software component.

Requirements of a specification technique:

It must be possible to construct specifications with reasonable effort.

With some training, it must be possible to read and 'understand' specifications.

A specification must be minimal.

A specification technique should allow us to capture the 'correct' type of information in a natural way.

A formal method should provide a means for specifying a system so that consistency, completeness, and correctness can be assessed in a systematic fashion.

Consistencyno contradictions (what is stated in one place is not contradicted in another). Consistency is ensured by mathematically proving that initial facts can be formally mapped into later statements within the specification.
Completenessdifficult even for formal methods
Correctness could be achieved if there is a mapping between design and requirements.
PrecisionLack of ambiguity

The properties required of an effective representation:


Expressivenessmust be capable of expressing many different things as well as types of things (elements, objects, data, relationships, processes, properties ...)

Capable is not sufficient. To be expressive it must also allow for a convenient representation (that is in a straightforward way, does this mean perhaps natural?), and must support the other properties given below.

Semantic Soundnesshas a mathematical foundation that allows correctness conditions to be stated
Programming Language Independent
Machine Manipulabilityuse computer tools to manipulate the formalism
Combinabilitymethods for combining formal structures and assessing the properties of the whole from the properties of the parts.

Primary components of a specification language


Syntaxdefines the specific notation with which the specification is represented. Typically the syntactic domain is based on standard set theory and predicate calculus.
Semanticsdefines how representation describes a system requirements. Must be capable of expressing things that may not be computable. Furthermore these semantics must be capable of expressing system behavior.
Relationsthe rules that indicate which objects properly satisfy the specification.

Ratings for Various Languages


ExpressivenessSemantic
Soundness
IndependenceManipulabilityCombinab ility
Natural Languagevery capable of representing any kind or type of component.Vague therefore not semantically sound (multitude of meanings possible)yesnoNo theory to support combining text fragments
Programming LanguageNot very
limited in what it can represent (it can only represent computable functions) Useful for describing algorithmic behavior.
yesnoyesyes
Formal GrammarNot Veryyesyessort ofyes
Logical Formalism syes. can be used to represent many differing types of things (behavior, comp onents,...) but not very good at representing algorithmic processesyes (within the expressive domain the meaning is exact)yeswell?yes. The theory generated by the union of two axioms systems is the union of the theories or a contradiction.

Specification Techniques

Informal Expressed in natural language or pictures.
Specification by Pre- and Postconditions{P} S {Q}

We establish what should hold before, {P}, and after, {Q}, execution. We show that the program, S, transforms {P} to {Q}.

As a design aid, this type of specification provides constraints which the implementation must satisfy.

Larch

Model OrientedProvide a direct means to describe the system's behavior. The system is specified in terms of mathematical structures.

VDM and Z

Property OrientedUse indirect means to specify behavior by stating the properties (constraints) the system must satisfy.

Eiffel, OBJ, AFFIRM


Counter Arguments


Formal Methods are Difficult

Only highly critical systems benefit from their use

Formal methods involves complex mathematics

Formal methods increase the cost of development

Formal methods are incomprehensible to clients

Nobody uses formal methods for real projects