A general framework for models of type polymorphism

We present a general framework for models of polymorphism. A crucial fact about polymorphic functions is their uniform behavior under type application. Under the Curry-Howard formulae-as-types isomorphism the polymorphic types behave like universal quantifiers. Lawvere noted that the rules of inference that characterize universal quantifiers assert that a universal quantifier can be found as a right adjoint to substitution. We combine these two insights to create a clear and satisfactory framework to explain type polymorphism. The framework has as its basis what we call substitution systems, which explain substitution when type variables are present. From the substitution systems we build up substitution functors that capture the concept of proliferating the type variables used in building expressions. Demanding that these functors have suitable adjoints completes our framework. The substitution functors with their "suitable" right adjoints make up a map of adjunctions. We show the framework to be suitable for semantics of polymorphic types by proving substitution theorems for types as well as terms, and $\beta$ as well as $\eta$ type reduction theorems. The generality of the framework is shown by fitting a wide variety of models to it. McCracken's finitary-retracts model uses finitary retracts over a finitary complete partial order to model the types. We show that this model fits in the general framework, and a similar method suffices for the closure model. Girard's qualitative-domains model too fits elegantly in our framework. Hyland's effective topos has given rise to a number of "set-theoretic" models of polymorphism. We show that the partial-equivalence-relations model can be satisfactorily fitted in our model theory. A similar technique enables any topos model to be viewed in the framework. Seely's model theory uses indexed category theory to provide a notion of a model for higher-order polymorphism. We show the equivalence of our approach to Seely's esoteric PL-categories when we restrict attention to the second order. This category-theoretic framework enables us to define logical relations. We start from logical relations over Cartesian closed categories using elements, extend these to cover the polymorphic case, and prove a logical-relations theorem based on these definitions.