Formal Specification
- Specifications of a software artifact's properties in a language defined by mathematical logic
- This provides a formal model of the artifact
- Since it is a model, not all information about the artifact is included
- What would it mean to have a complete formal model of a software artifact?
- Examples:
- Finite state machines
- Grammars
- Alloy
- Z
- Key advantages of formal models
- Unambiguous
- Can prove properties mathematically
- Can use automated proof techniques
- Disadvantages
- Learning curve
- Not always appropriate
Black Box Specification
- Concept developed by Harlan Mills
- Formal specification of the boundary between a software artifact
and its environment
- An artifact receives stimuli from its environment
- An artifact issues responses to its environment
- The black box models the mapping of stimuli to responses solely in terms
of external events
- This models less than a state machine does
- One straightforward representation
- History of interactions
- Current stimulus
- Current response
- Current response depends upon both the current stimulus and the
history
- Representing interactions
- Each stimulus and response is represented by a symbol
- Representing a history
- A history is a boolean expression representing a set of stimulus-response sequences
- Available operations:
- Boolean operators (
and, or, not)
-
includes: Returns true if its argument is included in the sequence
- Stimuli: Referred to by name
- Responses: Referred to by name, prefixed with "response"
-
count: Counts occurrences of its argument
- Arithmetic operators: Used with
count calls
- Sequencing (
:) operator: Matches specified chain
-
any: Matches anything
- Blackbox2 editor/analyzer (An example)