Halstead's theory of software science is one of "the best known and most thoroughly studied . . . composite measures of (software) complexity". Software science proposed the first analytical "laws" for computer software.

Software science assigns quantitative laws to the development of computer software, using a set of primitive measures that may be derived after code is generated or estimated once design is complete. These follow:

*n1 = the number of distinct operators that appear in a program.*

n2 = the number of distinct operands that appear in a program.

N1 = the total number of operator occurrences.

N2 = the total number of operand occurrences.n2 = the number of distinct operands that appear in a program.

N1 = the total number of operator occurrences.

N2 = the total number of operand occurrences.

Halstead uses these primitive measures to develop expressions for the overall program length, potential minimum volume for an algorithm, the actual volume (number of bits required to specify a program), the program level (a measure of software complexity), the language level (a constant for a given language), and other features such as development effort, development time, and even the projected number of faults in the software.

Halstead shows that length N can be estimated

**N = n1 log 2 n1 + n2 log 2 n2**

and program volume may be defined

**V = N log 2 (n1 + n2)**

It should be noted that V will vary with programming language and represents the volume of information (in bits) required to specify a program.

Theoretically, a minimum volume must exist for a particular algorithm. Halstead defines a volume ratio L as the ratio of volume of the most compact form of a program to the volume of the actual program. In actuality, L must always be less than 1. In terms of primitive measures, the volume ratio may be expressed as

**L = 2/n1 x n2/N2**

Halstead's work is amenable to experimental verification and a large body of research has been conducted to investigate software science. A discussion of this work is beyond the scope of this text, but it can be said that good agreement has been found between analytically predicted and experimental results.