A Linear Logical Framework
Total Page:16
File Type:pdf, Size:1020Kb
A Linear Logical Framework Iliano Cervesato and Frank Pfenning∗ Department of Computer Science Carnegie Mellon University Pittsburgh, PA 15213-3891 {iliano|fp}@cs.cmu.edu Abstract tuitionistic framework. Consequently the adequacy of the representation is difficult to prove and the formal We present the linear type theory LLF as the for- meta-theory quickly becomes intractable. mal basis for a conservative extension of the LF logical Linear logic [7] provides a view of context formulas framework. LLF combines the expressive power of de- as resources, which can be exploited to model the no- pendent types with linear logic to permit the natural and tion of state, as described for example in [4, 10, 12, 22]. concise representation of a whole new class of deductive The current proposals put the emphasis on the issue of systems, namely those dealing with state. As an exam- representing imperative constructs and resource-based ple we encode a version of Mini-ML with references in- logics, but appear inadequate for reasoning effectively cluding its type system, its operational semantics, and about these representations. On the other hand, intu- a proof of type preservation. Another example is the itionistic type-theoretic frameworks such as LF make encoding of a sequent calculus for classical linear logic the representation of meta-reasoning easy, but do not and its cut elimination theorem. LLF can also be given have any notion of linearity built in. an operational interpretation as a logic programming As a concrete example, consider the problem of rep- language under which the representations above can be resenting a cut-elimination procedure for linear logic. used for type inference, evaluation and cut-elimination. Given the derivation D foralinearsequent∆−→ Θ, this procedure produces an equivalent cut-free deriva- tion D0. Since it operates linearly on the formulas ap- 1 Introduction pearing in it, D would be adequately represented by atermpDqin a linear λ-calculus; the same holds for D0 A logical framework is a formal system designed to . This problem was encoded in LF by representing provide effective representations of deductive systems sequents as types and derivations as proof terms [18]. pDq and their properties. Proposals based on intuitionistic LF is intuitionistic and therefore the linearity of pDq logic and intuitionistic type theory, such as the logical needed to be checked explicitly as a property of , framework LF [9], have been widely used to study log- complicating the meta-theory to the extent that it be- ical formalisms [19] and programming languages [11]. came infeasible and only the cut-elimination algorithm Unfortunately, many constructs and concepts needed in without the linearity check was implemented. On the common programming practice cannot be represented other hand, encoding the same problem in Miller’s lin- in a satisfactory way in these meta-languages. In par- ear meta-logic Forum [12] would map linear sequent ticular, constructs based on the notion of state as found derivations to linear derivations in the meta-language. in imperative languages often escape an elegant formal- But since Forum lacks proof terms, no internal nota- ization by means of these tools. Similarly, logical sys- tion for those entities is provided and cut-elimination tems that, by definition (e.g. substructural logics) or cannot be implemented in this manner. by presentation (e.g. Dyckhoff’s contraction-free intu- In this paper, we propose a conservative extension itionistic sequent calculus [5]), rely on destructive con- of the logical framework LF that permits representing text reductions require awkward encodings in an in- linear objects and reasoning about them. This formal- ∗ ism, that we call Linear LF,orLLF for short, is a This work was supported by NSF Grant CCR-9303383. The type theory featuring linear function types (−◦ ), ad- second author was supported by the Alexander-von-Humboldt- > Stiftung when this paper was completed, during a visit to the De- ditive pairing (&), unit type ( ), and intuitionistic partment of Mathematics of the Technical University Darmstadt. dependent function types (Π). LLF extends the ob- This extended abstract will appear on the proceedings of the Eleventh Annual IEEE Symposium on Logic in Computer Science — LICS’96, New Brunswick, NJ, July 27–30 1996. jects of LF with linear functional abstraction, additive The language of objects is augmented accordingly with pairs and unit, the corresponding destructors, and their the respective constructors and destructors. Linear equational theory. In order to keep the system simple types operate on linear assumptions which we repre- we restrict the indices of type families to be linearly sent as distinguished declarations of the form xˆ: A in closed so that a type can depend only on intuitionis- the context; we write x: A for context elementsala ` LF tic assumptions, but not on linear variables. While at and call them intuitionistic assumptions.Thesyntax first this may appear to be a strong restriction, the re- of LLF is given by the following grammar (constructs sulting system is surprisingly expressive, allowing the not present in LF are separated by a double bar || ): faithful implementation of cut elimination for classical Objects: M ::= c | x | λx:A. M | M1 M2 linear logic, translations between linear natural deduc- || h i | h M 1 ,M2i|fst M | snd M tion and sequent calculus, and properties of imperative | λxˆ :A. M | M1 ˆM2 languages such as type preservation. Families: P ::= a | PM LLF also maintains the computational nature of LF | and is amenable to an efficient implementation as a Types: A ::= P Πx:A1.A2 || > | | −◦ logic programming language in the style of Elf [15, 17]. A 1 & A 2 A 1 A 2 The experience gained with linearity in the language Kinds: K ::= type | Πx:A. K Lolli [10, 2] applies directly to our formalism. Contexts: Ψ ::= ·|Ψ,x:A || Ψ ,xˆ:A The principal contributions of this work are: (1) the Signatures: Σ ::= ·|Σ,a:K | Σ,c:A definition of a uniform type theory admitting linear en- Here x, c and a range over object-level variables, object tities in conjunction with dependent types; (2) the use constants and type family constants, respectively. In of this system as a logical framework to represent and addition to the names displayed above, we will often reason about problems that are not handled well by use N and B to range over objects and types respec- previous formalisms, either linear or intuitionistic; (3) tively. Moreover, we denote generic terms, i.e. objects, the description of an operational system which consti- types or kinds, with the letters U and V , possibly sub- tutes the first step towards an implementation of this scripted. As usual, we write A → U for Πx : A. U formalism as a linear constraint logic programming lan- whenever x does not occur in the type or kind U. guage. To our knowledge, this is the first linear type The notions of free and bound variables are adapted theory that goes beyond simple types. Our work was from LF (notice the presence of a new binding con- inspired by ideas in [14]. struct: linear λ-abstraction). As usual, we identify The paper is organized as follows. Section 2 de- terms that differ only in the name of their bound vari- scribes LLF and presents major results in its meta- ables and write [M/x]U for the capture-avoiding sub- theory, such as the decidability of type-checking. Sec- stitution of M for x in the term U. Finally we require tion 3 indicates that efficient proof search in the style variables and constants to be declared at most once in of logic programming can be achieved in LLF . Sec- a context and in a signature, respectively. tion 4 illustrates the expressiveness of LLF on an ex- Below we will often need to access the intuitionistic ample featuring imperative computations. Section 5 part of a context. Therefore, we introduce the function presents cut-elimination for classical linear logic as an- Ψdefinedasfollows: other example. Finally, Section 6 assesses the results · = · and outlines future work. Ψ,x:A = Ψ,x:A Ψ,xˆ:A = Ψ 2 The Linear Logical Framework LLF We overload this notation and use Ψ to express the fact that the linear portion of the denoted context is In order to facilitate the description of LLF in the constrained to be empty (e.g. in the all rules for type available space, we must assume that the reader is fa- families in Figure 1). miliar with both the logical framework LF [9] and var- The meaning of the syntactic entities of LLF can ious presentations of linear logic [7, 8]. We will also be presented in various forms. Figures 1 and 2 show sparingly take advantage of the natural extension of the a version of the type system for LLF that we call Curry-Howard isomorphism to linear logic by viewing pre-canonical and that is particularly well-suited for types as formulas. proving meta-theoretic properties about this formal- LLF extends the logical framework LF with three ism. The system relies on the following seven judg- connectives from linear logic, seen in this context as ments: type constructors, namely multiplicative implication ` Σ ⇑– Sig (Σ is a pre-canonical signature) −◦ > ( ), additive conjunction (&) and additive truth ( ). `Σ Ψ ⇑– Ctx (Ψ is a pre-canonical context) 2 Signatures ` Σ ⇑– Sig ·`Σ A⇑–type ` Σ ⇑– Sig ·`Σ K⇑–Kind s dot s obj s fam `·⇑–Sig ` Σ,c:A⇑–Sig ` Σ,a:K ⇑–Sig Contexts ` Σ ⇑– Sig `Σ Ψ ⇑– Ctx Ψ `Σ A ⇑– type `Σ Ψ ⇑– Ctx Ψ `Σ A ⇑– type c dot c int c lin `Σ ·⇑–Ctx `Σ Ψ,x:A⇑– Ctx `Σ Ψ,xˆ:A⇑– Ctx Kinds `Σ Ψ ⇑– Ctx Ψ,x:A`Σ K ⇑– Kind kc type kc dep Ψ `Σ type ⇑– Kind Ψ `Σ Πx:A.