# What is Algebraic Specification

**Algebraic Specification Technique an Object Class** or type is specified in terms of relationships existing between the operations defined on that type. It was first brought into prominence by Guttag [1980, 1985] in specification of abstract data types. Various notations of algebraic specifications have evolved, including those based on OBJ and Larch languages.

# Representation of Algebraic Specification

Essentially, **Algebraic Specifications define a system as a heterogeneous algebra.** A heterogeneous algebra is a collection of different sets on which several operations are defined. Traditional algebras are homogeneous. A homogeneous algebra consists of a single set and several operations; {I, +, -, *, /}. In contrast, alphabetic strings together with operations of concatenation and length {A, I, con, len}, is not a homogeneous algebra, since the range of the length operation is the set of integers.

Each set of symbols in the algebra, in turn, is called a sort of the algebra. To define a heterogeneous algebra, we first need to specify its signature, the involved operations, and their domains and ranges. Using algebraic specification, we define the meaning of a set of interface procedure by using equations. An algebraic specification is usually presented in four sections.

## Types section:-

In this section, the sorts (or the data types) being used is specified.

### Exceptions section:-

This** section** gives the names of the exceptional conditions that might occur when different operations are carried out. These exception conditions are used in the later sections of an algebraic

specification. For example, in a queue, possible exceptions are novalue (empty queue), underflow (removal from an empty queue), etc.

### Syntax section:-

This section defines the signatures of the interface procedures. The collection of sets that form input domain of an operator and the sort where the output is produced are called the signature of the operator. For example, the append operation takes a queue and an element and returns a new queue. This is represented as:

1 |
append : queue x element → queue |

### Equations section:-

This section gives a set of rewrite rules (or equations) defining the meaning of the interface procedures in terms of each other. In general, this section is allowed to contain conditional expressions. For example, a rewrite rule to identify an empty queue may be written as:

1 |
isempty(create()) = true |

By convention each equation is implicitly universally quantified over all possible values of the variables. Names not mentioned in the syntax section such as ‘r’ or ‘e’ are variables. The first step in defining an algebraic specification is to identify the set of required operations. After having identified the required operators, it is helpful to classify them as either basic constructor operators, extra constructor operators, basic inspector operators, or extra inspection operators. The definition of these categories of operators is as follows:

### 1. Basic construction operators.

These operators are used to create or modify entities of a type. The basic construction operators are essential to generate all possible element of the type being specified. For example, ‘create’ and ‘append’ are basic construction operators for a FIFO queue.

### 2. Extra construction operators.

These are the construction operators other than the basic construction operators. For example, the operator ‘remove’ is an extra construction operator for a FIFO queue because even without using

‘remove’, it is possible to generate all values of the type being specified.

### 3. Basic inspection operators.

These operators evaluate attributes of a type without modifying them, e.g., eval, get, etc. Let S be the set of operators whose range is not thedata type being specified. The set of the basic operators S1 is a subset of S, such that each operator from S-S1 can be expressed in terms of the operators from S1. For example, ‘isempty’ is a basic inspection operator because it does not modify the FIFO queue type.

### 4. Extra inspection operators.

These are the inspection operators that are not basic inspectors.

# Properties of algebraic specifications

Three important properties that every algebraic specification should possess are:

### Completeness:

This property ensures that using the equations, it should be possible to reduce any arbitrary sequence of operations on the interface procedures. There is no simple procedure to ensure that an algebraic specification is complete.

### Finite termination property:

This property essentially addresses the following question: Do applications of the rewrite rules to

arbitrary expressions involving the interface procedures always terminate? For arbitrary algebraic equations, convergence (finite termination) is undecidable. But, if the right hand side of each rewrite rule has fewer terms than the left, then the rewrite process must terminate.

### Unique termination property:

This property indicates whether application of rewrite rules in different orders always result in the

same answer. Essentially, to determine this property, the answer to the following question needs to be checked: Can all possible sequence of choices in application of the rewrite rules to an arbitrary expression involving the interface procedures always give the same number? Checking the unique termination property is a very difficult problem.

## Structured Specification

Developing algebraic specifications is time consuming. Therefore efforts have been made to device ways to ease the task of developing algebraic specifications. The following are some of the techniques that have successfully been used to reduce the effort in writing the specifications.

### Incremental Specification.

The idea behind incremental specification is to first develop the specifications of the simple types and then specify more complex types by using the specifications of the simple types.

### Specification Instantiation.

This involves taking an existing specification which has been developed using a generic parameter

and instantiating it with some other sort.

# Advantages and Disadvantages of Algebraic Specifications

**Algebraic Specifications have a strong mathematical basis and can be viewed as ****heterogeneous algebra.** Therefore, they are unambiguous and precise. Using an algebraic specification, the effect of any arbitrary sequence of operations involving the interface procedures can automatically be studied. A major shortcoming of algebraic specifications is that they cannot deal with side effects.

Therefore, algebraic specifications are difficult to interchange with typical programming languages. Also, algebraic specifications are hard to understand.

# Executable specification language (4GLs).

If the **specification** of a system is expressed formally or by using a programming language, then it becomes possible to directly execute the specification. However, executable specifications are usually slow and inefficient, **4GLs3** (4th Generation Languages) are examples of executable specification languages. **4GLs** are successful because there is a lot of commonality across data

processing applications. **4GLs** rely on software reuse, where the common abstractions have been identified and parameterized. Careful experiments have shown that rewriting **4GL** programs in higher level languages results in up to 50% lower memory usage and also the program execution time can reduce ten folds. Example of a **4GL** is Structured Query Language (**SQL**).

**Please Share this Article With you Friends………⇓**