## Names and Binding in Type Theory

##### Abstract

Names and name-binding are useful concepts in the theory and practice of formal systems. In this thesis we study them in the context of dependent type theory. We propose a novel dependent type theory with primitives for the explicit handling of names. As the main application, we consider programming and reasoning with abstract syntax involving variable binders.
Gabbay and Pitts have shown that Fraenkel Mostowski (FM) set theory models a notion of name using which informal work with names and binding can be made precise. They have given a number of useful constructions for working with names and binding, such as a syntax-independent notion of freshness that formalises when two objects do not share names, and a freshness quantifier that simplifies working with names and binding. Related to FM set theory, a number of systems for working with names have been given, among them are the first-order Nominal Logic, the higher-order logic FM-HOL, the Theory of Contexts as well as the programming language FreshML.
In this thesis we study how dependent type theory can be extended with primitives for working with names and binding. Our choice of primitives is different from that in FM set theory. In FM set theory the fundamental primitive for working with names is swapping. All other concepts such as \alpha-equivalence classes and binding are constructed from it. For dependent type theory, however, this approach of constructing everything from swapping is not ideal, since it requires us to make strong assumptions on the type theory. For instance, the construction of \alpha-equivalence classes from swapping appears to require quotient types. Our approach is to treat constructions such as \alpha-equivalence classes and name-binding directly, turning them into primitives of the type theory. To do this, it is convenient to take freshness rather than swapping as the fundamental primitive.
Based on the close correspondence between type theories and categories, we approach the design of the dependent type theory by studying the categorical structure underlying FM set theory. We start from a monoidal structure capturing freshness. By analogy with the definition of simple dependent sums \Sigma and products \Pi from the cartesian product, we define monoidal dependent sums \Sigma^* and products \Pi^* from the monoidal structure. For the type of names N, we have an isomorphism \Sigma^*_N\iso\Pi^*_N generalising the freshness quantifier. We show that this structure includes \alpha-equivalence classes, name binding, unique choice of fresh names as well as the freshness quantifier. In addition to the set theoretic model corresponding to FM set theory, we also give a realizability model of this structure.
The semantic structure leads us to a bunched type theory having both a dependent additive context structure and a non-dependent multiplicative context structure. This type theory generalises the simply-typed \alpha\lambda-calculus of O'Hearn and Pym in the additive direction. It includes novel monoidal products \Pi^* and sums \Sigma^* as well as hidden-name types H for working with names and binding.
We give examples for the use of the type theory for programming and reasoning with abstract syntax
involving binders. We show that abstract syntax can be handled both in the style of FM set theory and in the style of Weak Higher Order Abstract Syntax. Moreover, these two styles of working with abstract syntax can be mixed, which has interesting applications such as the derivation of a term for the unique choice of new names.