The |
Let us start with formalizing the part of the
Expanding with the binary relation and the usual logical connectors and quantifiers, we obtain the set of formulas. More precisely, is the smallest set such that
In the case of the expressions and we will always assume that , whenever or is a subexpression of . We will also use and as abbreviations for and .
The formal theory for the
We recall our conventions concerning “,” and , which can be restated as axioms:
It will convenient to define the relation by
Then product, tuple and function types are required to satisfy the following conversion axioms:
We will denote by the above formal theory for
From the typing point of view, an environment corresponds to a finite set of additional hypotheses in . For instance, an environment in which we have functions , and a converter simply corresponds to the set . Again, we may consider models of the theory enriched with .
Given a model or , we say that is a type if . In that case, we call
the set of instances of . Inversely, given a subset , it is natural to search for a type with . In order to ensure the existence of such types for simple sets, such as , it is useful to increase the expressiveness of our language through the possibility to form so called logical types.
More precisely, let and be the counterparts of , and , modulo the addition of new primitives and . The set is defined in a similar way as , modulo the following additional constructions:
The corresponding theory is obtained by adding the following axioms to :
In particular, , , etc.
The type corresponds to overloading. Indeed, an overloaded function , with two definitions and corresponds to the overloaded type .
The type corresponds to an anonymous union of and .
The type corresponds to a template type.
For instance, the C++ template template<typename
T> T square (T) gives rise to . In
The type corresponds to a generic type.
For instance, is equivalent to the type of
The type corresponds to a conditional type. The condition usually concerns a quantifier. For instance, a clean specification of squaring a ring element would be given by , which is really a notation for .