Ordered Linear Logic and Applications

Jeff Polakow

August 2001

CMU-CS-01-152

School of Computer Science Carnegie Mellon University

Pittsburgh, PA 15213

Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy.

Thesis Committee: Frank Pfenning, Chair

Robert Harper John Reynolds Dana Scott

Dale Miller, Pennsylvania State University

Copyright \begin{matrix}c \\ ◯ \end{matrix} 2001 Jeff Polakow

This research was supported in part by the National Science Foundation under grants CCR-9804014 and CCR-9619584.

Keywords: ordered linear logic, linear logic, non-commututative logic, logic programming, logical frameworks This work is dedicated to my parents.

Acknowledgments

Firstly, and foremost, I would like to thank my principal advisor, Frank Pfenning, for his patience with me, and for teaching me most of what I know about logic and type theory.

I would also like to acknowledge some useful discussions with Kevin Watkins which led me to simplify some of this work.

Finally, I would like to thank my other advisor, John Reynolds, for all his kindness and support over the last five years.

Abstract

This thesis introduces a new logical system, ordered linear logic, which combines reasoning with unrestricted, linear, and ordered hypotheses. The logic conservatively extends (intuitionistic) linear logic, which contains both unrestricted and linear hypotheses, with a notion of ordered hypotheses. Ordered hypotheses must be used exactly once, subject to the order in which they were assumed (i.e., their order cannot be changed during the course of a derivation). This ordering constraint allows for logical representations of simple data structures such as stacks and queues. We construct ordered linear logic in the style of Martin-Löf from the basic notion of a hypothetical judgement. We then show normalization for the system by constructing a sequent calculus presentation and proving cut-elimination of the sequent system.

After introducing the basic logical system, we show how to extend techniques from linear logic to achieve an ordered logic programming language, Olli, and an ordered logical framework, OLF. Olli and OLF allow quite elegant encodings of situations involving simple data structures which are not possible without ordered hypotheses. Example Olli programs include a translator to and from deBruijn notation, and a breadth-first graph traversal program. The major OLF application presented in this dissertation is an analysis of some syntactic properties of the CPS transform.

8

Contents

1 Introduction 13

I Ordered Linear Logic 19

2 Ordered Linear Logic 21 2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.2 Judgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.3 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.4 Unrestricted Hypothetical Judgements . . . . . . . . . . . . . . . . . 23 2.5 Linear Hypothetical Judgements . . . . . . . . . . . . . . . . . . . . . 30 2.6 Ordered Hypothetical Judgements . . . . . . . . . . . . . . . . . . . . 34 2.7 Combined Reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 2.8 Modalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.9 Other Approaches to Combined Reasoning . . . . . . . . . . . . . . . 42 2.10 Derivation Rules for Ordered Linear Logic . . . . . . . . . . . . . . . 44 2.11 Properties of Ordered Linear Logic . . . . . . . . . . . . . . . . . . . 45

3 Normal Deductions 49 3.1 Normal Deductions for Ordered Linear Logic . . . . . . . . . . . . . . 50 3.2 Properties of Normal Deductions . . . . . . . . . . . . . . . . . . . . 52 3.3 Directed Deductions . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 4 Sequent Calculus 55

4.1 Sequent Calculus for Ordered Linear Logic . . . . . . . . . . . . . . . 56 4.2 Admissibility of Cut . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.3 Sequent Calculus With Cut . . . . . . . . . . . . . . . . . . . . . . . 62

5 Normalization for Ordered Linear Logic 65 5.1 Normal Deductions and Cut-Free Sequents . . . . . . . . . . . . . . . 67 5.2 Directed Deductions and Sequents with Cut . . . . . . . . . . . . . . 70 5.3 Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

II Ordered Linear Logic Programming 73

6 Uniform Derivations 75 6.1 Uniform Fragment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 6.2 Uniform Derivation System . . . . . . . . . . . . . . . . . . . . . . . 77

7 Residuation 87 7.1 Extended Uniform Derivations . . . . . . . . . . . . . . . . . . . . . . 88 7.2 Residuation of Mobile Hypotheses . . . . . . . . . . . . . . . . . . . . 91

8 Lazy Context Splitting 97 8.1 An Ordered IO System . . . . . . . . . . . . . . . . . . . . . . . . . . 97 8.2 Resource Management System for OLL . . . . . . . . . . . . . . . . . 102 8.3 Correctness of RMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

9 Lazy Erasure 111 9.1 Making ⊤ Deterministic . . . . . . . . . . . . . . . . . . . . . . . . . 111 9.2 Correctness of ⊤-flags System . . . . . . . . . . . . . . . . . . . . . . 118

10 Ordered Linear Logic Programming 127 10.1 Olli . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 10.2 Simple Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 10.3 Translating to deBruijn Notation . . . . . . . . . . . . . . . . . . . . 133 10.4 Mini-ML Abstract Machine . . . . . . . . . . . . . . . . . . . . . . . 137 10.5 Mergesort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 10.6 Breadth-First Tree Numbering . . . . . . . . . . . . . . . . . . . . . . 144 10.7 Breadth-First Search Graph Numbering . . . . . . . . . . . . . . . . . 145 10.8 Parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

11 Eager Failure 151 11.1 Failing Earlier in Linear Logic . . . . . . . . . . . . . . . . . . . . . . 151 11.2 Extension to Ordered Contexts . . . . . . . . . . . . . . . . . . . . . 154 11.3 Strict Derivation System . . . . . . . . . . . . . . . . . . . . . . . . . 156 11.4 Correctness of Strict Derivations . . . . . . . . . . . . . . . . . . . . . 161 11.5 Strictness Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 11.6 Implementation Issues . . . . . . . . . . . . . . . . . . . . . . . . . . 168

III Ordered Logical Framework 171

12 Ordered Types 173 12.1 Proof Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 12.2 Canonical Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

13 Ordered Logical Framework 193 13.1 Ordered Logical Framework . . . . . . . . . . . . . . . . . . . . . . . 194 13.2 Typing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 13.3 Definitional Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 13.4 Properties of Typing and Equality . . . . . . . . . . . . . . . . . . . . 202 14 Algorithmic Equality 209

14.1 Completeness of Algorithmic Equality . . . . . . . . . . . . . . . . . . 215 14.2 Soundness of Algorithmic Equality . . . . . . . . . . . . . . . . . . . 219

15 Decidability and Canonical Forms 223 15.1 Decidability of Equality . . . . . . . . . . . . . . . . . . . . . . . . . 223 15.2 Decidability of OLF Type-Checking . . . . . . . . . . . . . . . . . . . 225 15.3 Canonical Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 15.4 DeBruijn Terms in OLF . . . . . . . . . . . . . . . . . . . . . . . . . 234

16 CPS Analysis in OLF 239 16.1 CPS terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 16.2 Ordered Logical Framework Representation . . . . . . . . . . . . . . 242

16.2.1 DS Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 16.2.2 CPS Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

16.3 CPS Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 16.4 Bare Abstract Machine . . . . . . . . . . . . . . . . . . . . . . . . . . 249 16.5 Stack Abstract Machine . . . . . . . . . . . . . . . . . . . . . . . . . 252 16.6 Bare and Stack Equivalence . . . . . . . . . . . . . . . . . . . . . . . 256 16.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

IV Conclusions 265

17 Conclusions and Future Work 267

Chapter 1

Introduction

Now, it is the contention of the intuitionists ... that the basic mathematical notions, above all the notion of function, ought to be interpreted in such a way that the cleavage between mathematics, classical mathematics, that is, and programming that we are witnessing at present disappears.

— Per Martin-Löf

Constructive Mathematics and Computer Programming [34]

It has long been known that there are strong connections between intuitionistic logic and computation. The Curry-Howard isomorphism [30] between well-typed functional programs and constructive proofs gives a logical interpretation of pure functional computation. Thus each expression, of a particular type, represents a proof of that type viewed as a formula in intuitionistic logic. Having a type system with a logical intuition gives a computational intuition. For example, pursuing the Curry-Howard isomorphism a little further, we arrive at the understanding of expression evaluation as partial proof normalization. Since we know intuitionistic logic is normalizing, we immediately know any well-typed expression in a pure functional language will evaluate to a value. Even when considering real functional languages, which might contain unrestricted recursion or effects, a logically motivated type system is useful. Type inference algorithms, for instance, are based on a logical meaning of types and the proof theory behind that logic.

A further use of the logical intuition behind a type system is in the area of logical frameworks. A logical framework is essentially a formal language in which a deductive system can be defined and reasoned about. LF [23] is a particular logical framework based on dependent types, i.e., the meta-language is dependent type theory. Examples of systems which have been represented in LF include compiler verification, Mini-ML with its meta-theory, and the Church-Rosser theorem. Furthermore Twelf [48], a concrete implementation of LF, has been used as a tool to help in the discovery of new proofs; most notably a new proof of cut-elimination for classical, intuitionistic and linear logic was discovered with the system’s help [45, 44]. The ability to “reason” within the type system, and the insights necessary for its implementation come from the logical interpretation of the types.

A different method of connecting intuitionistic logic and computation is found in the logic programming paradigm. A logic program is simply a collection of predicates (over some term language) and formulas which specify when predicates are true. A query, for a program, is a formula constructed from the same set of predicates as the program. Execution of a logic program corresponds to proving a query, following a fixed operational semantics, using the program formulas. If a query is provable then we know that a specific relationship, represented by the logic program, holds between the terms in the query. Additionally, all existentially quantified variables in a query must be instantiated by the proof of that query. The “witnesses” for a query’s existential variable will also be returned when a sucessful proof is found.

In this setting, computation is a by-product of proof search. Thus the proof search algorithm used in a logic programming language must be relatively simple– the programmer must understand how a program will execute– and must have a reasonable computational interpetation, i.e., the operational semantics should allow us to easily think of a collection of formulas as a program. Although originally conceived within classical logic, the above mentioned existential property clearly places logic programming in the realm of intuitionistic logic.

While intuitionistic logic itself is useful as a logic for describing computations, there are many aspects of computation which fall outside its scope. Knowing a function has type A → B only conveys that the function expects an argument, of type A, and produces a result, of type B. It tells us nothing about how, or even if, the function’s argument is used. For this reason, researchers have been examining the computational content of richer logics hoping to find logical explanations for known phenomena as well as new possibilities for language constructs. Along these lines, linear logic [21] has received considerable attention in the programming language community over the past decade.

Unlike intuitionistic logic, linear logic can be used to express some information about how a function uses its argument. A linear function, of type A−∘B, must use its argument exactly once. This little bit of extra information has been used to describe a wide range of existing language phenomena from the difference between side-effecting and non-side-effecting functions [60] to the absence of snapback in Idealized Algol [39]. Additionally, linear logic has been used as the basis for a type system which guarantees polynomial runtime of well-typed programs [29]. Furthermore, logic programming systems and logical frameworks based on linear logic can encode state at the logical level. This is an improvement (at the very least in terms of elegance) over similar systems based on intuitionistic logic which must encode state at the term level.

The key difference between linear logic and intuitionistic logic is in the notion of how a hypothesis may be used. Intuitionistic logic places no constraints upon hypotheses; they may be ignored or repeatedly used. For this reason, we will refer to intuitionistic logic as unrestricted logic and, from this point on, reserve the description “intuitionistic” for a more general property as described below. In contrast, linear logic requires hypotheses to be used exactly once, hence the name linear. This restriction on hypothesis usage has far reaching consequences which make linear logic quite different from unrestricted logic. In Section 2.5, we shall treat this topic in some detail.

Linear logic was originally conceived as a classical logic. It is classical in the sense that DeMorgan laws hold and implication may be defined in terms of disjunction and negation. Thus, linear logic can be presented as a single-sided sequent system without the notion of hypotheses. There is an “intuitionistic” version of linear logic in which the notion of hypotheses entailing a goal is primitive. From this point on, all references to linear logic shall refer to the intuitionistic variant. It is this property of a logic, having a primitive notion of entailment, for which we will use the word intuitionistic.

This thesis introduces a new intuitionistic logical system, ordered linear logic, which can express more information about hypotheses than linear logic. Specifically, we will be able to convey some information about the order of hypotheses in context. In unrestricted and linear logic, the active hypotheses at any point in a proof have no order. Thus there is no way to directly encode, at the logical level, that one hypothesis was assumed before another. Ordered linear logic imposes an order on the active hypotheses which can be used to formulate such encodings.

Other logical systems with an inherent notion of ordering exist [61, 56, 1]. However, none of these logics are intuitionistic. While intuitionistic versions for some of these systems exist, current research seems to be focussed primarily on the classical presentations. We feel that an ordered logical system fundamentally based on the notion of hypothetical reasoning, in the same manner as other intuitionistic logics, will be of use to the programming language community. It might also take another step towards removing the cleavage lamented by the intuitionists.

This thesis shows that an intuitionistic logic with a notion of order on hypotheses is a useful tool for programming language applications. Towards this end, in addition to introducing ordered linear logic, we will also show several applications of the system to logic programming and logical frameworks. To further bolster the decision to explore an intuitionistic logic, we point out that analogous applications for classical ordered logics are complicated by the complexity of the systems and the lack of a clear computational interpretation.

This thesis is divided into three parts. The first part formally introduces ordered linear logic and demonstrates that the system makes sense as a logical system. The logic is motivated by a review and analysis of the reasoning systems for the three types of hypotheses (unrestricted, linear, ordered) previously mentioned. Ordered linear logic itself integrates the use of the different kinds of hypotheses into one logical system. The logic is developed in the style of Martin-Löf from the basic notion of a hypothetical judgement. In addition to a natural deduction system, we also develop a sequent system, through which we show normalization, and which will be the basis of our investigation of proof search in ordered linear logic.

The second part of the thesis demonstrates how we may base a logic programming language on ordered linear logic. The language we build, christened Olli, follows in the footsteps of λProlog [36] and its linear extension Lolli [27]^{1}. A logic programming interpreter may be intuitively thought of as a specialized theorem prover for which proof search is both efficient and amenable to a direct computational interpretation.

We first identify a fragment of the logic, the uniform fragment, with particularly strong proof theoretic properties. Basing Olli on the uniform fragment provides the computational interpretation, see [37]; additionally, the uniform fragment will be the

1Lolli is not quite an extension of λProlog since it lacks some higher-order features, e.g., higherorder predicates.

basis of a logical framework based on ordered linear logic, which is discussed in the third part of the dissertation. Thereafter, we concentrate on extending techniques developed for efficient linear logic proof search to the ordered case. We also include a chapter with a collection of Olli example programs which show how to use ordered hypotheses as a logical data structure. Example programs include a translation between lambda terms (represented via higher-order abstract syntax) and deBruijn notation terms, a merge sort, a breadth-first graph traversal, and a small natural language parser which handles unbounded dependencies.

The third part of the thesis shows how we may use ordered linear logic to construct a LF-style logical framework. We begin by formalizing the ordered type system implicit within the logic which gives us an ordered lambda calculus. We show that canonical forms (necessary for a logical framework) exist for the fragment of the calculus corresponding to the uniform fragment of the logic. We next add dependent types to the system, in a similar fashion as LLF [11], to get an ordered logical framework. We show that type checking remains decidable and that a suitable notion of canonical forms still exist. We show how the deBruijn translation Olli program may be viewed as a formal, LF-style, representation of the (informal) translation between lambda terms and deBruijn terms. We also show how the ordered logical framework provides an elegant means of analysing some syntactic properties of the CPS transform.

Finally, this thesis concludes with a broad summary and some thoughts on future work.

Preliminary parts of this dissertation were previously published as [51, 52, 53, 49].

18

Part I Ordered Linear Logic Ordered Linear Logic

2.1 Overview

Ordered linear logic is a logic which combines reasoning with unrestricted, linear and ordered hypotheses. Unrestricted hypotheses may be used arbitrarily often, or not at all regardless of the order in which they were assumed. Linear hypotheses must be used exactly once, also without regard to the order of their assumption. Ordered hypotheses must be used exactly once subject to the order in which they were assumed. All of these modes of reasoning independently lead to coherent logical systems which have been (and continue to be) studied in their own right– intuitionistic logic, purely linear logic, and Lambek calculus.

However, these modes of reasoning are not mutually exclusive. For instance, intuitionistic linear logic can be construed as a logic combining linear and unrestricted reasoning. This combination results in a coherent logical system which allows one to use both styles of reasoning side-by-side. Thus intuitionistic linear logic is a conservative extension of intuitionistic logic since intuitionistic linear logic encompasses unrestricted reasoning. In the same manner, ordered linear logic is a conservative extension of intuitionistic linear logic.

This chapter reviews unrestricted, linear, and ordered reasoning before combining them to get ordered linear logic. After (re)constructing a formal system for each style of reasoning, we shall turn to the question of how to combine them into a coherent logical system. Finally, we give a complete presentation of ordered linear logic.

2.2 Judgements

We treat the hypothetical judgement, with an associated substitution principle, as the fundamental concept from which a (intuitionistic) logic, or reasoning system, is built. Therefore we shall take as basic three kinds of hypothetical judgement for the three reasoning styles we will review.

We view logical connectives as internalizations of the informal reasoning which makes sense for the hypothetical judgement. Thus we will describe logical connectives by means of introduction and elimination rules as usual for natural deduction systems. The introduction rules explain how to construct a proof of a formula, while the elimination rules tell us how to use a formula. From another viewpoint, introduction rules describe what information is stored in a connective while elimination rules describe what information may be obtained from a connective. Thus we have a litmus test for possible connectives– can we get out as much information as we put in?

This condition can be formalized in two different ways. If we construct a proof of a formula and then deconstruct it (i.e., apply one of its elimination rules) , we should get back the information we started with. This property is captured by the notion of local reduction and corresponds to β-reduction under the Curry-Howard isomorphism. We also note that we want this property to hold for all possible construction/deconstruction combinations. Additionally, a formula should contain enough information to reconstruct a proof of itself; that is to say its proof should be constructable solely from its constituent parts. This property is captured by the concept of local expansions and corresponds to η-expansion under the Curry-Howard isomorphism. We shall only consider using logical connectives which satisfy both of these properties.

2.3 Notation

This section summarizes the notation we shall use in this chapter. All syntactic classes (i.e. x, B, Ω, etc.) can also be subscripted or primed.

For the sake of simplicity, we shall restrict ourselves to presenting first order logical systems. Thus we shall syntactically distinguish formulas from terms. We allow atomic formulas to depend upon terms and only allow quantification over terms.

We use x, y, z to denote hypothesis labels and term variables.

We use t, s for terms and a, b for term parameters^{1}.

We use A, B, C, etc... to denote formulas.

We use (x_{1}:A_{1}) … (x_{n}:A_{n}) to denote a context, or list of labelled formula occurrences. If n is 0 then the context is empty. Note that we use juxtaposition, rather than an explicit constructor, to form contexts. In order to have unambiguous proofs, we require that all labels are unique in a given context. We tacitly assume this condition holds for all contexts in the remainder of this thesis.

We use · to explicitly denote an empty context, or list.

We also use Γ, Δ, Ω to denote contexts. We also use juxtapostion to denote context concatenation.

We use D, E to denote derivations.

We shall use the notation Δ ▷◁ Δ′ to denote the non-deterministic merging of two contexts. We define the ▷◁ relation as follows:

· ▷◁ · = · Δ(y:A) ▷◁ Δ′ = (Δ ▷◁ Δ′)(y:A) Δ ▷◁ Δ′(y:A) = (Δ ▷◁ Δ′)(y:A)

Note that ▷◁ is commutative and associative.

2.4 Unrestricted Hypothetical Judgements

We begin by reviewing a logic with unrestricted hypotheses, or familiar old intuitionistic logic. There are many informal semantics, or intuitions, which people use to think about intuitionistic logic. However, for our purposes intuitionistic logic is a way to reason about the ability to derive rather than the actual act of derivation itself. Thus we will informally treat an intuitionistic logic derivation of A as meaning we have the ability to derive A.

We start with a hypothetical judgement:

(x_{1}:A_{1}) … (x_{n}:A_{n}) ⊢ A

We shall interpret the judgement as: If we have the ability to derive each of the A_{i} then we have the ability to derive A.

1The eigenvariables “generated” by ∀_{I} and ∃_{E} rules– see the end of section 2.4.

We shall use Γ to denote unrestricted contexts.

We want our unrestricted judgements to satisfy several structural properties^{2}. Namely, we do not want the derivability of judgements to depend upon the order of the hypotheses, nor upon the presence of extra (unused) hypotheses, nor upon the presence of redundant hypotheses. We formalize these properties as follows.

Structural Properties:

Exchange: Γ_{L}(x_{1}:A)(x_{2}:B)Γ_{R} ⊢ C implies Γ_{L}(x_{2}:B)(x_{1}:A)Γ_{R} ⊢ C.

Weakening: Γ ⊢ A implies Γ(x:B) ⊢ A.

Contraction: Γ(x_{1}:A)(x_{2}:A) ⊢ B implies Γ(x_{1}:A) ⊢ B.

We will keep these properties in mind when designing the inference rules we will use. After we have a full system, we will prove as a lemma that these properties hold.

Now that we have formally introduced the notation for our hypothetical judgement and stated the structural properties it should satisfy, we must describe how to reason with such judgements. The basic intuition behind a hypothetical judgement is that we may assume we can derive the given hypotheses. We may then use hypotheses instead of actual derivations while deriving the conclusion. Thus if we are given an actual derivation of one of our hypotheses, we should be able to substitute this actual derivation for the use of the hypothesis. We formalize this intuition with the following substitution principle.

Substitution principle:

Γ_{L} ⊢ A and Γ_{L}(x:A)Γ_{R} ⊢ C implies Γ_{L}Γ_{R} ⊢ C

Note that requiring the context for A to match part of the context for C will always be achievable as long as the expected structural properties hold for the system.^{3} As with the structural rules, we will keep this substitution principle in mind when designing the inference rules and then formally prove that the substitution principle holds after we have described the full system.

2Properties of hypotheses have historically been called structural.

3We structure the substitution principle in this manner in anticipation of Chapter 13 where we shall allow dependencies among the hypotheses.

The first inference rule we will want to form is the basic rule explaining how hypotheses are used. As this rule comes from the nature of hypothetical judgements and does not pertain to any logical connective, it is neither an introduction rule nor an elimination rule.

Unrestricted hypothesis rule:

\frac{x}{Γ_{L}(x:A)Γ_{R} ⊢ A}

The formulation of this rule ensures that exchange and weakening will hold for the logic since neither the location of x nor the presence of unused hypotheses matters.

We now consider implication, which may be thought of as a reflection of the hypothetical judgement into the logic itself since it allows us to express hypothetical statements as formulas.

Unrestricted Implication:

\begin{matrix}Γ(x:A) ⊢ B \\ → & I \\ Γ ⊢ A → B \end{matrix}  \begin{matrix}Γ ⊢ A → B  Γ ⊢ A \\ → & E \\ Γ ⊢ B \end{matrix}

Note that we require the hypotheses of the premises to match those of the conclusion in the elimination rule. This, when mirrored by all rules with multiple premises, allows contraction to hold for the system without any explicit structural rules.

We now show that →, as characterized by its introduction and elimination rules, satisfies our two criteria from Section 2.2 for logical connectives. We first show that information is neither gained nor lost by constructing and then deconstructing a derivation of →. This property is formalized by the following local reduction rule:

\begin{matrix}\begin{matrix}E \\ Γ(x:A) ⊢ B \end{matrix} ; →_{I} ; Γ ⊢ A → B & \begin{matrix}D \\ Γ ⊢ A \end{matrix} \\ → & E \\ Γ ⊢ B \end{matrix}  ⟹ \begin{matrix}E[D/x] \\ Γ ⊢ B \end{matrix}

The notation E[D/x] denotes the derivation E (which is a tree) with all occurrences of the hypothesis rule x (which will all be leaves) replaced by the derivation D. Note that this reduction is just an application of the substitution principle.

We now show that a derivation of → contains sufficient information to reconstruct itself. We formalize this property with the following local expansion rule:

\begin{matrix}D \\ Γ ⊢ A → B \end{matrix} ⟹  \begin{matrix}\begin{matrix}D′ \\ Γ(x:A) ⊢ A → B \end{matrix} & \frac{x}{Γ(x:A) ⊢ A} \\ → & E \\ Γ(x:A) ⊢ B \end{matrix} ; →_{I} ; Γ ⊢ A → B

where D′ is obtained from D by weakening.

We now turn to conjunction. We should be able to express in the logic the ability to derive two conclusions. If we can derive both A and B, we shall use A & B to reflect this fact in the logic. Furthermore, given that we know A & B, we should be able to retrieve derivations of both A and B. Thus we will have two elimination rules.

Conjunction:

\begin{matrix}Γ ⊢ A Γ ⊢ B \\ & & I \\ Γ ⊢ A & B \end{matrix}  \begin{matrix}Γ ⊢ A & B \\ & & E1 \\ Γ ⊢ A \end{matrix}  \begin{matrix}Γ ⊢ A & B \\ & & E2 \\ Γ ⊢ B \end{matrix}

Again note the contraction of hypotheses in the introduction rule.

Since there are two eliminations, there are two local reductions for & depending on which elimination was used.

\begin{matrix}\begin{matrix}D_{1} \\ Γ ⊢ A \end{matrix} & \begin{matrix}D_{2} \\ Γ ⊢ B \end{matrix} \\ & & I \\ Γ ⊢ A & B \end{matrix} ; &_{E1} ; Γ ⊢ A  ⟹ \begin{matrix}D_{1} \\ Γ ⊢ A \end{matrix}

\begin{matrix}\begin{matrix}D_{1} \\ Γ ⊢ A \end{matrix} & \begin{matrix}D_{2} \\ Γ ⊢ B \end{matrix} \\ & & I \\ Γ ⊢ A & B \end{matrix} ; &_{E2} ; Γ ⊢ B  ⟹ \begin{matrix}D_{2} \\ Γ ⊢ B \end{matrix}

Here is the local expansion:

\begin{matrix}D \\ Γ ⊢ A & B \end{matrix} ⟹  \begin{matrix}\begin{matrix}D \\ Γ ⊢ A & B \end{matrix} ; &_{E_{1}} ; Γ ⊢ A & \begin{matrix}D \\ Γ ⊢ A & B \end{matrix} ; &_{E_{2}} ; Γ ⊢ B \\ & & I \\ Γ ⊢ A & B \end{matrix}

We now consider truth, ⊤, which can be thought of as the unit of &– we have A&⊤ ≡ A ≡ ⊤&A where C ≡ D denotes that both C ⊢ D and D ⊢ C are derivable. Truth is always derivable and thus carries no information. Consequently, there will be no elimination rule since there is nothing to get out of a derivation of truth.

Truth:

\frac{⊤_{I}}{Γ ⊢ ⊤}  no elimination rule for ⊤.

Although there is no reduction (since there is no elimination rule) we do have a notion of expansion. Any derivation of ⊤ can be “expanded” to an immediate derivation of truth from the same hypotheses. While this is not actually an expansion of the given proof, it is an expansion in the sense of reconstructing a proof of ⊤ from its constituent parts (i.e., none).

\begin{matrix}D \\ Γ ⊢ ⊤ \end{matrix} ⟹ \frac{⊤_{I}}{Γ ⊢ ⊤}

We now consider disjunction, the dual concept to conjunction. If we can derive A or we can derive B, we will express this in the logic as A ⊕ B.^{4} Furthermore, in order to make use of a derivation of A ⊕ B, we must specify what to do in each case since we do not know which of the disjuncts we actually have the ability to derive.

Note that there will be two different introduction rules for disjunction depending on which conclusion we can actually derive. While these introduction rules are syntactically dual to the conjunction elimination rules, our disjunction elimination rule will have to break this syntactic duality.

4We use the notation ⊕ to be compatible with notation we will introduce later.

Disjunction:

\begin{aligned}Γ ⊢ A \\ & ⊕_{I1} \\ Γ ⊢ A ⊕ B \end{aligned}  \begin{aligned}Γ ⊢ A \\ & ⊕_{I2} \\ Γ ⊢ A ⊕ B \end{aligned}  \begin{aligned}Γ ⊢ A ⊕ B  Γ(x_{1}:A) ⊢ C Γ(x_{2}:B) ⊢ C \\ & ⊕_{E} \\ Γ ⊢ C \end{aligned}

Since there are two introductions, there will be two corresponding reductions which rely upon the substitution principle.

\begin{aligned}\begin{matrix}D \\ Γ ⊢ A \end{matrix} ; ⊕_{I1} ; Γ ⊢ A ⊕ B & \begin{matrix}E_{1} \\ Γ(x_{1}:A) ⊢ C \end{matrix} & \begin{matrix}E_{2} \\ Γ(x_{2}:B) ⊢ C \end{matrix} \\ & & & ⊕_{E} \\ & Γ ⊢ C \end{aligned}  ⟹ \begin{matrix}E_{1}[D/x_{1}] \\ Γ ⊢ C \end{matrix}

\begin{aligned}\begin{matrix}D \\ Γ ⊢ B \end{matrix} ; ⊕_{I2} ; Γ ⊢ A ⊕ B & \begin{matrix}E_{1} \\ Γ(x_{1}:A) ⊢ C \end{matrix} & \begin{matrix}E_{2} \\ Γ(x_{2}:B) ⊢ C \end{matrix} \\ & & & ⊕_{E} \\ & Γ ⊢ C \end{aligned}  ⟹ \begin{matrix}E_{2}[D/x_{2}] \\ Γ ⊢ C \end{matrix}

Here is the local expansion:

\begin{matrix}D \\ Γ ⊢ A ⊕ B \end{matrix} ⟹  \begin{aligned}\begin{matrix}D \\ Γ ⊢ A ⊕ B \end{matrix} & \frac{x_{1}}{Γ(x_{1}:A) ⊢ A} ; ⊕_{I1} ; Γ(x_{1}:A) ⊢ A ⊕ B & \frac{x_{2}}{Γ(x_{2}:B) ⊢ B} ; ⊕_{I2} ; Γ(x_{2}:B) ⊢ A ⊕ B \\ & & & ⊕_{E} \\ & Γ ⊢ A ⊕ B \end{aligned}

Finally we come to falsehood, 0,^{5} which may be thought of as the unit of ⊕. Just as disjunction and conjunction are dual, 0 and ⊤ are dual. Since we want our logic to be sound, there will be no introduction rule for 0. However, we will have an elimination rule since there is no reason to prevent someone from assuming a derivation of 0.

Falsehood:

no introduction rule for 0. \begin{matrix}Γ ⊢ 0 \\ 0 & E \\ Γ ⊢ C \end{matrix}

Note that C is unconstrained; we can derive anything from a derivation of 0.

5Again we choose this notation to be forward compatible.

Since there is no introduction rule, there is no local reduction. However, there is an expansion:

\begin{matrix}D \\ Γ ⊢ 0 \end{matrix} ⟹  \begin{matrix}D \\ Γ ⊢ 0 \end{matrix} ; 0_{E} ; Γ ⊢ 0

For the sake of expressivity and completeness, we now consider quantification. We will assume the standard two quantifiers, ∀ and ∃, and show that they are locally sound and complete.

Universal quantification:

\begin{aligned}Γ ⊢ A[a/x] \\ & ∀_{I}^{a} \\ Γ ⊢ ∀x. A \end{aligned}  \begin{aligned}Γ ⊢ ∀x. A \\ & ∀_{E} \\ Γ ⊢ A[t/x] \end{aligned}

Note that a must not appear free in the conclusion of the introduction rule. This can also be construed as another kind of judgement, usually called a parametric judgement where a is the parameter. The key idea behind a parametric judgement is that the parameter may be substituted by any term without affecting derivability of the judgement.

We have the following reduction:

\begin{matrix}D \\ Γ ⊢ A[a/x] \end{matrix} ; ∀_{I}^{a} ; Γ ⊢ ∀x. A ; ∀_{E} ; Γ ⊢ A[t/x]  ⟹ \begin{matrix}D[t/a] \\ Γ ⊢ A[t/x] \end{matrix}

And the following expansion:

\begin{matrix}D \\ Γ ⊢ ∀x. A \end{matrix} ⟹  \begin{matrix}D \\ Γ ⊢ ∀x. A \end{matrix} ; ∀_{E} ; Γ ⊢ A[a/x] ; ∀_{I}^{a} ; Γ ⊢ ∀x. A

Existential quantification:

\begin{aligned}Γ ⊢ A[t/x] \\ & ∃_{I} \\ Γ ⊢ ∃x. A \end{aligned}  \begin{aligned}Γ ⊢ ∃x. A Γ(u:A[a/x]) ⊢ C \\ & ∃_{E}^{a} \\ Γ ⊢ C \end{aligned}

Note that a must not appear free in A nor in the conclusion of the elimination rule. We have the following reduction:

\begin{aligned}\begin{matrix}D \\ Γ ⊢ A[t/x] \end{matrix} ; ∃_{I} ; Γ ⊢ ∃x. A & \begin{matrix}E \\ Γ(u:A[a/x]) ⊢ C \end{matrix} \\ & & ∃_{E}^{a} \\ & Γ ⊢ C \end{aligned}  ⟹ \begin{matrix}E[t/a][D/u] \\ Γ ⊢ C \end{matrix}

And the following expansion:

\begin{matrix}D \\ Γ ⊢ ∃x. A \end{matrix} ⟹  \begin{aligned}\begin{matrix}D \\ Γ ⊢ ∃x. A \end{matrix} & \frac{u}{Γ(u:A[a/x]) ⊢ A[a/x]} ; ∃_{I} ; Γ(u:A[a/x]) ⊢ ∃x. A \\ & & ∃_{E}^{a} \\ & Γ ⊢ ∃x. A \end{aligned}

2.5 Linear Hypothetical Judgements

We now examine a logic based on linear hypotheses. Our basic hypothetical judgement will be:

(y_{1}:A_{1}) … (y_{n}:A_{n}) ⊢ A

We use hypothesis tags y_{i} to emphasize that these hypotheses are linear rather than unrestricted. We shall interpret linear hypotheses as resources which must be used exactly once. We can then interpret the judgement as: If we have all the resources A_{i} (in any order) then we can derive A.

We use Δ to denote linear contexts.

Since these hypotheses are linear, we do not want linear contexts to satisfy contraction or weakening. Therefore the only structural property which we want to build into linear contexts is exchange.

Structural Properties:

Exchange: Δ_{L}(x_{1}:A)(x_{2}:B)Δ_{R} ⊢ C implies Δ_{L}(x_{2}:B)(x_{1}:A)Δ_{R} ⊢ C.

We now state the appropriate substitution principle for linear hypothetical judgements which relates a derivation of A to a hypothesis A.

Substitution principle:

Δ_{A} ⊢ A and Δ_{L}(y:A)Δ_{R} ⊢ C implies (Δ_{L} ▷◁ Δ_{A})Δ_{R} ⊢ C

Note that we re-emphasize, in this substitution principle, the irrelevance of hypothesis ordering by combining the context needed for A and the context in which hypothesis y appears with the non-deterministic merge, ▷◁.

The hypothesis rule will look quite different from the previous one since weakening should not hold for linear hypotheses. Actually, the absence of weakening forces the rule to only allow one hypothesis– the one being used.

Linear hypothesis rule:

\frac{y}{y:A ⊢ A}

Because there can only be one hypothesis in this rule, we cannot concisely capture the exchange property as we did in the previous system. Therefore we will have to structure the other rules to allow for exchange. This will be accomplished through the use of the non-deterministic merge operator, ▷◁.

We come next to linear implication.

Linear Implication:

\begin{matrix}Δ(y:A) ⊢ B \\ −∘ & I \\ Δ ⊢ A −∘ B \end{matrix}  \begin{matrix}Δ ⊢ A −∘ B  Δ_{A} ⊢ A \\ −∘ & E \\ Δ ▷◁ Δ_{A} ⊢ B \end{matrix}

Note the absence of contraction in the elimination rule and instead the (non-deterministic) merging of the two contexts used in the premises. By merging contexts, we insure that each hypothesis is used only once (we restrict contraction). By allowing the contexts to be non-deterministically merged, we ensure that the order of the hypotheses is irrelevant (we allow exchange). Logical connectives whose inference rules require merging together, rather than contracting, premise contexts to form the conclusion context are called multiplicative.

The reduction for linear implication is, like its unrestricted counterpart, just an application of the substitution principle.

\begin{matrix}\begin{matrix}E \\ Δ(y:A) ⊢ B \end{matrix} ; −∘_{I} ; Δ ⊢ A −∘ B & \begin{matrix}D \\ Δ_{A} ⊢ A \end{matrix} \\ −∘ & E \\ Δ ▷◁ Δ_{A} ⊢ B \end{matrix}  ⟹ \begin{matrix}E[D/y] \\ Δ ▷◁ Δ_{A} ⊢ B \end{matrix}

Here is the local expansion:

\begin{matrix}D \\ Δ ⊢ A −∘ B \end{matrix} ⟹  \begin{matrix}\begin{matrix}D \\ Δ ⊢ A −∘ B \end{matrix} & \frac{y}{y:A ⊢ A} \\ −∘ & E \\ Δ(y:A) ⊢ B \end{matrix} ; −∘_{I} ; Δ ⊢ A −∘ B

All of the previously shown unrestricted connectives, &, ⊤, ⊕, 0, and the quantifiers, also make sense for linear hypothetical judgements and correspond to reasoning about the ability to derive with given resources. Thus we can interpret a derivation of the judgement Δ ⊢ A & B as: Given the resources in Δ, we have the ability to derive A; and given the resources in Δ, we have the ability to derive B. Note that this differs from saying we can derive both A and B at the same time. Similarly a derivation of Δ ⊢ A ⊕ B can be interpreted as being able to derive either A or B. These unrestricted connectives, which require that the premises and conclusion all depend upon the same linear hypotheses, are called additive.

Another notion of conjunction exists for linear hypotheses which can be interpreted as actually deriving both conjuncts, at the same time. If we have derived A using the hypotheses in Δ_{A} and we have derived B using the hypotheses in Δ_{B}, then we reflect this fact in the logic as A ⊗ B. Of course the introduction rule for ⊗ must have in its conclusion a context created by combining Δ_{A} and Δ_{B} since both are needed.

In order to use a derivation of A ⊗ B, we cannot directly recover a derivation of A nor of B since we don’t know which hypotheses were used by each derivation. An attempt to form such an elimination rule (along the lines of those in the previous section) would result in ⊗ not having both a local reduction and a local expansion. Instead, we can only use a derivation of A ⊗ B when we know that hypotheses y_{1}:A and y_{2}:B are needed in another derivtion. Then, we can replace the two hypotheses y_{1}:A and y_{2}:B with the hypotheses needed to derive A and B.

Multiplicative Conjunction:

\begin{aligned}Δ_{A} ⊢ A Δ_{B} ⊢ B \\ & ⊗_{I} \\ Δ_{A} ▷◁ Δ_{B} ⊢ A ⊗ B \end{aligned}  \begin{aligned}Δ ⊢ A ⊗ B  Δ′(y_{1}:A)(y_{2}:B) ⊢ C \\ & ⊗_{E} \\ Δ′ ▷◁ Δ ⊢ C \end{aligned}

We use Δ_{A} ▷◁ Δ_{B} to combine contexts since we do not care about the order of the hypotheses; i.e., we want the exchange property to hold.

We have the following reduction:

\begin{aligned}\begin{matrix}D_{1} \\ Δ_{A} ⊢ A \end{matrix} & \begin{matrix}D_{2} \\ Δ_{B} ⊢ B \end{matrix} \\ & ⊗_{I} \\ Δ_{A} ▷◁ Δ_{B} ⊢ A ⊗ B \end{aligned}  \begin{matrix}E \\ Δ′(y_{1}:A)(y_{2}:B) ⊢ C \end{matrix}
⊗_{E}
Δ′ ▷◁ Δ_{A} ▷◁ Δ_{B} ⊢ C

⟹

\begin{matrix}E[D_{1}/y_{1}][D_{2}/y_{2}] \\ Δ′ ▷◁ Δ_{A} ▷◁ Δ_{B} ⊢ C \end{matrix}

We have the following expansion:

\begin{matrix}D \\ Δ ⊢ A ⊗ B \end{matrix} ⟹  \begin{aligned}\begin{matrix}D \\ Δ ⊢ A ⊗ B \end{matrix} & \begin{aligned}\frac{y_{1}}{y_{1}:A ⊢ A} & \frac{y_{2}}{y_{2}:B ⊢ B} \\ & ⊗_{I} \\ (y_{1}:A)(y_{2}:B) ⊢ A ⊗ B \end{aligned} \\ & & ⊗_{E} \\ & Δ ⊢ A ⊗ B \end{aligned}

Just as in the unrestricted case, we can consider the unit of this conjunction. The multiplicative unit, 1, must in essence be an empty derivation– a derivation requiring no hypotheses and thus a derivation of nothing. However, unlike the additive unit, ⊤, we can formulate both an introduction and elimination rule for 1.

Multiplicative unit:

\frac{1_{I}}{· ⊢ 1}  \begin{matrix}Δ′ ⊢ 1 Δ ⊢ A \\ 1 & E \\ Δ′ ▷◁ Δ ⊢ A \end{matrix}

Note that these rules are the 0-ary versions of the rules for ⊗.

We have the following reduction:

\begin{aligned}\frac{1_{I}}{· ⊢ 1} & & \begin{matrix}E \\ Δ ⊢ C \end{matrix} \\ 1 & E \\ & Δ ⊢ C \end{aligned}  ⟹ \begin{matrix}E \\ Δ ⊢ C \end{matrix}

We have the following expansion:

\begin{matrix}D \\ Δ ⊢ 1 \end{matrix} ⟹  \begin{aligned}\begin{matrix}D \\ Δ ⊢ 1 \end{matrix} & \frac{1_{I}}{· ⊢ 1} \\ 1 & E \\ & Δ ⊢ 1 \end{aligned}

While researchers have considered a multiplicative disjunction for intuitionistic linear logic [7], there seems to be no way to fit such a construction into the judgemental framework we have been developing. The notion of multiplicative disjunction seems to require allowing more than one conclusion for each judgement and thus falls outside the scope of a Martin-Löf-style natural deduction system.

2.6 Ordered Hypothetical Judgements

We finally consider a logic of ordered hypotheses. This logic is essentially the Lambek calculus [32], reconstructed from a judgemental point of view. Once again we will start with a hypothetical judgement:

(z_{1}:A_{1}) … (z_{n}:A_{n}) ⊢ A

where we use hypothesis tags z_{i} to distinguish ordered hypotheses from linear and unrestricted ones. Our interpretation of this basic judgement shall be: We can derive A when given all the resources A_{i} in order.

The ordered context, Ω, shall not enjoy any of the three structural properties. We have the following substitution principle for ordered hypothetical judgements.

Ordered substitution:

Ω ⊢ A and Ω_{L}(z:A)Ω_{R} ⊢ C implies Ω_{L}ΩΩ_{R} ⊢ C

Note that the hypotheses needed for A must be placed, in order, in the same location which the hypothesis A occupied in the context for C.

Since all the ordered hypotheses must be used, our ordered hypothesis rule is forced and is identical to the linear version.

Ordered hypothesis rule:

\frac{z}{z:A ⊢ A}

The treatment of ordered implication (i.e., how to reflect ordered hypothetical reasoning into the logic) is more complicated than for linear implication. Since ordered contexts will not admit the exchange rule, we have to think about where to put the new hypothesis in the ordered context. As it turns out, there are only two feasible choices for placing a new hypothesis into the ordered context.

The first possibility is to place the new hypothesis on the right of the all the other hypotheses.

Right ordered implication:

\begin{matrix}Ω(z:A) ⊢ B \\ ↠ & I \\ Ω ⊢ A ↠ B \end{matrix}  \begin{matrix}Ω ⊢ A ↠ B  Ω_{A} ⊢ A \\ ↠ & E \\ ΩΩ_{A} ⊢ B \end{matrix}

Note that the combination of hypotheses ΩΩ_{A}, the concatenation of Ω and Ω_{A}, in the elimination rule is forced in order for there to be a local reduction rule.

\begin{matrix}\begin{matrix}E \\ Ω(z:A) ⊢ B \end{matrix} ; ↠_{I} ; Ω ⊢ A ↠ B & \begin{matrix}D \\ Ω_{A} ⊢ A \end{matrix} \\ ↠ & E \\ ΩΩ_{A} ⊢ B \end{matrix}  ⟹ \begin{matrix}E[D/z] \\ ΩΩ_{A} ⊢ B \end{matrix}

Here is the local expansion:

\begin{matrix}D \\ Ω ⊢ A ↠ B \end{matrix} ⟹  \begin{matrix}\begin{matrix}D \\ Ω ⊢ A ↠ B \end{matrix} & \frac{z}{z:A ⊢ A} \\ ↠ & E \\ Ω(z:A) ⊢ B \end{matrix} ; ↠_{I} ; Ω ⊢ A ↠ B

The other possibility for an ordered implication is to place the hypothesis on the left of the ordered context.

Left ordered implication:

\begin{matrix}(z:A)Ω ⊢ B \\ ↣ & I \\ Ω ⊢ A ↣ B \end{matrix}  \begin{matrix}Ω ⊢ A ↣ B  Ω_{A} ⊢ A \\ ↣ & E \\ Ω_{A}Ω ⊢ B \end{matrix}

Note the reverse combination, Ω_{A}Ω, from the ↠_{E} rule is needed in this elimination rule.

We have the following local reduction:

\begin{matrix}\begin{matrix}E \\ (z:A)Ω ⊢ B \end{matrix} ; ↣_{I} ; Ω ⊢ A ↣ B & \begin{matrix}D \\ Ω_{A} ⊢ A \end{matrix} \\ ↣ & E \\ Ω_{A}Ω ⊢ B \end{matrix}  ⟹ \begin{matrix}E[D/y] \\ Ω_{A}Ω ⊢ B \end{matrix}

We have the following expansion:

\begin{matrix}D \\ Ω ⊢ A ↣ B \end{matrix} ⟹  \begin{matrix}\begin{matrix}D \\ Ω ⊢ A ↣ B \end{matrix} & \frac{z}{z:A ⊢ A} \\ ↣ & E \\ (z:A)Ω ⊢ B \end{matrix} ; ↣_{I} ; Ω ⊢ A ↣ B

Note that our choice of notation for the ordered implications has nothing to do with monics or epics from category theory and that Lambek used a slightly different notation for the two ordered implications. Specifically, A ↠ B was written as B/A, and A ↣ B was written as A\B. We feel that the arrow notation is easier to read; furthermore, it allows us to use the familiar backwards arrow notation for logic programming in Chapter 10.

We do not have any other ordered implications because there is no way to formulate complementary introduction and elimination rules when hypotheses are added to any other location in the ordered context. Suppose we tried to place the new hypothesis somewhere in the middle of the ordered context. In order to have a general rule, we could not require an exact number of other hypotheses to already be in the ordered context, e.g., placing a hypothesis two formulas from the right is not a good rule. The only other choice is to non-deterministically place the hypothesis somewhere in the ordered context. When we try to do this, we do not have enough information, in the elimination rule, to ensure that we get back a derivation of the same judgement we started with after applying a local reduction.

At this point we give several examples of derivable and non-derivable ordered hypothetical judgements which give a feel for the ordered implications. We assume implications are left-associative. First, the judgement · ⊢ A ↠ (A ↠ B) ↠ B is not derivable because the A will be on the wrong side of the A↠B in the ordered context. However, · ⊢ (A ↠ B) ↠ A ↠ B is derivable. Similarly, · ⊢ A ↠ (A ↠ B) ↣ B is derivable.

Like the linear hypothetical judgement, all of the additive connectives, and quantifiers, make sense for the ordered hypothetical judgement. However, the multiplicative connectives must be modified to ensure that exchange will not hold. Similarly to the implications, there will be two multiplicative conjunctions since the order in which the conjuncts were derived matters.

Right multiplicative conjunction:

\begin{aligned}Ω_{A} ⊢ A Ω_{B} ⊢ B \\ & •_{I} \\ Ω_{A}Ω_{B} ⊢ A • B \end{aligned}  \begin{aligned}Ω ⊢ A • B  Ω_{L}(z_{1}:A)(z_{2}:B)Ω_{R} ⊢ C \\ & •_{E} \\ Ω_{L}ΩΩ_{R} ⊢ C \end{aligned}

The reduction rule for this conjunction is similar to the rule for linear multiplicative conjunction.

\begin{aligned}\begin{matrix}D_{1} \\ Ω_{A} ⊢ A \end{matrix} & \begin{matrix}D_{2} \\ Ω_{B} ⊢ B \end{matrix} \\ & •_{I} \\ Ω_{A}Ω_{B} ⊢ A • B \end{aligned}  \begin{matrix}E \\ Ω_{L}(z_{1}:A)(z_{2}:B)Ω_{R} ⊢ C \end{matrix}
•_{E}
Ω_{L}Ω_{A}Ω_{B}Ω_{R} ⊢ C

⟹

\begin{matrix}E[D_{1}/z_{1}][D_{2}/z_{2}] \\ Ω_{L}Ω_{A}Ω_{B}Ω_{R} ⊢ C \end{matrix}

We have the following expansion:

\begin{matrix}D \\ Ω ⊢ A • B \end{matrix} ⟹  \begin{aligned}\begin{matrix}D \\ Ω ⊢ A • B \end{matrix} & \begin{aligned}\frac{z_{1}}{z_{1}:A ⊢ A} & \frac{z_{2}}{z_{2}:B ⊢ B} \\ & •_{I} \\ (z_{1}:A)(z_{2}:B) ⊢ A • B \end{aligned} \\ & & •_{E} \\ & Ω ⊢ A • B \end{aligned}

Note that (A • B) ↠ C ≡ A ↠ B ↠ C which effectively states that • is left-adjunct to ↠ as might be expected. We also point out the equivalence breaks if we replace ↠ by ↣; however if we switch the order of A and B we find that (B •A)↣C ≡ A↣B ↣C does hold.

Here is the other multiplicative conjunction which can be thought of as reversing the orders of the conjuncts when used.

Left multiplicative conjunction:

\begin{aligned}Ω_{A} ⊢ A Ω_{B} ⊢ B \\ & ∘_{I} \\ Ω_{A}Ω_{B} ⊢ B ∘ A \end{aligned}  \begin{aligned}Ω ⊢ B ∘ A Ω_{L}(z_{1}:A)(z_{2}:B)Ω_{R} ⊢ C \\ & ∘_{E} \\ Ω_{L}ΩΩ_{R} ⊢ C \end{aligned}

Note the reversal of A and B between the premises in the elimination rule. Now we can formulate the following reduction:

\begin{aligned}\begin{matrix}D_{1} \\ Ω_{A} ⊢ A \end{matrix} & \begin{matrix}D_{2} \\ Ω_{B} ⊢ B \end{matrix} \\ & ∘_{I} \\ Ω_{A}Ω_{B} ⊢ B ∘ A \end{aligned}  \begin{matrix}E \\ Ω_{L}(z_{1}:A)(z_{2}:B)Ω_{R} ⊢ C \end{matrix}
∘_{E}
Ω_{L}Ω_{A}Ω_{B}Ω_{R} ⊢ C

⟹

\begin{matrix}E[D_{1}/z_{1}][D_{2}/z_{2}] \\ Ω_{L}Ω_{A}Ω_{B}Ω_{R} ⊢ C \end{matrix}

We have the following expansion:

\begin{matrix}D \\ Ω ⊢ B ∘ A \end{matrix} ⟹  \begin{aligned}\begin{matrix}D \\ Ω ⊢ B ∘ A \end{matrix} & \begin{aligned}\frac{z_{1}}{z_{1}:A ⊢ A} & \frac{z_{2}}{z_{2}:B ⊢ B} \\ & ∘_{I} \\ (z_{1}:A)(z_{2}:B) ⊢ B ∘ A \end{aligned} \\ & & ∘_{E} \\ & Ω ⊢ B ∘ A \end{aligned}

Note that (A ∘ B) ↣ C ≡ A ↣ B ↣ C which effectively states that ∘ is left-adjunct to ↣ as might also be expected. Furthermore, A ∘ B is equivalent to B • A.

Since it involves no resources, the multiplicative unit is the same as in the linear case.

2.7 Combined Reasoning

We would like to combine the three modes of reasoning into one coherent logical system which allows us to use unrestricted, linear, and ordered hypotheses side-by-side. For this purpose we shall begin with a compound hypothetical judgement containing three contexts, one for each kind of hypothesis.

Γ; Δ; Ω ⊢ A

We will now need to formulate three substitution principles, one explaining how to use each kind of hypothesis. First consider how to relate ordered hypotheses to derivations. Suppose we know

\begin{matrix}E \\ Γ; Δ; Ω_{L}(z:A)Ω_{R} ⊢ C \end{matrix}  and  \begin{matrix}D \\ Γ; Δ_{A}; Ω_{A} ⊢ A \end{matrix}

We would like to be able to substitute occurrences of z in E with D to get a new derivation of C which doesn’t depend upon z. However, what about the linear and ordered hypotheses used in D? Since z is an ordered hypthesis, it only occurs once in E and this occurrence respects z’s place in the ordered context. Therefore, we may just throw in Δ_{A} with Δ and replace z with Ω_{A} without anything going wrong (see lemma 2). Then we get the following derivation:

\begin{matrix}E[D/z] \\ Γ; Δ ▷◁ Δ_{A}; Ω_{L}ΩΩ_{R} ⊢ C \end{matrix}

What happens when we try to substitute derivations for linear hypotheses? Suppose we know

\begin{matrix}E \\ Γ; Δ(y:A); Ω ⊢ C \end{matrix}  and  \begin{matrix}D \\ Γ; Δ_{A}; Ω_{A} ⊢ A \end{matrix}

We can proceed as before except for the placement of Ω_{A}. Since y is not an ordered variable, its usage in E is not constrained by the order of the variables in Ω. This leaves us with no safe place to put Ω_{A} since we have no way of knowing which parts of Ω will have been used at the time y is used. Consider the following example:

\begin{matrix}E \\ ·; y:A; z:B ⊢ C \end{matrix} \frac{z′}{·; ·; z′:A ⊢ A} = D

Note that C may be either A • B or B • A.

There are only two possible ways to substitute D for y:

\begin{matrix}E[D/y] \\ ·; ·; (z′:A)(z:B) ⊢ C \end{matrix}  or  \begin{matrix}E[D/y] \\ ·; ·; (z:B)(z′:A) ⊢ C \end{matrix}

However neither resulting judgement is derivable for both of the previously mentioned choices for C.

The only way we can safely substitute a derivation D for y is if D does not require ordered hypotheses. Similar reasoning shows us that we may only substitute a derivation for an unrestricted hypothesis if that derivation doesn’t depend upon ordered or linear hypotheses.

We now state the substitution principles we have arrived at:

Substitution principles:

Γ_{A}(x:A)Γ; Δ; Ω ⊢ C and Γ_{A}; ·; · ⊢ A implies Γ_{A}Γ; Δ; Ω ⊢ C.

Γ; Δ_{L}(y:A)Δ_{R}; Ω ⊢ C and Γ; Δ_{A}; · ⊢ A implies Γ; (Δ_{L} ▷◁ Δ_{A})Δ_{R}; Ω ⊢ C.

Γ; Δ; Ω_{L}(z:A)Ω_{R} ⊢ C and Γ; Δ_{A}; Ω_{A} ⊢ A implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}Ω_{R} ⊢ C.

The same considerations used to formulate the substitution principles must also guide the formulation of the inference rules. Thus we have the following rules for unrestricted implication:

\begin{matrix}ΓA; Δ; Ω ⊢ B \\ → & I \\ Γ; Δ; Ω ⊢ A → B \end{matrix}  \begin{matrix}Γ; Δ; Ω ⊢ A → B  Γ; ·; · ⊢ A \\ → & E \\ Γ; Δ; Ω ⊢ B \end{matrix}

where the linear and ordered contexts in the minor premise of the elimination rule must be empty.

For a presentation, using the three context hypothetical judgement, of the all the connectives previously considered see Section 2.10.

2.8 Modalities

While motivating the substitution principles, we concluded that we can only substitute linear hypotheses with derivations which require empty ordered contexts; and likewise we can only substitute unrestricted hypotheses with derivations which require empty linear and empty ordered contexts. These properties can be reflected into the logic with the use of unary connectives, which we sometimes call modalities. Thus we will introduce two modalities, ¡ and !^{6}, to respectively express independence from ordered hypotheses, and from both ordered and linear hypotheses. Their introduction rules are as follows:

\begin{matrix}Γ; Δ; · ⊢ A \\ ¡ & I \\ Γ; Δ; · ⊢ ¡A \end{matrix}  \begin{matrix}Γ; ·; · ⊢ A \\ ! & I \\ Γ; ·; · ⊢ !A \end{matrix}

The elimination rules for these modalities will reflect our intuition that they capture exactly what is needed to be substitutable for linear and unrestricted hypotheses.

Γ; Δ; Ω ⊢ ¡A Γ; Δ_{L}(y:A)Δ_{R}; Ω_{L}Ω_{R} ⊢ C

¡_{E} Γ; (Δ_{L} ▷◁ Δ)Δ_{R}; Ω_{L}ΩΩ_{R} ⊢ C

Γ; Δ; Ω ⊢ !A Γ(x:A)Γ′; Δ_{C}; Ω_{L}Ω_{R} ⊢ C
!_{E}
ΓΓ′; Δ_{C} ▷◁ Δ; Ω_{L}ΩΩ_{R} ⊢ C

6This is the same ! as in linear logic.

These elimination rules are simply the substitution principles for linear and unrestricted hypotheses without constraints on the contexts. These constraints have been captured by the modalities.

Both these connectives also satisfy our local soundness and completeness criteria as shown by the following local reductions and expansions:

Reduction for ¡:

\begin{matrix}D \\ Γ; Δ_{A}; · ⊢ A \end{matrix} ; ¡_{I} ; Γ; Δ_{A}; · ⊢ ¡A  \begin{matrix}E \\ Γ; Δ_{L}(y:A)Δ_{R}; Ω ⊢ C \end{matrix}
¡_{E} Γ; (Δ_{L} ▷◁ Δ_{A})Δ_{R}; Ω ⊢ C

⟹

E[D/y] Γ; (Δ_{L} ▷◁ Δ_{A})Δ_{R}; Ω ⊢ C

Expansion for ¡:

D Γ; Δ; Ω ⊢ ¡A

⟹ \begin{matrix}D \\ Γ; Δ; Ω ⊢ ¡A \end{matrix} \frac{y}{Γ; y:A; · ⊢ A} ; ¡_{I} ; Γ; y:A; · ⊢ ¡A

¡_{E} Γ; Δ; Ω ⊢ ¡A

Reduction for !:

\begin{matrix}D \\ Γ; ·; · ⊢ A \end{matrix} ; !_{I} ; Γ; ·; · ⊢ !A  \begin{matrix}E \\ Γ(x:A)Γ′; Δ; Ω ⊢ C \end{matrix}
!_{E} Γ; Δ; Ω ⊢ C

⟹

E[D/x] ΓΓ′; Δ; Ω ⊢ C

Expansion for !:

D Γ; Δ; Ω ⊢ !A

⟹ \begin{matrix}D \\ Γ; Δ; Ω ⊢ !A \end{matrix} \frac{x}{Γ(x:A); ·; · ⊢ A} ; !_{I} ; Γ(x:A); ·; · ⊢ !A

!_{E} Γ; Δ; Ω ⊢ !A

Note that both of these modalities are idempotent (!!A ≡ !A and ¡¡A ≡ ¡A) and that ! subsumes ¡ (!¡A ≡ !A and ¡!A ≡ !A)^{7}. Therefore, we do not get new modalities

7We now use C ≡ D to denote that both ·; ·; C ⊢ D and ·; ·; D ⊢ C are derivable.

from combinations of these two. We also point out that the unrestricted and linear implications are definable using these modalities: A → B ≡ (!A) ↠ B ≡ (!A) ↣ B and A −∘ B ≡ (¡A) ↠ B ≡ (¡A) ↣ B.

The equivalences for −∘ are established from the following substitution:

D = \frac{y}{Γ; y:A; · ⊢ A} ; ¡_{I} ; Γ; y:A; · ⊢ ¡A and \begin{matrix}E \\ Γ; Δ; Ω_{L}(z:¡A)Ω_{R} ⊢ C \end{matrix} ⟹ \begin{matrix}E[D/z] \\ Γ; Δ ▷◁ (y:A); Ω_{L}Ω_{R} ⊢ C \end{matrix}

and the following derivation:

\frac{z}{Γ; ·; z:¡A ⊢ ¡A}  \begin{matrix}D \\ Γ; Δ(y:A); Ω_{L}Ω_{R} ⊢ C \end{matrix}
¡_{E} Γ; Δ; Ω_{L}(z:¡A)Ω_{R} ⊢ C

which show that “mobilized” ordered hypotheses, i.e., ordered hypotheses of the form ¡A, are essentially (when considering derivability) the same as linear hypotheses. Similar results hold for “banged” ordered hypotheses (!A) and unrestricted hypotheses.

The modalities, ! and ¡, only partially distribute across the binary connectives. In particular the following are all derivable judgements

·; ·; !(A↠B) ⊢ !A↠!B ·; ·; !A•!B ⊢ !(A•B) ·; ·; !(A&B) ⊢ !A&!B ·; ·; !A⊕!B ⊢ !(A⊕B)

while none of their converses are derivable. Furthermore, replacing ! with ¡, • with ∘ or ↠ with ↣ does not affect derivability.

At this point our development of ordered linear logic is complete. Note that the unordered fragment of this logic is identical to intuitionistic linear logic^{8}. Before giving a full description of the system, we would like to point out that there are other possibilities for combining these various modes of reasoning.

2.9 Other Approaches to Combined Reasoning

Our system, following the tradition of linear logic, combines unrestricted, linear and ordered reasoning about hypotheses; it is the hypotheses which have constraints placed upon their usage. Another possibility is to place constraints at the context

8A ⊗ B, in linear logic, is equivalent to ¡A • ¡B in ordered linear logic.

level and have “mixed” contexts. This is the approach espoused by the logic of bunched implications (BI) [40] which combines unrestricted and linear reasoning (but not ordered reasoning).

In BI, contexts are not flat lists but trees. It is the tree nodes which are either unrestricted or linear. This system has two implications, → for unrestricted reasoning and →∗ for linear reasoning. The two implications correspond to two different context constructors, one of which allows either of its arguments to be copied and erased. Thus the judgement · ⊢ A →∗ B → B is derivable (where · denotes either empty context) while · ⊢ B →A→∗B is not derivable. It seems likely that one could extend BI with an ordered implication and an ordered context constructor and thus have an entirely different system from ordered linear logic which combines unrestricted, linear, and ordered reasoning.

A further possibility is to combine the formula level approach with the context level approach. That is to have a system like BI which also has modalities. This is essentially how Non-commutative Logic (NL) [1, 57] was constructed. NL combines all three types of reasoning, however unrestricted reasoning is limited to the formula level, by the use of a modality, while linear and ordered reasoning take place at the context level. Thus NL’s context is a tree-like hierarchical structure (more specifically a generalization of strict partial orders called order varieties) where all nodes are linear and some nodes are ordered. This forces the mobility of formulas to be scoped.

NL is presented as a classical logic. It is thus presented as a single-sided sequent system. Furthermore its context is circular in order to have a single negation. However, there is an intuitionistic version of NL [58, 16] which does not have a circular context.

Finally, we note that ordered linear logic can be thought of as an intuitionistic version of cyclic linear logic [61], which was an early attempt to combine ordered reasoning with linear logic. However, ordered linear logic was developed independently of cyclic linear logic and has a solid basis in the tradition Martin-Löf style logic. Because of this intuitionistic grounding, ordered linear logic gives rise to a term calculus and is a suitable basis for an LF style logical framework [23].

2.10 Derivation Rules for Ordered Linear Logic

In this section we summarize the derivation rules for ordered linear logic.

\frac{x}{Γ_{L}(x:A)Γ_{R}; ·; · ⊢ A} \frac{y}{Γ; y:A; · ⊢ A} \frac{z}{Γ; ·; z:A ⊢ A}
\begin{matrix}Γ(x:A); Δ; Ω ⊢ B \\ → & I \\ Γ; Δ; Ω ⊢ A → B \end{matrix} \begin{matrix}Γ; Δ; Ω ⊢ A → B  Γ; ·; · ⊢ A \\ → & E \\ Γ; Δ; Ω ⊢ B \end{matrix}

\begin{matrix}Γ; Δ(y:A); Ω ⊢ B \\ −∘ & I \\ Γ; Δ; Ω ⊢ A −∘ B \end{matrix} Γ; Δ; Ω ⊢ A −∘ B Γ; Δ_{A}; · ⊢ A −∘_{E}

Γ; Δ ▷◁ Δ_{A}; Ω ⊢ B

\begin{matrix}Γ; Δ; Ω(z:A) ⊢ B \\ ↠ & I \\ Γ; Δ; Ω ⊢ A ↠ B \end{matrix} Γ; Δ; Ω ⊢ A ↠ B Γ; Δ_{A}; Ω_{A} ⊢ A ↠_{E}

Γ; Δ ▷◁ Δ_{A}; ΩΩ_{A} ⊢ B

\begin{matrix}Γ; Δ; (z:A)Ω ⊢ B \\ ↣ & I \\ Γ; Δ; Ω ⊢ A ↣ B \end{matrix} Γ; Δ; Ω ⊢ A ↣ B Γ; Δ_{A}; Ω_{A} ⊢ A ↣_{E}

Γ; Δ ▷◁ Δ_{A}; Ω_{A}Ω ⊢ B

Γ; Δ_{A}; Ω_{L} ⊢ A Γ; Δ_{B}; Ω_{R} ⊢ B •_{I}

Γ; Δ_{A} ▷◁ Δ_{B}; Ω_{L}Ω_{R} ⊢ A • B

Γ; Δ; Ω ⊢ A • B Γ; Δ_{C}; Ω_{L}(z_{1}:A)(z_{2}:B)Ω_{R} ⊢ C •_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C

Γ; Δ_{A}; Ω_{R} ⊢ A Γ; Δ_{B}; Ω_{L} ⊢ B ∘_{I}

Γ; Δ_{A} ▷◁ Δ_{B}; Ω_{L}Ω_{R} ⊢ B ∘ A

Γ; Δ; Ω ⊢ B ∘ A Γ; Δ_{C}; Ω_{L}(z_{1}:A)(z_{2}:B)Ω_{R} ⊢ C ∘_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C

\frac{1_{I}}{Γ; ·; · ⊢ 1} Γ; Δ; Ω ⊢ 1 Γ; Δ_{C}; Ω_{L}Ω_{R} ⊢ C 1_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C

Γ; Δ; Ω ⊢ A Γ; Δ; Ω ⊢ B &_{I}

Γ; Δ; Ω ⊢ A & B

\begin{matrix}Γ; Δ; Ω ⊢ A & B \\ & & E1 \\ Γ; Δ; Ω ⊢ A \end{matrix} \begin{matrix}Γ; Δ; Ω ⊢ A & B \\ & & E2 \\ Γ; Δ; Ω ⊢ B \end{matrix}

\begin{matrix}Γ; Δ; Ω ⊢ A \\ ⊕ & I1 \\ Γ; Δ; Ω ⊢ A ⊕ B \end{matrix}  \begin{matrix}Γ; Δ; Ω ⊢ B \\ ⊕ & I2 \\ Γ; Δ; Ω ⊢ A ⊕ B \end{matrix}

Γ; Δ; Ω ⊢ A ⊕ B Γ; Δ_{C}; Ω_{L}(z_{1}:A)Ω_{R} ⊢ C Γ; Δ_{C}; Ω_{L}(z_{2}:B)Ω_{R} ⊢ C

⊕_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C

\frac{⊤_{I}}{Γ; Δ; Ω ⊢ ⊤} Γ; Δ; Ω ⊢ 0 0_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C
\begin{aligned}Γ; Δ; Ω ⊢ [a/x]A \\ & ∀_{I}^{a} \\ Γ; Δ; Ω ⊢ ∀x. A \end{aligned} \begin{aligned}Γ; Δ; Ω ⊢ ∀x. A \\ & ∀_{E} \\ Γ; Δ; Ω ⊢ [t/x]A \end{aligned}

\begin{aligned}Γ; Δ; Ω ⊢ [t/x]A \\ & ∃_{I} \\ Γ; Δ; Ω ⊢ ∃x. A \end{aligned} Γ; Δ; Ω ⊢ ∃x. A Γ; Δ_{C}; Ω_{L}(z:A[a/x])Ω_{R} ⊢ C ∃_{E}^{a}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C

\begin{matrix}Γ; Δ; · ⊢ A \\ ¡ & I \\ Γ; Δ; · ⊢ ¡A \end{matrix} Γ; Δ; Ω ⊢ ¡A Γ; Δ_{L}(y:A)Δ_{R}; Ω_{L}Ω_{R} ⊢ C ¡_{E}

Γ; (Δ_{L} ▷◁ Δ)Δ_{R}; Ω_{L}ΩΩ_{R} ⊢ C

\begin{matrix}Γ; ·; · ⊢ A \\ ! & I \\ Γ; ·; · ⊢ !A \end{matrix} Γ; Δ; Ω ⊢ !A Γ(x:A); Δ_{C}; Ω_{L}Ω_{R} ⊢ C !_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C

where a must not appear free in the conclusion the ∀_{I}^{a} rule; similarly, a must not appear free in the first premise nor the conclusion of the ∃_{E}^{a} rule.

2.11 Properties of Ordered Linear Logic

We now formally state and prove that the expected structural properties and substitution principles hold for ordered linear logic. Lemma 1 (Structural Properties) The following all hold:

1. Γ_{L}(x_{1}:A)(x_{2}:A)Γ_{R}; Δ; Ω ⊢ C implies Γ_{L}(x:A)Γ_{R}; Δ; Ω ⊢ C.

2. Γ_{L}Γ_{R}; Δ; Ω ⊢ C implies Γ_{L}(x:A)Γ_{R}; Δ; Ω ⊢ C.

3. Γ_{L}(x_{1}:A)(x_{2}:B)Γ_{R}; Δ; Ω ⊢ C implies Γ_{L}(x_{2}:B)(x_{1}:A)Γ_{R}; Δ; Ω ⊢ C.

4. Γ; Δ_{L}(y_{1}:A)(y_{2}:B)Δ_{R}; Ω ⊢ C implies Γ; Δ_{L}(y_{2}:B)(y_{1}:A)Δ_{R}; Ω ⊢ C.

Proof: By structural induction on the given derivation. Note that this induction defines a structure preserving translation—only the hypotheses change for each judgment in a derivation. □

Lemma 2 (Substitution) The following hold:

1. Γ_{A}(x:A)Γ; Δ; Ω ⊢ C and Γ_{A}; ·; · ⊢ A implies Γ_{A}Γ; Δ; Ω ⊢ C.

2. Γ; Δ_{L}(y:A)Δ_{R}; Ω ⊢ C and Γ; Δ_{A}; · ⊢ A implies Γ; (Δ_{L} ▷◁ Δ_{A})Δ_{R}; Ω ⊢ C.

3. Γ; Δ; Ω_{L}(z:A)Ω_{R} ⊢ C and Γ; Δ_{A}; Ω_{A} ⊢ A implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}Ω_{R} ⊢ C.

Proof: By structural induction over the given derivation for C. Again we have a structure preserving translation where every use of A in the deduction of C is replaced by the given deduction of A. □

We have already shown that each connective in the logic is locally sound and complete for a single context logic. Given the introduction and elimination rules of Section 2.10, it is a simple task to extend the previous local reductions and expansions to ordered linear logic.

Now that we have a complete logical system we would like to show that it is a “good” logic. The standard test for a natural deduction system is normalization. The local reductions for each connective provide a local normalization result, but this is not enough to guarantee a global result. Thus, we will prove a normalization result for ordered linear logic.

Although it is possible, using a Kripke-style logical-relations argument, we will not directly prove a normalization result on the natural deduction system presented in this chapter. Instead, we will follow Gentzen’s path and prove a cut-elimination result for a sequent calculus which is equivalent (in terms of derivability) to the natural deduction system. In addition to helping us prove normalization of ordered linear logic, the sequent calculus system is of interest in its own right.

Specifically, we will prove normalization as follows:

1. Introduce a normal natural deduction system for ordered linear logic.

(a) This system will only allow normal derivations.

(b) Normal derivations are trivially converted to arbitrary derivations.

2. Introduce a cut-free sequent calculus for ordered linear logic.

3. Show admissibility of cut for sequent system.

4. Show equivalence of arbitrary natural deductions and a sequent system with cut.

5. Show equivalence of normal natural deduction system and cut-free sequent calculus.

The subsequent three chapters will be occupied with executing this plan.

48

Normal Deductions

A normal deduction is one in which no unnecesary paths are taken when proceeding from hypotheses to conclusions– in other words, a derivation in which no formula is derived and then later eliminated. The intuition behind this property is the same which underlies the local reductions (and expansions) examined in the previous chapter: the conservation of information by the introduction/elimination rule pairs. However, the local reductions for each connective only cover introductions immediately followed by eliminations. They are not directly applicable to situations where a formula, A, is introduced and other formulas are eliminated (possibly modifying contexts) before eliminating A.

As noted by Prawitz [55], normal deductions correspond very well to natural human reasoning. Specifically, a normal derivation can be separated into two parts. One part consists of breaking down the given hypotheses, using the elimination rules, until all the parts needed to assemble the desired conclusion are obtained. The other part consists of producing the conclusion using the introduction rules. A further nice fact about normal derivations is that they enjoy the subformula property– every formula in a derivation is a subformula of the conclusion, or of some hypothesis in the last judgement. This property is absolutely necessary if there is to be any hope of automating proof search, which we wish to do in order to have an ordered linear logic programming language.

In this chapter, we present a refined system of natural deduction for ordered linear logic which only admits normal deductions. This system is based on separating normal deductions, characterized by bottom-up reasoning with introduction rules, from atomic deductions, characterized by top-down reasoning with elimination rules. These two can meet at any point with a coercion which allows us to view any atomic deduction as normal.

3.1 Normal Deductions for Ordered Linear Logic

We characterize normal deductions with two judgements:

Γ; Δ; Ω ⊢ A ↑ A has a normal derivation
Γ; Δ; Ω ⊢ A ↓ A has an atomic derivation

The arrow indicates the direction of reasoning allowed.

Below are the judgements for the normal natural deduction system. To improve readability, we leave hypothesis labels implicit and use generic names for the hypothesis rules.

\frac{ihyp}{Γ_{L}AΓ_{R}; ·; · ⊢ A ↓} \frac{lhyp}{Γ; A; · ⊢ A ↓} \frac{ohyp}{Γ; ·; A ⊢ A ↓} Γ; Δ; Ω ⊢ A ↓ ; coercion ; Γ; Δ; Ω ⊢ A ↑

\begin{matrix}ΓA; Δ; Ω ⊢ B ↑ \\ → & I \\ Γ; Δ; Ω ⊢ A → B ↑ \end{matrix} \begin{matrix}Γ; Δ; Ω ⊢ A → B ↓  Γ; ·; · ⊢ A ↑ \\ → & E \\ Γ; Δ; Ω ⊢ B ↓ \end{matrix}

\begin{matrix}Γ; ΔA; Ω ⊢ B ↑ \\ −∘ & I \\ Γ; Δ; Ω ⊢ A −∘ B ↑ \end{matrix} Γ; Δ; Ω ⊢ A −∘ B ↓ Γ; Δ_{A}; · ⊢ A ↑ −∘_{E}

\begin{matrix}Γ; Δ; AΩ ⊢ B ↑ \\ ↣ & I \\ Γ; Δ; Ω ⊢ A ↣ B ↑ \end{matrix} Γ; Δ; Ω ⊢ A ↣ B ↓ Γ; Δ_{A}; Ω_{A} ⊢ A ↑ ↣_{E}

\begin{matrix}Γ; Δ; ΩA ⊢ B ↑ \\ ↠ & I \\ Γ; Δ; Ω ⊢ A ↠ B ↑ \end{matrix} Γ; Δ; Ω ⊢ A ↠ B ↓ Γ; Δ_{A}; Ω_{A} ⊢ A ↑ ↠_{E}

Γ; Δ_{A}; Ω_{L} ⊢ A ↑ Γ; Δ_{B}; Ω_{R} ⊢ B ↑ •_{I}

Γ; Δ; Ω ⊢ A • B ↓ Γ; Δ_{C}; Ω_{L}ABΩ_{R} ⊢ C ↑ •_{E}

Γ; Δ_{A}; Ω_{R} ⊢ A ↑ Γ; Δ_{B}; Ω_{L} ⊢ B ↑ ∘_{I}

Γ; Δ; Ω ⊢ A ∘ B ↓ Γ; Δ_{C}; Ω_{L}BAΩ_{R} ⊢ C ↑ ∘_{E}

Γ; Δ ▷◁ Δ_{A}; Ω ⊢ B ↓ Γ; Δ ▷◁ Δ_{A}; Ω_{A}Ω ⊢ B ↓ Γ; Δ ▷◁ Δ_{A}; ΩΩ_{A} ⊢ B ↓ Γ; Δ_{A} ▷◁ Δ_{B}; Ω_{L}Ω_{R} ⊢ A • B ↑

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑ Γ; Δ_{A} ▷◁ Δ_{B}; Ω_{L}Ω_{R} ⊢ A ∘ B ↑

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

Γ; Δ; Ω ⊢ A ↑ Γ; Δ; Ω ⊢ B ↑ &_{I}

Γ; Δ; Ω ⊢ A & B ↑

\begin{matrix}Γ; Δ; Ω ⊢ A & B ↓ \\ & & E1 \\ Γ; Δ; Ω ⊢ A ↓ \end{matrix} \begin{matrix}Γ; Δ; Ω ⊢ A & B ↓ \\ & & E2 \\ Γ; Δ; Ω ⊢ B ↓ \end{matrix}

\begin{matrix}Γ; Δ; Ω ⊢ A ↑ \\ ⊕ & I1 \\ Γ; Δ; Ω ⊢ A ⊕ B ↑ \end{matrix}  \begin{matrix}Γ; Δ; Ω ⊢ B ↑ \\ ⊕ & I2 \\ Γ; Δ; Ω ⊢ A ⊕ B ↑ \end{matrix}
Γ; Δ; Ω ⊢ A ⊕ B ↓  Γ; Δ_{C}; Ω_{L}AΩ_{R} ⊢ C ↑  Γ; Δ_{C}; Ω_{L}BΩ_{R} ⊢ C ↑ ⊕_{E}
Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

1_{I} Γ; ·; · ⊢ 1 ↑

Γ; Δ; Ω ⊢ 1 ↓ Γ; Δ_{C}; Ω_{L}Ω_{R} ⊢ C ↑

1_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

⊤_{I} Γ; Δ; Ω ⊢ ⊤ ↑ Γ; Δ; Ω ⊢ 0 ↓ 0_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

\begin{aligned}Γ; Δ; Ω ⊢ [a/x]A ↑ \\ & ∀_{I}^{a} \\ Γ; Δ; Ω ⊢ ∀x. A ↑ \end{aligned} \begin{aligned}Γ; Δ; Ω ⊢ ∀x. A ↓ \\ & ∀_{E} \\ Γ; Δ; Ω ⊢ [t/x]A ↓ \end{aligned}

\begin{aligned}Γ; Δ; Ω ⊢ [t/x]A ↑ \\ & ∃_{I} \\ Γ; Δ; Ω ⊢ ∃x. A ↑ \end{aligned} Γ; Δ; Ω ⊢ ∃x. A ↓ Γ; Δ_{C}; Ω_{L}[a/x]AΩ_{R} ⊢ C ↑ ∃_{E}^{a}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

\begin{matrix}Γ; Δ; · ⊢ A ↑ \\ ¡ & I \\ Γ; Δ; · ⊢ ¡A ↑ \end{matrix} Γ; Δ; Ω ⊢ ¡A ↓ Γ; Δ_{C}A; Ω_{L}Ω_{R} ⊢ C ↑ ¡_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

\begin{matrix}Γ; ·; · ⊢ A ↑ \\ ! & I \\ Γ; ·; · ⊢ !A ↑ \end{matrix} Γ; Δ; Ω ⊢ !A ↓ ΓA; Δ_{C}; Ω_{L}Ω_{R} ⊢ C ↑ !_{E}

Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⊢ C ↑

It is easy to see that this system only allows normal proofs. Since there is no way to turn a normal (↑) derivation into an atomic (↓) one, it is indeed impossible to introduce and then eliminate a formula.

3.2 Properties of Normal Deductions

We remark that this system enjoys structural properties analogous to the previous system. Lemma 3 (Normal Structural Properties) The following all hold:

1. Γ_{L}AAΓ_{R}; Δ; Ω ⊢ C ↑ implies Γ_{L}AΓ_{R}; Δ; Ω ⊢ C ↑.

2. Γ_{L}Γ_{R}; Δ; Ω ⊢ C ↑ implies Γ_{L}AΓ_{R}; Δ; Ω ⊢ C ↑.

3. Γ_{L}ABΓ_{R}; Δ; Ω ⊢ C ↑ implies Γ_{L}BAΓ_{R}; Δ; Ω ⊢ C ↑.

4. Γ; Δ_{L}ABΔ_{R}; Ω ⊢ C ↑ implies Γ; Δ_{L}BAΔ_{R}; Ω ⊢ C ↑.

5. Γ_{L}AAΓ_{R}; Δ; Ω ⊢ C ↓ implies Γ_{L}AΓ_{R}; Δ; Ω ⊢ C ↓.

6. Γ_{L}Γ_{R}; Δ; Ω ⊢ C ↓ implies Γ_{L}AΓ_{R}; Δ; Ω ⊢ C ↓.

7. Γ_{L}ABΓ_{R}; Δ; Ω ⊢ C ↓ implies Γ_{L}BAΓ_{R}; Δ; Ω ⊢ C ↓.

8. Γ; Δ_{L}ABΔ_{R}; Ω ⊢ C ↓ implies Γ; Δ_{L}BAΔ_{R}; Ω ⊢ C ↓. Proof: By structural induction over the given derivation. □

Furthermore we have the following substitution principles. Notice that only an atomic derivation may be substituted for a hypothesis since the uses of assumptions are considered atomic deductions (the ohyp, lhyp, and ihyp rules). Lemma 4 (Normal Substitution) The following all hold:

1. Γ_{A}AΓ; Δ; Ω ⊢ C ↑ and Γ_{A}; ·; · ⊢ A ↓ implies Γ_{A}Γ; Δ; Ω ⊢ C ↑.

2. Γ; Δ_{L}AΔ_{R}; Ω ⊢ C ↑ and Γ; Δ_{A}; · ⊢ A ↓ implies Γ; (Δ_{L} ▷◁ Δ_{A})Δ_{R}; Ω ⊢ C ↑.

3. Γ; Δ; Ω_{L}AΩ_{R} ⊢ C ↑ and Γ; Δ_{A}; Ω_{A} ⊢ A ↓ implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}Ω_{R} ⊢ C ↑.

4. Γ_{A}AΓ; Δ; Ω ⊢ C ↓ and Γ_{A}; ·; · ⊢ A ↓ implies Γ_{A}Γ; Δ; Ω ⊢ C ↓.

5. Γ; Δ_{L}AΔ_{R}; Ω ⊢ C ↓ and Γ; Δ_{A}; · ⊢ A ↓ implies Γ; (Δ_{L} ▷◁ Δ_{A})Δ_{R}; Ω ⊢ C ↓.

6. Γ; Δ; Ω_{L}AΩ_{R} ⊢ C ↓ and Γ; Δ_{A}; Ω_{A} ⊢ A ↓ implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}Ω_{R} ⊢ C ↓.

Proof: By structural induction over the given derivation for C. □

Since the structure of the rules in the normal system follows that of the previous system, we can easily see that the normal system simply rules out some valid deductions of the previous system. Therefore we have the following soundness theorem.

Theorem 5 The following hold:

1. Γ; Δ; Ω ⊢ A ↑ implies Γ; Δ; Ω ⊢ A

2. Γ; Δ; Ω ⊢ A ↓ implies Γ; Δ; Ω ⊢ A

Proof: By simple structural induction. Coercions are simply eliminated. □

The converse, that every provable proposition has a normal deduction, does indeed hold and could be proved by a Kripke logical relations argument [19]. The proof for a fragment of the system above is a minor modification of the proof of the existence of canonical forms given in [51]. Instead, we will prove it indirectly by going through a sequent calculus presentation of ordered linear logic, taking advantage of the cut elimination theorem. This will also give further validation to our sequent system, which we are interested in for its own sake, by showing that it exactly proves the propositions which have natural deductions.

3.3 Directed Deductions

Before introducing the sequent system, we introduce a third natural deduction system for ordered linear logic which is obviously equivalent to the original. This system is based on the preceding normal system and has two judgements standing for normal and atomic derivations. However, in order to recover arbitrary deductions, it also allows an additional coercion from normal to atomic derivations. We write Γ; Δ; Ω ⊢^{+} A ↑ and Γ; Δ; Ω ⊢^{+} A ↓ which is defined by exactly the same rules as the normal and atomic judgments above, plus the rule

Γ; Δ; Ω ⊢^{+} A ↑

lemma

Γ; Δ; Ω ⊢^{+} A ↓

Theorem 6 The following hold:

1. Γ; Δ; Ω ⊢^{+} A ↑ iff Γ; Δ; Ω ⊢ A

2. Γ; Δ; Ω ⊢^{+} A ↓ iff Γ; Δ; Ω ⊢ A

Proof: In each direction, by simple structural induction on the given derivation. In the forward direction coercions are simply eliminated by the translation. In the backwards direction they are introduced if the last inference is not of the right kind. Note that these translations do not form a bijection since redundant coercions collapse. □

We also point out that Lemma 4 can be trivially extended to the directed deduction system. In succeeding chapters, we will use Lemma 4 for both normal and directed deductions.

Sequent Calculus

While natural deduction systems provide an elegant formalization of intuitionistic reasoning, they are not ideally suited for analyzing properties of proof search. The main difficulty stems from the inability to directly manipulate hypotheses in a natural deduction system. A formalism better suited for analyzing proof search is the sequent calculus.

In a sequent calculus, the logical connectives are characterized by right rules and left rules which, as we shall see, correspond to the introduction and elimination rules of natural deduction. In addition we have initial sequents which play the role of coercions in the normal natural deduction system. Furthermore, the sequent calculus is usually formulated with an explicit rule for reasoning with lemmas, called cut, which will correspond to the lemma rule in the directed natural deduction system (the system introduced at the end of Chapter 3).

In the sequent calculus proof search proceeds in one direction, from conclusion to hypotheses (bottom-up). This in contrast to a natural deduction system which requires two separate phases of proof search, one driven by the hypotheses (using elimination rules) and another analyzing the conclusion (using introduction rules). Proof search can proceed in one direction from beginning to end because the sequent calculus gives us, via the left rules, direct access to hypotheses. This also allows dual connectives (e.g., & and ⊕) to have syntactically dual inference rules.

In this chapter we present a sequent calculus for ordered linear logic. This sequent calculus is a conservative extension of both associative Lambek calculus [32] and the sequent system for non-commutative intuitionistic linear logic given in [8]. We will present a sequent system without an explicit cut rule. This system will correspond exactly to normal natural deductions. We will then prove that cut is an admissible rule in the system. This lets us form a sequent system with explicit cut rules which will correspond to the directed natural deduction system described at the end of Chapter 3.

4.1 Sequent Calculus for Ordered Linear Logic

Similar to natural deduction judgements, our sequents have the form:

Γ; Δ; Ω ⟹ A

where Γ, Δ, Ω are lists of formulas, and A is a proposition. Again, Γ, Δ, Ω are meant to denote an intuitionistic, linear, and ordered context respectively. We sometimes refer to the formulas on the left of the sequent arrow, the hypotheses, as the antecedent, and to those on the right of the sequent arrow as the succedent. As their names suggest, left rules will operate on formulas in the antecedent, while right rules will operate on the succedent formula.

In the sequent setting, one may logically think of the three antecedent contexts as one big context where the ordered hypotheses are in a fixed relative order while the other linear and unrestricted propositions may “float”. The intuitionistic propositions may also be copied or ignored. Traditionally the basic structural properties of the hypotheses– exchange, weakening, and cotraction– are explicitly formulated as inference rules in the sequent calculus. However, in keeping with the style of our natural deduction system, we will build these structural properties into the formulation of the left, right and init rules.

We start with initial sequents, which encode that all linear and ordered hypotheses must be used, while those in Γ need not be used.

\frac{init}{Γ; ·; A ⟹ A}

We have two explicit structural rules: place, which commits a linear hypothesis to a particular place among the ordered hypotheses; and copy, which duplicates and places an unrestricted hypothesis.

Γ_{L}AΓ_{R}; Δ; Ω_{L}AΩ_{R} ⟹ B

Γ; Δ_{L}Δ_{R}; Ω_{L}AΩ_{R} ⟹ B

copy Γ_{L}AΓ_{R}; Δ; Ω_{L}Ω_{R} ⟹ B

place Γ; Δ_{L}AΔ_{R}; Ω_{L}Ω_{R} ⟹ B

The following four rules describing the intuitionistic and linear implications translate the standard sequent rules for intuitionistic linear logic into our setting. Note the restrictions on the linear and ordered contexts in the two left rules which are necessary to preserve linearity and order, respectively.

\begin{matrix}ΓA; Δ; Ω ⟹ B \\ → & R \\ Γ; Δ; Ω ⟹ A → B \end{matrix} Γ; Δ; Ω_{L}BΩ_{R} ⟹ C Γ; ·; · ⟹ A →_{L}

Γ; Δ; Ω_{L}(A → B)Ω_{R} ⟹ C

\begin{matrix}Γ; ΔA; Ω ⟹ B \\ −∘ & R \\ Γ; Δ; Ω ⟹ A −∘ B \end{matrix} Γ; Δ_{B}; Ω_{L}BΩ_{R} ⟹ C Γ; Δ_{A}; · ⟹ A −∘_{L}

Γ; Δ_{B} ▷◁ Δ_{A}; Ω_{L}(A −∘ B)Ω_{R} ⟹ C

The right rule for ordered right implication A ↠ B adds A at the right end of the ordered context. In order to allow an admissible cut rule, the left rule must then take hypotheses immediately to the right of the right implication for deriving the antecedent A. The remaining hypotheses are joined with B (in order) to derive C. We must also be careful that each linear hypothesis comes from exactly one premise, although their order does not matter (hence the merge operation Δ_{B} ▷◁ Δ_{A}).

\begin{matrix}Γ; Δ; ΩA ⟹ B \\ ↠ & R \\ Γ; Δ; Ω ⟹ A ↠ B \end{matrix} Γ; Δ_{B}; Ω_{L}BΩ_{R} ⟹ C Γ; Δ_{A}; Ω_{A} ⟹ A ↠_{L}

Γ; Δ_{B} ▷◁ Δ_{A}; Ω_{L}(A ↠ B)Ω_{A}Ω_{R} ⟹ C

The rules for left implication are symmetric.

\begin{matrix}Γ; Δ; AΩ ⟹ B \\ ↣ & R \\ Γ; Δ; Ω ⟹ A ↣ B \end{matrix} Γ; Δ_{B}; Ω_{L}BΩ_{R} ⟹ C Γ; Δ_{A}; Ω_{A} ⟹ A ↣_{L}

Γ; Δ_{B} ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟹ C

The rules for the remaining connectives do not introduce any new ideas and are essentially the rules for a sequent presentation of intuitionistic linear logic extended to include ordered contexts.

Γ; Δ_{A}; Ω_{L} ⟹ A Γ; Δ_{B}; Ω_{R} ⟹ B •_{R}

Γ; Δ; Ω_{L}ABΩ_{R} ⟹ C •_{L}

Γ; Δ_{A}; Ω_{R} ⟹ A Γ; Δ_{B}; Ω_{L} ⟹ B ∘_{R}

Γ; Δ; Ω_{L}BAΩ_{R} ⟹ C ∘_{L}

Γ; Δ_{A} ▷◁ Δ_{B}; Ω_{L}Ω_{R} ⟹ A • B

Γ; Δ; Ω_{L}(A • B)Ω_{R} ⟹ C Γ; Δ_{A} ▷◁ Δ_{B}; Ω_{L}Ω_{R} ⟹ A ∘ B

Γ; Δ; Ω_{L}(A ∘ B)Ω_{R} ⟹ C

1_{R} Γ; ·; · ⟹ 1 Γ; Δ; Ω_{L}Ω_{R} ⟹ C 1_{L}

Γ; Δ; Ω_{L}1Ω_{R} ⟹ C

⊤_{R} Γ; Δ; Ω ⟹ ⊤

Γ; Δ; Ω ⟹ A Γ; Δ; Ω ⟹ B
&_{R}
Γ; Δ; Ω ⟹ A & B

Γ; Δ; Ω_{L}AΩ_{R} ⟹ C &_{L1}

Γ; Δ; Ω_{L}(A & B)Ω_{R} ⟹ C

Γ; Δ; Ω_{L}BΩ_{R} ⟹ C &_{L2}

Γ; Δ; Ω_{L}(A & B)Ω_{R} ⟹ C

\begin{matrix}Γ; Δ; Ω ⟹ A \\ ⊕ & R1 \\ Γ; Δ; Ω ⟹ (A ⊕ B) \end{matrix}  \begin{matrix}Γ; Δ; Ω ⟹ B \\ ⊕ & R2 \\ Γ; Δ; Ω ⟹ (A ⊕ B) \end{matrix}

Γ; Δ; Ω_{L}AΩ_{R} ⟹ C Γ; Δ; Ω_{L}BΩ_{R} ⟹ C

⊕_{L}

Γ; Δ; Ω_{L}(A ⊕ B)Ω_{R} ⟹ C

0_{L} Γ; Δ; Ω_{L}0Ω_{R} ⟹ C

Γ; Δ; Ω ⟹ A[a/x] ∀_{R}^{a} Γ; Δ; Ω ⟹ ∀x. A

Γ; Δ; Ω_{L}(A[t/x])Ω_{R} ⟹ C
∀_{L}
Γ; Δ; Ω_{L}(∀x. A)Ω_{R} ⟹ C

Γ; Δ; Ω ⟹ [t/x]A ∃_{R} Γ; Δ; Ω ⟹ ∃x. A

Γ; Δ; Ω_{L}(A[a/x])Ω_{R} ⟹ C
∃_{L}^{a}
Γ; Δ; Ω_{L}(∃x. A)Ω_{R} ⟹ C

Γ; ·; · ⟹ A _{!_{R}} Γ; ·; · ⟹ !A ΓA; Δ; Ω_{L}Ω_{R} ⟹ C !_{L}

Γ; Δ; Ω_{L}(!A)Ω_{R} ⟹ C

Γ; Δ; · ⟹ A _{¡_{R}} Γ; Δ; · ⟹ ¡A

Γ; ΔA; Ω_{L}Ω_{R} ⟹ C
¡_{L}
Γ; Δ; Ω_{L}(¡A)Ω_{R} ⟹ C

As usual we require that a not appear free in the conclusions of the ∀_{R}^{a} and ∃_{L}^{a} rules.

It is clear that this system has the subformula property: only instances of subformulas of propositions present in the conclusion can appear in the derivation. Since proof search based on this form of sequent calculus proceeds bottom-up, this is a critical property. It is due, of course, to the absence of any explicit cut rule.

To give a feel for how the sequent system works, we show a sample derivation which sketches how ordered linear logic can be used for natural language parsing. Suppose

Γ = [(np ↠ vp ↠ snt) (tv ↠ np ↠ vp) (loves ↠ tv) (mary ↠ np) (bob ↠ np)] where all

the words and grammatical abbreviations^{1} are atomic formulas. We may think of the formulas in Γ as a grammar for simple English sentences. For example, np↠vp↠snt specifies that a sentence is a verb phrase to the right of a noun phrase. The phrase to be parsed with the grammar is in the ordered context. The succedent contains the grammatical pattern with which we are trying to classify the input. Thus to parse the sentence: mary loves bob, we would prove: Γ; ·; mary loves bob ⟹ snt.

Θ

Γ; ·; np tv np ⟹ snt

\frac{init}{Γ; ·; bob ⟹ bob}
↠_{L}

Γ; ·; np tv (bob ↠ np) bob ⟹ snt

                                  \frac{init}{Γ; ·; loves ⟹ loves}

↠_{L}

   Γ; ·; np (loves ↠ tv) loves (bob ↠ np) bob ⟹ snt

\frac{init}{Γ; ·; mary ⟹ mary}
↠_{L}

          Γ; ·; (mary ↠ np) mary (loves ↠ tv) loves (bob ↠ np) bob ⟹ snt

copy ∗ 3

                         Γ; ·; mary loves bob ⟹ snt

where Θ =

\frac{init}{Γ; ·; snt ⟹ snt} \frac{init}{Γ; ·; vp ⟹ vp}
↠_{L}

Γ; ·; (vp ↠ snt) vp ⟹ snt

\frac{init}{Γ; ·; np ⟹ np}
↠_{L}

  Γ; ·; (np ↠ vp ↠ snt) np vp ⟹ snt

\frac{init}{Γ; ·; np ⟹ np}
↠_{L}

         Γ; ·; (np ↠ vp ↠ snt) np (np ↠ vp) np ⟹ snt

\frac{init}{Γ; ·; tv ⟹ tv}
↠_{L}

                 Γ; ·; (np ↠ vp ↠ snt) np (tv ↠ np ↠ vp) tv np ⟹ snt

copy ∗ 2

                               Γ; ·; np tv np ⟹ snt

Note that this is not the only way to derive the end-sequent. For instance, we could have moved all instances of copy and place to the beginning of the derivation; or we could have applied ↠_{L} to the formulas in a different order.

4.2 Admissibility of Cut

We shall now validate our version of the sequent calculus by showing the admissibility of cut in the system. Towards this end, we have the following lemma.

1snt = sentence, np = noun phrase, vp = verb phrase, tv = transitive verb

Lemma 7 (Weakening, Contraction, and Exchange) The following all hold:

1. Γ_{L}Γ_{R}; Δ; Ω ⟹ C implies Γ_{L}AΓ_{R}; Δ; Ω ⟹ C.

2. Γ_{L}AAΓ_{R}; Δ; Ω ⟹ C implies Γ_{L}AΓ_{R}; Δ; Ω ⟹ C.

3. Γ_{L}ABΓ_{R}; Δ; Ω ⟹ C implies Γ_{L}BAΓ_{R}; Δ; Ω ⟹ C.

4. Γ; Δ_{L}ABΔ_{R}; Ω ⟹ C implies Γ; Δ_{L}BAΔ_{R}; Ω ⟹ C.

Proof: By structural induction on the given derivation. Note that the structure of the derivation remains the same. □

Our sequent system combines the ideas of a multi-zone presentation due to Andreoli [2] with implicit structural rules to permit a proof of the admissibility of cut (and thus cut elimination) by structural induction as in [44].

Theorem 8 (Admissibility of Cut) The following three statements hold:

Cut_{Ω}: Γ; Δ_{C}; Ω_{C} ⟹ C and Γ; Δ; Ω_{L}CΩ_{R} ⟹ A implies Γ; Δ_{C} ▷◁Δ; Ω_{L}Ω_{C}Ω_{R} ⟹ A.

Cut_{Δ}: Γ; Δ_{C}; · ⟹ C and Γ; Δ_{L}CΔ_{R}; Ω ⟹ A implies Γ; (Δ_{L} ▷◁ Δ_{C})Δ_{R}; Ω ⟹ A.

Cut_{Γ}: Γ_{L}; ·; · ⟹ C and Γ_{L}CΓ_{R}; Δ; Ω ⟹ A implies Γ_{L}Γ_{R}; Δ; Ω ⟹ A.

Proof: By induction on the structure of the cut formula C, the type of cut where Cut_{Γ} > Cut_{Δ} > Cut_{Ω}, and the derivations of the premises. Therefore we may apply the induction hypothesis in the following cases: 1) the cut formula gets smaller; 2) the same cut formula but we move from Cut_{Γ} to Cut_{Δ} or Cut_{Ω}; 3) the same cut formula but we move from Cut_{Δ} to Cut_{Ω}; 4) the cut formula and type of cut stay the same but one of the derivations gets smaller.

There are 5 basic cases to consider: init cases where one of the premises is an init rule, structural cases where the cut formula is the subject of a structural rule, essential cases where the principal formula of both premises is cut, commutative cases where the cut formula is a side formula on the first or second premise. Note that these cases are not mutually exclusive.

We show some representative cases. case 1: init cases.

case: \frac{init}{Γ; ·; C ⟹ C} and Γ; Δ; Ω_{L}CΩ_{R} ⟹ A is trivial.

case: Γ; Δ; Ω ⟹ C and \frac{init}{Γ; ·; C ⟹ C} is trivial.

case: Γ_{L}; ·; · ⟹ C and \frac{init}{Γ_{L}CΓ_{R}; ·; A ⟹ A} then \frac{init}{Γ_{L}Γ_{R}; ·; A ⟹ A}

case 2: Structural cases.

case: Γ_{L}; ·; · ⟹ C and Γ_{L}CΓ_{R}; Δ; Ω_{L}CΩ_{R} ⟹ A copy Γ_{L}CΓ_{R}; Δ; Ω_{L}Ω_{R} ⟹ A

Then

Γ_{L}Γ_{R}; Δ; Ω_{L}CΩ_{R} ⟹ A  ind. hyp.(Cut_{Γ})
Γ_{L}Γ_{R}; ·; · ⟹ C  weakening
Γ_{L}Γ_{R}; Δ; Ω_{L}Ω_{R} ⟹ A  ind. hyp.(Cut_{Γ} > Cut_{Ω})

case 3: Essential cases.

case: \begin{matrix}ΓC; Δ; Ω ⟹ B \\ → & R \\ Γ; Δ; Ω ⟹ C → B \end{matrix} and Γ; Δ_{A}; Ω_{L}BΩ_{R} ⟹ A Γ; ·; · ⟹ C →_{L} Γ; Δ_{A}; Ω_{L}(C → B)Ω_{R} ⟹ A

Then

Γ; Δ; Ω ⟹ B  ind. hyp.(Cut_{Γ})
Γ; Δ_{A} ▷◁ Δ; Ω_{L}ΩΩ_{R} ⟹ A  ind. hyp.(Cut_{Ω})

case 4: Commutative cases where cut formula is not principal in first hypothesis (i.e. end-sequent of first given derivation can’t end in a right rule).

case: Γ; Δ_{B}; Ω_{L}BΩ_{R} ⟹ C Γ; Δ_{D}; Ω_{D} ⟹ D ↣_{L} Γ; Δ_{B} ▷◁ Δ_{D}; Ω_{L}Ω_{D}(D ↣ B)Ω_{R} ⟹ C and Γ; Δ; Ω_{LC}CΩ_{RC} ⟹ A Then

Γ; Δ_{B} ▷◁ Δ; Ω_{LC}Ω_{L}BΩ_{R}Ω_{RC} ⟹ A  ind. hyp.
Γ; Δ_{B} ▷◁ Δ ▷◁ Δ_{D}; Ω_{LC}Ω_{L}Ω_{D}(D ↣ B)Ω_{R}Ω_{RC} ⟹ A  ↣_{L}

case: Γ_{L}DΓ_{R}; Δ_{C}; Ω_{LC}DΩ_{RC} ⟹ C copy Γ_{L}DΓ_{R}; Δ_{C}; Ω_{LC}Ω_{RC} ⟹ C and Γ_{L}DΓ_{R}; Δ; Ω_{L}CΩ_{R} ⟹ A

Then

Γ_{L}DΓ_{R}; Δ_{C} ▷◁ Δ; Ω_{L}Ω_{LC}DΩ_{RC}Ω_{R} ⟹ A  ind. hyp.(Cut_{Ω})
Γ_{L}DΓ_{R}; Δ_{C} ▷◁ Δ; Ω_{L}Ω_{LC}Ω_{RC}Ω_{R} ⟹ A  copy

case 5: commutative cases where cut formula is not principal in end-sequent of second given derivation.

case: Γ; Δ_{C}; Ω_{C} ⟹ C and Γ; Δ; AΩ_{L}CΩ_{R} ⟹ B ↣_{R} Γ; Δ; Ω_{L}CΩ_{R} ⟹ A ↣ B

Then

Γ; Δ_{C} ▷◁ Δ; AΩ_{L}Ω_{C}Ω_{R} ⟹ B  ind. hyp.
Γ; Δ_{C} ▷◁ Δ; Ω_{L}Ω_{C}Ω_{R} ⟹ A ↣ B  ↣_{R}

case: Γ; Δ_{C}; Ω_{C} ⟹ C and Γ; Δ_{B}; Ω_{LL}CΩ_{LR}BΩ_{R} ⟹ A Γ; Δ_{D}; Ω_{D} ⟹ D ↣_{L} Γ; Δ_{B} ▷◁ Δ_{D}; Ω_{LL}CΩ_{LR}Ω_{D}(D ↣ B)Ω_{R} ⟹ A Then

Γ; Δ_{C} ▷◁ Δ_{B}; Ω_{LL}Ω_{C}Ω_{LR}BΩ_{R} ⟹ A  ind. hyp.
Γ; Δ_{C} ▷◁ Δ_{B} ▷◁ Δ_{D}; Ω_{LL}Ω_{C}Ω_{LR}Ω_{D}(D ↣ B)Ω_{R} ⟹ A  ↣_{L}

case: Γ; Δ_{C}; · ⟹ C and Γ; Δ_{L}CΔ_{R}; AΩ ⟹ B ↣_{R} Γ; Δ_{L}CΔ_{R}; Ω ⟹ A ↣ B

Then

Γ; Δ_{L} ▷◁ Δ_{C} ▷◁ Δ_{R}; AΩ ⟹ B  ind. hyp.
Γ; Δ_{L} ▷◁ Δ_{C} ▷◁ Δ_{R}; Ω ⟹ A ↣ B  ↣_{R}

case: Γ; Δ_{C}; · ⟹ C and Γ; Δ_{BL}CΔ_{BR}; Ω_{L}BΩ_{R} ⟹ A Γ; Δ_{D}; Ω_{D} ⟹ D ↣_{L} Γ; (Δ_{BL}CΔ_{BR}) ▷◁ Δ_{D}; Ω_{L}Ω_{D}(D ↣ B)Ω_{R} ⟹ A Then

Γ; Δ_{C} ▷◁ (Δ_{BL}Δ_{BR}); Ω_{L}BΩ_{R} ⟹ A  ind. hyp.
Γ; Δ_{C} ▷◁ (Δ_{BL}Δ_{BR}) ▷◁ Δ_{D}; Ω_{L}Ω_{D}(D ↣ B)Ω_{R} ⟹ A  ↣_{L}
□

4.3 Sequent Calculus With Cut

Theorem 8 lets us define a second sequent system with cut which is equivalent to the previous system. We write Γ; Δ; Ω ⟹^{+} A to denote a sequent derivation of A which may contain all of the previous sequent rules in addition to the three types of cut:

Γ; Δ_{C}; Ω_{C} ⟹^{+} C Γ; Δ; Ω_{L}CΩ_{R} ⟹^{+} A
Cut_{Ω}

Γ; Δ_{C} ▷◁ Δ; Ω_{L}Ω_{C}Ω_{R} ⟹^{+} A

Γ_{L}; ·; · ⟹^{+} C Γ_{L}CΓ_{R}; Δ; Ω ⟹^{+} A

Cut_{Γ}

Γ_{L}Γ_{R}; Δ; Ω ⟹^{+} A

Γ; Δ_{C}; · ⟹^{+} C Γ; Δ_{L}CΔ_{R}; Ω ⟹^{+} A
Cut_{Δ}

Γ; (Δ_{L} ▷◁ Δ_{C})Δ_{R}; Ω ⟹^{+} A

Then cut elimination follows directly. Theorem 9 (Cut Elimination) If Γ; Δ; Ω ⟹^{+} A then Γ; Δ; Ω ⟹ A. Proof: By structural induction on the given derivation. In the case of a cut we appeal to the induction hypothesis on both premises and then to admissibility of cut on the resulting cut-free derivations. □

64

Normalization for Ordered Linear Logic

At this point, we have introduced four^{1} different logical systems– two natural deduction systems and two sequent calculi. Additionally two of the systems are restricted versions of their respective counterparts. We have been referring (at times tacitly) to all the systems as presentations of ordered linear logic. It is now time to justify this claim. In this chapter we will formally show the correspondences between the systems of natural deduction and sequent calculus. Our methods extend [20] to cover ordered linear logic. Figure 5.1 provides a map of the relationships between the systems.

We first show how the cut-free sequent system corresponds to the normal natural deduction system. We have already remarked that normal natural deductions are those where the top-down use of elimination rules meets the bottom-up use of introduction rules in the middle:

↓elim ; coercion ; ↑intro

In a sequent system we reason entirely bottom up: the top-down uses of elimination rules are turned around and become bottom-up uses of the left rules. The right rules correspond directly to the introduction rules. They meet, not in the middle, but at the initial sequents:

\frac{init}{↑left ⟹ ↑right}

1five if the directed natural deduction system, ⊢^{+}, is considered different from the original natural deduction system

Directed ND  SC w/ Cut
Γ; Δ; Ω ⊢ A ≡ Γ; Δ; Ω ⊢^{+} A ↑  ⟹^{Thm 13} ; ⟸_{Thm 12}  Γ; Δ; Ω ⟹^{+} A
Normalization ↓↑injection  Cut elim.↓↑ injection
Γ; Δ; Ω ⊢ A ↑  ⟹^{Thm 11} ; ⟸_{Thm 10}  Γ; Δ; Ω ⟹ A
normal ND  cut-free SC

Figure 5.1: Correspondences

5.1 Normal Deductions and Cut-Free Sequents

We now formally state the soundness of cut-free sequents with respect to normal natural deductions.

Theorem 10 Γ; Δ; Ω ⟹ A implies Γ; Δ; Ω ⊢ A ↑

Proof: By structural induction on the given derivation. init rules are mapped to instances of coercion; place and copy rules are mapped to instances of the substitution principles; right rules are mapped to introduction rules; and left rules are mapped to elimination rules using the substitution principles when necessary. Note that the resulting derivation is normal, despite the use of the substitution principles, since we use it in the form of Lemma 4.

We show some representative cases.

case: \frac{init}{Γ; ·; A ⟹ A}

Then

Γ; ·; A ⊢ A ↓  ohyp
Γ; ·; A ⊢ A ↑  coercion

case: Γ; Δ_{L}Δ_{R}; Ω_{L}AΩ_{R} ⟹ B place Γ; Δ_{L}AΔ_{R}; Ω_{L}Ω_{R} ⟹ B

Then

Γ; Δ_{L}Δ_{R}; Ω_{L}AΩ_{R} ⊢ B ↑  ind. hyp.
Γ; A; · ⊢ A ↓  lhyp
Γ; Δ_{L}AΔ_{R}; Ω_{L}Ω_{R} ⊢ B ↑  lemma 4

case: \begin{matrix}Γ; Δ; ΩA ⟹ B \\ ↠ & R \\ Γ; Δ; Ω ⟹ A ↠ B \end{matrix}

Then

Γ; Δ; ΩA ⊢ B ↑  ind. hyp.
Γ; Δ; Ω ⊢ A ↠ B  ↠_{I}

case: Γ; Δ; Ω_{L}BΩ_{R} ⟹ C Γ; Δ_{A}; Ω_{A} ⟹ A ↠_{L} Γ; Δ ▷◁ Δ_{A}; Ω_{L}(A ↠ B)Ω_{A}Ω_{R} ⟹ C

Then

Γ; Δ; Ω_{L}BΩ_{R} ⊢ C ↑  ind. hyp.
Γ; Δ_{A}; Ω_{A} ⊢ A ↑  ind. hyp.
Γ; ·; A ↠ B ⊢ A ↠ B ↓  ohyp
Γ; Δ_{A}; (A ↠ B)Ω_{A} ⊢ B ↓  ↠_{E}
Γ; Δ ▷◁ Δ_{A}; Ω_{L}(A ↠ B)Ω_{A}Ω_{R} ⊢ C ↑  lemma 4
□

In the opposite direction we first need to generalize the induction hypothesis to make the proper statement about the atomic deduction—otherwise our induction would break down at the first coercion.

Theorem 11 The following hold:

1. Γ; Δ; Ω ⊢ A ↑ implies Γ; Δ; Ω ⟹ A

2. Γ; Δ; Ω ⊢ A ↓ and Γ; Δ_{C}; Ω_{L}AΩ_{R} ⟹ C implies Γ; Δ_{C} ▷◁ Δ; Ω_{L}ΩΩ_{R} ⟹ C.

Proof: By structural induction on the given derivations. Instances of coercion translate to uses of the init rule from the result of the induction hypothesis. Introduction rules are mapped to right rules. Elimination rules are mapped to sequent derivations constructed from the corresponding left rule and the result of an appeal to the induction hypothesis.

We show some representative cases.

case: \frac{ohyp}{Γ; ·; A ⊢ A ↓}

Γ; Δ_{C}; Ω_{L}AΩ_{R} ⟹ C  assumption

case: \frac{lhyp}{Γ; A; · ⊢ A ↓}

Then

Γ; Δ_{C}; Ω_{L}AΩ_{R} ⟹ C  assumption
Γ; Δ_{CL}AΔ_{CR}; Ω_{L}Ω_{R} ⟹ C  place
where Δ_{C} = Δ_{CL}Δ_{CR}

case: Γ; Δ; Ω ⊢ A ↠ B ↓ Γ; Δ_{A}; Ω_{A} ⊢ A ↑ ↠_{E} Γ; Δ ▷◁ Δ_{A}; ΩΩ_{A} ⊢ B ↓ Then

Γ; Δ_{C}; Ω_{L}BΩ_{R} ⟹ C  assumption
Γ; Δ_{A}; Ω_{A} ⟹ A  ind. hyp.
Γ; Δ_{A} ▷◁ Δ_{C}; Ω_{L}(A ↠ B)Ω_{A}Ω_{R} ⟹ C  ↠_{L}
Γ; Δ ▷◁ Δ_{A} ▷◁ Δ_{C}; Ω_{L}ΩΩ_{A}Ω_{R} ⟹ C  ind. hyp.

case: Γ; Δ; Ω ⊢ A ↓ ; coercion ; Γ; Δ; Ω ⊢ A ↑

Then

Γ; ·; A ⟹ A  init
Γ; Δ; Ω ⟹ A  ind. hyp.

case: \begin{matrix}Γ; Δ; ΩA ⊢ B ↑ \\ ↠ & I \\ Γ; Δ; Ω ⊢ A ↠ B ↑ \end{matrix}

Then

Γ; Δ; ΩA ⟹ B  ind. hyp.
Γ; Δ; Ω ⟹ A ↠ B  ↠_{R}
□

We remark that the mapping just shown takes init sequents to coercion rules. This gives further credence to our intuition on the relation between normal deductions and cut-free proofs. The coercion rule represents the end of a normal proof from an operational viewpoint just as the init sequents represent the end of a sequent proof.

The proofs above are constructive and inherently contain a method for translation between sequent derivations in ordered linear logic and natural deductions. Although the correspondence is very close, it is not a bijection, because the order in which left rules are applied in a sequent derivation may be irrelevant to the resulting natural deduction. If one wants to establish a bijection, one has to further restrict the sequent rules. This has been investigated by Herbelin [25] for intuitionistic logic.

5.2 Directed Deductions and Sequents with Cut

We now show that this correspondence extends to directed natural deductions (using the ⊢^{+} judgements) and sequents with explicit cut rules (using the ⟹^{+} sequents). Specifically, coercing a normal derivation into an atomic derivation will correspond to using cut in the sequent calculus.

Theorem 12 Γ; Δ; Ω ⟹^{+} A implies Γ; Δ; Ω ⊢^{+} A ↑

Proof: By induction on structure of the given derivation. The proof is exactly the same as the proof of theorem 10 with three additional cases. The cut rules are translated into a lemma rule followed by an appeal to the substitution principles.

We show the new cases.

case: Γ; Δ_{A}; Ω_{A} ⟹^{+} A Γ; Δ; Ω_{L}AΩ_{R} ⟹^{+} C Cut_{Ω} Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}Ω_{R} ⟹^{+} C

Then

Γ; Δ; Ω_{L}AΩ_{R} ⊢^{+} C ↑  ind. hyp.
Γ; Δ_{A}; Ω_{A} ⊢^{+} A ↑  ind. hyp.
Γ; Δ_{A}; Ω_{A} ⊢^{+} A ↓  rule lemma
Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}Ω_{R} ⊢^{+} C ↑  lemma 4

case: Γ; Δ_{A}; · ⟹^{+} A Γ; Δ_{L}AΔ_{R}; Ω ⟹^{+} C Cut_{Δ} Γ; Δ_{L} ▷◁ Δ_{A} ▷◁ Δ_{A}; Ω ⟹^{+} C

Then

Γ; Δ_{L}AΔ_{R}; Ω ⊢^{+} C ↑  ind. hyp.
Γ; Δ_{A}; · ⊢^{+} A ↑  ind. hyp.
Γ; Δ_{A}; · ⊢^{+} A ↓  rule lemma
Γ; Δ_{L} ▷◁ Δ_{A} ▷◁ Δ_{R}; Ω ⊢^{+} C ↑  lemma 4

case: Γ; ·; · ⟹^{+} A Γ_{L}AΓ_{R}; Δ; Ω ⟹^{+} C Cut_{Γ} Γ_{L}ΓΓ_{R}; Δ; Ω ⟹^{+} C

Then

Γ_{L}AΓ_{R}; Δ; Ω ⊢^{+} C ↑  ind. hyp.
Γ_{L}ΓAΓ_{R}; Δ; Ω ⊢^{+} C ↑  lemma 3
Γ; ·; · ⊢^{+} A ↑  ind. hyp.
Γ; ·; · ⊢^{+} A ↓  rule lemma
Γ_{L}Γ; ·; · ⊢^{+} A ↓  lemma 3
Γ_{L}ΓΓ_{R}; Δ; Ω ⊢^{+} C ↑  lemma 4
□

Theorem 13 The following hold:

1. Γ; Δ; Ω ⊢^{+} A ↑ implies Γ; Δ; Ω ⟹^{+} A

2. Γ; Δ; Ω ⊢^{+} A ↓ and Γ; Δ_{C}; Ω_{L}AΩ_{R} ⟹^{+} C implies Γ; Δ_{C} ▷◁ Δ; Ω_{L}ΩΩ_{R} ⟹^{+} C

Proof: By induction on structure of the given derivations. The proof is exactly the same as the proof of theorem 11 with one additional case: from the lemma coercion we construct a use of the Cut_{Ω} rule.

case: Γ; Δ; Ω ⊢^{+} A ↑ lemma Γ; Δ; Ω ⊢^{+} A ↓

Then

Γ; Δ_{C}; Ω_{L}AΩ_{R} ⟹^{+} C  assumption
Γ; Δ; Ω ⟹^{+} A  ind. hyp.
Γ; Δ ▷◁ Δ_{C}; Ω_{L}ΩΩ_{R} ⟹^{+} C  Cut_{Ω}
□

5.3 Normalization

The previous observations give a syntactic proof of normalization of the natural deduction system.

Theorem 14 (Normalization) Γ; Δ; Ω ⊢ A iff Γ; Δ; Ω ⊢ A ↑.

Proof: Given Γ; Δ; Ω ⊢ A, we know Γ; Δ; Ω ⊢^{+} A ↑ from Theorem 6. Then Γ; Δ; Ω ⟹^{+} A from Theorem 13. Then Γ; Δ; Ω ⟹ A from Theorem 9 (Cut Elimination). Then Γ; Δ; Ω ⊢ A ↑ from Theorem 10. The other direction is the contents of Theorem 5. □

This concludes the basic development of ordered linear logic. We have constructed the logic from the basic notion of a hypothetical judgement and an analysis of the structural properties of hypotheses. We exhibited a natural deduction system for the logic and argued that the system is coherent by proving a normalization result. We also presented a sequent calculus for the logic, corresponding to the natural deduction system, and a cut-elimination result.

Part II Ordered Linear Logic

Programming Uniform Derivations

We now turn our attention to proof search in ordered linear logic (OLL). All of the analysis in this chapter will use the sequent calculus of Chapter 4 which is better suited, by allowing direct manipulation of hypotheses, to examining proof search than the natural deduction system.

Our analysis aims at achieving a logic programming language, where we view computation as the bottom-up construction of a derivation. The difficulty with the sequent system, as given, is that in any situation many left or right rules can be applied, leading to unacceptable non-determinism. To solve this problem, we design an alternative, more restricted system with the following properties (which are enforced syntactically):

• Derivations are goal-directed in that a derivation of a sequent with a non-atomic goal^{1} always ends in a right rule. This allows us to view logical connectives in goals as search instructions.

• Derivations are focussed in that when deriving a sequent with an atomic goal we single out a particular hypothesis and apply a sequence of left rules until it is also atomic and immediately implies the goal. This allows us to view atomic goals as procedure calls.

In a minor departure from [37] we call derivations which are both goal-directed and focussed uniform.

1We refer to the succedent of a given sequent as the goal.

This chapter identifies the uniform fragment of ordered linear logic, the fragment of the logic for which uniform proofs are complete, and proves that this fragment may be thought of as an abstract logic programming language [37], i.e., goal-directed and focussed proof search is complete for the fragment. In subsequent chapters we will further analyse the uniform fragment to obtain a concrete logic programming language. Furthermore, the uniform fragment is of additional interest since it exactly corresponds to the canonical fragment of an ordered lambda calculus which serves as the basis for a logical framework^{2}.

6.1 Uniform Fragment

In this section we identify the goal-directed fragment of ordered linear logic. As one can write a focussing derivation system for the entire logic^{3}, goal-directedness characterizes the uniform fragment. Clearly the entire logic is not goal-directed, consider the sequent

·; ·; A • B ⟶ A • B

whose derivation is either an init rule (which is not goal-directed since the goal is non-atomic) or requires applying the •_{L} rule below the •_{R} rule.

As it turns out, the uniform fragment of OLL is:

Uniform Formulas A ::= P  atomic propositions
| A → B unrestricted implication
| A −∘ B linear implication
| A ↠ B ordered right implication
| A ↣ B ordered left implication
| A & B additive conjunction
| ⊤  additive unit
| ∀x. A universal quantifier

which is the uniform fragment of linear logic extended with ordered implications. That no other connectives are goal-directed may be seen from examining derivations of the form ·; ·; C ⟶ C similarly to the previous example.

We now formally state and prove the goal-directedness property.

2see chapters 12 and 13

3The techniques in [3] for full linear logic are easily extended to OLL.

Lemma 15 (Goal-Directedness) The following all hold:

1. Γ; Δ; Ω ⟹ A → B implies ΓA; Δ; Ω ⟹ B

2. Γ; Δ; Ω ⟹ A −∘ B implies Γ; ΔA; Ω ⟹ B

3. Γ; Δ; Ω ⟹ A ↠ B implies Γ; Δ; ΩA ⟹ B

4. Γ; Δ; Ω ⟹ A ↣ B implies Γ; Δ; AΩ ⟹ B

5. Γ; Δ; Ω ⟹ A & B implies Γ; Δ; Ω ⟹ A and Γ; Δ; Ω ⟹ B

6. Γ; Δ; Ω ⟹ ∀x. A implies Γ; Δ; Ω ⟹ A[a/x] where a is fresh. Proof: By using Theorem 8 (admissibility of the cut rules) we can use the given derivation to directly construct the result. We show a representative case.

case: \begin{matrix}D \\ Γ; Δ; Ω ⟹ A ↠ B \end{matrix}

Then

D Γ; Δ; Ω ⟹ A ↠ B \frac{init}{Γ; ·; A ⟹ A}  \frac{init}{Γ; ·; B ⟹ B} ↠_{L}

Γ; ·; (A ↠ B)A ⟹ B
Cut_{Ω} Γ; Δ; ΩA ⟹ B
□

6.2 Uniform Derivation System

Uniform derivations may now be conceived as a focussing system for the uniform fragment which forces right rules to appear below left rules along the major branch of a proof.

We formalize our system with two judgements:

Γ; Δ; Ω ⟶ A  goal A is uniformly derivable
Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A ≫ P hypothesis A immediately entails atomic goal P

where Γ, Δ and Ω are unrestricted, linear, and ordered hypotheses, respectively. In the latter judgment the ordered hypotheses are syntactically divided into a left part Ω_{L} and a right part Ω_{R}. It corresponds to the sequent

Γ; Δ; (Ω_{L}AΩ_{R}) ⟹ P

so that the split in the ordered context tracks the location of the hypothesis we have focused on. This correspondence is stated formally in the soundness and completeness theorems for uniform derivations below.

All of the right rules are exactly the same as in the sequent calculus. Since no left rules apply when the goal is non-atomic, the derivation is completely determined by the structure of the goal, as desired.

\begin{matrix}ΓA; Δ; Ω ⟶ B \\ → & R \\ Γ; Δ; Ω ⟶ A → B \end{matrix}  \begin{matrix}Γ; ΔA; Ω ⟶ B \\ −∘ & R \\ Γ; Δ; Ω ⟶ A −∘ B \end{matrix}
\begin{matrix}Γ; Δ; ΩA ⟶ B \\ ↠ & R \\ Γ; Δ; Ω ⟶ A ↠ B \end{matrix}  \begin{matrix}Γ; Δ; AΩ ⟶ B \\ ↣ & R \\ Γ; Δ; Ω ⟶ A ↣ B \end{matrix}

Γ; Δ; Ω ⟶ A Γ; Δ; Ω ⟶ B &_{R}

Γ; Δ; Ω ⟶ A & B

⊤_{R} Γ; Δ; Ω ⟶ ⊤

Γ; Δ; Ω ⟶ A[a/x] ∀_{R}^{a}

Γ; Δ; Ω ⟶ ∀x. A

When the goal has become atomic, we need to single out a hypothesis and determine if it immediately entails the goal. This is achieved by the three choice rules which apply to unrestricted, linear, or ordered hypotheses.

Γ_{L}AΓ_{R}; Δ; (Ω_{L}; Ω_{R}) ⟶ A ≫ P

choice_{Γ}

Γ_{L}AΓ_{R}; Δ; Ω_{L}Ω_{R} ⟶ P

Γ; Δ_{L}Δ_{R}; (Ω_{L}; Ω_{R}) ⟶ A ≫ P
choice_{Δ}
Γ; Δ_{L}AΔ_{R}; Ω_{L}Ω_{R} ⟶ P
Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A ≫ P
choice_{Ω}
Γ; Δ; Ω_{L}AΩ_{R} ⟶ P

choice_{Γ} is justified by copy in the sequent calculus, and choice_{Δ} by place. The premise and conclusion of choice_{Ω} correspond to identical sequents. An initial sequent corresponds to an immediate entailment between identical atomic formulas.

\frac{init}{Γ; ·; (·; ·) ⟶ P ≫ P}

The remaining left rules for immediate entailment directly correspond to the left sequent rules, keeping in mind that we have to consider the focussing formula as being between the left and right parts of the ordered context.

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ B ≫ P Γ; ·; · ⟶ A →_{L}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A → B ≫ P

Γ; Δ_{B}; (Ω_{L}; Ω_{R}) ⟶ B ≫ P Γ; Δ_{A}; · ⟶ A −∘_{L}

Γ; Δ_{A} ▷◁ Δ_{B}; (Ω_{L}; Ω_{R}) ⟶ A −∘ B ≫ P

Γ; Δ_{B}; (Ω_{L}; Ω_{R}) ⟶ B ≫ P Γ; Δ_{A}; Ω_{A} ⟶ A ↠_{L}

Γ; Δ_{A} ▷◁ Δ_{B}; (Ω_{L}; Ω_{A}Ω_{R}) ⟶ A ↠ B ≫ P

Γ; Δ_{B}; (Ω_{L}; Ω_{R}) ⟶ B ≫ P Γ; Δ_{A}; Ω_{A} ⟶ A ↣_{L}

Γ; Δ_{A} ▷◁ Δ_{B}; (Ω_{L}Ω_{A}; Ω_{R}) ⟶ A ↣ B ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A ≫ P

&_{L1}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A & B ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ B ≫ P
&_{L2}
Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A & B ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A[t/x] ≫ P

∀_{L}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ ∀x. A ≫ P

In the uniform system, we rewrite our sample parsing proof from Chapter 4 as follows:

Γ = [(np ↠ vp ↠ snt) (tv ↠ np ↠ vp) (loves ↠ tv) (mary ↠ np) (bob ↠ np)]

\frac{init}{Γ; ·; (·; ·) ⟶ snt ≫ snt}

Θ

     Γ; ·; loves bob ⟶ vp

↠_{L}

Γ; ·; (·; loves bob) ⟶ (vp ↠ snt) ≫ snt

                                   Θmary
                               Γ; ·; mary ⟶ np

↠_{L}

Γ; ·; (·; mary loves bob) ⟶ np ↠ vp ↠ snt ≫ snt

choice_{Γ}

   Γ; ·; mary loves bob ⟶ snt

where Θ =

\frac{init}{Γ; ·; (·; ·) ⟶ vp ≫ vp}

                                Θbob
                           Γ; ·; bob ⟶ np

↠_{L}

Γ; ·; (·; bob) ⟶ np ↠ vp ≫ vp

                                                     Θloves
                                                 Γ; ·; loves ⟶ tv

↠_{L}

                    Γ; ·; (·; loves bob) ⟶ tv ↠ np ↠ vp ≫ vp

choice_{Γ}

                            Γ; ·; loves bob ⟶ vp

where Θbob =

\frac{init}{Γ; ·; (·; ·) ⟶ np ≫ np}

\frac{init}{Γ; ·; (·; ·) ⟶ bob ≫ bob}
choice_{Ω}

                                            Γ; ·; bob ⟶ bob ↠_{L}

Γ; ·; (·; bob) ⟶ bob ↠ np ≫ np

choice_{Γ}

                               Γ; ·; bob ⟶ np

and Θmary, Θloves are similar.

Unlike the example given in Chapter 4, this is the only proof of the end-sequent. The first choice is forced since np ↠ vp ↠ snt is the only formula in Γ whose head, snt, matches the goal. The same is true for all the other choices made.

We now show that uniform derivations are sound and complete with respect to the sequent calculus. The soundness result is easy to show.

Theorem 16 (Soundness of Uniform Derivations)

1. If Γ; Δ; Ω ⟶ A then Γ; Δ; Ω ⟹ A.

2. If Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ A ≫ P then Γ; Δ; Ω_{L}AΩ_{R} ⟹ P.

Proof: By mutual structural induction on the derivations of the given judgements using the correspondences mentioned throughout this section. □

The completeness result is harder, but largely follows techniques of [3] and [37], adapted to the ordered case. The main difficulty arises from the mismatch between the left rules of the uniform system and the original sequent system. Therefore we will need to show how to construct a uniform derivation whose premises and conclusion match those of the sequent system’s left rules. To be concrete, suppose we have derivations of

Γ; Δ; Ω_{L}BΩ_{R} ⟶ C and Γ; Δ_{A}; Ω_{A} ⟶ A

then we need to show that we can construct a derivation of

Γ; Δ ▷◁ Δ_{A}; Ω_{L}(A ↠ B)Ω_{A}Ω_{R} ⟶ C

in order to show completeness of the uniform derivation system.

We will have to form so called “inversion” principles for each connective in the uniform system. The proofs for these inversion principles are non-trivial. Lemma 17, and its proof, presents a detailed proof of the inversion principle for ↣. Lemma 18 then states all of the necessary inversion principles, each of which may be proven similarly to Lemma 17.

Lemma 17

1. Γ; Δ; Ω_{L}BΩ_{R} ⟶ C and Γ; Δ_{A}; Ω_{A} ⟶ A implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟶ P.

2. Γ; Δ; (Ω_{LL}BΩ_{LR}; Ω_{R}) ⟶ C ≫ P and Γ; Δ_{A}; Ω_{A} ⟶ A implies Γ; Δ ▷◁ Δ_{A}; (Ω_{LL}Ω_{A}(A ↣ B)Ω_{LR}; Ω_{R}) ⟶ C ≫ P.

3. Γ; Δ; (Ω_{L}; Ω_{RL}BΩ_{RR}) ⟶ C ≫ P and Γ; Δ_{A}; Ω_{A} ⟶ A implies Γ; Δ ▷◁ Δ_{A}; (Ω_{L}; Ω_{RL}Ω_{A}(A ↣ B)Ω_{RR}) ⟶ C ≫ P.

Proof: By mutual induction on the structure of the given derivations. Assume Γ; Δ_{A}; Ω_{A} ⟶ A.

part 1:

Cases when C is atomic (i.e. C = P).

Assume \begin{matrix}Π \\ Γ; Δ; Ω_{L}BΩ_{R} ⟶ P \end{matrix} . Then there are 7 possibilities for Π:

case 1: Π ends with choice_{Ω} and Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ B ≫ P

Then

Γ; Δ ▷◁ Δ_{A}; (Ω_{L}Ω_{A}; Ω_{R}) ⟶ A ↣ B ≫ P  ↣_{L}
Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟶ P  choice_{Ω}

case 2: Π ends with choice_{Ω} and Γ; Δ; (Ω_{LL}; Ω_{LR}BΩ_{R}) ⟶ C ≫ P where Ω_{L} = Ω_{LL}CΩ_{LR}. Then

Γ; Δ ▷◁ Δ_{A}; (Ω_{LL}; Ω_{LR}Ω_{A}(A ↣ B)Ω_{R}) ⟶ C ≫ P  ind. hyp.
Γ; Δ ▷◁ Δ_{A}; Ω_{LL}CΩ_{LR}Ω_{A}(A ↣ B)Ω_{R} ⟶ P  choice_{Ω}

case 3: Π ends with choice_{Ω} and Γ; Δ; (Ω_{L}BΩ_{RL}; Ω_{RR}) ⟶ C ≫ P where Ω_{R} = Ω_{RL}CΩ_{RR}. Then

Γ; Δ ▷◁ Δ_{A}; (Ω_{L}Ω_{A}(A ↣ B)Ω_{RL}; Ω_{RR}) ⟶ C ≫ P  ind. hyp.
Ω_{L}Ω_{A}(A ↣ B)Ω_{RL}CΩ_{RR} ⟶ P  choice_{Ω}

cases 4,5,6,7 : Π ends with choice_{Δ} (2 cases) or choice_{Γ} (2 cases). Similar to previous two cases.

Cases when C is non-atomic.

case: Γ; Δ; Ω_{L}BΩ_{R}C_{1} ⟶ C_{2} ↠_{R} Γ; Δ; Ω_{L}BΩ_{R} ⟶ C_{1} ↠ C_{2} Then

Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R}C_{1} ⟶ C_{2}  ind. hyp.
Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟶ C_{1} ↠ C_{2}  ↠_{R}

cases for other connectives are similar.

part 2: Assume Γ; Δ; (Ω_{LL}BΩ_{LR}; Ω_{R}) ⟶ C ≫ P. Note that C cannot be atomic since the ordered context is not empty.

case: C = C_{1} ↣ C_{2} and Δ = Δ_{2} ▷◁ Δ_{1} and Ω_{LR} = Ω_{LRL}Ω_{LRR} and Γ; Δ_{2}; (Ω_{LL}BΩ_{LRL}; Ω_{R}) ⟶ C_{2} ≫ P and Γ; Δ_{1}; Ω_{LRR} ⟶ C_{1}. Then

Γ; Δ_{1} ▷◁ Δ_{A}; (Ω_{LL}Ω_{A}(A ↣ B)Ω_{LRL}; Ω_{R}) ⟶ C_{2} ≫ P  ind. hyp.
Γ; Δ ▷◁ Δ_{A}; (Ω_{LL}Ω_{A}(A ↣ B)Ω_{LRL}Ω_{LRR}; Ω_{R}) ⟶ C_{1} ↣ C_{2} ≫ P  ↣_{L}

case: C = C_{1} ↣ C_{2} and Δ = Δ_{2} ▷◁ Δ_{1} and Ω_{LL} = Ω_{LLL}Ω_{LLR} and Γ; Δ_{2}; (Ω_{LLL}; Ω_{R}) ⟶ C_{2} ≫ P and Γ; Δ_{1}; Ω_{LLR}BΩ_{LR} ⟶ C_{1}. Then

Γ; Δ_{1} ▷◁ Δ_{A}; Ω_{LLR}Ω_{A}(A ↣ B)Ω_{LR} ⟶ C_{1}  ind. hyp.
Γ; Δ ▷◁ Δ_{A}; (Ω_{LLL}Ω_{LLR}Ω_{A}(A ↣ B)Ω_{LR}; Ω_{R}) ⟶ C_{1} ↣ C_{2} ≫ P  ↣_{L}

case: C = C_{1} ↠ C_{2} and Δ = Δ_{2} ▷◁ Δ_{1} and Ω_{R} = Ω_{RL}Ω_{RR} and Γ; Δ_{2}; (Ω_{LL}BΩ_{LR}; Ω_{RR}) ⟶ C_{2} ≫ P and Γ; Δ_{1}; Ω_{RL} ⟶ C_{1}. Then

Γ; Δ_{2} ▷◁ Δ_{A}; (Ω_{LL}Ω_{A}(A ↣ B)Ω_{LR}; Ω_{RR}) ⟶ C_{2} ≫ P  ind. hyp.
Γ; Δ ▷◁ Δ_{A}; (Ω_{LL}Ω_{A}(A ↣ B)Ω_{LR}; Ω_{RL}Ω_{RR}) ⟶ C_{1} ↠ C_{2} ≫ P  ↠_{L}

cases: C = C_{1} −∘ C_{2}, C = C_{1} → C_{2}, C = C_{1} & C_{2}, C = ∀x. C′ Similar to previous cases.

part 3: Assume Γ; Δ; (Ω_{L}; Ω_{RL}BΩ_{RR}) ⟶ C ≫ P.

Then can be proven with reasoning symmetric to part 2.

□

We now state all the inversion principles needed to prove completeness. Lemma 18 (Inversion) The following all hold:

1. Γ; Δ; Ω_{L}BΩ_{R} ⟶ C and Γ; Δ_{A}; Ω_{A} ⟶ A implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟶ C.

2. Γ; Δ; Ω_{L}BΩ_{R} ⟶ C and Γ; Δ_{A}; Ω_{A} ⟶ A implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↠ B)Ω_{R} ⟶ C.

3. Γ; Δ; Ω_{L}BΩ_{R} ⟶ C and Γ; Δ_{A}; · ⟶ A implies Γ; Δ ▷◁ Δ_{A}; Ω_{L}(A −∘ B)Ω_{R} ⟶ C.

4. Γ; Δ; Ω_{L}BΩ_{R} ⟶ C and Γ; ·; · ⟶ A implies Γ; Δ; Ω_{L}(A → B)Ω_{R} ⟶ C.

5. Γ; Δ; Ω_{L}AΩ_{R} ⟶ C implies Γ; Δ; Ω_{L}(A & B)Ω_{R} ⟶ C

6. Γ; Δ; Ω_{L}BΩ_{R} ⟶ C implies Γ; Δ; Ω_{L}(A & B)Ω_{R} ⟶ C 7. Γ; Δ; Ω_{L}A[t/x]Ω_{R} ⟶ C implies Γ; Δ; Ω_{L}(∀x. A)Ω_{R} ⟶ C

8. Γ; Δ_{L}Δ_{R}; Ω_{L}AΩ_{R} ⟶ C implies Γ; Δ_{L}AΔ_{R}; Ω_{L}Ω_{R} ⟶ C.

9. Γ_{L}AΓ_{R}; Δ_{L}AΔ_{R}; Ω ⟶ C implies Γ_{L}AΓ_{R}; Δ_{L}Δ_{R}; Ω ⟶ C. Proof: Part 1 is immediate from the previous lemma. The other parts are similarly proved. □

We may now easily prove the completeness result. Theorem 19 (Completeness of Uniform Derivations) :

Γ; Δ; Ω ⟹ A implies Γ; Δ; Ω ⟶ A. Proof: By induction on the structure of the given derivation:

case: \frac{init}{Γ; ·; P ⟹ P} Then \frac{init}{Γ; ·; (·; ·) ⟶ P ≫ P} choice_{Ω} Γ; ·; P ⟶ P

case: \begin{matrix}Γ; Δ; AΩ ⟹ B \\ ↣ & R \\ Γ; Δ; Ω ⟹ A ↣ B \end{matrix}

Then

Γ; Δ; AΩ ⟶ B  ind. hyp.
Γ; Δ; Ω ⟶ A ↣ B  ↣_{R}

cases: ↠_{R},−∘_{R},→_{R}, &_{R}, ∀_{R} all similar to previous case.

case:

Γ; Δ_{B}; Ω_{L}BΩ_{R} ⟹ C Γ; Δ_{A}; Ω_{A} ⟹ A ↣_{L}

Γ; Δ_{B} ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟹ C Then

Γ; Δ_{B}; Ω_{L}BΩ_{R} ⟶ C and Γ; Δ_{A}; Ω_{A} ⟶ A ind. hyp.
Γ; Δ_{B} ▷◁ Δ_{A}; Ω_{L}Ω_{A}(A ↣ B)Ω_{R} ⟶ C  lemma 18

cases: ↠_{L},−∘_{L},→_{L},&_{Li},∀_{L},copy,place all similar to previous case.

□

We have now shown that ordered linear logic qualifies as an abstract logic programming language in the sense of [37]. However, directly coding up the uniform derivation system will result in hopelessly slow code due to the non-determinism still present in the inference rules. Even though the derivation system is goal-directed, many unspecified choices will be encountered during a bottom-up proof search.

A major source of non-determinism involves choosing which formula to focus on, and occurs in rules: choice_{x}, and &_{Lx}. It is impossible to completely eliminate this type of non-determinism (at least while staying within the bounds of logic programming). Most of the remaining non-determinism can be effectively removed from the system using standard techniques from logic programming. We can fix an order for proving each premise of of a multi-premise rule. We can remove existential choices, the need to pick a term in the ∀_{L} rule, by introducing logic variables and unification.

After taking the above measures, the only non-determinism yet to consider comes from the need to split^{4} the linear and ordered contexts, and occurs in rules: choice_{Γ}, choice_{Δ}, ↠_{L}, ↣_{L}, and −∘_{L}. The non-determinism of the ↠_{L}, ↣_{L} and −∘_{L} rules can be handled with a non-trivial extension of the input-ouput model used by Lolli and LLF for linear logic; Chapter 8 provides the details. However, the non-deterministic context splits in the choice_{Γ} and choice_{Δ} rules are not amenable to the same treatment. Therefore, we first explain, in Chapter 7, how to transform this nondeterminism into a form which can be treated with the techniques of Chapter 8.

4Remember we are considering bottom-up proof search.

86

Residuation

As mentioned in the previous chapter, the non-deterministic context splits in the choice_{Γ} and choice_{Δ} rules is different than that in the ↠_{L}, ↣_{L} and −∘_{L} rules. The former rules simply pick an arbitrary point at which the ordered context is to be split; while the latter rules actually divide the ordered (and linear) context between two premises. Note that the former context splitting arises from the need to fix the position of a non-ordered hypothesis in the ordered context.

It turns out that the sub-goals of a non-ordered formula place constraints upon where the formula must be located in the ordered context. Consider the following derivable sequent:

·; A ↠ B ↣ C; BA ⟶ C

The ↠ requires that A be to the right of A ↠ B ↣ C; similarly B must be to its left. Thus a derivation of this sequent requires A ↠ B ↣ C to be placed in between the A and B in the ordered context. Using these observations, we may constrain the position of a non-ordered focus formula while solving its subgoals.

This chapter shows exactly how this process works. We first expand the formula language to allow restricted occurrences of the non-uniform connectives which maintain goal-directedness. We then use this expanded formula language to remove the non-deterministic context splits in the choice_{Γ} and choice_{Δ} rules.

7.1 Extended Uniform Derivations

As mentioned in section 6.1, the connectives outside the uniform fragment are not goal-directed. However, we can allow restricted occurrences of non-uniform connectives, without compromising uniformity. Specifically, we can separate formulas into goal formulas, which may appear on the right of a sequent (i.e., positively), and clause formulas which may appear to the left of a sequent (i.e., negatively). It turns out that allowing positive occurrences, and forbidding negative occurences, of nonuniform connectives does not affect goal-directedness.

Clause Formulas D ::= P  atomic propositions
| G → D unrestricted implication
| G −∘ D linear implication
| G ↠ D ordered right implication
| G ↣ D ordered left implication
| D_{1} & D_{2} additive conjunction
| ⊤  additive unit
| ∀x. D universal quantifier

Goal Formulas G ::= P  atomic propositions
| D → G unrestricted implication
| !G  unrestricted modality
| D −∘ G unrestricted implication
| ¡G  linear modality
| D ↠ G ordered right implication
| D ↣ G ordered left implication
| G_{1} • G_{2} right multiplicative conjuction
| G_{1} ∘ G_{2} left multiplicative conjuction
| 1  multiplicative unit
| G_{1} & G_{2} additive conjunction
| ⊤  additive unit
| G_{1} ⊕ G_{2} multiplicative disjunction
| 0  multiplicative falsehood
| ∀x. G  universal quantifier
| ∃x. G  existential quantifier

For the rest of this chapter, and the subsequent ones dealing with logic programming, we shall take care to maintain the distinction between clause formulas, G, and goal formulas, D. We now explicitly show the complete extended uniform derivation rules.

We have two types of mutually dependent sequents to capture uniform (i.e. focussing and goal-directed) derivations:

Γ; Δ; Ω ⟶ G  uniform derivability
Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P  immediate entailment

where Γ,Δ,Ω,Ω_{L}, and Ω_{R} are lists of clause formulas.

Here are the inference rules for extended uniform derivations:

\frac{1_{R}}{Γ; ·; · ⟶ 1}  \begin{aligned}Γ; ·; · ⟶ G \\ & !_{R} \\ Γ; ·; · ⟶ !G \end{aligned}  \begin{matrix}Γ; Δ; · ⟶ G \\ ¡ & R \\ Γ; Δ; · ⟶ ¡G \end{matrix}

\begin{matrix}ΓD; Δ; Ω ⟶ G \\ → & R \\ Γ; Δ; Ω ⟶ D → G \end{matrix}  \begin{matrix}Γ; ΔD; Ω ⟶ G \\ −∘ & R \\ Γ; Δ; Ω ⟶ D −∘ G \end{matrix}

\begin{matrix}Γ; Δ; ΩD ⟶ G \\ ↠ & R \\ Γ; Δ; Ω ⟶ D ↠ G \end{matrix}  \begin{matrix}Γ; Δ; DΩ ⟶ G \\ ↣ & R \\ Γ; Δ; Ω ⟶ D ↣ G \end{matrix}

Γ; Δ_{1}; Ω_{1} ⟶ G_{1} Γ; Δ_{2}; Ω_{2} ⟶ G_{2} •_{R}

Γ; Δ_{1}; Ω_{1} ⟶ G_{1} Γ; Δ_{2}; Ω_{2} ⟶ G_{2} ∘_{R}

\begin{aligned}Γ; Δ; Ω ⟶ G_{1} \\ & ⊕_{R1} \\ Γ; Δ; Ω ⟶ G_{1} ⊕ G_{2} \end{aligned}  \begin{aligned}Γ; Δ; Ω ⟶ G_{2} \\ & ⊕_{R2} \\ Γ; Δ; Ω ⟶ G_{1} ⊕ G_{2} \end{aligned}  no 0_{R} rule

Γ; Δ; Ω ⟶ G_{1} Γ; Δ; Ω ⟶ G_{2} &_{R}

Γ; Δ; Ω ⟶ G[g/x] ∀_{R}^{a}

Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2} ⟶ G_{1} • G_{2}

Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{2}Ω_{1} ⟶ G_{1} ∘ G_{2} Γ; Δ; Ω ⟶ G_{1} & G_{2}

⊤_{R} Γ; Δ; Ω ⟶ ⊤ Γ; Δ; Ω ⟶ ∀x. G (a not free in conclusion)

Γ; Δ; Ω ⟶ G[t/x] ∃_{R} Γ; Δ; Ω ⟶ ∃x. G

Γ_{L}DΓ_{R}; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P

choice_{Γ}

Γ_{L}DΓ_{R}; Δ; Ω_{L}Ω_{R} ⟶ P Γ; Δ_{L}Δ_{R}; (Ω_{L}; Ω_{R}) ⟶ D ≫ P

choice_{Δ}

Γ; Δ_{L}DΔ_{R}; Ω_{L}Ω_{R} ⟶ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P

choice_{Ω}

Γ; Δ; Ω_{L}DΩ_{R} ⟶ P

\frac{init}{Γ; ·; (·; ·) ⟶ P ≫ P}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D_{1} ≫ P

&_{L1}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D_{1} & D_{2} ≫ P Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D_{2} ≫ P

&_{L1}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D_{1} & D_{2} ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D[t/x] ≫ P

∀_{L}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ ∀x. D ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P Γ; ·; · ⟶ G →_{L}

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ G → D ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P Γ; Δ_{G}; · ⟶ G −∘_{L}

Γ; Δ ▷◁ Δ_{G}; (Ω_{L}; Ω_{R}) ⟶ G −∘ D ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P Γ; Δ_{G}; Ω_{G} ⟶ G ↠_{L}

Γ; Δ ▷◁ Δ_{G}; (Ω_{L}; Ω_{G}Ω_{R}) ⟶ G ↠ D ≫ P

Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P Γ; Δ_{G}; Ω_{G} ⟶ G ↣_{L}

Γ; Δ ▷◁ Δ_{G}; (Ω_{L}Ω_{G}; Ω_{R}) ⟶ G ↣ D ≫ P

We can now state the correctness of this system. Theorem 20 (Soundness of Extended Uniform Derivations)

1. Γ; Δ; Ω ⟶ G implies Γ; Δ; Ω ⟹ G.

2. Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ G ≫ P implies Γ; Δ; Ω_{L}GΩ_{R} ⟹ P.

where only clause formulas occur in each context.

Proof: By mutual structural induction on the derivations of the given judgements. □

Theorem 21 (Completeness of Uniform Derivations)

Γ; Δ; Ω ⟹ G implies Γ; Δ; Ω ⟶ G where only clause formulas occur in each context.

Proof: We may use the proof of theorem 19. We need only add cases for the nonuniform connectives; each of which is simply an appeal to the induction hypothesis since non-uniform connectives only appear positively. □

From this point forward, we will assume that all contexts only contain clause formulas.

7.2 Residuation of Mobile Hypotheses

Recall from chapter 6 our interpretation of goals as search instructions. Following this lead, we may interpret clause formulas as compound search instructions, since all of the subgoals must be solved in order to successfully use a hypothesis. To better illustrate, consider:

·; P_{1} ↠ P_{2} ↣ P; P_{2}P_{1} ⟶ P

whose derivation is:

\begin{matrix}\frac{init}{·; ·; (·; ·) ⟶ P ≫ P} & ⋮ ; ·; ·; P_{2} ⟶ P_{2} \\ ↣ & L \\ ·; ·; (P_{2}; ·) ⟶ P_{2} ↣ P ≫ P \end{matrix} ⋮ ; ·; ·; P_{1} ⟶ P_{1}
↠_{L}
·; ·; (P_{2}; P_{1}) ⟶ P_{1} ↠ P_{2} ↣ P ≫ P
choice_{Δ} ·; P_{1} ↠ P_{2} ↣ P; P_{2}P_{1} ⟶ P

Both P_{1} and P_{2} must be derived in order to successfully use P_{1} ↠ P_{2} ↣ P. Further more, we know, from the ↠ and ↣ that the ordered hypotheses used to prove P_{2} must be to the left of those used to solve P_{1}. But this is exactly what the connective ∘ requires. Thus we could think about changing the above derivation into something like the following:

⋮ ; ·; ·; P_{2} ⟶ P_{2}  ⋮ ; ·; ·; P_{1} ⟶ P_{1}
∘_{R}
·; ·; P_{2}P_{1} ⟶ P_{1} ∘ P_{2}
choice′_{Δ} ·; P_{1} ↠ P_{2} ↣ P; P_{2}P_{1} ⟶ P

where we have transformed the two subgoals, P_{1} and P_{2}, into a new compound subgoal, P_{1} ∘ P_{2}. We call this sort of transformation residuation.

It turns out that mobile hypotheses, hypotheses in the unrestricted and linear contexts, can be residuated (logically compiled) into goal formulas (with some minor extensions) following the general development in [9]. This observation will allow us to focus on unrestricted formulas without having to split the ordered context. Rather, the splitting will be delayed and taken care of by the multiplicative conjunction rules, which can be handled similarly to the ↣_{L}, ↠_{L}, and −∘_{L} rules as explained in chapter 8.

First we extend goal formulas with an atomic equality:

Goal Formulas G ::= … | P_{1} ≐ P_{2} Equality

then add a new inference rule:

\frac{≐_{R}}{Γ; ·; · ⟶^{r} P ≐ P}

We need only add a right rule for this new connective since it is a goal formula.

We now present a residuation derivation system, which is sound and complete wrt uniform derivations, in which the ordered context need not be split when focusing on an unrestricted formula. This derivation system will consist of two types of sequent

\begin{matrix}Γ; Δ; Ω ⟶^{r} G \\ Γ; Δ; (Ω_{L}; Ω_{R}) ⟶^{r} D ≫ P \end{matrix}

which exactly match their uniform counterparts, except as noted below, plus the new judgement

G′; D ≫ P \ G

which shall be used to residuate clause formulas into goal formulas. In this new judgement, G′, D, and P are considered input and G is considered the output; specifically, G′ is an accumulating result (goal formula), D is the formula being residuated, P is the atom which must match the head^{1} of D, and G is the resulting goal formula.

We use the following inference rules for the new judgements:

\overline{G; P′ ≫ P \ (P′ ≐ P) • G}  \overline{G; ⊤ ≫ P \ 0}

\frac{G′; D_{1} ≫ P \ G_{1} G′; D_{2} ≫ P \ G_{2}}{G′; D_{1} & D_{2} ≫ P \ G_{1} ⊕ G_{2}}

\frac{(!G_{1}) • G′; D ≫ P \ G}{G′; G_{1} → D ≫ P \ G}  \frac{(¡G_{1}) • G′; D ≫ P \ G}{G′; G_{1} −∘ D ≫ P \ G}

\frac{G_{1} ∘ G′; D ≫ P \ G}{G′; G_{1} ↠ D ≫ P \ G}  \frac{G_{1} • G′; D ≫ P \ G}{G′; G_{1} ↣ D ≫ P \ G}

Note that these inference rules will not fail when the input/output conventions mentioned above are respected; thus every clause formula can be successfully residuated.

Lemma 22 For every D,G′,P there exists a unique, non-atomic G such that G′; D ≫ P \ G

The example from the beginning of this section, P_{1} ↠ P_{2} ↣ P, can now be residuated as follows:

\frac{\frac{\overline{P_{2} • (P_{1} ∘ 1); P ≫ P \ (P ≐ P) • (P_{2} • (P_{1} ∘ 1))}}{P_{1} ∘ 1; P_{2} ↣ P ≫ P \ (P ≐ P) • (P_{2} • (P_{1} ∘ 1))}}{1; P_{1} ↠ P_{2} ↣ P ≫ P \ (P ≐ P) • (P_{2} • (P_{1} ∘ 1))}

where we use 1 to initialize the accumulated result.

We will remove the non-determinism from choice_{Γ} and choice_{Δ} by replacing them with the following rules:

1; D ≫ P \ G Γ_{L}DΓ_{R}; Δ; Ω ⟶^{r} G

choiceR_{Γ}

Γ_{L}DΓ_{R}; Δ; Ω ⟶^{r} P

1Head in the sense of Prolog or λProlog.

1; D ≫ P \ G Γ; Δ_{L}Δ_{R}; Ω ⟶^{r} G

choiceR_{Δ}

Γ; Δ_{L}DΔ_{R}; Ω ⟶^{r} P

All of the other inference rules remained unchanged from Section 7.1.

We now prove the following theorems which justifies such a change.

Theorem 23 (Soundness of Residuation)

1. Γ; Δ; Ω ⟶^{r} G implies Γ; Δ; Ω ⟶ G.

2. Γ; Δ; (Ω_{L}; Ω_{R}) ⟶^{r} D ≫ P implies Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P.

3. G′; D ≫ P \ G and Γ; Δ; Ω ⟶^{r} G implies

there exists Δ′, Δ_{D}, Ω_{L}, Ω′, and Ω_{R} such that Ω = Ω_{L}Ω′Ω_{R} and Δ = Δ_{D} ▷◁ Δ′ and Γ; Δ′; Ω′ ⟶^{r} G′ and Γ; Δ_{D}; (Ω_{L}; Ω_{R}) ⟶ D ≫ P.

Proof: Parts 1 and 2: by structural induction on the given residuation derivation. We show a representative case.

case: 1; D ≫ P \ G Γ; Δ_{L}Δ_{R}; Ω ⟶^{r} G choiceR_{Δ} Γ; Δ_{L}DΔ_{R}; Ω ⟶^{r} P

Γ; Δ_{L}Δ_{R}; (Ω_{L}; Ω_{R}) ⟶ D ≫ P and Γ; Δ′; Ω′ ⟶^{r} 1
where Ω = Ω_{L}Ω′Ω_{R} and Δ = Δ_{L}Δ_{R} ▷◁ Δ′  ind. hyp. (Pt. 3)
Δ′ = · = Ω′  inversion
Γ; Δ_{L}DΔ_{R}; Ω_{L}Ω_{R} ⟶ P  choice_{Ω}

Part 3: by structural induction on given residual derivation using inversion on the residuation derivation rules for multiplicative conjunctions. Note that G cannot be atomic. We give a representative case for part 3.

case: \frac{G_{1} ∘ G′; D ≫ P \ G}{G′; G_{1} ↠ D ≫ P \ G} and Γ; Δ; Ω ⟶^{r} G

Ω_{L}Ω′Ω_{R} = Ω and Δ = Δ_{D} ▷◁ Δ′ and

Γ; Δ′; Ω′ ⟶ G_{1} ∘ G′ and Γ; Δ_{D}; (Ω_{L}; Ω_{R}) ⟶ D ≫ P  ind. hyp.

Ω′ = Ω′_{2}Ω′_{1} and Δ′ = Δ′_{1} ▷◁ Δ′_{2} and

Γ; Δ′_{1}; Ω′_{1} ⟶^{r} G_{1} and Γ; Δ′_{2}; Ω′_{2} ⟶^{r} G′  inversion on ∘_{R}
Γ; Δ_{D} ▷◁ Δ′_{1}; (Ω_{L}; Ω′_{1}Ω_{R}) ⟶ G_{1} ↠ D ≫ P  by rule ↠_{L}
□

Theorem 24 (Completeness of Residuation)

1. Γ; Δ; Ω ⟶ G implies Γ; Δ; Ω ⟶^{r} G.

2. Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P implies Γ; Δ; (Ω_{L}; Ω_{R}) ⟶^{r} D ≫ P.

3. Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P and G′; D ≫ P \ G and Γ; Δ′; Ω ⟶^{r} G′

implies Γ; Δ ▷◁ Δ′; Ω_{L}ΩΩ_{R} ⟶^{r} G.

Proof: Structural induction on given uniform derivation. We give a representative case for part 1, and for part 3. case (for Part 1): Γ; Δ_{L}Δ_{R}; (Ω_{L}; Ω_{R}) ⟶ D ≫ P choice_{Δ} Γ; Δ_{L}DΔ_{R}; Ω_{L}Ω_{R} ⟶ P

Γ; ·; · ⟶^{r} 1  rule 1_{R}
1; D ≫ P \ G  Lemma 22
Γ; Δ_{L}Δ_{R}; Ω_{L}Ω_{R} ⟶^{r} G  ind. hyp. (Pt. 3)
Γ; Δ_{L}DΔ_{R}; Ω_{L}Ω_{R} ⟶^{r} P  choiceR_{Ω}

case (for Part 3): Γ; Δ; (Ω_{L}; Ω_{R}) ⟶ D ≫ P Γ; Δ_{G}; Ω_{1} ⟶ G_{1} ↠_{L} Γ; Δ ▷◁ Δ_{G}; (Ω_{L}; Ω_{1}Ω_{R}) ⟶ G_{1} ↠ D ≫ P

G′; G_{1} ↠ D ≫ P \ G and Γ; Δ′; Ω ⟶^{r} G′ assumptions
G_{1} ∘ G′; D ≫ P \ G  inversion
Γ; Δ_{G}; Ω_{1} ⟶^{r} G_{1}  ind. hyp. (Pt. 1)
Γ; Δ_{G} ▷◁ Δ′; ΩΩ_{1} ⟶^{r} G_{1} ∘ G′  by rule ∘_{R}
Γ; Δ ▷◁ Δ_{G} ▷◁ Δ′; Ω_{L}ΩΩ_{1}Ω_{R} ⟶^{r} G  ind. hyp. (Pt. 3)

□

Note that only mobile formulas can be residuated into goal formulas. The fact that these formulas can be placed anywhere in the ordered context is crucial for the correctness of the residuation transformation. There seems to be no way to logically compile ordered clause formulas into goal formulas because it would require recording the location of the clause formula in the resulting goal formula.

Lazy Context Splitting

We now deal with the non-deterministic context splitting required of the ↠_{L}, ↣_{L}, −∘_{L}, •_{R}, and ∘_{R} rules. For linear logic, it is well known that this non-determinism can be removed by using an input/output resource management system [27]. This approach, which “lazily” splits contexts by passing all formulas, or resources, to one premise and then giving the left-overs to the other premise, operationally requires fixing an order for proving the premises of an inference rule.

More general constraint based approaches, which do not require a fixed order for proving premises, are also possible for linear logic [22, 4]. It seems quite likely that similar constraint based systems can be developed for ordered linear logic. However these approaches, while of interest for general theorem proving, are not necessarily suited for a logic programming interpreter whose operational semantics must have a strong computational interpretation. Since we are presently aiming at developing a logic programming system, we will not pursue general constraint-based approaches to ordered resource management in this thesis.

As shown in [49] the input/output (IO) model can be extended to ordered linear logic. In this chapter, we present those results applied to the residuation derivation system of chapter 7.

8.1 An Ordered IO System

Linear hypotheses can be treated as in the so-called IO system of Hodas and Miller [27]. The rules •_{R}, ∘_{R}, −∘_{L}, ↠_{L}, and ↣_{L} propagate all linear hypotheses to the first premise which returns the list of unused hypotheses when it has been solved successfully. These are then passed on to the second premise. The hypotheses used in neither premise are then returned as unused in the conclusion.

This model of deterministic resource consumption is intuitively attractive and easy to reason about for the programmer, but its extension to the ordered context is complicated by the need to preserve the order of the hypotheses:

·; ·; P_{2}P_{1}(P_{1} ↣ P_{2} ↣ P) ⟶ P

is a derivable sequent while

·; ·; P_{1}P_{2}(P_{1} ↣ P_{2} ↣ P) ⟶ P

is not. For the main judgement of uniform derivability, adding input and output contexts is straightforward.

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G

During the search, the input contexts Γ, Δ_{I}, and Ω_{I} and the goal G are given, while the output contexts Δ_{O} and Ω_{O} are returned. In the interest of economy (both for the presentation of the rules and the implementation) we do not actually delete formulas from Δ_{I} and Ω_{I} but replace them with a placeholder □.

The right rules for the ordered resource management judgement are constructed by expanding the contexts from the uniform derivation system into pairs of input/output contexts. Thus the ↠_{R} rule is just:

Γ ; Δ_{I}\Δ_{O} ; Ω_{I}D\Ω_{O}□ ⟶ G ↠_{R}

Γ ; Δ_{I}\Δ_{O} ; Ω_{I}\Ω_{O} ⟶ D ↠ G

We require the □ in the output context to ensure the hypothesis has actually been used. The other right rules (excluding those for • and ∘), as well as the choice_{Γ} and choice_{Δ} rules, are constructed similarly. Section 8.2 contains the complete resource management system for ordered linear logic. Note that this lazy splitting of resources actually introduces non-determinism, the construction of linear and ordered output contexts, into the ⊤_{R} rule.

Next we come to the choice_{Ω} rule, that is, we choose to focus on an ordered assumption. This determines the division of the remaining ordered hypotheses. We therefore divide the input contexts and join the output contexts at the chosen assumption. The new judgement reads

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P

where Ω_{LI} and Ω_{RI} are the parts to the left and right of the focussed formula D, and Ω_{LO} and Ω_{RO} are the corresponding output contexts. The choice_{Ω} rule for this system then looks as follows:

Γ ; Δ_{I}\Δ_{O} ; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P

choice_{Ω} Γ ; Δ_{I}\Δ_{O} ; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶ P

Replacing D from the input context with □ in the output context indicates that D was consumed.

The init rule does not consume any resources except for the focus formula. Therefore all input resources are passed on.

\frac{init}{Γ; Δ\Δ; (Ω_{L}\Ω_{L}; Ω_{R}\Ω_{R}) ⟶ P ≫ P}

This effectively states that the linear and ordered contexts of the initial sequent should be empty.

The →_{L}, −∘_{L}, &_{L}, and ∀_{L} rules for this judgement introduce no new ideas.

We now consider the left rule for right implication. We are trying to derive a judgement of the form

Γ ; Δ_{I}\? ; (Ω_{LI}\? ; Ω_{RI}\?) ⟶ G ↠ D ≫ P

where the output contexts denoted by ? have yet to be computed. The linear output context can be threaded through each of the premises without further analysis. However for the ordered output contexts, we need to do a bit more work. Because G ↠ D is a right implication situated between Ω_{LI} and Ω_{RI}, the derivation of G must consume some initial segment of Ω_{RI}. Before that, we need to see if D immediately entails P (the left premise of the ↠_{L} rule)^{1} which we obtain from

Γ ; Δ_{I}\Δ_{M} ; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω) ⟶ D ≫ P

Then we need to take the unconsumed parts at the left end of Ω, denoted by Ω_{GI}, and allow them as the ordered input context for the solution to G.

Γ ; Δ_{M}\Δ_{O} ; Ω_{GI}\Ω_{GO} ⟶ G

1In Prolog terminology: we need to unify the clause head with P before solving any subgoals.

Now we can fill the holes in the conclusion with Ω_{LO} and Ω_{GO}Ω_{RO}, respectively. In summary, the rule reads

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶ D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶ G ↠_{L1}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶ G ↠ D ≫ P

where Ω_{GI} is the longest leftmost segment of Ω_{GI}Ω_{RO} not containing □, and Ω_{RO} the remainder. We will denote this with the following notation:

□ ∉ Ω_{GI} and Ω_{RO} = □ or ·

Note that Ω_{RO} = □ or · really stands for ∃Ω. Ω_{RO} = □Ω or Ω_{RO} = ·. We will use the symmetric notation, Ω_{LO} = □ or · to form the ↣_{L} and •_{R} rules.

Further note that the context split appearing in the ↠_{L} rule, Ω_{GI}Ω_{RO}, is deterministic.

In order to demonstrate the intended operational use of the input/output system, we now walk through a short example derivation (where we elide the always empty unrestricted and linear contexts); figure 8.1 contains the complete formal derivation (still with elided contexts). Consider trying to prove the closed formula:

(P_{1} ↠ P_{2} ↠ P) ↠ P_{1} ↠ P_{2} ↠ P

Since we want a self-contained proof, we begin with the sequent:

·\· ⟶ (P_{1} ↠ P_{2} ↠ P) ↠ P_{1} ↠ P_{2} ↠ P

where we specify that the ordered output context is empty. After three uses of the ↠_{R} rule we arrive at the following situation:

(P_{1} ↠ P_{2} ↠ P)P_{1}P_{2}\? ⟶ P

where we have not yet computed the ordered output context. We must now choose a formula to focus on. Of course we will choose the only one which works:

·\·; P_{1}P_{2}\? ⟶ P_{1} ↠ P_{2} ↠ P ≫ P

We now start applying ↠_{L} rules. We will always try the major premise first and put the minor premise on a stack of things to do. Thus we arrive at the sequent:

·\·; P_{1}P_{2}\P_{1}P_{2} ⟶ P ≫ P

\frac{init}{· \·; P_{1}P_{2}\P_{1}P_{2} ⟶ P ≫ P}

\frac{init}{P_{1}\P_{1} ; ·\· ⟶ P_{2} ≫ P_{2}}

choice_{Ω}

P_{1}P_{2}\P_{1}□ ⟶ P_{2}

↠_{L}
· \·; P_{1}P_{2}\P_{1}□ ⟶ P_{2} ↠ P ≫ P

\frac{init}{· \·; ·\· ⟶ P_{1} ≫ P_{1}}

choice_{Ω}
P_{1}\□ ⟶ P_{1}
↠_{L}

· \·; P_{1}P_{2}\□□ ⟶ P_{1} ↠ P_{2} ↠ P ≫ P

choice_{Ω}

(P_{1} ↠ P_{2} ↠ P)P_{1}P_{2}\□□□ ⟶ P

↠_{R}

(P_{1} ↠ P_{2} ↠ P)P_{1}\□□ ⟶ P_{2} ↠ P

↠_{R}

(P_{1} ↠ P_{2} ↠ P)\□ ⟶ P_{1} ↠ P_{2} ↠ P

↠_{R}

· \· ⟶ (P_{1} ↠ P_{2} ↠ P) ↠ P_{1} ↠ P_{2} ↠ P

Figure 8.1: Sample derivation

Because this sequent is initial, we know that the input and output ordered contexts are equal. We can now move on to the proof of P_{2}:

P_{1}P_{2}\? ⟶ P_{2}

We will prove this by focussing on P_{2}. After a choice_{Ω} rule, we get to the initial sequent:

P_{1}\P_{1} ; ·\· ⟶ P_{2} ≫ P_{2}

We know then, from the form of the choice_{Ω} rule that the output context for the proof of P_{2}, the immediately preceding ?, is P_{1}□. We may now move on to proving P_{1}. Note that the input context for the proof of P_{1} will only consist of P_{1}:

P_{1}\? ⟶ P_{1}

We will focus on P_{1}, which will give us an initial sequent. Then, coming out of the choice_{Ω} rule, we will be able to compute that the output context above is just □. At this point, we have no presmises left to prove, however we are not done. We must continue back “down” the proof tree, filling in output contexts and checking to make sure the conditions on the output contexts required by the ↠_{R} rules are met.

The right rule for • is handled similarly. The left rule for ↣ and the right rule for ∘ are symmetrically fashioned.

8.2 Resource Management System for OLL

We now present the complete resource management system (RMS) for ordered linear logic. We have two types of sequent for our RMS derivations

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G
Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P

corresponding to the two types of sequents in the previous sections. are the output contexts. The unrestricted and ordered input contexts, Γ, Ω_{I}, Ω_{LI}, and Ω_{RI}, are lists of clauses which do not contain placeholders, □. The linear input context, Δ_{I}, is a list which may contain both formulas and □. Likewise, all of the output contexts, Δ_{O}, Ω_{O}, Ω_{LO}, and Ω_{RO}, may contain both formulas and □.

We define the following “superset” relation on input/output contexts, where we use Ψ to stand for any kind of context (unrestricted, linear, or ordered):

\overline{· ⊒ ·}  \frac{Ψ ⊒ Ψ′}{ΨD ⊒ Ψ′D}  \frac{Ψ ⊒ Ψ′}{ΨD ⊒ Ψ′□}  \frac{Ψ ⊒ Ψ′}{Ψ□ ⊒ Ψ′□}

It will be an invariant of our derivation rules that input contexts will always be supersets of their associated output contexts, i.e., anytime Ψ_{I}\Ψ_{O} appears in a valid derivation, Ψ_{I} ⊒ Ψ_{O} holds.

We use the notation ∥Ψ∥ to denote the length of list Ψ. Note that Ψ ⊒ Ψ′ implies that ∥Ψ∥ = ∥Ψ′∥.

Here are the RMS derivation rules:

\frac{≐_{R}}{Γ; Δ\Δ; Ω\Ω ⟶ P ≐ P}  \frac{1_{R}}{Γ; Δ\Δ; Ω\Ω ⟶ 1}

Γ; ·\·; ·\· ⟶ G !_{R} Γ; Δ\Δ; Ω\Ω ⟶ !G Γ; Δ_{I}\Δ_{O}; ·\· ⟶ G

ΓD; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G →_{R}

Γ; Δ_{I}D\Δ_{O}□; Ω_{I}\Ω_{O} ⟶ G −∘_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}D\Ω_{O}□ ⟶ G ↠_{R}

Γ; Δ_{I}\Δ_{O}; DΩ_{I}\□Ω_{O} ⟶ G ↣_{R}

¡_{R} Γ; Δ_{I}\Δ_{O}; Ω\Ω ⟶ ¡G Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ D → G

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ D −∘ G Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ D ↠ G

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ D ↣ G

Γ; Δ_{I}\Δ_{M}; Ω_{I}\Ω_{L}Ω_{2} ⟶ G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{R} ⟶ G_{2} •_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶ G_{1} • G_{2}

(□ ∉ Ω_{2} and (Ω_{L} = □ or ·))

Γ; Δ_{I}\Δ_{M}; Ω_{I}\Ω_{2}Ω_{R} ⟶ G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{L} ⟶ G_{2} ∘_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶ G_{1} ∘ G_{2}

(□ ∉ Ω_{2} and (Ω_{R} = □ or ·))

Ω_{I} ⊒ Ω_{O} and Δ_{I} ⊒ Δ_{O} ⊤_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ ⊤

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{1} Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{2}
&_{R}
Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{1} & G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{1} ⊕_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{1} ⊕ G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{2} ⊕_{R2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G_{1} ⊕ G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G[a/x] ∀_{R}^{a}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ ∀x. G (a not free in conclusion)

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G[t/x]
∃_{R}
Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ ∃x. G

1; D ≫ P \ G Γ_{L}DΓ_{R}; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G

choice_{Γ}

Γ_{L}DΓ_{R}; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ P

1; D ≫ P \ G Γ; Δ_{LI}□Δ_{RI}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G

choice_{Δ}

Γ; Δ_{LI}DΔ_{RI}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P

choice_{Ω}

Γ; Δ_{I}\Δ_{O}; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶ P

\frac{init}{Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶ P ≫ P}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D_{1} ≫ P

&_{L1}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D_{1} & D_{2} ≫ P Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D_{2} ≫ P

&_{L2}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D_{1} & D_{2} ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D[t/x] ≫ P

∀_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ ∀x. D ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P Γ; ·\·; ·\· ⟶ G →_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ G → D ≫ P

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P Γ; Δ_{M}\Δ_{O}; ·\· ⟶ G −∘_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ G −∘ D ≫ P

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶ D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶ G ↠_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶ G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO}Ω_{GI} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶ G ↣_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO}Ω_{GO} ; Ω_{RI}\Ω_{RO}) ⟶ G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·))

Note that the choice_{Δ} rule only allows an actual formula, and not a □, to be focussed upon.

The RMS system satisfies the following basic properties which we shall rely upon to prove its correctness.

Lemma 25

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G implies Ω_{I} ⊒ Ω_{O} and Δ_{I} ⊒ Δ_{O}.

2. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P implies Ω_{LI} ⊒ Ω_{LO} and Ω_{LI} ⊒ Ω_{LO} and Δ_{I} ⊒ Δ_{O}.

3. Γ; Δ_{I}\Δ_{O}; Ω_{IL}Ω_{IR}\Ω_{OL}Ω_{OR} ⟶ G and □ ∉ Ω, Δ and Ω_{IL} ⊒ Ω_{OL} implies Γ; Δ_{I} ▷◁ Δ\Δ_{O} ▷◁ Δ; Ω_{IL}ΩΩ_{IR}\Ω_{OL}ΩΩ_{OR} ⟶ G.

4. Γ; Δ_{I}\Δ_{O}; (Ω_{LIL}Ω_{LIR}\Ω_{LOL}Ω_{LOR} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P

and □ ∉ Ω and Ω_{LIL} ⊒ Ω_{LOL} implies Γ; Δ_{I}\Δ_{O}; (Ω_{LIL}ΩΩ_{LIR}\Ω_{LOL}ΩΩ_{LOR} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P.

5. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RIL}Ω_{RIR}\Ω_{ROL}Ω_{ROR}) ⟶ D ≫ P

and □ ∉ Ω and Ω_{RIL} ⊒ Ω_{ROL} implies Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RIL}ΩΩ_{RIR}\Ω_{ROL}ΩΩ_{ROR}) ⟶ D ≫ P.

Proof: By structural induction on given derivation. □

8.3 Correctness of RMS

In order to prove that RMS derivations are sound and complete with respect to residuation derivations, we define the difference of an input context, and output context, Ψ_{I} − Ψ_{O}, as follows:

· − ·  = ·
Ψ_{I}D − Ψ_{O}D = (Ψ_{I} − Ψ_{O})
Ψ_{I}□ − Ψ_{O}□ = (Ψ_{I} − Ψ_{O})
Ψ_{I}D − Ψ_{O}□ = (Ψ_{I} − Ψ_{O}) D

where input patterns not covered are undefined. Thus ∥Ψ_{I}∥ ≠ ∥Ψ_{O}∥ implies Ψ_{I} − Ψ_{O} is undefined. Also note that Ψ_{I} ⊒ Ψ_{O} implies Ψ_{I} − Ψ_{O} is defined; and conversely, Ψ_{I} − Ψ_{O} is defined implies Ψ_{I} ⊒ Ψ_{O}.

We begin by showing soundness.

Theorem 26 (Soundess of RMS)

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G implies Γ; Δ_{I} − Δ_{O}; Ω_{I} − Ω_{O} ⟶^{r} G.

2. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P implies

Γ; Δ_{I} − Δ_{O}; (Ω_{LI} − Ω_{LO}; Ω_{RI} − Ω_{RO}) ⟶^{r} D ≫ P.

Proof: By structural induction on given RMS derivation. We give representative cases.

case: \frac{init}{Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶ P ≫ P}

Then

Γ; ·; (·; ·) ⟶^{r} P ≫ P  init

case: 1; D ≫ P \ G Γ; Δ_{IL}□Δ_{IR}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G choice_{Δ} Γ; Δ_{IL}DΔ_{IR}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ P Then

Γ; Δ_{IL}□Δ_{IR} − Δ_{O}; Ω_{I} − Ω_{O} ⟶^{r} G  ind. hyp.
Δ_{O} = Δ_{OL}□Δ_{OR} where Δ_{IL} ⊒ Δ_{OL}  Δ_{IL}□Δ_{IR} ⊒ Δ_{O}

Δ_{IL}□Δ_{IR} − Δ_{O} = (Δ_{IL} − Δ_{OL})(Δ_{IR} − Δ_{OR})

Γ; (Δ_{IL} − Δ_{OL})D(Δ_{IR} − Δ_{OR}); Ω_{I} − Ω_{O} ⟶^{r} P  choice_{Δ}

Note (Δ_{IL} − Δ_{OL})D(Δ_{IR} − Δ_{OR}) = Δ_{IL}DΔ_{IR} − Δ_{OL}□Δ_{OR}

case: Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P choice_{Ω} Γ; Δ_{I}\Δ_{O}; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶ P Then

Γ; Δ_{I} − Δ_{O}; (Ω_{LI} − Ω_{LO}; Ω_{RI} − Ω_{RO}) ⟶^{r} D ≫ P  ind. hyp.
Γ; Δ_{I} − Δ_{O}; (Ω_{LI} − Ω_{LO})D(Ω_{RI} − Ω_{RO}) ⟶^{r} P  choice_{Ω}

Note (Ω_{LI} − Ω_{LO})D(Ω_{RI} − Ω_{RO}) = Ω_{LI}DΩ_{RI} − Ω_{LO}□Ω_{RO}

case: Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶ D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶ G ↠_{L} Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶ G ↠ D ≫ P (□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·)) Then

Ω_{RI} = Ω_{GI}Ω_{RR}  lemma 25
Ω_{RI} − Ω_{GI}Ω_{RO} = Ω_{RR} − Ω_{RO}  □ ∉ Ω_{GI} and defn. of -
Ω_{RI} − Ω_{GO}Ω_{RO} = (Ω_{GI} − Ω_{GO})(Ω_{RR} − Ω_{RO})  defn. of -

Γ; Δ_{M} − Δ_{O}; Ω_{GI} − Ω_{GO} ⟶^{r} G  ind. hyp.
Γ; Δ_{I} − Δ_{M}; (Ω_{LI} − Ω_{LO}; Ω_{RR} − Ω_{RO}) ⟶^{r} D ≫ P  ind. hyp.

Note: (Δ_{I} − Δ_{M}) ▷◁ (Δ_{M} − Δ_{O}) = Δ_{I} − Δ_{O}

Γ; Δ_{I} − Δ_{O}; (Ω_{LI} − Ω_{LO}; (Ω_{GI} − Ω_{GO})(Ω_{RR} − Ω_{RO})) ⟶^{r} G ↠ D ≫ P ↠_{L}
□

We immediately get the following corollary: Corollary 27

1. Γ; ·\·; ·\· ⟶ G implies Γ; ·; · ⟶^{r} G.

2. Γ; ·\·; (·\·; ·\·) ⟶ G ≫ P implies Γ; ·; (·; ·) ⟶^{r} G ≫ P. We now move on to showing completeness.

Theorem 28 (Completeness of RMS)

1. Γ; Δ_{I} − Δ_{O}; Ω_{I} − Ω_{O} ⟶^{r} G and □ ∉ Ω_{I} implies Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G.

2. Γ; Δ_{I} − Δ_{O}; (Ω_{LI} − Ω_{LO}; Ω_{RI} − Ω_{RO}) ⟶^{r} D ≫ P

and □ ∉ Ω_{LI} and □ ∉ Ω_{RI} implies

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P.

Proof: By structural induction on given residuation derivation. We give representative cases.

case: \frac{init}{Γ; ·; (·; ·) ⟶^{r} P ≫ P}

Then

Δ_{I} − Δ_{O} = · and Ω_{LI} − Ω_{LO} = · and Ω_{LI} − Ω_{LO} = ·  assumptions
Δ_{I} = Δ_{O} and Ω_{LI} = Ω_{LO} and Ω_{RI} = Ω_{RO}  defn. of -
Γ; Δ_{I}\Δ_{I}; (Ω_{LI}\Ω_{LI} ; Ω_{RI}\Ω_{RI}) ⟶ P ≫ P  init

case: 1; D ≫ P \ G Γ; Δ_{L}Δ_{R}; Ω ⟶^{r} G choice_{Δ} Γ; Δ_{L}DΔ_{R}; Ω ⟶^{r} P Then

Δ_{I} − Δ_{O} = Δ_{L}DΔ_{R} and Ω_{I} − Ω_{O} = Ω  assumptions

Δ_{I} = Δ_{IL}DΔ_{IR} and Δ_{O} = Δ_{OL}□Δ_{OR} and Δ_{IL} − Δ_{OL} = Δ_{L} Δ_{IL}□Δ_{IR} − Δ_{OL}□Δ_{OR} = Δ_{L}Δ_{R}

Γ; Δ_{IL}□Δ_{IR}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ G  ind. hyp.
Γ; Δ_{IL}DΔ_{IR}\Δ_{O}; Ω_{I}\Ω_{O} ⟶ P  choice_{Δ}

case: Γ; Δ; (Ω_{L}; Ω_{R}) ⟶^{r} D ≫ P choice_{Ω} Γ; Δ; Ω_{L}DΩ_{R} ⟶^{r} P Then

Δ_{I} − Δ_{O} = Δ and Ω_{I} − Ω_{O} = Ω_{L}DΩ_{R}  assumptions

Ω_{I} = Ω_{IL}DΩ_{IR} and Ω_{O} = Ω_{OL}□Ω_{OR}

where Ω_{IL} − Ω_{OL} = Ω_{L} and Ω_{IR} − Ω_{OR} = Ω_{R}  defn. of -
Γ; Δ_{I}\Δ_{O}; (Ω_{IL}\Ω_{OL} ; Ω_{IR}\Ω_{OR}) ⟶ D ≫ P  ind. hyp.
Γ; Δ_{I}\Δ_{O}; Ω_{IL}DΩ_{IR}\Ω_{OL}□Ω_{OR} ⟶ P  choice_{Ω}

case: Γ; Δ; (Ω_{L}; Ω_{R}) ⟶^{r} D ≫ P Γ; Δ_{G}; Ω_{G} ⟶^{r} G ↠_{L} Γ; Δ ▷◁ Δ_{G}; (Ω_{L}; Ω_{G}Ω_{R}) ⟶^{r} G ↠ D ≫ P Then

Let Δ_{I} − Δ_{O} = Δ ▷◁ Δ_{G} and □ ∉ Ω_{LI} and □ ∉ Ω_{RI}

and Ω_{LI} − Ω_{LO} = Ω_{L} and Ω_{RI} − Ω′_{RO} = Ω_{G}Ω_{R}  assumptions

Let Δ_{M} be a context s.t. Δ_{I} − Δ_{M} = Δ and Δ_{M} − Δ_{O} = Δ_{G} Let Ω_{GI}Ω_{RR} = Ω_{RI} and Ω_{GO}Ω_{RO} = Ω′_{RO} where

Ω_{GI} − Ω_{GO} = Ω_{G} and Ω_{RR} − Ω_{RO} = Ω_{R} and (Ω_{RO} = □ or ·)

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶ D ≫ P  ind. hyp.
Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶ G  ind. hyp.
Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶ G ↠ D ≫ P  by rule ↠_{L}
□

The RMS derivation succeeds in removing all non-deterministic context-splits. However, this comes at the cost of introducing non-determinism into the ⊤_{R} rule. This new non-determinism must also be eradicated in order to have a feasible basis for a logic programming language.

110

Lazy Erasure

As noted in Chapter 8, we removed the non-deterministic context splits at the expense of making the ⊤_{R} rule highly non-deterministic. A similar situation occurs in the development of Lolli [26] and is simply dealt with by adding a binary flag to each sequent denoting whether, or not, a ⊤ capable of consuming the linear hypotheses occurs in the derivation; if such a ⊤ does occur, then linearity can be relaxed. In that system the ⊤_{R} rule does nothing except set this flag. Thus we may think of ⊤ consuming, or erasing, formulas in a lazy fashion just as the RMS system of Chapter 8 lazily splits contexts.

Unfortunately, such a simple solution is not possible for ordered linear logic. The fact that ordered contexts are split apart and later recombined prevents a solution with a single binary flag– consider that the immediate entailment sequents maintain two separate ordered context input/output pairs. However, there is a way to extend the idea of a ⊤ flag which allows us to remove the non-determinism from the ⊤_{R} rule. This chapter explains how we accomplish that task.

9.1 Making ⊤ Deterministic

In this section we remove the non-determinism from the ⊤_{R} rule by making it lazy– it will simply pass on its input context– and adding some new information to the sequents to keep track of which parts of the ordered context could have been consumed by a ⊤.

Rather than use a single ⊤-flag, we will use a list, τ, containing both 0 and 1 which serves as an abstraction of the output context. The 0s in τ will correspond to the □s in Ω. The 1s in τ will corresponds to regions of Ω which could have been consumed by a ⊤. For example consider the following:

Ω = □Ω_{1}□Ω_{2}□ τ = 0100

where □ ∉ Ω_{1}Ω_{2}. The 1 in τ states that Ω_{1} passed through a ⊤_{R} rule and thus need not be explicitly consumed. However, Ω_{2} must be explicitly consumed since there is no 1 in τ matching it. Thus the τs may also be thought of as abstractions of the output contexts which express strictness (whether formulas must be explicitly consumed) constraints. In analogy to output contexts, we will use the notation τ = 0 or · , and its symmetric variation, to stand for ∃τ′. τ = 0τ′ or τ = ·.

In order to simplify our presentation, we shall restrict τ to never have two consecutive 1s. To cut down the number of explicit cases we must examine in our subsequent development, we define the following concatenation operators for τ which contract adjacent 1s:

\begin{matrix}· + τ′ = & τ′ \\ τ0 + τ′ = & τ0τ′ \\ τ1 + · = & τ1 \\ τ1 + 0τ′ = & τ10τ′ \\ τ1 + 1τ′ = & τ1τ′ \end{matrix}  \begin{matrix}· ∗ · = & · \\ 1 ∗ · = & · \\ · ∗ 1 = & · \\ 1 ∗ 1 = & 1 \end{matrix}

We will use the “disjunctive” concatenation, +, to form output contexts in the inference rules developed in this section. We will only use the “conjunctive” concatenation, ∗, in the definition of mrg, a helper function defined below.

Note that the constraint 0 ∉ τ implies that τ = · or τ = 1.

As a result of making ⊤_{R} lazy, two different, yet compatible, output contexts might be computed for the two premises of the &_{R} rule. In order to give a correct version of the rule, we need to be able to merge compatible contexts into a form which preserves the constraints on both contexts. With this in mind, we define a helper relation, mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ), to merge two compatible pairs of ordered output contexts and their abstractions. Note that mrg is a function where the first four arguments are input and the last two are output.

\frac{0 ∉ τ_{1} and 0 ∉ τ_{2}}{mrg(·, τ_{1}, ·, τ_{2}, ·, τ_{1} ∗ τ_{2})}  \frac{mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ)}{mrg(DΩ_{1}, τ_{1}, DΩ_{2}, τ_{2}, DΩ, τ)}

mrg(Ω_{1}, 1τ_{1}, Ω_{2}, τ_{2}, Ω, τ) (0 ∉ τ′_{2})

mrg(DΩ_{1}, 1τ_{1}, □Ω_{2}, τ′_{2}0τ_{2}, □Ω, τ′_{2}0τ)

mrg(Ω_{1}, τ_{1}, Ω_{2}, 1τ_{2}, Ω, τ) (0 ∉ τ′_{1})

mrg(□Ω_{1}, τ′_{1}0τ_{1}, DΩ_{2}, 1τ_{2}, □Ω, τ′_{1}0τ)

mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) (0 ∉ τ′_{i})

mrg(□Ω_{1}, τ′_{1}0τ_{1}, □Ω_{2}, τ′_{2}0τ_{2}, □Ω, (τ′_{1} ∗ τ′_{2})0τ)

mrg satisfies the following properties which we will rely upon in the subsequent correctness proofs.

Lemma 29

1. mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, 1τ) implies τ_{1} = 1τ′_{1} and τ_{2} = 1τ′_{2}.

2. mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) and □ ∉ Ω implies Ω_{1} = Ω_{2} = Ω.

3. mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) implies mrg(Ω_{1}, 1 + τ_{1}, Ω_{2}, 1 + τ_{2}, Ω, 1 + τ).

Proof: By structural induction on the given derivation. □

We also define mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v), where v_{i} ∈ {T, F }, to merge two compatible linear contexts. We use the standard notations ∨ and ∧ for boolean disjunction and conjunction. mrgL is also a function where the first four arguments are input and the last two are output.

\overline{mrgL(·, v_{1}, ·, v_{2}, ·, v_{1} ∧ v_{2})}

\frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v)}{mrgL(DΔ_{1}, v_{1}, DΔ_{2}, v_{2}, DΔ, v)}  \frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v)}{mrgL(□Δ_{1}, v_{1}, □Δ_{2}, v_{2}, □Δ, v)}

\frac{mrgL(Δ_{1}, T, Δ_{2}, v_{2}, Δ, v)}{mrgL(DΔ_{1}, T, □Δ_{2}, v_{2}, □Δ, v)}  \frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, T, Δ, v)}{mrgL(□Δ_{1}, v_{1}, DΔ_{2}, T, □Δ, v)}

We state a few properties of mrgL which will be helpful in subsequent proofs.

Lemma 30 Assume T ⊒ T and T ⊒ F and F ⊒ F and F ⋣ T.

1. mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v) implies v = v_{1} ∧ v_{2} and Δ_{i} ⊒ Δ.

2. mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v) and v_{i} = F implies Δ_{i} = Δ.

3. Δ_{1} ⊒ Δ_{2} and v_{1} ⊒ v_{2} implies there exist Δ and v such that mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v).

4. Δ_{2} ⊒ Δ_{1} and v_{2} ⊒ v_{1} implies there exist Δ and v such that mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v).

Proof: By structural induction on given derivation in parts 1 and 2. By structural induction on Δ_{1} in part 3. By structural induction on Δ_{2} in part 4. □

We now have enough machinery to write down our ⊤-flag derivation system. We have two types of sequent for our ⊤-flag derivations:

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P

which correspond exactly to their RMS counterparts with the addition of the previously described output context abstractions, τ, τ_{L}, τ_{R}, and a linear ⊤-flag, v ∈ {T, F }.

Here are the ⊤-flags derivation rules:

\frac{≐_{R}}{Γ; Δ\Δ; Ω\Ω ⟶_{F ·} P ≐ P}  \frac{1_{R}}{Γ; Δ\Δ; Ω\Ω ⟶_{F ·} 1}

Γ; ·\·; ·\· ⟶_{v τ} G !_{R} Γ; Δ\Δ; Ω\Ω ⟶_{F ·} !G Γ; Δ_{I}\Δ_{O}; ·\· ⟶_{v τ} G

Γ; Δ_{I}\Δ_{O}; Ω\Ω ⟶_{v ·} ¡G

ΓD; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} D → G

Γ; Δ_{I}D\Δ_{O}□; Ω_{I}\Ω_{O} ⟶_{v τ} G

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} D −∘ G

Γ; Δ_{I}D\Δ_{O}D; Ω_{I}\Ω_{O} ⟶_{T τ} G

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{T τ} D −∘ G

¡_{R} →_{R} −∘_{RF}

−∘_{RT}

Γ; Δ_{I}\Δ_{O}; Ω_{I}D\Ω_{O}□ ⟶_{v τ0τ′} G

↠_{R0} (0 ∉ τ′)

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} D ↠ G

Γ; Δ_{I}\Δ_{O}; Ω_{I}D\Ω_{O}D ⟶_{v τ1} G

↠_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ1} D ↠ G

Γ; Δ_{I}\Δ_{O}; DΩ_{I}\□Ω_{O} ⟶_{v τ′0τ} G

↣_{R0} (0 ∉ τ′)

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} D ↣ G

Γ; Δ_{I}\Δ_{O}; DΩ_{I}\DΩ_{O} ⟶_{1τ G}

↣_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{1τ D↣G}

Γ; Δ_{I}\Δ_{M}; Ω_{I}\Ω_{L}Ω_{2} ⟶_{v_{1} τ_{L}} G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{R} ⟶_{v_{2} τ_{R}} G_{2}

•_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ_{R})} G_{1} • G_{2}

(□ ∉ Ω_{2} and (Ω_{L} = □ or ·))

Γ; Δ_{I}\Δ_{M}; Ω_{I}\Ω_{2}Ω_{R} ⟶_{v_{1} τ_{R}} G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{L} ⟶_{v_{2} τ_{L}} G_{2}

∘_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ_{R})} G_{1} ∘ G_{2}

(□ ∉ Ω_{2} and (Ω_{R} = □ or ·))

\frac{⊤_{R}}{Γ; Δ\Δ; Ω\Ω ⟶_{T 1} ⊤}

Γ; Δ_{I}\Δ_{1}; Ω_{I}\Ω_{1} ⟶_{v_{1} τ_{1}} G_{1} Γ; Δ_{I}\Δ_{2}; Ω_{I}\Ω_{2} ⟶_{v_{2} τ_{2}} G_{2}  mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω_{O}, τ) mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ_{O}, v)
&_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G_{1} & G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G_{1}

⊕_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G_{1} ⊕ G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G_{2}

⊕_{R2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G_{1} ⊕ G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G[a/x]

∀_{R}^{a}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} ∀x. G

(a not free in conclusion)

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G[t/x]

∃_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} ∃x. G

1; D ≫ P \ G Γ_{L}DG_{R}; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G

choice_{Γ}

Γ_{L}DΓ_{R}; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} P

1; D ≫ P \ G Γ; Δ_{LI}□Δ_{RI}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G

choice_{Δ}

Γ; Δ_{LI}DΔ_{RI}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P

choice_{Ω}

Γ; Δ_{I}\Δ_{O}; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶_{v τ_{L}0τ_{R}} P

\frac{init}{Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶_{F (· ; ·)} P ≫ P}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D_{1} ≫ P

&_{L1}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D_{1} & D_{2} ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D_{2} ≫ P

&_{L2}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D_{1} & D_{2} ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D[t/x] ≫ P

∀_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} ∀x. D ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P Γ; ·\·; ·\· ⟶_{v′ τ} G

→_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} G → D ≫ P

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})} D ≫ P Γ; Δ_{M}\Δ_{O}; ·\· ⟶_{v_{2} τ} G

−∘_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ_{R})} G −∘ D ≫ P

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})} D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{v_{2} τ} G

↠_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ+τ_{R})} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO}Ω_{GI} ; Ω_{RI}\Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})} D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{v_{1} τ} G

↣_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO}Ω_{GO} ; Ω_{RI}\Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ ; τ_{R})} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·))

We introduce the following notation:

#(Ω) ≡ the number of placeholders in Ω
#(τ) ≡ the number of 0s in τ

⊤-flags derivations satisfy the following basic properties. Lemma 31

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G implies Ω_{I} ⊒ Ω_{O} and #(Ω_{O}) = #(τ).

2. Δ_{IL} ⊒ Δ_{OL} implies

Γ; Δ_{IL}□Δ_{IR}\Δ_{OL}□Δ_{OR}; Ω_{I}\Ω_{O} ⟶_{v τ} G iff

Γ; Δ_{IL}DΔ_{IR}\Δ_{OL}DΔ_{OR}; Ω_{I}\Ω_{O} ⟶_{v τ} G.

3. Ω_{IL} ⊒ Ω_{OL} and □ ∉ Ω implies

Γ; Δ_{I}\Δ_{O}; Ω_{IL}ΩΩ_{IR}\Ω_{OL}ΩΩ_{OR} ⟶_{v τ} G iff

Γ; Δ_{I}\Δ_{O}; Ω_{IL}Ω_{IR}\Ω_{OL}Ω_{OR} ⟶_{v τ} G.

4. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P implies

Ω_{LI} ⊒ Ω_{LO} and Ω_{RI} ⊒ Ω_{RO} and

#(Ω_{LO}) = #(τ_{L}) and #(Ω_{RO}) = #(τ_{R}).

5. Δ_{IL} ⊒ Δ_{OL} implies

Γ; Δ_{IL}□Δ_{IR}\Δ_{OL}□Δ_{OR}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P iff

Γ; Δ_{IL}DΔ_{IR}\Δ_{OL}DΔ_{OR}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P.

6. Ω_{LIL} ⊒ Ω_{LOL} and □ ∉ Ω implies

Γ; Δ_{I}\Δ_{O}; (Ω_{LIL}ΩΩ_{LIR}\Ω_{LOL}ΩΩ_{LOR} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P iff

Γ; Δ_{I}\Δ_{O}; (Ω_{LIL}Ω_{LIR}\Ω_{LOL}Ω_{LOR} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P.

7. Ω_{RIL} ⊒ Ω_{ROL} and □ ∉ Ω implies

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RIL}ΩΩ_{RIR}\Ω_{ROL}ΩΩ_{ROR}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P iff

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RIL}Ω_{RIR}\Ω_{ROL}Ω_{ROR}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P.

Proof: Each part is proved by straightforward structural induction on the given derivation. □

9.2 Correctness of ⊤-flags System

In order to prove the correctness of the ⊤-flags derivation system with respect to the resource management system of Chapter 8, we need to relate ⊤-flags output contexts, and their associated flag lists, to RMS output contexts. Due to the lazy treatment of ⊤, one ⊤-flags context can be related to many RMS contexts. We define the following relation between ⊤-flags output contexts and RMS output contexts:

\frac{0 ∉ τ}{Φ(·, τ, ·)}  \frac{Φ(Ω, τ, Ω′)}{Φ(DΩ, τ, DΩ′)}  \frac{Φ(Ω, 1τ, Ω′)}{Φ(DΩ, 1τ, □Ω′)}  \begin{aligned}Φ(Ω, τ, Ω′) \\ & (0 ∉ τ′) \\ Φ(□Ω, τ′0τ, □Ω′) \end{aligned}

Φ satisfies the following properties which we rely upon to prove correctness of the ⊤-flags derivations.

Lemma 32

1. Φ(Ω, τ, Ω′) implies Ω ⊒ Ω′.

2. Φ(Ω_{L}, τ_{L}, Ω′_{L}) and Φ(Ω_{R}, τ_{R}, Ω′_{R}) implies Φ(Ω_{L}Ω_{R}, τ_{L} + τ_{R}, Ω′_{L}Ω′_{R}).

3. Φ(Ω_{L}Ω_{R}, τ_{L}τ_{R}, Ω′) and #(Ω_{L}) = #(τ_{L})

and (Ω_{R} = □ or ·) and (τ_{R} = 0 or ·) implies

there exist Ω′_{L} and Ω′_{R} such that Ω′ = Ω′_{L}Ω′_{R} and Φ(Ω_{L}, τ_{L}, Ω′_{L}) and Φ(Ω_{R}, τ_{R}, Ω′_{R}).

4. Φ(Ω_{L}Ω_{R}, τ_{L}τ_{R}, Ω′) and #(Ω_{R}) = #(τ_{R})

and (Ω_{L} = □ or ·) and (τ_{L} = 0 or ·) implies

there exist Ω′_{L} and Ω′_{R} such that Ω′ = Ω′_{L}Ω′_{R} and Φ(Ω_{L}, τ_{L}, Ω′_{L}) and Φ(Ω_{R}, τ_{R}, Ω′_{R}).

5. Φ(Ω, τ, Ω′_{L}Ω′_{R}) and □ ∉ Ω implies

there exist Ω_{L} and Ω_{R} such that Ω = Ω_{L}Ω_{R} and Φ(Ω_{L}, τ, Ω′_{L}) and Φ(Ω_{R}, τ, Ω′_{R}).

Proof: Each part is proved by induction on the given derivation. □

Additionally, Φ and mrg interact in the following manner which allows our &_{R} rule to correctly match the corresponding RMS rule.

Lemma 33

1. Φ(Ω, τ, Ω′) and mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) implies Φ(Ω_{1}, τ_{1}, Ω′) and Φ(Ω_{2}, τ_{2}, Ω′).

2. Φ(Ω_{1}, τ_{1}, Ω′) and Φ(Ω_{2}, τ_{2}, Ω′) implies

there exist Ω and τ such that Φ(Ω, τ, Ω′) and mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ).

Proof:

Part 1: By induction on Φ(Ω, τ, Ω′) examining cases for mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) making use of lemma 29.

Part 2: By induction on Φ(Ω_{1}, τ_{1}, Ω′) examining cases for Φ(Ω_{2}, τ_{2}, Ω′).

□

We now prove the soundness of ⊤-flags derivations wrt to RMS derivations. This proof is complicated by the fact that formulas in a ⊤-flags context can be translated to □s and the deterministic context splits (in the ↠_{L}, ↣_{L}, •_{R}, and ∘_{R} rules) depend upon □s. Consider the rule

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})} D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{v_{2} τ} G

↠_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ+τ_{R})} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

The output context, Ω_{GI}Ω_{RO} will be translated to some context Ω′_{O}. We will then deterministically split Ω′_{O} into Ω′_{GI}Ω′_{RO} where □ ∉ Ω′_{GI} and Ω′_{RO} = □ or ·. However, if τ_{R} begins with a 1, Ω_{GI} might be longer than Ω′_{GI} since any formula in Ω_{GI} could have been translated to a □. In such a situation, we will have cut out of Ω_{GI}, in the second premise, the formulas which were consumed by the ⊤, corresponding to the opening 1 in τ_{R}, in order to construct the matching RMS rule instantiation. It turns out this is always possible to do, although the analysis is quite tedious.

We will consider four cases, two for each type of sequent depending on the value of the linear ⊤ flag.

Theorem 34 (Soundness of ⊤-flags)

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{F τ} G and Φ(Ω_{O}, τ, Ω′_{O})

implies Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω′_{O} ⟶ G.

2. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{T τ} G and Φ(Ω_{O}, τ, Ω′_{O}) and Δ_{O} ⊒ Δ′_{O} implies Γ; Δ_{I}\Δ′_{O}; Ω_{I}\Ω′_{O} ⟶ G.

3. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{F (τ_{L} ; τ_{R})} D ≫ P

and Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{RO}, τ_{R}, Ω′_{RO})

implies Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω′_{LO} ; Ω_{RI}\Ω′_{RO}) ⟶ D ≫ P.

4. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{T (τ_{L} ; τ_{R})} D ≫ P

and Δ_{O} ⊒ Δ′_{O} and Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{RO}, τ_{R}, Ω′_{RO}) implies Γ; Δ_{I}\Δ′_{O}; (Ω_{LI}\Ω′_{LO} ; Ω_{RI}\Ω′_{RO}) ⟶ D ≫ P.

Proof: By structural induction on given derivation. We give representative cases.

case: \frac{⊤_{R}}{Γ; Δ\Δ; Ω\Ω ⟶_{T 1} ⊤}

Then

Φ(Ω, 1, Ω′) and Δ ⊒ Δ′  assumptions
Ω ⊒ Ω′  Lemma 32.1
Γ; Δ\Δ′; Ω\Ω′ ⟶ ⊤  ⊤_{R}

case:

Γ; Δ_{I}\Δ_{1}; Ω_{I}\Ω_{1} ⟶_{T τ_{1}} G_{1} Γ; Δ_{I}\Δ_{2}; Ω_{I}\Ω_{2} ⟶_{T τ_{2}} G_{2}  mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) mrgL(Δ_{1}, T, Δ_{2}, T, Δ_{O}, T)
&_{R} Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{T τ} G_{1} & G_{2}

Then

Φ(Ω_{O}, τ, Ω′_{O}) and Δ_{O} ⊒ Δ′_{O}  assumption
Φ(Ω_{1}, τ_{1}, Ω′_{O}) and Φ(Ω_{2}, τ_{2}, Ω′_{O})  Lemma 33
Δ_{1} ⊒ Δ_{O} and Δ_{2} ⊒ Δ_{O}  Lemma 30

Note Δ_{1} ⊒ Δ′_{O} and Δ_{2} ⊒ Δ′_{O}

Γ; Δ_{I}\Δ′_{O}; Ω_{I}\Ω′_{O} ⟶ G_{1} and Γ; Δ_{I}\Δ′_{O}; Ω_{I}\Ω′_{O} ⟶ G_{2} ind. hyp.
Γ; Δ_{I}\Δ′_{O}; Ω_{I}\Ω′_{O} ⟶ G_{1} & G_{2}  rule &_{R}

case:

\frac{init}{Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶_{F (· ; ·)} P ≫ P}

Then

Φ(Ω_{L}, ·, Ω′_{L}) and Φ(Ω_{R}, ·, Ω′_{R})  assumptions
Ω_{L} = Ω′_{L} and Ω_{R} = Ω′_{R}  inspection of Φ
Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶ P ≫ P  init

case: Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{F (τ_{L} ; τ_{R})} D ≫ P

choice_{Ω} Γ; Δ_{I}\Δ_{O}; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶_{F τ_{L}0τ_{R}} P

Then

Φ(Ω_{LO}□Ω_{RO}, τ_{L}0τ_{R}, Ω′_{O})  assumption
#(τ_{L}) = #(Ω_{LO}) and #(τ_{R}) = #(Ω_{RO})  Lemma 31
Ω′_{O} = Ω′_{LO}Ω′_{R} and Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(□Ω_{RO}, 0τ_{R}, Ω′_{R})  Lemma 32.3
Ω′_{R} = □Ω′_{RO} and Φ(Ω_{RO}, τ_{R}, Ω′_{RO})  inversion on Φ
Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶ D ≫ P  ind. hyp.
Γ; Δ_{I}\Δ_{O}; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶ P  choice_{Ω}

case:

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶_{F (τ_{L} ; τ_{R})} D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{F τ} G

↠_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{F (τ_{L} ; ττ_{R})} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·) and τ_{R} ≠ 1τ′)

Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{GO}Ω_{RO}, ττ_{R}, Ω′_{O})  assumptions

Note τ_{R} = 0 or ·

#(τ_{R}) = #(Ω_{GI}Ω_{RO}) = #(Ω_{RO}) and #(τ) = #(Ω_{GO})  Lemma 31

Ω′_{O} = Ω′_{GO}Ω′_{RO} and Φ(Ω_{GO}, τ, Ω′_{GO}) and Φ(Ω_{RO}, τ_{R}, Ω′_{RO})

for some Ω′_{GO} and Ω′_{RO}  Lemma 32.3
Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω′_{GO} ⟶ G  ind. hyp.(1)
Φ(Ω_{GI}Ω_{RO}, τ_{R}, Ω_{GI}Ω′_{RO})  □ ∉ Ω_{GI}
Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω′_{LO} ; Ω_{RI}\Ω_{GI}Ω′_{RO}) ⟶ D ≫ P  ind. hyp.(3)
Ω′_{RO} = □ or ·  inversion on Φ
Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω′_{LO} ; Ω_{RI}\Ω′_{GO}Ω′_{RO}) ⟶ G ↠ D ≫ P  rule ↠_{L}

case:

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶_{F (τ_{L} ; 1τ_{R})} D ≫ P Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{F τ} G

↠_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{F (τ_{L} ; τ+1τ_{R})} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

Then

Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{GO}Ω_{RO}, τ + 1τ_{R}, Ω′_{O})  assumptions
#(Ω_{GO}) = #(τ) and #(Ω_{GI}Ω_{RO}) = #(Ω_{RO}) = #(1τ_{R})  lemma 31
Ω′_{O} = Ω′_{GO}Ω′_{RO} and Φ(Ω_{GO}, τ + 1, Ω′_{GO}) and Φ(Ω_{RO}, τ_{R}, Ω′_{RO})  Lemma 32.3

Let Ω_{GOL}Ω_{GIR} = Ω_{GO} where (Ω_{GOL} = □ or ·) and □ ∉ Ω_{GIR} Let τ_{GL}τ_{GR} = τ where (τ_{GL} = 0 or ·) and 0 ∉ τ_{GR}

#(Ω_{GO}) = #(Ω_{GOL}) = #(τ + 1)  □ ∉ Ω_{GIR}

Note τ_{GR} + 1 = 1 Ω′_{GO} = Ω′_{GOL}Ω′_{GIR} and Φ(Ω_{GOL}, τ_{GL}, Ω′_{GOL}) and Φ(Ω_{GIR}, 1, Ω′_{GIR})

for some Ω′_{GOL} and Ω′_{GIR}  Lemma 32.4

Let Ω′_{GIRL}Ω′_{GIRR} = Ω′_{GIR} where □ ∉ Ω′_{GIRL} and (Ω′_{GIRR} = □ or ·) Ω_{GIR} = Ω_{GIRL}Ω_{GIRR} and Φ(Ω_{GIRL}, 1, Ω′_{GIRL}) and Φ(Ω_{GIRR}, 1, Ω′_{GIRR})

for some Ω_{GIRL} and Ω_{GIRR}  Lemma 32.5
Φ(Ω_{GIRL}, τ_{GR}, Ω′_{GIRL}) and Ω_{GIRL} = Ω′_{GIRL}  □ ∉ Ω′_{GIRL}, 0 ∉ τ_{GR}

Note τ_{GL} + τ_{GR} = τ

Φ(Ω_{GOL}Ω_{GIRL}, τ, Ω′_{GOL}Ω_{GIRL})  Lemma 32.2
Ω_{GI} = Ω_{GIL}Ω_{GIRL}Ω_{GIRR} and Ω_{GIL} ⊒ Ω_{GOL} for some Ω_{GIL}  Ω_{GI} ⊒ Ω_{GO}

Note we may rewrite the second premise of the given derivation as

Γ; Δ_{M}\Δ_{O}; Ω_{GIL}Ω_{GIRL}Ω_{GIRR}\Ω_{GOL}Ω_{GIRL}Ω_{GIRR} ⟶_{F τ} G

Γ; Δ_{M}\Δ_{O}; Ω_{GIL}Ω_{GIRL}\Ω_{GOL}Ω_{GIRL} ⟶_{F τ} G  Lemma 31
Γ; Δ_{M}\Δ_{O}; Ω_{GIL}Ω_{GIRL}\Ω′_{GOL}Ω_{GIRL} ⟶ G  ind. hyp.(1)
Φ(Ω_{GIL}Ω_{GIRL}, ·, Ω_{GIL}Ω_{GIRL})  □ ∉ Ω_{GIL}Ω_{GIRL}

Note 1 + τ_{R} = 1τ_{R}

Φ(Ω_{GIL}Ω_{GIRL}Ω_{GIRR}Ω_{RO}, 1τ_{R}, Ω_{GIL}Ω_{GIRL}Ω′_{GIRR}Ω′_{RO})  Lemma 32.2
Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω′_{LO} ; Ω_{RI}\Ω_{GIL}Ω_{GIRL}Ω′_{GIRR}Ω′_{RO}) ⟶ D ≫ P  ind. hyp.(3)
Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω′_{LO} ; Ω_{RI}\Ω′_{GOL}Ω_{GIRL}Ω′_{GIRR}Ω′_{RO}) ⟶ G ↠ D ≫ P  rule ↠_{L}
□

We now prove completeness of ⊤-flags derivations wrt RMS derivations.

Theorem 35 (Completeness of ⊤-flags)

1. Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω′_{O} ⟶ G implies

there exist Δ_{O}, Ω_{O}, and τ such that Δ_{O} ⊒ Δ′_{O} and Φ(Ω_{O}, τ, Ω′_{O}) and

(Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω_{O} ⟶_{F τ} G or Γ; Δ′_{I}\Δ_{O}; Ω′_{I}\Ω_{O} ⟶_{T τ} G).

2. Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{RO}) ⟶ D ≫ P implies

there exist Δ_{O}, Ω_{LO}, Ω_{RO}, τ_{L}, and τ_{R} such that Δ_{O} ⊒ Δ′_{O} and Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{RO}, τ_{R}, Ω′_{RO}) and

(Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω_{LO} ; Ω′_{RI}\Ω_{RO}) ⟶_{F (τ_{L} ; τ_{R})} D ≫ P or

Γ; Δ′_{I}\Δ_{O}; (Ω′_{LI}\Ω_{LO} ; Ω′_{RI}\Ω_{RO}) ⟶_{T (τ_{L} ; τ_{R})} D ≫ P).

Proof: By structural induction on the given derivation. We give representative cases.

case: Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω′_{O} ⟶ G_{1} Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω′_{O} ⟶ G_{2}

&_{R}
Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω′_{O} ⟶ G_{1} & G_{2}

Γ; Δ′_{I}\Δ_{1}; Ω′_{I}\Ω_{1} ⟶_{v_{1} τ_{1}} G_{1} and Φ(Ω_{1}, τ_{1}, Ω′_{O}) and Δ_{1} ⊒ Δ′_{O}

and (if v_{1} = F then Δ_{1} = Δ′_{O})  ind. hyp.

Γ; Δ′_{I}\Δ_{2}; Ω′_{I}\Ω_{2} ⟶_{v_{2} τ_{2}} G_{2} and Φ(Ω_{2}, τ_{2}, Ω′_{O}) and Δ_{2} ⊒ Δ′_{O}

and (if v_{2} = F then Δ_{2} = Δ′_{O})  ind. hyp.

mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω_{O}, τ) and Φ(Ω_{O}, τ, Ω′_{O})

for some Ω_{O} and τ  Lemma 33
mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ_{O}, v) for some Δ_{O} and v  Lemma 30
Γ; Δ′_{I}\Δ_{O}; Ω′_{I}\Ω_{O} ⟶_{v τ} G_{1} & G_{2}  rule &_{R}
Note if v = F then Δ_{O} = Δ′_{O}  Lemma 30

case:

\frac{init}{Γ; Δ′\Δ′; (Ω′_{L}\Ω′_{L} ; Ω′_{R}\Ω′_{R}) ⟶ P ≫ P}

Then

Γ; Δ′\Δ′; (Ω′_{L}\Ω′_{L} ; Ω′_{R}\Ω′_{R}) ⟶_{F (· ; ·)} P ≫ P  init

case: Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{RO}) ⟶ D ≫ P

choice_{Ω}
Γ; Δ′_{I}\Δ′_{O}; Ω′_{LI}DΩ′_{RI}\Ω′_{LO}□Ω′_{RO} ⟶ P

Then

Γ; Δ′_{I}\Δ_{O}; (Ω′_{LI}\Ω_{LO} ; Ω′_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P

and Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{RO}, τ_{R}, Ω′_{RO}) and Δ_{O} ⊒ Δ′_{O}

and (if v = F then Δ_{O} = Δ′_{O})  ind. hyp.
Φ(Ω_{LO}□Ω_{RO}, τ_{L}0τ_{R}, Ω′_{LO}□Ω′_{RO})  Lemma 32.2
Γ; Δ′_{I}\Δ_{O}; Ω′_{LI}DΩ′_{RI}\Ω_{LO}□Ω_{RO} ⟶_{v τ_{L}0τ_{R}} P  choice_{Ω}

case:

Γ; Δ′_{I}\Δ′_{M}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{GI}Ω′_{RO}) ⟶ D ≫ P Γ; Δ′_{M}\Δ′_{O}; Ω′_{GI}\Ω′_{GO} ⟶ G ↠_{L}

Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{GO}Ω′_{RO}) ⟶ G ↠ D ≫ P

(□ ∉ Ω′_{GI} and (Ω′_{RO} = □Ω′ or ·))

Γ; Δ′_{I}\Δ_{M}; (Ω′_{LI}\Ω_{LO} ; Ω′_{RI}\Ω_{R}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P

and Φ(Ω_{LO}, τ_{L}, Ω′_{LO}) and Φ(Ω_{R}, τ_{R}, Ω′_{GI}Ω′_{RO})

and Δ_{M} ⊒ Δ′_{M} and (if v = F then Δ_{M} = Δ′_{M})  ind. hyp.

Let Ω_{GI}Ω_{RO} = Ω_{R} where □ ∉ Ω_{GI} and (∃Ω. Ω_{RO} = □Ω or ·)

Ω_{R} ⊒ Ω′_{GI}Ω′_{RO}  Lemma 32.1

Ω′_{GI}Ω′_{RO} = Ω′_{GI}Ω′_{ROL}Ω′_{ROR} and Ω_{RO} ⊒ Ω′_{ROR} and Ω_{GI} ⊒ Ω′_{GI}Ω′_{ROL}

and Ω_{GI} = Ω′_{GI}Ω_{GIR} and Ω_{GIR} ⊒ Ω′_{ROL}  properties of ⊒

Γ; Δ′_{M}\Δ_{O}; Ω′_{GI}\Ω_{GO} ⟶_{v′ τ} G and Φ(Ω_{GO}, τ, Ω′_{GO})

and Δ_{O} ⊒ Δ′_{O} and (if v′ = F then Δ_{O} = Δ′_{O})  ind. hyp.

Suppose Δ_{M} = D′ and Δ′_{M} = □

Δ_{O} = □  Δ′_{M} ⊒ Δ_{O}
Γ; Δ_{M}\D′; Ω′_{GI}\Ω_{GO} ⟶_{v′ τ} G  Lemma 31.1
Thus we can generalize the above argument to show  iterating
Γ; Δ_{M}\Δ_{O1}; Ω′_{GI}\Ω_{GO} ⟶_{v′ τ} G and Δ_{O1} ⊒ Δ_{O} for some Δ_{O1}  Lemma 31.1
Γ; Δ′_{I}\Δ_{O1}; (Ω′_{LI}\Ω_{LO} ; Ω′_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v∨v′) (τ_{L} ; τ_{R})} D ≫ P  ↠_{L}

Note if v ∨ v′ = F then Δ_{O1} = Δ′_{O}.

□

We now have a derivation system for extended uniform ordered linear logic which does not require any non-deterministic splitting of resources. The non-determinism left in this system resides in the choice of formula to focus upon, the ⊕_{R} rules, and the choice of term t in the ∀_{L} and ∃_{R} rules. All of this non-determinism can be handled in the standard ways– choosing an arbitrary order to choose clauses and try goals; and using unification to delay picking an actually term– to give us a derivation system whose direct implementation is reasonably efficient. Thus we can base a logic programming interpreter on the ⊤-flags system.

However, there are still inefficiencies in the ⊤-flags system which can greatly slow down proof search. Specifically, the techniques reported in [10] and [33] for improving linear logic proof search can be extended to ordered linear logic and incorporated into the ⊤-flags system. We will delay this extension until Chapter 11, and first discuss logic programming in ordered linear logic.

Ordered Linear Logic Programming

Before linear logic programming languages, any state associated with logic programs had to be represented as a term (typically a list) and threaded through the program in much the same manner as state must be simulated in a purely functional language^{1}. With the addition of linear hypotheses to logic programs, state could be implicitly represented by the linear context and thus moved from the term-level to the formulalevel. While this situation certainly allows for more elegant programs, it also allows for more efficient programs as compiler technology matures. For example, Hodas and Tamura [28] describe a theorem prover, originally in Prolog, which becomes both more elegant and more efficient when rewritten in Lolli. Similarly, adding ordered hypotheses to a logic programming language allows some kinds of data structures (e.g., stacks) to be moved from the term-level to the formula-level.

In this chapter, we introduce Olli, an ordered extension of Lolli, which is based on the ⊤-flags derivation system of chapter 9. After attending to the few details needed to turn the ⊤-flags system into a logic programming interpreter, we will present a series of example Olli programs.

1One could also resort to extra-logical features such as assert and retract; however, these constructs destroy the logical interpretation of a logic program, in addition to being extremely difficult to correctly use.

10.1 Olli

As mentioned at the end of chapter 9, the ⊤-flags derivation system is deterministic enough to allow a reasonable direct implementation which gives us an ordered linear logic programming interpreter. We will call the resulting ordered linear logic programming language Olli. Just as ordered linear logic is a conservative extension of intuitionistic linear logic, Olli is a conservative extension of (pure) Lolli– the formula language of Lolli is a subset of that for Olli.

In order to turn the ⊤-flag system into a logic programming interpreter, we need to deal with the two remaining sources of non-determinism in the system– the choice of a term for instantiating quantified variables; and the choices of a formula to focus on when the goal is atomic, and a sub-goal to pursue when the goal is a disjunction. We employ the standard treatment for both choices. We first alter the ∀_{L} and ∃_{R} rules to substitute new logic variables, rather than terms, and alter the ≐_{R} rule to unify the two terms rather than just check for equality. We then assume that disjunctive goals and clause formulas are tried in some arbitrary and fixed order, where backtracking allows the system to try the next choice when the current one results in failure.

At this point in time, the ideal order for trying clause formulas is not clear. The standard solution (used by λProlog and Lolli) is to try the dynamically assumed clauses in the reverse order of their assumption, and then try the static program clauses from first to last. However, this “temporal” ordering is not always optimal. For applications using the ordered context as a queue (e.g., Section 10.5), it is preferable to try the ordered formulas from right to left, even though formulas are added to the left side of the ordered context. Therefore, we have chosen, for simplicity, to try dynamic clauses from right to left starting with the ordered context, then moving to the linear context, then to the unrestricted context, and finally trying the static program clauses from first to last^{2}. Thus given the goal

D_{1} −∘ D_{2} → D_{3} ↠ D_{4} ↣ P

After assuming all the new clause formulas, the order in which the clauses will be focussed on is: D_{3}, D_{4}, D_{1}, D_{2}.

After the initial release of Lolli, more analysis of linear logic proof search yielded

2This operational semantics is actually different from that of Lolli, however there is no reason (other than simplicity) for not using a more complicated search which matches Lolli for Lolli programs and still tries the ordered context from right to left.

techniques for improving the efficiency of Lolli proof search. As it turns out, these techniques can be extended to Olli, but we delay our treatment of them until chapter 11.

We assume a typed, higher-order term language^{3} and implicit universal quantification over free variables (tokens beginning with an uppercase letter). We also write B ↞A for A↠B and B ↢A for A↣B in the manner of Prolog where backwards arrows are left-associative, and bind looser than forwards arrows and &. We use italics for meta-variables which stand for ground terms and typewriter for program code, including logic variables.

The following sections contain example logic programs which may be written in Olli. We note that all three of our system’s contexts are important for logic programming. The program clauses will typically reside in the unrestricted context since their use should be unrestricted. The linear context is used to hold information which can be accessed in any order– the final examples in this chapter show how the linear context can be put to use. The ordered context can act as a logical data structure and hold information which must be accessed in a constrained fashion.

Section 10.2 contains a simple example which we will use to illustrate Olli’s operational behavior in detail. In later sections, we assume familiarity with the operational semantics of Olli and concentrate mostly on the declarative interpretations of the example programs.

10.2 Simple Examples

We begin by considering various simple programs concerned with lists. :: is the infix list constructor and nil is the empty list.

The following program, which does not make use of the ordered fragment of the

3We will assume for the sake of simplicity that the terms are dynamically within the L_{λ} fragment [35] which makes unification deterministic.

logic (and is therefore a Lolli program), can be used to permute a list.

                       perm (X::L) K
                         ∘− (elem X −∘ perm L K).
                       perm nil (X::K)

                         ∘− elem X

                         ∘− perm nil K.
                       perm nil nil.

The program works on a query perm l K by first assuming elem x for every element x of l. This is achieved by the first clause. Then the assumptions are consumed one by one through uses of the second clause and added to the output list. The tail of the output list is instantiated to nil when there are no further linear assumptions, and the last clause can therefore succeed. Because the linear context is unordered, every possible order of linear resource consumption constitutes a valid proof where the result variable, K, becomes instantiated to a different permutation of the input list l. Thus, by interactively asking for solutions (or by explicitly failing), this program can be made to enumerate all possible permutations of a list.

If we replace the linear implications by right ordered implications, only one order remains possible: the one that reverses the list.

                       rev (X::L) K
                          ↞ (elem X ↠ rev L K).
                       rev nil (X::K)

                          ↞ elem X

                          ↞ rev nil K.
                       rev nil nil.

After assuming elem x for every element x of l, we will be in the following situation, where we have elided the unrestricted context (which only contains the program clauses), the always empty linear context, and all ⊤ flags

                  elem x_{1} . . . elem x_{n}\Ω ⟶ rev nil K

where Ω has yet to be computed. At this point we must use the second rev clause; choosing the final clause would lead to failure, even though the head matches, since the ordered hypotheses have not been consumed. Upon choosing the second clause we are in the following situation (remember the choice_{Γ} rule residuates the chosen formula)

elem x_{1} . . . elem x_{n}\Ω ⟶ (rev nil K≐ rev nil (X::K'))•(elem X∘(rev nil K'∘1))

The first part of the goal succeeds, setting K = (X::K'), without consuming any resources and leaving us in the following situation

            elem x_{1} . . . elem x_{n}\Ω ⟶ elem X ∘ (rev nil K' ∘ 1)

We now proceed to solve the first subgoal, note that output context Ω′ for the first subgoal is different than the output context Ω of the entire goal, and leave the second subgoal pending

                   elem x_{1} . . . elem x_{n}\Ω′ ⟶ elem X

At this point we must choose one of the elem x_{i} to match the elem X in the goal. Following our operational semantics, we start with the rightmost ordered hypothesis, elem x_{n}. This choice will succeed, setting X = x_{n}, and cause Ω′ = elem x_{1} … elem x_{n−1}□. Thus we know that K = x_{n}::K'.

We next restore the pending goal and arrive, via the ∘_{R} rule, at the following situation

               elem x_{1} . . . elem x_{n−1}\Ω′′ ⟶ rev nil K' ∘ 1

where we know that Ω = Ω′′□. The execution will proceed in the same manner, at each step consuming the rightmost ordered hypothesis, until the input ordered context is empty at which point, using the third program clause, the computation will end with K = x_{n}:: …::x_{1}::nil. Note that the goal 1 is always immediately successful and thus we may ignore all such subgoals which build up over the course of an execution.

When introducing this example, we mentioned that only one solution existed for a given input list. Not choosing the rightmost ordered hypothesis, when solving goals of the form elem X, always results in some ordered hypotheses (those to the right of the chosen hypothesis) not being consumed and thus a failed proof attempt. We delay a detailed explanation and analysis of this behavior until Chapter 11 where we improve the failure mechanism for our proof search.

Note that changing the outer ↠ in the second clause will only result in changing the ∘ in the compiled version to a •. Furthermore, this change does not affect provability since 1 is the unit for both conjunctions. In general the outermost ordered arrow of an unrestricted (or linear) program clause may be either ↠ or ↣ without affecting the semantics of a program.

We could also “uncurry” this example in the following way

                       rev (X::L) K
                          ↞ (elem X ↠ rev L K).
                       rev nil (X::K)
                          ↞ elem X ∘ rev nil K.
                       rev nil nil.

and maintain the exact same operational behavior. This is evident from the residuation of the second clause (supposing a goal of the form rev nil K')

        (rev nil K'≐ rev nil (X::K)) • ((elem X ∘ rev nil K') ∘ 1)

which is equivalent to the residuation of the “curried” form shown earlier. We could also change the second clause to

                        rev nil (X::K)
                          ↞ rev nil K • elem X.

and maintain the same declarative meaning as the previous versions, i.e., this version will admit the same solutions as the other versions. However, the operational behaviour will now be quite different. In particular, the “recursive” subgoal of this clause, rev nil K, will be solved first. This will create a stack of pending goals of he form elem X each of which will need to consume the leftmost ordered hypothesis for the entire proof to succeed. Thus, due to the need to try ordered hypotheses from right to left, each of the pending goals, elem X will have to try all of the ordered hypotheses, and fail for each choice but the last, before succeeding.

We point out one further permutation. If we replace the nested ↠ in the first program clause with ↣, the program will add elements to the left of the ordered context. Then, since the rest of the program is unchanged and requires consuming ordered hypotheses from right to left, this modified program represents the identity relation.

                        id (X::L) K
                          ↞ (elem X ↣ id L K).
                        id nil (X::K)

                          ↞ elem X

                          ↞ id nil K.
                        id nil nil.

10.3 Translating to deBruijn Notation

Our first serious example is a translation between lambda terms and deBruijn style terms. More details on this presentation of deBruijn terms and their connection to regular terms can be found in [47]. We use the following grammars for regular terms and deBruijn terms:

Lambda Terms e ::= x | e_{1} e_{2} | λx. e
deBruijn Terms e′ ::= 1 | e′ ↑ | e′_{1} e′_{2} | Λe′

Given a lambda term, we can construct a deBruijn term by recursively descending through the given term’s structure and maintaining a stack of lambda-bound variables. Upon reaching a variable, its depth in the stack corresponds to the index in a deBruijn term.

We can translate deBruijn terms to regular lambda terms with the following judgement:

K ⊢ e ↔ e′

where K is a list of regular variables, i.e., K = x_{1} … x_{n}.

Here are the derivation rules for the translation:

\begin{aligned}K ⊢ e_{1} ↔ e′_{1} K ⊢ e_{2} ↔ e′_{2} \\ & tr app \\ K ⊢ e_{1} e_{2} ↔ e′_{1} e′_{2} \end{aligned}  \begin{matrix}K x ⊢ e ↔ e′ \\ tr lam & x \\ K ⊢ λx. e ↔ Λ e′ \end{matrix}
\frac{tr 1}{K x ⊢ x ↔ 1}  \begin{aligned}K ⊢ e ↔ e′ \\ & tr ↑ \\ K x ⊢ e ↔ e′ ↑ \end{aligned}

where x does not occur free in the conclusion of the tr lam^{x} rule. Note that the context, K, is a stack; and that the translation is non-deterministic, e.g., λx. λy. y (x x) can be translated to both ΛΛ1 ((1 ↑) (1 ↑)) and ΛΛ1 ((1 1) ↑).

We can directly transcribe the previous derivation rules to an Olli program which uses the ordered context as a stack.

We assume the following term constants (where exp and exp' are arbitrary base types for terms):

    lam : (exp -> exp) -> exp.
    app : exp -> exp -> exp.

                                     lam' : exp' -> exp'.
                                     app' : exp' -> exp' -> exp'.
                                    shift : exp' -> exp'.
                                      one : exp'.

lam, and app represent regular lambda terms (variables will be implicitly represented by meta-variables); while lam', app', shift, and one represent deBruijn terms.

We use the following predicates:

             tr :  exp -> exp' -> o.    var :  exp -> o.

where tr is the translation program and var is a helper predicate to store named variables in the ordered context. We follow the λ-Prolog convention and use o to stand for the type of propositions. tr e E' expects a lambda term, e, and computes an equivalent deBruijn style term, E'.

We can now transcribe each rule as a program clause. We will use the following general scheme to encode the translation judgements as ordered linear logic sequents:

x_{1} … x_{n} ⊢ e ↔ e′ ⇝ Γ; ·; var x_{1} … var x_{n} ⟹ tr ⌜e⌝ ⌜e′⌝

where the unrestricted context Γ contains the translation program (which we develop below). ⌜e⌝ is the obvious representation of regular term e using the constructors for exp and ⌜e′⌝ is the representation of deBruijn term e′ using the constructors for exp'. We will delay a formal presentation of the correctness of this encoding, and the ensuing representation of the derivation rules, until the end of Chapter 15 where we reformulate this example in an ordered logical framework.

We start with the tr app rule. To translate app E1 E2, we simply translate both subterms using the current stack. Thus, eliding the unrestriced and linear contexts, we need to reduce proving

           var x_{1} . . . var x_{n} ⟹ tr (app E1 E2) (app' E1' E2')

to proving

                     var x_{1} . . . var x_{n} ⟹ tr E1 E1'

and

                     var x_{1} . . . var x_{n} ⟹ tr E2 E2'

where we have omitted the unrestricted and linear contexts. The x_{i} are term-level variables already encountered during the translation. This is achieved with the following clause:

                    tr (app E1 E2) (app' E1' E2')
                       ↞ tr E1 E1' & tr E2 E2'.

Notice the & gives a copy of the stack (the ordered context) to each subterm translation. Here is the compiled version of the clause which will actually be used:

(tr (app e_{1} e_{2}) E'≐ tr (app E1 E2) (app' E1' E2'))•((tr E1 E1'&tr E2 E2')∘1)

where tr (app e_{1} e_{2}) E' is the goal at the time the clause is chosen.

We next consider the tr lam rule. To translate a lam E, we add a variable to the stack and translate the body of the lambda. Thus we must reduce solving

               var x_{1} . . . var x_{n} ⟹ tr (lam E) (lam' E')

to

                var x_{1} . . . (var x_{n}) (var x) ⟹ tr (E x) E'

This is accomplished by the following clause:

                    tr (lam E) (lam' E')
                       ↞ (∀x. var x ↠ tr (E x) E').

The inner ↠ forces the variable to be added to the top of the stack (the right side of the ordered context^{4}). Here is the compiled version of the clause:

  (tr (lam e) E'≐ tr (lam E) (lam' E')) • (∀x. var x ↠ tr (E x) E') ∘ 1)

To translate a variable, which e must be if it is not an application or lambda, we search through the stack, keeping track of how far we’ve gone, until we find the variable. If the target variable is at the top of the stack (the rightmost var in the context), which corresponds to the tr 1 rule, we have the following situation:

                 var x_{1} . . . (var x_{n}) (var x) ⟹ tr x one

4This is an arbitrary choice. We could rewrite the whole program to use the left side of the context as the top. However this would require changing the program clauses that read variables off the stack.

where we are done and can throw away the rest of the stack. This is accomplished by:

                              tr E one ; ↞ var E ; ↞ ⊤.

For this clause to be successfully used, the var E must come from the top of the stack (the right of the ordered context) since the ⊤ can only consume data to the left of var E. This situation is identical to that of the rev program in Section 10.2. For reference we show the compiled version of this clause:

                 (tr x one≐ tr E one) • (var E ∘ (⊤ ∘ 1))

We could alternatively write the previous program clause as:

                             tr E one ; ↢ ⊤ ; ↢ var E.

Using this alternate formulation does not change the declarative meaning of the program; furthermore, it does not really change the operational semantics in any essential way. Consider the compiled version of the clause:

                 (tr x one≐ tr E one) • (⊤ • (var E • 1))

Upon using this clause, after the unifying E and x, we arrive at the following situation:

var x_{1} … var x_{n}\Ω ⟶_{τ v} ⊤ • (var x • 1)

We first solve the subgoal ⊤, which always succeeds. Operationally ⊤ simply passes its input context to output, and sets the ⊤-flags. We will then be in the following situation:

var x_{1} … var x_{n}\Ω ⟶_{v′ τ′} var x • 1

where v′ and τ′ have yet to be computed. At this point, the proof search proceeds in the same manner as before, with the rightmost ordered hypothesis always being successfully chosen. Furthermore, it is still the case that only the rightmost resource can be successfully used. After the preceding sequent is solved, we know τ = 1τ′ as mandated by the •_{R} rule. Thus the ⊤ can only consume formulas occurring to the left of all □ in Ω.

Finally, if the target variable is not at the top of the stack, we must reduce

              var x_{1}, . . . , var x_{n}, var x ⟹ tr y (shift E')

to

var x_{1}, …, var x_{n} ⟹ tr y E'

which corresponds to the tr ↑ rule. We accomplish this by the following clause:

                           tr E (shift E')

                             ↞ var F

                             ↞ tr E E'.

Finally, we note that the deBruijn translation program can also be used to translate the other direction, from deBruijn terms to regular terms, by using a query of the form tr E e′ where e′ is a deBruijn term.

10.4 Mini-ML Abstract Machine

Our next example shows how a continuation-based abstract machine for evaluating Mini-ML can be directly encoded in Olli. The basic idea is to use the ordered context as a stack of continuations to be evaluated. We assume a standard version of Mini-ML constructed using higher-order abstract syntax [47]. Values are distinguished from terms by an asterisk; so z is a term while z^{∗} is a value.

Expressions e ::= z | s e | lam x. e | e_{1} e_{2} |
(case e_{1} of z ⇒ e_{2}| s x ⇒ e_{3}) | v
Values v ::= z^{∗} | s^{∗} v | lam^{∗}x. e | x

We define the continuation machine as follows:

Instructions  i ::= e | return v |

(case_{1} v_{1} of z ⇒ e_{2}| s x ⇒ e_{3}) | app_{1}v_{1}e_{2} | app_{2}v_{1}v_{2}

Continuations K ::= init | K; λx. i
Machine States  s ::= K ⋄ i | answer v

We use the following transition rules for machine states:

st init :: init ⋄ return v ↪ answer v
st return :: K; λx. i ⋄ return v ↪ K ⋄ i[v/x]
st vl :: K ⋄ v ↪ K ⋄ return v
st z :: K ⋄ z ↪ K ⋄ return z^{∗}
st s :: K ⋄ s e ↪ K; λx. return(s^{∗} x) ⋄ e
st case :: K ⋄ case e_{1} of z ⇒ e_{2}| s x ⇒ e_{3} ↪
K; λx_{1}. case_{1} x_{1} of z ⇒ e_{2}| s x ⇒ e_{3} ⋄ e_{1}
st case1 z :: K ⋄ case1 z^{∗} of z ⇒ e_{2}| s x ⇒ e_{3} ↪ K ⋄ e_{2}
st case1 s :: K ⋄ case1 (s^{∗} v) of z ⇒ e_{2}| s x ⇒ e_{3} ↪ K ⋄ e_{3}[v/x]
st lam :: K ⋄ lam x. e ↪ K ⋄ return (lam^{∗}x. e)
st app :: K ⋄ e_{1} e_{2} ↪ K; λx_{1}. app_{1} x_{1} e_{2} ⋄ e_{1}
st app1 :: K ⋄ app_{1} v_{1} e_{2} ↪ K; λx_{2}. app_{2} v_{1} x_{2} ⋄ e_{2}
st app2 :: K ⋄ app_{2} (lam^{∗}x. e) v_{2} ↪ K ⋄ e[v_{2}/x]

We now show how the continuation machine can be written as an Olli program. Rather than building an explicit stack-like structure to represent the continuation K, we will simply store instructions in the ordered context. Thus we will use the following representation to encode the machine:

K ⋄ i ⇝ ⌜K⌝ ⟹ ⌜i⌝

where ⌜K⌝ is the representation, described below, of the continuation (stack) K and similarly for ⌜i⌝.

We use the following signature to encode the abstract machine as an Olli program:

z  : exp.
s  : exp → exp.
case : exp → exp → (val → exp) → exp.
lam  : (val → exp) → exp.
app  : exp → exp → exp.
vl  : exp → val.
z^{∗}  : val.
s^{∗}  : val → val.
lam^{∗} : (val → exp) → val.
eval : exp → val → o.
ev  : exp → o.
return : val → o.
case1 : val → exp → (val → exp) → o.
appm1 : val → exp → o.
appm2 : val → val → o.

Given the goal: return V ↠ ev e, our program will evaluate the expression e and instantiate V with the resulting value. The intended reading of this query is: evaluate e with the identity continuation (the continuation which just returns its value). A goal of ev e is intended to mean: evaluate e. A goal of return V is intended to mean: pass V to the top continuation on the stack (i.e. the rightmost element in the ordered context).

We could use term-level lambdas to represent abstractions over instructions, λx. i, and explicitly encode the substitutions in the transition rules (in st return, st case1 s, and st app2) as applications. However, we will instead make use of the left implication, ↣, and let unification implicitly achieve the required substitutions. To do this, we will represent λx. i as ∀V.return V ↢ ⌜i⌝ where ⌜i⌝ is the representation of the instruction i. Thus the continuation (stack) built by an evaluation of (s (s z))

init; λx. return (s^{∗} x); λx. return (s^{∗} x)

is represented as the ordered context

(return V) (∀V. return V↢ return (s^{∗} V)) (∀V. return V↢ return (s^{∗} V))

We will then use subgoals of the form return v to explicitly pass a value to the top continuation on the stack. With this encoding, we will not need to explcitly represent the st init and st return transition rules. We have the following representations:

init ⋄ return v ⇝ return V ⟹ return v

where the logic variable V is the final answer;

K; λx. i ⋄ return v ⇝ ⌜K⌝ (∀V. return V ↢ ⌜i⌝) ⟹ return v

where the ordering constraints force the proof of return v to focus on the rightmost ordered formula.

We now show the clauses of the program. We begin with a wrapper to put queries into the correct form:

           eval E V
             ↞ (return V ↠ ev E).

The rest of the program clauses directly mirror the machine transition rules:

ev (vl V)
  ↞ return V.
ev z
  ↞ return z^{∗}.
ev (s E)
  ↞ ((∀V. return V ↢ return (s^{∗} V)) ↠ ev E).
ev (case E1 E2 E3)
  ↞ ((∀V. return V ↢ case1 V E2 E3) ↠ ev E1).

case1 z^{∗} E2 E3

  ↞ ev E2.

case1 (s^{∗} V) E2 E3

  ↞ ev (E3 V).
ev (lam E)
   ↞ return (lam^{∗} E).
ev (app E1 E2)
   ↞ ((∀V1. return V1 ↢ app1 V1 E2) ↠ ev E1).
app1 V1 E2
   ↞ (∀V2. return V2 ↢ app2 V1 V2) ↠ ev E2).

app2 (lam^{∗} E1') V2

   ↞ ev (E1' V2).

The intended reading of the ev (s E) clause (the second program clause) is this: to evaluate (s E) evaluate E under the continuation which takes its value, V, and passes the value s^{∗} V to the next continuation on the stack. Note the use of ↣ nested inside ↠. This forces the continuations put into the ordered context to be evaluated in stack fashion. When the goal is return V the only choice of formula to focus on will be the rightmost formula in the ordered context.

To better illustrate this point, consider the evaluation of (s (s z)). The initial goal will be return V ↠ ev (s (s z)) after which return V will be immediately added to the previously empty ordered context. Next the ev (s E) clause will be chosen to focus on and will result in ∀V. return V ↢ return (s^{∗} V) being added to the right end (because of ↠) of the ordered context. The new goal will be ev (s z) and the previous step will be repeated. At this point, the goal will be ev z which will cause the appropriate progam clause (the second in the preceding program listing) to be focused on and give rise to a new goal of return z^{∗}.

The ordered context now consists of:

 (return V) (∀V. return V ↢ return (s^{∗} V)) (∀V. return V ↢ return (s^{∗} V)).

Since there is no program clause whose head matches the goal, one of the clauses in the ordered context must be focused on. Although all the ordered clauses match the goal, only the rightmost one can be successfully chosen. The leftmost clause obviously cannot work since it is atomic and the other clauses are also in the ordered context. The middle clause also does not work because the ↣ requires that the body of the clause be solved with resources to the left of the clause which would prevent the rightmost clause from being consumed.

10.5 Mergesort

Our next example, a merge sort, shows how the ordered context can be used as a queue. The merge sort algorithm takes an input list, breaks it up into singleton lists and merges pairs of adjacent lists into larger sorted lists. This process repeats until one sorted list is left. The algorithm can be implemented with a queue. After the initial setup– enqueing the singleton lists– we can repeatedly dequeue two lists and enqueue their merge until only one list is in the queue.

We use the following predicates:

                 mergeSort : list int → list int → o.
                 msort  : list int → o.
                 srt  : list int → o.

where mergeSort is the main program, whose first argument is the input list and whose second argument is the output; msort is a helper predicate which does the actual work; and srt is a wrapper which allows lists to be stored in the ordered context (the queue).

The computation proceeds in two phases. Assuming an input list x_{1}:: ⋯::x_{n}::nil we want to reduce solving

                  · ⟹ mergeSort (x_{1}:: · · ·::x_{n}::nil) L

to solving

                srt(x_{1} ::nil) . . . srt(x_{n} ::nil) ⟹ msort L

We achieve this with the two clauses

                  mergeSort (H::T) L
                    ↞ (srt (H::nil) ↠ mergeSort T L).
                  mergeSort nil L ↞ msort L.

In the first clause, the embedded ↠ causes the new srt hypothesis to be added to the right of all the other ordered hypotheses (the top of our queue).

In the second phase we assume a general situation of the form

(srt l_{n}) … (srt l_{2})(srt l_{1}) ⟹ msort L

where the l_{i} are already sorted and L is still to be computed. Starting from the right, we merge l_{1} and l_{2} and add the result to the left end of the ordered context, in effect using it as a work queue. The resulting situation will be

(srt l_{12})(srt l_{n}) … (srt l_{4})(srt l_{3}) ⟹ msort L

which is then treated the same way, merging l_{3} and l_{4}. We finish when there is only one element srt k in the ordered context and unify L with k. This is expressed by the following two clauses.

                       msort L

                         ↞ srt L1
                         ↞ srt L2
                         ← merge L1 L2 L12

                         ↞ (srt L12 ↣ msort L).
                       msort L ↞ srt L.

In the first clause, similar to the previous example, the three ↞ require that the two srt hypotheses be taken from the right of the ordered clauses used to solve the rest of the body. The unrestricted implication, ←, is used for the call to merge since the merge operation does not make use of the ordered (or linear) context. The embedded ↣ causes the new srt clause to be inserted at the left end of the ordered consequences available to the recursive computation of msort. Since all ordered assumptions must be used, the final clause above can succeed only if the complete list has indeed been sorted, that is, there is only one ordered hypothesis srt l.

The standard Prolog-style merge predicate which, given two sorted lists l_{1} and l_{2}, returns a sorted merge l_{12} is as follows

                   merge (H1::T1) (H2::T2) (H2::T3)

                     ← H1 > H2
                     ← merge (H1::T1) T2 T3.

                   merge (H1::T1) (H2::T2) (H1::T3)

                     ← H1 =< H2
                     ← merge T1 (H2::T2) T3.

                   merge L nil L.
                   merge nil L L.

If we change the first msort clause to assume L12 on the right, by writing (srt L12↠ msort L) instead of (srt L12 ↣ msort L), then we obtain an insertion sort because after one step we arrive at

(srt l_{n}) … (srt l_{3})(srt l_{12})

which will next merge l_{3} into l_{12}, etc.

10.6 Breadth-First Tree Numbering

Our next example also employs the ordered context as a queue. We show a program for computing the breadth-first numbering of a given tree. Given a tree as input, this program will compute a tree with the same structure whose nodes are labeled with integers corresponding to their order in a breadth-first traversal. This example directly encodes the algorithm proposed by Okasaki in [41].

The program essentially executes a breadth-first traversal of the given tree by using the ordered context as a work queue. The right end of the context will be the top of the queue; thus we will always use ↣ to enqueue data. The root of the tree at the top of the work queue is always the next node to visit in the traversal. Thus, upon dequeing a tree, we enqueue its children and continue on. We build up the answer tree while “traversing” the input tree. This aspect of the computation requires the use of a double queue in the (eager) functional setting. However, we may entirely sidestep this issue with Olli by using logic variables to implicitly reconstruct our answer tree.

We assume the following tree constructors

         node : α → tree α → tree α → tree α. empty : tree α.

for a parameterized type tree.

We make use of the following predicates in our program:

                  nd  : (tree α) → (tree int) → o.
                  bf num : (tree α) → (tree int) → o.
                  bf  : int → o.

where int is the type of Peano numbers with the usual constructors z and s. nd stores an input (sub)tree and the equivalent breadth-first numbered (sub)tree. bf num is our main predicate and bf is a helper predicate which simply cycles through the work queue implicitly represented by the ordered context.

We begin by enqueuing the whole tree and setting the counter to 0.

                        bf num T T'
                           ↞ (nd T T' ↣ bf z).

We will now be in the following (generalized) situation:

(nd t_{1} T1) … (nd t_{m} Tn) ⟹ bf n

If the queue is empty, we are done.

                                bf N.

No further computation is required since unification will have already reconstructed the complete answer tree. Note that this clause will only succeed if the ordered context is empty.

If there is an empty tree at the top of the queue

                  (nd t_{1} T1) . . . (nd empty T') ⟹ bf n

then we just ignore it since there are no leaves to include in the breadth-first numbering.

                         bf N

                            ↞ nd empty empty

                            ↞ bf N.

Note that this clause, like similar clauses in the previous examples, can only succeed when the first subgoal matches the rightmost ordered clause.

If there is a non-empty tree at the top of the queue

               (nd t_{1} T1) . . . (nd (node v t_{l} t_{r}) T') ⟹ bf n

mark the answer subtree’s root node with the current node number (accomplished by unification), enqueue the two children and continue on with the current node number incremented.

                 bf N

                    ↞ nd (node   L R) (node N L' R')

                    ↞ (nd L L' ↣ nd R R' ↣ bf (s N)).

Note that the two children must be enqueued in the order written above to achieve the correct ordering

              (nd t_{r} R')(nd t_{l} L')(nd t_{1} T1) . . . ⟹ bf (s n)

10.7 Breadth-First Search Graph Numbering

Our next example continues the theme of breadth-first search. However, we will now show a more involved program which computes the shortest distance from a given start node to every other node in a graph (assuming equal length edges). This example will make use of all three contexts.

This program will be given a graph^{5} and a start node as input. It will return a list of distances from the start node to each other graph node. The computation proceeds by executing a breadth-first traversal of the graph during which each node is marked with the its distance from the start node. The shortest distance is guaranteed since the traversal is breadth-first.

This program will assume graphs are lists of nodes with their associated edge lists. We make the following type definition:

                    graph α ≡ (list (α × (list α)))

Thus we have the following representation:

[figure: d; e; b; c; a; ≡; [ <a,[b,c]>, <b,[d]>, <c,[e]>, <d,[]>, <e,[d]> ]] and the result of running our program on this graph with a given as the start node would be:

                [ <a,0>, <b,1>, <c,1>, <d,2>, <e,2> ]

We will use the following predicates for our program (where opt is the standard parametrized option type):

          bfs main : (graph α) → α → (list (α × (optint))) → o.
          bfs  : (graph α) → α → o.
          bfs'  : α → int → o.
          bfs'' : (list α) → int → o.
             finish : (graph α) → (list (α × (optint))) → o.
             nodes : (graph α) → (list (α × (optint))) → o.

node : (α × (list α)) → o.

             used : (α × int) → o.
             next : (α × int) → o.

5We assume that each node is uniquely labelled in the graph.

where the arguments to bfs main are the input graph, start node and result list respectively; bfs, bfs' and bfs'' are helper predicates; finish is a predicate to package up the results of the computation into the output list; and the final four predicates allow various terms to be stored in the various contexts.

The program begins by placing a copy of the entire input graph into the context for later use. We will need this at the end of the computation to gracefully deal with disconnected graphs.

                      bfs main G S R
                        ← (nodes G R → bfs G S).

After storing away a copy of the input graph, we begin by placing each node of the graph, with its edge list, into the linear context. When done placing the entire graph into the linear context, we call bfs' to begin the traversal at the specified start node, S, with current distance 0.

                       bfs (N::G) S
                         ∘− (node N −∘ bfs G S).
                       bfs nil S
                         ∘− bfs' S z.

We are now ready to begin the breadth-first traversal, each step of which is broken into two stages. In the first stage, we will be in the following situation:

Γ(nodes g R) ; Δ ; (next <v_{1}, d_{1}>) … (next <v_{n}, d_{n}>) ⟹ bfs' v d

where Γ contains the program clauses, g is the original input graph, Δ contains either node <v_{i}, e_{i}> or used <v_{i}, d′_{i}> for each node label v_{i} in g, and v = v_{i} for some i.

First we take the node we are going to start with, v, out of the linear context. We then mark v as used, also recording the current distance, and pass v’s edge list to the second stage of the search process. If v was already encountered earlier in the search, we continue to the second stage without passing it’s edge list.

                   bfs' V D

                     ∘− node <V,E>

                     ↞ (used <V,D> −∘ bfs'' E D).
                   bfs' V D

                     ∘− used <V,D'>

                     ↞ (used <V,D'> −∘ bfs'' nil D).

At the beginning of the second stage, we will be in the following situation:

Γ(nodes g R) ; Δ ; (next <v_{1}, d_{1}>) … (next <v_{n}, d_{n}>) ⟹ bfs'' e d

We now add new edges to the work queue and then pick a node off the top of the queue to continue the search from (return to the first stage with). If there are no nodes left in the queue, the computation is finished and we just need to package up the results. We accomplish this by passing our copy of the input graph and the final result list to finish.

                    bfs'' (V::Vs) D
                      ↞ (next <V,D> ↣ bfs'' Vs D).
                    bfs'' nil D

                      ↞ next <V,D'>

                      ↞ bfs' V (s D').
                    bfs'' nil D

                      ← nodes G R

                      ∘− finish G R.

Once the computation is finished, the ordered context will be empty and the linear context will contain each node’s distance from start node (if the node was reachable).

                   Γ(nodes g R) ; Δ ; · ⟹ finish g R

The program finishes by placing all of the graph nodes and their distances into the output list. Unreachable nodes, left in the context from the initialization process, will be marked with none.

                  finish nil nil.
                  finish (<V,E>::G) (<V,some D>::R)

                     ∘− used <V,D>

                     ∘− finish G R.
                  finish (<V,E>::G) (<V,none>::R)

                     ∘− node <V,E>

                     ∘− finish G R.

10.8 Parsing

The following example is a fragment of a parsing program from [50]. This example shows how Olli can be used to directly parse grammatical constructions with unbounded dependencies such as relative clauses.

                     1 : snt ↞ vp ↞ np.
                     2 : vp ↞ np ↞ tv.
                     3 : rel ↢ whom ↞ (np −∘ snt).
                     4 : np ↞ jill.
                     5 : tv ↞ married.

We may intuitively read the formulas in the following manner: snt ↞ vp ↞ np states that a sentence is a verb phrase to the right of a noun phrase. We can use these formulas to parse a phrase by putting each word of the sentence into the ordered context and trying to derive the atomic formula corresponding to the phrase type. This method of parsing was used by Lambek in his paper introducing the Lambek calculus [32].

We may interpret clause 3 as: a relative clause is whom to the left of a sentence missing a noun phrase. As explained in [26] this is a standard interpretation of relative clauses. By putting a np into the linear context, the sentence after whom will only be successfully parsed if it is indeed missing a noun phrase.

We now show a trace of the above formulas parsing a relative clause, showing at each step the resource sequent (including the current goal), the pending goals, and the the rule applied. The unrestricted context containing the above program is left implicit.

Action  Active hypotheses and goal  Goals pending

                          ·; whom jill married ⟶ rel none
  reduce by 3  ·; whom jill married ⟶ whom  np −∘ snt

solved, restore pending goal ·; jill married ⟶ np −∘ snt none

  assume  np ; jill married ⟶ snt  none
  reduce by 1  np ; jill married ⟶ vp       np
  reduce by 2  np ; jill married ⟶ np       tv , np

solved, restore pending goal ·; jill married ⟶ tv         np

  reduce by 5  ·; jill married ⟶ married    np

solved, restore pending goal ·; jill ⟶ np  none
reduce by 4 ·; jill ⟶ jill none

solved

Using the linear context in manner described above has some limitations which should be pointed out. The correct parsing of dependent clauses typically constrains where the relative pronoun may fill in for a missing noun phrase. Most relative clauses, rather than being sentences missing noun phrases are really sentences whose verb phrase is missing a noun phrase.

If we changed the relative clause to be whom married jill we would not have a grammatically correct relative noun. However the parser given above will be able to parse the modified phrase since the location of the missing noun phrase is not constrained. There are a variety of simple ways to fix this problem for the small parser given above. For instance, we could define a new type of sentence in which the verb phrase is missing a noun phrase. This basically amounts to using gap-locator rules as described in [42] [26].

The parsers given in [26], which logically handle some constraints on the placement of dependencies, are constructed quite differently from the Olli parser we have presented. Rather than placing the input to be parsed into the context, they pass it around as a list. They do however use the linear context to store fillers— empty noun phrase predicates which can be used when an actual noun phrase is missing in the sentence— in the same manner as the above parser does. We point out that all of the (pure) Lolli parsers are also valid Olli programs since (pure) Lolli is a subset of Olli.

In fact with this threaded style of parser, Olli is able to correctly handle at least one natural language phenomenom which could not be done in pure Lolli. When a relative clause occurs inside a relative clause, correct parses of the sentence should associate the inner relative pronoun with the first missing noun phrase in the clause and the second with the second. In other words, dependencies should not cross inside a nested relative clause. Consider the phrase: the book that the man whom Jane likes GAP wrote GAP where GAP denotes a missing noun phrase. The first GAP should correspond to the man and not to the book.

Since the Lolli parser (as well as the Olli parser given above) introduces fillers into the linear context, there is no way to force the parser to use one or the other of two suitable fillers. Thus the Lolli parser would parse the preceding sentence in two ways, only one of which would be correct. Hodas’ solution was to rely on a non-logical control construct and the operational semantics of Lolli to prevent the bad parse. One can easily see (as Hodas remarked) that such a situation can be directly handled in Olli by putting the fillers into the ordered context.

Eager Failure

While the ⊤-flags derivation system of chapter 9 provides a reasonably efficient proof search procedure for Olli, it does not take full advantage of the ordering constraints to fail as soon as possible. Since the Olli’s operational semantics specify a depth first search, it is advantageous to fail as early as possible in order to minimize program execution time. A ⊤-flags derivation can only fail when an atom does not match the head of the focus formula in the init rule, or when an ordered, or linear, hypothesis is not consumed. This second condition is only tested after the output context of the ↠_{R}, ↣_{R}, and −∘_{R} rules are computed. However, by adding a little bit of information to the sequents, it is possible to eagerly detect such a failure much earlier during proof search.

In [10], Cervesato et al. introduced RM3, a derivation system for Lolli which better utilized the linearity constraints and failed earlier than previous systems. Lopez and Pimentel then refined this approach in [33], taking advantage of the operational semantics of derivation search, and produced an equivalent system, the frame system, better suited to implementation than RM3. In this chapter, we extend Lopez and Pimentel’s approach to OLL and produce a derivation system which fails much sooner than the ⊤-flags system.

11.1 Failing Earlier in Linear Logic

In order to fail earlier, we keep track of which parts of the linear context must be consumed and which parts need not be consumed in a derivation. Then, at the end of a derivation branch (in the init rule), we require that the whole linear context need not be consumed. For this reason we will call our new derivation system strict– we do not allow hypotheses into output contexts if we know they will never be consumed. We determine a formula will never be consumed if there is no possibility of it being passed into a future derivation branch (assuming bottom-up, left-to-right derivation construction).

Consider the following example of a failed derivation (for a purely linear system):

\frac{init}{P_{1}P_{2}\P_{1}P_{2} ⟶ P ≫ P}

\frac{init}{P_{2}\P_{2} ⟶ P_{1} ≫ P_{1}}

choice_{Δ}

P_{1}P_{2}\□P_{2} ⟶ P_{1} −∘_{L}

P_{1}P_{2}\□P_{2} ⟶ P_{1} −∘ P ≫ P

choice_{Δ}

P_{1}P_{2}(P_{1} −∘ P)\□P_{2}□ ⟶ P −∘_{R}

P_{1}P_{2}\□P_{2} ⟶ (P_{1} −∘ P) −∘ P −∘_{R}

P_{1}\failure ⟶ P_{2} −∘ (P_{1} −∘ P) −∘ P −∘_{R}

· \− ⟶ P_{1} −∘ P_{2} −∘ (P_{1} −∘ P) −∘ P

This derivation fails because of the unused hypothesis P_{2}. As written, the failure is not detected until the output of the −∘_{R} rule is checked. However, it is possible to tell that the derivation must fail at the P_{2}\P_{2} ⟶ P_{1} ≫ P_{1} sequent, the rightmost leaf of the tree. At that point, all the proof branches have been completed, yet there is still an unused hypothesis. Therefore the proof must fail since this hypothesis will never be consumed.

To fail earlier, we must simply collect enough information to let the init rules determine whether there are any pending branches in the search tree into which the ordered and linear hypotheses will be passed. The RM3 system achieves this by maintaining separate contexts to distinguish hypotheses which will get passed on from those which will not. The frame system achieves the same end without separate contexts by taking advantage of the fact that hypotheses are always added to the right side of the linear context. Thus the linear context forms a stack-like structure where the top stack frame contains the strict formulas, i.e., the ones which will not be passed on.

Rather than forming explicit stacks, one may achieve the same result as the frame system by allowing a special symbol in the context which essentially starts a new stack frame. We will use the symbol ◁ and call it a frame pointer. A strict derivation system^{1}, for linear logic, using frame pointers can be characterized by the following inference rules:

\overline{δ(·)}  \overline{δ(Δ◁)}  \frac{δ(Δ)}{δ(Δ□)}
δ(Δ)

init Δ\Δ ⟶ P ≫ P

Δ_{I} ◁ \Δ_{M}◁ ⟶ D ≫ P Δ_{M}\Δ_{O} ⟶ G −∘_{L}

Δ_{I}\Δ_{O} ⟶ G −∘ D ≫ P

Δ_{I}\Δ_{O} ⟶ D ≫ P ·\· ⟶ G →_{L}

Δ_{I}\Δ_{O} ⟶ G −∘ D ≫ P

where all the other inference rules are unchanged. The check in the init rule causes eager failures. The new frame pointer is added in the −∘_{L} rule because all linear hypotheses in the output of the first premise will be passed into the second premise. However, in the →_{L} rule we do not add a frame pointer because no linear hypotheses will be passed into the second premise.

We rewrite the previous example, using frame pointers as follows:

\overline{δ(P_{1}P_{2}◁)} ; init ; P_{1}P_{2} ◁ \P_{1}P_{2}◁ ⟶ P ≫ P

failure

P_{1}P_{2}\− ⟶ P_{1} −∘_{L}

P_{1}P_{2}(P_{1} −∘ P)\− ⟶ P −∘_{R}

P_{1}P_{2}\− ⟶ (P_{1} −∘ P) −∘ P −∘_{R}

P_{1}\− ⟶ P_{2} −∘ (P_{1} −∘ P) −∘ P −∘_{R}

where the proof search fails in the init rule since δ(P_{2}) does not hold.

init P_{2}\− ⟶ P_{1} ≫ P_{1}

choice_{Δ} P_{1}P_{2}\− ⟶ P_{1} −∘ P ≫ P

choice_{Δ} · \− ⟶ P_{1} −∘ P_{2} −∘ (P_{1} −∘ P) −∘ P 1We ignore the lazy treatment of ⊤ which is an orthogonal issue.

11.2 Extension to Ordered Contexts

Although the frame pointer machinery works well for linear contexts, it is not directly applicable to ordered contexts. There are two basic differences between linear and ordered contexts which stand in our way. Firstly, formulas are added to both sides of the ordered context, unlike the linear context in which formulas are always added on one side. Secondly, the ordered context is split between premises in the multiplicative rules, this stands in contrast to the linear context which is never syntactically split apart.

The main idea behind the extension of frames to ordered contexts is simply to add another type of frame pointer, ▷, which points to the right. The ability to start a frame from either end of the context is exactly what is needed for dealing with the deterministic ordered context splitting in our resource management system (and its extension by ⊤-flags). To see this more clearly, consider the left rules for the ordered implications (ignoring the unrestricted and linear contexts, and ignoring ⊤-flags).

\frac{Ω_{LI}\Ω_{LO}; Ω_{RI}\Ω_{GI}Ω_{RO} ⟶ D ≫ P Ω_{GI}\Ω_{GO} ⟶ G}{Ω_{LI}\Ω_{LO}; Ω_{RI}\Ω_{GO}Ω_{RO} ⟶ G ↠ D ≫ P}

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

In the rule for ↠, only the formulas (Ω_{GI}) on the left-hand side of the right output context will get passed into the pending proof branch for G.

However, in the rule for ↣

\frac{Ω_{LI}\Ω_{LO}Ω_{GI}; Ω_{RI}\Ω_{RO} ⟶ D ≫ P Ω_{GI}\Ω_{GO} ⟶ G}{Ω_{LI}\Ω_{LO}Ω_{GO}; Ω_{RI}\Ω_{RO} ⟶ G ↣ D ≫ P}

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·))

only formulas on the right-hand side of the left output context (Ω_{GI}) get passed on. Thus we need the ability to start frames on the left-hand side of the ordered context to correctly deal with ↠, and on the right-hand side to deal with ↣.

Following this reasoning, we will end up with rules of the form:

\frac{(Ω_{L} = ▷Ω or Ω_{L} = Ω◁ or Ω_{L} = ·) and (Ω_{R} = ▷Ω′ or Ω_{R} = Ω′◁ or Ω_{R} = ·)}{Ω_{L}\Ω_{L}; Ω_{R}\Ω_{R} ⟶ P ≫ P}

\frac{Ω_{LI} ◁ \Ω_{LO}Ω_{GI}◁; Ω_{RI}\Ω_{RO} ⟶ D ≫ P Ω_{GI}\Ω_{GO} ⟶ G}{Ω_{LI}\Ω_{LO}Ω_{GO}; Ω_{RI}\Ω_{RO} ⟶ G ↣ D ≫ P}

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·))

\frac{Ω_{LI}\Ω_{LO}Ω_{GI}; ▷Ω_{RI}\ ▷ Ω_{RO} ⟶ D ≫ P Ω_{GI}\Ω_{GO} ⟶ G}{Ω_{LI}\Ω_{LO}Ω_{GO}; Ω_{RI}\Ω_{RO} ⟶ G ↣ D ≫ P}

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

The frame pointers are simply stating that some the portions of the ordered context will get passed on to some pending proof branch. That is why the init rule will accept a context as long as there is at least one pointer on the whole context. When we add a ◁ to the left context in the rule for ↣, we are stating that the rightmost portion, which does not contain □, of the left output context will be passed on to the proof branch for G.

The last detail to consider is that formulas are added on both the left and right side of the context. The system outlined above does not fully account for this as shown by the following example:

\frac{init}{D ◁ ◁\D ◁ ◁; ·\· ⟶ C ≫ C} \frac{init}{· \·; BD ◁ \BD◁ ⟶ A ≫ A} choice_{Ω} ABD ◁ \□BD◁ ⟶ A ↣_{R} BD ◁ \BD◁ ⟶ A ↣ A ↣_{R} D ◁ \failure ⟶ B ↣ A ↣ A ↣_{L} D ◁ \−; ·\− ⟶ (B ↣ A ↣ A) ↣ C ≫ Cnot done ↣_{L}

D\−; ·\− ⟶ D ↣ (B ↣ A ↣ A) ↣ C ≫ C

choice_{Ω} D(D ↣ (B ↣ A ↣ A) ↣ C)\− ⟶ C

The failure does not occur until the ↣_{R} rule explicitly checks that the B was consumed. We can allow the the failure occur in the init rule by constraining the scope of the frame pointer to not include hypotheses added to the context after the frame pointer. We will achieve this scoping by tagging hypotheses and frame pointers with an integer, or “level”, and carrying around the current level on the sequent arrow.

We make the following definition:

\overline{Ω} = max\{n|D^{n} ∈ Ω\}

and define the following relation which plays a similar role for ordered contexts as δ plays for linear contexts:

\overline{o(·)}  \frac{\overline{Ω} ≤ m}{o(▷^{m}Ω)}  \frac{\overline{Ω} ≤ m}{o(Ω◁^{m})}

With the above considerations and definitions, our rules take the following form:

\frac{o(Ω_{L}) o(Ω_{R})}{Ω_{L}\Ω_{L}; Ω_{R}\Ω_{R} ⟶^{n} P ≫ P}

\frac{Ω_{LI} ◁^{n} \Ω_{LO}Ω_{GI} ◁^{n}; Ω_{RI}\Ω_{RO} ⟶^{n} D ≫ P Ω_{GI}\Ω_{GO} ⟶^{n+1} G}{Ω_{LI}\Ω_{LO}Ω_{GO}; Ω_{RI}\Ω_{RO} ⟶^{n} G ↣ D ≫ P}

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·))

\frac{Ω_{LI}\Ω_{LO}Ω_{GI}; ▷^{n}Ω_{RI}\ ▷^{n} Ω_{RO} ⟶^{n} D ≫ P Ω_{GI}\Ω_{GO} ⟶^{n+1} G}{Ω_{LI}\Ω_{LO}Ω_{GO}; Ω_{RI}\Ω_{RO} ⟶^{n} G ↣ D ≫ P}

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

\begin{matrix}Ω_{I}D^{n}\Ω_{O}□ ⟶^{n} G \\ ↠ & R \\ Ω_{I}\Ω_{O} ⟶^{n} D ↠ G \end{matrix}  \begin{matrix}D^{n}Ω_{I}\□Ω_{O} ⟶^{n} G \\ ↣ & R \\ Ω_{I}\Ω_{O} ⟶^{n} D ↣ G \end{matrix}

Note that the derivation rules maintain the following invariant. Every unconsumed portion of an output context will be flanked by a frame pointer, whose tag is at least as big as all the formula tags in the portion, explicitly denoting that the portion will be passed into a pending proof branch. This invariant will also hold for the full strict derivation system presented in Section 11.3.

11.3 Strict Derivation System

This section presents the complete strict derivation system which extends the ⊤-flags system of Chapter 9.

As usual we will have two types of sequents

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P

where n is a natural number; input contexts, Ω_{xI}, are lists of tagged clause formulas, G^{n}, and pointers, ◁^{n} and ▷^{n}; and output contexts, Ω_{xO}, are lists of tagged clause formulas, placeholders and pointers; Γ, Δ_{x} and τ_{x} are unchanged from the ⊤-flags system.

Before showing the strict inference rules, we need to extend all of the machinery used in ⊤-fags derivations to work on strict contexts. We begin by extending ⊒ to work on strict linear and ordered contexts:

\overline{· ⊒ ·}  \frac{Ψ ⊒ Ψ′}{ΨD^{m} ⊒ Ψ′D^{m}}  \frac{Ψ ⊒ Ψ′}{ΨD^{m} ⊒ Ψ′□}  \frac{Ψ ⊒ Ψ′}{Ψ◁^{n} ⊒ Ψ′◁^{n}}  \frac{Ψ ⊒ Ψ′}{Ψ▷^{n} ⊒ Ψ′▷^{n}}  \frac{Ψ ⊒ Ψ′}{Ψ◁ ⊒ Ψ′◁}

We next consider mrg for strict ordered contexts:

\overline{mrg(·, τ_{1}, ·, τ_{2}, ·, τ_{1} ∗ τ_{2})}  \frac{mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ)}{mrg(D^{m}Ω_{1}, τ_{1}, D^{m}Ω_{2}, τ_{2}, D^{m}Ω, τ)}

mrg(Ω_{1}, 1τ_{1}, Ω_{2}, τ_{2}, Ω, τ) (0 ∉ τ′_{2})

mrg(D^{m}Ω_{1}, 1τ_{1}, □Ω_{2}, τ′_{2}0τ_{2}, □Ω, τ′_{2}0τ)

mrg(Ω_{1}, τ_{1}, Ω_{2}, 1τ_{2}, Ω, τ) (0 ∉ τ′_{1})

mrg(□Ω_{1}, τ′_{1}0τ_{1}, D^{m}Ω_{2}, 1τ_{2}, □Ω, τ′_{1}0τ)

mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ) (0 ∉ τ′_{i})

mrg(□Ω_{1}, τ′_{1}0τ_{1}, □Ω_{2}, τ′_{2}0τ_{2}, □Ω, (τ′_{1} ∗ τ′_{2})0τ)

\frac{mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ)}{mrg(▷^{n}Ω_{1}, τ_{1}, ▷^{n}Ω_{2}, τ_{2}, ▷^{n}Ω, τ)}  \frac{mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω, τ)}{mrg(◁^{n}Ω_{1}, τ_{1}, ◁^{n}Ω_{2}, τ_{2}, ◁^{n}Ω, τ)}

Finally we extend mrgL to strict linear contexts.

\overline{mrgL(·, v_{1}, ·, v_{2}, ·, v_{1} ∧ v_{2})}  \frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v)}{mrgL(◁Δ_{1}, v_{1}, ◁Δ_{2}, v_{2}, ◁Δ, v)}

\frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v)}{mrgL(DΔ_{1}, v_{1}, DΔ_{2}, v_{2}, DΔ, v)}  \frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v)}{mrgL(□Δ_{1}, v_{1}, □Δ_{2}, v_{2}, □Δ, v)}

\frac{mrgL(Δ_{1}, T, Δ_{2}, v_{2}, Δ, v)}{mrgL(DΔ_{1}, T, □Δ_{2}, v_{2}, □Δ, v)}  \frac{mrgL(Δ_{1}, v_{1}, Δ_{2}, T, Δ, v)}{mrgL(□Δ_{1}, v_{1}, DΔ_{2}, T, □Δ, v)}

We state the following lemma which we will use in the proof of Lemma 42.

Lemma 36 mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ, v) and δ(Δ_{1}) and δ(Δ_{2}) implies δ(Δ). Proof: By structural induction on the given derivation. □

We may now write the inference rules for strict derivations:

δ(Δ) o(Ω)

≐_{R}

Γ; Δ\Δ; Ω\Ω ⟶_{F ·}^{n} P ≐ P

δ(Δ)  o(Ω)  Γ; ·\·; ·\· ⟶_{v τ}^{n} G
!_{R}

Γ; Δ\Δ; Ω\Ω ⟶_{F ·}^{n} !G

o(Ω) Γ; Δ_{I}\Δ_{O}; ·\· ⟶_{v τ}^{n} G

¡_{R}

Γ; Δ_{I}\Δ_{O}; Ω\Ω ⟶_{v ·}^{n} !G

ΓD; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

→_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} D → G

Γ; Δ_{I}D\Δ_{O}□; Ω_{I}\Ω_{O} ⟶_{F τ}^{n} G

−∘_{RF}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{F τ}^{n} D → G

Γ; Δ_{I}D\Δ_{O}X; Ω_{I}\Ω_{O} ⟶_{T τ}^{n} G

−∘_{RT}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{T τ}^{n} D → G

(X = □ or X = D)

Γ; Δ_{I}\Δ_{O}; Ω_{I}D^{n}\Ω_{O}□ ⟶_{v τ0τ′}^{n} G

↠_{R0} (0 ∉ τ′)

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} D ↠ G

Γ; Δ_{I}\Δ_{O}; Ω_{I}D^{n}\Ω_{O}D^{n} ⟶_{v τ1}^{n} G

↠_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ1}^{n} D ↠ G

Γ; Δ_{I}\Δ_{O}; D^{n}Ω_{I}\□Ω_{O} ⟶_{v τ′0τ}^{n} G

↣_{R0} (0 ∉ τ′)

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} D ↣ G

Γ; Δ_{I}\Δ_{O}; D^{n}Ω_{I}\D^{n}Ω_{O} ⟶_{v 1τ}^{n} G

↣_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v 1τ}^{n} D ↣ G

Γ; Δ_{I} ◁ \Δ_{M}◁; Ω_{I} ◁^{n} \Ω_{L}Ω_{2}◁^{n} ⟶_{v_{1} τ_{L}}^{(n+1)} G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{R} ⟶_{v_{2} τ_{R}}^{(n+1)} G_{2}

•_{R0}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ_{R})}^{n} G_{1} • G_{2}

(□ ∉ Ω_{2} and (Ω_{L} = □ or ·) and τ_{L} ≠ τ1)

Γ; Δ_{I} ◁ \Δ_{M}◁; Ω_{I} ◁^{n} \Ω_{L}Ω_{2}◁^{n} ⟶_{v_{1} τ_{L}1}^{(n+1)} G_{1} Γ; Δ_{M}\Δ_{O}; ▷^{n}Ω_{2}\ ▷^{n} Ω_{R} ⟶_{v_{2} τ_{R}}^{(n+1)} G_{2}

•_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ_{R})}^{n} G_{1} • G_{2}

(□ ∉ Ω_{2} and (Ω_{L} = □ or ·))

Γ; Δ_{I} ◁ \Δ_{M}◁; ▷^{n}Ω_{I}\ ▷^{n} Ω_{2}Ω_{R} ⟶_{v_{1} τ_{R}}^{(n+1)} G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{L} ⟶_{v_{2} τ_{L}}^{(n+1)} G_{2}

∘_{R0}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ_{R})}^{n} G_{1} ∘ G_{2}

(□ ∉ Ω_{2} and (Ω_{R} = □ or ·) and τ_{R} ≠ 1τ)

Γ; Δ_{I} ◁ \Δ_{M}◁; ▷^{n}Ω_{I}\ ▷^{n} Ω_{2}Ω_{R} ⟶_{v_{1} 1τ_{R}}^{(n+1)} G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2} ◁^{n} \Ω_{L}◁^{n} ⟶_{v_{2} τ_{L}}^{(n+1)} G_{2}

∘_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+1τ_{R})}^{n} G_{1} ∘ G_{2}

(□ ∉ Ω_{2} and (Ω_{R} = □ or ·))

\begin{aligned}δ(Δ)  o(Ω) \\ & 1_{R} \\ Γ; Δ\Δ; Ω\Ω ⟶_{F ·}^{n} 1 \end{aligned}  \frac{⊤_{R}}{Γ; Δ\Δ; Ω\Ω ⟶_{T 1}^{n} ⊤}

Γ; Δ_{I}\Δ_{1}; Ω_{I}\Ω_{1} ⟶_{v_{1} τ_{1}}^{n} G_{1} Γ; Δ_{I}\Δ_{2}; Ω_{I}\Ω_{2} ⟶_{v_{2} τ_{2}}^{n} G_{2} mrg(Ω_{1}, τ_{1}, Ω_{2}, τ_{2}, Ω_{O}, τ) mrgL(Δ_{1}, v_{1}, Δ_{2}, v_{2}, Δ_{O}, v)

&_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G_{1} & G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G_{1}

⊕_{R1}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G_{1} ⊕ G_{2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G_{2}

⊕_{R2}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G_{1} ⊕ G_{2}

1; D ≫ P \ G Γ_{L}DG_{R}; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

choice_{Γ}

Γ_{L}DΓ_{R}; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} P

1; D ≫ P \ G Γ; Δ_{LI}□Δ_{RI}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

choice_{Δ}

Γ; Δ_{LI}DΔ_{RI}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P

choice_{Ω}

Γ; Δ_{I}\Δ_{O}; Ω_{LI}D^{m}Ω_{RI}\Ω_{LO}□Ω_{RO} ⟶_{v τ_{L}0τ_{R}}^{n} P

δ(Δ)  o(Ω_{L})  o(Ω_{R})

init

Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶_{F (· ; ·)}^{n} P ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D_{1} ≫ P

&_{L1}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D_{1} & D_{2} ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D_{2} ≫ P

&_{L2}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D_{1} & D_{2} ≫ P

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P Γ; ·\·; ·\· ⟶_{v′ τ′}^{n} G

→_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} G → D ≫ P

Γ; Δ_{I} ◁ \Δ_{M}◁; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})}^{n} D ≫ P Γ; Δ_{M}\Δ_{O}; ·\· ⟶_{v_{2} τ}^{n} G

−∘_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ_{R})}^{n} G −∘ D ≫ P

Γ; Δ_{I} ◁ \Δ_{M}◁; (Ω_{LI}\Ω_{LO} ; ▷^{n}Ω_{RI}\ ▷^{n} Ω_{GI}Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})}^{n} D ≫ P

Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{v_{2} τ}^{(n+1)} G

↠_{L0}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ+τ_{R})}^{n} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·) and τ_{R} ≠ 1τ)

Γ; Δ_{I} ◁ \Δ_{M}◁; (Ω_{LI}\Ω_{LO} ; ▷^{n}Ω_{RI}\ ▷^{n} Ω_{GI}Ω_{RO}) ⟶_{v_{1} (τ_{L} ; 1τ_{R})}^{n} D ≫ P

Γ; Δ_{M}\Δ_{O}; Ω_{GI} ◁^{n} \Ω_{GO}◁^{n} ⟶_{v_{2} τ}^{(n+1)} G

↠_{L1}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ+1τ_{R})}^{n} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □ or ·))

Γ; Δ_{I} ◁ \Δ_{M}◁; (Ω_{LI} ◁^{n} \Ω_{LO}Ω_{GI} ◁^{n}; Ω_{RI}\Ω_{RO}) ⟶_{v_{1} (τ_{L} ; τ_{R})}^{n} D ≫ P

Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{v_{2} τ}^{(n+1)} G

↣_{L0}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ ; τ_{R})}^{n} G ↣ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·) and τ_{L} ≠ τ1)

Γ; Δ_{I} ◁ \Δ_{M}◁; (Ω_{LI} ◁^{n} \Ω_{LO}Ω_{GI} ◁^{n}; Ω_{RI}\Ω_{RO}) ⟶_{v_{1} (τ_{L}1 ; τ_{R})}^{n} D ≫ P

Γ; Δ_{M}\Δ_{O}; ▷^{n}Ω_{GI}\ ▷^{n} Ω_{GO} ⟶_{v_{2} τ}^{(n+1)} G

↣_{L1}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L}1+τ ; τ_{R})}^{n} G ↣ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{LO} = □ or ·))

11.4 Correctness of Strict Derivations

Proving the soundness of strict derivations wrt ⊤-flags derivations is trivial since each strict derivation, when stripped of tags and pointers, is a ⊤-flags derivation.

Theorem 37

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G implies ∃Δ′_{I}, Δ′_{O}, Ω′_{I}, Ω′_{O}.

Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω′_{O} ⟶_{v τ} G

2. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P implies

∃Δ′_{I}, Δ′_{O}, Ω′_{LI}, Ω′_{LO}, Ω′_{RI}, Ω′_{RO}.

Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P

Proof: Structural induction on given derivation. □

In order to prove the other direction, we introduce some machinery to relate ⊤- flags contexts to strict contexts.

We start with Θ which relates a ⊤-flags context, not containing □, to a strict context.

\overline{Θ^{n}(·, ·)} \begin{aligned}Θ^{n}(Ω, Ω′) \\ & (m ≤ n) \\ Θ^{n}(Ω, ▷^{m}Ω′) \end{aligned} \begin{aligned}Θ^{n}(Ω, Ω′) \\ & (m ≤ n) \\ Θ^{n}(Ω, ◁^{m}Ω′) \end{aligned} \begin{aligned}Θ^{n}(Ω, Ω′) \\ & (m ≤ n) \\ Θ^{n}(DΩ, D^{m}Ω′) \end{aligned}

We will make use of the following properties of Θ. Lemma 38

1. Θ^{n}(Ω_{L}Ω_{R}, Ω′) implies ∃Ω′_{L}, Ω′_{R}. Ω′_{L}Ω′_{R} = Ω′ and Θ^{n}(Ω_{L}, Ω′_{L}) and Θ^{n}(Ω_{R}, Ω′_{R}).

2. Θ^{n}(Ω_{L}, Ω′_{L}) and Θ^{n}(Ω_{R}, Ω′_{R}) implies Θ^{n}(Ω_{L}Ω_{R}, Ω′_{L}Ω′_{R}).

3. Θ^{n}(Ω, Ω′_{L}Ω′_{R}) and m ≤ n implies Θ^{n}(Ω, Ω′_{L} ▷^{m} Ω′_{R}) and Θ^{n}(Ω, Ω′_{L} ◁^{m} Ω′_{R}).

4. Θ^{m}(Ω, Ω′) and m ≤ n implies Θ^{n}(Ω, Ω′) .

5. Θ^{n}(Ω, Ω′) implies \overline{Ω′} ≤ n. Proof: By structural induction on given derivation. □

We now relate ⊤-flags input/output context pairs to strict input/output context pairs.

\overline{Ξ^{n}(·\·, ·\·)} \frac{Ξ^{n}(Ω\Ω, Ω′\Ω′) Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{I}\Ω′_{O})}{Ξ^{n}(ΩDΩ_{I}\Ω□Ω_{O}, Ω′D^{m}Ω′_{I}\Ω′□Ω′_{O})}

(□ ∉ Ω, m ≤ n)

\frac{Θ^{m}(Ω, Ω′)}{Ξ^{n}(Ω\Ω, Ω′ ◁^{m} \Ω′◁^{m})}

(□ ∉ Ω, m ≤ n)

\frac{Θ^{m}(Ω, Ω′)}{Ξ^{n}(Ω\Ω, ▷^{m}Ω′\ ▷^{m} Ω′)}

(□ ∉ Ω, m ≤ n)

Since we will only translate successful ⊤-flags derivations to strict derivations, we must ensure that the translated output contexts satisfy the invariant on strictness derivations stated at the end of Section 11.2.

We make use of the following properties of Ξ.

Lemma 39

1. Ξ^{n}(Ω\Ω, Ω′_{I}\Ω′_{O}) implies Ω′_{I} = Ω′_{O}.

2. Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{I}\Ω′_{O}) implies Θ^{n}(Ω_{I}, Ω′_{I}).

3. Ξ^{n}(Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO}, Ω′_{I}\Ω′_{O}) and Ω_{LI} ⊒ Ω_{LO} and m ≤ n

implies ∃Ω′_{LI}, Ω′_{RI}, Ω′_{LO}, Ω′_{RO}. Ω′_{I} = Ω′_{LI}D^{m}Ω′_{RI} and Ω′_{O} = Ω′_{LO}□Ω′_{RO} and Ξ^{n}(Ω_{LI}\Ω_{LO}, Ω′_{LI}\Ω′_{LO}) and Ξ^{n}(Ω_{RI}\Ω_{RO}, Ω′_{RI}\Ω′_{RO}).

4. Ξ^{n}(Ω_{LI}\Ω_{LO}, Ω′_{LI}\Ω′_{LO}) and Ξ^{n}(Ω_{RI}\Ω_{RO}, Ω′_{RI}\Ω′_{RO}) and m ≤ n implies Ξ^{n}(Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO}, Ω′_{LI}D^{m}Ω′_{RI}\Ω′_{LO}□Ω′_{RO}).

5. Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{LI}Ω′_{RI}\Ω′_{LO}Ω′_{RO}) implies

Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{LI} ▷^{n} Ω_{RI}\Ω′_{LO} ▷^{n} Ω′_{RO}) and Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{LI} ▷^{n} Ω_{RI}\Ω′_{LO} ◁^{n} Ω′_{RO}).

6. Ξ^{m}(Ω_{I}\Ω_{O}, Ω′_{I}\Ω′_{O}) and m ≤ n implies Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{I}\Ω′_{O}).

7. Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{I}\Ω′_{O}) implies \overline{Ω′_{I}} ≤ n and \overline{Ω′_{O}} ≤ n.

Proof: By induction on the given derivation with appeals to Lemma 38. For part 4, induct on the derivation for Ξ^{n}(Ω_{LI}\Ω_{LO}, Ω′_{LI}\Ω′_{LO}) and consider cases for Ξ^{n}(Ω_{RI}\Ω_{RO}, Ω′_{RI}\Ω′_{RO}). □

We now turn our attention to linear contexts.

\overline{ϵ(·\·, ·\·)}  \frac{ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O})}{ϵ(Δ_{I}\Δ_{O}, ◁Δ′_{I}\ ◁ Δ′_{O})}
\frac{ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O})}{ϵ(DΔ_{I}\DΔ_{O}, DΔ′_{I}\DΔ′_{O})} \frac{ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O})}{ϵ(DΔ_{I}\□Δ_{O}, DΔ′_{I}\□Δ′_{O})} \frac{ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O})}{ϵ(□Δ_{I}\□Δ_{O}, □Δ′_{I}\□Δ′_{O})}

Lemma 40 1. ϵ(Δ\Δ, Δ′_{I}\Δ′_{O}) implies Δ′_{I} = Δ′_{O}.

2. ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O}) and Δ_{I}\Δ_{M} and Δ_{M} ⊒ Δ_{O}

implies there exists Δ′_{M} such that

ϵ(Δ_{I}\Δ_{M}, Δ′_{I}\Δ′_{M}) and ϵ(Δ_{M}\Δ_{O}, Δ′_{M}\Δ′_{O}).

Proof: By induction on the structure of the given ϵ derivation. □

We can now show the completeness of strict derivations wrt to ⊤-flags derivations. Theorem 41

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ} G and δ(Δ′_{O}) and ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O}) and Ξ^{n}(Ω_{I}\Ω_{O}, Ω_{O}\Ω′_{O})

implies Γ; Δ′_{I}\Δ′_{O}; Ω′_{I}\Ω′_{O} ⟶_{v τ}^{n} G

2. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO}; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P and δ(Δ′_{O}) and ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O})

and Ξ^{n}(Ω_{LI}\Ω_{LO}, Ω′_{LI}\Ω′_{LO}) and Ξ^{n}(Ω_{RI}\Ω_{RO}, Ω′_{RI}\Ω′_{RO})

implies Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P

Proof: Structural induction on given strict derivation making use of lemmas 38 and 39. We give representative cases. case:

\frac{init}{Γ; Δ\Δ; (Ω_{L}\Ω_{L} ; Ω_{R}\Ω_{R}) ⟶_{F (· ; ·)} P ≫ P}

Then

Ξ^{n}(Ω_{L}\Ω_{L}, Ω′_{LI}\Ω′_{LO}) and Ξ^{n}(Ω_{R}\Ω_{R}, Ω′_{RI}\Ω′_{RO})  assumptions
δ(Δ′_{O}) and ϵ(Δ\Δ, Δ′_{I}\Δ′_{O})  assumptions
Δ′_{I} = Δ′_{O}  Lemma 40
Ω′_{LI} = Ω′_{LO} and Ω′_{RI} = Ω′_{RO}  Lemma 39.1
o(Ω′_{LI}) and o(Ω′_{RI})  defn. of Ξ
Γ; Δ′\Δ′; (Ω′_{LI}\Ω′_{LI} ; Ω′_{RI}\Ω′_{RI}) ⟶_{F (· ; ·)}^{n} P ≫ P  init

case: Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})} D ≫ P

choice_{Ω}

Γ; Δ_{I}\Δ_{O}; Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO} ⟶_{v τ_{L}0τ_{R}} P

Then

Ξ^{n}(Ω_{LI}DΩ_{RI}\Ω_{LO}□Ω_{RO}, Ω′_{I}\Ω′_{O})  assumptions
δ(Δ′_{O}) and ϵ(Δ_{I}\Δ_{O}, Δ′_{I}Δ′_{O})  assumptions

Ω′_{I} = Ω′_{LI}D^{m}Ω′_{RI} and Ω′_{O} = Ω′_{LO}□Ω′_{RO} and

Ξ(Ω_{LI}\Ω_{LO}, Ω′_{LI}\Ω′_{LO}) and Ξ(Ω_{RI}\Ω_{RO}, Ω′_{RI}\Ω′_{RO})  Lemma 39.3
Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{RI}\Ω′_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P  ind. hyp.
Γ; Δ′_{I}\Δ′_{O}; Ω′_{LI}D^{m}Ω′_{RI}\Ω′_{LO}□Ω′_{RO} ⟶_{v τ_{L}0τ_{R}}^{n} P  choice_{Ω}

case:

Γ; Δ_{I}\Δ_{M}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GI}Ω_{RO}) ⟶_{v_{1} (τ_{L} ; 1τ_{R})} D ≫ P  Γ; Δ_{M}\Δ_{O}; Ω_{GI}\Ω_{GO} ⟶_{v_{2} τ} G
↠_{L}

Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{GO}Ω_{RO}) ⟶_{(v_{1}∨v_{2}) (τ_{L} ; τ+1τ_{R})} G ↠ D ≫ P

(□ ∉ Ω_{GI} and (Ω_{RO} = □Ω or ·))

Then

Ξ^{n}(Ω_{LI}\Ω_{LO}, Ω′_{LI}\Ω′_{LO}) and Ξ^{n}(Ω_{RI}\Ω_{GO}Ω_{RO}, Ω′_{RI}\Ω′_{R})  assumptions
δ(Δ′_{O}) and ϵ(Δ_{I}\Δ_{O}, Δ′_{I}\Δ′_{O})  assumptions

There exists Δ′_{M} such that

ϵ(Δ_{I}\Δ_{M}, Δ′_{I}\Δ′_{M}) and ϵ(Δ_{M}\Δ_{O}, Δ′_{M}\Δ′_{I})  Lemma 40
δ(Δ′_{M}◁)  defn. of δ.

Suppose Ω_{RO} = □Ω_{O} for some Ω_{O} (case for Ω_{RO} = · is similar)

Ω_{RI} = Ω_{GI}DΩ_{I} where Ω_{GI} ⊒ Ω_{GO} and Ω_{I} ⊒ Ω_{O}  Ω_{RI} ⊒ Ω_{GO}Ω_{RO}

Note that Ξ^{n}(Ω_{GI}DΩ_{I}\Ω_{GO}□Ω_{O}, Ω′_{RI}\Ω′_{R}) Ω′_{RI} = Ω′_{GI}D^{m}Ω′_{I} and Ω′_{R} = Ω′_{GO}□Ω′_{O} and

Ξ^{n}(Ω_{GI}\Ω_{GO}, Ω′_{GI}\Ω′_{GO}) and Ξ^{n}(Ω_{I}\Ω_{O}, Ω′_{I}\Ω′_{O})  Lemma 39.3
Θ^{n}(Ω_{GI}, Ω′_{GI})  Lemma 39.2
Ξ^{n}(Ω_{GI}\Ω_{GI}, ▷^{n}Ω′_{GI}\ ▷^{n} Ω′_{GI})  defn. of Ξ
Ξ^{n}(Ω_{GI}DΩ_{I}\Ω_{GI}□Ω_{O}, ▷^{n}Ω′_{GI}D^{m}Ω′_{I}\ ▷^{n} Ω′_{GI}□Ω′_{O})  Lemma 39.4

Γ; Δ′_{I} ◁ \Δ′_{M}◁; (Ω′_{LI}\Ω′_{LO} ; ▷^{n}Ω′_{GI}D^{m}Ω′_{I}\ ▷^{n} Ω′_{GI}□Ω′_{O}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P

ind. hyp.

Ξ^{(n+1)}(Ω_{GI}\Ω_{GO}, Ω′_{GI} ◁^{n} \Ω′_{GO}◁^{n})  Lemmas 39.5 and 39.6
Γ; Δ′_{M}\Δ′_{O}; Ω′_{GI} ◁^{n} \Ω′_{GO}◁^{n} ⟶_{v τ}^{(n+1)} G  ind. hyp.
Γ; Δ′_{I}\Δ′_{O}; (Ω′_{LI}\Ω′_{LO} ; Ω′_{GI}D^{m}Ω′_{I}\Ω′_{GO}□Ω′_{O}) ⟶_{v (τ_{L} ; τ+τ_{R})}^{n} D ≫ P by rule ↠_{L}
□

11.5 Strictness Properties

We show that the system will never fail at the −∘_{R} rule. Lemma 42 (Linear Strictness)

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{F τ}^{n} G implies δ(Δ_{O}).

2. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{F (τ_{L} ; τ_{R})}^{n} G ≫ P implies δ(Δ_{O}).

Proof: Induction on given derivation using Lemma 36. □

Thus we may collapse the two −∘_{R} rules into one rule:

Γ; Δ_{I}D\Δ_{O}X; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

−∘_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} D −∘ G

where X is either □ or D.

Additionally, the strict system will never fail at the ↠_{R} or ↣_{R} rules. To show this, we introduce the following notation:

ρ(Ω) ≡ max{n | ◁^{n} ∈ Ω or ▷^{n} ∈ Ω}
μ(Ω_{I}, Ω_{O}) ≡ Ω_{I} ⊒ Ω_{O} and \overline{Ω_{O}} ≤ ρ(Ω_{I}) and ∀Ω_{IL}, Ω_{IR}, D^{m}, Ω_{OL}, Ω_{OR}.

(Ω_{IL}D^{m}Ω_{IR} = Ω_{I} and Ω_{OL}□Ω_{OR} = Ω_{O} and ∥Ω_{IL}∥ = ∥Ω_{OL}∥)

implies \overline{Ω_{OL}} ≤ ρ(Ω_{IL}) and \overline{Ω_{OR}} ≤ ρ(Ω_{IR})

Lemma 43 (Ordered Strictness)

1. Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G implies μ(Ω_{I}, Ω_{O})

2. Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P implies

μ(Ω_{LI}, Ω_{LO}) and μ(Ω_{RI}, Ω_{RO})

Proof: Structural induction on given derivation. We show a representative case.

case:

Γ; Δ_{I} ◁ \Δ_{M}◁; Ω_{I} ◁^{n} \Ω_{L}Ω_{2}◁^{n} ⟶_{v_{1} τ_{L}}^{(n+1)} G_{1} Γ; Δ_{M}\Δ_{O}; Ω_{2}\Ω_{R} ⟶_{v_{2} τ_{R}}^{(n+1)} G_{2}

•_{R0}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{L}Ω_{R} ⟶_{(v_{1}∨v_{2}) (τ_{L}+τ_{R})}^{n} G_{1} • G_{2}

(□ ∉ Ω_{2} and (Ω_{L} = Ω□ or ·) and τ_{L} ≠ τ1)

Then

μ(Ω_{I} ◁^{n}, Ω_{L}Ω_{2}◁^{n}) and μ(Ω_{2}, Ω_{R})  ind. hyp.
Ω_{I} = Ω_{IL}Ω_{2} and Ω_{IL} ⊒ Ω_{L}  Ω_{I} ◁^{n} ⊒ Ω_{L}Ω_{2}◁^{n}

Ω_{I} ⊒ Ω_{L}Ω_{R}

ρ(Ω_{I}) ≥ ρ(Ω_{IL}) and ρ(Ω_{I}) ≥ ρ(Ω_{2})  Ω_{I} = Ω_{IL}Ω_{2}
\overline{Ω_{L}} ≤ ρ(Ω_{IL}) ≤ ρ(Ω_{I})  Ω_{L} = Ω□ or · and μ(Ω_{I} ◁^{n}, Ω_{L}Ω_{2}◁^{n})
\overline{Ω_{R}} ≤ ρ(Ω_{2}) ≤ ρ(Ω_{I})  μ(Ω_{2}, Ω_{R})

\overline{Ω_{L}Ω_{R}} ≤ ρ(Ω_{I}) Let Ω_{LI}D^{m}Δ_{RI} = Δ_{I} and Ω_{LO}□Ω_{RO} = Ω_{L}Ω_{R} where ∥Ω_{LI}∥ = ∥Ω_{LO}∥ D^{m} ∈ Ω_{IL} or D^{m} ∈ Ω_{2}

In either case \overline{Ω_{xO}} ≤ ρ(Ω_{xI})  ind. hyp.

□

We will call a sequent Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G valid if \overline{Ω_{I}} ≤ n and ρ(Ω_{I}) < n. We will call a sequent Γ; Δ_{I}\Δ_{O}; (Ω_{LI}\Ω_{LO} ; Ω_{RI}\Ω_{RO}) ⟶_{v (τ_{L} ; τ_{R})}^{n} D ≫ P valid

if \overline{Ω_{LI}Ω_{RI}} ≤ n and ρ(Ω_{LI}Ω_{RI}) ≤ n. Note that the derivation rules preserve this validity. It is a corollary of Lemma 43 that bottom-up, left-to-right derivations of valid sequents will never fail at the ↠_{R} or ↣_{R} rules.

11.6 Implementation Issues

After choosing a formula D, computation of its residual formula, G′; D ≫ P \ G, is parametric in P. Thus, we can compile program clauses once, abstracting over P, and then use them in their compiled form by giving them the P we are trying to solve.

The strict system has the nice property that the ordered context checks in the init, ≐_{R}, 1_{R}, and →_{L} rules may be done in constant time. One need only check each end of the ordered context to determine if \overline{Ω} ≤ m. One can easily see that this is indeed the case by noticing that the tags only increase from conclusion to premise(s) and that no inference rules change the tags on any ordered hypotheses or frame pointers. Then, since everything is added to the right or left side of the ordered context, the highest tag in a context must occur at either end of the context.

The linear context checks, i.e., δ(Δ), are possibly linear in the length of Δ. However, we can further optimize the linear context management as follows. Since we know the strictness property holds, we may actually remove linear hypotheses from the linear context once they are consumed. We may then change the definition of δ as follows:

\overline{δ(·)}  \overline{δ(Δ◁)}

We then change the choice_{Δ}, ⊤_{R} and −∘_{R} rules as follow:

1; D ≫ P \ G Γ; Δ_{L}Δ_{R}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

choice_{Ω}

Γ; Δ_{L}DΔ_{R}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} P

\begin{aligned}◁ ∉ Δ′ \\ & ⊤_{R◁} \\ Γ; Δ ◁ Δ′\Δ; Ω_{I}\Ω_{O} ⟶_{T 1}^{n} ⊤ \end{aligned}  \frac{⊤_{R·}}{Γ; ·\·; Ω_{I}\Ω_{O} ⟶_{T 1}^{n} ⊤}

Γ; Δ_{I}D\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} G

−∘_{R}

Γ; Δ_{I}\Δ_{O}; Ω_{I}\Ω_{O} ⟶_{v τ}^{n} D −∘ G

While failing much sooner than previous versions, the system is still not quite equivalent to RM3. In the &_{R} rule, no attempt is made to restrict the second premise to only using formulas consumed by the first premise. Thus a strict derivation can fail in the &_{R} rule. We could of course adapt the scheme used in the frame system [33], which is linear in the size of the linear context, to prevent failures due to linear hypotheses. However the extension of this scheme to the ordered case is not very satisfying– it seems to prohibit constant time ordered context strictness checks at the proof leaves. Thus, it is not clear if “fixing” this is worth the trouble since it would seem to require scanning through the ordered context at every terminal rule.

There is a prototype implementation of Olli using the strict derivation system, with the just-mentioned modifications. It is written in the Teyjus [38] implementation of λProlog and is available at:

  http://www.cs.cmu.edu/~jpolakow.

170

Part III

Ordered Logical Framework Ordered Types

In this chapter we add proof terms to ordered linear logic. This essentially turns the logic into a type system for an ordered lambda calculus following the Curry-Howard isomorphism. Furthermore, as hinted at in Chapter 2, the local reductions and expansions become β-reductions and η-expansions for the ordered lambda calculus terms.

After re-introducing the logic as a type theory, we will show that there is a canonical fragment of the type theory, i.e., a fragment for which canonical (or long βηnormal) forms exist, which corresponds to the uniform fragment of the logic examined in Chapter 6. The existence of canonical forms is critical in logical framework applications of our calculus, since it is the canonical forms which are in bijective correspondence with the objects to be represented. This property is inherited both from the logical framework LF [23] and its linear refinement LLF [11].

In Chapter 13 we will show that we can add dependent types to the theory to produce a LF style logical framework. We will then proceed to show that typechecking remains decidable and that canonical forms still exist^{1}. Finally, in Chapter 16 we will show how such an ordered logical framework can be used to analyze some syntactic properties of the CPS transform.

1We will not show actual canonical forms, rather we will show that a slightly weaker notion exists which is still suitable for logical framework representations– see Section 15.3.

12.1 Proof Terms

In this section we present the basic natural deduction system for ordered linear logic (Chapter 2.10) annotated with proof terms. The proof terms will form an ordered lambda calculus.

We start with the types we shall use:

Types A ::= a  atomic types
| A_{1} → A_{2}  unrestricted implication
| A_{1} −∘ A_{2} linear implication
| A_{1} ↠ A_{2}  ordered right implication
| A_{1} ↣ A_{2} ordered left implication
| A_{1} & A_{2}  additive conjunction
| ⊤  additive truth
| A_{1} • A_{2}  multiplicative conjunction
| 1  multiplicative truth
| A_{1} ⊕ A_{2}  additive disjunction
| 0  additive falsehood
| !A  unrestricted modality
| ¡A  linear modality

We do not consider the quantifiers here. Instead we will consider a generalization of the universal quantifier (dependent types) in Chapter 13. We will not treat the existential quantifier at all, since it is not necessary for the applications of ordered lambda terms considered in this thesis. Furthermore, we only include one multiplicative pair type (•) since the other one (∘) is trivially definable, A_{1} ∘ A_{2} ≡ A_{2} • A_{1}.

We will use the following proof terms:

Terms M ::= x | y | z  variables
| λx:A. M | M_{1} M_{2}  unrestricted functions (→)
| λ̂y:A. M | M_{1}ˆ M_{2}  linear functions (−∘)
| λ^{>}z:A. M | M_{1}^{>}M_{2}  right ordered functions (↠)
| λ^{<}z:A. M | M_{1}^{<} M_{2}  left ordered functions (↣)
| ⟨M_{1} , M_{2}⟩ | fst M | snd M  additive pairs (&)
| ⟨⟩  additive unit (⊤)
| [M_{1} , M_{2}] | let [z , z′] = M in N  multiplicative pairs (•)
| ⋆ | let ⋆ = M in N  multiplicative unit (1)
| inl^{B} M | inr^{A} M
| case M of inl z ⇒ N∥inr z′ ⇒ N′ additive disjunction (⊕)
| abort^{A} M  additive falsehood (0)
| !M | let !x = M in N  unrestricted modality (!)
| ¡M | let ¡y = M in N  linear modality (¡)

We use the following judgement to type our terms:

Γ; Δ; Ω ⊢ M : A

where Γ, Δ, and Ω have the same form as in the natural deduction system in Chapter 2^{2}.

We can now state all of the typing rules. These are the same rules given in Chapter 2.10, annotated with proof terms. We also restate the local reductions and expansions for each term as β-reductions and η-expansions.

Variable Rules.

\frac{uvar}{Γ_{1}(x:A)Γ_{2}; ·; · ⊢ x : A}

\frac{lvar}{Γ; y:A; · ⊢ y : A}

\frac{ovar}{Γ; ·; z:A ⊢ z : A}

2However, we now interpret the labels on hypotheses as variables.

Unrestricted Functions A→B.

Γ(x:A); Δ; Ω ⊢ M : B

→I Γ; Δ; Ω ⊢ λx:A. M : A → B

Γ; Δ; Ω ⊢ M : A → B Γ; ·; · ⊢ N : A

→E Γ; Δ; Ω ⊢ M N : B

We have the following reduction rule:

(λx:A. M) N ⟹_{β} [N/x]M

We have the following expansion for terms M of type A → B:

M ⟹_{η} λx:A. M x

where x is not free in M. Linear Functions A −∘ B.

Γ; Δ(y:A); Ω ⊢ M : B
−∘I
Γ; Δ; Ω ⊢ λ̂y:A. M : A −∘ B

Γ; Δ_{1}; Ω ⊢ M : A −∘ B Γ; Δ_{2}; · ⊢ N : A −∘E

Γ; Δ_{1} ▷◁ Δ_{2}; Ω ⊢ Mˆ N : B

We have the following reduction rule:

(λ̂y:A. M)ˆ N ⟹_{β} [N/y]M

We have the following expansion for terms M of type A −∘ B:

M ⟹_{η} λ̂y:A. Mˆ y

where y is not free in M.

Right Ordered Functions A↠B.

Γ; Δ; Ω(z:A) ⊢ M : B

↠I
Γ; Δ; Ω ⊢ λ^{>}z:A. M : A ↠ B

Γ; Δ_{1}; Ω_{1} ⊢ M : A ↠ B Γ; Δ_{2}; Ω_{2} ⊢ N : A

↠E
Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2} ⊢ M^{>}N : B

We have the following reduction rule:

(λ^{>}z:A. M)^{>}N ⟹_{β} [N/z]M

We have the following expansion for terms M of type A ↠ B:

M ⟹_{η} λ^{>}z:A. M^{>}z

where z is not free in M. Left Ordered Functions A↣B.

Γ; Δ; (z:A)Ω ⊢ M : B

↣I
Γ; Δ; Ω ⊢ λ^{<}z:A. M : A ↣ B

Γ; Δ_{2}; Ω_{2} ⊢ M : A ↣ B Γ; Δ_{1}; Ω_{1} ⊢ N : A

↣E
Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2} ⊢ M^{<} N : B

We have the following reduction rule:

(λ^{<}z:A. M)^{<} N ⟹_{β} [N/z]M

We have the following expansion for terms M of type A ↣ B:

M ⟹_{η} λ^{<}z:A. M^{<} z

where z is not free in M.

Multiplicative Conjunction A•B.

Γ; Δ_{1}; Ω_{1} ⊢ M:A Γ; Δ_{2}; Ω_{2} ⊢ N:B

•I Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2} ⊢ [M , N] : A • B

Γ; Δ_{2}; Ω_{2} ⊢ M : A • B Γ; Δ_{1}; Ω_{1}(z:A)(z′:B)Ω_{3} ⊢ N : C

•E

Γ; Δ_{1}Δ_{2}; Ω_{1}Ω_{2}Ω_{3} ⊢ let [z , z′] = M in N : C

We have the following reduction rule:

let [z , z′] = [M , M′] in N ⟹_{β} N[M/z, M′/z′]

We have the following expansion for terms M of type A • B:

M ⟹_{η} let [z , z′] = M in [z , z′]

We will not bother with assigning a term to the other ordered conjunction, ∘, since it simply reverses z and z′ in the term displayed above.

Multiplicative Unit 1.

\frac{1I}{Γ; ·; · ⊢ ⋆ : 1}

Γ; Δ_{2}; Ω_{2} ⊢ M : 1 Γ; Δ_{1}; Ω_{1}Ω_{3} ⊢ N : C

1E

Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2}Ω_{3} ⊢ let ⋆ = M in N : C

We have the following reduction rule:

let ⋆ = ⋆ in N ⟹_{β} N

We have the following expansion for terms M of type 1:

M ⟹_{η} let ⋆ = M in ⋆

Additive Conjunction A&B.

Γ; Δ; Ω ⊢ M : A Γ; Δ; Ω ⊢ N : B

&I Γ; Δ; Ω ⊢ ⟨M , N⟩ : A & B

Γ; Δ; Ω ⊢ M : A & B
&E_{1}
Γ; Δ; Ω ⊢ fst M : A

Γ; Δ; Ω ⊢ M : A & B
&E_{2}
Γ; Δ; Ω ⊢ snd M : B

We have the following reduction rules:

\begin{aligned}fst ⟨M , N⟩ & ⟹_{β} & M \\ snd ⟨M , N⟩ & ⟹_{β} & N \end{aligned}

We have the following expansion for terms M of type A & B:

M ⟹_{η} ⟨fst M , snd M⟩

Additive Unit ⊤.

\frac{⊤I}{Γ; Δ; Ω ⊢ ⟨⟩ : ⊤}

Since there is no elimination rule, there are no reductions for the additive unit. However we do the following expansion for terms M of type ⊤:

M ⟹_{η} ⟨⟩

Additive Disjunction ⊕.

Γ; Δ; Ω ⊢ M : A ⊕I_{1}

Γ; Δ; Ω ⊢ inl^{B} M : A ⊕ B

Γ; Δ; Ω ⊢ M : B ⊕I_{2}

Γ; Δ; Ω ⊢ inr^{A} M : A ⊕ B

Γ; Δ_{2}; Ω_{2} ⊢ M : A ⊕ B Γ; Δ_{1}; Ω_{1}(z:A)Ω_{3} ⊢ N : C Γ; Δ_{1}; Ω_{1}(z′:B)Ω_{3} ⊢ N′ : C

⊕E Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2}Ω_{3} ⊢ case M of inl z ⇒ N∥inr z′ ⇒ N′ : C

We have the following reduction rules:

case inl^{B} M of inl z ⇒ N∥inr z′ ⇒ N′ ⟹_{β} [M/z]N
case inr^{A} M′ of inl z ⇒ N∥inr z′ ⇒ N′ ⟹_{β} [M′/z′]N′

We have the following expansion for terms M of type A ⊕ B:

M ⟹_{η} case M of inl z ⇒ inl z∥inr z′ ⇒ inr z′

Additive Falsehood 0.

Γ; Δ_{2}; Ω_{2} ⊢ M : 0
0E
Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2}Ω_{3} ⊢ abort^{C} M : C

Since there is no introduction rule for 0, there are no new reductions. We do have the following expansion for terms M of type 0:

M ⟹_{η} abort0 M

Unrestricted Modality !A.

Γ; ·; · ⊢ M : A

!I Γ; ·; · ⊢ !M : !A

Γ; Δ_{2}; Ω_{2} ⊢ M : !A Γ(x:A); Δ_{1}; Ω_{1}Ω_{3} ⊢ N : C
!E
Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2}Ω_{3} ⊢ let !x = M in N : C

We have the following reduction rule:

let !x = !M in N ⟹_{β} [M/x]N

We have the following expansion for terms M of type !A:

M ⟹_{η} let !x = M in !x

Linear Modality ¡A.

Γ; Δ; · ⊢ M : A

¡I Γ; Δ; · ⊢ ¡M : ¡A

Γ; Δ_{2}; Ω_{2} ⊢ M : ¡A Γ; Δ_{1}(y:A); Ω_{1}Ω_{3} ⊢ N : C
¡E
Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2}Ω_{3} ⊢ let ¡y = M in N : C

We have the following reduction rule:

let ¡y = ¡M in N ⟹_{β} [M/y]N

We have the following expansion for terms M of type ¡A:

M ⟹_{η} let ¡y = M in ¡y

In order to prove subject reduction we proceed to establish the expected structural properties for contexts and substitution lemmas.

Lemma 44 (Structural Properties)

1. Γ_{1}(x:A)(x′:A′)Γ_{2}; Δ; Ω ⊢ M : B implies Γ_{1}(x′:A′)(x:A)Γ_{2}; Δ; Ω ⊢ M : B.

2. Γ_{1}Γ_{2}; Δ; Ω ⊢ M : B implies Γ_{1}(x:A)Γ_{2}; Δ; Ω ⊢ M : B.

3. Γ_{1}(x:A)(x′:A)Γ_{2}; Δ; Ω ⊢ M : B implies Γ_{1}(x:A)Γ_{2}; Δ; Ω ⊢ [x/x′]M : B.

4. Γ; Δ_{1}(y:A)(y′:A′)Δ_{2}; Ω ⊢ M : B implies Γ; Δ_{1}(y′:A′)(y:A)Δ_{2}; Ω ⊢ M : B. Proof: By induction on the structure of the given derivations. □ Lemma 45 (Substitution Properties)

1. Γ_{1}(x:A)Γ_{2}; Δ; Ω ⊢ M : B and Γ_{1}; ·; · ⊢ N : A implies Γ_{1}Γ_{2}; Δ; Ω ⊢ [N/x]M : B.

2. Γ; Δ_{1}(y:A)Δ_{2}; Ω ⊢ M : B and Γ; Δ′; · ⊢ N : A implies Γ; (Δ_{1} ▷◁ Δ′)Δ_{2}; Ω ⊢ [N/y]M : B.

3. Γ; Δ; Ω_{1}(z:A)Ω_{2} ⊢ M : B and Γ; Δ′; Ω′ ⊢ N : A

implies Γ; Δ ▷◁ Δ′; Ω_{1}Ω′Ω_{2} ⊢ [N/z]M : B. Proof: By induction over the structure of the given typing derivation for M in each case, using Lemma 44. □

Subject reduction now follows immediately. Theorem 46 (Subject Reduction)

Γ; Δ; Ω ⊢ M : A and M ⟹_{β} M′ implies Γ; Δ; Ω ⊢ M′ : A. Proof: For each reduction, we apply inversion to the given typing derivation and then use the substitution lemma 45 to obtain the typing derivation for the conclusion. □

Subject expansion also holds. Theorem 47 (Subject Expansion)

Γ; Δ; Ω ⊢ M : A and M ⟹_{η} M′ implies Γ; Δ; Ω ⊢ M′ : A.

Proof: By a direct derivation in each case^{3}, using weakening (Lemma 44.(2)) for unrestricted functions. □

Finally, we state one further property of ordered typing derivations which is crucial for our logical-relations applications in Chapter 16.

Theorem 48 (Demotion)

1. Γ; Δ_{1}(y:A)Δ_{2}; Ω ⊢ M : B implies Γ(x:A); Δ_{1}Δ_{2}; Ω ⊢ [x/y]M : B.

2. Γ; Δ; Ω_{1}(z:A)Ω_{2} ⊢ M : B implies Γ; Δ(y:A); Ω_{1}Ω_{2} ⊢ [y/z]M : B.

Proof: In both cases by induction on the structure of the given derivation. □

12.2 Canonical Forms

In this section, we show that canonical (or long βη-normal) forms exists for a fragment of the ordered lambda calculus. This fragment consists of the types which correspond to the uniform fragment of ordered linear logic. We give a proof by logical relations which foreshadows some of the techniques we will use in Chapters 13, 14, and 15 to prove decidability of type-checking in an ordered logical framework^{4}. We further speculate that this proof could likely be adapted to a direct proof of normalization for ordered linear logic (without using the sequent calculus).

For the remainder of this chapter, we only consider types, A, within the canonical fragment:

Canonical Types A ::= a  atomic types
| A_{1} → A_{2}  unrestricted implication
| A_{1} −∘ A_{2} linear implication
| A_{1} ↠ A_{2}  ordered right implication
| A_{1} ↣ A_{2} ordered left implication
| A_{1} & A_{2}  additive conjunction
| ⊤  additive truth

3In fact the expansions shown in Chapter 2.

4The type system of this chapter extended with dependent types.

In order to show the existence of canonical forms, we will give a canonicalization procedure, and then show that this procedure always succeeds on terms in the canonical fragment of the calculus (i.e., terms whose types are in the uniform fragment of ordered linear logic). In order to simplify our argument, and to show a more realistic canonicalization procedure, we ignore linearity and ordering constraints when transforming a term into canonical form. This omission is sound as long as we know beforehand that the term being transformed is well-typed.

Our proof proceeds as follows. We first formalize the property that a term can be converted to canonical form via a deductive system which can easily be related to the usual notion of long βη-normal form. This deductive system can also be read as an algorithm for converting a term to canonical form.

We then prove that any well-typed term (within the canonical fragment) can indeed be converted to canonical form. Our proof will be an argument by Kripke logical relations (also called Tait’s method) consisting of two parts: (1) If M is a well-typed term of type A then M is in the logical relation represented by A, and (2) if M is in the logical relation represented by A then there is some canonical term N convertible to M. Our reduction strategy is based on weak head reduction defined below.

\frac{β_{→}}{(λx:A. M) N ⟶^{whr} M[N/x]} M ⟶^{whr} M′ whr_{→}

M N ⟶^{whr} M′ N

\frac{β_{−∘}}{(λ̂y:A. M)ˆ N ⟶^{whr} M[N/y]} M ⟶^{whr} M′ whr_{−∘}

Mˆ N ⟶^{whr} M′ˆ N

\frac{β_{↣}}{(λ^{<}z:A. M)^{<} N ⟶^{whr} M[N/z]} M ⟶^{whr} M′ whr_{↣}

M^{<} N ⟶^{whr} M′^{<} N

\frac{β_{↠}}{(λ^{>}z:A. M)^{>}N ⟶^{whr} M[N/z]} M ⟶^{whr} M′ whr_{↠}

M^{>}N ⟶^{whr} M′^{>}N

\frac{β_{&1}}{fst ⟨M , N⟩ ⟶^{whr} M} M ⟶^{whr} M′ whr_{&1}

⟨M , N⟩ ⟶^{whr} ⟨M′ , N⟩

\frac{β_{&2}}{snd ⟨M , N⟩ ⟶^{whr} N} N ⟶^{whr} N′ whr_{&2}

⟨M , N⟩ ⟶^{whr} ⟨M , N′⟩

Intuitively, canonical terms are atomic terms of atomic type, or λ-abstractions of canonical terms, or pairs of canonical terms. Atomic terms are variables, or fst applied to atomic terms, or snd applied to atomic terms, or applications of atomic terms to canonical terms. This is formalized in the judgments Ψ ⊢ M ⇑ M′ : A, which denotes that M has canonical form M′ at type A, and Ψ ⊢ M ↓ M′ : A, which denotes that M has atomic form M′ at type A. Ψ stands for a context composed of unrestricted, linear and ordered variables. Note that these inference rules are essentially the normal derivation rules of Chapter 3 without the linearity and ordering constraints on hypotheses.

Variables

\frac{uvar}{Ψ_{1}(x:A)Ψ_{2} ⊢ x ↓ x : A}

\frac{lvar}{Ψ_{1}(y:A)Ψ_{2} ⊢ y ↓ y : A}

\frac{ovar}{Ψ_{1}(z:A)Ψ_{2} ⊢ z ↓ z : A}

Atomic Types.

Ψ ⊢ M ↓ M′ : a

coercion

Ψ ⊢ M ⇑ M′ : a

M ⟶^{whr} M′ Ψ ⊢ M′ ⇑ M′′ : a

reduction

Ψ ⊢ M ⇑ M′′ : a Unrestricted Functions.

\begin{aligned}Ψ(x:A) ⊢ M x ⇑ M′ : B \\ & →I \\ Ψ ⊢ M ⇑ λx:A. M′ : A → B \end{aligned} ; \begin{aligned}Ψ ⊢ M ↓ M′ : A → B Ψ ⊢ N ⇑ N′ : A \\ & →E \\ Ψ ⊢ M N ↓ M′ N′ : B \end{aligned}

Linear Functions.

\begin{aligned}Ψ(y:A) ⊢ Mˆ y ⇑ M′ : B \\ & −∘I \\ Ψ ⊢ M ⇑ λ̂y:A. M′ : A −∘ B \end{aligned} ; \begin{aligned}Ψ ⊢ M ↓ M′ : A −∘ B Ψ ⊢ N ⇑ N′ : A \\ & −∘E \\ Ψ ⊢ Mˆ N ↓ M′ˆ N′ : B \end{aligned}

Right Ordered Functions.

\begin{aligned}Ψ(z:A) ⊢ M^{>}z ⇑ M′ : B \\ & ↠I \\ Ψ ⊢ M ⇑ λ^{>}z:A. M′ : A ↠ B \end{aligned} ; \begin{aligned}Ψ ⊢ M ↓ M′ : A ↠ B Ψ ⊢ N ⇑ N′ : A \\ & ↠E \\ Ψ ⊢ M^{>}N ↓ M′^{>}N′ : B \end{aligned}

Left Ordered Functions.

\begin{aligned}Ψ(z:A) ⊢ M^{<} z ⇑ M′ : B \\ & ↣I \\ Ψ ⊢ M ⇑ λ^{<}z:A. M′ : A ↣ B \end{aligned} ; \begin{aligned}Ψ ⊢ M ↓ M′ : A ↣ B Ψ ⊢ N ⇑ N′ : A \\ & ↣E \\ Ψ ⊢ M^{<} N ↓ M′^{<} N′ : B \end{aligned}

Additive Pairs.

Ψ ⊢ fst M ⇑ M′_{1} : A Ψ ⊢ snd M ⇑ M′_{2} : B

&I Ψ ⊢ M ⇑ ⟨M′_{1} , M′_{2}⟩ : A & B

Ψ ⊢ M ↓ M′ : A & B

&E1 Ψ ⊢ fst M ↓ fst M′ : A

Ψ ⊢ M ↓ M′ : A & B

&E2 Ψ ⊢ snd M ↓ snd M′ : B

Additive Unit.

\frac{⊤I}{Ψ ⊢ M ⇑ ⟨⟩ : ⊤}

We first state the following soundness lemma for the transformation process. Note that since the transformation judgements ignore linearity and ordering constraints, it is only meant to be applied to well-typed terms.

Lemma 49 Γ; Δ; Ω ⊢ M : A and ΓΔΩ ⊢ M ⇑ M′ : A implies

Γ; Δ; Ω ⊢ M′ : A and M′ is in long βη-normal form.

Proof: By structural inductions on the given derivations. □

We use the notation Ψ′ ≥ Ψ to denote that Ψ′ contains all declarations in Ψ and possibly more. We then have the following weakening lemma.

Lemma 50

1. Ψ ⊢ M ⇑ M′ : A and Ψ′ ≥ Ψ implies Ψ′ ⊢ M ⇑ M′ : A.

2. Ψ ⊢ M ↓ M′ : A and Ψ′ ≥ Ψ implies Ψ′ ⊢ M ↓ M′ : A.

Proof: By structural induction on the given derivation. □

The following unary Kripke logical relation is the crux of our argument. It is defined by induction on the type A.

Ψ ⊢ M ∈ [[a]] iff Ψ ⊢ M ⇑ N : a for some N.

Ψ ⊢ M ∈ [[A_{1} → A_{2}]] iff for all N and Ψ′ ≥ Ψ,

Ψ′ ⊢ N ∈ [[A_{1}]] implies Ψ′ ⊢ M N ∈ [[A_{2}]]. Ψ ⊢ M ∈ [[A_{1} −∘ A_{2}]] iff for all N and Ψ′ ≥ Ψ,

Ψ′ ⊢ N ∈ [[A_{1}]] implies Ψ′ ⊢ Mˆ N ∈ [[A_{2}]]. Ψ ⊢ M ∈ [[A_{1} ↠ A_{2}]] iff for all N and Ψ′ ≥ Ψ,

Ψ′ ⊢ N ∈ [[A_{1}]] implies Ψ′ ⊢ M^{>}N ∈ [[A_{2}]]. Ψ ⊢ M ∈ [[A_{1} ↣ A_{2}]] iff for all N and Ψ′ ≥ Ψ,

Ψ′ ⊢ N ∈ [[A_{1}]] implies Ψ′ ⊢ M^{<} N ∈ [[A_{2}]]. Ψ ⊢ M ∈ [[A_{1} & A_{2}]] iff Ψ ⊢ fst M ∈ [[A_{1}]] and Ψ ⊢ snd M ∈ [[A_{2}]]. Ψ ⊢ M ∈ [[⊤]].

We can now formally state and prove the second part of our proof— that welltyped terms in the logical relation at all types have canonical forms. We can prove this only simultaneously with the reverse statement for terms with an atomic form.

Lemma 51 (Logical Relations and Canonical Forms)

1. Ψ ⊢ M ∈ [[A]] implies Ψ ⊢ M ⇑ N : A for some N.

2. Ψ ⊢ M ↓ N : A implies Ψ ⊢ M ∈ [[A]].

Proof: By induction on A using structural properties of contexts. We show the case for ordered right implication. All other cases are similar or simpler.

Case: A = A_{1} ↠A_{2}. For each of the two properties (1) and (2) we need two appeals to the induction hypothesis, one on part (1) and one on part (2). First we consider property (1).

Ψ ⊢ M ∈ [[A_{1} ↠ A_{2}]]  by assumption
Ψ(x:A_{1}) ≥ Ψ  defn. of ≥
Ψ(z:A_{1}) ⊢ z ↓ z : A_{1}  by rule ovar
Ψ(z:A_{1}) ⊢ z ∈ [[A_{1}]]  by ind. hyp. (2) on A_{1}
Ψ(z:A_{1}) ⊢ M^{>}z ∈ [[A_{2}]]  by defn. of [[A_{1} ↠ A_{2}]]
Ψ(z:A_{1}) ⊢ M^{>}z ⇑ M_{2} : A_{2}  by ind. hyp. (1) on A_{2}
Ψ ⊢ M ⇑ λ^{>}z:A_{1}. M_{2} : A_{1} ↠ A_{2}  by rule ↠I

Next we show property (2).

Ψ ⊢ M ↓ M′ : A_{1} ↠ A_{2}  by assumption
Ψ′ ≥ Ψ and Ψ′ ⊢ N ∈ [[A_{1}]]  new assumptions
Ψ′ ⊢ N ⇑ N′ : A_{1}  by ind. hyp. (1) on A_{1}
Ψ′ ⊢ M ↓ M′ : A_{1} ↠ A_{2}  Lemma 50
Ψ′ ⊢ M^{>}N ↓ M′^{>}N′ : A_{2}  by rule ↠E
Ψ′ ⊢ M^{>}N ∈ [[A_{2}]]  by ind. hyp. (2) on A_{2}
Ψ ⊢ M ∈ [[A_{1} ↠ A_{2}]]  by defn. of [[A_{1} ↠ A_{2}]]

□

To prove that every well-typed term is in the logical relation we need closure under head expansion.

Lemma 52 (Closure Under Head Expansion)

M ⟶^{whr} M′ and Ψ ⊢ M′ ∈ [[A]] implies Ψ ⊢ M ∈ [[A]].

Proof: By induction on A. We show two representative cases.

Case: A = a. Then

Ψ ⊢ M′ ∈ [[a]]  by assumption
Ψ ⊢ M′ ⇑ M′′ : a  by defn. of [[a]]
M ⟶^{whr} M′  by assumption
Ψ ⊢ M ⇑ M′′ : a  by rule reduction
Ψ ⊢ M ∈ [[a]]  by defn. of [[a]]

Case: A = A_{1} ↠ A_{2}. Then

Ψ ⊢ M′ ∈ [[A_{1} ↠ A_{2}]]  by assumption
Ψ′ ≥ Ψ and Ψ ⊢ N ∈ [[A_{1}]]  new assumptions
Ψ′ ⊢ M′^{>}N ∈ [[A_{2}]]  by defn. of [[A_{1} ↠ A_{2}]]
M ⟶^{whr} M′  by assumption
M^{>}N ⟶^{whr} M′^{>}N  by rule whr_{↠}
Ψ′ ⊢ M^{>}N ∈ [[A_{2}]]  by ind. hyp. on A_{2}
Ψ ⊢ M ∈ [[A_{1} ↠ A_{2}]]  by defn. of [[A_{1} ↠ A_{2}]]
□

In order to show Γ; Δ; Ω ⊢ M : A implies ΓΔΩ ⊢ M ∈ [[A]], we need to explicitly manipulate substitutions. We shall define a substitution in the usual way as a list of variable assignments:

σ ::= · | σ, M/x | σ, M/y | σ, M/z

where there is at most one assignment for any variable. Substitutions compose in the obvious way. We write id_{Ψ} for the identity substitution on the variables declared in Ψ. We define logical relations on substitutions by induction on the structure of contexts.

Ψ′ ⊢ σ ∈ [[·]] iff σ = ·
Ψ′ ⊢ (σ, M/x) ∈ [[Ψ(x:A)]] iff
Ψ′ ⊢ σ ∈ [[Ψ]] and Ψ′ ⊢ M ∈ [[A]]
Ψ′ ⊢ (σ, M/y) ∈ [[Ψ(y:A)]] iff
Ψ′ ⊢ σ ∈ [[Ψ]] and Ψ′ ⊢ M ∈ [[A]]
Ψ′ ⊢ (σ, M/z) ∈ [[Ψ(z:A)]] iff
Ψ′ ⊢ σ ∈ [[Ψ]] and Ψ′ ⊢ M ∈ [[A]]

Lemma 53 (Weakening for [[−]])

1. Ψ ⊢ M ∈ [[A]] and Ψ′ ≥ Ψ implies Ψ′ ⊢ M ∈ [[A]].

2. Ψ′ ⊢ σ ∈ [[Ψ]] and Ψ′′ ≥ Ψ′ implies Ψ′′ ⊢ σ ∈ [[Ψ]].

Proof: By induction on the structure of the given derivation. □

Lemma 54 (Identity) Ψ ⊢ id_{Ψ} ∈ [[Ψ]]

Proof: Immediate by definition and lemma 51. □

Lemma 55 (Typing and Logical Relations) Γ; Δ; Ω ⊢ M : A and Ψ′ ≥ ΓΔΩ and Ψ ⊢ σ ∈ [[Ψ′]]

implies Ψ ⊢ M[σ] ∈ [[A]] where M[σ] is the result of applying substitution σ to M.

Proof: By induction on the structure of the given typing derivation D using Lemma 52 and elementary inversion properties of the logical relations for substitutions. We show three representative cases.

Case:

D = \frac{ovar}{Γ; ·; z:A ⊢ z:A}

This case follows directly from the assumption that the substitution is in the logical relation.

Ψ′ ≥ Γ(z:A) and Ψ ⊢ σ ∈ [[Ψ′]]  assumptions
Ψ ⊢ M′ ∈ [[A]] where M′/z ∈ σ  by inversion properties of [[−]]
Ψ ⊢ z[σ] ∈ [[A]]  by defn. of substitution

Case:

D = \begin{matrix}D_{2} \\ Γ; Δ; Ω(z:A_{1}) ⊢ M_{2} : A_{2} \end{matrix} ; ↠I ; Γ; Δ; Ω ⊢ λ^{>}z:A_{1}. M_{2} : A_{1} ↠ A_{2}

In this case the critical step uses closure under head expansion (Lemma 52).

Ψ′ ≥ ΓΔΩ and Ψ ⊢ σ ∈ [[Ψ′]]  assumptions
Ψ′′ ≥ Ψ and Ψ′′ ⊢ N ∈ [[A_{1}]]  new assumptions
Ψ′′ ⊢ σ ∈ [[Ψ′]]  Lemma 53
Ψ′′ ⊢ (σ, N/z) ∈ [[Ψ′(z:A_{1})]]  by defn. of [[−]]
Ψ′′ ⊢ M_{2}[σ, N/z] ∈ [[A_{2}]]  by ind. hyp. on D_{2}
Ψ′′ ⊢ (λ^{>}z:A_{1}. M_{2}[σ, z/z])^{>}N ∈ [[A_{2}]]  by Lemma 52
Ψ ⊢ λ^{>}z:A_{1}. M_{2}[σ, z/z] ∈ [[A_{1} ↠ A_{2}]]  by defn. of [[A_{1} ↠ A_{2}]]
Ψ ⊢ (λ^{>}z:A_{1}. M_{2})[σ] ∈ [[A_{1} ↠ A_{2}]]  by defn. of substitution

Case:

D = \begin{matrix}D_{1} \\ Γ; Δ_{1}; Ω_{1} ⊢ M_{1} : A_{2} ↠ A_{1} \end{matrix} \begin{matrix}D_{2} \\ Γ; Δ_{2}; Ω_{2} ⊢ M_{2} : A_{2} \end{matrix} ↠E Γ; Δ_{1} ▷◁ Δ_{2}; Ω_{1}Ω_{2} ⊢ M_{1}^{>}M_{2} : A_{1}

In this case the result follows by elementary inversion properties for the logical relation on substitutions.

Ψ′ ≥ Γ(Δ_{1} ▷◁ Δ_{2})Ω_{1}Ω_{2} and Ψ ⊢ σ ∈ [[Ψ′]]  by assumption
Ψ ⊢ M_{1}[σ] ∈ [[A_{2} ↠ A_{1}]]  by ind. hyp. on D_{1}
Ψ ⊢ M_{2}[σ] ∈ [[A_{2}]]  by ind. hyp. on D_{2}
Ψ ⊢ (M_{1}[σ])^{>}(M_{2}[σ]) ∈ [[A_{1}]]  by defn. of [[A_{2} ↠ A_{1}]]
Ψ ⊢ (M_{1}^{>}M_{2})[σ] ∈ [[A_{1}]]  by defn. of substitution
□

Theorem 56 (Canonical Forms) Γ; Δ; Ω ⊢ M : A implies for some N, ΓΔΩ ⊢ M ⇑ N : A.

Proof: Immediate from lemmas 55, 51, and 54. □

Now that we know the ordered type system has a canonical fragment, it is natural to start thinking about basing a logical framework on the system. However, most interesting logical framework applications require the ability to quantify over terms. Towards this end, we shall extend the type system with dependent types in Chapter 13, and then proceed to show, in Chapters 14 and 15 that type-checking remains decidable and canonical forms still exist. The proof techniques we use, which are essentially generalizations of the method employed in this chapter, follow the development in [24] and [59] extended to the ordered case. We show an extended application, concerning syntactic properties of the CPS transform, of the resulting ordered logical framework in Chapter 16.

192

Ordered Logical Framework

Logical frameworks are formal systems (meta-languages) suitable for encoding and reasoning about deductive systems (object languages). For a general overview of logical frameworks and some of their uses, see [46]. The Edinburgh logical framework (LF), introduced in [23], is a particular logical framework based on dependent types; it may be intuitively thought of as λP in the lambda cube [6]^{1}.

LF representations typically follow the slogan judgements as types, with a new type declared for each judgement to be represented; derivations then become LF terms. Dependent types allow for a smooth encoding of higher-level properties of the object system in the same manner. For example, we can encode Mini-ML, evaluation for Mini-ML, and a proof of value soundness all with the judgements-as-types methodology by using dependent types– see [47] for details. This technique essentially reduces checking the validity of object-level deductions to meta-level type-checking.

In order for such encodings to really be useful, LF must satisfy two key properties. Every LF term, of a type representing an object-level judgement, should correspond to some object-level derivation of that judgement. In order to establish a bijection, we require that LF have a notion of canonical forms to represent all LF terms for any particular type. Furthermore, we should be able to decide whether a given objectlevel deduction is valid. Thus, since type-checking a term corresponds to proving a deduction valid, LF type-checking should be decidable.

An additional aspect of LF representations is the use of higher-order abstract syntax, an idea going back to Church [12], which employs meta-level variables to

1This intuition is not exact since LF is actually a proper subset of λP as noted in [31].

represent object-level variables. With this technique, we can often avoid explicitly encoding the machinery of object-level substitution; instead, we may rely upon the underlying LF substitution mechanism. Thus, higher-order abstract syntax allows for particularly elegant encodings of systems with variable bindings.

However, higher-order abstract syntax only works when the object-level variables behave in the same manner as the meta-level variables. Thus one could not use the technique to accurately represent linear functions, since LF variables are unrestricted. In order to allow the use of LF-style representation techniques on a wider class of systems, Cervesato and Pfenning investigated the extension of LF with linear types [11]. The resulting linear logical framework (LLF), which conservatively extends LF, permits LF-style representation of linear systems such as those involving state. For technical reasons, only non-dependent linear types were considered and additive conjunctions including the additive unit were added to the framework.

In this chapter, we add dependent types to the basic ordered type system of Chapter 12 with the intention of forming an LF-style logical framework. Following LLF, we only allow unrestricted dependencies– types can only depend upon unrestricted variables. We will prove the decidability of type-checking for the system, in Chapter 15, with a simple extension of the techniques of [24] and [59] to the ordered case. This proof can be thought of as a generalization of the basic techniques used to prove the existence of canonical forms in the non-dependent type-theory (Section 12.2). The existence of canonical forms for the dependent system will be a by-product of a type-checking algorithm.

Our development precisely follows that of [24] and [59]. The addition of ordered types does not affect the development in any significant manner (except to add more cases) since, for the purposes of the equality checking, ordered types are identical to linear types. The details of all proofs in this and the subsequent two chapters, may be found in [24] and [59].

13.1 Ordered Logical Framework

We introduce the type system which we will refer to as the ordered logical framework (OLF). It is essentially the ordered type system of Chapter 12 augmented with dependent types, i.e., types which may depend upon terms. In order to facilitate a clear exposition, we will shift our nomenclature to objects, families, and kinds. Objects correspond to terms, families correspond to types, while kinds are new constructs which classify families (i.e., kinds are “types” for families). Here is the syntax for OLF.

Syntax

Kinds  K ::= type | Πx:A. K
Families  A ::= a | A M |
Πx:A_{1}. A_{2} | A_{1} −∘ A_{2} |
A_{1} ↠ A_{2} | A_{1} ↣ A_{2} |
A_{1} & A_{2} | ⊤
Objects M ::= c | x | y | z |
λx:A. M | M_{1} M_{2} |
λ̂y:A. M | M_{1}ˆ M_{2} |
λ^{>}z:A. M | M_{1}^{>}M_{2} |
λ^{<}z:A. M | M_{1}^{<} M_{2} |
⟨M_{1} , M_{2}⟩ | fst M | snd M | ⟨⟩
Signatures  Σ ::= · | Σ(a:K) | Σ(c:A)
Unrestricted Contexts  Γ ::= · | Γ(x:A)
Linear Contexts  Δ ::= · | Δ(y:A)
Ordered Contexts  Ω ::= · | Ω(z:A)

We also use N for objects and B for families. We continue our convention of syntactically distinguishing unrestricted, linear and ordered assumptions. Thus, like LLF, only unrestricted assumptions may appear in families and kinds since Πs only bind unrestricted variables, x.

We will employ the following judgements to define the OLF type theory.

Judgements

⊢ Σ sig  Σ is a valid signature
⊢_{Σ} Γ uctx  Γ is a valid unrestricted context
Γ ⊢_{Σ} Δ lctx Δ is a valid linear context
Γ ⊢_{Σ} Ω octx  Ω is a valid ordered context

Γ ⊢_{Σ} K : kind  K is a valid kind
Γ ⊢_{Σ} A : K  A has kind K
Γ; Δ; Ω ⊢_{Σ} M : A  M has type A
Γ ⊢_{Σ} K_{1} = K_{2} : kind  K_{1} equals K_{2}
Γ ⊢_{Σ} A_{1} = A_{2} : K  A_{1} equals A_{2} at kind K
Γ; Δ; Ω ⊢_{Σ} M_{1} = M_{2} : A M_{1} equals M_{2} at type A

We assume Σ is a valid signature in the judgement ⊢_{Σ} Γ uctx. We assume Σ is a valid signature and Γ is valid in Σ for judgements of the form Γ ⊢_{Σ} J.

13.2 Typing Rules

Signatures

\overline{⊢ · sig}     \frac{⊢ Σ sig · ⊢_{Σ} K : kind}{⊢ Σ(a:K) sig} \frac{⊢ Σ sig · ⊢_{Σ} A : type}{⊢ Σ(c:A) sig}

From this point on, we assume a valid signature, Σ, implicit in all judgements.

Contexts

                  \overline{⊢ · uctx}     \frac{⊢ Γ uctx Γ ⊢ A : type}{⊢ Γ(x:A) uctx}

\overline{Γ ⊢ · lctx}     \frac{Γ ⊢ Δ lctx Γ ⊢ A : type}{Γ ⊢ Δ(y:A) lctx}

\overline{Γ ⊢ · octx}     \frac{Γ ⊢ Ω octx Γ ⊢ A : type}{Γ ⊢ Ω(z:A) octx}

From this point on, we presuppose the validity of all contexts in judgements, rather than explicitly checking this property.

Kinds

           Γ ⊢ type : kind

Γ ⊢ A : type Γ(x:A) ⊢ K : kind Γ ⊢ Πx:A. K : kind

Families

\frac{a:K ∈ Σ}{Γ ⊢ a : K}  \frac{Γ ⊢ A : Πx:A′. K  Γ; ·; · ⊢ M : A′}{Γ ⊢ A M : K[M/x]}

\frac{Γ ⊢ A_{1} : type Γ(x:A_{1}) ⊢ A_{2} : type}{Γ ⊢ Πx:A_{1}. A_{2} : type}

\frac{Γ ⊢ A : K Γ ⊢ K = K′ : kind}{Γ ⊢ A : K′}

Objects

\frac{c:A ∈ Σ}{Γ; ·; · ⊢ c : A}  \frac{x:A ∈ Γ}{Γ; ·; · ⊢ x : A}  \overline{Γ; y:A; · ⊢ y : A}  \overline{Γ; ·; z:A ⊢ z : A}

\frac{Γ ⊢ A′ : type Γ(x:A′); Δ; Ω ⊢ M : A}{Γ; Δ; Ω ⊢ λx:A′. M : Πx:A′. A}  \frac{Γ; Δ; Ω ⊢ M : Πx:A′. A Γ; ·; · ⊢ M′ : A′}{Γ; Δ; Ω ⊢ M M′ : A[M′/x]}

\frac{Γ ⊢ A′ : type Γ; Δ(y:A′); Ω ⊢ M : A}{Γ; Δ; Ω ⊢ λ̂y:A′. M : A′ −∘ A}  \frac{Γ; Δ; Ω ⊢ M : A′ −∘ A Γ; Δ′; · ⊢ M′ : A′}{Γ; Δ ▷◁ Δ′; Ω ⊢ Mˆ M′ : A}

\frac{Γ ⊢ A′ : type Γ; Δ; Ω(z:A′) ⊢ M : A}{Γ; Δ; Ω ⊢ λ^{>}z:A′. M : A′ ↠ A}  \frac{Γ; Δ; Ω ⊢ M : A′ ↠ A Γ; Δ′; Ω′; · ⊢ M′ : A′}{Γ; Δ ▷◁ Δ′; ΩΩ′ ⊢ M^{>}M′ : A}

\frac{Γ ⊢ A′ : type Γ; Δ; (z:A′)Ω ⊢ M : A}{Γ; Δ; Ω ⊢ λ^{<}z:A′. M : A′ ↣ A}  \frac{Γ; Δ; Ω ⊢ M : A′ ↣ A Γ; Δ′; Ω′; · ⊢ M′ : A′}{Γ; Δ ▷◁ Δ′; Ω′Ω ⊢ M^{<} M′ : A}

\overline{Γ; Δ; Ω ⊢ ⟨⟩ : ⊤}  \frac{Γ; Δ; Ω ⊢ M_{1} : A_{1} Γ; Δ; Ω ⊢ M_{2} : A_{2}}{Γ; Δ; Ω ⊢ ⟨M_{1} , M_{2}⟩ : A_{1} & A_{2}}

\frac{Γ; Δ; Ω ⊢ M : A_{1} & A_{2}}{Γ; Δ; Ω ⊢ fst M : A_{1}}  \frac{Γ; Δ; Ω ⊢ M : A_{1} & A_{2}}{Γ; Δ; Ω ⊢ snd M : A_{2}}

\frac{Γ; Δ; Ω ⊢ M : A Γ ⊢ A = A′ : type}{Γ; Δ; Ω ⊢ M : A′}

13.3 Definitional Equality

In this section we define the equality judgement used in the kind conversion rule for families and the type conversion rule for objects; the last typing rules for families and objects respectively. Following [24], this equality is based on a notion of parallel conversion plus extensionality, rather than directly on βη-conversion. We do not include explicit reflexivity rules since they are admissible (Lemma 58).

Simultaneous Congruence

\frac{c:A ∈ Σ}{Γ; ·; · ⊢ c = c : A}  \frac{x:A ∈ Γ}{Γ; ·; · ⊢ x = x : A}

\overline{Γ; y:A; · ⊢ y = y : A}  \overline{Γ; ·; z:A ⊢ z = z : A}

\frac{Γ ⊢ A′_{1} = A′ : type Γ ⊢ A′_{2} = A′ : type Γ(x:A′); Δ; Ω ⊢ M = N : A}{Γ; Δ; Ω ⊢ λx:A′_{1}. M = λx:A′_{2}. N : Πx:A′. A}

\frac{Γ; Δ; Ω ⊢ M = N : Πx:A′. A Γ; ·; · ⊢ M′ = N′ : A′}{Γ; Δ; Ω ⊢ M M′ = N N′ : A[M′/x]}

\frac{Γ ⊢ A′_{1} = A′ : type Γ ⊢ A′_{2} = A′ : type Γ; Δ(y:A′); Ω ⊢ M = N : A}{Γ; Δ; Ω ⊢ λ̂y:A′_{1}. M = λ̂y:A′_{2}. N : A′ −∘ A}

\frac{Γ; Δ; Ω ⊢ M = N : A′ −∘ A Γ; Δ′; · ⊢ M′ = N′ : A′}{Γ; Δ ▷◁ Δ′; Ω ⊢ Mˆ M′ = Nˆ N′ : A}

\frac{Γ ⊢ A′_{1} = A′ : type Γ ⊢ A′_{2} = A′ : type Γ; Δ; Ω(z:A′) ⊢ M = N : A}{Γ; Δ; Ω ⊢ λ^{>}z:A′_{1}. M = λ^{>}z:A′_{2}. N : A′ ↠ A}

\frac{Γ; Δ; Ω ⊢ M = N : A′ ↠ A Γ; Δ′; Ω′ ⊢ M′ = N′ : A′}{Γ; Δ ▷◁ Δ′; ΩΩ′ ⊢ M^{>}M′ = N^{>}N′ : A}

\frac{Γ ⊢ A′_{1} = A′ : type Γ ⊢ A′_{2} = A′ : type Γ; Δ; (z:A′)Ω ⊢ M = N : A}{Γ; Δ; Ω ⊢ λ^{<}z:A′_{1}. M = λ^{<}z:A′_{2}. N : A′ ↣ A}

\frac{Γ; Δ; Ω ⊢ M = N : A′ ↣ A Γ; Δ′; Ω′ ⊢ M′ = N′ : A′}{Γ; Δ ▷◁ Δ′; Ω′Ω ⊢ M^{<} M′ = N^{<} N′ : A}

\frac{Γ; Δ; Ω ⊢ M_{1} = N_{1} : A_{1} Γ; Δ; Ω ⊢ M_{2} = N_{2} : A_{2}}{Γ; Δ; Ω ⊢ ⟨M_{1} , M_{2}⟩ = ⟨N_{1} , N_{2}⟩ : A_{1} & A_{2}}

\frac{Γ; Δ; Ω ⊢ M = N : A_{1} & A_{2}}{Γ; Δ; Ω ⊢ fst M = fst N : A_{1}}  \frac{Γ; Δ; Ω ⊢ M = N : A_{1} & A_{2}}{Γ; Δ; Ω ⊢ snd M = snd N : A_{2}}

Extensionality

\frac{Γ ⊢ A′ : type Γ; Δ; Ω ⊢ M : Πx:A′. A Γ; Δ; Ω ⊢ N : Πx:A′. A Γ(x:A′); Δ; Ω ⊢ M x = N x : A}{Γ; Δ; Ω ⊢ M = N : Πx:A′. A}

\frac{Γ ⊢ A′ : type \begin{matrix}Γ; Δ; Ω ⊢ M : A′ −∘ A \\ Γ; Δ; Ω ⊢ N : A′ −∘ A \end{matrix} Γ; Δ(y:A′); Ω ⊢ Mˆ y = Nˆ y : A}{Γ; Δ; Ω ⊢ M = N : A′ −∘ A}

\frac{Γ ⊢ A′ : type \begin{matrix}Γ; Δ; Ω ⊢ M : A′ ↠ A \\ Γ; Δ; Ω ⊢ N : A′ ↠ A \end{matrix} Γ; Δ; Ω(z:A′) ⊢ M^{>}z = N^{>}z : A}{Γ; Δ; Ω ⊢ M = N : A′ ↠ A}

\frac{Γ ⊢ A′ : type \begin{matrix}Γ; Δ; Ω ⊢ M : A′ ↣ A \\ Γ; Δ; Ω ⊢ N : A′ ↣ A \end{matrix} Γ; Δ; (z:A′)Ω ⊢ M^{<} z = N^{<} z : A}{Γ; Δ; Ω ⊢ M = N : A′ ↣ A}

\frac{\begin{matrix}Γ; Δ; Ω ⊢ M : A_{1} & A_{2} \\ Γ; Δ; Ω ⊢ N : A_{1} & A_{2} \end{matrix} Γ; Δ; Ω ⊢ fst M = fst N : A_{1} Γ; Δ; Ω ⊢ snd M = snd N : A_{2}}{Γ; Δ; Ω ⊢ M = N : A_{1} & A_{2}}

\frac{Γ; Δ; Ω ⊢ M : ⊤ Γ; Δ; Ω ⊢ N : ⊤}{Γ; Δ; Ω ⊢ M = N : ⊤}

Parallel Conversion

\frac{Γ ⊢ A′ : type Γ(x:A′); Δ; Ω ⊢ M = N : A Γ; ·; · ⊢ M′ = N′ : A′}{Γ; Δ; Ω ⊢ (λx:A′. M) M′ = N[N′/x] : A[N′/x]}

\frac{Γ ⊢ A′ : type Γ; Δ(y:A′); Ω ⊢ M = N : A Γ; Δ′; · ⊢ M′ = N′ : A′}{Γ; Δ ▷◁ Δ′; Ω ⊢ (λ̂y:A′. M)ˆ M′ = N[N′/y] : A}

\frac{Γ ⊢ A′ : type Γ; Δ; Ω(z:A′) ⊢ M = N : A Γ; Δ′; Ω′ ⊢ M′ = N′ : A′}{Γ; Δ ▷◁ Δ′; ΩΩ′ ⊢ (λ^{>}z:A′. M)^{>}M′ = N[N′/z] : A}

\frac{Γ ⊢ A′ : type Γ; Δ; (z:A′)Ω ⊢ M = N : A Γ; Δ′; Ω′ ⊢ M′ = N′ : A′}{Γ; Δ ▷◁ Δ′; Ω′Ω ⊢ (λ^{<}z:A′. M)^{<} M′ = N[N′/z] : A}

\frac{Γ; Δ; Ω ⊢ M_{1} = N_{1} : A_{1} Γ; Δ; Ω ⊢ M_{2} = N_{2} : A_{2}}{Γ; Δ; Ω ⊢ fst ⟨M_{1} , M_{2}⟩ = N_{1} : A_{1}}

\frac{Γ; Δ; Ω ⊢ M_{1} = N_{1} : A_{1} Γ; Δ; Ω ⊢ M_{2} = N_{2} : A_{2}}{Γ; Δ; Ω ⊢ snd ⟨M_{1} , M_{2}⟩ = N_{2} : A_{2}}

Equivalence

\frac{Γ; Δ; Ω ⊢ M = N : A}{Γ; Δ; Ω ⊢ N = M : A}  \frac{Γ; Δ; Ω ⊢ M = M′ : A Γ; Δ; Ω ⊢ M′ = N : A}{Γ; Δ; Ω ⊢ M = N : A}

Type Conversion

\frac{Γ; Δ; Ω ⊢ M = N : A Γ ⊢ A = A′ : type}{Γ; Δ; Ω ⊢ M = N : A′}

Family Congruence

\frac{a:K ∈ Σ}{Γ ⊢ a = a : K}

\frac{Γ ⊢ A_{1} = A_{2} : Πx:A′. K Γ; ·; · ⊢ M_{1} = M_{2} : A′}{Γ ⊢ A_{1} M_{1} = A_{2} M_{2} : K[N_{1}/x]}

\frac{Γ ⊢ A′_{1} : type Γ ⊢ A′_{1} = A′_{2} : type Γ(x:A′_{1}) ⊢ A_{1} = A_{2} : type}{Γ ⊢ Πx:A′_{1}. A_{1} = Πx:A′_{2}. A_{2} : type}

\frac{Γ ⊢ A′_{1} = A′_{2} : type Γ ⊢ A_{1} = A_{2} : type}{Γ ⊢ A′_{1} −∘ A_{1} = A′_{2} −∘ A_{2} : type}

\frac{Γ ⊢ A′_{1} = A′_{2} : type Γ ⊢ A_{1} = A_{2} : type}{Γ ⊢ A′_{1} ↠ A_{1} = A′_{2} ↠ A_{2} : type}

\frac{Γ ⊢ A′_{1} = A′_{2} : type Γ ⊢ A_{1} = A_{2} : type}{Γ ⊢ A′_{1} ↣ A_{1} = A′_{2} ↣ A_{2} : type}

\frac{Γ ⊢ A′_{1} = A′_{2} : type Γ ⊢ A_{1} = A_{2} : type}{Γ ⊢ A′_{1} & A_{1} = A′_{2} & A_{2} : type}

\overline{Γ ⊢ ⊤ = ⊤ : type}

Family Equivalence

\frac{Γ ⊢ A_{1} = A_{2} : K}{Γ ⊢ A_{2} = A_{1} : K}  \frac{Γ ⊢ A_{1} = A′_{1} : K  Γ ⊢ A′_{1} = A_{2} : K}{Γ ⊢ A_{1} = A_{2} : K}

Kind Conversion

\frac{Γ ⊢ A_{1} = A_{2} : K Γ ⊢ K = K′ : kind}{Γ ⊢ A_{1} = A_{2} : K′}

Kind Congruence

                        Γ ⊢ type = type : kind

\frac{Γ ⊢ A_{1} : type Γ ⊢ A_{1} = A_{2} : type Γ(x:A_{1}) ⊢ K_{1} = K_{2} : kind}{Γ ⊢ Πx:A_{1}. K_{1} = Πx:A_{2}. K_{2} : kind}

Kind Equivalence

\frac{Γ ⊢ K_{1} = K_{2} : kind}{Γ ⊢ K_{2} = K_{1} : kind}     \frac{Γ ⊢ K_{1} = K′_{1} : kind Γ ⊢ K′_{1} = K_{2} : kind}{Γ ⊢ K_{1} = K_{2} : kind}

13.4 Properties of Typing and Equality

We show some basic properties of definitional equality. We use J to stand for any judgement of the type theory to avoid some repetitive statements. Substitution is extended to J in the obvious way; for example if J is N : B, then J[M/x] is N[M/x] : B[M/x].

Lemma 57 (Weakening)

1. ΓΓ′ ⊢ J implies Γ(x:A)Γ′ ⊢ J.

2. ΓΓ′; Δ; Ω ⊢ J implies Γ(x:A)Γ′; Δ; Ω ⊢ J.

Proof: By induction on the structure of the given derivation. □

Lemma 58 (Reflexivity)

1. Γ; Δ; Ω ⊢ M : A implies Γ; Δ; Ω ⊢ M = M : A.

2. Γ ⊢ A : K implies Γ ⊢ A = A : K.

3. Γ ⊢ K : kind implies Γ ⊢ K = K : kind. Proof: By induction on the structure of the given derivation. □ Lemma 59 (Substitution Property)

Assume all contexts are valid.

1. Γ; ·; · ⊢ M : A and Γ(x:A)Γ′ ⊢ J implies Γ(Γ′[M/x]) ⊢ J[M/x].

2. Γ; ·; · ⊢ M : A and Γ(x:A)Γ′; Δ; Ω ⊢ J implies Γ(Γ′[M/x]); Δ[M/x]; Ω[M/x] ⊢ J[M/x].

3. Γ; Δ′; · ⊢ M : A and Γ; Δ_{1}(y:A)Δ_{2}; Ω ⊢ J implies Γ; (Δ_{1} ▷◁ Δ′)Δ_{2}; Ω ⊢ J[M/y].

4. Γ; Δ′; Ω′ ⊢ M : A and Γ; Δ; Ω_{1}(z:A)Ω_{2} ⊢ J implies

Γ; Δ ▷◁ Δ′; Ω_{1}Ω′Ω_{2} ⊢ J[M/z].

Proof: By induction on the structure of the given derivation. □ Lemma 60 (Context Conversion)

Assume ⊢ Γ(x:A) uctx and Γ ⊢ A′ : type and Γ ⊢ A = A′ : type.

1. Γ(x:A) ⊢ J implies Γ(x:A′) ⊢ J.

2. Γ(x:A); Δ; Ω ⊢ J implies Γ(x:A′); Δ; Ω ⊢ J. Proof: By Lemmas 57 and 59. □

A stronger version of the next lemma which includes equality judgements is required. However, that must be postponed until after Lemma 63. For now we state the following weaker version which we use in the proof of Lemma 63. Lemma 61 (Functionality for Typing)

Assume ⊢ Γ(x:A)Γ′ uctx and Γ; ·; · ⊢ M = M′ : A and Γ; ·; · ⊢ M : A and Γ; ·; · ⊢ M′ : A.

1. Γ(x:A)Γ′; Δ; Ω ⊢ N : B implies Γ(Γ′[M/x]); Δ[M/x]; Ω[M/x] ⊢ N[M/x] = N[M′/x] : B[M/x].

2. Γ(x:A)Γ′ ⊢ B : K implies Γ(Γ′[M/x]) ⊢ B[M/x] = B[M′/x] : K[M/x].

3. Γ(x:A)Γ′ ⊢ K : kind implies Γ(Γ′[M/x]) ⊢ K[M/x] = K[M′/x] : kind. Proof: By induction on the structure of the given derivation. □

Again we postpone a stronger version of the next lemma until after Lemma 63. Lemma 62 (Inversion on Simple Types and Kinds)

1. Γ ⊢ Πx:A_{1}. A_{2} : K implies Γ ⊢ A_{1} : type and Γ(x:A_{1}) ⊢ A_{2} : type.

2. Γ ⊢ A_{1} −∘ A_{2} : K implies Γ ⊢ A_{1} : type and Γ ⊢ A_{2} : type.

3. Γ ⊢ A_{1} ↠ A_{2} : K implies Γ ⊢ A_{1} : type and Γ ⊢ A_{2} : type.

4. Γ ⊢ A_{1} ↣ A_{2} : K implies Γ ⊢ A_{1} : type and Γ ⊢ A_{2} : type.

5. Γ ⊢ A_{1} & A_{2} : K implies Γ ⊢ A_{1} : type and Γ ⊢ A_{2} : type.

6. Γ ⊢ Πx:A. K : kind implies Γ ⊢ A : type and Γ(x:A) ⊢ K : kind. Proof: Parts 1 through 5 by induction on the structure of the given derivation. Part 6 is immediate. □ Lemma 63 (Validity)

Assume ⊢ Γ uctx and Γ ⊢ Δ lctx and Γ ⊢ Ω octx.

1. Γ; Δ; Ω ⊢ M : A implies Γ ⊢ A : type.

2. Γ; Δ; Ω ⊢ M = N : A implies Γ ⊢ A : type and Γ; Δ; Ω ⊢ M : A and Γ; Δ; Ω ⊢ N : A.

3. Γ ⊢ A : K implies Γ ⊢ K : kind.

4. Γ ⊢ A = B : K implies Γ ⊢ K : kind and Γ ⊢ A : K and Γ ⊢ B : K.

5. Γ ⊢ K = K′ : kind implies Γ ⊢ K : kind and Γ ⊢ K′ : kind.

Proof: By induction on the structure of the given derivation making use of Lemmas 61 and 62. □ Lemma 64 (Functionality for Equality)

Assume ⊢ Γ(x:A) uctx and Γ(x:A) ⊢ Δ lctx and Γ(x:A) ⊢ Ω octx and Γ; ·; · ⊢ M = M′ : A.

1. Γ(x:A); Δ; Ω ⊢ N = N′ : B implies Γ; Δ[M/x]; Ω[M/x] ⊢ N[M/x] = N′[M′/x] : B[M/x].

2. Γ(x:A) ⊢ A = B : K implies Γ ⊢ A[M/x] = B[M′/x] : K[M/x].

3. Γ(x:A) ⊢ K = K′ : kind implies Γ ⊢ K[M/x] = K′[M′/x] : kind. Proof: By Lemmas 63, 59 and 61. □ Lemma 65 (Typing Inversion)

Assume ⊢ Γ uctx and Γ ⊢ Δ lctx and Γ ⊢ Ω octx.

1. Γ; Δ; Ω ⊢ c:A implies Δ = · = Ω and c:B ∈ Σ and Γ ⊢ A = B : type.

2. Γ; Δ; Ω ⊢ x : A implies Δ = · = Ω and x:B ∈ Γ and Γ ⊢ A = B : type.

3. Γ; Δ; Ω ⊢ y : A implies Δ = y:B and Ω = · and Γ ⊢ A = B : type.

4. Γ; Δ; Ω ⊢ z : A implies Δ = · and Ω = y:B and Γ ⊢ A = B : type.

5. Γ; Δ; Ω ⊢ M_{1} M_{2} : A implies Γ; Δ; Ω ⊢ M_{1} : Πx:A_{2}. A_{1} and Γ; ·; · ⊢ M_{2} : A_{2} and Γ ⊢ A_{1}[M_{2}/x] = A : type.

6. Γ; Δ; Ω ⊢ λx:A. M : B implies Γ ⊢ B = Πx:A. A′ : type and Γ ⊢ A : type and Γ(x:A); Δ; Ω ⊢ M : A′.

7. Γ; Δ; Ω ⊢ M_{1}ˆ M_{2} : A implies Δ = Δ_{1} ▷◁ Δ_{2} and Γ ⊢ A_{1} = A : type and Γ; Δ_{1}; Ω ⊢ M_{1} : A_{2} −∘ A_{1} and Γ; Δ_{2}; · ⊢ M_{2} : A_{2}.

8. Γ; Δ; Ω ⊢ λ̂y:A. M : B implies Γ ⊢ B = A −∘ A′ : type and Γ ⊢ A : type and Γ; Δ(y:A); Ω ⊢ M : A′.

9. Γ; Δ; Ω ⊢ M_{1}^{>}M_{2} : A implies Δ = Δ_{1} ▷◁ Δ_{2} and Ω = Ω_{1}Ω_{2} and Γ ⊢ A_{1} = A : type and Γ; Δ_{1}; Ω_{1} ⊢ M_{1} : A_{2} ↠ A_{1} and Γ; Δ_{2}; Ω_{2} ⊢ M_{2} : A_{2}.

10. Γ; Δ; Ω ⊢ λ^{>}z:A. M : B implies Γ ⊢ B = A ↠ A′ : type and Γ ⊢ A : type and Γ; Δ; Ω(z:A) ⊢ M : A′.

11. Γ; Δ; Ω ⊢ M_{1}^{<} M_{2} : A implies Δ = Δ_{1} ▷◁ Δ_{2} and Ω = Ω_{2}Ω_{1} and Γ ⊢ A_{1} = A : type and Γ; Δ_{1}; Ω_{1} ⊢ M_{1} : A_{2} ↣ A_{1} and Γ; Δ_{2}; Ω_{2} ⊢ M_{2} : A_{2}.

12. Γ; Δ; Ω ⊢ λ^{<}z:A. M : B implies Γ ⊢ B = A ↣ A′ : type and Γ ⊢ A : type and Γ; Δ; (z:A)Ω ⊢ M : A′.

13. Γ; Δ; Ω ⊢ fst M : A implies Γ; Δ; Ω ⊢ M : A_{1} & A_{2} and Γ ⊢ A = A_{1} : type.

14. Γ; Δ; Ω ⊢ snd M : A implies Γ; Δ; Ω ⊢ M : A_{1} & A_{2} and Γ ⊢ A = A_{2} : type.

15. Γ; Δ; Ω ⊢ ⟨M_{1} , M_{2}⟩ : A implies Γ ⊢ A = A_{1} & A_{2} : type and Γ; Δ; Ω ⊢ M_{1} : A_{1} and Γ; Δ; Ω ⊢ M_{2} : A_{2}.

16. Γ ⊢ a : K implies a:K′ ∈ Σ and Γ ⊢ K = K′ : kind.

17. Γ ⊢ A M : K implies Γ ⊢ A : Πx:A_{1}. K′ and Γ; ·; · ⊢ M : A_{1} and Γ ⊢ K = K′[M/x] : kind.

18. Γ ⊢ Πx:A. B : K implies Γ ⊢ K = type : kind and Γ ⊢ A : type and Γ(x:A) ⊢ B : type.

19. Γ ⊢ A −∘ B : K implies Γ ⊢ K = type : kind and Γ ⊢ A : type and Γ ⊢ B : type.

20. Γ ⊢ A ↠ B : K implies Γ ⊢ K = type : kind and Γ ⊢ A : type and Γ ⊢ B : type.

21. Γ ⊢ A ↣ B : K implies Γ ⊢ K = type : kind and Γ ⊢ A : type and Γ ⊢ B : type.

22. Γ ⊢ A & B : K implies Γ ⊢ K = type : kind and Γ ⊢ A : type and Γ ⊢ B : type.

23. Γ ⊢ ⊤ : K implies Γ ⊢ K = type : kind.

24. Γ ⊢ Πx:A. K : kind implies Γ ⊢ A : type and Γ(x:A) ⊢ K : kind.

Proof: By induction on structure of given derivation using Lemma 63. □

Lemma 66 (Equality Inversion)

Assume ⊢ Γ uctx.

1. Γ ⊢ K = type : kind or Γ ⊢ type = K : kind

implies K = type.

2. Γ ⊢ K = Πx:A_{1}. K_{1} : kind or Γ ⊢ Πx:A_{1}. K_{1} = K : kind

implies K = Πx:A_{2}. K_{2} and Γ ⊢ A_{1} = A_{2} : type and

Γ(x:A_{1}) ⊢ K_{1} = K_{2} : kind.

3. Γ ⊢ A = Πx:B_{1}. B_{2} : type or Γ ⊢ Πx:B_{1}. B_{2} = A : type

implies A = Πx:A_{1}. A_{2} and Γ ⊢ A_{1} = B_{1} : type and

Γ(x:A_{1}) ⊢ A_{2} = B_{2} : type.

4. Γ ⊢ A = B_{1} −∘ B_{2} : type or Γ ⊢ B_{1} −∘ B_{2} = A : type implies A = A_{1} −∘ A_{2} and Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

5. Γ ⊢ A = B_{1} ↠ B_{2} : type or Γ ⊢ B_{1} ↠ B_{2} = A : type implies A = A_{1} ↠ A_{2} and Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

6. Γ ⊢ A = B_{1} ↣ B_{2} : type or Γ ⊢ B_{1} ↣ B_{2} = A : type implies A = A_{1} ↣ A_{2} and Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

7. Γ ⊢ A = B_{1} & B_{2} : type or Γ ⊢ B_{1} & B_{2} = A : type implies A = A_{1} & A_{2} and Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

Proof: By induction on structure of given derivation using Lemma 60. □

Lemma 67 (Injectivity)

1. Γ ⊢ Πx:A. K = Πx:A′. K′ : kind implies Γ ⊢ A = A′ : type and Γ(x:A) ⊢ K = K′ : kind.

2. Γ ⊢ Πx:A_{1}. A_{2} = Πx:B_{1}. B_{2} : type implies Γ ⊢ A_{1} = B_{1} : type and Γ(x:A_{1}) ⊢ A_{2} = B_{2} : type.

3. Γ ⊢ A_{1} −∘ A_{2} = B_{1} −∘ B_{2} : type implies Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

4. Γ ⊢ A_{1} ↠ A_{2} = B_{1} ↠ B_{2} : type implies Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

5. Γ ⊢ A_{1} ↣ A_{2} = B_{1} ↣ B_{2} : type implies Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

6. Γ ⊢ A_{1} & A_{2} = B_{1} & B_{2} : type implies Γ ⊢ A_{1} = B_{1} : type and Γ ⊢ A_{2} = B_{2} : type.

Proof: Immediate from Lemma 66. □

At this point, we have stated all the properties we shall need to carry out our proof. The next chapter introduces a different notion for equality which is obviously decidable. We shall show that the two equalities coincide and thus prove decidablity of type-checking in general for OLF.

Algorithmic Equality

In this chapter we present an equality algorithm which is sound and complete with respect to definitional equality of Section 13.3. We further show the decidability of this equality procedure in Chapter 15. The algorithm is identical to that given in [59] with a trivial extension to cover ordered types (which are treated identically to linear types). As explained in [24] the algorithm consists of two stages. To compare two objects at some arbitrary type, we first reduce the comparison to objects of base type by applying extensionality rules. Then, to compare objects at base type, we reduce each object to weak head normal form and compare heads. If the heads are equal we continue on to compare the corresponding arguments.

The algorithm is type-directed and thus requires types to be carried along. However, this complicates the treatment of dependent types. The solution proposed in [24] avoids such complications by using a simplified type structure which only contains information about the shape of the object (e.g., it is a function, it is a pair); which is really all that is necessary to parametrically apply extensionality rules and transform a comparison at arbitrary type to one at base type. In practice this simply means changing Π families into (non-dependent) → types and erasing the object (family) dependencies from Π families (kinds).

The context splittings required by the definitional equality judgements further complicate the correctness of the algorithm. However, as noted in [59], the linearity constraints upon objects may be ignored for the purposes of equality checking (assuming we know beforehand that the objects being compared are well-typed). The same holds for the ordering constraints upon objects. Therefore our simplified type structure will treat all assumptions as unrestricted. However, in order to not complicate substitution, we maintain the syntactical distinctions among variable names.

Here is the formal specification of the simplified type system:

Simple Kinds  κ ::= type^{−} | τ → κ
Simple Types  τ ::= α |
τ_{1} → τ_{2} | τ_{1} −∘ τ_{2} |
τ_{1} ↠ τ_{2} | τ_{1} ↣ τ_{2} |
τ_{1} & τ_{2} | ⊤
Simple Contexts Ψ ::= · | Ψ(x:τ) | Ψ(y:τ) | Ψ(z:τ)

Note that the simplified types are exactly the canonical types in Chapter 12.

We sometimes use Θ for simple contexts. Note that simplified contexts may contain variables of all three syntactic forms– however, as we shall see, simplified contexts treat all variables as unrestricted. We assume a simple base type a^{−} for each constant family a.

We now state an erasure function which simplifies OLF constructs.

                            (kind)^{−} = kind^{−}

(Πx:A. K)^{−} = A^{−} → K^{−}

                            (type)^{−} = type^{−}

(a)^{−} = a^{−}
(A M)^{−} = A^{−}
(Πx:A_{1}. A_{2})^{−} = A_{1}^{−} → A_{2}^{−}
(A_{1} −∘ A_{2})^{−} = A_{1}^{−} −∘ A_{2}^{−}
(A_{1} ↠ A_{2})^{−} = A_{1}^{−} ↠ A_{2}^{−}
(A_{1} ↣ A_{2})^{−} = A_{1}^{−} ↣ A_{2}^{−}
(A_{1} & A_{2})^{−} = A_{1}^{−} & A_{2}^{−}
(⊤)^{−} = ⊤
(·)^{−} = ·
(Γ(x:A))^{−} = Γ^{−}(x:A^{−})
(Δ(y:A))^{−} = Δ^{−}(y:A^{−})
(Ω(z:A))^{−} = Ω^{−}(z:A^{−})

Erasure remains invariant under equality and substitution.

Lemma 68 (Erasure Preservation)

1. Γ ⊢ A_{1} = A_{2} : K implies A_{1}^{−} = A_{2}^{−}.

2. Γ ⊢ K_{1} = K_{2} : kind implies K_{1}^{−} = K_{2}^{−}.

3. Γ(x:A) ⊢ B : K implies B^{−} = B^{−}[M/x].

4. Γ(x:A) ⊢ K : kind implies K^{−} = K^{−}[M/x].

Proof: By structural induction on the given derivation. □

Here are the judgements for the equality algorithm:

M ⟶^{whr} M′ M weak head reduces to M’
Ψ ⊢ M ⟷ N : τ  M is structurally equal to N.
Ψ ⊢ M ⟺ N : τ  M equals N at simple type τ.

Ψ ⊢ A_{1} ⟷ A_{2} : κ A_{1} is structurally equal to A_{2}.
Ψ ⊢ A_{1} ⟺ A_{2} : κ A_{1} equals A_{2} at simple kind κ.

Ψ ⊢ K_{1} ⟺ K_{2} : kind^{−} Kind K_{1} equals kind K_{2}.

For weak head reduction, M ⟶^{whr} M′ we assume M is given and compute M′ or fail. For structural equality, Ψ ⊢ M ⟷ N : τ we assume Ψ, M, and N are given and compute τ or fail. Algorithmic equality, Ψ ⊢ M ⟺ N : τ, simply checks for equality and succeeds or fails. The same interpretations hold for the analogous judgements on families and kinds.

Weak Head Reduction

\overline{(λx:A. M) N ⟶^{whr} M[N/x]}  \frac{M ⟶^{whr} M′}{M N ⟶^{whr} M′ N}

\overline{(λ̂y:A. M)ˆ N ⟶^{whr} M[N/y]}  \frac{M ⟶^{whr} M′}{Mˆ N ⟶^{whr} M′ˆ N}

\overline{(λ^{<}z:A. M)^{<} N ⟶^{whr} M[N/z]}  \frac{M ⟶^{whr} M′}{M^{<} N ⟶^{whr} M′^{<} N}

\overline{(λ^{>}z:A. M)^{>}N ⟶^{whr} M[N/z]}  \frac{M ⟶^{whr} M′}{M^{>}N ⟶^{whr} M′^{>}N}

\overline{fst ⟨M , N⟩ ⟶^{whr} M}  \frac{M ⟶^{whr} M′}{⟨M , N⟩ ⟶^{whr} ⟨M′ , N⟩}

\overline{snd ⟨M , N⟩ ⟶^{whr} N}  \frac{N ⟶^{whr} N′}{⟨M , N⟩ ⟶^{whr} ⟨M , N′⟩}

Structural Object Equality We use u to stand for any syntactic variable class, i.e., x or y or z.

\frac{u:τ ∈ Ψ}{Ψ ⊢ u ⟷ u : τ}  \frac{c:τ ∈ Σ}{Ψ ⊢ c ⟷ c : A^{−}}

\frac{Ψ ⊢ M_{1} ⟷ N_{1} : τ_{2} → τ_{1} Ψ ⊢ M_{2} ⟺ N_{2} : τ_{2}}{Ψ ⊢ M_{1} M_{2} ⟷ N_{1} N_{2} : τ_{1}}

\frac{Ψ ⊢ M_{1} ⟷ N_{1} : τ_{2} −∘ τ_{1} Ψ ⊢ M_{2} ⟺ N_{2} : τ_{2}}{Ψ ⊢ M_{1}ˆ M_{2} ⟷ N_{1}ˆ N_{2} : τ_{1}}

\frac{Ψ ⊢ M_{1} ⟷ N_{1} : τ_{2} ↠ τ_{1} Ψ ⊢ M_{2} ⟺ N_{2} : τ_{2}}{Ψ ⊢ M_{1}^{>}M_{2} ⟷ N_{1}^{>}N_{2} : τ_{1}}

\frac{Ψ ⊢ M_{1} ⟷ N_{1} : τ_{2} ↣ τ_{1} Ψ ⊢ M_{2} ⟺ N_{2} : τ_{2}}{Ψ ⊢ M_{1}^{<} M_{2} ⟷ N_{1}^{<} N_{2} : τ_{1}}

\frac{Ψ ⊢ M ⟷ M′ : τ_{1} & τ_{2}}{Ψ ⊢ fst M ⟷ fst M′ : τ_{1}}  \frac{Ψ ⊢ M ⟷ M′ : τ_{1} & τ_{2}}{Ψ ⊢ snd M ⟷ snd M′ : τ_{2}}

Type-Directed Object Equality

\frac{M ⟶^{whr} M′ Ψ ⊢ M′ ⟺ N : α}{Ψ ⊢ M ⟺ N : α}  \frac{N ⟶^{whr} N′ Ψ ⊢ M ⟺ N′ : α}{Ψ ⊢ M ⟺ N : α}

\frac{Ψ ⊢ M ⟷ N : α}{Ψ ⊢ M ⟺ N : α}

\frac{Ψ(x:τ_{1}) ⊢ M x ⟺ N x : τ_{2}}{Ψ ⊢ M ⟺ N : τ_{1} → τ_{2}}  \frac{Ψ(y:τ_{1}) ⊢ Mˆ y ⟺ Nˆ y : τ_{2}}{Ψ ⊢ M ⟺ N : τ_{1} −∘ τ_{2}}

\frac{Ψ(z:τ_{1}) ⊢ M^{>}z ⟺ N^{>}z : τ_{2}}{Ψ ⊢ M ⟺ N : τ_{1} ↠ τ_{2}}  \frac{Ψ(z:τ_{1}) ⊢ M^{<} z ⟺ N^{<} z : τ_{2}}{Ψ ⊢ M ⟺ N : τ_{1} ↣ τ_{2}}

\overline{Ψ ⊢ M ⟺ N : ⊤}  \frac{Ψ ⊢ fst M ⟺ fst N : τ_{1} Ψ ⊢ snd M ⟺ snd N : τ_{2}}{Ψ ⊢ M ⟺ N : τ_{1} & τ_{2}}

Structural Family Equality

\frac{a:K ∈ Σ}{Ψ ⊢ a ⟷ a : K^{−}}  \frac{Ψ ⊢ A ⟷ B : τ → κ Ψ ⊢ M ⟺ N : τ}{Ψ ⊢ A M ⟷ B N : κ}

Kind-Directed Family Equality

\frac{Ψ ⊢ A ⟷ B : type^{−}}{Ψ ⊢ A ⟺ B : type^{−}}  \frac{Ψ(x:τ) ⊢ A x ⟺ B x : κ}{Ψ ⊢ A ⟺ B : τ → κ}

\frac{Ψ ⊢ A_{1} ⟺ B_{1} : type^{−} Ψ(x:A_{1}^{−}) ⊢ A_{2} ⟺ B_{2} : type^{−}}{Ψ ⊢ Πx:A_{1}. A_{2} ⟺ Πx:B_{1}. B_{2} : type^{−}}

\frac{Ψ ⊢ A_{1} ⟺ B_{1} : type^{−} Ψ ⊢ A_{2} ⟺ B_{2} : type^{−}}{Ψ ⊢ A_{1} −∘ A_{2} ⟺ B_{1} −∘ B_{2} : type^{−}}

\frac{Ψ ⊢ A_{1} ⟺ B_{1} : type^{−} Ψ ⊢ A_{2} ⟺ B_{2} : type^{−}}{Ψ ⊢ A_{1} ↠ A_{2} ⟺ B_{1} ↠ B_{2} : type^{−}}

\frac{Ψ ⊢ A_{1} ⟺ B_{1} : type^{−} Ψ ⊢ A_{2} ⟺ B_{2} : type^{−}}{Ψ ⊢ A_{1} ↣ A_{2} ⟺ B_{1} ↣ B_{2} : type^{−}}

\overline{Ψ ⊢ ⊤ ⟺ ⊤ : type^{−}}  \frac{Ψ ⊢ A_{1} ⟺ B_{1} : type^{−} Ψ ⊢ A_{2} ⟺ B_{2} : type^{−}}{Ψ ⊢ A_{1} & A_{2} ⟺ B_{1} & B_{2} : type^{−}}

Algorithmic Kind Equality

                     Ψ ⊢ type^{−} ⟺ type^{−} : kind^{−}

\frac{Ψ ⊢ A ⟺ B : type^{−} Ψ(x:A^{−}) ⊢ K ⟺ K′ : kind^{−}}{Ψ ⊢ Πx:A. K ⟺ Πx:B. K′ : kind^{−}}

We now state some basic properties of our equality derivations. Lemma 69 (Weakening for Algorithmic Equality)

For each algorithmic equality judgement J,

ΨΨ′ ⊢ J implies Ψ(x:τ)Ψ′ ⊢ J. Proof: By structural induction on the given derivation. □ Lemma 70 (Determinacy of Algorithmic Equality)

1. M ⟶^{whr} M′ and M ⟶^{whr} M′′ implies M′ = M′′.

2. Ψ ⊢ M ⟷ N : τ implies there is no M′ s.t. M ⟶^{whr} M′.

3. Ψ ⊢ M ⟷ N : τ implies there is no N′ s.t. N ⟶^{whr} N′.

4. Ψ ⊢ M ⟷ N : τ and Ψ ⊢ M ⟷ N : τ′ implies τ = τ′.

5. Ψ ⊢ A ⟷ B : κ and Ψ ⊢ A ⟷ B : κ′ implies κ = κ′. Proof: By structural induction on the given derivation. Parts 2 and 3 may be proved by contradiction using inversion on the structural equality inference rules. □

Lemma 71 (Symmetry of Algorithmic Equality)

1. Ψ ⊢ M ⟺ N : τ implies Ψ ⊢ N ⟺ M : τ.

2. Ψ ⊢ M ⟷ N : τ implies Ψ ⊢ N ⟷ M : τ.

3. Ψ ⊢ A ⟺ B : κ implies Ψ ⊢ B ⟺ A : κ.

4. Ψ ⊢ A ⟷ B : κ implies Ψ ⊢ B ⟷ A : κ.

5. Ψ ⊢ K ⟺ K′ : kind^{−} implies Ψ ⊢ K′ ⟺ K : kind^{−}. Proof: By structural induction on the given derivations. □ Lemma 72 (Transitivity of Algorithmic Equality)

1. Ψ ⊢ M ⟺ M′ : τ and Ψ ⊢ M′ ⟺ N : τ implies Ψ ⊢ M ⟺ N : τ.

2. Ψ ⊢ M ⟷ M′ : τ and Ψ ⊢ M′ ⟷ N : τ implies Ψ ⊢ M ⟷ N : τ.

3. Ψ ⊢ A ⟺ A′ : κ and Ψ ⊢ A′ ⟺ B : κ implies Ψ ⊢ A ⟺ B : κ.

4. Ψ ⊢ A ⟷ A′ : κ and Ψ ⊢ A′ ⟷ B : κ implies Ψ ⊢ A ⟷ B : κ.

5. Ψ ⊢ K ⟺ K′ : kind^{−} and Ψ ⊢ K′ ⟺ K′′ : kind^{−} implies

Ψ ⊢ K ⟺ K′′ : kind^{−}.

Proof: By structural induction on the given derivations using Lemma 70. □

14.1 Completeness of Algorithmic Equality

In this section we show that algorithmic equality is complete with respect to definitional equality. The formal theorem we will show is:

Γ; Δ; Ω ⊢ M = N : A implies Γ^{−}Δ^{−}Ω^{−} ⊢ M ⟺ N : A^{−}

This is proved via logical relations defined on the simplified type of an object. Thus we will show:

1. Γ; Δ; Ω ⊢ M = N : A implies Γ^{−}Δ^{−}Ω^{−} ⊢ M = N ∈ [[A^{−}]] 2. Ψ ⊢ M = N ∈ [[A^{−}]] implies Ψ ⊢ M ⟺ N : A^{−}

We use σ (and sometimes θ) to stand for substitutions.

Substitutions σ ::= · | σ, M/x | σ, M/y | σ, M/z

We assume as usual that no variable occurs more than once in a substitution. We further assume tacit variable renaming takes place when necessary to maintain this constraint. We denote the application of a substitution, σ, to a term, M, with σ(M). We also assume parameterized identity substitutions, id_{x}, on any context x.

We use the notation Ψ′ ≥ Ψ to denote that Ψ′ contains all declarations in Ψ and possibly more.

We define a Kripke logical relation inductively on simple types. As usual, we require that the property we wish to prove holds at base type. At higher types the property is inductively maintained.

A Kripke Logical Relation

1. Ψ ⊢ M = N ∈ [[α]] iff Ψ ⊢ M ⟺ N : α.

2. Ψ ⊢ M = N ∈ [[τ′ → τ]] iff ∀Ψ′, M′, N′.

Ψ′ ≥ Ψ and Ψ′ ⊢ M′ ⟺ N′ ∈ [[τ′]] implies Ψ′ ⊢ M M′ ⟺ N N′ ∈ [[τ]].

3. Ψ ⊢ M = N ∈ [[τ′ −∘ τ]] iff ∀Ψ′, M′, N′.

Ψ′ ≥ Ψ and Ψ′ ⊢ M′ ⟺ N′ ∈ [[τ′]] implies Ψ′ ⊢ Mˆ M′ ⟺ Nˆ N′ ∈ [[τ]].

4. Ψ ⊢ M = N ∈ [[τ′ ↠ τ]] iff ∀Ψ′, M′, N′.

Ψ′ ≥ Ψ and Ψ′ ⊢ M′ ⟺ N′ ∈ [[τ′]] implies Ψ′ ⊢ M^{>}M′ ⟺ N^{>}N′ ∈ [[τ]].

5. Ψ ⊢ M = N ∈ [[τ′ ↣ τ]] iff ∀Ψ′, M′, N′.

Ψ′ ≥ Ψ and Ψ′ ⊢ M′ ⟺ N′ ∈ [[τ′]] implies Ψ′ ⊢ M^{<}M′ ⟺ N^{<}N′ ∈ [[τ]].

6. Ψ ⊢ M = N ∈ [[τ_{1} & τ_{2}]] iff Ψ ⊢ fst M = fst N ∈ [[τ_{1}]] and Ψ ⊢ snd M = snd N ∈ [[τ_{2}]].

7. Ψ ⊢ M = N ∈ [[⊤]].

8. Ψ ⊢ A = B ∈ [[type^{−}]] iff Ψ ⊢ A ⟺ B : type^{−}.

9. Ψ ⊢ A = B ∈ [[τ → κ]] iff ∀Ψ′, M, N. Ψ′ ≥ Ψ and Ψ′ ⊢ M ⟺ N ∈ [[τ]] implies Ψ′ ⊢ A M ⟺ B N ∈ [[κ]].

10. Ψ ⊢ σ = θ ∈ [[·]] iff σ = · = θ.

11. Ψ ⊢ σ = θ ∈ [[Θ, u:τ]] iff σ = (σ′, M/u) and θ = (θ′, N/u) and

Ψ ⊢ M = N ∈ [[τ]] and Ψ ⊢ σ′ = θ′ ∈ [[Θ]].

Lemma 73 (Weakening for Logical Relations)

For each logical relation R, ΨΨ′ ⊢ R implies Ψ(x:τ)Ψ′ ⊢ R. Proof: By induction on the type or kind. □

We may now show the second part of our proof. Theorem 74 (Logically Related Terms are Algorithmically Equal)

1. Ψ ⊢ M = N ∈ [[τ]] implies Ψ ⊢ M ⟺ N : τ.

2. Ψ ⊢ A = B ∈ [[κ]] implies Ψ ⊢ A ⟺ B : κ.

3. Ψ ⊢ M ⟷ N : τ implies Ψ ⊢ M = N ∈ [[τ]].

4. Ψ ⊢ A ⟷ B : κ implies Ψ ⊢ A = B ∈ [[κ]]. Proof: By induction on the structure of τ or κ. □

The first part of our proof requires a few extra lemmas. Lemma 75 (Closure Under Head Expansion)

1. M ⟶^{whr} M′ and Ψ ⊢ M′ = N ∈ [[τ]] implies Ψ ⊢ M = N ∈ [[τ]].

2. N ⟶^{whr} N′ and Ψ ⊢ M = N′ ∈ [[τ]] implies Ψ ⊢ M = N ∈ [[τ]]. Proof: By induction on the structure of τ. □ Lemma 76 (Symmetry of Logical Relation)

1. Ψ ⊢ M = N ∈ [[τ]] implies Ψ ⊢ N = M ∈ [[τ]].

2. Ψ ⊢ A = B ∈ [[κ]] implies Ψ ⊢ B = A ∈ [[κ]].

3. Ψ ⊢ σ = θ ∈ [[Θ]] implies Ψ ⊢ θ = σ ∈ [[Θ]]. Proof: By induction on the structure of τ, κ, and Θ using Lemma 71. □ Lemma 77 (Transitivity of Logical Relation)

1. Ψ ⊢ M = M′ ∈ [[τ]] and Ψ ⊢ M′ = N ∈ [[τ]] implies Ψ ⊢ M = N ∈ [[τ]].

2. Ψ ⊢ A = A′ ∈ [[κ]] and Ψ ⊢ A′ = B ∈ [[κ]] implies Ψ ⊢ A = B ∈ [[κ]].

3. Ψ ⊢ σ = σ′ ∈ [[Θ]] and Ψ ⊢ σ′ = θ ∈ [[Θ]] implies Ψ ⊢ σ = θ ∈ [[Θ]]. Proof: By induction on the structure of τ, κ, and Θ using Lemmas 72. □

We may now prove a generalization of the first part of our proof. Lemma 78

(Definitionally Equal Terms are Logically Related Under Substitutions)

1. Γ; Δ; Ω ⊢ M = N : A and Ψ ⊢ σ = θ ∈ [[Ψ′]] and Ψ′ ≥ Γ^{−}Δ^{−}Ω^{−} implies Ψ ⊢ σ(M) = θ(N) ∈ [[A^{−}]].

2. Γ ⊢ A = B : K and Ψ ⊢ σ = θ ∈ [[Ψ′]] and Ψ′ ≥ Γ^{−} implies

Ψ ⊢ σ(A) = θ(B) ∈ [[K^{−}]].

Proof: By induction on the given derivation of definitional equality using the prior results in this section. □

It is now easy to finish off the proof of completeness of algorithmic equality. Lemma 79 (Identity Substitutions are Logically Related)

Ψ ⊢ id_{Ψ} = id_{Ψ} ∈ [[Ψ]]. Proof: By definition of [[Ψ]] and Theorem 74 □ Theorem 80 (Definitionally Equal Terms are Logically Related)

1. Γ; Δ; Ω ⊢ M = N : A implies Γ^{−}Δ^{−}Ω^{−} ⊢ M = N ∈ [[A^{−}]].

2. Γ ⊢ A = B : K implies Γ^{−} ⊢ A = B ∈ [[K^{−}]].

Proof: By Lemmas 78 and 79. □

Theorem 81 (Completeness of Algorithmic Equality)

1. Γ; Δ; Ω ⊢ M = N : A implies Γ^{−}Δ^{−}Ω^{−} ⊢ M ⟺ N : A^{−}.

2. Γ ⊢ A = B : K implies Γ^{−} ⊢ A ⟺ B : K^{−}.

Proof: By Theorems 80 and 74. □

14.2 Soundness of Algorithmic Equality

In this section we show the soundness of algorithmic equality with respect to definitional equality. In general this does not hold since the algorithmic equality does not force the objects being compared to be well-typed, or even have the same types. However, if we restrict attention to well-typed objects of the same type, then we get a soundness result.

A further difficulty lies in the simplified type structure, used by the algorithmic equality, which ignores linearity and ordering constraints. We must therefore rely upon the objects’ typing derivations to recover hypothesis management, required by definitional equality derivations, satisfying linearity and ordering constraints. However, due to the presence of ⊤, two typing derivations for equal objects can disagree about which linear and ordered hypotheses are consumed in a derivation branch. The solution adopted in [59] gets around this problem by constructing a mediating object, for algorithmically equal objects, which is definitionally equal to both given objects.

Before proceeding to the main lemma, we need to show the following result.

Lemma 82 (Subject Reduction)

M ⟶^{whr} M′ and Γ; Δ; Ω ⊢ M : A implies Γ; Δ; Ω ⊢ M = M′ : A.

Proof: By induction on the given weak head reduction derivation making use of Lemmas 62, 67 and 59. □

We may now prove the following lemma which directly implies the result we want.

Lemma 83 (Algorithmically Equal Well-Formed Terms Have Mediating Terms)

Assume ⊢ Γ uctx and Γ ⊢ Δ_{1} lctx and Γ ⊢ Δ_{2} lctx and Γ ⊢ Ω_{1} lctx and Γ ⊢ Ω_{2} octx.

1. Γ; Δ_{1}; Ω_{1} ⊢ M : A and Γ; Δ_{2}; Ω_{2} ⊢ N : A and Ψ ⊢ M ⟺ N : A^{−} and

Ψ ≥ Γ^{−}Δ_{1}^{−}Ω_{1}^{−} and Ψ ≥ Γ^{−}Δ_{2}^{−}Ω_{2}^{−} implies ∃P. Γ; Δ_{1}; Ω_{1} ⊢ P = M : A and Γ; Δ_{2}; Ω_{2} ⊢ P = N : A.

2. Γ; Δ_{1}; Ω_{1} ⊢ M : A and Γ; Δ_{2}; Ω_{2} ⊢ N : B and Ψ ⊢ M ⟷ N : τ

Ψ ≥ Γ^{−}Δ_{1}^{−}Ω_{1}^{−} and Ψ ≥ Γ^{−}Δ_{2}^{−}Ω_{2}^{−} implies

∃C, P. Γ ⊢ C = A : type and Γ ⊢ C = B : type

and Γ; Δ_{1}; Ω_{1} ⊢ P = M : C and Γ; Δ_{2}; Ω_{2} ⊢ P = N : C
and A^{−} = B^{−} = C^{−} = τ.

3. Γ ⊢ A : K and Γ ⊢ B : K and Γ^{−} ⊢ A ⟺ B : K^{−} implies Γ ⊢ A = B : K.

4. Γ ⊢ A_{1} : K_{1} and Γ ⊢ A_{2} : K_{2} and Γ^{−} ⊢ A_{1} ⟷ A_{2} : κ implies Γ ⊢ A_{1} = A_{2} : K_{1} and Γ ⊢ K_{1} = K_{2} : kind and K_{1}^{−} = K_{2}^{−} = κ.

5. Γ ⊢ K : kind and Γ ⊢ K′ : kind and Γ^{−} ⊢ K ⟷ K′ : kind^{−} implies Γ ⊢ K = K′ : kind.

Proof: By induction on the given algorithmic equality derivation using inversion and injectivity properties. □

Theorem 84 (Soundness of Algorithmic Equality)

Assume ⊢ Γ uctx and Γ ⊢ Δ lctx and Γ ⊢ Ω octx.

1. Γ; Δ; Ω ⊢ M : A and Γ; Δ; Ω ⊢ N : A and Γ^{−}Δ^{−}Ω^{−} ⊢ M ⟺ N : A^{−} implies Γ; Δ; Ω ⊢ M = N : A.

2. Γ ⊢ A : K and Γ ⊢ B : K and Γ^{−} ⊢ A ⟺ B : K^{−} implies Γ ⊢ A = B : K.

Proof: By Lemma 83, symmetry and transitivity. □

Now that we have shown the correctness of algorithmic equality, with respect to definitional equality, we are ready to show decidability of OLF type-checking.

222

Decidability and Canonical Forms

In this chapter we show that the type checking for OLF is decidable and that there exists a notion of canonical form in OLF suitable for logical framework representations. We first show that algorithmic equality is decidable. We then use the correctness of algorithmic equality, Theorems 81 and 84, to show decidability of type-checking.

The notion of canonical form we will define will come from the algorithmic equality derivations. Specifically, we will make use of the fact that the mediating terms mentioned in Lemma 83 are unique up to the type labels on bound variables. We will define a canonical representation for each equivalence class of mediating terms which will serve as a representative for a given type.

15.1 Decidability of Equality

An object is normalizing if it is algorithmically equal to some other object.

Lemma 85 (Decidability of Normalizing Terms)

1. Ψ ⊢ M ⟺ M′ : τ and Ψ ⊢ N ⟺ N′ : τ implies it is decidable whether Ψ ⊢ M ⟺ N : τ.

2. Ψ ⊢ M ⟷ M′ : τ_{1} and Ψ ⊢ N ⟷ N′ : τ_{2} implies it is decidable whether Ψ ⊢ M ⟷ N : τ_{3} for some τ_{3}.

3. Ψ ⊢ A ⟺ A′ : κ and Ψ ⊢ B ⟺ B′ : κ implies it is decidable whether Ψ ⊢ A ⟺ B : κ.

4. Ψ ⊢ A ⟷ A′ : κ_{1} and Ψ ⊢ B ⟷ B′ : κ_{2} implies it is decidable whether Ψ ⊢ A ⟷ B : κ_{3} for some κ_{3}.

5. Ψ ⊢ K_{1} ⟺ K′_{1} : kind^{−} and Ψ ⊢ K_{2} ⟺ K′_{2} : kind^{−} implies it is decidable whether Ψ ⊢ K_{1} ⟺ K_{2} : kind^{−}.

Proof: By induction on the structure of the given derivation using Lemma 70. □

Lemma 86 (Decidability of Algorithmic Equality)

1. Γ; Δ; Ω ⊢ M : A and Γ; Δ; Ω ⊢ N : A implies it is decidable whether Γ^{−}Δ^{−}Ω^{−} ⊢ M ⟺ N : A^{−}.

2. Γ ⊢ A : K and Γ ⊢ B : K implies it is decidable whether Γ^{−} ⊢ A ⟺ B : K^{−}.

3. Γ ⊢ K : kind^{−} and Γ ⊢ K′ : kind^{−} implies it is decidable whether Γ^{−} ⊢ K ⟺ K′ : kind^{−}.

Proof: By Lemma 58 and Theorem 81 both M and N are normalizing. Then, by Lemma 85 we are done. □

Theorem 87 (Decidability of Definitional Equality)

Γ; Δ; Ω ⊢ M : A and Γ; Δ; Ω ⊢ N : A implies it is decidable whether Γ; Δ; Ω ⊢ M = N : A.

Γ ⊢ A : K and Γ ⊢ B : K implies it is decidable whether Γ ⊢ A = B : K.

Γ ⊢ K : kind and Γ ⊢ K′ : kind implies it is decidable whether Γ ⊢ K = K′ : kind.

Proof: By Theorems 81, 84 and Lemma 86. □

15.2 Decidability of OLF Type-Checking

We now present a decidable version of the typing rules from Section 13.2 which is essentially a trivial extension of the algorithmic type-checking rules given in [24]. These rules use algorithmic equality, rather than definitional equality, and should be used in a bottom-up fashion.

We introduce the following new judgements for algorithmic type-checking:

Γ ⊢ K ⇒ kind  K is a valid kind
Γ ⊢ A ⇒ K  A has kind K
Γ; Δ; Ω ⊢ M ⇒ A M has type A

We may operationally think of everything to the left of ⇒ as input and the family, or kind, to the right of ⇒ as output.

Kinds

        Γ ⊢ type ⇒ kind

Γ ⊢ A ⇒ type Γ(x:A) ⊢ K ⇒ kind Γ ⊢ Πx:A. K ⇒ kind

Families

\frac{a:K ∈ Σ}{Γ ⊢ a ⇒ K}  \frac{Γ ⊢ A ⇒ Πx:B. K  Γ ⊢ M ⇒ B′ Γ^{−} ⊢ B ⟺ B′ : type}{Γ ⊢ A M ⇒ K[M/x]}

\frac{Γ ⊢ A_{1} ⇒ type Γ(x:A_{1}) ⊢ A_{2} ⇒ type}{Γ ⊢ Πx:A_{1}. A_{2} ⇒ type}

Objects

\frac{c:A ∈ Σ}{Γ; ·; · ⊢ c ⇒ A}  \frac{x:A ∈ Γ}{Γ; ·; · ⊢ x ⇒ A}  \overline{Γ; y:A; · ⊢ y ⇒ A}  \overline{Γ; ·; z:A ⊢ z ⇒ A}

\frac{Γ ⊢ A′ ⇒ type Γ(x:A′); Δ; Ω ⊢ M ⇒ A}{Γ; Δ; Ω ⊢ λx:A′. M ⇒ Πx:A′. A}

\frac{Γ; Δ; Ω ⊢ M ⇒ Πx:B. A Γ; ·; · ⊢ M′ ⇒ B′ Γ^{−} ⊢ B ⟺ B′ : type}{Γ; Δ; Ω ⊢ M M′ ⇒ A[M′/x]}

\frac{Γ ⊢ A′ ⇒ type Γ; Δ(y:A′); Ω ⊢ M ⇒ A}{Γ; Δ; Ω ⊢ λ̂y:A′. M ⇒ A′ −∘ A}

\frac{Γ; Δ; Ω ⊢ M ⇒ B −∘ A Γ; Δ′; · ⊢ M′ ⇒ B′ Γ^{−} ⊢ B ⟺ B′ : type}{Γ; Δ ▷◁ Δ′; Ω ⊢ Mˆ M′ ⇒ A}

\frac{Γ ⊢ A′ ⇒ type Γ; Δ; Ω(z:A′) ⊢ M ⇒ A}{Γ; Δ; Ω ⊢ λ^{>}z:A′. M ⇒ A′ ↠ A}

\frac{Γ; Δ; Ω ⊢ M ⇒ B ↠ A Γ; Δ′; Ω′; · ⊢ M′ ⇒ B′ Γ^{−} ⊢ B ⟺ B′ : type}{Γ; Δ ▷◁ Δ′; ΩΩ′ ⊢ M^{>}M′ ⇒ A}

\frac{Γ ⊢ A′ ⇒ type Γ; Δ; (z:A′)Ω ⊢ M ⇒ A}{Γ; Δ; Ω ⊢ λ^{<}z:A′. M ⇒ A′ ↣ A}

\frac{Γ; Δ; Ω ⊢ M ⇒ B ↣ A Γ; Δ′; Ω′; · ⊢ M′ ⇒ B′ Γ^{−} ⊢ B ⟺ B′ : type}{Γ; Δ ▷◁ Δ′; Ω′Ω ⊢ M^{<} M′ ⇒ A}

\overline{Γ; Δ; Ω ⊢ ⟨⟩ ⇒ ⊤}  \frac{Γ; Δ; Ω ⊢ M_{1} ⇒ A_{1} Γ; Δ; Ω ⊢ M_{2} ⇒ A_{2}}{Γ; Δ; Ω ⊢ ⟨M_{1} , M_{2}⟩ ⇒ A_{1} & A_{2}}

\frac{Γ; Δ; Ω ⊢ M ⇒ A_{1} & A_{2}}{Γ; Δ; Ω ⊢ fst M ⇒ A_{1}}  \frac{Γ; Δ; Ω ⊢ M ⇒ A_{1} & A_{2}}{Γ; Δ; Ω ⊢ snd M ⇒ A_{2}}

\frac{Γ; Δ; Ω ⊢ M ⇒ A Γ ⊢ A = A′ ⇒ type}{Γ; Δ; Ω ⊢ M ⇒ A′}

Note that these typing rules are completely syntax-directed; each form of object appears in the conclusion of only one rule, whose premises contain only subcomponents of the object; and similarly for families and kinds.

We also assume new algorithmic type-checking based judgements to check validity for signatures and contexts.

Lemma 88 (Correctness of Algorithmic Type-Checking)

1. Γ; Δ; Ω ⊢ M ⇒ A implies Γ; Δ; Ω ⊢ M : A.

2. Γ; Δ; Ω ⊢ M : A implies ∃A′. Γ; Δ; Ω ⊢ A = A′ : type and Γ; Δ; Ω ⊢ M ⇒ A′.

Proof: Part 1 is proved by induction on the structure of the given derivation using Lemma 63, Theorem 84, and the type conversion rule.

Part 2 is proved by induction on the structure of the given derivation using transitivity definitional equality rules, Lemma 66 and Theorem 81. □

Theorem 89 (Decidability of Type-Checking)

1. ⊢ Γ uctx is decidable.

2. ⊢ Γ uctx implies Γ ⊢ Δ lctx and Γ ⊢ Ω octx are decidable.

3. ⊢ Γ uctx and Γ ⊢ Δ lctx and Γ ⊢ Ω octx implies Γ; Δ; Ω ⊢ M : A is decidable.

4. ⊢ Γ uctx implies Γ ⊢ A : K is decidable.

5. ⊢ Γ uctx implies Γ ⊢ K : kind is decidable.

Proof: There exists at most one A′ such that Γ; Δ; Ω ⊢ M ⇒ A′ since the algorithmic typing rules are syntax-directed and algorithmic equality is decidable. Then by Lemma 88, Γ; Δ; Ω ⊢ M : A iff Γ ⊢ A = A′ : type which can be decided by checking Γ^{−} ⊢ A ⟺ A′ : type^{−}. □

15.3 Canonical Forms

We now turn our attention to identifying canonical forms for OLF.

We will start off by instrumenting the algorithmic equality judgements to produce the mediating object for two equal objects. These mediating objects will be unique. However, since algorithmic equality uses simplified types, we will not be able to construct an actual OLF object (we can recover the type-labels later from the actual type of the terms).

Rather we will construct an OLF object without the type labels on bound variables. This object will be unique. We will call such objects quasi objects and define them as follows:

Quasi objects Q ::= x | y | z |
λx. Q | Q_{1} Q_{2} |
λ̂y. Q | Q_{1}ˆ Q_{2} |
λ^{>}z. Q | Q_{1}^{>}Q_{2} |
λ^{<}z. Q | Q_{1}^{<} Q_{2} |
⟨Q_{1} , Q_{2}⟩ | fst Q | snd Q | ⟨⟩

We can now define the notions of quasi-canonical and quasi-atomic form, with the usual two mutually recursive judgments:

Γ; Δ; Ω ⊢ Q ⇑ A Q is quasi-canonical at type A
Γ; Δ; Ω ⊢ Q ↓ A Q is quasi-atomic at type A

The derivation rules for these judgements are as follows:

Variables

\frac{uvar}{Γ_{1}(x:A)Γ_{2}; ·; · ⊢ x ↓ A}

\frac{lvar}{Γ; y:A; · ⊢ y ↓ A}

\frac{ovar}{Γ; ·; z:A ⊢ z ↓ A}

Atomic Types.

Γ; Δ; Ω ⊢ Q ↓ a′ Γ ⊢ a′ = a : type

coercion

Γ; Δ; Ω ⊢ Q ⇑ a Unrestricted Functions.

Γ(x:A); Δ; Ω ⊢ Q′ ⇑ B

ΠI Γ; Δ; Ω ⊢ λx. Q′ ⇑ Πx:A. B

Γ; Δ; Ω ⊢ Q ↓ Πx:A. B Γ; ·; · ⊢ Q′ ⇑ A

ΠE
Γ; Δ; Ω ⊢ Q Q′ ↓ B[(Q′)_{A}^{♯}/x]

Linear Functions.

Γ; Δ(y:A); Ω ⊢ Q′ ⇑ B
−∘I
Γ; Δ; Ω ⊢ λ̂y. Q′ ⇑ A −∘ B

Γ; Δ; Ω ⊢ Q ↓ A −∘ B Γ; Δ′; · ⊢ Q′ ⇑ A −∘E

Γ; Δ ▷◁ Δ′; Ω ⊢ Qˆ Q′ ↓ B

Right Ordered Functions.

Γ; Δ; Ω(z:A) ⊢ Q′ ⇑ B

↠I

Γ; Δ; Ω ⊢ λ^{>}z. Q′ ⇑ A ↠ B

Γ; Δ; Ω ⊢ Q ↓ A ↠ B Γ; Δ′; Ω′ ⊢ Q′ ⇑ A

↠E

Γ; Δ ▷◁ Δ′; ΩΩ′ ⊢ Q^{>}Q′ ↓ B

Left Ordered Functions.

Γ; Δ; (z:A)Ω ⊢ Q′ ⇑ B
↣I
Γ; Δ; Ω ⊢ λ^{<}z. Q′ ⇑ A ↣ B

Γ; Δ; Ω ⊢ Q ↓ A ↣ B Γ; Δ′; Ω′ ⊢ Q′ ⇑ A

↣E
Γ; Δ ▷◁ Δ′; Ω′Ω ⊢ Q^{<} Q′ ↓ B

Additive Pairs.

Γ; Δ; Ω ⊢ Q_{1} ⇑ A Γ; Δ; Ω ⊢ Q_{2} ⇑ B

&I Γ; Δ; Ω ⊢ ⟨Q_{1} , Q_{2}⟩ ⇑ A & B

Γ; Δ; Ω ⊢ Q ↓ A & B

&E1 Γ; Δ; Ω ⊢ fst Q ↓ A

Γ; Δ; Ω ⊢ Q ↓ A & B

&E2 Γ; Δ; Ω ⊢ snd Q ↓ B

Additive Unit.

\frac{⊤I}{Γ; Δ; Ω ⊢ ⟨⟩ ⇑ ⊤}

Given a derivation of Γ; Δ; Ω ⊢ Q ⇑ A, one may produce an actual OLF object by adding type labels to Q. We use the notation (Q)_{A}^{♯} to denote this operation. Note that this operation is compositional, i.e., (Q[Q′/x])_{A}^{♯} = (Q)_{A}^{♯}[(Q′)_{A′}^{♯}/x] where A is the (given) type of the whole term, and A′ is the type of variable x in context.

We make use of the following properties of quasi-canonical forms.

Lemma 90

1. Γ_{1}Γ_{2}; Δ; Ω ⊢ Q ⇑ A implies Γ_{1}ΓΓ_{2}; Δ; Ω ⊢ Q ⇑ A.

2. Γ; Δ; Ω_{1}(z:A′)Ω_{2} ⊢ Q ⇑ A implies Γ(x:A′); Δ; Ω_{1}Ω_{2} ⊢ Q[x/z] ⇑ A.

3. Γ; Δ_{1}(y:A′)Δ_{2}; Ω ⊢ Q ⇑ A implies Γ(x:A′); Δ_{1}Δ_{2}; Ω ⊢ Q[x/z] ⇑ A.

Proof: By structural induction on the given derivation. □

Note that quasi-canonical objects are simply objects in βη-long form which are missing type labels on bound variables.

Theorem 91 Assume Γ ⊢ A : type.

1. Γ; Δ; Ω ⊢ Q ⇑ A implies Γ; Δ; Ω ⊢ (Q)_{A}^{♯} : A.

2. Γ; Δ; Ω ⊢ Q ↓ A implies Γ; Δ; Ω ⊢ (Q)_{A}^{♯} : A.

Proof: By structural induction on the given derivation. □

We use the notation M^{♭} for the result of erasing type labels from an OLF object M to get a quasi object. Note that this operation is compositional, i.e., (M[M′/x])^{♭} = (M)^{♭}[(M′)^{♭}/x].

We now restate Lemma 83 to explicitly characterize the form of the mediating terms using the quasi canonical judgements.

Lemma 92 (Almost Canonical Forms)

Assume ⊢ Γ uctx and Γ ⊢ Δ_{1} lctx and Γ ⊢ Δ_{2} lctx and Γ ⊢ Ω_{1} lctx and Γ ⊢ Ω_{2} octx.

1. Γ; Δ_{1}; Ω_{1} ⊢ M : A and Γ; Δ_{2}; Ω_{2} ⊢ N : A and Ψ ⊢ M ⟺ N : A^{−} and

Ψ ≥ Γ^{−}Δ_{1}^{−}Ω_{1}^{−} and Ψ ≥ Γ^{−}Δ_{2}^{−}Ω_{2}^{−} implies

there exists a P such that Γ; Δ_{1}; Ω_{1} ⊢ P = M : A and Γ; Δ_{2}; Ω_{2} ⊢ P = N : A and Γ; Δ_{1}; Ω_{1} ⊢ (P)^{♭} ⇑ A and P is unique up definitional equality of type labels.

2. Γ; Δ_{1}; Ω_{1} ⊢ M : A and Γ; Δ_{2}; Ω_{2} ⊢ N : B and Ψ ⊢ M ⟷ N : τ

and Ψ ≥ Γ^{−}Δ_{1}^{−}Ω_{1}^{−} and Ψ ≥ Γ^{−}Δ_{2}^{−}Ω_{2}^{−} implies

there exists C and P such that Γ ⊢ C = A : type and Γ ⊢ C = B : type and Γ; Δ_{1}; Ω_{1} ⊢ P = M : C and Γ; Δ_{2}; Ω_{2} ⊢ P = N : C and A^{−} = B^{−} = C^{−} = τ and Γ; Δ_{1}; Ω_{1} ⊢ (P)^{♭} ↓ C and P is unique up to definitional equality of type labels.

3. Γ ⊢ A : K and Γ ⊢ B : K and Γ^{−} ⊢ A ⟺ B : K^{−} implies Γ ⊢ A = B : K.

4. Γ ⊢ A_{1} : K_{1} and Γ ⊢ A_{2} : K_{2} and Γ^{−} ⊢ A_{1} ⟷ A_{2} : κ implies Γ ⊢ A_{1} = A_{2} : K_{1} and Γ ⊢ K_{1} = K_{2} : kind and K_{1}^{−} = K_{2}^{−} = κ.

5. Γ ⊢ K : kind and Γ ⊢ K′ : kind and Γ^{−} ⊢ K ⟷ K′ : kind^{−} implies Γ ⊢ K = K′ : kind.

Proof: By induction on the given algorithmic equality derivation using inversion and injectivity properties. □

Define acnf(M) to be the P resulting from an application of Lemma 92 to two derivations of Γ; Δ; Ω ⊢ M : A.

Theorem 93 (Quasi-Canonical Forms) Γ; Δ; Ω ⊢ M : A implies Γ; Δ; Ω ⊢ (acnf(M))^{♭} ⇑ A.

Proof: Direct from Lemma 92. □

As stated in Lemma 92, for a given well-typed OLF term M, its almost-canonical form, acnf(M), is unique up to typing labels. Therefore, the quasi-canonical, (acnf(M))^{♭}, is unique. Thus we can use quasi-canonical forms for logical framework representations.

Lemma 94

1. Γ; Δ; Ω ⊢ M : A implies ((acnf(M))^{♭})_{A}^{♯} = acnf(M).

2. Γ; Δ; Ω ⊢ Q ⇑ A implies ((Q)_{A}^{♯})^{♭} = Q and acnf((Q)_{A}^{♯}) = (Q)_{A}^{♯}.

Proof: By structural induction on given derivation. □

We have the following special substitution properties for quasi-canonical forms. Note that the type being substituted into must be constant.

Lemma 95

1. Γ; ·; · ⊢ Q′ ↓ a and Γ(x:a)Γ′; Δ; Ω ⊢ Q ⇑ A implies Γ(Γ′[(Q′)_{a}^{♯}/x]); Δ[(Q′)_{a}^{♯}/x]; Ω[(Q′)_{a}^{♯}/x] ⊢ Q[Q′/x] ⇑ A.

2. Γ; Δ′; · ⊢ Q′ ↓ a and Γ; Δ_{1}(y:a)Δ_{2}; Ω ⊢ Q ⇑ A implies Γ; (Δ_{1} ▷◁ Δ′)Δ_{2}; Ω ⊢ Q[Q′/y] ⇑ A.

3. Γ; Δ′; Ω′ ⊢ Q′ : a and Γ; Δ ▷◁ Δ′; Ω_{1}(z:a)Ω_{2} ⊢ Q ⇑ A implies Γ; Δ; Ω_{1}Ω′Ω_{2} ⊢ Q[Q′/z] ⇑ A.

4. Γ; ·; · ⊢ Q′ ↓ a and Γ(x:a)Γ′; Δ; Ω ⊢ Q ↓ A implies Γ(Γ′[(Q′)_{a}^{♯}/x]); Δ[(Q′)_{a}^{♯}/x]; Ω[(Q′)_{a}^{♯}/x] ⊢ Q[Q′/x] ↓ A.

5. Γ; Δ′; · ⊢ Q′ ↓ a and Γ; Δ_{1}(y:a)Δ_{2}; Ω ⊢ Q ↓ A implies Γ; (Δ_{1} ▷◁ Δ′)Δ_{2}; Ω ⊢ Q[Q′/y] ↓ A.

6. Γ; Δ′; Ω′ ⊢ Q′ : a and Γ; Δ ▷◁ Δ′; Ω_{1}(z:a)Ω_{2} ⊢ Q ↓ A implies Γ; Δ; Ω_{1}Ω′Ω_{2} ⊢ Q[Q′/z] ↓ A.

Proof: Direct from Lemma 59, Lemma 94, Theorem 93, Theorem 91, the compositionality of (−)^{♯} and (−)^{♭}, and the fact that the substitution of a constant type introduces no new redices. □

The next section shows an example of how OLF may be used to represent deductive systems. The adequacy proofs for the example will illustrate how quasi-canonical forms really are strong enough for OLF representations. Chapter 16 shows how OLF can be used to analyze syntactic properties of the CPS transform.

15.4 DeBruijn Terms in OLF

In this section we show a small example application of OLF. In Chapter 10 we gave an Olli program for translating regular lambda terms to deBruijn terms (or viceversa). We will now recast that example in OLF and prove the correctness of our OLF representation. We begin by reviewing the formal definition of regular terms, deBruijn terms, and the translation between the two.

Regular Terms e ::= x | e_{1} e_{2} | \underline{λ}x. e
deBruijn Terms e′ ::= 1 | e′ ↑ | e′_{1} e′_{2} | Λe′

We use \underline{λ} for regular terms to distinguish them from unrestricted OLF functions written with λ.

We use the judgement

x_{1} … x_{n} ⊢ e ↔ e′

to translate between regular and deBruijn terms. We use K to stand for x_{1} … x_{n}. Here are the derivation rules for our translation judgement.

\begin{aligned}K ⊢ e_{1} ↔ e′_{1} K ⊢ e_{2} ↔ e′_{2} \\ & tr app \\ K ⊢ e_{1} e_{2} ↔ e′_{1} e′_{2} \end{aligned}  \begin{matrix}K x ⊢ e ↔ e′ \\ tr lam & x \\ K ⊢ λx. e ↔ Λ e′ \end{matrix}
\frac{tr 1}{K x ⊢ x ↔ 1}  \begin{aligned}K ⊢ e ↔ e′ \\ & tr ↑ \\ K x ⊢ e ↔ e′ ↑ \end{aligned}

where x does not occur in K in the tr lam^{x} rule.

We can now write down an OLF signature with constants for representing all of the above judgements and rules. We start with the abstract syntax for regular and deBruijn terms:

exp : type.
lam : (exp → exp) → exp.
app : exp → exp → exp.

exp’ : type.
lam’ : exp’ → exp’.
app’ : exp’ → exp’ → exp’.
shift : exp’ → exp’.
one : exp’.

Note that these constants are the same as the signature used by the Olli translation program.

We define the following representation function (⌜−⌝), and its inverse (⌞−⌟), which form a bijection between regular terms and quasi-canonical objects:

\begin{matrix}⌜x⌝ = & x \\ ⌜\underline{λ}x. e⌝ = & lam (λx. ⌜e⌝) \\ ⌜e_{1} e_{2}⌝ = & app ⌜e_{1}⌝ ⌜e_{2}⌝ \end{matrix}  \begin{matrix}⌞x⌟ = & x \\ ⌞lam (λx. E)⌟ = & \underline{λ}x. ⌞E⌟ \\ ⌞appE_{1} E_{2}⌟ = & ⌞E_{1}⌟ ⌞E_{2}⌟ \end{matrix}

Note that ⌜e[e_{1}/x]⌝ = ⌜e⌝[⌜e_{1}⌝/x]. Lemma 96 For every regular term e Γ; ·; · ⊢ ⌜e⌝ ⇑ exp where Γ = x_{1}:exp … x_{n}:exp for each x_{i} free in e. Proof: By structural induction on e. □ Note that Γ; ·; · ⊢ (⌜e⌝)exp^{♯} : exp. Lemma 97 Γ; ·; · ⊢ Q ⇑ exp implies ⌞Q⌟ is a well-formed regular term. Proof: Immediate from fact that ⌞−⌟ is a function. □ Note that Γ; ·; · ⊢ (Q)exp^{♯} : exp. Theorem 98

1. ⌞((⌜e⌝)exp^{♯})^{♭}⌟ = e.

2. Γ; ·; · ⊢ M : exp implies (⌜⌞(acnf(M))^{♭}⌟⌝)exp^{♯} = acnf(M). Proof: Direct from previous definitions, Lemma 94 and Theorem 93. □

We define the following function (⌜−⌝), and its inverse (⌞−⌟), which form a bijection between deBruijn terms and quasi-canonical objects:

⌜1⌝ = one
⌜e′ ↑⌝ = shift ⌜e′⌝
⌜Λe′⌝ = lam’ ⌜e′⌝
⌜e′_{1} e′_{2}⌝ = app’ ⌜e′_{1}⌝ ⌜e′_{2}⌝

⌞one⌟ = 1
⌞shift E′⌟ = ⌞E′⌟ ↑
⌞lam’ E′⌟ = Λ⌞E′⌟
⌞app’ E′_{1} E′_{2}⌟ = ⌞E′_{1}⌟ ⌞E′_{2}⌟

Note that the quasi-canonical objects do not contain variable binders and thus are also actual OLF objects.

Lemma 99 For every deBruijn term e′ ·; ·; · ⊢ ⌜e′⌝ ⇑ exp’ Proof: By structural induction on e′. □ Lemma 100 ·; ·; · ⊢ Q ⇑ exp’ implies ⌞Q⌟ is a well-formed deBruijn term. Proof: Immediate from fact that ⌞−⌟ is a function. □ Theorem 101

1. ⌞((⌜e′⌝)exp’^{♯})^{♭}⌟ = e′.

2. Γ; ·; · ⊢ M : exp’ implies (⌜⌞(acnf(M))^{♭}⌟⌝)exp’^{♯} = acnf(M). Proof: Direct from previous definitions, Lemma 94 and Theorem 93. □

We now move on to the translation judgements. Because we will use the ordered context to implicitly represent the environments (K from the translation judgements given at the beginning of this section) we also need to define a helper constant which allows us to store terms of type exp in the ordered context.

tr : exp → exp’ → type.
var : exp → type.

We can now define constructors to represent the derivation rules.

tr app’ : ΠE1:exp. ΠE1′:exp’. ΠE2:exp. ΠE2′:exp’.

tr E1 E1′ & tr E2 E2′↠ tr (app E1 E2) (app’ E1′ E2′).

tr lam’ : ΠE:exp → exp. ΠE′:exp’.

(Πx:exp. var x ↠ tr (E x) E′)↠ tr (lam E) (lam’ E′).

tr one : ΠE:exp.

⊤↠ var E↠ tr E one.

tr shift : ΠF:exp. ΠE:exp. ΠE′:exp’.

tr E E′↠ var F ↠ tr E (shift E′).

Note that these declarations are the clauses of the Olli translation program. We define ⌈−⌉ and ⌊−⌋ on variable lists and ordered contexts as follows:

⌈·⌉ = · ⌈K x⌉ = ⌈K⌉ (v:var x) (for fresh v)
⌊·⌋ = · ⌊Ω (v:var x)⌋ = ⌊Ω⌋ x

Lemma 102 K ⊢ e ↔ e′ implies there exists a Q such that

Γ; ·; ⌈K⌉ ⊢ Q ⇑ tr (⌜e⌝)exp^{♯} (⌜e′⌝)exp’^{♯}

where Γ = x_{1}:exp … x_{n}:exp for each x_{i} in K.

Proof: By structural induction on the given derivation. □

Note that Γ; ·; ⌈K⌉ ⊢ (Q)_{tr (⌜e⌝)exp^{♯} (⌜e′⌝)exp’^{♯}}^{♯} : tr (⌜e⌝)exp^{♯} (⌜e′⌝)exp’^{♯}.

Lemma 103 Γ; ·; v_{1}:var x_{1} … v_{n}:var x_{n} ⊢ Q ⇑ tr E E′ implies

⌊v_{1}:var x_{1} … v_{n}:var x_{n}⌋ ⊢ ⌞(acnf(E))^{♭}⌟ ↔ ⌞(acnf(E′))^{♭}⌟.

Proof: By structural induction on the given derivation. □

Note that Γ; ·; v_{1}:var x_{1} … v_{n}:var x_{n} ⊢ (Q)_{tr E E′}^{♯} : tr E E′.

The representation function implicit in Lemma 102 and its inverse in Lemma 103 form a bijection between equivalence classes (up to definitional equality of type labels) of “almost” canonical forms for type family tr and informal translations. This is easily proved by using inversion properties of the quasi-canonical judgements.

CPS Analysis in OLF

In this chapter we show how an ordered logical framework supports the representation of CPS terms and a machine for their evaluation. The ordering properties of CPS terms which at first appear somewhat ad hoc are directly captured as typing properties in the representation that are preserved during evaluation. Complicated stack invariants can be recognized as uniform substitution properties, providing an example of how the organizing principles of a logical framework can contribute conceptually to our understanding of object languages.

The rest of this chapter is organized as follows. In section 16.1 we review CPS terms and their occurrence invariants. In section 16.2 we give a representation of CPS terms in an ordered logical framework in which the occurrence invariants are implicit in the ordered types. In sections 16.3, 16.4 and 16.5, we give representations of the CPS transformation and different evaluation models for CPS terms. In section 16.6 we show how the relationship between the bare evaluation and stack evaluation of a term can be formalized in OLF. We then use this formalization to give a proof that the machines produce the same result. Finally we give some conclusions and directions for further work in section 16.7.

16.1 CPS terms

In this section we review CPS terms and their ordering properties as investigated in [15, 14].

We use the following syntax for direct style (DS) terms:

DS Roots  r ::= e
DS Expressions  e ::= e_{1} e_{2} | t
DS Trivial Expressions  t ::= \underline{λ}x. r | x

and for CPS terms:

Root Terms  r ::= \underline{λ}k. e
Serious Terms  e ::= t_{1} t_{2} c | c t
Trivial Terms  t ::= \underline{λ}x. r | x | v
Continuation Terms  c ::= \underline{λ}v. e | k

Note that in the CPS syntax, we are distinguishing trivial variables x which are parameters of functions from trivial variables v which are parameters to continuations.

We formulate the left-to-right call-by-value CPS transform as three mutually recursive judgements. A direct-style term r is transformed into a CPS term r′ whenever the judgment

⊢ r ⟶^{DR} r′

is satisfied. Given a CPS continuation c, a direct-style expression e is transformed into a CPS expression e′ whenever the judgment

⊢ e; c ⟶^{DE} e′

is satisfied. Finally, a direct-style trivial expression t is transformed into a CPS trivial expression t′ whenever the judgment

⊢ t ⟶^{DT} t′

is satisfied.

\frac{⊢ e; k ⟶^{DE} e′}{⊢ e ⟶^{DR} \underline{λ}k. e′}  \frac{⊢ t ⟶^{DT} t′}{⊢ t; c ⟶^{DE} c t′}

⊢ e_{2} ; \underline{λ}v_{2}. v_{1} v_{2} c ⟶^{DE} e′_{2} ⊢ e_{1} ; \underline{λ}v_{1}. e′_{2} ⟶^{DE} e′ (v_{1} not free in conclusion)

⊢ e_{1} e_{2} ; c ⟶^{DE} e′

\overline{⊢ x ⟶^{DT} x} \frac{⊢ r ⟶^{DR} r′}{⊢ \underline{λ}x. r ⟶^{DT} \underline{λ}x. r′}

Terms resulting from a left-to-right call-by-value CPS translation of direct-style terms satisfy properties in addition to the CPS syntax, both on occurrences of continuation identifiers k and the parameters v of continuations. In [15] the occurrence properties on continuation identifiers and parameters are separately specified with two judgment families. However these occurrences are tightly coupled and may be naturally captured with just one family of judgments as follows. We shall use four mutually recursive judgments

⊨^{Root} r Φ ⊨^{Exp} e Φ ⊨^{Triv} t Φ ⊨^{Cont} c

where Φ is a stack of both continuation identifiers and parameters:

Φ ::= · | Φ, k | Φ, v

We have the following inference rules for these judgements:

\frac{k ⊨^{Exp} e}{⊨^{Root} \underline{λ}k. e}

\frac{Φ_{t} ⊨^{Triv} t Φ_{c} ⊨^{Cont} c}{Φ_{c}Φ_{t} ⊨^{Exp} c t}  \frac{Φ_{1} ⊨^{Triv} t_{1} Φ_{0} ⊨^{Triv} t_{0} Φ_{c} ⊨^{Cont} c}{Φ_{c}Φ_{o}Φ_{1} ⊨^{Exp} t_{0} t_{1} c}
\overline{· ⊨^{Triv} x}  \frac{⊨^{Root} r}{· ⊨^{Triv} \underline{λ}x. r}  \overline{v ⊨^{Triv} v}
\overline{k ⊨^{Cont} k}  \frac{Φ, v ⊨^{Exp} e}{Φ ⊨^{Cont} \underline{λ}v. e}

Our presentation is general enough to serve as a target for both Plotkin’s original call-by-value CPS transform and a one-pass version which avoids administrative redices.

It is easy to see that continuation identifiers, k, are used linearly in each root term and that continuation parameters, v, form a stack during the processing of each serious term. Furthermore, each k is used in a serious term only after all local parameters to continuations are used. These properties can be precisely captured with ordered types.

We next show how to prove that ⊢ r ⟶^{DR} r′ implies ⊨^{Root} r′ with the aid of an ordered logical framework.

16.2 Ordered Logical Framework Representation

We will now show how the OLL type theory presented in Chapter 13 provides exactly what is needed to capture and reason about the ordering properties of CPS terms. For the sake of readability, we will elide an explicit type argument, A, for the labeling operation, (−)_{A}^{♯}; this should not cause any ambiguity since the necessary type will be apparent from the context. Furthermore, we will use the notation A′ → A to stand for Πx:A′. A when x does not appear free in A. Finally, since our representation will not use linear hypotheses, we elide the linear context in all of our judgements.

16.2.1 DS Terms

Our representation of DS terms will use three basic types corresponding to the three kinds of DS terms.

droot : type. dexp : type. dtriv : type.

We will then build our representations from term constructors corresponding to DS terms. Note that representation uses higher-order abstract syntax, so object level functions are represented by meta-level functions.

e2r : dexp → droot.
dapp : dexp → dexp → dexp.
t2e : dtriv → dexp.
dlam : (dtriv → droot) → dtriv.

Given the previous signature, there is an obvious compositional bijection between DS terms and quasi-canonical objects in the above signature. This bijection is established by the following mutually recursive representation functions, ⌜−⌝^{R},⌜−⌝^{E},⌜−⌝^{T}, and their inverses ⌞−⌟^{R},⌞−⌟^{E},⌞−⌟^{T}.

⌜e⌝^{R} = e2r ⌜e⌝^{E}  ⌞e2r E⌟_{R} = ⌞E⌟_{E}

⌜e_{0} e_{1}⌝^{E} = dapp ⌜e_{0}⌝^{E} ⌜e_{1}⌝^{E}  ⌞dapp E_{0} E_{1}⌟_{E} = ⌞E_{0}⌟_{E} ⌞E_{1}⌟_{E}
⌜t⌝^{E} = d2e ⌜t⌝^{T}  ⌞d2e T ⌟_{E} = ⌞T ⌟_{T}
⌜\underline{λ}x. r⌝^{T} = dlam (λx. ⌜r⌝^{R})  ⌞dlam (λx. R)⌟_{T} = \underline{λ}x. ⌞R⌟_{R}
⌜x⌝^{T} = x  ⌞x⌟_{T} = x

Lemma 104 For every DS term e where Γ = x_{1}:dtriv … x_{n}:dtriv for each x_{i} free in e:

1. Γ; ·; · ⊢ ⌜e⌝^{R} ⇑ droot

2. Γ; ·; · ⊢ ⌜e⌝^{E} ⇑ dexp

3. Γ; ·; · ⊢ ⌜e⌝^{T} ⇑ dtriv Proof: By structural induction on e. □ Lemma 105

1. Γ; ·; · ⊢ Q ⇑ droot implies ⌞Q⌟_{R} is a well-formed DS root.

2. Γ; ·; · ⊢ Q ⇑ dexp implies ⌞Q⌟_{E} is a well-formed DS expression.

3. Γ; ·; · ⊢ Q ⇑ dexp implies ⌞Q⌟_{T} is a well-formed DS trivial term. Proof: Immediate from fact that ⌞−⌟ is a function. □

16.2.2 CPS Terms

Our representation of CPS terms will use four basic types corresponding to the four kinds of CPS terms.

root : type. exp : type. triv : type. cont : type.

We will then build our representations from term constructors corresponding to CPS terms. The use of ordered types forces the CPS term representations to have the linearity and ordering constraints noted at the end of section 16.1.

klam : (cont ↠ exp) → root.
kapp : cont ↠ triv ↠ exp.
app : cont ↠ triv ↠ triv ↠ exp.
lam : (triv → root) → triv.
vlam : (triv ↠ exp) ↠ cont.

The intuition behind these type declarations may best be gleaned from the representation function and its adequacy theorem below. Note that a positive occurrence of an unrestricted function → as in the type of klam imposes a restriction on the corresponding argument: it may not depend on the continuation k or parameters v. On the other hand, a negative occurrence of → as in the type of lam licenses the unrestricted use of the corresponding bound variable x. The right ordered functions ↠ impose the stack-like discipline on parameters of continuations and the continuations themselves explained in the previous section.

Given the previous signature, there is a compositional bijection between CPS terms satisfying the occurrence conditions and quasi-canonical objects in the above signature. This bijection is established by the following representation function, ⌜−⌝ and its inverse ⌞−⌟.

⌜\underline{λ}k. e⌝ = klam (λ^{>}k⌜e⌝)  ⌞klam (λ^{>}k. E)⌟ = \underline{λ}k. ⌞E⌟
⌜t_{0} t_{1} c⌝ = app^{>}⌜c⌝^{>}⌜t_{0}⌝^{>}⌜t_{1}⌝  ⌞app^{>}C^{>}T_{0}^{>}T_{1}⌟ = ⌞T_{0}⌟ ⌞T_{1}⌟ ⌞C⌟
⌜c t⌝ = kapp^{>}⌜c⌝^{>}⌜t⌝  ⌞kapp^{>}C^{>}T ⌟ = ⌞C⌟ ⌞T ⌟

\begin{aligned}⌜\underline{λ}x. r⌝ & = & lam (λx. ⌜r⌝) & ⌞lam (λx. R)⌟ & = & \underline{λ}x. ⌞R⌟ \\ ⌜x⌝ & = & x & ⌞x⌟ & = & x \\ ⌜v⌝ & = & v & ⌞v⌟ & = & v \end{aligned}

⌜\underline{λ}v. e⌝ = vlam^{>}(λ^{>}v. ⌜e⌝)  ⌞vlam^{>}(λ^{>}v. E)⌟ = \underline{λ}v. ⌞E⌟
⌜k⌝ = k  ⌞k⌟ = k
⌜·⌝ = ·  ⌞·⌟ = ·
⌜Φ, v⌝ = ⌜Φ⌝, v:triv  ⌞Φ, v:triv⌟ = ⌞Φ⌟, v
⌜Φ, k⌝ = ⌜Φ⌝, k:cont  ⌞Φ, k:cont⌟ = ⌞Φ⌟, k

Note that and ⌞⌜u⌝⌟ = u for any term u. Additionally, since variables are mapped to variables, the representation function and its inverse are compositional (i.e., commute with substitution).

We formally prove the correspondence in two parts.

Theorem 106 (Representations are Canonical Forms) Consider terms r, e, and t with free ordinary variables among x_{1}, …, x_{n} and let Γ = x_{1}:triv … x_{n}:triv.

1. If ⊨^{Root} r then Γ; · ⊢ ⌜r⌝ ⇑ root.

2. If Φ ⊨^{Exp} e then Γ; ⌜Φ⌝ ⊢ ⌜e⌝ ⇑ exp.

3. If Φ ⊨^{Triv} t then Γ; ⌜Φ⌝ ⊢ ⌜t⌝ ⇑ triv.

4. If Φ ⊨^{Cont} c then Γ; ⌜Φ⌝ ⊢ ⌜c⌝ ⇑ cont.

Proof: By induction on the structure of the given derivations. We give a representative case.

case: \frac{k ⊨^{Exp} e}{⊨^{Root} \underline{λ}k. e}

Γ; k:cpair ⊢ ⌜e⌝ ⇑ exp  ind. hyp.
Γ; · ⊢ λ^{>}k. ⌜e⌝ ⇑ cpair ↠ exp  ↠_{I}
Γ; · ⊢ klam ↓ (cpair ↠ exp) → root  const
Γ; · ⊢ klam (λ^{>}k. ⌜e⌝) ⇑ root  →_{E}, coercion
□

Theorem 107 (Canonical Forms are Representations) Let Γ = x_{1}:triv, …, x_{n}:triv be given.

1. For any Q such that Γ; · ⊢ Q ⇑ root, ⌞Q⌟ is defined and ⊨^{Root} ⌞Q⌟.

2. For any Ω = v_{1}:triv … v_{n}:triv and Q with Γ; k:cont, Ω ⊢ Q ⇑ exp, ⌞Q⌟ is defined and k, ⌞Ω⌟ ⊨^{Exp} ⌞Q⌟.

3. For any Ω = v_{1}:triv … v_{n}:triv and Q such that Γ; Ω ⊢ Q ⇑ triv, ⌞Q⌟ is defined and ⌞Ω⌟ ⊨^{Triv} ⌞Q⌟.

4. For any Ω = v_{1}:triv … v_{n}:triv and Q with Γ; k:cont, Ω ⊢ Q ⇑ cont, ⌞Q⌟ is defined and k, ⌞Ω⌟ ⊨^{Cont} ⌞Q⌟.

Proof: By induction on the structure of the given canonical derivations. We give a representative case.

case: Γ; · ⊢ klam (λ^{>}k. e) ⇑ root

Γ; · ⊢ klam (λ^{>}k. e) ↓ root  inversion on coercion
Γ; · ⊢ λ^{>}k. e ⇑ cpair ↠ exp  inversion on →_{E}
Γ; k:cpair ⊢ e ⇑ exp  inversion on ↠_{I}
⌞e⌟ is defined, and k ⊨^{Exp} ⌞e⌟  ind. hyp.
⊨^{Root} \underline{λ}k. ⌞e⌟  by definition
□

16.3 CPS Transform

We represent CPS transform with three basic types corresponding to the three judgements of the transform.

cps r : droot→root→type. cps e : dexp→cont→exp→type. cps t : dtriv→triv→type.

We then use the following terms to construct representations of the CPS transform.

cps root : ΠE:dexp. ΠE′:cont ↠ exp.

(Πk:cont. cps e E k (E′^{>}k)) → cps r (e2r E) (klam E′).

cps app : ΠE_{0}:dexp. ΠE_{1}:dexp. ΠC:cont. ΠE′_{1}:triv ↠ exp. ΠE′:exp.

cps e E_{0} (vlam^{>}E′_{1}) E′→ (Πv_{0}:triv. cps e E_{1} (vlam^{>}λ^{>}v_{1}:triv. app^{>}C^{>}v_{0}^{>}v_{1}) (E′_{1}^{>}v_{0}))→ cps e (dapp E_{0} E_{1}) C E′.

cps triv : ΠT:dtriv. ΠC:cont. ΠT′:triv.

cps t T T′ → cps e (t2e T) C (kapp^{>}C^{>}T′).

cps lam : ΠR:dtriv → droot. ΠR′:triv → root.

(Πx:dtriv. Πx′:triv. cps t x x′ → cps r (R x) (R′ x′))→ cps t (dlam R) (lam R′).

We may now show the adequacy of above representation in two parts. In the informal translation we map variables x to themselves; in the formalization we map each variable x from the direct-style term to a corresponding variable x′ in the continuationpassing term. These variables and their relationship are captured in contexts

Γ = x_{1}:dtriv … x_{n}:dtriv
Γ′ = x′_{1}:triv … x′_{n}:triv
Γ_{m} = m_{1}:cps t x_{1} x′_{1} … m_{n}:cps t x_{n} x′_{n}

which always occur together in this manner.

Theorem 108 (Representations are Canonical Forms) Let Γ^{∗} = Γ, Γ′, Γ_{m} be a context of the form explained above that contains all free variables occurring in the relevant judgment. Then

1. ⊢ r ⟶^{DR} r′ implies ∃Q. Γ^{∗}; · ⊢ Q ⇑ cps r (⌜r⌝^{R})^{♯} (⌜r′⌝)^{♯} and ⊨^{Root} r′.

2. ⊢ e; c ⟶^{DE} e′ and Φ ⊨^{Cont} c implies

∃Q. Γ^{∗}, ⌜Φ⌝; ·; · ⊢ Q ⇑ cps e (⌜e⌝^{E})^{♯} (⌜c⌝)^{♯} (⌜e′⌝)^{♯} and Φ ⊨^{Exp} e′.

3. ⊢ t ⟶^{DT} t′ implies ∃Q. Γ^{∗}; ·; · ⊢ Q ⇑ cps t (⌜t⌝^{T})^{♯} (⌜t′⌝)^{♯} and · ⊨^{Triv} t′.

Proof: By structural induction on the given derivation. We show a representative case.

case: ⊢ e_{2} ; \underline{λ}v_{2}. v_{1} v_{2} c ⟶^{DE} e′_{2} ⊢ e_{1} ; \underline{λ}v_{1}. e′_{2} ⟶^{DE} e′ (v_{1} not free in conclusion) ⊢ e_{1} e_{2} ; c ⟶^{DE} e′

Then

Φ ⊨^{Cont} c  assumption
v_{1} ⊨^{Triv} v_{1} and v_{2} ⊨^{Triv} v_{2}  defn.
Φ, v_{1} ⊨^{Cont} \underline{λ}v_{2}. v_{1} v_{2} c  defn.

(Γ^{∗}, ⌜Φ⌝, v_{1}:triv); · ⊢ Q_{2} ⇑ cps e (⌜e_{2}⌝^{E})^{♯} (vlam^{>}λ^{>}v_{2}. app (⌜c⌝)^{♯} v_{1} v_{2}) (⌜e′_{2}⌝)^{♯}

and Φ, v_{1} ⊨^{Exp} e′_{2}  ind. hyp.
Γ^{∗}; (⌜Φ⌝, v_{1}:triv) ⊢ ⌜e′_{2}⌝ ⇑ exp  Theorem 106, Lemma 90
Γ^{∗}; ⌜Φ⌝ ⊢ λ^{>}v_{1}. ⌜e′_{2}⌝ ⇑ triv ↠ exp  ↠_{I}
(Γ^{∗}, ⌜Φ⌝); · ⊢ λ^{>}v_{1}. ⌜e′_{2}⌝ ⇑ triv ↠ exp  Lemma 90

(Γ^{∗}, ⌜Φ⌝); · ⊢ λv_{1}. Q_{2} ⇑

Πv_{1}:triv. cps e (⌜e_{2}⌝^{E})^{♯} (vlam^{>}λ^{>}v_{2}. app (⌜c⌝)^{♯} v_{1} v_{2}) (⌜e′_{2}⌝)^{♯}  Π_{I}
Φ ⊨^{Cont} \underline{λ}v_{1}. e′_{2}  defn.

(Γ^{∗}, ⌜Φ⌝); · ⊢ Q_{1} ⇑ cps e (⌜e_{1}⌝^{E})^{♯} (vlam^{>}λ^{>}v_{1}. (⌜e′_{2}⌝)^{♯}) (⌜e′⌝)^{♯}

and Φ ⊨^{Exp} e′  ind. hyp.

(Γ^{∗}, ⌜Φ⌝); · ⊢ cps app ⌜e_{1}⌝^{E} ⌜e_{2}⌝^{E} ⌜c⌝ (λ^{>}v_{1}. ⌜e′_{2}⌝) ⌜e′⌝ Q_{1} (λv_{1}. Q_{2}) ⇑

cps e (dapp (⌜e_{1}⌝^{E})^{♯} (⌜e_{2}⌝^{E})^{♯}) (⌜c⌝)^{♯} (⌜e′⌝)^{♯}  Π_{E}, coercion
□

Theorem 109 (Canonical Forms are Representations) Assume Γ only contains variables of the following types: dtriv, triv, cps t x x′ (for x, x′ in Γ), and cont. Further assume the types below are canonical.

1. Γ; ·; · ⊢ M ⇑ cps r R R′ implies ⊢ ⌞R⌟_{R} ⟶^{DR} ⌞R′⌟.

2. Γ; ·; · ⊢ M ⇑ cps e E C E′ implies ⊢ ⌞E⌟_{E} ; ⌞C⌟ ⟶^{DE} ⌞E′⌟.

3. Γ; ·; · ⊢ M ⇑ cps t T T′ implies ⊢ ⌞T ⌟_{T} ⟶^{DR} ⌞T′⌟.

Proof: By structural induction on the given canonical derivation. We give a representative case.

case: Γ; · ⊢ cps app E_{1} E_{2} C (λ^{>}v_{1}. E′_{2}) E′ D_{1} (λv_{1}. D_{2}) ⇑ cps e (dapp E_{1} E_{2}) C E′ Then

Γ; · ⊢ D_{1} ⇑ cps e E_{1} (vlam^{>}(λ^{>}v_{1}:triv. E′_{2})) E′  inversion on Π_{E}

Note Γ; ·; · ⊢ (λ^{>}v_{1}:triv. E′_{2})^{>}v_{1} = E′_{2} : exp (Γ, v_{1}:triv); · ⊢ D_{2} ⇑

cps e E_{2} (vlam^{>}(λ^{>}v_{2}:triv. app^{>}C^{>}v_{1}^{>}v_{2})) E′_{2}  inversion on Π_{E}, Π_{I}
⌞E_{2}⌟_{E}; \underline{λ}v_{2}. v_{1} v_{2} ⌞C⌟ ⟶^{DE} ⌞E′_{2}⌟  ind. hyp.
⌞E_{1}⌟_{E}; \underline{λ}v_{1}. E′_{2} ⟶^{DE} ⌞E′⌟  ind. hyp.

Note v_{1} cannot be in Γ

⌞E_{2}⌟_{E} ⌞E_{2}⌟_{E}; ⌞P ⌟ ⟶^{DE} ⌞E′⌟  defn.
□

The adequacy of our representation implies that the terms resulting from a CPS transformation satisfy the occurrence conditions of section 16.1.

⊢ r ⟶^{DR} r′ implies ⊨^{Root} r′.

It is also possible to represent a one-pass CPS transformation directly using thirdorder constructors and still guarantee ordering properties for the results. A further examination of this optimized translation is left as future work.

16.4 Bare Abstract Machine

We now begin extending our representation to include evaluation of CPS terms. We will begin by showing a representation of a naive evaluator which makes no use of the ordering invariants. The following is a bare abstract machine for CPS evaluation.

\frac{⊢_{B}^{Exp} e ↪ a}{⊢_{B}^{Root} \underline{λ}k. e ↪ a}  \overline{⊢_{B}^{Exp} k t ↪ t}

\frac{⊢_{B}^{Exp} e[t/v] ↪ a}{⊢_{B}^{Root} (\underline{λ}v. e) t ↪ a}  \frac{⊢_{B}^{Exp} e[t/x][c/k] ↪ a}{⊢_{B}^{Root} (\underline{λ}x. \underline{λ}k. e) t c ↪ a}

Notice that this machine describes a regular big-step operational semantics for a λ-calculus—every redex is reduced by a substitution.

We introduce two type constructors to represent bare evaluations:

evalr_{B} : root → triv → type. evale_{B} : exp → triv → type.

Additionally, we introduce a new object to our signature for CPS terms:

ret : cont

ret^{1} will be substituted for the continuation identifiers, k, in bare evaluations. In order to make the inverse representation function on objects well-defined, we augment it

1We chose the term ret for continuation identifiers since a continuation is not invoked until the end of the current computation, thus it is like a return statement.

with a continuation identifier k when applied to a continuation term or a serious term:

⌞klam (λ^{>}k. E)⌟ = \underline{λ}k. ⌞E⌟_{k}
⌞app^{>}C^{>}T_{0}^{>}T_{1}⌟_{k} = ⌞T_{0}⌟ ⌞T_{1}⌟ ⌞C⌟_{k}
⌞kapp^{>}C^{>}T ⌟_{k} = ⌞C⌟_{k} ⌞T ⌟
⌞lam (λx. R)⌟ = \underline{λ}x. ⌞R⌟
⌞x⌟ = x
⌞v⌟ = v
⌞vlam^{>}(λ^{>}v. E)⌟_{k} = \underline{λ}v. ⌞E⌟_{k}
⌞k⌟_{k} = k
⌞ret⌟_{k} = k

We use the following object constructors to represent bare evaluations:

evr_{B}  : ΠA:triv. ΠE:cont ↠ exp.
evale_{B} (E^{>}ret) A → evalr_{B} (klam E) A.
eve_{B} 0 : ΠA:triv. evale_{B} (kapp^{>}ret^{>}A) A.
eve_{B} 1 : ΠA:triv. ΠT:triv. ΠE:triv ↠ exp.
evale_{B} (E^{>}T) A → evale_{B} (kapp^{>}(vlam^{>}E)^{>}T) A.
eve_{B} app : ΠA:triv. ΠT:triv. ΠC:cont. ΠE:triv → cont ↠ exp.
evale_{B} ((E T)^{>}C) A→
evale_{B} (app^{>}C^{>}(lam (λx:triv. klam (E x)))^{>}T) A.

We prove that our representation of bare evaluations is in bijective correspondence with actual bare evaluations in two parts as follows.

Theorem 110 (Bare evaluations are canonical forms) Assume r and e have no free x.

1. ⊨^{Root} r, and ⊢_{B}^{Root} r ↪ a implies ∃Q. ·; · ⊢ Q ⇑ evalr_{B} (⌜r⌝)^{♯} (⌜a⌝)^{♯}.

2. k ⊨^{Exp} e, and ⊢_{B}^{Exp} e ↪ a implies ∃Q. ·; · ⊢ Q ⇑ evale_{B} (⌜e⌝[ret/k])^{♯} (⌜a⌝)^{♯}.

Proof: By structural induction on the given canonical derivation.

case: \frac{⊢_{B}^{Exp} e[t/x][c/k] ↪ a}{⊢_{B}^{Exp} (\underline{λ}x. \underline{λ}k. e) t c ↪ a} and k′ ⊨^{Exp} (\underline{λ}x. \underline{λ}k. e) t c

Then

· ⊨^{Triv} t and k ⊨^{Exp} e and k′ ⊨^{Cont} c  inversion

·; · ⊢ ⌜t⌝ ⇑ triv and x:triv; k:cont ⊢ ⌜e⌝ ⇑ exp and

·; k′:cont ⊢ ⌜c⌝ ⇑ cont  Theorem 106

·; · ⊢ ⌜t⌝ ↓ triv and x:triv; k:cont ⊢ ⌜e⌝ ↓ exp and

·; k′:cont ⊢ ⌜c⌝ ↓ cont  inversion
·; k′:cont ⊢ ⌜e⌝[⌜t⌝/x][⌜c⌝/k] ⇑ exp  Lemma 95
k′ ⊨^{Exp} e[t/x][c/k]  Theorem 107
·; · ⊢ Q ⇑ evale_{B} (⌜e[t/x][c/k]⌝[ret/k′])^{♯} (⌜a⌝)^{♯} for some Q  ind. hyp.
·; · ⊢ eve_{B} app ⌜a⌝ ⌜t⌝ (⌜c⌝[ret/k′]) (λx. λ^{>}k. ⌜e⌝) Q ⇑  Π_{E}

evale_{B} (app^{>}(⌜c⌝[ret/k′])^{♯}^{>}(lam λx:triv. klam λ^{>}k:cont. (⌜e⌝)^{♯})^{>}(⌜t⌝)^{♯}) (⌜a⌝)^{♯}.

□

Theorem 111 (Canonical forms are bare evaluations)

1. ·; · ⊢ Q ⇑ evalr_{B} R A implies ⊨^{Root} ⌞R⌟ and ⊢_{B}^{Root} ⌞R⌟ ↪ ⌞A⌟.

2. ·; · ⊢ Q ⇑ evale_{B} E A implies ⊢_{B}^{Exp} ⌞E⌟_{k} ↪ ⌞A⌟ for any k.

Proof: By induction on the given canonical typing derivation making use of αconversion to allow choice of any k.

case: ·; · ⊢ evr_{B} A E D ⇑ evalr (klam E) A Then

·; · ⊢ E ⇑ cont ↠ exp and E = λ^{>}k. E′  inversion
·; · ⊢ D ⇑ evale_{B} (E′[ret/k])^{♯} A  inversion
k ⊨^{Exp} ⌞E′[ret/k]⌟_{k} and ⊢_{B}^{Exp} ⌞E′[ret/k]⌟_{k} ↪ ⌞A⌟  ind. hyp.

Note ⌞E′[ret/k]⌟_{k} = ⌞E′⌟_{k}[⌞ret_{k}⌟/k] = ⌞E′⌟_{k}.

⊢_{B}^{Root} \underline{λ}k. ⌞E′⌟_{k} ↪ ⌞A⌟  defn
□

In addition to proving that we really have represented bare evaluations, we have also proved that bare evaluation preserves the ordering invariants of CPS terms. This comes for free as a result of theorem 107.

16.5 Stack Abstract Machine

We now consider a more sophisticated evaluation model which makes use of the ordering constraints on CPS terms. Rather than substituting for continuations and continuation parameters, we can evaluate terms by keeping a stack of continuations and their parameters and then effectively treating k and v as pop instructions.

We need stacks, ϕ, of both trivial terms and continuation terms for our stack evaluator.

ϕ ::= · | ϕ, t | ϕ, c

We give a big step operational semantics for stack evaluation as follows:

\frac{• ⊢_{St}^{Exp} e ↪ a}{⊢_{St}^{Root} \underline{λ}k. e ↪ a}  \frac{ϕ ⊢_{St}^{Triv} t ↪ a; •}{ϕ ⊢_{St}^{Exp} k t ↪ a}

\frac{ϕ ⊢_{St}^{Triv} t ↪ t′; ϕ′, \underline{λ}v. e ϕ′, t′ ⊢_{St}^{Exp} e ↪ a}{ϕ ⊢_{St}^{Exp} k t ↪ a}  \frac{ϕ ⊢_{St}^{Triv} t ↪ t′; ϕ′ ϕ′, t′ ⊢_{St}^{Exp} e ↪ a}{ϕ ⊢_{St}^{Exp} (\underline{λ}v. e) t ↪ a}

\frac{ϕ ⊢_{St}^{Triv} t_{1} ↪ t; ϕ′ ϕ′ ⊢_{St}^{Triv} t_{0} ↪ \underline{λ}x. \underline{λ}k. e; ϕ′′ ϕ′′ ⊢_{St}^{Exp} e[t/x] ↪ a}{ϕ ⊢_{St}^{Exp} t_{0} t_{1} k ↪ a}

\frac{ϕ ⊢_{St}^{Triv} t_{1} ↪ t; ϕ′ ϕ′ ⊢_{St}^{Triv} t_{0} ↪ \underline{λ}x. \underline{λ}k. e′; ϕ′′ ϕ′′, \underline{λ}v. e ⊢_{St}^{Exp} e′[t/x] ↪ a}{ϕ ⊢_{St}^{Exp} t_{0} t_{1} (\underline{λ}v. e) ↪ a}

\overline{ϕ ⊢_{St}^{Triv} \underline{λ}x. r ↪ \underline{λ}x. r; ϕ}  \overline{ϕ, t ⊢_{St}^{Triv} v ↪ t; ϕ}

Notice that this machine only performs substitution to reduce redices between trivial terms. Arguments to continuations are instead pushed onto the stack.

We show an OLF representation of the stack machine which uses the ordered context to represent the stack. We introduce the following new type constructors for representing stack evaluations:

evalr_{St} : root → triv → type. evale_{St} : exp → triv → type. evalt : triv → triv → type.

Since we use the ordered context as a stack, we also need constructors which allow us to put continuation terms and trivial terms into the ordered context:

cnt : cont → type. var : triv → type.

cnt and var will be used to represent continuation terms and trivial terms stored in the stack. We also introduce a new object:

pop : triv

which will be substituted for the continuation parameters, v during stack evaluation. As before we need to augment the inverse representation function with Φ as follows:

⌞klam (λ^{>}k. E)⌟ = \underline{λ}k. ⌞E⌟_{k}
⌞app^{>}C^{>}T_{0}^{>}T_{1}⌟_{ΦΦ_{0}Φ_{1}} = ⌞T_{0}⌟_{Φ_{0}} ⌞T_{1}⌟_{Φ_{1}} ⌞C⌟_{Φ}
⌞kapp^{>}C^{>}T ⌟_{ΦΦ_{t}} = ⌞C⌟_{Φ} ⌞T ⌟_{Φ_{t}}
⌞lam (λx. R)⌟_{·} = \underline{λ}x. ⌞R⌟
⌞x⌟_{·} = x
⌞v⌟_{v} = v
⌞pop⌟_{v} = v
⌞vlam^{>}(λ^{>}v. E)⌟_{Φ} = \underline{λ}v. ⌞E⌟_{Φ,v}
⌞k⌟_{k} = k
⌞ret⌟_{k} = k

The inverse representation function is stated non-deterministically– the splittings for Φ must be guessed. However, it is easy to see that the constraints on Φ in the variable cases ensure there will be at most one correct splitting of Φ at any point in the execution of the function.

We use the following term constructors to represent stack evaluations:

evr_{St} : ΠA:triv. ΠE:cont ↠ exp.

evale_{St} (E^{>}ret) A → evalr_{St} (klam E) A.

eve_{St} 0 : ΠA:triv. ΠT:triv.

evalt T A ↠ evale_{St} (kapp^{>}ret^{>}T) A.

eve_{St} 1 : ΠA:triv. ΠT:triv. ΠT′:triv. ΠE:triv ↠ exp.

(var T′ ↠ evale_{St} (E^{>}pop) A)↠ cnt (vlam^{>}E)↠ evalt T T′↠ evale_{St} (kapp^{>}ret^{>}T) A.

eve_{St} 2 : ΠA:triv. ΠT:triv. ΠT′:triv. ΠE:triv ↠ exp.

(var T′ ↠ evale_{St} (E^{>}pop) A)↠ evalt T T′↠ evale_{St} (kapp^{>}(vlam^{>}E)^{>}T) A.

eve_{St} app 0 : ΠA:triv. ΠT_{0}:triv. ΠT_{1}:triv. ΠT:triv. ΠE:triv → cont ↠ exp.

evale_{St} ((E T)^{>}ret) A↠ evalt T_{0} (lam λx:triv. klam (E x))↠ evalt T_{1} T ↠ evale_{St} (app^{>}ret^{>}T_{0}^{>}T_{1}) A.

eve_{St} app 1 : ΠA:triv. ΠT_{0}:triv. ΠT_{1}:triv. ΠE′:triv ↠ exp. ΠT:triv.

ΠE:triv → cont ↠ exp. (cnt (vlam^{>}E′) ↠ evale_{St} ((E T)^{>}ret) A)↠ evalt T_{0} (lam λx:triv. klam (E x))↠ evalt T_{1} T ↠ evale_{St} (app^{>}(vlam^{>}E′)^{>}T_{0}^{>}T_{1}) A.

evt lam  : ΠR:triv → root. evalt (lam R) (lam R).
evt vp  : ΠT:triv. var T ↠ evalt pop T.

Note that this representation does not contain an explicit stack. Instead, the ordered context of the type theory implicitly provides the representation of the evaluation machine’s stack. In order to prove our representations are in bijective correspondence to stack evaluations, we need the following auxiliary definitions.

For any term u, |⌜u⌝| denotes ⌜u⌝ with all free k replaced by ret and all free v replaced by pop.

We define validity for evaluation stacks, ϕ, with respect to Φ (as defined in section 16.1) as follows:

\overline{⊨^{E} · : k} \frac{· ⊨^{Triv} t ⊨^{E} ϕ : Φ}{⊨^{E} (ϕ, t) : (Φ, v)} \frac{⊨^{E} ϕ : (Φ, k′, Φ_{c}) (k′, Φ_{c}) ⊨^{cont} c}{⊨^{E} (ϕ, c) : (Φ, k′, Φ_{c}, k)}

\overline{⊨^{T} · : ·} \frac{· ⊨^{Triv} t ⊨^{T} ϕ : Φ}{⊨^{T} (ϕ, t) : (Φ, v)}

Finally we need a representation function, and its inverse, for evaluation stacks.

⌜·⌝  = ·  ⌞·⌟  = ·
⌜(ϕ, t)⌝ = ⌜ϕ⌝, vv:var ⌜t⌝  ⌞Ω, vv:var T ⌟ = ⌞Ω⌟, ⌞T ⌟_{·}
⌜(ϕ, c)⌝ = ⌜ϕ⌝, cv:cnt |⌜c⌝|  ⌞Ω, cv:cnt C⌟ = ⌞Ω⌟, ⌞C⌟_{Φ}

where we can construct Φ from the form of Ω as follows:

either Ω = Ω′, cv:cnt C′, Ω_{C} and we construct Φ such that ⊨^{E} ⌞Ω_{C}⌟ : Φ; or cv:cnt C′ ∉ Ω and we construct Φ such that ⊨^{E} ⌞Ω⌟ : Φ.

Theorem 112 (Stack evaluations are canonical forms) Assume all r, e, and t have no free x.

1. ⊢_{St}^{Root} r ↪ a and ⊨^{Root} r implies ∃M. ·; · ⊢ M ⇑ evalr_{St} ⌜r⌝ ⌜a⌝.

2. ϕ ⊢_{St}^{Exp} e ↪ a and ⊨^{E} ϕ : (Φ, k, Φ_{e}) (where ⋄ ∉ Φ_{e}) and (k, Φ_{e}) ⊨^{Exp} e

implies ∃M. ·; ⌜ϕ⌝ ⊢ M ⇑ evale_{St} |⌜e⌝| ⌜a⌝.

3. ϕ, ϕ_{t} ⊢_{St}^{Triv} t ↪ a; ϕ and ⊨^{T} ϕ_{t} : Φ_{t} and Φ_{t} ⊨^{Triv} t implies ∃M. ·; ⌜ϕ_{t}⌝ ⊢ M ⇑ evalt |⌜t⌝| ⌜a⌝.

Proof: By structural induction on the given derivations. In pt. 2, derivations of ⊨^{T} ϕ : Φ needed to apply the induction hypthesis are constructed by case analysis on the relevant trivial term.

□

Theorem 113 (Canonical forms are stack evaluations)

1. ·; ·; · ⊢ M ⇑ evalr_{St} R A implies ⊢_{St}^{Root} ⌞R⌟ ↪ ⌞A⌟_{·}.

2. ·; ·; Ω ⊢ M ⇑ evale_{St} E A and ⊨^{E} ⌞Ω⌟ : Φ implies ⌞Ω⌟ ⊢_{St}^{Exp} ⌞E⌟_{Φ} ↪ ⌞A⌟_{·}.

3. ·; ·; Ω ⊢ M ⇑ evalt_{St} T A and ⊨^{T} ⌞Ω⌟ : Φ implies ϕ′, ⌞Ω⌟ ⊢_{St}^{Exp} ⌞T ⌟_{Φ} ↪ ⌞A⌟_{·}; ϕ′ for any ϕ′.

Proof: By structural induction on the given canonical derivations. □

16.6 Bare and Stack Equivalence

In this section we show that the two evaluation models produce the same result. We will carry out our proof inside OLF. Note that this is different from formally representing a proof in OLF; instead we give an informal proof which happens to use OLF. Danvy and Pfenning give a similar proof in [15] which acts directly on the bare and stack machines. We note that carrying out this analysis on OLF representations does not simplify the proof. However, it does show that OLF is expressive enough to represent the main relation of Danvy and Pfenning’s proof as a type family. Furthermore, this representation has a direct computational interpretation as a logic program following the operational interpretation of LF type families as logic programs [43].

We first define a relation which holds when a term evaluated by the stack machine and a term evaluated by the bare machine will both evaluate to the same answer. We define this relation as four OLF type families.

trans r : root → root → type. trans e : exp → exp → type.

trans t : triv → triv → type. trans c : cont → cont → type.

The first argument to each type family will be a term partially evaluated by the stack machine, and the second argument will be a term partially evaluated by the bare machine. The term constructors for these families specify when partially evaluated terms are related. Partially evaluated terms are related if they are the same; pop is related to a trivial term t if var t′ is the rightmost ordered hypothesis and t′ is related to t; similarly, ret is related to a continuation term c if cnt c′ is the rightmost ordered hypothesis and c′ is related to c.

trans klam : ΠE:cont ↠ exp. ΠE′:cont ↠ exp.

(Πk:cont. trans c k k ↠ trans e (E^{>}k) (E′^{>}k))→ trans r (klam E) (klam E′)

trans app : ΠC:cont. ΠC′:cont. ΠT_{0}:triv. ΠE:triv → cont ↠ exp. ΠT_{1}:triv. ΠT′_{1}:triv.

trans c C C′↠ trans t T_{0} (lam λx:triv. klam λ^{>}k:cont. E x^{>}k)↠ trans t T_{1} T′_{1}↠ trans e (app^{>}C^{>}T_{0}^{>}T_{1}) (app^{>}C′^{>}(lam λx:triv. klam λ^{>}k:cont. E x^{>}k)^{>}T′_{1})

trans kapp : ΠC:cont. ΠC′:cont. ΠT:triv. ΠT′:triv.

trans c C C′↠ trans t T T′↠ trans e (kapp^{>}C^{>}T) (kapp^{>}C′^{>}T′)

trans lam : ΠR:triv → root. ΠR′:triv → root.

(Πx:triv. trans t x x → trans r (R x) (R′ x))→ trans t (lam R) (lam R′)

trans pop : ΠT:triv.

trans t T T → var T ↠ trans t pop T

trans vlam : ΠE:triv ↠ exp. ΠE′:triv ↠ exp.

(Πv:triv. trans t v v ↠ trans e (E^{>}v) (E′^{>}v))↠ trans c (vlam^{>}E) (vlam^{>}E′)

trans ret : ΠE:triv ↠ exp. ΠE′:triv ↠ exp.

trans c (vlam^{>}E′) (vlam^{>}E)↠ cnt (vlam^{>}E′)↠ trans c ret (vlam^{>}E).

trans init : trans c ret ret

In the rest of this section, all the outermost arguments explicit in the preceding constructors are left implicit.

We next prove some elementary properties of this relation, or set of type families, which are necessary to prove the main result, Theorem 119, which states that two related terms evaluate, using their respective machines, to the same answer.

For any OLF quasi canonical term Q whose free variables of type triv range over x_{1} … x_{n} and v_{1} … v_{m} we have the following definitions:

Γ_{x}^{Q} = x_{1}:triv, …, x_{n}:triv Γ_{xx}^{Q} = trans t x_{1} x_{1}, …, trans t x_{n} x_{n}
Γ_{v}^{Q} = v_{1}:triv, …, v_{m}:triv Ω_{v}^{Q} = trans t v_{1} v_{1}, …, trans t v_{m} v_{m}

Our first lemma states that if two terms are related in a context which does not contain variables of type var t nor of type cnt c, then the two terms are syntactically equal.

Lemma 114

1. Γ_{x}^{R}, Γ_{xx}^{R}; · ⊢ Q ⇑ trans r R R′ implies R = R′.

2. Γ_{x}^{E}, Γ_{xx}^{E}, k:cont, Γ_{v}^{E}; trans c k k, Ω_{v}^{E} ⊢ Q ⇑ trans e E E′ implies E = E′.

3. Γ_{x}^{T} , Γ_{xx}^{T}, Γ_{v}^{T}; Ω_{v}^{T} ⊢ Q ⇑ trans t T T′ implies T = T′.

4. Γ_{x}^{C}, Γ_{xx}^{C}, k:cont, Γ_{v}^{C}; trans c k k, Ω_{v}^{C} ⊢ Q ⇑ trans c C C′ implies C = C′.

Proof: By induction on the given derivation. □

We now need a lemma which shows that terms are related to themselves.

Lemma 115

1. Γ_{x}^{R}; · ⊢ R ⇑ root implies ∃Q. Γ_{x}^{R}, Γ_{xx}^{R}; · ⊢ Q ⇑ trans r R R.

2. Γ_{x}^{E}; k:cont, Γ_{v}^{E} ⊢ E ⇑ exp implies ∃Q. Γ_{x}^{E}, Γ_{xx}^{E}, k:cont, Γ_{v}^{E}; trans c k k, Ω_{v}^{E} ⊢ Q ⇑ trans e E E.

3. Γ_{x}^{T}; Γ_{v}^{T} ⊢ T ⇑ triv implies ∃Q. Γ_{x}^{T} , Γ_{xx}^{T}, Γ_{v}^{T}; Ω_{v}^{T} ⊢ Q ⇑ trans t T T.

4. Γ_{x}^{C}; k:cont, Γ_{v}^{C} ⊢ C ⇑ cont implies ∃Q. Γ_{x}^{C}, Γ_{xx}^{C}, k:cont, Γ_{v}^{C}; trans c k k, Ω_{v}^{C} ⊢ Q ⇑ trans c C C.

Proof: By induction on the given derivation. □

The next lemma contains two technical results. Trivial terms partially evaluated by the bare machine are always related to themselves in an empty ordered context since they contain no pop and only one ret (for the initial continuation). It also shows that the information in the evaluation stack can be used to further evaluate a partially stack evaluated trivial term to a bare evaluated trivial term, provided the two terms are related.

Lemma 116

1. Γ; Ω ⊢ Q ⇑ trans t T T′ implies ∃Q′. Γ; · ⊢ Q′ ⇑ trans t T′ T′

2. ·; Ω ⊢ Q ⇑ trans t T T′ implies ∃Q′. ·; Ω ⊢ Q′ ⇑ evalt_{St} T T′

Proof: By induction on the given derivation. □

The next two lemmas are essentially substitution lemmas for stack “variables”. In the constructors for deciding if two partially evaluated terms are related, recursive descent into functional terms (the trans klam, trans lam, and trans vlam) is achieved, by generating a new parameter and applying it to both terms under the assumption that the parameter is related to itself. The next lemmas state that we may substitute actual terms into such parameters.

Lemma 117 In the following assume Γ = x_{1}:triv, m_{1}:trans t x_{1} x_{1}, …, x_{n}:triv, m_{n}:trans t x_{n} x_{n}, k:cont, v_{1}:triv, …, v_{m}:triv; and that Ω_{R} only contains identifiers of types var X and at most one identifier of type trans t v_{i} v_{i} for each v_{i} in Γ.

1. Γ, v:triv; Ω_{L}, m:trans t v v, Ω_{R} ⊢ Q ⇑ trans e E E′ and ·; · ⊢ R ⇑ trans t T T implies ∃Q′. Γ; Ω_{L}, m′:var T, Ω_{R} ⊢ Q′ ⇑ trans e (E[pop/v]) (E′[T/v])

2. Γ, v:triv; Ω_{L}, m:trans t v v, Ω_{R} ⊢ Q ⇑ trans c C C′ and ·; · ⊢ R ⇑ trans t T T implies ∃Q′. Γ; Ω_{L}, m′:var T, Ω′_{R} ⊢ Q′ ⇑ trans c (C[pop/v]) (C′[T/v])

Proof: By induction on the major given derivation. Assume ·; · ⊢ R ⇑ trans t A A.

• case:

Γ, v:triv; Ω_{L}, m:trans t v v, Ω_{R} ⊢ trans kapp^{>}R_{C}^{>}R_{T} ⇑ trans e (kapp^{>}C^{>}T) (kapp^{>}C′^{>}T′) Note that m must be consumed by either R_{C} or R_{T}.

– subcase: Γ, v:triv; Ω_{L}, m:trans t v v, Ω_{RL} ⊢ R_{C} ⇑ trans c C C′ and Ω_{R} = Ω_{RL}Ω_{RR}

Note v cannot occur free in T or T′  trans t v v ∉ Γ, Ω_{RR}

Γ; Ω_{L}, m′:var A, Ω_{RL} ⊢ R′_{C} ⇑ trans c (C[pop/v]) (C′[A/v])

for some R′_{C}  ind. hyp.

Γ; Ω_{L}, m′:var A, Ω_{R} ⊢ trans kapp^{>}R′_{C} ^{>}R_{T} ⇑

trans e (kapp^{>}(C[pop/v])^{>}T) (kapp^{>}(C′[A/v])^{>}T′)  Π_{E}

– subcase:

Γ, v:triv; Ω_{LR}, m:trans t v v, Ω_{R} ⊢ R_{T} ⇑ trans t T T′ and Ω_{L} = Ω_{LL}Ω_{LR}

Ω_{LR} = · = Ω_{R} and R_{T} = m and T = v = T′  inversion
Γ; m′:var A ⊢ trans pop^{>}R^{>}m′ ⇑ trans t pop A  Π_{E}

Note we can remove v:triv since v no longer occurs free in goal. Γ; Ω_{LL}, m′:var A ⊢ trans kapp^{>}R_{C} ^{>}(trans pop^{>}R^{>}m′) ⇑

trans e (kapp^{>}C^{>}pop) (kapp^{>}C′^{>}A)  Π_{E}

• case: trans app is similar.

• case:

Γ, v:triv; Ω_{L}, m:trans t v v, Ω_{R} ⊢ trans vlam^{>}(λv′:triv. λ^{>}m′:trans t v′ v′. R_{E}) ⇑

trans c (vlam^{>}λ^{>}v′:triv. E) (vlam^{>}λ^{>}v′:triv. E′) Γ, v:triv, v′:triv; Ω_{L}, m:trans t v v, Ω_{R}, m′:trans t v′ v′ ⊢ R_{E} ⇑

trans e E E′  inversion

Γ, v′:triv; Ω_{L}, m′′:var A, Ω_{R}, m′:trans t v′ v′ ⊢ R′_{E} ⇑

trans e (E[pop/v]) (E′[A/v]) for some R′_{E}  ind. hyp.

Γ; Ω_{L}, m′′:var A, Ω_{R} ⊢ trans vlam^{>}(λv′:triv. λ^{>}m′:trans t v′ v′. R′_{E}) ⇑

trans c (vlam^{>}λ^{>}v′:triv. E[pop/v]) (vlam^{>}λ^{>}v′:triv. E′[A/v])  Π_{E}

• No other cases.

□

Lemma 118 In the following assume Γ = x_{1}:triv, m_{1}:trans t x_{1} x_{1}, …, x_{n}:triv, m_{n}:trans t x_{n} x_{n}, v_{1}:triv, …, v_{m}:triv; and that Ω only contains identifiers of types var X and at most one identifier of type trans t v_{i} v_{i} for each v_{i} in Γ.

1. Γ, k:cont; m:trans c k k, Ω ⊢ Q ⇑ trans e E E′ and ·; Ω′ ⊢ R ⇑ trans c C_{s} C_{b} implies ∃Q′. Γ; Ω′, m′:cnt C_{s}, Ω ⊢ Q′ ⇑ trans e (E[ret/k]) (E′[C_{b}/k]).

2. Γ, k:cont; m:trans c k k, Ω ⊢ Q ⇑ trans c C C′ and ·; Ω′ ⊢ R ⇑ trans c C_{s} C_{b} implies ∃Q′. Γ; Ω′, m′:cnt C_{s}, Ω ⊢ Q′ ⇑ trans c (C[ret/k]) (C′[C_{b}/k]).

Proof: Similar to previous proof. □

We can now prove the main theorem, that related terms evaluate to the same result in both machines.

Theorem 119

1. ∃R. ·; ⊢ R ⇑ trans r Rt Rt′ implies ∃Q. ·; · ⊢ Q ⇑ evalr_{St} Rt A iff ∃Q′. ·; · ⊢ Q′ ⇑ evalr_{B} Rt′ A.

2. ∃R. ·; Ω ⊢ R ⇑ trans e E E′ implies ∃Q. ·; Ω ⊢ Q ⇑ evale_{St} E A iff ∃Q′. ·; · ⊢ Q′ ⇑ evale_{B} E′ A.

Proof: By induction on the given evaluation derivation. Note that R determines which evaluation is being considered.

• case:

·; · ⊢ trans klam (λk:cont. λ^{>}m:trans c k k. R_{E}) ⇑
trans r (klam λ^{>}k:cont. E) (klam λ^{>}k:cont. E)
k:cont; m:trans c k k ⊢ R_{E} ⇑ trans e E E′  inversion
·; · ⊢ R_{E}[ret/k][trans init/m] ⇑ trans e (E[ret/k]) (E′[ret/k])  Lemma 95

Suppose ·; · ⊢ evr_{St} Q_{E} ⇑ evalr_{St} (klam λ^{>}k:cont. E) A.

·; · ⊢ Q_{E} ⇑ evale_{St} (E[ret/k]) A  inversion
∃Q′_{E}. ·; · ⊢ Q′_{E} ⇑ evale_{B} (E′[ret/k]) A  ind. hyp.

·; · ⊢ evr_{B} Q′_{E} ⇑ evalr_{B} (klam λ^{>}k:cont. E′) A  Π_{E}

Other direction is similar.

• case:

·; Ω_{C}Ω_{T} ⊢ trans kapp^{>}R_{c}^{>}R_{T} ⇑ trans c (kapp^{>}C^{>}T) (kapp^{>}C′^{>}T′)

·; Ω_{T} ⊢ R_{T} ⇑ trans t T T′  inversion

∃Q_{T} , R_{T′}. ·; Ω_{T} ⊢ Q_{T} ⇑ evalt_{St} T T′ and

·; · ⊢ R_{T′} ⇑ trans t T′ T′  Lemma 116

– subcase: C = ret and Ω_{C} = ·

C′ = ret and R_{C} = trans init  inversion

·; Ω_{T} ⊢ eve 0_{St}^{>}Q_{T} ⇑ evale_{St} (kapp^{>}ret^{>}T) T′ and

·; · ⊢ eve 0_{B} ⇑ evale_{B} (kapp^{>}ret^{>}T′) T′  Π_{E}

– subcase: C = ret and Ω_{C} ≠ · C′ = vlam^{>}λ^{>}v:triv. E′ and Ω_{C} = Ω_{E}, m:cnt (vlam^{>}λ^{>}v:triv. E) and R_{C} = trans ret^{>}(trans vlam^{>}λv:triv. λ^{>}m_{v}:trans t v v. R_{E})^{>}m and

v:triv; Ω_{E}, m_{v}:trans t v v ⊢ R_{E} ⇑ trans e E E′  inversion

·; Ω_{E}, m:cnt (vlam^{>}λ^{>}v:triv. E) ⊢ eve 1_{St}^{>}(λ^{>}m_{T′}:var T′. Q_{E})^{>}m^{>}Q_{T} ⇑

evale_{St} (kapp^{>}ret^{>}T) A  new assumption
·; Ω_{E}, m_{T′}:var T′ ⊢ Q_{E} ⇑ evale_{St} (E[pop/v]) A  inversion
∃R′_{E}. ·; Ω_{E}, m_{T′}:var T′ ⊢ R′_{E} ⇑ trans e(E[pop/v]) (E′[T′/v) Lemma 117
∃Q′_{E}. ·; · ⊢ Q′_{E} ⇑ evale_{B} (E′[T′/v]) A  ind. hyp.
·; · ⊢ eve 1_{B} Q′_{E} ⇑ evale_{B} (kapp^{>}(vlam^{>}λ^{>}v:triv. E′)^{>}T′) A  Π_{E}

Similar reasoning for the other direction.

– subcase: C = vlam^{>}λ^{>}v:triv. E C′ = vlam^{>}λ^{>}v:triv. E′ and

R_{C} = trans vlam^{>}λv:triv. λ^{>}m_{v}:trans t v v. R_{E}  inversion

Then similar reasoning to previous applies.

• case:

·; Ω_{C}, Ω_{T_{0}}, Ω_{T_{1}} ⊢ trans app^{>}R_{C} ^{>}R_{T_{0}} ^{>}R_{T_{1}} ⇑ trans e (app^{>}C^{>}T_{0}^{>}T_{1}) (app^{>}C′^{>}(lam λx:triv. klam λ^{>}k:cont. E)^{>}T′_{1})

·; Ω_{C} ⊢ R_{C} ⇑ trans c C C′ and ·; Ω_{T_{1}} ⊢ R_{T_{1}} ⇑ trans t T_{1} T′_{1} and

·; Ω_{T_{0}} ⊢ R_{T_{0}} ⇑ trans t T_{0} (lam λx:triv. klam λ^{>}k:cont. E)  inversion

·; · ⊢ R′_{T_{1}} ⇑ trans t T′_{1} T′_{1} and ·; · ⊢ R′_{T_{0}} ⇑ trans t(lam λx:triv. klam λ^{>}k:cont. E) (lam λx:triv. klam λ^{>}k:cont. E)

for some R′_{T_{0}} and R′_{T_{1}}  Lemma 116
R′_{T_{0}} =  inversion

trans lam (λx:triv. λm_{x}:trans t x x. trans klam λk:cont. λ^{>}m_{k}:trans c k k. R_{E})

x:triv, m_{x}:trans t x x, k:cont; m_{k}:trans c k k ⊢ R_{E} ⇑ trans e E E  inversion

k:cont; m_{k}:trans c k k ⊢ R_{E}[T′_{1}/x][R′_{T_{1}}/m_{x}] ⇑

trans e (E[T′_{1}/x]) E([T′_{1}/x])  Lemma 95

Then similar reasoning to previous case, using both lemma 117 and lemma 118, can be employed to complete the proof. Note there are 2 subcases, C = ret and C = vlam^{>}λ^{>}v:triv. E_{v}.

□

Theorem 120 (Equivalence of Machine Representations) ∃M. ·; · ⊢ M ⇑ evalr_{St} R A iff ∃M′. ·; · ⊢ M′ ⇑ evalr_{B} R A

Proof: Immediate from previous lemmas and theorems □

We may now use Theorem 111 and Theorem 113 to transfer the result of Theorem 120 back to the informal bare and stack evaluation machines.

16.7 Conclusion

We have shown that an ordered logical framework provides the necessary machinery for a natural encoding of CPS terms satisfying the given occurrence invariants. We have further shown that the framework is rich enough to allow a natural representation of stack-based evaluation. Furthermore we have seen that preservation of CPS invariants under evaluation is then trivial to prove. We feel this in itself is significant considering the difficulty involved in carrying out such representations in a framework with no inherent notion of order. Dzafic [17] has shown how to represent system and properties closely related to ours in LF, with considerable overhead since stacks and the necessary substitution properties all have to be represented explicitly.

Finally, we mention that these techniques are easily extended to represent and reason about other systems which rely upon an ordering of resources. For instance, [54] extends the analysis, and results, of this chapter to a CPS transform which removes explicit exceptions. We also strongly conjecture that both the analysis of evaluation with first class continuations, carried out in [13], and the analysis of information flow using ordered continuations in [62] can be naturally re-formulated in OLF.

Part IV Conclusions

265

Conclusions and Future Work

Ordered linear logic is a new logical formalism which conservatively extends (intuitionistic) linear logic with ordered hypotheses– hypotheses which must be used exactly once subject to the order in which they were assumed. The logic is constructed, in the style of Martin-Löf, from the basic notion of a hypothetical judgement and its associated substitution principle. Specifically, ordered linear logic results from combining three different kinds of hypothetical judgements– unrestricted, linear, and ordered.

Ordered linear logic seems to have several advantages over other logical systems which combine unrestricted, linear and ordered reasoning such as Non-Commutative Logic [1, 57], cyclic linear logic [61], and pomset logic [56]. Since ordered linear logic is intuitionistic and associates structural properties with formulas, rather than contexts^{1}, it is a simpler system than its counterparts. In fact, most of the proofs of basic results (e.g., cut elimination, normalization, focussing, etc...) in this thesis are straightforward extensions of those for linear logic. Proving similar properties for Non-Commutative Logic has not turned out to be so easy, as evidenced by [5, 18]. Furthermore, since ordered linear logic is intuitionistic, it gives rise to a typed term calculus which can be used as the basis of a logical framework.

While we have presented the basic system of ordered linear logic, there is much room for further exploration. As mentioned in Section 2.7, there are other ways to combine the three modes of reasoning present in the system. It seems quite likely that a logical system which incorporates both formula-level and context-level structural properties exists. This logic could be formulated as a sequent system with three

1as described in Section 2.7

context constructors and two modalities.

Another possibility for exploration involves making the ordered context circular. Investigations of intuitionistic logics have typically only considered non-cyclic contexts, however it seems likely that a coherent intuitionistic logical system with a circular context exists. Such a system would be quite different from ordered linear logic, and probably would not be useful for the same applications; however a circular context might also remove certain unsatisfactory situations such as the inability to residuate ordered formulas.

Some other directions for exploration include the addition of a (multiplicative) negation, i.e., ⊥; and the definition of a formal mathematical semantics for ordered linear logic.

After presenting the basic system of ordered linear logic, we showed that proof search in the logic behaves similarly to proof search in linear logic. In particular, there is a readily identifiable uniform fragment of ordered linear logic which can serve as the basis for a logic programming language, as well as a logical framework. Ordered versions of these linear logic applications afford considerably more elegant solutions than their linear counterparts. Specifically, the ordered context can be used to implicitly represent simple data structures (e.g., stacks, queues), eliminating the need to explicitly construct such structures at the term level.

For logic programming, this expressivity results in more elegant code than is possible using just unrestricted and/or linear hypotheses. Furthermore, shifting some data structures to the logical level (as opposed to the term level) opens up the possibility of more efficient executions as compiler technology for ordered/linear logic programming languages improves. For logical frameworks, it allows representations using higher-order abstract syntax which would not be possible without ordered hypotheses; this in turn makes representation of meta-theoretic properties tractable. For example, using LF (or linear LF), it is not feasible to completely represent the equivalence between lambda terms represented via higher-order abstract syntax and DeBruijn terms. However, the ordered logical framework permits a natural encoding of DeBruijn terms which allows a straightforward encoding of the proof of equivalence using the standard LF methodology.

There are, of course, limitations to what can be represented with the ordered context. So far, we have only really used the ordered context as a stack, or a queue. Furthermore, it only seems possible to have one logical queue or stack in a representation. Thus, an Olli program implementing an algorithm requiring two separate work queues would need to represent one of the queues in the term level. On a slightly different (though probably related) note, writing a meta-circular interpreter in Olli is surprisingly difficult. The very natural approach which works for both (pure) λProlog and Lolli breaks down for Olli. The problem lies in the inability to store information in a formula about its position in the ordered context, which is necessary for the meta-circular interpreter to correctly match the operational behavior of Olli and maintain the ordering constraints. Writing a correct meta-circular interpreter seems to require explicitly creating machinery to maintain the ordering constraints. A similar difficulty arises when trying to formalize a proof of cut-elimination for ordered linear logic in the ordered logical framework. In addition to investigating possible solutions to the above mentioned problems, we would like to expand the range of applications for ordered linear logic, which we feel is largely unexplored.

Finally, we note that a largely ignored aspect of this work is in applications of the ordered lambda calculus. This dissertation has only employed ordered terms in the logical framework setting. It would be interesting to explore direct applications of the ordered lambda calculus.

270

Bibliography

[1] V. Michele Abrusci and Paul Ruet. Non-commutative logic I: The multiplicative fragment. Annals of Pure and Applied Logic, 101(1):29–64, 1999.

[2] J.-M. Andreoli. Proposal for a Synthesis of Logic and Object-Oriented Programming Paradigms. PhD thesis, University of Paris VI, 1990.

[3] J.-M. Andreoli. Logic programming with focusing proofs in linear logic. Journal of Logic and Computation, 2(3):297–347, 1992.

[4] J.-M. Andreoli. Focussing and proof construction. Annals of Pure and Applied Logic, 2000. to appear.

[5] Jean-Marc Andreoli and Roberto Maieli. Focusing and proof-nets in linear and non-commutative logic. In Harald Ganzinger, David McAllester, and Andrei Voronkov, editors, Proceedings of 6th International Conference on Logic Programming and Automated Reasoning, pages 320–336, Tbilisi, Republic of Georgia, September 1999. Springer-Verlag LNAI 1705.

[6] Henk P. Barendregt. Lambda calculi with types. In S. Abramsky, D. Gabbay, and T.S.E. Maibaum, editors, Handbook of Logic in Computer Science, volume 2, chapter 2, pages 117–309. Oxford University Press, 1992.

[7] G. M. Bierman. A note on full intuitionistic linear logic. Annals of Pure and Applied Logic, 79(3):281–287, June 1996.

[8] C. Brown and D. Gurr. Relations and non-commutative linear logic. Technical Report DAIMI PB-372, Computer Science Department, Aarhus University, November 1991.

[9] Iliano Cervesato. Proof-theoretic foundation of compilation in logic programming languages. In J. Jaffar, editor, Proceedings of the 1998 Joint International Conference and Symposium on Logic Programming (JICSLP’98), pages 115–129, Manchester, UK, June 1998. MIT Press.

[10] Iliano Cervesato, Joshua S. Hodas, and Frank Pfenning. Efficient resource management for linear logic proof search. Theoretical Computer Science, 232:133– 163, 2000. Revised version of paper in the Proceedings of the 5th International Workshop on Extensions of Logic Programming, Leipzig, Germany, March 1996.

[11] Iliano Cervesato and Frank Pfenning. A linear logical framework. Information and Computation, 1999. To appear in the special issue with invited papers from LICS’96, E. Clarke, editor.

[12] Alonzo Church. A formulation of the simple theory of types. Journal of Symbolic Logic, 5:56–68, 1940.

[13] Olivier Danvy. Formalizing implementation strategies for first-class continuations. In Programming Languages and Systems, The Proceedings of the 9th European Symposium on Programming, volume 1782 of lncs, pages 88–103, 2000.

[14] Olivier Danvy, Belmina Dzafic, and Frank Pfenning. On proving syntactic properties of CPS programs. In Third International Workshop on Higher Order Operational Techniques in Semantics (HOOTS’99), Paris, France, September 1999.

[15] Olivier Danvy and Frank Pfenning. The occurrence of continuation parameters in CPS terms. Technical Report CMU-CS-95-121, Department of Computer Science, Carnegie Mellon University, February 1995.

[16] Philippe de Groote. Partially commutative linear logic: sequent calculus and phase semantics. In V.M. Abrusci and C. Casadio, editors, Proofs and Linguistic Categories, Application of Logic to the Analysis and Implementation of Natural Language Proceedings 1996 Roma Workshop, pages 199–208. Cooperativa Libraria Universitaria Editrice Bologna, 1996.

[17] Belmina Dzafic. Formalizing program transformations. Master’s thesis, DAIMI, Department of Computer Science, University of Aarhus, Aarhus, Denmark, December 1998.

[18] Claudia Faggian. Proof construction and non-commutativity: a cluster calculus. In Proceedings of the 2nd International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP’00), Montreal,Canada, September 2000.

[19] Jean Gallier. On Girard’s “candidats de reductibilité”. In Odifreddi, editor, Logic and Computer Science, pages 123–203. Academic Press, 1990.

[20] Jean Gallier. Constructive logics. Part I: A tutorial on proof systems and typed λ-calculi. Theoretical Computer Science, 110(2):249–339, 1993.

[21] J.-Y. Girard. Linear logic. Theoretical Computer Science, 50:1–102, 1987.

[22] J.A. Harland and David J. Pym. Resource-distribution via boolean constraints. In W. McCune and G. Sutcliffe, editors, Proc. CADE-14, pages 222–236. Springer-Verlag LNCS 1249, 1997.

[23] Robert Harper, Furio Honsell, and Gordon Plotkin. A framework for defining logics. Journal of the Association for Computing Machinery, 40(1):143–184, January 1993.

[24] Robert Harper and Frank Pfenning. On equivalence and canonical forms in the LF type theory. Technical Report CMU-CS-00-148, Department of Computer Science, Carnegie Mellon University, July 2000. An extended abstract appeared at Workshop on Logical Frameworks and Meta-Languages (LFM’99), Paris, France, September 1999.

[25] Hugo Herbelin. Séquents qu’on calcule. PhD thesis, Université Paris 7, January 1995.

[26] J. S. Hodas. Logic Programming in Intuitionistic Linear Logic: Theory, Design and Implementation. PhD thesis, University of Pennsylvania, Department of Computer and Information Science, 1994.

[27] J. S. Hodas and D. Miller. Logic programming in a fragment of intuitionistic linear logic. Information and Computation, 110(2):327–365, 1994. Extended abstract in the Proceedings of the Sixth Annual Symposium on Logic in Computer Science, Amsterdam, July 15–18, 1991.

[28] Joshua S. Hodas and Naoyuki Tamura. lolliCOP - a linear logic encoding of a lean connection-method theorem prover for first-order classical logic. In Proceedings of the International Joint Conference on Automated Reasoning, pages 670–684, Siena, Italy, June 2001.

[29] Martin Hofmann. Linear types and non-size-increasing polynomial time computation. In G. Longo, editor, Proceedings of the Fourteenth Annual Symposium on Logic in Computer Science, pages 464–473, Trento, Italy, July 1999. IEEE Computer Society Press.

[30] W.A. Howard. The formula-as-types notion of construction. In J.R. Hindley and J.P. Seldin, editors, To H.B. Curry, Essays on Combinatory Logic, Lambda Calculus, and Formalism. Academic Press, 1980.

[31] Twan Laan, Fairouz Kamareddine, and Rob Nederpelt. Refining the Barendregt cube using parameters. In Herbert Kuchen and Kazunori Ueda, editors, Proceedings of the 5th International Symposium on Functional and Logic Programming (FLOPS’01), pages 375–389, Tokyo, Japan, March 2001. Springer-Verlag LNCS 2024.

[32] Joachim Lambek. The mathematics of sentence structure. American Mathematical Monthly, 65:363–386, 1958.

[33] Pablo Lopez and Ernesto Pimentel. Resource management in linear logic proof search revisited. In Harald Ganzinger, David McAllester, and Andrei Voronkov, editors, Proceedings of 6th International Conference on Logic Programming and Automated Reasoning, pages 304–319, Tbilisi, Republic of Georgia, September 1999. Springer-Verlag LNAI 1705.

[34] Per Martin-Löf. Constructive mathematics and computer programming. In Logic, Methodology and Philosophy of Science VI, pages 153–175. North-Holland, 1980.

[35] Dale Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. Journal of Logic and Computation, 1(4):497– 536, 1991.

[36] Dale Miller and Gopalan Nadathur. Higher-order logic programming. In Ehud Shapiro, editor, Proceedings of the Third International Logic Programming Conference, pages 448–462, London, June 1986.

[37] Dale Miller, Gopalan Nadathur, Frank Pfenning, and Andre Scedrov. Uniform proofs as a foundation for logic programming. Annals of Pure and Applied Logic, 51:125–157, 1991.

[38] Gopalan Nadathur and Dustin J. Mitchell. System description: Teyjus—a compiler and abstract machine based implementation of lambda prolog. In H. Ganzinger, editor, Proceedings of the 16th International Conference on Automated Deduction (CADE-16), pages 287–291, Trento, Italy, July 1999. Springer-Verlag LNCS.

[39] P. W. O’Hearn and J. C. Reynolds. From algol to polymorphic linear lambdacalculus. Journal of the ACM, 47(1):167–223, January 2000.

[40] P.W. O’Hearn and D. J. Pym. The logic of bunched implications. Bulletin of Symbolic Logic, 5(2):215–244, June 1999.

[41] Chris Okasaki. Breadth-first numbering: Lessons from a small exercise in algorithm design. In Proceedings of International Conference on Functional Programming, pages 131–136, September 2000.

[42] Remo Pareschi. Type-Driven Natural Language Analysis. PhD thesis, University of Edinburgh, Edinburgh, Scotland, July 1989. Available as technical report MS-CIS-89-45, Department of Computer and Information Sciences, University of Pennsylvania.

[43] Frank Pfenning. Logic programming in the LF logical framework. In Gérard Huet and Gordon Plotkin, editors, Logical Frameworks, pages 149–181. Cambridge University Press, 1991.

[44] Frank Pfenning. Structural cut elimination in linear logic. Technical Report CMU-CS-94-222, Department of Computer Science, Carnegie Mellon University, December 1994.

[45] Frank Pfenning. Structural cut elimination. In D. Kozen, editor, Proceedings of the Tenth Annual Symposium on Logic in Computer Science, pages 156–166, San Diego, California, June 1995. IEEE Computer Society Press.

[46] Frank Pfenning. The practice of logical frameworks. In Hélène Kirchner, editor, Proceedings of the Colloquium on Trees in Algebra and Programming, pages 119– 134, Linköping, Sweden, April 1996. Springer-Verlag LNCS 1059. Invited talk.

[47] Frank Pfenning. Computation and Deduction. Cambridge University Press, 2001. In preparation. Draft from April 1997 available electronically.

[48] Frank Pfenning and Carsten Schürmann. System description: Twelf — a metalogical framework for deductive systems. In H. Ganzinger, editor, Proceedings of the 16th International Conference on Automated Deduction (CADE-16), pages 202–206, Trento, Italy, July 1999. Springer-Verlag LNAI 1632.

[49] Jeff Polakow. Linear logic programming with an ordered context. In Proceedings of the 2nd International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP’00), pages 68–79, Montreal,Canada, September 2000.

[50] Jeff Polakow and Frank Pfenning. Ordered linear logic programming. Technical Report CMU-CS-98-183, Department of Computer Science, Carnegie Mellon University, December 1998.

[51] Jeff Polakow and Frank Pfenning. Natural deduction for intuitionistic noncommutative linear logic. In J.-Y. Girard, editor, Proceedings of the Fourth International Conference on Typed Lambda Calculi and Applications (TLCA’99), pages 295–309, l’Aquila, Italy, April 1999. Springer-Verlag LNCS 1581.

[52] Jeff Polakow and Frank Pfenning. Relating natural deduction and sequent calculus for intuitionistic non-commutative linear logic. In Andre Scedrov and Achim Jung, editors, Proceedings of the 15th Conference on Mathematical Foundations of Programming Semantics, pages 311–328, New Orleans, Louisiana, April 1999. Electronic Notes in Theoretical Computer Science, Volume 20.

[53] Jeff Polakow and Frank Pfenning. Properties of terms in continuation passing style in an ordered logical framework. In Workshop on Logical Frameworks and Meta-Languages (LFM 2000), Santa Barbara, California, June 2000.

[54] Jeff Polakow and Kwangkeun Yi. Proving syntactic properties of exceptions in an ordered logical framework. In Herbert Kuchen and Kazunori Ueda, editors, Proceedings of the 5th International Symposium on Functional and Logic Programming (FLOPS’01), pages 61–77, Tokyo, Japan, March 2001. Springer-Verlag LNCS 2024.

[55] D. Prawitz. Ideas and results in proof theory. In Jens Erik Fenstad, editor, Proceedings of the 2nd Scandinavian Logic Symposium, pages 235–307, North Holland, Amsterdam, June 1970.

[56] Christian Retore. Pomset logic: a non-commutative extension of classical linear logic. In Proceedings of the Second International Conference on Typed Lambda Calculi and Applications (TLCA’97), pages 300–318. Springer-Verlag LNCS 1210, 1997.

[57] P. Ruet. Non-commutative logic II : sequent calculus and phase semantics. Mathematical Structures in Computer Science, 10(2):277–312, 2000.

[58] Paul Ruet. Logique non-commutative et programmation concurrente par contraintes. PhD thesis, Universite Denis Diderot, Paris 7, 1997.

[59] Joseph Vanderwaart and Karl Crary. A simplified account of the metatheory of linear LF. unpublished manuscript, 2000.

[60] P. Wadler. Linear types can change the world. In M. Broy and C. B. Jones, editors, IFIP TC 2 Working Conference on Programming Concepts and Methods, pages 561–581, Sea of Gallilee, Israel, April 1990. North-Holland.

[61] D.N. Yetter. Quantales and (non-commutative) linear logic. Journal of Symbolic Logic, 55(1):41–64, 1990.

[62] Steve Zdancewic and Andrew C. Myers. Secure information flow and CPS. In Proceedings of the 10th European Symposium on Programming (ESOP’01), pages 46–61. Springer-Verlag LNCS 2028, April 2001.