Elimination of Negation in a Logical Framework

Alberto Momigliano July 6, 2000

Department of Philosophy 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 Dana Scott Dale Miller, Pennsylvania State University

Copyright \begin{matrix}c \\ ◯ \end{matrix} 2000 Alberto Momigliano

Abstract

We address the issue of endowing a logical framework with a logically justified notion of negation. Logical frameworks with a logic programming interpretation such as hereditary Harrop formulae cannot directly express negative information, although negation is a useful specification tool. Since negation-as-failure does not fit well in a logical framework, especially one endowed with hypothetical and parametric judgments, we adapt the idea of elimination of negation from Horn logic to a fragment of higher-order hereditary Harrop formulae. The idea is to replace occurrences of negative predicates with positive ones which are operationally equivalent. This entails two separate phases.

Complementing terms, i.e. in our case higher-order patterns. Due the presence of partially applied lambda terms, intuitionistic lambda calculi are not closed under complementation. We thus develop a strict lambda calculus, where we can directly express whether a function depends on its argument.

Complementing clauses. This can be seen as a negation normal form procedure which is consistent with intuitionistic provability. It entails finding a middle ground between the Closed World Assumption usually associated with negation and the Open World Assumption typical of logical frameworks. As this is in general not possible, we restrict ourselves to a fragment in which clause complementation is viable and that has proven to be expressive enough for the practice of logical frameworks. The main technical idea is to isolate a set of programs where static and dynamic clauses do not overlap.

\underline{ii}

Draft of July 6, 2000

Contents

1 Introduction 1 1.1 Logical Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2.1 What is Failure (in a Logical Framework)? . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2.2 Which Logical Framework? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.3 From Theorem Proving to Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4 Negation-as-Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.5 Extending Horn Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.5.1 Constructive Negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.5.2 Non-Failure Driven Negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.5.3 Proof-Theoretic Approaches to Negation and NF . . . . . . . . . . . . . . . . . . . . . 12 1.5.4 Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.6 Contributions and Technical Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2 The Relative Complement Problem 15 2.1 The Not Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2 Disunification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.3 Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.4 Complementing Higher-Order Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.5 Partially Applied Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3 A Strict λ-Calculus 25 3.1 Strict Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.2 Canonical Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 3.3 Related Work on Strictness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4 The Relative Complement Problem for Higher-Order Patterns 41

4.1 Towards Term Complementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.1.1 Simple Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.1.2 Full Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

4.2 The Complement Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.3 Unification of Simple Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 4.4 The Algebra of Strict Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

5 Elimination of Negation in Clauses 63 5.1 The Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.2 Introduction to HHF Complementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.3 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 5.4 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.5 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

5.5.1 NF in Clausal Intuitionistic Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.5.2 NF and N-Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.5.3 NF in First-Order Uniform Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.5.4 Partial Inductive Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

6 Clause Complementation 77

6.1 The Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 6.1.1 Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 6.1.2 ⊤-Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

6.2 Context Schemata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 6.2.1 Schema Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 6.2.2 Context Preservation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

6.3 Terminating Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 6.4 Complementable Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

6.4.1 Normalization of Input Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 6.5 The Clause Complement Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 6.6 Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.7 Exclusivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 6.8 Exhaustivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 6.9 Refinements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

6.9.1 More on Termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 6.9.2 Elimination of ∨ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

6.10 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

7 Conclusions and Future Work 135

7.1 Lifting Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 7.1.1 Parameters Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 7.1.2 Extension to Any Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 7.1.3 Open Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 7.1.4 Local Variables Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

7.2 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7.2.1 Beyond Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7.2.2 Richer Type Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 7.2.3 Predicate Quantification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

7.3 Implementation Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 7.4 Additional Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

7.4.1 Higher-Order Program Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 7.4.2 Strictness in Explicit Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

List of Figures

2.1 Some disunification rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2 Computation of ∀y : z ≠ 0 ∧ z ≠ ssy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.3 M is a fully applied pattern: Γ ⊢_{Σ} M f.a. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.1 Typing rules for λ^{→^{l}} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2 First derivation of ·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B . . . . . . . . . . . . . . . . . . . . . 27 3.3 Second derivation of ·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B . . . . . . . . . . . . . . . . . . . 27

3.4 Canonical forms for λ^{→^{l}} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 3.5 The system in [BF93] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.1 Full application translation: Γ ⊢ M ⟷ N . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 4.2 Ground instance: Γ ⊢ M ∈ ∥N∥ : A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.3 Not a ground instance: Γ ⊢ M ∉ ∥N∥ : A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5.1 Synthesis of the predicate odd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.2 Synthesis of the nonmember predicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

6.1 Provability and denial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 6.2 Immediate entailment and denial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 6.3 ⊤-Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.4 Judgments Γ; D \ G < S, ⊧_{S} D and Γ; D < S . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 6.5 Extracting contexts schemata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 6.6 Generation of the subgoal relation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.7 Complementable clause and goal: Γ; D ⊢ D compl and Γ; D ⊢ G compl . . . . . . . . . . . . . 100 6.8 Clause, goal, assumption and term normalization . . . . . . . . . . . . . . . . . . . . . . . . . 104 6.9 Clause Complementation: Not_{D}(D) = D′ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 6.10 Assumption complementation: Γ ⊢ Notα(D) = D′ . . . . . . . . . . . . . . . . . . . . . . . . 106 6.11 Goal complementation: Γ ⊢ Not_{G}(G) = G′ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 6.12 Clause augmentation: aug_{D}(D) = D^{a} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.13 Goal augmentation: Γ; D ⊢ aug_{G}(G) = G^{a} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 6.14 ∨-Elimination: D_{1} ∨ D_{2} \ D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

vi  LIST OF FIGURES

Chapter 1

Introduction

Suppose we are giving a formal definition of a programming language in the style of natural semantics [Kah87]; after we have specified the abstract syntax, the type system (e : τ) and a small step evaluation semantics (e ↦ e′), it is time to check their consistency via a proof of type soundness. We may start by attempting the Progress lemma, which will eventually guarantee that well-typed expressions cannot go wrong; in symbols, this could go like this: for every expressions e such that e : τ and e is not a value, there exists an expression e′ such that e ↦ e′. Now, imagine that our language is fairly sophisticated and our funding agency requires a machine-checkable verification of our results. Thus, we decide to use an automated reasoning tool, possibly an interactive one. A proof of progress is a rather trivial structural induction for a human, but in order to be machine checked, it needs to be spelled out in every detail. We may have implemented judgments defining expressions, values, typing and evaluation: but what about the notion of not being a value? We may try to reason in a strictly intuitionistic way and view ¬value(e) as the derivation of a contradiction ⊥ from the assumption value(e). This is possible, but certainly not in the spirit of the proof; ¬value(e) is just a test, a way to sift out expressions that are already fully evaluated. What we really need is a positive (inductive) definition of “not being a value”, say nonvalue(e); indeed, this should be possible, since non-values are exactly those expressions which are not values. Nevertheless, manually coding this notion may be tedious and error-prone, especially considering evolution of our initial specification. Moreover, we will also have the obligation of proving, at least to our satisfaction, that the explicit definition of ‘non-value’ coincides with the negation of ‘value’. Lacking this, our formal verification cannot be entirely trusted.

For another example consider a simple instance of reasoning about process algebra, such as Peterson’s algorithm for mutual exclusion [Pet81]. The problem here is to ensure that two processes can never be simultaneously in their critical section. A process can be in several (possibly many) states, such as sleeping, trying, critical; a transition relation describes how the system moves from a state to another, according to whether a process is allowed to change its status. Suppose we want to verify some property of the system such as safety: for any possible sequence of transitions if the initial state is safe, so is the final one. Now, from the description of the problem, it is apparent that a state is safe if both process are not in their critical section. It would benefit the verification attempt to have a positive explicit specification of being a safe state, rather than working with an implicit negative one. Not only the number of states can be fairly large, but consider the natural extension of the same problem to n-processes: a hand-written positive specification of a state being safe can be incomplete or plain wrong. Again, over time, the number of states will increase or possibly decrease and the safety specification needs to evolve accordingly.

The bottom line is that negation is a very common connective in a specification – and rightly so, since it is one of the most basic logic operators. Formalizations that use negation are often sharper and more concise. Nevertheless, not every automated reasoning tool available nowadays is able to provide an appropriate handling of this connective. This is particularly problematic for logical frameworks based on higher-order logic or type-theory with a logic programming interpretation, such as Twelf [SP98] and λProlog [NM88, Mil89b]. While the latter provide a very advanced unified environment for the specification, implementation and verification of deductive systems, they inherit the traditional problems with negation, which Prolog has struggled with since its inception. These problems are further augmented by some of their more beneficial features; namely by being ‘higher-order’ and being based on intuitionistic provability. Those characteristics are the main key elements of the success of those frameworks and should be preserved under every extension. This dissertation presents an approach to endow those languages with a logically sound notion of negation without sacrifying any part of their representation power.

1.1 Logical Frameworks

A logical framework [Pfe99] is a meta-language for the specification, implementation and verification of deductive systems and their meta-theory. Deductive systems consist of axioms and rules defining derivable judgments; they can be used to specify logics and aspects of programming languages such as operational semantics, type systems, abstract machines and compilation.

Logical frameworks offer a bridge between the success of declarative programming languages (logic and functional) and the unsatisfactory results of general theorem proving. There is perhaps a reasonable middle way between Poincare’s derision to the logicist approach:

“If you need twenty-seven equations to prove that 1 is a natural number, how many will you need to prove a real theorem?”^{1}.

and Wos’ claim to have solved with OTTER real mathematical open questions (see [WM91] for a depressing list).

Many logical framework have been proposed in the literature (see [Pfe99] for an overview) and many extensions are also under consideration. However, we must carefully balance the benefits that any proposed extension can bring against the complications its meta-theory would incur. We have two main issues to consider:

1. It is been argued that logical frameworks should be by design as weak as possible [dB91], in order to:

• Simplify proofs of adequacy of encodings.

• Allow effective checking of the validity of derivations.

• Reduce the complexity of proof-search.

• Inherit a treatable unification problem.

2. At the same time logical frameworks must provide powerful tools to support the design process of deductive systems. Experience has shown that the strength of a logical framework is proportional to the ease it makes encodings simple and concise. The more direct is the encoding, the easier is to reason about it. One well known example is higher-order abstract syntax [PE88], which moves renaming and substitution principles to the meta-language; this avoids the explicit programming and proving of a large series of low-level results about those trivial but ubiquitous concepts. Another example is the reification of derivations as proof terms in type-theoretic languages, which reduces run-time check for correctness of derivations to type-checking in the meta-language.

The approach taken in the Twelf project is a “pay as you go” one. In other words, every extension is carefully crafted so as to be conservative on the operational and declarative semantics of the core language. Examples are the linear extension [CP96] or refinement types [Pfe93].

1.2 Negation

The aim of this thesis is to develop a framework for the synthesis of the negation of logic programs in logical frameworks such as hereditary Harrop formulae (HHF) [MNPS91] and its implementation in λProlog [NM88]. We intend this to set the basis for type-theoretic frameworks such as LF [HHP93] and its implementation Twelf [SP98] and possibly their linear refinement as Lolli [HM94] and LLF [CP96]. This approach could also be useful for generic theorem proving systems, especially ones based on higher-order logic such as Isabelle [Isa98].

1Les dernieres efforts des logiciens, in Science et Methode, p. 193.

Draft of July 6, 2000

Those systems (Isabelle excluded) do not provide a primitive negation operator. Indeed, constructive logics usually implement negative information as ¬A ≡ A → ⊥, where ⊥ denotes absurdity and the Duns Scoto Law is the elimination rule. Thus negative predicates have no special status; that would correspond to explicitly coding negative information in a program, which is entirely consistent with the procedural interpretation of hypothetical judgments available in logical frameworks with a logic programming interpretation. However, this would not only significantly complicate goal-oriented proof search (as it is manifested in the difficulty of implementing, for example, the full logic of Forum [Mil94]), but providing negative definitions seems to be particularly error-prone, repetitive and not particularly interesting; more importantly, in a logical framework we have also to fulfill the proof obligation that the proposed negative definition does behave as the complement (of its positive counterpart).

Providing a viable negation operator has an immediate practical relevance in programming in those languages, since it relieves the user from the burden of explicitly encoding negative information in the form of clauses which express the condition for a predicate not to hold. Automating the synthesis of negative information has not only a clear benefit in the logic programming sense, but it may also have a rather dramatic effect on the possibility of implementing deductive systems that would prove to be too unwieldy to deal with otherwise. The synthesis of the negation of predicates such as typable, well-formed, canonical form, subsort, value etc.–as well as Prolog-like predicates such as equality, set membership and the like–will increase the amount of meta-theory that can be formalized.

Of course, the addition of negation does not change the recursion-theoretic expressive power of a language, but we claim that it does make a difference at the representation level. To bring this to the extreme, deductive systems can be expressed eventually in, say, first-order Horn logic and ideally proved-checked or even demonstrated by a resolution theorem prover or more likely by an interactive one. In practice, this has turned out to be very problematic, if not a total failure; hence the refinement of the tools to higher-order logic and type-theory.

Traditionally, negation-as-failure (NF ) [Cla78] has been the overwhelmingly used approach in logic programming (see [AB94] for a recent survey): that is, infer ¬A if every proof of A fails finitely. The operational nature of this rule and its ultimately troublesome logical status is a serious threat to the logical frameworks’ endeavor. We will return on the topic of why NF is an absolutely inadequate way to address the issues of negation in a such a framework in Section 1.4.

While the topic of negation has been pursued to the extreme in first-order logic programming (we shall try a small review of closely related approaches in Section 1.3), the field is almost virgin as far as higherorder logic and type theory is concerned: languages such as λProlog implement NF with the usual cut-fail combination: a logical reconstruction for the first order fragment has been attempted, with somewhat disappointing results, in Harland’s thesis [Har91b].

Though the impetus of this enterprise may seem at first sight mainly pragmatic, it should not be underrated. In short, we are trying to design a reasonable notion of negation, a basic building block of any logic under severe computational constraints:

“The problem is difficult because it seeks a notion of negation which is simultaneously semantically elegant and computationally feasible: in both execution and mathematical/logical semantics the extended language should cleanly extend the definite clause language” [JLLM91].

The reason why NF is so popular in the logic programming paradigm is that it essentially requires no modification to the search structure of an logic programming interpreter. The real question is whether it also satisfies the other aforementioned criteria. Nonetheless this is just a part of it:

“... this notion [NF ] is a basic logical notion, a notion of value to pure logic (as studied since the Ancient Greeks) of equal importance and theoretical standing as notion like Possibility, Deduction, Axiom and the like. The role of negation by failure in logic programming in only a special case: one manifestation of its role in logic” [Gab91].

Our answer to this plea will be to show that, paradoxically, the best way to deal with negation in the logic programming setting is to eliminate it through transformation.

It is a basic fact of classical propositional logic that connectives are inter-definable; more precisely, a sufficiently expressive set of sentential operators can provide, by definition, the missing ones, as an immediate consequence of their truth-value semantics. It is therefore customary and economically convenient to assume as primitive only this basis and define the others operators in terms of the former. In almost every definition negation is taken as primitive, paired either with conjunction, disjunction or implication; even those more succinct presentations based on a singleton connective as nand retain an implicit flavor of negation.

There is yet another way to address negation which is related to the transformational approach we are interested in. This is known as negation normal form and it is used for example in Tait’s concise proof of cut-elimination for classical logic. For every atomic predicate symbol p we also have a symbol denoting the opposite, say \overline{p}. Then, with the essential usage of double negation elimination and De Morgan’s laws, negation is defined as follows:

¬p =^{def}  \overline{p}
¬\overline{p} =^{def} p
¬¬p =^{def} p
¬(A ∧ B) =^{def} ¬A ∨ ¬B
¬(A ∨ B) =^{def} ¬A ∧ ¬B

Thus, as far as the classical propositional structure is concerned, negation can be accomplished simply by renaming. Consistency is then achieved by adding axioms that specifies that is it inconsistent to hold both p and \overline{p}, namely p ↔ ¬\overline{p} an ¬p ↔ \overline{p}.

This is another way to look at the approach to negation that we shall investigate, that is the transformational one, also known as intensional negation, initiated in [ST84] and developed in Pisa for Horn logic [BMPT87, BMPT90, BLLM94]. Roughly, given a clause with occurrences of negated predicates, say Q ← G, ¬P, G′, where P is an already defined atom, the aim is to derive a positive predicate, say non P, which implements the complement of P, preserving operational equivalence; then, it is merely a question of replacement, yielding the negation-less clause Q ← G, non P, G′. This has the neat effect that negation and its problems are eliminated, i.e. we avoid any extension to the (meta) language. Technically, we can achieve this by transforming a Horn program into negation normal form and then by negating atoms via complementing terms, a problem first addressed in [LM87] for first-order terms. To mention the simplest example possible, suppose we have a procedure p that calls somewhere a check for a number not to be even, where the latter is already defined:

p(X) ← … ¬even(X) …
even(0).
even(s(s(Y))) ← even(Y).

The goal is to obtain a definition for p, where the negative occurrence of even(X) is replaced by a positive call to its complement, say non even(X). This involves the synthesis of the non even predicate from its positive definition:

p(X) ← … non even(X) …
non even(s(0)).
non even(s(s(Y))) ← non even(Y).

Thus where is our contribution? The problem is that this does not carry immediately over to every computational logics, where the notion of negation normal form may be in itself problematic. The issue was not apparent in the existing literature because of the identification of logic programming with Horn programming. For accident or necessity (though we now lean for the former) Horn logic imposed itself as the format in logic programming. Because of its restricted syntax classical and intuitionistic provability coincide in this fragment. This entails that classical equivalences preserve the intended operational semantics of the source program. Thus negation normal forms do work here, as we explain in Chapter 5

Nevertheless, this approach does not scale immediately to more expressive languages. Once we go beyond Horn logic, the intuitionistic (or ‘search-like’) interpretation becomes crucial to ensure the existence of what is commonly agreed as a reasonable interpreter for a logic programming language. Our endeavor can be paraphrased as the search for a notion of negation normal form for a significantly fragment of higher-order intuitionistic logic which is compatible with a logic programming interpretation.

It must be remarked that the issue of negation in constructivism is by no means new, but it has been considered by many problematic. One sticky point lies in the Heyting semantics of ¬A, seen as a short for A → ⊥; many have expressed doubts about the epistemological status of a construction which yields the absurdum. A discussion can be found in Wansing’s monography [Wan93]. Already in its textbook [Hey56] Heyting mentions Griss’ attempt to formalize a notion of negation-less mathematics. The most well-known approach to marry a first-class notion of negation with constructivism is Nelson’s strong negation [Nel49]. As we will argue in Section 5.3, the interaction between strong negation and implication is inadequate to support the operational interpretation of HHF we are interested in.

Additionally, elimination of negation does not scale immediately to logical frameworks such as HHF, for two other reasons:

1. The simply-typed λ-calculus is not closed under term complement.

2. There is an intrinsic tension between the Closed World Assumption (CWA) [Rei78], which is associated with negation, and the Open World Assumption (OWA) typical of languages with embedded implication.

Differently from the first-order case, the complement of a lambda term cannot, in general, be described by a pattern, or even by a finite set of patterns. We can isolate one basic difficulty: a pattern such as λx. E x for an existential variable E matches any term of appropriate type, while λx. E matches precisely those terms λx. M where M does not depend on x. The complement then consists of all terms λx. M such that M does depend on x. However, this set cannot be described by a pattern, or even a finite set of patterns. This formulation of the problem suggests that we should consider a calculus with an internal notion of strictness so that we can directly express that a term must depend on a given variable. We will therefore introduce a strict λ-calculus where term complement in the simply typed λ-calculus can be embedded and performed.

The second issue is rooted again in the fundamental difference between Horn and HHF formulae: as well known, a Horn predicate definition can be seen as an inductive definition of the same predicate. The minimality condition of inductive definitions excludes anything else which is not allowed by the base and step case(s). This corresponds in Horn logic to the existence of the least model and to the consistency of the CWA and its finitary approximation, the completion of a program [Cla78]: every atom which is not provable from a program is assumed to be false. Languages which provide embedded implication and universal quantification are instead open-ended and thus require the OWA; in fact, dynamic assumptions may, at run-time, extend the current signature and program in a totally unpredictable way. This makes it in general impossible to talk about the closure of such a program. In the literature (reviewed in detail in Section 5.5) the issue has been addressed in essentially three ways:

1. By enforcing a strict distinction between CWA and OWA predicates and applying NF only to the former [Har91b], where the latter would require minimal negation, as in [Mom92].

2. By switching to a modal logic, which is able to take into account arbitrary extensions of the program as possible worlds (see the completion construction in [GO98] for N-Prolog and [Bon94] for Hypothetical Datalog).

3. By embracing the idea of partiality in inductive definitions and using the rule of definitional reflection to incorporate a proof-theoretical notion of closure analogous to the completion [SH93, MM97].

None of those approaches are satisfactory for our purposes: most of the predicates we want to negate are open-ended; similarly, definitional reflection is not well-behaved (for example cut is not eliminable) for that very class of programs we are interested in. Moreover, we need to express the negation of a predicate in the same language where the predicate is formulated. Our solution is to restrict the set of programs we deem deniable in a novel way, so as to enforce a Regular Word Assumption (RWA): we define a class of programs whose dynamic assumptions extend the current database in a specific regular way. This constitutes a reasonable middle ground between the CWA which allows no dynamic assumption but is amenable to negation and the OWA, where assumptions are totally unpredictable. The RWA is also a promising tool in the study of the meta-logical frameworks [Sch00]. Technically, this regularity under dynamic extension is calibrated so as to ensure that static and dynamic clauses never overlap. This property extends to the negative program; in a sense, we maintain a distinction between static and dynamic information, but at a much finer level, i.e. inside the definition of a predicate. The resulting fragment is very rich, as it captures the essence of the usage of hypothetical and parametric judgments in a logical framework; namely, that they are intrinsically combined to represent scoping constructs in the object language. This is why we contend that this class of programs is adequate for the practice of logical frameworks.

1.2.1 What is Failure (in a Logical Framework)?

A minimal requirement for a negation operator ‘¬’ is that if a set of assumption Γ is consistent, it is the case that Γ ⊢ A iff not Γ ⊢ ¬A. It is a key issue how to interpret the notion of non-existence of a proof. In the logic programming tradition this has been identified with the idea of finite failure: the logic programming interpreter is run by querying a given program P with a goal G; the halting of the query without a derivation is evidence enough to assert the negation of G. This idea actually traces back to the same principle in the deductive database context, where the decision problem has a positive answer. Indeed, in this setting, the Closed World Assumption is a most natural one, since, given the large number of entries in a database, the only reasonable way to encode negation is by absence. The transfer of this idea to full logic programming [She85] has been not exactly worry-free, as the enormous literature on the subject testifies. Luckily, our requirements are somewhat different from general logic programming; in fact, in a logical framework, negation refers not to finite failure but to unprovability tout court, as we refrain from negating programs whose negation is not recursively axiomatizable: the adequacy of the representation will break down, since there would be functions which cannot be captured by the framework. We will therefore deal only with terminating programs; this is why we identify negation with a complement operation. This restriction, far from being an easy way out, gives us the additional burden to prove that termination is preserved under every manipulation of programs.

It is clear that elimination of negation makes sense only when negation is stratified [ABW88], i.e. the negative predicates ultimately refers (in the call graph) to a positive one. We will informally adopt the generally accepted weaker notion of local stratification [AB94], when the positive dependency relies not simply on predicate names, but on ground instantiations of literals. While there may be a place in logic programming for non-stratified negation, as the emerging answer set programming paradigm [Lif99] testifies, the latter seems to be circumscribed to solving mainly combinatorial problems. This does not seem to be a concern for a logical framework.

1.2.2 Which Logical Framework?

In this dissertation we work with the pattern fragment of third-order HHF; thus our results apply to the same fragment of L_{λ}[Mil91], although every design decision has been influenced by the possibility to extend it to the richer language of LF and to its implementation in Twelf. We comment on this in the conclusions (Chapter 7). Twelf can be seen as a dependently-typed CLP-oriented enhancement of L_{λ}. Both share unification restricted to the pattern fragment, as well as the lack of predicate quantification. For convenience reasons we take the liberty of decorating HHF clauses with labels that can be thought of as names. This allows us to be more concise when applying program transformations. Even though they resemble the same notation in Twelf, they lack any intrinsic meaning and will not be used as proof-terms.

Furthermore, we restrict ourselves to HHF without local variables. If we look in the usual logic programming fashion at an implicational clause as a rule where the consequent is the ‘head’ and the antecedent the ‘body’, a local variable is an essentially existential one which occurs in the body but not in the head. This restriction is customary in the literature on elimination of negation [ST84, MPRT90a]. For example the following clause for typing application cannot be allowed, in this format.

ofapp : ∀E_{1}, E_{2} :exp. ∀T_{1}, T_{2} :tp.
of (app E_{1} E_{2}) T_{2}
← of E_{1} (arrow T_{1} T_{2})
← of E_{2} T_{1}.

The problem is that Horn clauses with local variables are already not closed under complementation; in fact, elimination of negation will transform those into extensionally universally quantified variables. It is a whole new topic to give an operational reading of universal quantification in this setting and to mingle it with parametric judgments. It is our feeling that the issue of local variables during complementation does not have a simple general solution. Approaches which embrace the extensional nature of universal quantification brought in by the negation of existential quantifiers [BMPT90, ABT90] are not satisfactory and robust enough to carry over to logical frameworks with intensional universal quantification, except when dealing with finite domains.

While it is well-known that every computable function can be expressed by a Horn programs without local variables, we cannot hide that this is a somewhat severe restriction. We offer some ideas on how to partially overcome it in the conclusion (Subsection 7.1.4).

1.3 From Theorem Proving to Prolog

A legitimate question is to ask is why logic programming does not have a primitive notion of negation. To understand that, we need to say something on how logic programming and Prolog developed. This enterprise has a rather peculiar parabola; logic programming owes its (relative) success to the way it limits and directs generic theorem proving; from then on, ironically, most of the effort has been to extend its boundaries without falling back onto full clausal logic.

Automatic theorem proving, or at least the intuition (and the dream), can be dated back to Leibniz, but become more of a reality in 1965 when Robinson introduced the resolution principle [Rob65]. Briefly, it is a proof procedure which proceeds by contradiction, converting a sentence to clausal form and testing for inconsistency with a version of Gentzen’s cut-rule augmented with unification. Yet, this approach has been shown to be in general in-practical. A great deal of research developed after Robinson’s breakthrough aimed at restricting the search space, while preserving completeness. This is not the place to give even a short account of these studies: we just sketch those that led to the basis of Prolog as we know it; for references and a chronology see [Apt90]. When building a refutation there are basically two sources of choice:

1. Deciding which clauses to pick as parent clauses.

2. Deciding which literals in those clauses are to be resolved away.

One way to support the first restriction is linear resolution, independently proposed by Loveland and Luckam in 1970, which by fixing one goal at each step, never needs to resolve two input clauses together. As far as the second point is concerned, we may decide, after Hill, Kowalski and Kuehner, to fix the literal to resolve in the center clause (’linear resolution with selection function’). Though we have narrowed the search space considerably, there is still a fair amount of choice, namely conjunctive choice in the side clauses, ancestors tracking and factoring. The winning strategy is to restrict the syntax of the clauses themselves; the choice fell on Horn clauses: definite clauses (that is clauses with exactly one positive literal) are interpreted as input ones, while Horn clauses with empty positive part are taken as goals. Eventually we have arrived at pure Prolog or SLD-resolution.

What has SLD-resolution to do with programming? The answer can be found in the so-called procedural interpretation of Horn logic. Although the origins of Prolog are shrouded in mystery, it is known that in 1972 both Kowalski and Colmerauer came up with the idea that (a subset of) logic could be used as a programming language. A definite clause A ← B_{1}, B_{2}, …, B_{n} can be viewed as a definition of an Algol-like procedure: procedure A

begin call B_{1} call B_{2}

⋮

call B_{n} end

Goal invocation corresponds to procedure invocation, and the ordering of the goals in the body of the invoked clause corresponds to sequencing of statements. In logic programs data manipulation is entirely achieved by means of unification, which encompasses parameter passing, multiple assignment, record allocation, data construction and selection.

In spite of its limits, it can be shown that Horn logic has the same computational power of every other programming language [Apt90]. Moreover, Horn logic has some nice model-theoretic properties, namely the minimum model property; it is natural to consider the latter as the declarative meaning or the intended interpretation of a program. Therefore it has been argued that we should be content with Horn logic, which seems to be a complete and reasonably efficient computational logic. However, many have been dissatisfied with the difficulty to express even the easiest logical problems in a language that lacks (explicit) disjunction and negation. We share this complaint up to a certain point. We maintain the logic programming works as far as the logical and the algorithmic parts do not differ too much, and that Kowalski’s motto “Programs = Logic + Control” has shown its intrinsic limitations. Yet, we strongly share the idea that especially from a programming point of view it would be advisable to have the possibility of performing negative queries and overall to have a negation operator in the body of clauses instead of simulating it with extra-logical constructions, which make programs less understandable and declarative. It is not a question of expressive power, it is a matter of style and convenience.

There are three ways, in order of increasing complexity, to add negation to Horn logic:

• Negative atomic queries.

• Negative literals in clauses bodies.

• Negative heads.

It is not possible to try to review all the proposed extensions; historically much of the attention has been concentrated on incorporating NF ; from that, most of first-order expressivity is recovered [LT84].

1.4 Negation-as-Failure

Since negative information is independent from definite programs, a specialized inference rule must be invoked: negation as failure (NF ), which in logic programming, originated from the confluence of two quite different trends of research: the refinements of resolution based automatic proof procedures and the relational approach to databases. For a nice introduction see [She88, AB94]. The idea of a proof under the NF rule is a natural one: suppose you have a set of axioms and some kind of inference mechanism which produces a recursively enumerable set of theorems, and that you are asked to verify the truth of a negative conjecture ¬C under NF ; then you try to prove C from your theory; if you succeed, then ¬C does not hold, while if you realize (in a finite time) that C is not provable, then you are entitled to assert that ¬C holds. Its basic idea is to state that a goal is false if we are able to prove that it cannot be proved by the program. Actually, NF is more a computational than a logical notion; we answer ‘no’ to a goal because our attempt to say ‘yes’ failed, so we say ‘no’ because we cannot say ‘yes;. Differently from other kind of negation, NF “… does not follow from some constructive knowledge, but from lack of knowledge” ([Gab91] pp. 8). That motivates its intrinsic non-monotonicity: in fact, in dynamic databases every enlargement may cause the meaning of failure to change and so turn success into failure.

In logic programming, NF works this way:

” … The basic idea is to use SLD-resolution augmented by the NF rule. When a positive literal is selected, we use essentially SLD-derivation to derive a new goal. However, when a ground negative literal is selected, the goal answering process is entered recursively in order to try to establish the negative subgoal … Having selected ground negative literal ¬A in some goal, an attempt is made to construct a finitely failed SLDNF tree with root ← A before continuing with the remainder of the computation. If such a tree is constructed, then the subgoal ¬A succeeds. Otherwise, if a SLDNF -refutation is found for ¬A, then the subgoal fails … ” ([Llo93] p. 87).

The operational nature of this rule motivates the lack of a unique semantics and some of its related troublesome features: to begin with, possible unsoundness: without run-time checks on the substitution returned by a negative open query, the final answer substitution may not be a logical consequence of the program. This is the so-called “floundering” phenomenon, the undecidable question of whether the computation will reach a negative open query and abort. Soundness is preserved only for ground queries; the flip side of the medal is that now negation is not a first-class connective, but just a test that cannot return substitutions. We review in Section 1.5.1 how and with what computational cost this can be avoided. And of course, NF is in general incomplete in general logic programming.

All of the above makes NF a suspicious candidate for a negation operator in any logic programming language, but the situation is even worse in logical frameworks. Even if we manage to isolate a well-behaved logical fragment, such as acyclic normal programs [AB90], allowing NF in a logical framework carries some additional problems. First, the meta-theory becomes really unwieldy, as both provability and unprovability must now be taken into account. The two systems would be interlinked by rules such as:

\begin{aligned}Γ ⊬ F \\ & ¬ − R+ \\ Γ ⊢ ¬F \end{aligned}  \begin{aligned}Γ ⊢ F \\ & ¬ − R− \\ Γ ⊬ ¬F \end{aligned}

where ⊬ denotes a proof system for finite failure. In a type-theoretic logical frameworkthis issue is further exacerbated by the need to deliver evidence of what a proof of a certain judgment is. The most popular way, since the Automath project [dB80], is to to see derivations as lambda terms inhabiting judgments seen as types. Although it is in principle possible to associate proof-terms to a derivation by negation-as-failure – this is implicit in the denial proof system that we present in Chapter 6, Figure 6.1 and 6.2 – the existence of (unique) canonical forms is in general impossible to achieve; and this is pretty much a death sentence for NF. In fact, in frameworks with hypothetical judgments, as recognized first by Gabbay [Gab85], the unrestricted combination of NF and embedded implication is particularly problematic, since it leads to the failure of basic logic principles such as cut-elimination. We discuss this issue in details in Section 5.5.

At the user level, the presence of NF in a logical framework would make adequacy theorems more difficult to establish, again because both provability and unprovability now need to be considered.

In summary the adoption of NF in a logical framework seems to be a very risky, if not hopeless road, considering its fragility already in the very simple setting of Horn clauses.

1.5 Extending Horn Logic

As previously mentioned, once Horn logic was isolated as the core of a programming language, a fairly disorderly race was off to get more mileage out of Prolog. To sum up, we can isolate several (slightly overlapping) positions:

• The “tories”: for model-theoretic reasons, Horn logic is the best possible world, see the manifest “Why Horn logic matters in computer science” [Mak87].

• The “realists”, guided by Apt: logic programming is Horn logic with NF : what’s left to do is logicize the impure features of Prolog.

• The “Making Prolog more expressive” people: divided in two main intertwined sub-tribes: the “logicians”, which claim that programming in Horn logic is like living with one hand tied behind your back, and the “compilers” (see Sato and Tamaki. [TS84]: those come from the specification approach and look at Horn logic as a implementation language which is the target of a long and tiresome travel through derivation and/or transformations from first-order logic. For the logicians, it is a must to conquer any piece of land outside Horn logic, say by adding connectives [PG86], pre-compilation [LT84], change of interpreters (say connection graphs [GR87]) or, more reasonably, switching from classical logic to fragments in the intuitionistic galaxy, reviewed in Section 5.5.

• Finally, there is the proof-theoretic approach of uniform proofs: new connectives are allowed only if we can ascribe a clear meaning in term of search and provide a way of endowing logic programming in a purely logical way with features such as modules, data abstraction and scoping typical of other mature languages.

We now concentrate on how recent research has tried to address some of the problems connected with NF.

1.5.1 Constructive Negation

Constructive Negation is an attempt to devise methods capable to provide logically justified answers to non-ground negative queries, in analogy with the witnessing property of constructive logics. Formally, for a suitable derivability relation, this property ensures that from ⊢ ∃x¬p(x) we can infer the existence of a term t such that ⊢ ¬p(t). We can roughly distinguish two approaches:

i. Program Transformation: [ST84], [FRTW88], [BMPT90].

ii. Negation by Constraints: [Wal87] for Datalog programs, [Cha88] [Cha89] and extended to CLP in [Stu95]; Fail Substitutions: [She89] [MN89].

Historically, the original attempt to deal with the issue was simply to try avoiding the floundering phenomenon: given that the latter is in general undecidable, one possibility is to try to make sure that when a negative literal is called it has already been grounded: there are basically three possibilities:

1. Satisfy the syntactic, though very restrictive, conditions on allowed computations [She85], which essentially reduces evaluation to ground evaluation.

2. Try to achieve grounding by delaying as in [M]NU-Prolog [Nai86] or Sicstus [AAB^{+}95], where a goal may be declared to be “frozen” and is evaluated only when it reaches a sufficient degree of instantiation. This is obviously only a partial solution, since at run-time there is no guarantee to eventually ground the problematic query. A more complex and historically less successful alternative is offered by the computation rules of IC-Prolog, which allow the computation of negative open queries if their positive counterpart does not bound any variable (see [Nai86], for a comprehensive analysis and references).

3. Covering the open negative query with a generator of values for the relevant variables. This is further detailed next.

Static Approaches

If we are dealing with Datalog programs, i.e. with finite Herbrand Universe (U_{P}), the naive approach would be to instantiate all the rules with potentially troublesome goal with terms from U_{P} [ABW88], say through propagation in every negative literal in the program. This is clearly infeasible, since it may result in an intractable numbers of rules, especially in an untyped setting.

A sophistication of this idea can be found in [FRTW88]: the proposal is to automatically infer a ‘type’ for the problematic variables and transform the original program into one where grounding is ensured by coverage from those types. Then useless answers originating from general instantiation would be excluded by the typing discipline. Although it can be shown that the new program is equivalent to the old one, this cannot be extended to full Prolog: function symbols make the type infinite and non-ground facts would undermine the instantiation capability of the type.

Finally, the transformation approach falls in this category and is detailed in Chapter 5.

Dynamic Approaches

Chan [Cha88] is acknowledged to be the inventor of the term ’constructive’ negation in this area; his approach can be roughly characterized as mixing NF with a constraints-solving attitude. In essence it consists in evaluating a negative goal by executing its positive version and by negating the answer obtained. As in the CLP family of languages, unification and disunification are kept explicit and returned as solutions. Of course, we need to keep the (in)equalities in normal form and there are some obvious problems when dealing with computations that have infinite answers; those are addressed in a following paper ([Cha89]), by quantifying over the answer substitutions. No proof of completeness is offered. We can offer the following rational reconstruction: the key observation is that if G is a goal and we consider the answer substitutions θ_{1}, ..., θ_{n} as equations, G ↔ ∃(θ_{1}∨…∨θ_{n}) is a logical consequence of the completed database. Therefore the constructive negation rule is simply ¬G ↔ ¬∀(θ_{1} ∨…∨θ_{n}), where the right-hand side can be simplified by disunification. For instance given the query not(even(X)), its positive version yields the answer X = 0 ∨ ∃Y : X = s(s(Y)), whose negation is X ≠ 0 ∧ ∀Y : X ≠ s(s(Y)): its solved form is hence X = s(0), which we can regard as a more informative refinement of the answer constructive negation produces.

A generalization to constraint logic programming over arbitrary structures is given in [Stu95]; it turns out to be sound and complete w.r.t. the three-valued models of the completion. Other development of constructive negation are addressed in [Fag97].

(E)SLDNF − S ([She89]) The finite failure case in the definition of SLDNF -resolution is modified as follows: a goal (Γ, ¬A) has a descendent θΓ, if there is a finitely failed-tree for θA, where dom(θ) ∈ F V (A). So NF can instantiate under success, i.e. negative goals may directly return substitutions: given P and G the aim is to look for a (fail) substitution θ such that P ⊢ θG has a finitely failed tree; then by the soundness of the NF rule ∀θ¬G is a consequence of comp(P) and thus θ is an answer substitution for the query ¬G. This seems very costly, since it entails enumerating (guessing) every fail substitution. I am not aware of any implementation of this proposal.

This is refined in [MN89], where it is shown how to avoid to generate all possible substitutions in lieu of a maximal general fail substitution. Moreover, the improvement w.r.t. Chan’s work lies in the feature of always including some positive bindings for the variable in the negated goal. If the SLD-tree is infinite, the method enumerates the set of fail substitutions; this corresponds to the fact that in general negative queries cannot be represented by finite positive information alone (connected to [LM87]).

1.5.2 Non-Failure Driven Negation

During the years ways of incorporating other more logical forms of negation than NF have appeared. Since most of the time this gives back full non clausal-logic, most of them are cataloged as automated theorem provers. In all these accounts, negative information has to be provided explicitly and specific rules are offered to deal with that. Sometimes it is possible to mix “open world” and “closed world” predicates safely. For a more detailed account and bibliography, let me refer to [Mom92].

• N(Q)Prolog [GR84], a complete implementation of positive intuitionistic logic. By defining disjunction classically and allowing a restart rule (see nH Prolog next), Gabbay shows it to be complete for full classical logic as well.

• Negation as Inconsistency ([GS86]). Here we evaluate a query against an ordered pair ⟨P, N⟩, where P is a Horn program and N a set of queries that are required not to succeed; this is logically equivalent to adding to the program the negation of all the members of N, and permits importing negative facts and rules. Both systems have a very awkward first-order version.

• Stickel’s PTTP, supplements SLD-resolution with the model elimination rule. This entails keeping track of the ancestors of the goal, loosing one of the key feature of Prolog, namely input resolution.

• Loveland’s nH Prolog [RL92] incorporates case analysis in SLD-resolution, by demanding the invocation of a restart rule for every disjunctive head, until the stack of the former. Without requiring contrapositives (as in PTTP), it simulates case analysis with different runs of essentially the Prolog engine. Unfortunately naive nH-Prolog is incomplete and the new versions (Progressive nH and Inheritance nH ) have a less natural and convincing description.

• Another extension goes under the name of disjunctive logic programming (see [LMR92] and references therein). It aims to deal with full clausal logic by generalizing Horn clauses to disjunctive heads.

1.5.3 Proof-Theoretic Approaches to Negation and NF

In the 90’s there has been an attempt to tie LP to proof-theory, where it belongs: and this has brought new insights, particularly on NF.

The first step is to view Horn clauses positively as rules and goals as existentially closed conjunctions of atoms to be proved by the former. Historically this can probably be dated back to Gabbay and Reyle [GR84]. It is customary [HSH90] to distinguish among two approaches:

1. Clauses as axioms (programs as theories) and some form of Gentzen sequent calculus to infer goals, i.e. uniform proofs systems.

2. Clauses as rules [HSH90]: Horn (and beyond) programs should be seen as set of inference rules for the derivation of (not necessarily ground) atoms.

This has the following relation with negation:

1. Minimal, intuitionistic and classical negation can be superimposed over uniform proofs [Mil89c], [Har91a], [Mom92]: Minimal negation, being camouflaged implication, is executed through the AUGMENT/backchain operation; the evaluation of ¬D consists in the assumption of D and in the attempt to prove ⊥ from the enlarged theory. The Duns Scoto Law and Reductio ad Absurdum for atoms formalize the latter, preserving the feature of abstract logic programming languages [MNPS91].

2. GCLA [MAK91] is based on the rule-based definitional approach to logic programming: it has intuitionistic negation built-in, applying the definiens operator to the left-hand side of a sequent. A discussion can be found in Section 5.5.4.

Stärk [Stä92] has given a sequent calculus reconstruction of NF using Clark’s equality and freeness axioms, negation (switch) rule and cut rules. Much more is however contained in Stärk’s thesis and subsequent research, although not directly applicable to our goals; to quote a few, he shows that a sequent is provable in this calculus iff it is true in all 3-valued model of the completion. Furthermore a completeness result is proved w.r.t SLDNF -resolution for program satisfying the cut-property.

1.5.4 Outline

This dissertation is organized in two main parts which address:

• The relative complement problem for higher-order patterns.

• Clause complementation for a fragment of third-order Hereditary Harrop formulae.

We start in Chapter 2 by introducing the relative complement problem; we review the existing solutions to the first-order case in the literature, namely a variant of Lassez & Marriot’s original uncover algorithm [LM87] (Section 2.1) and disunification [Com91] (Section 2.2). We then discuss in Section 2.4 the problems connected to extending those idea to the higher-order case, where we notice the fundamental difference between fully and partially applied terms. For the latter fragment, the simply-typed λ calculus is not closed under term complement. We remedy this by introducing the strict λ-calculus in Chapter 3. We develop the system and mention the existence of canonical forms. Once we have a calculus strong enough to deal with partially applied terms, Section 4.1 introduces a restriction of the language (“simple terms”) for which complementation is possible. The algorithm for negation is presented in Section 4.2; in Section 4.3 we give a unification algorithm for the same fragment. This completes our solution to the relative complement problems for higher-order patterns. We conclude this chapter in Section 4.4 by showing how to organize finite sets of simple terms into a boolean algebra. We end up this part of the dissertation reviewing related work on strictness (Section 3.3).

Chapter 5 sets the stage for clause complementation. First, in Section 5.1, we offer a reconstruction of the transformational approach to negation in the Horn case. Then in Section 5.2 and 5.3 we give an informal view of the complement algorithm for HHF and of the restrictions it requires by means of examples. In Section 5.4 we try to motivate the pragmatic adequacy of the fragment of HHF we deal with, while Section 5.5 reviews the state of the art in NF and intuitionistic provability.

Chapter 6 is the heart of the thesis; we first introduce the source language and its uniform proofs system in Section 6.1. We then establish the fundamental notion of context schema (Section 6.2). This allows to enforce the Regular World Assumption (RWA), on which clause complementation is built. After formalizing the restriction to terminating programs in Section 6.3, we present the clause complementation algorithm and the related notion of augmentation (Section 6.5 and 6.6). We then prove the main theorem (Section 6.7 and 6.8). Finally, Section 6.9 discusses how to give an operational semantics to our language.

We conclude the dissertation in Chapter 7 by discussing first how to lift some of the current restrictions (Section 7.1); then we address possible extensions, implementation issues and further future work (Section 7.2, 7.3 and 7.4).

1.6 Contributions and Technical Acknowledgments

The original contribution of the thesis are:

• A relative complement algorithm for higher-order patterns internalized into a strict type theory.

• A complement algorithm for a useful class of third-order hereditary Harrop formulae.

We contend that our approach is the first one to give a realistic analysis of negation in logical frameworks with an emphasis on the development of a practical tool to incorporate this operator in existing languages.

This work has benefited enormously from the large ensemble of research collected in the Elf and offspring projects: not only form the existence of this language and environment, but also from specific contributions which we have used (in a somewhat simplified setting) in this thesis. Let me mention only the most recent ones: schema contexts (Schürmann [Sch00]), linear unification (Cervesato and Pfenning [CP96]), subordination (Virga [Vir99]), mode and termination analysis (Rohwedder and Pfenning [RP96]).

This research has been financially supported for seven semesters by the Department of Philosophy at CMU and by a one-year scholarship from “Consiglio Nazionale delle Ricerche”, Italy.

The Relative Complement Problem

An open term t in a given signature can be seen as the intensional representation of the set of its ground instances, say ∥t∥. According to this interpretation, the complement of t is the set of ground terms which are not instances of t, i.e. are in the set-theoretic complement of ∥t∥. It is natural to generalize this to the notion of relative complement; this corresponds to computing a suitable representation of all the ground instances of a given (finite) set of terms which are not instances of another given one, in symbols:

∥t_{1}, …, t_{n}∥ − ∥u_{1}, …, u_{m}∥

where dots represent (set theoretic) union^{1}. More properly:

∥t_{1}, …, t_{n}∥ =^{def} ⋃_{i=1}^{n} ∥t_{i}∥

Let F V (t_{1}, …, t_{n}) = x⃗ disjoint from F V (u_{1}, …, u_{m}) = y⃗. Then the relative complement problem can be also expressed by the following (restricted) form of equational problem [Com91], where the z_{i}’s are free variables.

∃x⃗∀y⃗ : ⋀_{i=1}^{n} z_{i} = t_{i} ∧ ⋀_{i=1}^{m} z_{i} ≠ u_{i}

Example 2.1 Consider the signature containing the usual declarations for 0, s, +. The following rules define integer addition modulo 2.

s(s(0)) ⟼ 0
y + 0 ⟼ y
0 + y ⟼ y
y + y ⟼ 0

The following relative complement problem expresses the question of sufficient completeness (in this case yielding a positive answer) of the rewrite rules:

∥x_{1} + x_{2}∥ − ∥s(s(0)), 0 + y, y + 0, y + y∥

which corresponds to

∃x_{1}x_{2}∀y : (z = x_{1} + x_{2}) ∧ (z ≠ s(s(0))) ∧ (z ≠ y + 0) ∧ (z ≠ 0 + y) ∧ (z ≠ y + y)

Then, since a variable stands for the universe of discourse, a complement problem is representable merely by

∥z∥ − ∥u_{1}, …, u_{m}∥

1Another equivalent notation found in the literature is t_{1} ∨ ⋯ ∨ t_{n} \ u_{1} ∨ ⋯ ∨ u_{m} [LM87], or a mixture of the two.

Draft of July 6, 2000

or a simpler (∃-degenerate) equational problem:

∀y⃗ : ⋀_{i=1}^{m} z ≠ u_{i}

Now we turn to review solutions to the relative complement problem in first-order languages.

2.1 The Not Algorithm

We start with the ‘Not’ algorithm for first-order terms that specializes the prototypical uncover algorithm proposed in [LM87] as a first attempt to solve the the problem and is at the heart of Barbuti et al.’s approach [BMPT90]. We present it in a many-sorted framework, differently from the uni-sorted original version. We call (in this chapter) a term linear if it does not contain repeated occurrences of a free variable.

Definition 2.2 Consider a many-sorted signature Σ and a linear term t : τ. We define Not(t) by structural induction, where we suppose that t_{i} has sort τ_{i} and the z’s are new free variables of appropriate typing:

Not(z : τ)  = ∅
Not(f(\overline{t_{n}}) : τ) =
\{g(\overline{z_{m}}) : τ | g ∈ Σ, g ≢ f, g : \overline{τ_{m}} → τ\} ∪
{f(z_{1}, …, z_{i−1}, s, z_{i+1}, …, z_{n}) : τ | s ∈ Not(t_{i}), 1 ≤ in}

The uni-sorted version of this function tends to produce a lot of irrelevant outcomes. For example, Not(cons(s(x), nil)) does not yield only the desired {nil, cons(0, nil), cons(y, cons(z, xs))} in the informal signature of lists of numerals but also {0, s(x), …}. On the other hand, fixing

Σ = {0 : nat, nil : nlist, s : nat → nat, cons : nat ∗ nlist → nlist}

we get the desired result. This problem may tend to increase dramatically with the size of the signature. It can be argued that the notion of complementation itself without an underlying type discipline makes little sense, not only from a complexity standpoint, but also in intellectual terms. Moreover, more refined type theories, as dependent types and/or sub-typing will further constrain the result of the evaluation of Not.

A complement operator must satisfy the following desiderata:

1. Exclusivity: it is not the case that s is both a ground instance of t and of Not(t).

2. Exhaustivity: s is a ground instance of t or s is a ground instance of Not(t).

That is, the Not algorithm ought to behave as a the complement operation on sets of ground terms. This cannot be achieved in all generality. In other words, intensional representations of terms are not closed under complementation. One canonical example is as follows:

Example 2.3 Consider the signature {a : i, f : (i ∗ i) → i}: intuitively the complement of f(y, y) should be:

∥z∥ − ∥f(y, y)∥ = {a} ∪ {f(x, z) | x ≠ z}

Instead, the Not algorithm would incorrectly yield:

Not(f(y, y)) =^{?} {a}

In fact, Lassez & Marriot [LM87] have been the first to point out that this complement algorithm is correct only for linear terms: complement of non-linear ones do not have a straightforward finite representation. More sophisticated representation, such as constrained terms [Com88] have been investigated, but are not suitable to our applications.

Moreover, as well known, the restriction to linearity seems to be almost immaterial in logic programming thanks to the idea of left-linearization introduced by Plaisted and used first by Stickel [Sti88] to avoid unnecessary occur checks testing. It simply consists of a source-to-source transformation which replaces repeated occurrence of the same variable in a clause head with new variables which are then constrained in the body by a new predicate, say eq, whose definition is simply eq(x, x); unification will then provide the other properties of equality. For example, continuing Example 2.3, a clause such as ∀y . p(y, y) ← G would be replaced by ∀z_{1}. ∀z_{2} . p(z_{1}, z_{2}) ← eq(z_{1}, z_{2}) ∧ G. As a matter of fact, this approach is less innocent as it looks at first sight, since it opens the road to a CLP attitude; moreover, eq as a predicate is not linear in itself and required an ad hoc treatment in the transformational approach to negation [BMPT90]. Miller [Mil89a] has shown how to automatically infer the equality predicate (the so-called copy clause) for any type. However, for any order greater than the first, this clauses are not Horn and their negation is itself problematic. One of the result in this dissertation is to apply elimination of negation to predicates such as copy.

Once we have a way to solve complement problems, it is easy to pair it to intersection, seen as unification [Plo71], to have a solution to relative complements as well, i.e.

∥t_{1}∥ − ∥u_{1}, …, u_{m}∥ =^{def} ∥t_{1}∥ ∩ ∥Not(u_{1})∥ ∩ … ∩ ∥Not(u_{m})∥

Another more general approach is possible. As we have seen in the beginning, it is possible to express the (relative) complement problem on terms as an equational problem. This is the basis to solve complement problems with disunification, as we sketch next.

2.2 Disunification

Disunification is devoted to solving arbitrary first order formulae whose only predicate symbol is equality, call them equational formulae. The definition of what a solution is differs on the application at hand. We may be interested only in the overall validity or in the possible assignments that make the formula valid. As we have seen, complement problems can be seen as systems of disequations with universally quantified variables. Thus a disunification algorithm (over first-order terms) will solve these problems, possibly providing values for free variables.

From an historic perspective this field became defined when it was realized by Martelli & Montanari [MM82], if not by Herbrand (see the Appendix in [Sny91]) that first-order unification can be seen as a transformation on sets of equations. On the other hand the work of Mal’cev [Mal71] on the decidability and the possibility to give complete axiomatization of the theory of equational algebras qualifies as an ancestor. The definition of Prolog-II introduced first-class disequations. Indeed Colmerauer [Col84] showed them to have solutions in the algebra of rational trees. Next Lassez & Marriot [LM87] proposed the seminal (although awkward) uncover algorithm for computing relative complements. Kirchner and Lescanne first unified those previous papers in the framework of equational problems and proposed a set of transformational rules, though without a completeness proof [KL87]. Maher introduced the unification community to Mal’cev’s results [Mah88]. Comon and Lescanne were the first one to present an adequate set of rules [Com88, CL89] and the former surveyed the field [Com91].

How to go on to derive a disunification procedure can vary from the syntax and semantics we are concerned with, but nevertheless it entails the following steps:

• Provide a set of axioms T that hold in the model we consider.

• Design a set of rules R for the transformation of equational formulae that can be proven correct w.r.t. T .

• Design a control C on R such that the application of rules satisfying C terminates: irreducible formulae are in solved form and have the same set of solutions as the original problem.

• If arbitrary formulae are allowed and solved forms are trivially decidable, this entails the decidability and completeness of T .

The simplest example is unification of finite (first-order) terms:

\begin{aligned}R & : & w = t ∧ P [w] & ⟼ & w = t ∧ [t/w]P \\ M1 & : & w = t ∧ w ≠ u & ⟼ & w = t ∧ t ≠ u \\ UE1 & : & ∀y⃗, y . P ∧ y ≠^{·} t & ⟼ & ⊥ \\ Clh(T) & : & f(\overline{t_{n}}) ≠ g(\overline{s_{m}}) & ⟼ & ⊤ \\ Clh(F) & : & f(\overline{t_{n}}) = g(\overline{s_{m}}) & ⟼ & ⊥ \\ Dec1 & : & f(\overline{t_{n}}) ≠^{·} f(\overline{u_{n}}) & ⟼ & ⋁_{i=1}^{n} t_{i} ≠^{·} u_{i} \\ Dec2 & : & f(\overline{t_{n}}) = f(\overline{u_{n}}) & ⟼ & ⋀_{i=1}^{n} t_{i} = u_{i} \\ E & : & ∀y⃗ . P & ⟼ & ⋁_{f∈Σ}(∃x⃗∀y⃗ . P ∧ w = f(x⃗)) \end{aligned}

In rule R w ∉ V ar(t), in E, P contains a (dis)equation with LHS w and RHS u, where the latter is not a variable and contains a universally quantified variable.

Figure 2.1: Some disunification rules

• T is Clark’s free equality theory [Cla78].

• R are, say, the Martelli-Montanari rules; correctness corresponds to the preservation of solutions under rule application.

• Solved forms yield idempotent substitutions and control restricts the application of variable elimination. Completeness (of the theory) is established for example as in [Mah88].

The disunification rewrite rules are divided into three big classes:

• Equality rules, i.e. rules which are correct for any equational algebra

• Rules for finite trees over any signature

• Rules for finite trees over a finite signature.

We will not present the complete set of rules with logical provisos and control. We just mention that the first group contains Replacement, Universal Quantifier Elimination, Existential Quantifier Elimination and Elimination of Disjunctions. The second batch contain Clash, Decomposition, Occur check. The third section would contain rules which are sensitive to the cardinality of the signature. Here we mention only the Explosion rule (E), which is motivated by the domain closure axiom (DCA) [MMP88]. We list in Figure 2.1 the rules relevant to the following example in their barest form, i.e. with only soundness and no termination condition:

We now give an example of disunification on the numerals signature, which is required in the synthesis of the odd program (see Figure 5.1). It consists in solving:

∀y : z ≠ 0 ∧ z ≠ ssy  (2.1)

The intuitive solution of (2.1) is z = s(0). We will use the rules in Figure 2.1 and gloss over normalization steps as well as elimination of trivial (dis)equations. Branches stemming from the explosion rule are numbered and pursued separately (keeping in mind that they form a disjunction, i.e. a finitely branching tree from a search standpoint). R(x) denote application of the rule R on variable x. The computation is traced in Figure 2.2.

Note that disunification nicely overcomes the difference between linear and non-linear terms with different notions of solved forms, namely unification solved form versus solved form with disequations [Com91]. This may be interpreted as evidence of the opportunity of rephrasing unrestricted relative complements as disunification problems. We, on the other hand, maintain that this approach is unnecessarily general for this purpose. Implementing disunification entails managing the non-deterministic application of a few

∀y : z ≠ 0 ∧ z ≠ ssy

⟼_{E(z)(1,2)}

(1) ∀y : z ≠ 0 ∧ z ≠ ssy ∧ z = 0

⟼_{M1(z)}

∀y : 0 ≠ 0 ∧ 0 ≠ ssy ∧ z = 0

⟼_{Clh(F)}^{∗} ⊥

(2) ∃x∀y : z ≠ 0 ∧ z ≠ ssy ∧ z = sx

⟼_{M1(z)}

∃x∀y : sx ≠ 0 ∧ sx ≠ ssy ∧ z = sx

⟼_{Dec,Clh(T)}^{∗}

∃x∀y : x ≠ sy ∧ z = sx

⟼_{E(x)(2.1,2.2)}

(2.1) ∃x∀y : x ≠ sy ∧ z = sx ∧ x = 0

⟼_{M1(z)}

∃x∀y : 0 ≠ sy ∧ z = s(0) ∧ x = 0

⟼_{Clh(T)}^{∗} z = s(0)

(2.2) ∃x_{1}x∀y : x ≠ sy ∧ z = sx ∧ x = sx_{1}

⟼_{M1(x),Dec1}^{∗}

∃x_{1}x∀y : x_{1} ≠ y ∧ z = sx ∧ x = sx_{1}

⟼_{UE_{1}(y)}^{∗} ⊥

Figure 2.2: Computation of ∀y : z ≠ 0 ∧ z ≠ ssy

dozen rules which eventually turns a given problem into a solved form. Though a reduction to a significant subset of the disunification rules as the one depicted in Figure 2.1 is likely to be attainable for complement problems, control is a major problem. Moreover the higher-order case results in additional complications, such as restrictions on the occurrences of bound variables, which fall outside an otherwise clean framework. As we show in this dissertation, this must not necessarily be the case. We believe that our techniques for the higher-order case can also be applied to analyze disunification, although we have not investigated this possibility at present.

2.3 Other Applications

Complement problems and elimination of negation are not restricted to logic programming, but have some other relevant application in theoretical computer science. Let me refer to [JLLM91] and [Com91] for issues impossible to detail here and for complete references.

In fact, complement problems and variants of the uncover algorithm [LM87] as a first attempt to solve the former, have been studied and tentatively applied in several ways:

• In functional programming, to determine, modulo pattern matching, whether the program clauses describing a function are exhaustive and disjoint, even further to produce a non-ambiguous set of patterns. Moreover, it is possible to take advantage of the given sequential application of the rules to provide an improved compiled code. Indeed, if, say, the second rule applies, it means the first one does not: hence the terms reducible by the second rule are in the complement of the LHS of the first.

• The connection of complementation to the notion of ground reducibility in term rewriting systems makes it a candidate as a checker for sufficient completeness [GH78] of an algebraic (equational) specification. If the latter fails to be complete, the transformation rules my lead to recover the missing cases—hence the motto in [Thi84]:

“Stop losing sleep over incomplete specifications”

Here we are looking for counter-examples: if a function is not sufficiently complete, there is a term, built from the constructors in the signature, which is different from any LHS, thus irreducible (see Example 2.1).

• In term rewriting systems describing infinite transition systems, the complement of a LHS returns the states from which no transition is achievable, providing thusly a tool for the temporal analysis of communicating processes.

• In machine learning, a concept can be captured by a term with some (finite) exceptions: the computation of this structure, which is a relative complement, coincides with the search for an explicit representation of the cited concept.

• Finally, applications to inductive theorem proving under the slogan induction-less induction or proof by consistency [Com98] are under scrutiny. This is connected to the idea of the so-called inductive reducibility property.

We now switch gears and discuss the extension of the relative complement problem to the higher-order case; as usual, we restrict ourselves to a specific class of λ-terms.

2.4 Complementing Higher-Order Patterns

In most functional and logic programming languages the notion of a pattern, together with the requisite algorithms for matching or unification, play an important role in the operational semantics. And, of course, patterns form the left-hand sides of rewrite rules and are thus critical to the study of rewrite systems. Consequently, analysis of the structure of patterns is an important task in the implementation of programming languages and more abstract studies of rewriting systems and their properties.

Perhaps the most fundamental problems are matching and unification, but other questions such as generalization also arise frequently. Here, we are concerned with the problem of pattern complement in a setting were patterns may contain binding operators, so-called higher-order patterns [Mil91, Nip91]. A term possibly containing some existential variables is called a pattern if each occurrence of an existential variable has the form E x_{1} … x_{n}, where the arguments x_{i} are distinct occurrences of free or bound variables (but not existential variables). Higher-order patterns have found applications in logic programming [Mil91, Pfe91a, MP93], logical frameworks [DPS97], term rewriting [Nip93], and functional logic programming [HP96]. Higher-order patterns inherit many pleasant properties from the first-order case. In particular, most general unifiers [Mil91] and least general generalizations [Pfe91b] exist, even for complex type theories.

In this section we discuss some of the preliminary issues towards a generalization to the complement algorithm to higher-order patterns. We assume the following:

• All terms are linear, i.e. existential variables occurs only once.

• Types do not contain occurrences of the primitive type o. We thus complement only terms with no inner logical structure.

The main difference w.r.t. the first-order case is twofold: first, the second-order (relative) complement problem is not semi-decidable, but higher-order disunification on higher-order patterns is decidable [Lug94].

Secondly, as we will see, the class of patterns is not closed under complement, although a special subclass is. We call a canonical pattern Γ ⊢ M : A fully applied if each occurrence of an existential variable E under binders y_{1}, …, y_{m} is applied to some permutation of the variables in Γ and y_{1}, …, y_{m}. This is formally defined in Figure 2.3. Fully applied patterns play an important role in functional logic programming and rewriting [HP96] because any fully applied existential variable Γ ⊢ E x_{1} … x_{n} denotes all canonical terms with free variables from Γ. It is this property which makes complementation particularly simple. In fact, the main difference with the first-order case is that we need to carefully keep track of bound variables: those are collected in a context Γ, so that the complement of a rigid term is taken w.r.t. both the signature and the current context. In the case the term is not fully applied, the complement has to take into account whether some of the variables mentioned in a lambda binder do appear in the matrix; we discuss this in the next Section 2.5. We first analyze the simpler case.

\overline{y_{π(n)}} = dom(Γ)

                                    faPat

Γ ⊢_{Σ} F \overline{y_{n}} f.a.

Γ, x:A ⊢_{Σ} M f.a.

                                                              faLam

Γ ⊢_{Σ} λx:A. M f.a.

h ∈ Γ ∪ Σ Γ ⊢_{Σ} N_{1} f.a. · · · Γ ⊢_{Σ} N_{n} f.a.

                                                             faApp

Γ ⊢_{Σ} h \overline{N_{n}} f.a.

Figure 2.3: M is a fully applied pattern: Γ ⊢_{Σ} M f.a.

The language of the simply-typed λ-calculus is as follows, where we use a for atomic types (different from the type of proposition o), c for term-level constants, and x for term-level variables, while h will stand for a constant or a variable.

Simple Types A ::= a | A_{1} → A_{2}
Terms M ::= c | x | λx:A. M | M_{1} M_{2}
Signatures Σ ::= · | Σ, a:type | Σ, c:A
Contexts Γ ::= · | Γ, x:A

We require that signatures and contexts declare each constant or variable at most once so that, for example, when we write Γ, x:A, x may not already be declared in Γ. Furthermore, we identify contexts which differ only in their order, in other words, contexts are treated as sets of declarations for distinct variables. We promote “,” to denote disjoint set union. As usual we identify terms which differ only in the names of their bound variables. We restrict attention to well-typed terms, omitting the standard typing rules.

In applications such a logic programming or logical frameworks, λ-abstraction is used to represent binding operators in some object language. In such a situation the most normal forms are long βη-normal forms (which we call canonical forms), since the canonical forms are almost always the terms in bijective correspondence with the objects we are trying to represent. Every well-typed term in the simply-typed λ-calculus has a unique canonical form—a property which persists in the strict λ-calculus introduced in Chapter 3. See that chapter for further discussion and an inductive definition of canonical forms.

We denote existential variables of type A (also called logical variables, meta-variables, or pattern variables) by E_{A}, although we mostly omit the type A when it is clear from the context. We think of existential variables as syntactically distinct from bound variables or free variables declared in a context.

Semantically, an existential variable E_{A} stands for all canonical terms M of type A in the empty context with respect to a given signature. We extend this to arbitrary well-typed terms in the usual way, and write ∥M∥ for the set of canonical ground instances of a term M possibly containing existential variables (see Figure 4.2). In this setting, unification of two patterns corresponds to an intersection of the set of terms they denote [Mil91, Pfe91b]. This set is always either empty, or can be expressed again as the set of instances of a single pattern. That is, patterns admit most general unifiers.

Definition 2.4 (Fully applied higher-order pattern complement) Fix a signature Σ. For a fully applied higher-order linear pattern in canonical form M, define Γ ⊢ Not(M : A) as:

Γ ⊢ Not(E \overline{x_{n}} : a)  = ∅
Γ ⊢ Not(h M_{1} … M_{m} : a) = diff_{Γ}(h : \overline{A_{m}} → a) ∪
{h (Z_{1}Γ) … (Z_{i−1}Γ) N (Z_{i+1}Γ) … (Z_{m}Γ) |
N ∈ Γ ⊢ Not(M_{i} : A_{i}), 1 ≤ i ≤ m}
Γ ⊢ Not(λx:A. M : A → B) = {λx:A. N | N ∈ (Γ, x : A ⊢ Not(M : B))}

where m ≥ 0, (Z Γ) denotes that a fresh variable Z of appropriate typing may depend from the every variables in dom(Γ) and

diff_{Γ}(h : \overline{A_{m}} → a) = \{g (Z_{1}Γ) … (Z_{n}Γ) | g ∈ Σ ∪ Γ, g : \overline{A_{n}} → a, n ≥ 0, h ≢ g\}

Note that the definition makes an essential use of the fact that M is canonical and thus its matrix has atomic type a.

Remark 2.5 For h ∈ Γ ∪ Σ, Γ ⊢ Not(h : a) = diff_{Γ}(h : a).

Proof: Consider the 0-ary application case. □

We will suppress mention of the type in Γ ⊢ Not(M : A) when it can be inferred from the context.

Example 2.6 Consider the untyped λ-calculus^{2}.

e ::= x | Λx. e | e_{1} e_{2}

We encode these expressions using the usual techniques of higher-order abstract syntax (see, for example, [MP91]) as canonical forms over the following signature Σ_{lam}.

exp : type
lam : (exp → exp) → exp
app : exp → exp → exp

The representation function is given by:

⌜x⌝ = x : exp
⌜Λx. e⌝ = lam (λx:exp. ⌜e⌝)
⌜e_{1} e_{2}⌝ = app ⌜e_{1}⌝ ⌜e_{2}⌝

As usual with higher-order abstract syntax [PE88], we identify the name of (bound) variables in both languages. The adequacy of the encoding bijectively relates α-equivalence classes of object-level terms with βη-equivalence classes at the meta-level. Now, suppose we want to negate the identity predicate on unary function types:

id(λx:exp. x).

The intuitive answer is as follows:

\begin{matrix}¬id(λx:exp. app (E_{1} x)(E_{2} x)). \\ ¬id(λx:exp. lam (λy:exp. (E x y)). \end{matrix}

This follows from the computation of · ⊢ Not(λx:exp. x):

· ⊢ Not(λx:exp. x) = {λx:exp. Z | Z ∈ (x:exp ⊢ Not(x))}
= {λx:exp. Z | Z ∈ diff_{x:exp}(x:exp))}
= {λx:exp. Z | Z ∈ {app (E_{1}x)(E_{2}x), lam (λy:exp. (E x y))}}
= {λx:exp. app (E_{1} x)(E_{2} x), λx:exp. lam (λy. (E x y))}

For another illustration, consider the representation of an object-language β-redex:

⌜(Λx. e) f⌝ = app (lam (λx:exp. ⌜e⌝)) ⌜f⌝

where ⌜e⌝ my have free occurrences of x. When written as a pattern with variables E_{exp→exp} and F_{exp} ranging over closed terms, this is expressed as app (lam (λx:exp. (E x)) F). Consider the predicate:

betardx(app (lam (λx:exp. E x)) F)

The complement of the arguments in the empty context contains every top-level λ-abstraction plus every application where the first argument is not an abstraction:

· ⊢ Not(app (lam (λx:exp. (E x)) F)) = {lam (λx:exp. Z x), app (app Z_{1} Z_{2}) Z_{3}}

2We use Λ for lambda abstraction in the object-calculus, not to be confused with λ in the meta-language.

Draft of July 6, 2000

Thus the negation of the betardx predicate is:

\begin{matrix}¬betardx(lam (λx:exp. Z x)) \\ ¬betardx(app (app Z_{1} Z_{2}) Z_{3}) \end{matrix}

If the term to complement is complex, we need to call the Not algorithm recursively as many times as its depth. Let us see another slightly more complicated example.

Example 2.7 Consider the signature of numerals and the problem · ⊢ Not(λf:n → n. f 0).

· ⊢ Not(λf:n → n. f 0) = {λf:n → n. Z | Z ∈ (f:n → n ⊢ Not(f 0))}
= {λf:n → n. Z | Z ∈ diff_{f}(f) ∪ {f Z′ | Z′ ∈ (f:n → n ⊢ Not(0))}}
= {λf:n → n. Z | Z ∈ {0, s(Z_{1} f)} ∪ {f Z′ | N′ ∈ {f(Z_{2} f), s(N_{3} f)}}
= {λf:n → n. 0, λf:n → n. s(Z_{1} f), λf:n → n. f(f(Z_{2} f)), λf:n → n. f(s(Z_{3} f))}

2.5 Partially Applied Terms

Consider a predicate on the signature Σ_{lam} true if a unary function ⌜Λx. e⌝ does not depend on its argument. This can be encoded using a pattern variable E_{exp} which does not depend on x.

vacous(λx:exp. E).  (2.2)

Intuitively, the complement should be a predicate, say strict, true when the function does use its arguments. Note that there is no finite set of patterns which has as its ground instances exactly those terms M which depend on a given variable x. One way to express it is as follows:

strict(λx:exp. x).
strict(λx:exp. app (E_{1} x)(E_{2} x))
← strict(λx:exp. E_{1} x).
strict(λx:exp. app (E_{1} x)(E_{2} x))
← strict(λx:exp. E_{2} x).
strict(λx:exp. lam (λy:exp. (E x y)))
← (∀z:exp. strict(λx:exp. (E x z))).

Hence the complement of a fact, whose terms are partially applied patterns, would lead to possibly hypothetical and parametric clauses.

Example 2.8 The encoding of an η-redex takes the form:

⌜Λx. e x⌝ = lam(λx:exp. app ⌜e⌝ x)

where ⌜e⌝ may contain no free occurrence of x. The side condition is again expressed in a pattern by introducing an existential variable E_{exp} which does not depend on x. Hence, its complement with respect to the empty context should contain, among others, also all terms

lam (λx:exp. app (E x) x)

where E does depend on x.

More generally, we would have to decorate programs with predicates discriminating when a pattern is fully applied or not. It is clear that the simply typed λ-calculus, or, for that matter, every other intuitionistic type theory is not strong enough to represent the complement of partially applied patterns. This failure of closure under complementation cannot be avoided similarly to the way in which left-linearization bypasses the limitation to linear terms and it needs to be addressed directly.

One approach is taken by Lugiez [Lug95]: he modifies the language of terms to promote constraints to first-class objects, similarly in spirit to explicit substitutions. For example λxyz. M{1, 3} would denote a function which depends on its first and third argument. The technical handling of those objects then becomes awkward as they require specialized rules which are foreign to the issues of complementation.

We can instead internalize the (in)dependence constraints in a type theory which explicitly take into account the occurrence issue. Since our underlying λ-calculus is typed, we use typing to express that a function must or must not depend on its argument. Following standard terminology, we call such terms strict in x and the corresponding function λx: A. M a strict function. The natural choice is a calculus of strict types and is formalized in Section 3.1. We first give an informal presentation.

We can introduce a strict application primitive constructor, say F ^{#}x, which express the fact that F must use an argument x mentioned in the context. Thus for example:

· ⊢ Not(λe:exp. E) = λx:exp. F ^{#}x

Therefore, the complement of (2.2) would be:

¬vacous(λx:exp. F ^{#}x).

Conversely, taking the complement of terms where arguments must occur yields terms where some argument must not occur: for example

· ⊢ Not(λx:exp. λy:exp. E ^{#}y ^{#}x) = {λx:exp. λy:exp. F, λx:exp. λy:exp. F_{1}^{#}x,
λx:exp. λy:exp. F_{2}^{#}y}

Let \overline{x_{n}}, \overline{y_{m}} be two sets of variables such that \overline{y_{m}} ⊆ \overline{x_{n}}. Let \overline{z_{p}} = \overline{x_{n}} − \overline{y_{m}}. We first treat the intuitionistic application case. The complement of λ\overline{x_{n}}. E \overline{y_{m}} is the set of terms that may depend on \overline{y_{m}} but has to depend on one of the \overline{z_{p}}’s, that is p terms such that, for an appropriate context Γ:

Γ ⊢ Not(E \overline{y_{m}}) = ⋃_{j=1}^{p}\{E_{j} \overline{y_{m}} z_{1} … z_{j−1} ^{#}z_{j} z_{j+1} … z_{p}\}

The complement of terms with strict application is defined as:

Γ ⊢ Not(E ^{#}y_{1}^{#}y_{2} … ^{#} y_{m}) = ⋃_{j=1}^{m}{E_{j} y_{1} … y_{j−1} y_{j+1} … y_{m}}

Example 2.9

· ⊢ Not(λxyzw. E y w) = {λxyzw. F_{1} y w ^{#}x z, λxyzw. F_{2} y w x ^{#}z}
· ⊢ Not(λxy. E ^{#}x ^{#}y) = {λxy. F_{1} x, λxy. F_{2} y}

Yet, there is a certain asymmetry between strict and intuitionistic application: while the former completely determines the occurrence status of a variable, the latter leaves the status floating indeterminately between the possibility of occurrence or not. We can benefit from a notation which captures the ‘nonoccurring’ condition explicitly. One possibility is to decorate bound variables as well as function types with three occurrence annotations 1, 0, u with the intended meaning of:

x^{1} : x must occur
x^{0} : x must not occur
x^{u} : x is undetermined

Its intended semantics, as a type theory, is explored next.

A Strict λ-Calculus

In this Chapter we introduce a strict λ-calculus and develop its basic properties. Chapter 4 will introduce a restriction of the language for which complementation is possible.

3.1 Strict Types

As we have seen in the preceding Chapter, the complement of a partially applied pattern in the simplytyped λ-calculus cannot be expressed in a finitary manner within the same calculus. We thus generalize our language to include strict functions of type A →^{1} B (which are guaranteed to depend on their argument) and invariant functions of type A →^{0} B (which are guaranteed not to depend on their argument). Of course, any concretely given function either will or will not depend on its argument, but in the presence of existential variables we still need the ability to remain uncommitted. Therefore our calculus also contains the full function space A →^{u} B. A similar calculus has been independently investigated in [Wri91, BF93]: for a comparison see Section 3.3.

Labels k ::= 1 | 0 | u
Types A ::= a | A_{1} →^{k} A_{2}
Terms M ::= c | x | λx^{k}:A. M | (M_{1} M_{2})^{k}
Contexts Γ ::= · | Γ, x:A

Note that there are three different forms of abstractions and applications, where the latter are distinguished by different labels on the argument. It is not really necessary to distinguish three forms of application syntactically, since the type of function determines the status of the application, but it is convenient for our purposes. If a label is u it is called undetermined, otherwise it is determined and denoted with the metavariable d.

We use a formulation of the typing judgment with three zones, containing the unrestricted, irrelevant and strict hypotheses, denoted by Γ, Ω, and Δ, respectively.

Γ; Ω; Δ ⊢ M : A

We implicitly assume a fixed signature Σ which would otherwise clutter the presentation. Recall that Γ_{1}, Γ_{2} is a union of two contexts which do not declare any common variables. Recall also that we consider contexts as sets, that is, exchange is left implicit.

Our system is biased towards a bottom-up reading of the rules in that variables never disappear, i.e. they are always propagated from the conclusion to the premises, although their status might be changed.

Let us go through the typing rules in detail. The requirement for the strict context Δ to be empty in the Id^{u} and Id^{1} rules expresses that strict variables must be used, while undetermined variables in Γ or irrelevant variables in Ω can be ignored. Note that there is no rule for irrelevant variables, which expresses that they cannot be used.

26  CHAPTER 3. A STRICT λ-CALCULUS

\begin{aligned}c:A ∈ Σ \\ & Con \\ Γ; Ω; · ⊢ c : A \end{aligned}

\frac{Id^{u}}{(Γ, x:A); Ω; · ⊢ x : A}  no Id^{0} rule  \frac{Id^{1}}{Γ; Ω; x:A ⊢ x : A}

(Γ, x:A); Ω; Δ ⊢ M : B

→^{u} I

Γ; Ω; Δ ⊢ λx^{u}:A. M : A →^{u} B

Γ; (Ω, x:A); Δ ⊢ M : B

→^{0} I

Γ; Ω; Δ ⊢ λx^{0}:A. M : A →^{0} B

Γ; Ω; (Δ, x:A) ⊢ M : B

→^{1} I

Γ; Ω; Δ ⊢ λx^{1}:A. M : A →^{1} B

Γ; Ω; Δ ⊢ M : A →^{u} B (Γ, Δ); Ω; · ⊢ N : A

→^{u} E Γ; Ω; Δ ⊢ M N^{u} : B

Γ; Ω; Δ ⊢ M : A →^{0} B (Γ, Ω, Δ); ·; · ⊢ N : A

→^{0} E Γ; Ω; Δ ⊢ M N^{0} : B

(Γ, Δ_{N}); Ω; Δ_{M} ⊢ M : A →^{1} B (Γ, Δ_{M}); Ω; Δ_{N} ⊢ N : A

→^{1} E Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ M N^{1} : B

Figure 3.1: Typing rules for λ^{→^{l}}

\begin{matrix}\begin{aligned}& Id^{1} \\ y:A; ·; x:A →^{1} A →^{1} B ⊢ x : A →^{1} A →^{1} \end{aligned} & \begin{aligned}& Id^{1} \\ x:A →^{1} A →^{1} B; ·; y:A ⊢ y : A \end{aligned} \\ →^{1} E \\ ·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ xy^{1} : A →^{1} B \end{matrix}  \begin{aligned}& Id^{u} \\ (x:A →^{1} A →^{1} B, y:A); ·; · ⊢ y : A \end{aligned}

→^{1} E

·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B

Figure 3.2: First derivation of ·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B

\begin{matrix}\begin{aligned}& Id^{1} \\ y:A; ·; x:A →^{1} A →^{1} B ⊢ x : A →^{1} A →^{1} B \end{aligned} & \begin{aligned}& Id^{u} \\ (x:A →^{1} A →^{1} B, y:A); ·; · ⊢ y : A \end{aligned} \\ →^{1} E \\ y:A; ·; x:A →^{1} A →^{1} B ⊢ xy^{1} : A →^{1} B \end{matrix}  \begin{aligned}& Id^{1} \\ x:A →^{1} A →^{1} B; ·; y:A ⊢ y : A \end{aligned}

→^{1} E

·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B

Figure 3.3: Second derivation of ·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B

The introduction rules for undetermined, invariant, and strict functions simply add a variable to the appropriate context and check the body of the function.

The difficult rules are the three elimination rules. First, the undetermined context Γ is always propagated to both premises. This reflects that we place no restriction on the use of these variables.

Next we consider the strict context Δ. Recall that this contains the variables which should occur strictly in a term. An undetermined function M : A →^{u} B may or may not use its argument. An occurrence of a variable in the argument to such a function can therefore not be guaranteed to be used. Hence we must require in the rule →^{u} E for an application M N^{u} that all variables in Δ occur strictly in M. This ensures at least one strict occurrence in M and no further restrictions on occurrences of strict variables in the argument are necessary. This is reflected in the rule by adding Δ to the undetermined context while checking the argument N. The treatment of the strict variables in the vacuous application M N^{0} is similar.

In the case of a strict application M N^{1} each strict variable should occur strictly in either M or N. We therefore split the context into Δ_{M} and Δ_{N} guaranteeing that each variable has at least one strict occurrence in M or N, respectively. However, strict variables can occur more than once, so variables from Δ_{N} can be used freely in M, and variables from Δ_{M} can occur freely in N. As before, we reflect this by adding these variables to the undetermined context.

Finally we consider the irrelevant context Ω. Variables declared in Ω cannot be used except in the argument to an irrelevant function (which is guaranteed to ignore its argument). We therefore add the irrelevant context Ω to the undetermined context when checking the argument of a vacuous application M N^{0}.

We now illustrate how the strict application rule non-deterministically splits contexts. Consider the typing problem ·; ·; (x:A →^{1} A →^{1} B, y:A) ⊢ (xy^{1})y^{1} : B. There are four ways to split the strict context:

Δ_{M} = x:A →^{1} A →^{1} B, y:A Δ_{N} = ·
Δ_{M} = x:A →^{1} A →^{1} B  Δ_{N} = y:A
Δ_{M} = y:A  Δ_{N} = x:A →^{1} A →^{1} B
Δ_{M} = ·  Δ_{N} = x:A →^{1} A →^{1} B, y:A

Only the first two yield a valid derivation (depicted in Figure 3.2 and Figure 3.3), as x needs to be strict in the leftmost branch.

Our strict λ-calculus satisfies the expected properties, culminating in the existence of canonical forms which is critical for the intended applications. We begin with the following:

Remark 3.1 (Inversion) All rules in λ^{→^{l}} are invertible.

We will often use inversion principles tacitly in proofs by structural induction on the typing derivation. Note that, although typing derivation may not, typing is unique.

Theorem 3.2 (Uniqueness of Typing) If Γ; Ω; Δ ⊢ M : A and Γ′; Ω′; Δ ⊢ M : A′, then A ≡ A′.

Proof: By induction on the structure of the given derivations, exploiting ‘functionality’ of signatures and contexts. □

We start addressing the structural properties of the context(s). Exchange is directly built into the formulation and will not be repeated.

Theorem 3.3 (Weakening)

1. (Weakening^{u}) If Γ; Ω; Δ ⊢ M : A then (Γ, x:C); Ω; Δ ⊢ M : A.

2. (Weakening^{0}) If Γ; Ω; Δ ⊢ M : A then Γ; (Ω, x:C); Δ ⊢ M : A.

Proof: By induction on the structure of the given derivation. □

The following properties allow us to lose track of strict and vacuous occurrences, if we are so inclined. We use the phrase ‘by sub-derivation’ to localize the immediate sub-derivation(s) of a given one; ‘by rule’ means in this Chapter by application of the correct (and unique) typing rule, when not explicitly mentioned.

Theorem 3.4 If Γ; (Ω, x:C); Δ ⊢ M : A, then (Γ, x:C); Ω; Δ ⊢ M : A.

Proof: By induction on the structure of D :: Γ; (Ω, x:C); Δ ⊢ M : A .

Case:

D = \begin{aligned}c:A ∈ Σ \\ & Idc \\ Γ; (Ω, x:C); · ⊢ c : A \end{aligned}

Then

E = \begin{aligned}c:A ∈ Σ \\ & Idc \\ (Γ, x:C); Ω; · ⊢ c : A \end{aligned}

Case:

D = \frac{Id^{u}}{(Γ, y:A); (Ω, x:C); · ⊢ y : A}

Then

E = \frac{Id^{u}}{(Γ, y:A, x:C); Ω; · ⊢ y : A}

Case:

D = \frac{Id^{1}}{Γ; (Ω, x:C); y:A ⊢ y : A}

Then

E = \frac{Id^{1}}{(Γ, x:C); Ω; y:A ⊢ y : A}

Case:

D = \begin{matrix}D′ \\ Γ; (Ω, x:C, y:A); Δ ⊢ M : B \end{matrix} ; →^{0} I ; Γ; (Ω, x:C); Δ ⊢ (λy^{0} :A. M) : A →^{0} B

Γ; (Ω, x:C, y:A); Δ ⊢ M : B  By sub-derivation
(Γ, x:C); (Ω, y:A); Δ ⊢ M : B  By IH on D′
(Γ, x:C); Ω; Δ ⊢ (λy^{0} :A. M) : A →^{0} B  By rule →^{0} I

Case: D ends in →^{u} I or →^{1} I: the claim follows from an immediate appeal to the inductive hypothesis, as in the above case.

Case:

D = \begin{matrix}D_{1} \\ Γ; (Ω, x:C); Δ ⊢ M : A →^{u} B \end{matrix} \begin{matrix}D_{2} \\ (Γ, Δ); (Ω, x:C); · ⊢ N : A \end{matrix} →^{u} E Γ; (Ω, x:C); Δ ⊢ M N^{u} : B

D_{1} :: Γ; (Ω, x:C); Δ ⊢ M : A →^{u} B  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M : A →^{u} B  By IH on D_{1}
D_{2} :: (Γ, Δ); (Ω, x:C); · ⊢ N : A  By sub-derivation
(Γ, Δ, x:C); Ω; · ⊢ N : A  By IH on D_{2}
(Γ, x:C); Ω; Δ ⊢ M N^{u} : B  By rule →^{u} E

Case:

D = \begin{matrix}D_{1} \\ Γ; (Ω, x:C); Δ ⊢ M : A →^{0} B \end{matrix} \begin{matrix}D_{2} \\ (Γ, Ω, Δ, x:C); ·; · ⊢ N : A \end{matrix} →^{0} E Γ; (Ω, x:C); Δ ⊢ M N^{0} : B

Γ; (Ω, x:C); Δ ⊢ M : A →^{0} B  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M : A →^{0} B  By IH on D_{1}
(Γ, Ω, Δ, x:C); ·; · ⊢ N : A  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M N^{0} : B  By rule →^{0} E

Case:

D = \begin{matrix}D_{1} \\ (Γ, Δ_{N}); (Ω, x:C); Δ_{M} ⊢ M : A →^{1} B \end{matrix} \begin{matrix}D_{2} \\ (Γ, Δ_{M}); (Ω, x:C); Δ_{N} ⊢ N : A \end{matrix} →^{1} E Γ; (Ω, x:C); (Δ_{N}, Δ_{M}) ⊢ M N^{1} : B

(Γ, Δ_{N}); (Ω, x:C); Δ_{M} ⊢ M : A →^{1} B  By sub-derivation
(Γ, x:C, Δ_{N}); Ω; Δ_{M} ⊢ M : A →^{1} B  By IH on D_{1}
(Γ, Δ_{M}); (Ω, x:C); Δ_{N} ⊢ N : A  By sub-derivation
(Γ, x:C, Δ_{M}); Ω; Δ_{N} ⊢ N : A  By IH on D_{2}
(Γ, x:C); Ω; (Δ_{N}, Δ_{M}) ⊢ M N^{1} : B  By rule →^{1} E
□

Corollary 3.5 (Loosening^{0}) If Γ; (Ω, Φ); Δ ⊢ M : A, then (Γ, Φ); Ω; Δ ⊢ M : A. Proof: By repeated application of Theorem 3.4. □ Theorem 3.6 If Γ; Ω; (Δ, x:C) ⊢ M : A, then (Γ, x:C); Ω; Δ ⊢ M : A. Proof: By induction on the structure of D :: Γ; Ω; (Δ, x:C) ⊢ M : A. Case: D ends in Con, Id^{u}: vacuously true. Case:

D = \frac{Id^{1}}{Γ; Ω; x:A ⊢ x : A}

Then

E = \frac{Id^{u}}{(Γ, x:A); Ω; · ⊢ x : A}

Case:

D = \begin{aligned}Γ; Ω; (Δ, x:C, y:A) ⊢ M : B \\ & →^{1} I \\ Γ; Ω; (Δ, x:C) ⊢ (λy^{1} :A. M) : A →^{1} B \end{aligned}

Draft of July 6, 2000

Γ; Ω; (Δ, x:C, y:A) ⊢ M : B  By sub-derivation
(Γ, x:C,); Ω; (Δ, y:A) ⊢ M : B  By IH
(Γ, x:C); Ω; Δ ⊢ (λy^{1} :A. M) : A →^{1} B  By rule

Case: D ends in →^{u} I or →^{0} I: the thesis follow from an immediate appeal to the inductive hypothesis as in

the above case. Case:

D = Γ; Ω; (Δ, x:C) ⊢ M : A →^{u} B (Γ, Δ, x:C); Ω; · ⊢ N : A →^{u} E Γ; Ω; (Δ, x:C) ⊢ M N^{u} : B
Γ; Ω; (Δ, x:C) ⊢ M : A →^{u} B  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M : A →^{u} B  By IH
(Γ, Δ, x:C), Ω; · ⊢ N : A  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M N^{u} : B  By rule

Case:

D = Γ; Ω; (Δ, x:C) ⊢ M : A →^{0} B (Γ, Ω, Δ, x:C); ·; · ⊢ N : A →^{0} E Γ; Ω; (Δ, x:C) ⊢ M N^{0} : B

Γ; Ω; (Δ, x:C) ⊢ M : A →^{0} B  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M : A →^{0} B  By IH
(Γ, Ω, Δ, x:C); ·; · ⊢ N : A  By sub-derivation
(Γ, x:C); Ω; Δ ⊢ M N^{0} : B  By rule

Case: D ends in →^{1}. There are two sub-cases:

x ∈ Δ_{M} D =

(Γ, Δ_{N}); Ω; (Δ′_{M}, x:C) ⊢ M : A →^{1} B (Γ, Δ′_{M}, x:C); Ω; Δ_{N} ⊢ N : A

→^{1} E Γ; Ω; (Δ′_{M}, x:C, Δ_{N}) ⊢ M N^{1} : B

(Γ, Δ_{N}); Ω; (Δ′_{M}, x:C) ⊢ M : A →^{1} B  By sub-derivation
(Γ, Δ_{N}, x:C); Ω; Δ′_{M} ⊢ M : A →^{1} B  By IH
(Γ, Δ′_{M}, x:C); Ω; Δ_{N} ⊢ N : A  By sub-derivation
(Γ, x:C); Ω; (Δ_{N}, Δ′_{M}) ⊢ M N^{1} : B  By rule

x ∈ Δ_{N} Symmetrical to the above.

□

Corollary 3.7 (Loosening^{1}) If Γ; Ω; Δ ⊢ M : A, then (Γ, Δ); Ω; · ⊢ M : A. Proof: By repeated application of Theorem 3.6. □ Theorem 3.8 (Substitution Properties)

1. (Substitution^{u}) If (Γ, x:A); Ω; Δ ⊢ M : C and (Γ, Δ); Ω; · ⊢ N : A, then Γ; Ω; Δ ⊢ [N/x]M : C.

2. (Substitution^{0}) If Γ; (Ω, x:A); Δ ⊢ M : C and (Γ, Δ, Ω); ·; · ⊢ N : A, then Γ; Ω; Δ ⊢ [N/x]M : C.

3. (Substitution^{1}) If (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ M : C and (Γ, Δ_{M}); Ω; Δ_{N} ⊢ N : A, then

Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ [N/x]M : C. Proof: The proof is by mutual induction on the height of the derivation D of M : C. We show the crucial cases.

Draft of July 6, 2000

3.1. STRICT TYPES  31

1.

Substitution^{u} Case:

D = \begin{aligned}c:C ∈ Σ \\ & Con \\ (Γ, x:A); Ω; · ⊢ c : C \end{aligned}

As [N/x]c = c, then

F = \begin{aligned}c:C ∈ Σ \\ & Con \\ Γ; Ω; · ⊢ c : C \end{aligned}

Case:

D = \frac{Id^{u}}{(Γ′, x:A, y:C); Ω; · ⊢ y : C}

As [N/x]y = y, then

F = \frac{Id^{u}}{(Γ′, y:C); Ω; · ⊢ y : C}

Case:

D = \frac{Id^{u}}{(Γ, x:A); Ω; · ⊢ x : C}

As [N/x]x = N and C = A, then F = E :: Γ; Ω; · ⊢ N : C Case:

D = \frac{Id^{1}}{(Γ, x:A); Ω; y:C ⊢ y : C}

As [N/x]y = y, then

F = \frac{Id^{1}}{Γ; Ω; y:C ⊢ y : C}

Case:

D = (Γ, x:A, y:B); Ω; Δ ⊢ M : C →^{u} I (Γ, x:A); Ω; Δ ⊢ λy^{u}:B. M : B →^{u} C

(Γ, x:A, y:B); Ω; Δ ⊢ M : C  By sub-derivation
Γ; Ω; · ⊢ N : C  By hypothesis
(Γ, y:B); Ω; · ⊢ N : C  By Weakening^{u}
(Γ, y:B); Ω; Δ ⊢ [N/x]M : C  By IH
Γ; Ω; Δ ⊢ (λy^{u}:B. [N/x]M) : A →^{u} B  By rule
Γ; Ω; Δ ⊢ [N/x](λy^{u}:B. M) : A →^{u} B  By subst.

Case: D ends with →^{0} I, →^{1} I: similarly. Case:

D = \begin{matrix}D_{1} \\ (Γ, x:A); Ω; Δ ⊢ P : B →^{u} C \end{matrix} \begin{matrix}D_{2} \\ (Γ, Δ, x:A); Ω; · ⊢ Q : B \end{matrix} →^{u} E (Γ, x:A); Ω; Δ ⊢ P Q^{u} : C

(Γ, x:A); Ω; Δ ⊢ P : B →^{u} C  By sub-derivation
E :: (Γ, Δ); Ω; · ⊢ N : A  By hypothesis
Γ; Ω; Δ ⊢ [N/x]P : B →^{u} C  By IH on D_{1} and E
(Γ, x:A, Δ); Ω; · ⊢ Q : B  By sub-derivation
(Γ, Δ); Ω; · ⊢ [N/x]Q : B  By IH on D_{2} and E
Γ; Ω; Δ ⊢ ([N/x]P)([N/x]Q)^{u} : C  By rule
Γ; Ω; Δ ⊢ [N/x](P Q^{u}) : C  By substitution.

Draft of July 6, 2000

Case:

D = \begin{matrix}D_{1} \\ (Γ, x:A); Ω; Δ ⊢ P : B →^{0} C \end{matrix} \begin{matrix}D_{2} \\ (Γ, Δ, Ω, x:A); ·; · ⊢ Q : B \end{matrix} →^{0} E (Γ, x:A); Ω; Δ ⊢ P Q^{0} : C

(Γ, x:A); Ω; Δ ⊢ P : B →^{0} C  By sub-derivation
E :: (Γ, Δ); Ω; · ⊢ N : A  By hypothesis
Γ; Ω; Δ ⊢ [N/x]P : B →^{0} C  By IH on D_{1} and E
(Γ, x:A, Ω, Δ); ·; · ⊢ Q : B  By sub-derivation
E′ :: (Γ, Δ, Ω); ·; · ⊢ N : A  By Loosening^{0} Ω in E
(Γ, Δ, Ω); ·; · ⊢ [N/x]Q : B  By IH on D_{2} and E′
Γ; Ω; Δ ⊢ [N/x](P Q)^{0} : C  By rule

Case: D =

\begin{matrix}D_{1} \\ (Γ, x:A, Δ_{Q}); Ω; Δ_{P} ⊢ P : B →^{1} C \end{matrix}  \begin{matrix}D_{2} \\ (Γ, x:A, Δ_{P}); Ω; Δ_{Q} ⊢ Q : B \end{matrix}

→^{1} E (Γ, x:A); Ω; (Δ_{P} , Δ_{Q}) ⊢ P Q^{1} : C

(Γ, x:A, Δ_{Q}); Ω; Δ_{P} ⊢ P : B →^{1} C  By sub-derivation
E :: (Γ, Δ_{P} , Δ_{Q}); Ω; · ⊢ N : A  By hypothesis
(Γ, Δ_{Q}); Ω; Δ_{P} ⊢ [N/x]P : B →^{1} C  By IH on D_{1} and E
(Γ, x:A, Δ_{P}); Ω; Δ_{Q} ⊢ Q : B  By sub-derivation
(Γ, Δ_{P}); Ω; Δ_{Q} ⊢ [N/x]Q : B  By IH on D_{2} and E
Γ; Ω; (Δ_{P} , Δ_{Q}) ⊢ [N/x](P Q)^{1} : C  By rule

2. Substitution^{0} Similar to the above.

3.

Substitution^{1}

Case: D ends in Con, Id^{u}: vacuously true. Case:

D = \frac{Id^{1}}{(Γ, Δ_{N}); Ω; x:A ⊢ x : A}

and [N/x]x = N; then Δ_{M} = ·, F = E :: Γ; Ω; Δ_{N} ⊢ N. Case:

D = \begin{matrix}D_{1} \\ (Γ, Δ_{N}); (Ω, y:B); (Δ_{M}, x:A) ⊢ Q : C \end{matrix} →^{0} I (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ λy^{0} :B. Q : B →^{0} C

D_{1} :: (Γ, Δ_{N}); (Ω, y:B); (Δ_{M}, x:A) ⊢ Q : C  By sub-derivation
E :: (Γ, Δ_{M}); Ω; Δ_{N} ⊢ N : A  By hypothesis
E′ :: (Γ, Δ_{M}); (Ω, y:B); Δ_{N} ⊢ N : A  By Weakening^{0} on E
Γ; (Ω, y:B); (Δ_{M}, Δ_{N}) ⊢ [N/x]Q : C  By IH on D_{1} and E′
Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ λy^{0} :B. [N/x]Q : B →^{0} C  By rule
Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ [N/x](λy^{0} :B. Q) : B →^{0} C  By substitution.

Case: D ends with →^{u} I. Proceed similarly using Weakening^{u}. Case: D ends with →^{1} I. It follows by an immediate appeal to the IH. Case:

D = (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ P : B →^{u} C (Γ, Δ_{M}, x:A, Δ_{N}); Ω; · ⊢ Q : B →^{u} E (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ P Q^{u} : C

D_{1} :: (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ P : B →^{u} C  By sub-derivation
E :: (Γ, Δ_{M}); Ω; Δ_{N} ⊢ N : A  By hypothesis
Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ [N/x]P : B →^{u} C  By IH on D_{1} and E
D_{2} :: (Γ, Δ_{M}, x:A, Δ_{N}); Ω; · ⊢ Q : B  By sub-derivation
(Γ, Δ_{M}, Δ_{N}); Ω; · ⊢ [N/x]Q : B  By IH on D_{2} and E
Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ [N/x](P Q)^{u} : C  By rule

Case: D ends in →^{0} E: similar. Case: D ends in →^{1} E: there are two sub-cases^{1}, where Δ_{M} = Δ_{P} , Δ_{Q}:

x ∈ Δ_{P} D =

\begin{matrix}D_{1} \\ (Γ, Δ_{N}, Δ_{Q}); Ω; (Δ′_{P} , x:A) ⊢ P : B →^{1} C \end{matrix}  \begin{matrix}D_{2} \\ (Γ, Δ_{N}, x:A, Δ′_{P}); Ω; Δ_{Q} ⊢ Q : B \end{matrix}

→^{1} E (Γ, Δ_{N}); Ω; (Δ′_{P} , x:A, Δ_{Q}) ⊢ P Q^{1} : C

D_{1} :: (Γ, Δ_{N}, Δ_{Q}); Ω; (Δ′_{P} , x:A) ⊢ P : B →^{1} C  By sub-derivation
E :: (Γ, Δ′_{P} Δ_{Q}); Ω; Δ_{N} ⊢ N : A  By hypothesis
(Γ, Δ_{Q}); Ω; (Δ′_{P} , Δ_{N}) ⊢ [N/x]P : B →^{1} C  By IH 3 on D_{1}, E
(Γ, Δ_{Q}, Δ_{N}); Ω; Δ′_{P} ⊢ [N/x]P : B →^{1} C  By Loosening^{1} Δ_{N}
D_{2} :: (Γ, Δ_{N}, x:A, Δ′_{P}); Ω; Δ_{Q} ⊢ Q : B  By sub-derivation
E′ :: (Γ, Δ′_{P} , Δ_{Q}, Δ_{N}); Ω; · ⊢ N : A  By Loosening^{1} Δ_{N} in E
(Γ, Δ_{N}, Δ′_{P}); Ω; Δ_{Q} ⊢ [N/x]Q : B  By IH 1 on D_{2}, E′
Γ; Ω; (Δ′_{P} , Δ_{Q}, Δ_{N}) ⊢ [N/x](P Q)^{1} : C  By rule

x ∈ Δ_{Q} Symmetrical to the above.

□

Theorem 3.9 (Contraction) Let z be a fresh variable of type A:

1. (Contraction^{u}) If (Γ, x:A, y:A); Ω; Δ ⊢ M : C, then (Γ, z:A); Ω; Δ ⊢ [z/y][z/x]M : C.

2. (Contraction^{0}) If Γ; (Ω, x:A, y:A); Δ ⊢ M : C, then Γ; (Ω, z:A); Δ ⊢ [z/y][z/x]M : C.

3. (Contraction^{1}) If Γ; Ω; (Δ, x:A, y:A) ⊢ M : C, then Γ; Ω; (Δ, z:A) ⊢ [z/y][z/x]M : C.

Proof:

1. (Γ, x:A, y:A); Ω; Δ ⊢ M : C  By assumption
(Γ, x:A, y:A, z:A); Ω; Δ ⊢ M : C  By Weakening^{u}
(Γ, y:A, Δ, z:A); Ω; · ⊢ z : A  By rule Id^{u}
(Γ, y:A, z:A); Ω; Δ ⊢ [z/x]M : C  By Substitution^{u}
(Γ, Δ, z:A); Ω; · ⊢ z : A  By rule Id^{u}
(Γ, z:A); Ω; Δ ⊢ [z/y][z/x]M : C  By Substitution^{u}

2. Similarly, using Substitution^{0}.

3. Γ; Ω; (Δ, x:A, y:A) ⊢ M : C  By assumption
(Γ, z:A); Ω; (Δ, x:A, y:A) ⊢ M : C  By Weakening^{u}
(Γ, y:A, Δ); Ω; z:A ⊢ z : A  By rule Id^{1}
Γ; Ω; (Δ, y:A, z:A) ⊢ [z/x]M : C  By Substitution^{1}

1FIXED

Draft of July 6, 2000

(Γ, z:A); Ω; (Δ, y:A) ⊢ [z/x]M : C  By Loosening^{1}
(Γ, Δ); Ω; z:A ⊢ z : A  By rule Id^{1}
Γ; Ω; (Δ, z:A) ⊢ [z/y][z/x]M : C  By Substitution^{1}
□

The notions of reduction and expansion derive directly from the ordinary β and η rules.

\begin{matrix}(λx^{k}:A. M) N^{k} & ⟶^{β} & [N/x]M \\ M : A →^{k} B & ⟶^{η̄} & λx^{k}:A. M x^{k} \end{matrix}

Indeed one of the main reason to introduce irrelevant variables, as ones which may occur but must not be used, is to well-type η-expansion of invariant functions:

M : A →^{0} B ⟶^{η̄} λx^{0}:A. M x^{0}

The subject reduction and expansion theorems are an immediate consequence of the structural and substitution properties.

Theorem 3.10 (Subject Reduction) If Γ; Ω; Δ ⊢ M : A and M ⟶^{β} M′ then Γ; Ω; Δ ⊢ M′ : A.

Proof: By induction^{2}on the relation M ⟶^{β} M′: we consider only the β reduction case, while the other congruence cases follow immediately by IH.

1. Let M ≡ (λx^{u}:B. P)Q^{u} : A and M′ ≡ [Q/x]P.

Γ; Ω; Δ ⊢ (λx^{u}:B. P)Q^{u} : A  By hypothesis
E :: (Γ, Δ); Ω; · ⊢ Q : B  By inversion
Γ; Ω; Δ ⊢ λx^{u}:B. P : B →^{u} A  By inversion
D :: (Γ, x:B); Ω; Δ ⊢ P : A  By inversion
Γ; Ω; Δ ⊢ [Q/x]P : A  By Substitution^{u} on D, E

2. Let M ≡ (λx^{0} :B. P)Q^{0} : A and M′ ≡ [Q/x]P.

Γ; Ω; Δ ⊢ (λx^{0} :B. P)Q^{0} : A  By hypothesis
E :: (Γ, Ω, Δ); ·; · ⊢ Q : B  By inversion
Γ; Ω; Δ ⊢ λx^{0} :B. P : B →^{0} A  By inversion
D :: Γ; (Ω, x:B); Δ ⊢ P : A  By inversion
Γ; Ω; Δ ⊢ [Q/x]P : A  By Substitution^{0} on D, E

3. Let M ≡ (λx^{1} :B. P)Q^{1} : A and M′ ≡ [Q/x]P.

Γ; Ω; Δ ⊢ (λx^{1} :B. P)Q^{1} : A and Δ = Δ_{P} , Δ_{Q}  By hypothesis
E :: (Γ, Δ_{P}); Ω; Δ_{Q} ⊢ Q : B  By inversion
(Γ, Δ_{Q}); Ω; Δ_{P} ⊢ λx^{1} :B. P : B →^{1} A  By inversion
D :: (Γ, Δ_{Q}); Ω; (Δ_{P} , x:B) ⊢ P : A  By inversion
Γ; Ω; (Δ_{P} , Δ_{Q}) ⊢ [Q/x]P : A  Substitution^{1} on D, E
□

Theorem 3.11 (Subject Expansion) If Γ; Ω; Δ ⊢ M : A →^{k} B and M ⟶^{η̄} M′ then Γ; Ω; Δ ⊢ M′ : A →^{k} B.

2FIXED Proof: By^{3}induction on the relation M ⟶^{η̄} M′: we consider only the η expansion case, while the other congruence cases follow immediately by IH:

Draft of July 6, 2000

1. Γ; Ω; Δ ⊢ M : A →^{u} B  By hypothesis
(Γ, x:A); Ω; Δ ⊢ M : A →^{u} B  By Weakening^{u}
(Γ, x:A, Δ); Ω; · ⊢ x : A  By rule Id^{u}
(Γ, x:A); Ω; Δ ⊢ M x^{u} : B  By rule →^{u} E
Γ; Ω; Δ ⊢ λx^{u}:A. M x^{u} : A →^{u} B  By rule →^{u} I
2. Γ; Ω; Δ ⊢ M : A →^{0} B  By hypothesis
Γ; (Ω, x:A); Δ ⊢ M : A →^{0} B  By Weakening^{0}
(Γ, Ω, x:A, Δ); ·; · ⊢ x : A  By rule Id^{u}
(Γ, x:A); Ω; Δ ⊢ M x^{0} : B  By rule →^{0} E
Γ; Ω; Δ ⊢ λx^{0} :A. M x^{0} : A →^{0} B  By rule →^{0} I
3. Γ; Ω; Δ ⊢ M : A →^{1} B  By hypothesis
(Γ, x:A); Ω; Δ ⊢ M : A →^{1} B  By Weakening^{u}
(Γ, Δ); Ω; x:A ⊢ x : A  By rule Id^{1}
Γ; Ω; (Δ, x:A) ⊢ M x^{1} : B  By rule →^{1} E
Γ; Ω; Δ ⊢ λx^{1} :A. M x^{1} : A →^{1} B  By rule →^{1} I
□

The following Lemma^{4}establishes a sort of consistency property of the type system, so that a term can be typed only by exclusive contexts. In particular we show that a term M cannot be both strict and vacuous in one variable, say x. This will be central in the proof of disjointness of term complementation (Theorem 4.20):

Lemma 3.12 It is not the case that both Γ_{1}; Ω_{1}; (Δ_{1}, x:C) ⊢ M : A and Γ_{2}; (Ω_{2}, x:C); Δ_{2} ⊢ M : A.

Proof: By induction on the structure of D_{1} :: Γ_{1}; Ω_{1}; (Δ_{1}, x:C) ⊢ M : A and inversion on D_{2} :: Γ_{2}; (Ω_{2}, x:C); Δ_{2} ⊢ M : A.

Case:

D_{1} = \frac{Id^{1}}{Γ_{1}; Ω_{1}; x:A ⊢ x : A}

but there can be no proof of x : A from Γ_{2}; (Ω_{2}, x:A); Δ_{2}.

Case:

D_{1} = \begin{aligned}Γ_{1}; Ω_{1}; (Δ_{1}, x:C, y:B) ⊢ M : A \\ & →^{1} I \\ Γ_{1}; Ω_{1}; (Δ_{1}, x:C) ⊢ λy^{1} :B. M : B →^{1} A \end{aligned}

and

D_{2} = \begin{aligned}Γ_{2}; (Ω_{2}, x:C); (Δ_{2}, y:B) ⊢ M : A \\ & →^{1} I \\ Γ_{2}; (Ω_{2}, x:C); Δ_{2} ⊢ λy^{1} :B. M : B →^{1} A \end{aligned}

Γ_{1}; Ω_{1}; (Δ_{1}, x:C, y:B) ⊢ M : A  By sub-derivation of D_{1}
Γ_{2}; (Ω_{2}, x:C); (Δ_{2}, y:B) ⊢ M : A  By inversion on D_{2}
⊥  By IH

Case: D_{1} ends in →^{u} I, →^{0} I. The result follows analogously by IH.

Case: D_{1} ends in →^{u} E, →^{0} E. The result follows by IH on the leftmost sub-derivation.

3FIXED 4FIXED Case: D_{1} ends in →^{1} E: there are two sub-cases:

Subcase: Δ_{M}^{1} = Ψ_{M}^{1}, x:C

D_{1} = (Γ_{1}, Δ_{N}^{1}); Ω_{1}; (Ψ_{M}^{1}, x:C) ⊢ M : A →^{1} B (Γ_{1}, Ψ_{M}^{1}, x:C); Ω_{1}; Δ_{N}^{1} ⊢ N : A →^{1} E Γ_{1}; Ω_{1}; (Ψ_{M}^{1}, x:C, Δ_{N}^{1}) ⊢ M N^{1} : B

and

D_{2} = (Γ_{2}, Δ_{N}^{2}); (Ω_{2}, x:C); Δ_{M}^{2} ⊢ M : A →^{1} B (Γ_{2}, Δ_{M}^{2}); (Ω_{2}, x:C); Δ_{N}^{2} ⊢ N : A →^{1} E Γ_{2}; (Ω_{2}, x:C); (Δ_{M}^{2}, Δ_{N}^{2}) ⊢ M N^{1} : B

(Γ_{1}, Δ_{N}^{1}); Ω_{1}; (Ψ_{M}^{1}, x:C) ⊢ M : A →^{1} B  By sub-derivation of D_{1}
(Γ, Δ_{N}^{2}); (Ω_{2}, x:C); Δ_{M}^{2} ⊢ M : A →^{1} B  By inversion on D_{2}
⊥  By IH

Subcase: Δ_{N}^{1} = Ψ_{N}^{1}, x:C: Symmetrically.

□

Corollary 3.13 (Exclusivity)

1. It is not the case that both Γ; Ω; (Δ, x:C) ⊢ M : A and (Γ, Ω, Δ); x:C; · ⊢ M : A.

2. It is not the case that both Γ; (Ω, x:C); Δ ⊢ M : A and (Γ, Ω, Δ); ·; x:C ⊢ M : A. Proof:

1. Not Γ; Ω; (Δ, x:C) ⊢ M : A and Γ; (Ω, x:C); Δ ⊢ M : A  By Lemma 3.12
Not Γ; Ω; (Δ, x:C) ⊢ M : A and (Γ, Δ); (Ω, x:C); · ⊢ M : A  By Loosening^{1} Δ
Not Γ; Ω; (Δ, x:C) ⊢ M : A and (Γ, Ω, Δ); x:C; · ⊢ M : A  By Loosening^{0} Ω

2. Analogously.

□

We end this section by checking that our strict calculus is a conservative extension of the simply typed λ-calculus. We therefore define a forgetful functor from λ^{→^{l}} to λ^{→}:

| A →^{k} B | = | A | → | B |
| a | = a
| x | = x
| c | = c
| λx^{k}:A. M | = λx:| A |. | M |
| M N^{k} | = | M | | N |
| · | = ·
| Γ, x:A | = | Γ |, x: | A |
| Σ, a:type | = | Σ |, a:type
| Σ, c:A | = | Σ |, c: | A |

Theorem 3.14 (Conservativity) If Γ; Ω; Δ ⊢_{λ^{\underrightarrow{l}}} M : A,, then | Γ |, | Ω |, | Δ | ⊢_{λ^{→}}| M | : | A |. Proof: By induction on the structure of the given derivation. □

Draft of July 6, 2000

\begin{aligned}c:A ∈ Σ \\ & cIdc \\ Γ; Ω; · ⊢ c ↓ A \end{aligned}

\frac{cId^{u}}{(Γ, x:A); Ω; · ⊢ x ↓ A}  no rule for cId^{0}  \frac{cId^{1}}{Γ; Ω; x:A ⊢ x ↓ A}

Γ; Ω; Δ ⊢ M ↓ a

cAt Γ; Ω; Δ ⊢ M ⇑ a

(Γ, x:A); Ω; Δ ⊢ M ⇑ B

c →^{u} I

Γ; Ω; Δ ⊢ (λx^{u}:A. M) ⇑ A →^{u} B

Γ; Ω; (Δ, x:A) ⊢ M ⇑ B

c →^{1} I

Γ; Δ ⊢ (λx^{1} :A. M) ⇑ A →^{1} B

Γ; (Ω, x:A); Δ ⊢ M ⇑ B

c →^{0} I

Γ; Ω; Δ ⊢ (λx^{0} :A. M) ⇑ A →^{0} B

Γ; Ω; Δ ⊢ M ↓ A →^{u} B (Γ, Δ); Ω; · ⊢ N ⇑ A

c →^{u} E Γ; Ω; Δ ⊢ M N^{u} ↓ B

Γ; Ω; Δ ⊢ M ↓ A →^{0} B (Γ, Ω, Δ); ·; · ⊢ N ⇑ A

c →^{0} E Γ; Ω; Δ ⊢ M N^{0} ↓ B

(Γ, Δ_{N}); Ω; Δ_{M} ⊢ M ↓ A →^{1} B (Γ, Δ_{M}); Ω; Δ_{N} ⊢ N ⇑ A

c →^{1} E Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ M N^{1} ↓ B

Figure 3.4: Canonical forms for λ^{→^{l}}

3.2 Canonical Forms

We present the inductive definition of canonical forms in λ^{→^{l}}, i.e. terms in βη-long normal form. This is a generalization of canonicity for the simply-typed λ-calculus, as described in [Pfe92]. It is realized by the two mutually recursive judgments depicted in Figure 3.2:

1. Γ; Ω; Δ ⊢ M ↓ A: M is atomic of type A.

2. Γ; Ω; Δ ⊢ M ⇑ A: M is canonical of type A.

Theorem 3.15 (Canonical Form Theorem) If Γ; Ω; Δ ⊢ M : A, then there is N such that Γ; Ω; Δ ⊢ M ⇑ N : A.

Proof: A suitable reformulation of Tait’s method along the lines of [Cer96]^{5}. □

We sometimes abbreviate the statement of the canonical form Theorem as Γ; Ω; Δ ⊢ M ⇑↓ A.

We will also need the typing rule and the canonical form for existential variables. We use Φ for arrays of (distinct) labeled bound variables; if x^{k} ∈ Φ, we set Φ(x) = k. We say that Γ; Ω; Δ ⊢ Φ ok if the following holds:

5Fill in

Draft of July 6, 2000

Φ(x) = u ↔ x ∈ dom(Γ)
Φ(x) = 0 ↔ x ∈ dom(Ω)
Φ(x) = 1 ↔ x ∈ dom(Δ)

Moreover, if Γ; Ω; Δ ⊢ M : A and Γ; Ω; Δ ⊢ Φ ok we may write ⌜Φ⌝ ⊢ M : A.

We assume that the type A in E_{A} is well-behaved w.r.t. Γ; Ω; Δ and Φ.

Γ; Ω; Δ ⊢ Φ ok

P at Γ; Ω; Δ ⊢ E_{A} Φ : a

Γ; Ω; Δ ⊢ E_{A} Φ : a

cP at Γ; Ω; Δ ⊢ E_{A} Φ ↓ a

Remark 3.16 Exclusivity (Lemma 3.12) holds for open patterns as well.

Proof: Assume that both Γ; Ω; (Δ, x:C) ⊢ E Φ : A and Γ′; (Ω′, x:C); Δ′ ⊢ E Φ : A. Then Γ; Ω; (Δ, x:C) ⊢ Φ ok and Γ′; (Ω′, x:C); Δ′ ⊢ Φ ok iff Φ(x) = 1 and Φ(x) = 0, impossible. □

3.3 Related Work on Strictness

Church original definition of the set Λ_{I} of (untyped) λ-terms [Chu41] has this clause for abstraction:

If M ∈ Λ_{I} and x ∈ F V (M), then λx . M ∈ Λ_{I}.

i.e. in this language there cannot be any vacuous abstractions. It can be shown that the only difference between Λ_{I} and Λ – the usual definition of λ-terms – is the lack of the combinator K. Indeed, it can be shown that every term in Λ can be defined from Λ_{I} and K. The λI-calculus is the theory of conversion restricted to Λ_{I} terms. This fragment was favored by Church over the nowadays usual calculus, because, among other issues, it is strong enough to represent every partial recursive function, albeit not in the most efficient way: see [Bar80] Chapter 2.2.2 − 2.2.5 and more extensively in Chapter 9. See [GdQ92] for an historical account.

This would correspond in a simply typed setting to allowing only strict types: more formally if we denote with Λ^{→^{k}} the terms typable in a Curry system based on the →^{k} function space, then Λ^{→^{1}} = Λ^{→^{u}} ∩ Λ_{I}, as noted for example in [BF93].

The combinatory counterpart of this calculus obviously excludes K and consists of I, W, B, C, see [CF58] and [Bar80], Appendix B for an alternative basis. Those are the axioms of what Church called weak implicational logic [Chu51], i.e. identity, contraction, prefixing and permutation. This establishes the link with an enterprise born from a very different origin.

The relevance logic project emerged in fact in the early sixties out of Anderson and Belnap’s dissatisfaction with the so-called ‘paradoxes of implication’, let it be material, intuitionistic or strict (in the modal sense of Lewis and Langford); it was built on the work of Moh, Church, Parry in the fifties^{6} and climaxed with the publication of the first volume of Entailment [AB75] (the second one was published only in 1992 [AAB92]). Following Girard’s and Belnap’s [Bel93] suggestion, we will not refer to our calculus as relevant, but as strict logic, as the former may also satisfy other principles such as distributivity of arrow over conjunction.

On an unrelated front, starting with Mycroft’s seminal paper [Myc80], compile-time analysis of functional programs concentrated on strictness analysis in order to get the best out of call-by-value and call-by-need evaluation; first in terms of abstract interpretation, later by using non-standard types to represent these ‘intensional’ information about functions (see [Jen91] for a comparison of these two techniques). However, earlier work as [TMM89] used non-standard primitive type to distinguish strict or non-strict terms, closed only under intuitionistic implication. Not forgetting Wadler’s early paper [Wad90] on using linear logic for sharing analysis, Wright [Wri91, Wri92] seems the first one to have extended the Curry-Howard isomorphism

6Some early work in the twenties in the Soviet Union was, at the time, not accessible.

Draft of July 6, 2000

\frac{var}{Γ[1 := 0], x^{1}:A ⊢ x : A}

Γ ⊢ M : A →^{1} B Γ′ ⊢ N : A′ app →^{1} Γ, Γ′ ⊢ M N : B

Γ ⊢ M : A →^{0} B Γ′ ⊢ N : A′ app →^{0} Γ, Γ′[1 := 0] ⊢ M N : B

Γ ⊢ M : A →^{u} B Γ′ ⊢ N : A′ app →^{u}

Γ, Γ′[1 := u] ⊢ M N : B

All elimination rules have the condition A′ ≤ A

Figure 3.5: The system in [BF93]

to (the implicational fragment of) relevance logic and explicitly connected the two areas, although both [Bel74] and [Hel77] had previously recognized the link between strictness and relevance^{7}.

In [BF93] the author summarizes the above-mentioned idea of expressing via types the reduction behavior of terms. He characterizes in an operational sense the class of terms which need their argument, the idea being that not only each terms need to be strict, but so does the result of each application. M is not strict if for all N no descendant of N is in the normal form of M N. This class is then shown to be equivalent to the Curry-typable fragment of Λ_{I}.

We now discuss the Curry typing system proposed there, which makes available strict, invariant and intuitionistic types: yet, it is biased towards enforcing strictness information, which ultimately lead to a difference of expressive power from our calculus. Some rules are presented in Figure 3.5– we omit the introduction rules which are as expected – transliterated in our notation. There is only one context, where variables carry their occurrence status as a label. There are no different abstractors or applicators, but different rules. Note that there is only one identity rule, the strict one, so that e.g. λx . x : A →^{u} A is not derivable, as it can be given the more stringent type A →^{1} A. The elimination rules are not syntax-directed, therefore not invertible, as the system is essentially top-down driven. Let us concentrate on the elimination rules: the side condition enforces the information ordering, so that for example A′ →^{0} B ≤ A →^{u} B′, provided that A ≤ A′, B ≤ B′. This allow to infer by strict application Γ, Γ′ ⊢ M N : C from Γ ⊢ M : (A →^{u} B) →^{1} C and Γ′ ⊢ A →^{0} B. The latter is instead forbidden in our system by the labeled reduction rules. The rationale on the substitution operation on context is that in app →^{0} A is not relevant to B, so all hypothesis should be deleted. Instead, in order to preserve every variable declaration, their strict label is changed into irrelevant. This would amount to moving the strict variables in the irrelevant context in our system. Note the difference with our rule, where the latter variables are moved in the undetermined context. Similarly in app →^{u} strict labels turn into undetermined. Moreover, having only one context, the author needs a strategy to deal with same binding with different annotations; the solution is that while propagating premises top-down a binding x^{1}:A supersedes x^{u}:A which in turn supersedes x^{0}:A.

The author goes on (see also [WBF93]) detailing a system which refines the strict calculus by allowing to count usage, motivated by sharing analysis; thus A →^{i} B denotes a term where A is used i times to infer B. Undetermined usage is then added via dummy variables. This unfortunately leads to an undecidable type checking problem.

In [Wri96] Wright introduces an Annotation Logic as a general framework for resource-conscious logics. The annotation logic has formulae/types of the form

A ::= X^{k} | A →^{k} B

7Note that we have became aware of this literature only after having fully developed our calculus which was modeled after the two-zoned linear logic calculus.

Draft of July 6, 2000

for any annotation k and has structural and connective rules as well as annotation ones:

\begin{aligned}Γ ⊢ A^{i} \\ & ∗k \\ Γ^{k} ⊢ A^{ik} \end{aligned}  \begin{aligned}Γ, A^{i} ⊢ B \\ & +k \\ Γ, A^{i+k} ⊢ B \end{aligned}

The latter implement rules such as promotion/dereliction. By instantiation with different algebras of annotation, we get systems as linear, strict logic as well as various other usage logics. An abstract normalization procedure is sketched, which however needs commutative conversions (e.g. the case contraction/arrow elimination) already in the purely implicational fragment. Another problem is that properties as loosening should in our opinion be admissible rather than primitive rules.

Bunched Implication

In a series of papers Pym et at. (see [Pym99] and references therein) introduce a first-order and its correspondent dependent type calculus which aim to couple multiplicative and addititive implication. The two are distinct by allowing two different constructors for contexts which are called “bunches”. This is different from a zoned calculus as bunches can be nested. As expected, contraction and weakening are allowed for additive assumptions but not for multiplicative ones. The resulting logic can be seen as variant of relevant logic, as there is no requirement that an argument to a multiplicative function must be used only once, but only that it should not share with other variables in the (proof) term. Thus, in out terminology A →^{1} ((A →^{u} A →^{u} B) →^{u} B) is derivable, but not A →^{1} ((A →^{1} A →^{1} B) →^{1} B). Moreover, the logic allows additive conjunction to distribute on additive disjunction, which is not allowed in multiplicative additive intuitionistic linear logic. Its naturality should follow from its categorical semantics. Its correspondent dependent type calculus, dubbed RLF is proposed as a resource conscious conservative extension of LF.

Relevant Logic Programming

In [Bol90] the author presents his approach to relevant, i.e. in our terminology strict logic programming as part of his dissertation on ‘Conditional Logic Programming’ [Bol88]. He makes a (weak) case for its utility in applications such as planning and diagnosis, whose hypothetical queries should indeed use their premises. The system boils down to a strict version of N-Prolog. Unfortunately the author was only partially aware of Girard’s work on linear logic, and entirely not aware of the notion of uniform proof [MNPS91], although he gives a brave attempt to a mainly proof-theoretic approach: thus, as Gabbay and McCarthy before, he embarks on an awfully complicated and low-level description of an interpreter which enforces the usage requirement, for, I think, the following fragment; note that there are two conjunctions: & is additive and ∧ multiplicative.

Assertions A ::= P | Q →^{1} P | A_{1}&A_{2} | ∀x . A
Queries Q ::= P | Q_{1} ∧ Q_{2} | Q_{1} ∨ Q_{2} | A →^{1} Q | ∃x . Q

If we were formulating a strict logical framework in the sense of [Cer96], the former system would therefore be a strict (no pun intended) subset of the latter.

The Relative Complement Problem for Higher-Order Patterns

We introduce in the next Section 4.1 a restriction of the language for which complementation is possible (Section 4.2). Moreover, in Section 4.3 we will give an unification algorithm for this fragment. Section 4.4 shows how the former operations induce a boolean algebra over finite sets of terms.

4.1 Towards Term Complementation

Now that we have developed a calculus which is potentially strong enough to represent the complement of linear patterns, we need to answer two questions: how do we embed the original λ-calculus, and is the calculus now closed under complement?

We reiterate that we require that our complement operator ought to satisfy the usual boolean rules for negation:

1. (Disjointness) It is not the case that some M is both a ground instance of N and of Not(N).

2. (Exhaustivity) Every M is a ground instance of N or of Not(N).

Unfortunately, while the first property follows quite easily from Corollary 3.13, it turns out that exhaustivity does not hold in general in the presence of intuitionistic application. In fact, consider the application y x^{u}; while it is clear that Γ ⊢ y x^{u} ∈ ∥E x^{u} y^{u}∥, it is not the case that Γ ⊢ y x^{u} ∈ ∥E x^{1} y^{u}∥ or Γ ⊢ y x^{u} ∈ ∥E x^{0} y^{u}∥.

However, the main result of this Chapter is that the complement algorithm presented in Definition 4.13 is sound and complete for the fragment which results from the natural embedding of the original simply-typed λ-calculus; this is sufficient for our overall goal, that is to use term complementation as a subroutine of clause complementation (see Section 6.5). We will proceed in two separate phases:

• Restrict to a class of terms (that we call simple) for which the crucial property of tightening (Lemma 4.5) can be established, yielding exhaustivity as a corollary.

• Bring simple terms to ‘full application’.

4.1.1 Simple Terms

Recall that we have introduced strictness to capture occurrence conditions on variables in canonical forms. This means that first-order constants (and by extension bound variables) should be considered strict functions of their argument, since these arguments will indeed occur in the canonical form. On the other hand, if we have a second order constant, we cannot restrict the argument function to be either strict or vacuous, since this would render our representations inadequate.

42 CHAPTER 4. THE RELATIVE COMPLEMENT PROBLEM FOR HIGHER-ORDER PATTERNS

Example 4.1 Continuing Example 2.6, consider the representation of the K combinator:

⌜λx. λy. x⌝ = lam (λx:exp. lam (λy:exp. x))

Notice that the argument to the first occurrence of ‘lam’ is a strict function, while the argument to the second occurrence is an invariant function. If we can give only one type to ‘lam’ it must therefore be

(exp →^{u} exp) →^{1} exp.

Generalizing this observation means that positive occurrence of function types are translated to strict functions, while negative occurrences to undetermined functions. We can formalize this as an embedding of the simply-typed λ-calculus into a fragment of the strict calculus via two (overloaded) mutually recursive functions ()^{−} and ()^{+}. First, the definition on types.

(A → B)^{+} = A^{−} →^{1} B^{+}
(A → B)^{−} = A^{+} →^{u} B^{−}
a^{−} = a^{+} = a

We extend it to canonical terms (including existential variables), signatures, and contexts; we remark that embedding only canonical forms rules out the case of ‘+-ing’ a lambda expression.

(λx:A. M)^{−} = λx^{u}:A^{+}. M^{−}
M^{−} = M^{+}  for M of base type
x^{+} = x
c^{+} = c
(E_{A} x_{1} … x_{n})^{+} = F_{A^{−}} x_{1}^{u} … x_{n}^{u}
(M N)^{+} = M^{+} (N^{−})^{1}
(·)^{+} = ·
(Γ, x:A)^{+} = Γ^{+}, x:A^{+}
(Σ, a:type)^{+} = Σ^{+}, a:type
(Σ, c:A)^{+} = Σ^{+}, c:A^{+}

Example 4.2 Coming back to Example 4.1:

(lam (λx:exp. lam (λy:exp. x)))^{+} = lam (λx^{u}:exp. lam (λy^{u}:exp. x)^{1})^{1}

The image of the embedding of the canonical forms of the simply-typed λ-calculus gives rise to the following fragment:

Simple Terms M ::= λx^{u}:A^{+}. M | (… (h M_{1})^{1} … M_{n})^{1} | (… (E_{A^{−}} x_{1})^{u} … x_{n})^{u}

We often abbreviate (… (h M_{1})^{1} … M_{n})^{1} as h \overline{M_{n}^{1}}; similarly we shall use F_{A^{−}} \overline{x_{n}^{u}}. Note that, by the restriction to η-long β-normal forms, such terms, as well as pattern variables, must be of base type.

To prove the correctness of the embedding (Theorem 4.4), we will need the following:

Lemma 4.3 If Γ ⊢ E_{A} \overline{x_{n}} : a, then Γ^{+}; ·; · ⊢ F_{A^{−}} \overline{x_{n}^{u}} : a.

Proof: A straightforward induction on A. □

The next theorem requires the usual inductive definition of canonical terms in the simply-typed λ-calculus, which can be obtained by dropping labels (Theorem 3.14) from the definition of canonical form in Figure 3.2.

Theorem 4.4 (Correctness of ()^{±})

1. If Γ ⊢ M ⇑ A, then Γ^{+}; ·; · ⊢ M^{−} ⇑ A^{−}.

2. If Γ ⊢ M ↓ A, then Γ^{+}; ·; · ⊢ M^{+} ↓ A^{+}. Proof: By mutual induction on the proofs of D_{1} :: Γ ⊢ M ⇑ A and D_{2} :: Γ ⊢ M ↓ A. Case:

D_{2} = c:A ∈ Σ ; atmCnst ; Γ ⊢ c ↓ A

Since c^{+} = c and Σ^{+}(c) = A^{+} we conclude

E − \frac{cIdc}{Γ^{+}; ·; · ⊢ c^{+} ↓ A^{+}}

Case:

D_{2} = \frac{atmVar}{(Γ, x:A) ⊢ x ↓ A}

Since x^{+} = x and Γ^{+}(x) = A^{+} we conclude

E = \frac{cId^{u}}{(Γ^{+}, x:A^{+}) ⊢ x^{+} ↓ A^{+}}

Case:

D_{2} = Γ ⊢ M ↓ B → A Γ ⊢ N ⇑ B atmApp Γ ⊢ M N ↓ A
Γ ⊢ M ↓ B → A  By sub-derivation
Γ^{+}; ·; · ⊢ M^{+} ↓ (B → A)^{+}  By IH 2
Γ^{+}; ·; · ⊢ M^{+} ↓ B^{−} →^{1} A^{+}  By the embedding
Γ ⊢ N ⇑ B  By sub-derivation
Γ^{+}; ·; · ⊢ N^{−} ⇑ B^{−}  By IH 1
Γ^{+}; ·; · ⊢ M^{+}(N^{−})^{1} ↓ A^{+}  By rule c →^{1} E
Γ^{+}; ·; · ⊢ (M N)^{+} ↓ A^{+}  By the embedding

Case:

D_{2} = Γ ⊢ E_{A} \overline{x_{n}} : a canPat Γ ⊢ E_{A} \overline{x_{n}} ↓ a
Γ ⊢ E_{A} \overline{x_{n}} : a  By sub-derivation
Γ^{+}; ·; · ⊢ F_{A^{−}} \overline{x_{n}^{u}} : a  By Lemma 4.3
Γ^{+}; ·; · ⊢ F_{A^{−}} \overline{x_{n}^{u}} ↓ a  By rule cP at
Γ^{+}; ·; · ⊢ (E_{A} \overline{x_{n}})^{+} : a^{+}  By the embedding

Case:

D_{1} = Γ ⊢ M ↓ a ; canAtm ; Γ ⊢ M ⇑ a

Γ ⊢ M ↓ a  By sub-derivation
Γ^{+}; ·; · ⊢ M^{+} ↓ a^{+}  By IH 2
Γ^{+}; ·; · ⊢ M^{+} ⇑ a^{+}  By rule cAt
Γ^{+}; ·; · ⊢ M^{−} ⇑ a^{−}  By the embedding

Draft of July 6, 2000

Case:

D_{1} = Γ, x:A ⊢ M ⇑ B canLam Γ ⊢ λx:A. M ⇑ A → B
Γ, x:A ⊢ M ⇑ B  By sub-derivation
(Γ^{+}, x:A^{+}) ⊢ M^{−} ⇑ B^{−}  By IH 1
Γ^{+}; ·; · ⊢ λx^{u}:A^{+}. M ⇑ A^{+} →^{u} B^{−}  By rule c →^{u} I
Γ^{+}; ·; · ⊢ (λx:A. M)^{−} ⇑ (A → B)^{−}  By the embedding
□

From now on we may hide the ()^{1} decoration from strict application of constants in examples. Moreover, for every judgment J on simple terms, we will shorten Γ; ·; · ⊢ J into Γ ⊢ J.

We can now prove the crucial tightening lemma. It expresses the property that every closed simple term is either strict or vacuous in a given undetermined variable. Lemma 4.5 (Tightening) Let M be a simple pattern without existential variables:

1. If (Γ, x:C); Ω; Δ ⊢ M ↓ A, then Γ; Ω; (Δ, x:C) ⊢ M ↓ A or Γ; (Ω, x:C); Δ ⊢ M ↓ A.

2. If (Γ, x:C); Ω; Δ ⊢ M ⇑ A, then Γ; Ω; (Δ, x:C) ⊢ M ⇑ A or Γ; (Ω, x:C); Δ ⊢ M ⇑ A. Proof: By mutual induction on D_{1} :: (Γ, x:C); Ω; Δ ⊢ M ↓ A and D_{2} :: (Γ, x:C); Ω; Δ ⊢ M ⇑ A. Case:

D_{1} = \begin{aligned}c:A ∈ Σ \\ & cIdc \\ (Γ, x:C); Ω; · ⊢ c ↓ A \end{aligned}

Then

E = \begin{aligned}c:A ∈ Σ \\ & cIdc \\ Γ; (Ω, x:C); · ⊢ c ↓ A \end{aligned}

and by weakening the claim. Case:

D_{1} = \frac{cId^{u}}{(Γ, x:C, y:A); Ω; · ⊢ y ↓ A}

Then

E = \frac{cId^{u}}{(Γ, y:A); (Ω, x:C); · ⊢ y ↓ A}

and by weakening the claim. Case:

D_{1} = \frac{cId^{u}}{(Γ, x:C); Ω; · ⊢ x ↓ C}

Then

E = \frac{cId^{1}}{Γ; Ω; x:C ⊢ x ↓ C}

and by weakening the claim. Case:

D_{1} = \frac{Id^{1}}{(Γ, x:C); Ω; y:A ⊢ y ↓ A}

Then

E = \frac{Id^{1}}{Γ; (Ω, x:C); y:A ⊢ y ↓ A}

and by weakening the claim.

Draft of July 6, 2000

Case:

D_{2} = \begin{aligned}(Γ, x:C); Ω; Δ ⊢ M ↓ a \\ & cAt \\ (Γ, x:C); Ω; Δ ⊢ M ⇑ a \end{aligned}

(Γ, x:C); Ω; Δ ⊢ M ↓ a  By sub-derivation
Γ; Ω; (Δ, x:C) ⊢ M ↓ a or Γ; (Ω, x:C); Δ ⊢ M ↓ a  By IH 1
Subcase: Γ; Ω; (Δ, x:C) ⊢ M ↓ a  By assumption
Γ; Ω; (Δ, x:C) ⊢ M ⇑ a  By rule cAt

hence the claim by weakening.

Subcase: Γ; (Ω, x:C); Δ ⊢ M ↓ a  By assumption
Γ; (Ω, x:C); Δ ⊢ M ⇑ a  By rule cAt

hence the claim by weakening.

Case:

D = (Γ, x:C, y:A); Ω; Δ ⊢ M ⇑ B c →^{u} I (Γ, x:C); Ω; Δ ⊢ (λy^{u}:A. M) ⇑ A →^{u} B

(Γ, x:C, y:A); Ω; Δ ⊢ M ⇑ B  By sub-derivation
(Γ, y:A); Ω; (Δ, x:C) ⊢ M ⇑ B or (Γ, y:A); (Ω, x:C); Δ ⊢ M ⇑  By IH 2
Subcase: (Γ, y:A); Ω; (Δ, x:C) ⊢ M ⇑ B  By assumption
Γ; Ω; (Δ, x:C) ⊢ (λy^{u}:A. M) ⇑ A →^{u} B  By rule c →^{u} I

hence the claim by weakening.

Subcase: (Γ, y:A); (Ω, x:C); Δ ⊢ M ⇑: symmetrical

Case:

D = (Γ, x:C, Δ_{N}); Ω; Δ_{M} ⊢ M ↓ A →^{1} B (Γ, x:C, Δ_{M}); Ω; Δ_{N} ⊢ N ⇑ A c →^{1} E (Γ, x:C); Ω; (Δ_{M}, Δ_{N}) ⊢ M N^{1} ↓ B

There are four sub-cases, stemming from IH 1 and 2:

1. (Γ, Δ_{N}); Ω; (Δ_{M}, x:C) ⊢ M ↓ A →^{1} B  By assumption
(ΓΔ_{M}); Ω; (x:C, Δ_{N}) ⊢ N ⇑ A  By assumption
(Γ, Δ_{M}, x:C); Ω; Δ_{N} ⊢ N ⇑ A  By Loosening^{1} x
Γ; Ω; (Δ_{M}, x:C, Δ_{N}) ⊢ M N^{1} ↓ B  By rule

hence by weakening the claim.

2. (Γ, Δ_{N}); (Ω, x:C); Δ_{M} ⊢ M ↓ A →^{1} B  By assumption
(Γ, Δ_{M}); (Ω, x:C); Δ_{N} ⊢ N ⇑ A  By assumption
Γ; (Ω, x:C); (Δ_{M}, Δ_{N}) ⊢ M N^{1} ↓ B  By rule

hence by weakening the claim.

3. (Γ, Δ_{N}); Ω; (Δ_{M}, x:C) ⊢ M ↓ A →^{1} B  By assumption
(Γ, Δ_{M}); (Ω, x:C); Δ_{N} ⊢ N ⇑ A  By assumption
(Γ, x:C, Δ_{N}); Ω; Δ_{M} ⊢ N ⇑ A  By Loosening^{0} x
Γ; Ω; (Δ_{M}, x:C, Δ_{N}) ⊢ M N^{1} ↓ B  By rule

hence by weakening the claim.

4. Symmetrical to 3.

□

We remark that tightening fails to hold once we allow non-simple terms, namely intuitionistic application. For example y:A →^{u} B, x:A; ·; · ⊢ y x^{u} : B but both y:A →^{u} B; ·; x:A ⊬ y x^{u} : B and y:A →^{u} B; x:A; · ⊬ y x^{u} : B. This suggest that simple terms are not only a useful technical device to achieve term complement in the simply-typed case, but possibly for other more general calculi such as the linear λ-calculus.

Ω = dom(Γ)\ | Φ |

                                                    TrnPat

Γ ⊢ E Φ^{u} ⟷ Z Φ^{u} Ω^{0}

Γ, x:A ⊢ M ⟷ N

                                                      TrnLam

Γ ⊢ λx^{u}:A. M ⟷ λx^{u}:A. N

Γ ⊢ M_{1} ⟷ N_{1} ⋯ Γ ⊢ M_{n} ⟷ N_{n} TrnApp

Γ ⊢ h \overline{M_{n}^{1}} ⟷ h \overline{N_{n}^{1}}

Figure 4.1: Full application translation: Γ ⊢ M ⟷ N

Corollary 4.6 Let M be a simple closed pattern such that Γ; ·; · ⊢ M ⇑↓ A; then there are Δ, Ω such that Γ = Δ, Ω and ·; Ω; Δ ⊢ M ⇑↓ A.

Proof: By induction on Γ, using Lemma 4.5. □

4.1.2 Full Application

We can simplify the presentation of the algorithms for complement and later unification if we extend every term to be applied to all bound variables in their declaration order. This is possible for simple linear patterns without changing the set of its ground instances. We just insert vacuous applications, which guarantees that the extra variables are not used. In slight abuse of notation we call the resulting terms fully applied.

We describe^{1}in Figure 4.1.2 the judgment Γ ⊢ M ⟷ N which turns a term M into an equivalent fully applied term N: while we need this translation specialized to simple terms, it is clear how to generalize this judgment to the canonical forms of any strict term.

Example 4.7 Recall the simple term from Example 2.8:

lam (λx^{u}:exp. app E x)

has fully applied form

lam (λx^{u}:exp. app (Z x^{0}) x)

for a fresh existential variable Z of type exp →^{0} exp.

We may check the the output of the translation is indeed fully applied w.r.t. its definition in Figure 2.3:

Lemma 4.8 If M is a simple term and Γ ⊢ M ⟷ N, then Γ ⊢ N f.a. .

Proof: A straightforward induction on the structure of the given derivation. □

We have now arrived to the following language, where the labeling on flexible patterns is unrestricted, still called “simple terms”:

Simple Terms M ::= λx^{u}:A^{+}. M | (… (h M_{1})^{1} … M_{n})^{1} | (… (E x_{1}^{l_{1}}) … x_{n}^{l_{n}})

To prove the set-theoretic adequacy of the translation, we will need the following irrelevance Lemma.

Lemma 4.9 (Irrelevance) If M is a closed simple term, then:

1. If Γ; (Ω, x:C); Δ ⊢ M ⇑ A, then Γ; Ω; Δ ⊢ M ⇑ A.

2. If Γ; (Ω, x:C); Δ ⊢ M ↓ A, then Γ; Ω; Δ ⊢ M ↓ A.

1FIXED

Draft of July 6, 2000

4.1. TOWARDS TERM COMPLEMENTATION  47

Proof: By mutual induction on D_{1} :: Γ; (Ω, x:C); Δ ⊢ M ↓ A and D_{2} :: Γ; (Ω, x:C); Δ ⊢ M ⇑ A. Case:

D_{1} = \begin{aligned}c:A ∈ Σ \\ & cIdc \\ Γ; (Ω, x:C); · ⊢ c ↓ A \end{aligned}

Then

E = \begin{aligned}c:A ∈ Σ \\ & cIdc \\ Γ; Ω; · ⊢ c ↓ A \end{aligned}

Case:

D_{1} = \frac{cId^{u}}{(Γ, y:A); (Ω, x:C); · ⊢ y ↓ A}

Then

E = \frac{cId^{u}}{(Γ, y:A); Ω; · ⊢ y ↓ A}

Case:

D_{1} = \frac{cId^{1}}{Γ; (Ω, x:C); y:A ⊢ y ↓ A}

Then

E = \frac{cId^{1}}{Γ; Ω; y:A ⊢ y ↓ A}

Case: D_{2} ends in cAt: by IH 2. Case:

D_{2} = (Γ, y:A); (Ω, x:C); Δ ⊢ M ⇑ B c →^{u} I Γ; (Ω, x:C); Δ ⊢ (λy^{u}:A. M) ⇑ A →^{u} B

(Γ, y:A); (Ω, x:C); Δ ⊢ M ⇑ B  By sub-derivation
(Γ, y:A); Ω; Δ ⊢ M ⇑ B  By IH 2
Γ; Ω; Δ ⊢ (λy^{u}:A. M) ⇑ A →^{u} B  By rule

Case: D_{2} =

(Γ, Δ_{N}); (Ω, x:C); Δ_{M} ⊢ M ↓ A →^{1} B (Γ, Δ_{M}); (Ω, x:C); Δ_{N} ⊢ N ⇑ A

c →^{1} E Γ; (Ω, x:C); (Δ_{M}, Δ_{N}) ⊢ M N^{1} ↓ B

(Γ, Δ_{N}); (Ω, x:C); Δ_{M} ⊢ M ↓ A →^{1} B  By sub-derivation
(Γ, Δ_{N}); Ω; Δ_{M} ⊢ M ↓ A →^{1} B  By IH 2
(Γ, Δ_{M}); (Ω, x:C); Δ_{N} ⊢ N ⇑ A  By sub-derivation
(Γ, Δ_{M}); Ω; Δ_{N} ⊢ N ⇑ A  By IH 1
Γ; Ω; (Δ_{M}, Δ_{N}) ⊢ M N^{1} ↓ B  By rule
□

Note that this holds for any strict canonical terms, but it is false for terms containing redeces. For example ·; x:A; · ⊢ (λy^{0} :A. c) x^{0} : B, as x becomes unbound in the rightmost premise, but ·; ·; · ⊬ (λy^{0} :A. c) x^{0} : B.

Draft of July 6, 2000

M ↓ t Φ · ⊢ t : A grFlx

Γ ⊢ M ∈ ∥E_{A} Φ∥ : a

(Γ, x:A); Ω; Δ ⊢ M ∈ ∥N∥ : B

                                                          grLam

Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. N∥ : A →^{u} B

Γ ⊢ h : \overline{A_{n}} →^{1} a Γ ⊢ M_{1} ∈ ∥N_{1}∥ : A_{1} ⋯ Γ ⊢ M_{n} ∈ ∥A_{n}∥ : A_{n} grApp

Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h \overline{N_{n}^{1}}∥ : a

Figure 4.2: Ground instance: Γ ⊢ M ∈ ∥N∥ : A

Ground Instances We recall that we assume every type to be inhabited, so that every term can be seen as the intensional representation of the set of its ground instances. The judgment in Figure 4.2 Γ ⊢ M ∈ ∥N∥ : A formalizes conditions for M to be a ground instance of a simple linear term N at type A. We then extend the judgment to sets of terms of the same type as follows:

∃i:1 ≤ i ≤ n Γ ⊢ M ∈ ∥N_{i}∥ : A gr_{i}

Γ ⊢ M ∈ ∥N_{1} ⋯ N_{n}∥ : A

Remark 4.10 Γ ⊢ M ∈ ∥E_{A} Φ∥ : a iff M ↓ t Φ and · ⊢ t : A iff t ≡ λΦ . S and if Γ; Ω; Δ ⊢ Φ ok , then Γ; Ω; Δ ⊢ S : A. This fact will be heavily used in the following. Lemma 4.11 (Ground Instance Weakening) If Γ ⊢ M ∈ ∥N∥ : A then (Γ, x:A) ⊢ M ∈ ∥N∥ : A. Proof: By induction on the structure of the given derivation. □

We implicitly use the above lemma to weaken different contexts with common basis to an unique one. Now we can prove that the the full application translation preserves the set of ground instances.

Theorem 4.12 (Adequacy of Full Application Translation) Let N be a simple term of type A, such that Γ ⊢ N ⟷ Q; then Γ ⊢ M ∈ ∥N∥ : A iff Γ ⊢ M ∈ ∥Q∥ : A. Proof: By induction on the structure of D :: Γ ⊢ M ⟷ N. Case: D ends in TrnPat:

(→) Γ ⊢ M ∈ ∥E_{B} Φ^{u})∥ and Ω = dom(Γ)\ | Φ |  By assumption
M ↓ t Φ^{u} and · ⊢ t : B for Γ; ·; · ⊢ Φ ok  By inversion
Γ; ·; · ⊢ S : A  By Remark 4.10
Γ; ·; · ⊢ S ⇑↓ A  By the canonical form Theorem
Γ; Ω; · ⊢ S ⇑↓ A  By Weakening^{0}
Γ; Ω; · ⊢ S : A  By soundness of canonicity
M ↓ t′ Φ^{u}Ω^{0} for · ⊢ t′ : B′ and Γ; Ω; · ⊢ (Φ^{u}, Ω^{0}) ok  By Remark 4.10
Γ; ·; · ⊢ M ∈ ∥F_{B′} Φ^{u}Ω^{0}∥  By rule
(←) Γ; ·; · ⊢ M ∈ ∥F_{B′} Φ^{u}Ω^{0}∥ and Ω = dom(Γ)\ | Φ |  By assumption
M ↓ t′ Φ^{u}Ω^{0} for · ⊢ t′ : B′ and Γ; Ω; · ⊢ (Φ^{u}, Ω^{0}) ok  By inversion
Γ; Ω; · ⊢ S : A  By Remark 4.10
Γ; Ω; · ⊢ S ⇑↓ A  By the canonical form Theorem

Draft of July 6, 2000

Γ; ·; · ⊢ S ⇑↓ A  By Irrelevance (Lemma 4.9)
Γ; ·; · ⊢ S : A  By soundness of canonicity
Γ; ·; · ⊢ M ∈ ∥E_{B} Φ^{u}∥  By rule and Remark 4.10

Case: D ends in TrnLam or TrnApp: the result follows from a straightforward application of the inductive hypothesis.

□

From now on we tacitly assume that all simple terms are fully applied. We call a term E x_{1}^{l_{1}} … x_{n}^{l_{n}} a generalized variable.

4.2 The Complement Algorithm

The idea of complementation for applications and abstractions is quite simple and similar to the first-order case. For generalized variables we consider each argument in turn. If an argument variable is undetermined it does not contribute to the negation. If an argument variable is strict then any term where this variable does not occur contributes to the negation. We therefore complement the corresponding label from 0 to 1 while all other arguments are undetermined. For vacuous argument variables we proceed dually. If Γ = x_{1}:A_{1}, …, x_{n}:A_{n}, we write E Γ^{u} for the application of E x_{1}^{u} … x_{n}^{u}. Such an application represents the set of all terms without existential variables and free variables from Γ.

In preparation for the rules, we observe that the complement operation on terms behaves on labels like negation does on truth-values in Kleene’s three-valued logic, in the sense of the following table:

Not(1) = 0
Not(0) = 1
Not(u) = u

Note that these labels form a three-valued semi-lattice with the (reverse) partial information ordering 1 ≤ u, 0 ≤ u.

Definition 4.13 (Higher-Order Pattern Complement) Fix a signature Σ. For a linear simple term M such that Γ ⊢ M : A define Γ ⊢ Not(M) ⇒ N : A by the following rules:

∃i:1 ≤ i ≤ n k ∈ {1, 0}

                                                                           NotFlx

Γ ⊢ Not(E x_{1}^{k_{1}} … x_{i−1}^{k_{i−1}} x_{i}^{k} x_{i+1}^{k_{i+1}} … x_{n}^{k_{n}}) ⇒ Z x_{1}^{u} … x_{i−1}^{u} x_{i}^{Not(k)} x_{i+1}^{u} … x_{n}^{u} : a

no rule for k = u

Γ, x:A ⊢ Not(M) ⇒ N : B

                                                            NotLam

Γ ⊢ Not(λx^{u}:A. M) ⇒ λx^{u}:A. N : A →^{u} B

g ∈ Σ ∪ Γ, g : A_{1} →^{1} … →^{1} A_{m} →^{1} a m ≥ 0, h ≢ g

NotApp^{1}

Γ ⊢ Not(h \overline{M_{n}^{1}}) ⇒ (… (g (Z_{1} Γ^{u}))^{1} … (Z_{m} Γ^{u}))^{1} : a

∃i:1 ≤ i ≤ n Γ ⊢ Not(M_{i}) ⇒ N : A_{i}
NotApp^{2}
Γ ⊢ Not(h \overline{M_{n}^{1}}) ⇒ (… (h (Z_{1} Γ^{u}))^{1} … (Z_{i−1} Γ^{u})^{1} N^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{n} Γ^{u}))^{1} : a

where the Z’s are fresh logic variables of appropriate typing, h ∈ Σ ∪ Γ and Γ ⊢ h : A_{1} →^{1} … →^{1} A_{n} →^{1} a. Note that a given M may be related to several terms N all of which belong to the complement of M. Finally we define Γ ⊢ Not(M) = N : A if N = {N | Γ ⊢ Not(M) ⇒ N : A}.

We may drop the type information from the above judgment in examples and proofs; we will write Γ ⊢ M ∈ ∥Not(N)∥ : A, when Γ ⊢ Not(N) = N and Γ ⊢ M ∈ ∥N ∥ : A.

Note that if E_{A} is a generalized variable considered in the empty context, it has the canonical form λ\overline{x_{n}^{u}} . E \overline{x_{n}^{u}}. Hence · ⊢ Not(E_{A}) = ∅ as expected.

Example 4.14 Let Γ = x:B, y:C:

Γ ⊢ Not(E x^{u}y^{1}) = {F x^{u}y^{0}}
Γ ⊢ Not(E x^{0}y^{1}) = {F x^{1}y^{u}, G x^{u}y^{0}}  (4.1)

It is worthwhile to observe that the members of a complement set are not mutually disjoint, due to the indeterminacy of u. We can achieve an exclusive ‘or’ if we resolve this indeterminacy, that is by considering for every x^{u} the two possibilities x^{1}, x^{0}. Thus, for example, equation (4.1) may be made explicit into:

{F x^{1}y^{1}, G x^{1}y^{0}, H x^{0}y^{0}}

It is clear that in the worst case scenario the number of terms in a complement set is bound by 2^{n}; hence the usefulness of this further step needs to be pragmatically determined.

Example 4.15 In the signature of numerals:

Not(λx^{u}λy^{u}. s(E x^{1}y^{0})^{1} =
{λx^{u}λy^{u}. x, λx^{u}λy^{u}. y, λx^{u}λy^{u}. 0, λx^{u}λy^{u}. s(Z x^{0}y^{u})^{1}, λx^{u}λy^{u}. s(Z′ x^{u}y^{1})^{1}}

We can now revisit^{2} Example 2.8:

Not(lam(λx^{u}:exp. app (E x^{0}) x)) =
{lam(λx^{u}:exp. app (Z x^{1}) (Z′ x^{u})),
lam(λx^{u}:exp. app (Z x^{u}) (app (Z′ x^{u}) (Z′′x^{u})),
lam(λx^{u}:exp. app (Z x^{u}) (lam(λy^{u}:exp. Z′ x^{u} y^{u})),
lam(λx^{u}:exp. lam(λy^{u}:exp. Z x^{u} y^{u})),
lam(λx^{u}:exp. x),
app Z Z′}

It is easy to show that simple terms are closed under complementation.

Theorem 4.16 If M is a simple term and Γ ⊢ Not(M) ⇒ N : A, then N is simple.

Proof: By induction on the structure of D :: Γ ⊢ Not(M) ⇒ N : A.

Case: D ends in NotFlx: immediate.

Case:

D = Γ, x:A ⊢ Not(M) ⇒ N : B NotLam Γ ⊢ Not(λx^{u}:A. M) ⇒ λx^{u}:A. N : A →^{u} B

By sub-derivation Γ, x:A ⊢ Not(M) ⇒ N : B, hence by IH N is simple and so is λx^{u}:A. N.

Case:

D = g ∈ Σ ∪ Γ, g : A_{1} →^{1} … →^{1} A_{m} →^{1} a m ≥ 0, h ≢ g NotApp^{1} Γ ⊢ Not(h \overline{M_{n}^{1}}) ⇒ (… (g (Z_{1} Γ^{u}))^{1} … (Z_{m} Γ^{u}))^{1} : a

Since every (Z_{i} Γ^{u}) is simple, so is (… (g (Z_{1} Γ^{u}))^{1} … (Z_{m} Γ^{u}))^{1}.

2To avoid too many indices on existential variables, we adopt a convention that the scope of existential variables is limited to each member of a complement set.

Draft of July 6, 2000

Case: D =

Γ ⊢ Not(M_{i}) ⇒ N : A_{i} 1 ≤ i ≤ n
NotApp^{2}
Γ ⊢ Not(h \overline{M_{n}^{1}}) ⇒ (… (h (Z_{1} Γ^{u}))^{1} … (Z_{i−1} Γ^{u})^{1} N^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{n} Γ^{u}))^{1} : a

By IH N is simple and as above so is every (Z_{i} Γ^{u}). Thus (… (h (Z_{1} Γ^{u}))^{1} … (Z_{i−1} Γ^{u}) N^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{n} Γ^{u}))^{1} is simple.

□

Corollary 4.17 If M is a simple term, and Γ ⊢ Not(M) = N, then N is a set of simple terms.

We address the soundness and completeness of the complement algorithm w.r.t. the set-theoretic semantics: the proof obligation consists in proving that the former does behave as a complement operation on sets of patterns, i.e. it satisfies disjointness and exhaustivity. Termination is obvious as the algorithm is syntax-directed and only finitely branching. We start with soundness: for Φ ≡ x_{1}^{k_{1}} … x_{i−1}^{k_{i−1}} x_{i}^{d} x_{i+1}^{k_{i+1}} … x_{n}^{k_{n}} let Not(Φ) ≡ x_{1}^{u} … x_{i−1}^{u} x_{i}^{Not(d)} x_{i+1}^{u} … x_{n}^{u}.

Theorem 4.18 Let Γ ⊢ N : A be simple linear pattern: for every Q such that Γ ⊢ Not(N) ⇒ Q : A, it is not the case that both Γ ⊢ M ∈ ∥N∥ : A and Γ ⊢ M ∈ ∥Q∥ : A.

Proof: By induction on the structure of D :: Γ ⊢ Not(N) ⇒ Q.

Case: D ends in NotFlx. For x:A ∈ Γ let Φ(x_{i}) = 1; moreover let Ψ; Ω; (Δ, x:A) ⊢ Φ ok; assume Γ ⊢ M ∈ ∥E Φ∥ and Γ ⊢ M ∈ ∥Not(E Φ)∥, that is Γ ⊢ M ∈ ∥Z Not(Φ)∥. Then both Ψ; Ω; (Δ, x:A) ⊢ M : A and (Ψ, Ω, Δ); x:A; · ⊢ M : A, impossible by Corollary 3.13. Analogously for k_{i} = 0. The result follows trivially for k_{i} = u.

Case: D ends in NotApp^{1}. Suppose both Γ ⊢ M ∈ ∥h \overline{N_{n}^{1}}∥ and Γ ⊢ M ∈ ∥g (Z_{1} Γ^{u})^{1} … (Z_{m} Γ^{u})^{1}∥ for h ≢ g; but this is immediately impossible by rule grApp as the root of M should be both h and g.

Case: D ends in NotApp^{2}.

Γ ⊢ Not(h \overline{N_{n}^{1}}) ⇒ (… (h (Z_{1} Γ^{u}))^{1} … (Z_{i−1} Γ^{u})^{1} Q^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{n} Γ^{u}))^{1} : a  By hypothesis
Γ ⊢ Not(N_{i}) ⇒ Q : A_{i}, for some 1 ≤ i ≤ n  By sub-derivation
Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h \overline{N_{n}^{1}}∥ : a  By assumption
Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h (Z_{1} Γ^{u})^{1} … (Z_{i−1} Γ^{u})^{1} Q^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{n} Γ^{u})^{1}∥ : a  By assumption
Γ ⊢ M_{i} ∈ ∥N_{i}∥ : A_{i}  By inversion
Γ ⊢ M_{i} ∈ ∥Q∥ : A_{i}  By inversion
⊥  By IH

Case: D ends in NotLam:

Γ ⊢ Not(λx^{u}:A. N) ⇒ λx^{u}:A. Q : A →^{u} B  By hypothesis
Γ, x:A ⊢ Not(N) ⇒ Q : B  By sub-derivation
Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. N∥ : A →^{u} B  By hypothesis
Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. Q∥ : A →^{u} B  By assumption
Γ, x:A ⊢ M ∈ ∥N∥ : B  By inversion
Γ, x:A ⊢ M ∈ ∥Q∥ : B  By inversion
⊥  By IH
□

Note that soundness is based on Corollary 3.13, which holds for any strict term: thus disjointness does not require simple terms.

M ↓ t Φ · ⊬ t : A ngrFlx

Γ ⊢ M ∉ ∥E_{A} Φ∥ : a

Γ, x:A ⊢ M ∉ ∥N∥ : B ngrLam

Γ ⊢ λx^{u}:A. M ∉ ∥λx^{u}:A. N∥ : A →^{u} B

Γ ⊢ h : \overline{A_{n}} →^{1} a ∃i : 1 ≤ i ≤ n. Γ ⊢ M_{i} ∉ ∥N_{i}∥ : A_{i} ngrApp

Γ ⊢ h \overline{M_{n}^{1}} ∉ ∥h \overline{N_{n}^{1}}∥ : a

g ≢ h

                                             ngrAppCls

Γ ⊢ g \overline{M_{m}} ∉ ∥h \overline{N_{n}^{1}}∥ : a

Figure 4.3: Not a ground instance: Γ ⊢ M ∉ ∥N∥ : A

Lemma 4.19 Assume Γ ⊢ E_{A} Φ : a; then, either Γ ⊢ M ∈ ∥E_{A} Φ∥ : a or there exists 1 ≤ i ≤ n such that Γ ⊢ Not(E_{A} Φ) ⇒ Z Not(Φ) : a and Γ ⊢ M ∈ ∥Z Not(Φ)∥ : a.

Proof: Let Γ; ·; · ⊢ M : A; then by Corollary 4.6 there exists Ω and Δ such that Γ = Ω, Δ and ·; Ω; Δ ⊢ M ⇑↓ A. Fix x_{i}^{k_{i}} for 1 ≤ i ≤ n:

Case: For every x ∈ dom(Ω) such that x = x_{i}^{k_{i}} it holds k_{i} ∈ {0, u} and for every x ∈ dom(Δ), k_{i} ∈ {1, u}. Then Γ ⊢ M ∈ ∥E Φ∥.

Case: For some x ∈ dom(Ω) such that x = x_{i}^{k_{i}} it holds k_{i} = 1. Then Γ ⊢ M ∈ ∥Z x_{1}^{u} … x_{i−1}^{u} x_{i}^{1} x_{i+1}^{u} … x_{n}^{u}∥, that is Γ ⊢ M ∈ ∥Z|Not(Φ)∥.

Case: For some x ∈ dom(Δ) such that x = x_{i}^{k_{i}} it holds k_{i} = 0. Then Γ ⊢ M ∈ ∥Z x_{1}^{u} … x_{i−1}^{u} x_{i}^{0} x_{i+1}^{u} … x_{n}^{u}∥, that is Γ ⊢ M ∈ ∥Z Not(Φ)∥.

□

For technical reasons, we need the rules complementary to Figure 4.2. Those are depicted in Figure 4.3: We are now ready to prove exhaustivity of complementation.

Theorem 4.20 Assume Γ ⊢ N : A is a simple linear pattern; then if Γ ⊢ M ∉ ∥N∥ : A, then there is a Q such that Γ ⊢ Not(N) ⇒ Q : A and Γ ⊢ M ∈ ∥Q∥ : A.

Proof: By induction on the structure of D :: Γ ⊢ M ∉ ∥N∥ : A.

Case: D ends in ngrFlx: by Lemma 4.19.

Case: D ends in ngrAppCls.

Γ ⊢ g \overline{M_{m}} ∉ ∥h \overline{N_{n}^{1}}∥ : a  By hypothesis
Γ ⊢ Not(h \overline{N_{n}^{1}}) ⇒ (… (g (Z_{1} Γ^{u}))^{1} … (Z_{m} Γ^{u}))^{1} : a  By rule NotApp^{1}
Γ ⊢ g \overline{M_{m}} ∈ ∥g (Z_{1} Γ^{u})^{1} … (Z_{m} Γ^{u})^{1}∥ : a  By rule grApp

Case: D ends in ngrApp:

Γ ⊢ h \overline{M_{n}^{1}} ∉ ∥h \overline{N_{n}^{1}}∥ : a  By hypothesis
Γ ⊢ M_{i} ∉ ∥N_{i}∥ : A_{i} for some 1 ≤ i ≤ n  By sub-derivation
Γ ⊢ Not(N_{i}) ⇒ Q : A_{i} and Γ ⊢ M_{i} ∈ ∥Q∥ : A_{i}  By IH
Γ ⊢ M_{j} ∈ ∥(Z_{j} Γ^{u})^{1}∥ for all j ≠^{·} i, 1 ≤ j ≤ n  By rule grFlx
Γ ⊢ Not(h \overline{M_{n}^{1}}) ⇒ (… (h (Z_{1} Γ^{u}))^{1} … (Z_{i−1} Γ^{u})^{1} N^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{n} Γ^{u}))^{1} : a  By rule NotLam
Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h (Z_{1} Γ^{u})^{1} … (Z_{i−1} Γ^{u})^{1} Q^{1} (Z_{i+1} Γ^{u})^{1} … (Z_{m} Γ^{u})^{1}∥ : a  By rule grApp.

Case: D ends in ngrLam.

Γ ⊢ λx^{u}:A. M ∉ ∥λx^{u}:A. N∥ : A →^{u} B  By hypothesis
Γ, x:A ⊢ M ∉ ∥N∥ : B  By sub-derivation
Γ, x:A ⊢ Not(N) ⇒ Q : B and Γ, x:A ⊢ M ∈ ∥Q∥ : B for some Q  By IH
Γ ⊢ Not(λx^{u}:A. N) ⇒ λx^{u}:A. Q : A →^{u} B  By rule NotLam
Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. Q∥ : A →^{u} B  By rule grLam

□

Corollary 4.21 (Partition Lemma) For a fixed signature Σ let Γ ⊢ N : A be a linear simple term:

1. (Disjointness) It is not the case that Γ ⊢ M ∈ ∥N∥ : A and Γ ⊢ M ∈ ∥Not(N)∥ : A.

2. (Exhaustivity) Γ ⊢ M ∈ ∥N∥ : A or Γ ⊢ M ∈ ∥Not(N)∥ : A.

Proof: Disjointness is entailed by Theorem 4.18, exhaustivity by Theorem 4.20. □

4.3 Unification of Simple Terms

As we observed earlier in Chapter 2, we can solve a relative complement problem pairing complementation with intersection. We thus address now the task of giving an algorithm for unification of (linear) simple terms. We start by determining when two labeling are compatible:

1 ∩ 1 = u ∩ 1 = 1 ∩ u = 1
0 ∩ 0 = u ∩ 0 = 0 ∩ u = 0
u ∩ u = u

Recall that Φ is a list of labeled bound variables; we can extend the intersection operations to these contexts.

· ∩ · = ·
(Φ, x^{k}) ∩ (Φ′, x^{k′}) = (Φ ∩ Φ′, x^{k∩k′}) if k ∩ k′ is defined.

Remark 4.22 If Γ_{i}; Ω_{i}; Δ_{i} ⊢ Φ_{i} ok, 1 ≤ i ≤ 2, then (Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ (Φ_{1} ∩ Φ_{2}) ok, where Γ_{1} ∩ Γ_{2} denotes set-theoretic intersection and (Φ_{1} ∩ Φ_{2})(x) =^{def} Φ_{1}(x) ∩ Φ_{2}(x). Indeed, (Φ_{1} ∩ Φ_{2})(x) = u iff x ∈ dom(Γ_{1}) and x ∈ dom(Γ_{2}); moreover (Φ_{1} ∩ Φ_{2})(x) = 0 iff either x ∈ dom(Ω_{1} ∪ Γ_{2}) or x ∈ dom(Ω_{2} ∪ Γ_{1}). Analogously for (Φ_{1} ∩ Φ_{2})(x) = 1. From that, as before, it follows that Ψ ⊢ M ∈ ∥E_{A} Φ_{1} ∩ Φ_{2}∥ iff M ↓ λΦ_{1} ∩ Φ_{2} . S such that (Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ S : A.

Following standard terminology with call atomic terms whose head is a free or bound variable rigid, while terms whose head is an existential variable is called flexible.

Definition 4.23 (Higher-Order Pattern Intersection) Fix a signature Σ. For simple linear terms M and N without shared variables such that Γ ⊢ M : A and Γ ⊢ N : A, define Γ ⊢ M ∩ N ⇒ Q : A by the following rules:

\frac{∩F F}{Γ ⊢ (E_{1} Φ_{1}) ∩ (E_{2} Φ_{2}) ⇒ H (Φ_{1} ∩ Φ_{2}) : a}

no rule for flex-flex same

c ∈ Σ Γ ⊢ (H_{1} Φ_{1}) ∩ M_{1} ⇒ N_{1} : A_{1} ⋯ Γ ⊢ (H_{n} Φ_{n}) ∩ M_{n} ⇒ N_{n} : A_{n}

∩F R^{c}
Γ ⊢ (E Φ) ∩ (c \overline{M_{n}^{1}}) ⇒ c \overline{N_{n}^{1}} : a

y ∈ Γ Γ ⊢ (H_{1} Φ_{1}) ∩ M_{1} ⇒ N_{1} : A_{1} ⋯ Γ ⊢ (H_{n} Φ_{n}) ∩ M_{n} ⇒ N_{n} : A_{n}

∩F R^{y}
Γ ⊢ (E Φ) ∩ (y \overline{M_{n}^{1}}) ⇒ y \overline{N_{n}^{1}} : a

h ∈ Γ ∪ Σ Γ ⊢ M_{1} ∩ N_{1} ⇒ Q_{1} : A_{1} ⋯ Γ ⊢ M_{n} ∩ N_{n} ⇒ Q_{n} : A_{n}

∩RR
Γ ⊢ h \overline{M_{n}^{1}} ∩ h \overline{N_{n}^{1}} ⇒ h \overline{Q_{n}^{1}} : a

Γ, x:A ⊢ M ∩ N ⇒ Q : B

∩L

Γ ⊢ λx^{u}:A. M ∩ λx^{u}:A. N ⇒ λx^{u}:A. Q : A →^{u} B

where the H’s are fresh variables of appropriate typing and n ≥ 0. We omit two rules ∩RF^{c} and ∩RF^{y} which are symmetric to ∩F R^{c} and ∩F R^{y}. The rules ∩F R^{c} and ∩RF^{c} have the following proviso: for all x ∈ Φ and 1 ≤ i, j ≤ n:

∀x.Φ(x) = 0 → ∀i . Φ_{i}(x) = 0
∀x.Φ(x) = u → ∀i . Φ_{i}(x) = u
∀x.Φ(x) = 1 → ∃i . Φ_{i}(x) = 1 ∧ ∀j, j ≠ i.Φ_{j}(x) = u

The rules ∩F R^{y} and ∩RF^{y} are subject to the proviso:

∀x.Φ(x) = 0 → ∀i . Φ_{i}(x) = 0
∀x.Φ(x) = u → ∀i . Φ_{i}(x) = u
∀x.x ≠ y ∧ Φ(x) = 1 → ∃i . Φ_{i}(x) = 1 ∧ ∀j, j ≠ i.Φ_{j}(x) = u
Φ(y) = u ∨ (Φ(y) = 1 ∧ ∀i.Φ_{i}(y) = u)

Finally define Γ ⊢ M ∩ N : A = Q if Q = {Q | Γ ⊢ M ∩ N ⇒ Q : A}.

Some remarks are in order:

• In rule ∩F F we can assume that the same list of variables, though with different labeling, is the argument of E, F and H, since simple terms are fully-applied and due to linearity we can always reorder the context to the same list.

• Since patterns are linear and M and N share no pattern variables, the flex-flex case arises only with distinct variables. This also means we do not have to apply substitutions or perform the customary occurs-check.

• In the flex/rigid and rigid/flex rules, the proviso enforces the typing discipline since each strict variable x must be strict in some premise. If instead y is the projected variable, the modified condition on y takes into account that the head of an application constitutes a strict occurrence; moreover, since y did occur, it is set to u in the rest of the computation, as there are no more requirements on that variable.

• The symmetric rules take the place of an explicit exchange rule that is problematic w.r.t. termination.

The following example illustrates how the Flex-Rigid rules, in this case ∩F R^{c}, make unification on simple terms finitary.

Example 4.24 Consider the unification problem

x:A ⊢ E x^{1} ∩ c (F x^{u})^{1} (F′ x^{u})^{1}

Since x is strict in the LHS, there are two ways in which Φ can be ‘split’ leading to the following sub-problems:

\begin{matrix}1. & x:A ⊢ E′ x^{1} ∩ F x^{u} ⇒ H x^{1} & x:A ⊢ E′′ x^{u} ∩ F′ x^{u} ⇒ H′ x^{u} \\ 2. & x:A ⊢ E′ x^{u} ∩ F x^{u} ⇒ H x^{u} & x:A ⊢ E′′ x^{1} ∩ F′ x^{u} ⇒ H′ x^{1} \end{matrix}

Hence the result:

x:A ⊢ E x^{1} ∩ c (F x^{u})^{1} (F′ x^{u})^{1} = {c (H x^{1})^{1} (H′ x^{u})^{1}, c (H x^{u})^{1} (H′ x^{1})^{1}}

Note that, similarly to complementation, intersection return a solution with some ‘overlapping’ possible; again it is possible, in a post-processing phase to make the result exclusive: for example the above problem can be made explicit in:

x:A ⊢ E x^{1} ∩ c (F x^{u})^{1} (F′ x^{u})^{1} =
{c (H x^{1})^{1} (H′ x^{0})^{1}, c (H x^{0})^{1} (H′ x^{1})^{1}, c (H x^{1})^{1} (H′ x^{1})^{1}}

However, differently from complementation, we must remark that the latter is not the most general solution w.r.t. the subsumption ordering on terms based on the (reverse) partial information ordering on labels. Indeed, a member of the intersection, e.g. c (H x^{1})^{1} (H′ x^{0})^{1} is a lower bound of both terms above, i.e.

c (H x^{1})^{1} (H′ x^{0})^{1} ≤ E x^{1}
c (H x^{1})^{1} (H′ x^{0})^{1} ≤ c (H x^{u})^{1} (H′ x^{u})^{1}

but it is not the greatest upper bound:

c (H x^{1})^{1} (H′ x^{0})^{1} ≤ c (H x^{1})^{1} (H′ x^{u})^{1}

The following example illustrates the additional proviso on ∩F R^{y}:

Example 4.25 The unification problem y:A ⊢ (E y^{0}) ∩ (y (F y^{u})^{1} (F′ y^{u})^{1}) has no solution, whereas y:A ⊢ (E y^{1}) ∩ (y (F y^{1})^{1} (F′ y^{0})^{1}) = {y (H y^{1})^{1} (H′ y^{0})^{1}}.

Lemma 4.26 Let M be a closed simple term such that Γ_{1}; Ω_{1}; Δ_{1} ⊢ M : A and Γ_{2}; Ω_{2}; Δ_{2} ⊢ M : A ; then Γ_{1}; Ω_{1}; Δ_{1} ⊢ M : A and Γ_{2}; Ω_{2}; Δ_{2} ⊢ M : A iff (Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : A.

Proof: (→) By induction on the size of (Γ_{1} ∪ Γ_{2}) \ (Γ_{1} ∩ Γ_{2}).

Base Let Γ_{1} = Γ_{2}, thus (Γ_{1} ∪ Γ_{2}) \ (Γ_{1} ∩ Γ_{2}) = ∅. Then by Exclusivity (Lemma 3.12) Ω_{1} = Ω_{2} and Δ_{1} = Δ_{2} and the claim holds.

Step Let Γ_{1} = (Γ′_{1}, x:C), where x ∉ dom(Γ_{2}). By Tightening (Lemma 4.5) either Γ′_{1}; (Ω_{1}, x:C); Δ_{1} ⊢ M : A or Γ′_{1}; Ω_{1}; (Δ_{1}, x:C) ⊢ M : A:

Subcase: Γ′_{1}; (Ω_{1}, x:C); Δ_{1} ⊢ M : A  By assumption
(Γ′_{1} ∩ Γ_{2}); (Ω_{1}, x:C, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : A  By IH
(Γ_{1} ∩ Γ_{2}); (Ω_{1}, x:C, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : A  x ∉ dom(Γ_{2})
(Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : A  x ∈ dom(Ω_{2}) by Lemma 3.12

Subcase: Γ′_{1}; Ω_{1}; (Δ_{1}, x:C) ⊢ M : A. Analogously.

(←)

(Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : A  By hypothesis
(Γ_{1} ∩ Γ_{2}, Ω_{2}); Ω_{1}; (Δ_{1}, Δ_{2}) ⊢ M : A  By Loosening^{0} on Ω_{2}
(Γ_{1} ∩ Γ_{2}, Ω_{2}, Δ_{2}); Ω_{1}; Δ_{1} ⊢ M : A  By Loosening^{1} on Δ_{2}
Γ_{1}; Ω_{1}; Δ_{1} ⊢ M : A  Since (Γ_{1} ∩ Γ_{2}), Ω_{2}, Δ_{2}, Ω_{1}, Δ_{1} = Γ_{1}, Ω_{1}, Δ_{1}
Γ_{2}; Ω_{2}; Δ_{2} ⊢ M : A  Analogously

□

We introduce two n-ary strict application rules, one which correspond to the imitation step and the other to projection, which will be needed in the proof of Theorem 4.33 and 4.34; in the following we shorten x ∈ dom(Γ) to x ∈ Γ.

(Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} 1 ≤ i ≤ n

→^{1} E_{n}^{c}

Γ; Ω; Δ ⊢ c M_{1}^{1} … M_{n}^{1} : B

where Γ; Ω; · ⊢ c : A_{1} →^{1} … →^{1} A_{n} →^{1} B and

1. ∀x ∈ Δ . ∃i : 1 ≤ i ≤ n . x ∈ Δ_{i}^{1}.

2. ∀i : 1 ≤ i ≤ n . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ.

(Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} 1 ≤ i ≤ n

→^{1} E_{n}^{y}

Γ; Ω; Δ ⊢ y M_{1}^{1} … M_{n}^{1} : B

where Γ_{0}; Ω; Δ_{0} ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B and

1. ∀x ∈ Δ, x ≠ y . ∃i : 1 ≤ i ≤ n . x ∈ Δ_{i}^{1}.

2. ∀i : 1 ≤ i ≤ n . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ.

3. Δ_{0} = {y} and ∀i : 1 ≤ i ≤ n. y ∈ Δ_{i}^{u}. Note that in the latter rule we consider only the case where y occurs strictly, that is Δ_{0} = {y}; indeed, if y ∈ Γ_{0}, then the rule is just a renaming of the previous rule →^{1} E_{n}^{c}.

We proceed to show that both are derivable and invertible rules. Lemma 4.27 Let Γ; Ω; · ⊢ c : A_{1} →^{1} … →^{1} A_{n} →^{1} B: if (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} for 1 ≤ i ≤ j, then

(Γ, Δ^{u}); Ω; Δ^{1} ⊢ c M_{1}^{1} … M_{j}^{1} : A_{j+1} →^{1} … →^{1} A_{n} →^{1} B, where

1. ∀x ∈ Δ^{1}.∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}.

1’. ∀x ∈ Δ^{u}.¬∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}.

2. ∀i : 1 ≤ i ≤ j . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ^{u} ∪ Δ^{1}. Proof: By induction on j. j = 0 Set Δ^{1} = ·; then by hypothesis and Weakening^{u} (Γ, Δ^{u}); Ω; · ⊢ c : A_{1} →^{1} … →^{1} A_{n} →^{1} B.

j + 1 (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i}, 1 ≤ i ≤ j  By assumption
(Γ, Δ^{u}); Ω; Δ^{1} ⊢ c M_{1}^{1} … M_{j}^{1} : A_{j+1} →^{1} … →^{1} A_{n} →^{1} B  By IH
(Γ, Δ_{j+1}^{u}); Ω; Δ_{j+1}^{1} ⊢ M_{j+1} : A_{j+1}  By hypothesis
(Γ, Δ_{+}^{u}); Ω; Δ_{+}^{1} ⊢ c M_{1}^{1} … M_{j+1}^{1} : A_{j+2} →^{1} … →^{1} A_{n} →^{1} B  By rule →^{1} E

such that:

Draft of July 6, 2000

(a) x ∈ Δ_{+}^{1} ↔ x ∈ Δ_{j+1}^{1} or x ∈ Δ^{1}.

(b) x ∈ Δ_{+}^{u} ↔ x ∈ Δ_{j+1}^{u} and x ∈ Δ^{u}. We now show that the last step satisfy the conditions in the claim.

1. x ∈ Δ_{+}^{1}  By assumption
x ∈ Δ_{j+1}^{1} ∪ Δ^{1}  By (a)

Subcase: x ∈ Δ_{j+1}^{1}

∃i:1 ≤ i ≤ j + 1 . x ∈ Δ_{i}^{1}

Subcase: x ∈ Δ^{1}

x ∈ Δ_{i}^{1}, for some 1 ≤ i ≤ j  By IH
∃i:1 ≤ i ≤ j + 1 . x ∈ Δ_{i}^{1}  A fortiori
1’. x ∈ Δ_{+}^{u}  By hypothesis
x ∈ Δ^{u}  By (b)
¬∃i:1 ≤ i ≤ j . x ∈ Δ_{i}^{1}  By IH
x ∈ Δ_{j+1}^{u}  By (b)
x ∉ Δ_{j+1}^{1}  By disjointness of contexts

¬∃i:1 ≤ i ≤ j + 1 . x ∈ Δ_{i}^{1}

2. ∀i:1 ≤ i ≤ j . Δ_{i}^{1} ∪ Δ_{i}^{u} = Δ^{1} ∪ Δ^{u}  By IH
Δ_{j+1}^{1} ∪ Δ_{j+1}^{u} = Δ^{1} ∪ Δ^{u}  By hypothesis
∀i:1 ≤ i ≤ j + 1 . Δ_{i}^{1} ∪ Δ_{i}^{u} = Δ_{+}^{1} ∪ Δ_{+}^{u}  By (a) and (b) and set manipulations
□

Lemma 4.28 Let Γ; Ω; · ⊢ c : A_{1} →^{1} … →^{1} A_{n} →^{1} B: if (Γ, Δ^{u}); Ω; Δ^{1} ⊢ c M_{1}^{1} … M_{j}^{1} : A_{j+1} →^{1} … →^{1} A_{n} →^{1}

B, then for every 1 ≤ i ≤ j there are Δ_{i}^{u}, Δ_{i}^{1} such that (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} and 1. ∀x ∈ Δ^{1}.∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}. 1’. ∀x ∈ Δ^{u}.¬∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}.

2. ∀i : 1 ≤ i ≤ j . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ^{u} ∪ Δ^{1}. Proof: By induction on j. j = 0 Set Δ^{1} = ·; then by hypothesis and Weakening^{u} (Γ, Δ^{u}); Ω; · ⊢ c : A_{1} →^{1} … →^{1} A_{n} →^{1} B.

j + 1 (Γ, Δ^{u}); Ω; Δ^{1} ⊢ c M_{1}^{1} … M_{j+1}^{1} : A_{j+2} →^{1} … →^{1} A_{n} →^{1} B  By assumption

(Γ, Δ_{+}^{u}); Ω; Δ_{+}^{1} ⊢ c M_{1}^{1} … M_{j}^{1} : A_{j+1} →^{1} … →^{1} A_{n} →^{1} B and

(Γ, Δ_{j+1}^{u}); Ω; Δ_{j+1}^{1} ⊢ M_{j+1} : A_{j+1}  By inversion on rule →^{1} E and

(x ∈ Δ_{+}^{1} ↔ x ∈ Δ_{j+1}^{1} ∨ x ∈ Δ^{1}) and (x ∈ Δ_{+}^{u} ↔ x ∈ Δ_{j+1}^{u} ∧ x ∈ Δ^{u})

(Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} for 1 ≤ i ≤ j  By IH

since the conditions on the claim are satisfied as in the above Lemma 4.27.

□

Corollary 4.29 Rule →^{1} E_{n}^{c} is derivable and invertible. Proof: For derivability, use Lemma 4.27 with j = n, Δ^{u} = ·, Δ^{1} = Δ; conditions 1. and 2. are immediately satisfied. Ditto w.r.t. invertibility, using Lemma 4.28. □ Lemma 4.30 Let Γ_{0}; Ω; y: … ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B. If (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} for 1 ≤ i ≤ j, then

(Γ, Δ^{u}); Ω; Δ^{1} ⊢ y M_{1}^{1} … M_{j}^{1} : A_{j+1} →^{1} … →^{1} A_{n} →^{1} B and

1. ∀x ∈ Δ^{1}.∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}.

Draft of July 6, 2000

1’. ∀x ∈ Δ^{u}.¬∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}.

2. ∀i : 1 ≤ i ≤ j . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ^{u} ∪ Δ^{1}. Proof: By induction on j. j = 0 Let Δ_{1} = {y} and weaken Γ_{0} to Γ, Δ^{u}; by hypothesis (Γ, Δ^{u}); Ω; Δ^{1} ⊢ yA_{1} →^{1} … →^{1} A_{n} →^{1} B. j + 1 Completely analogous to the same case in Lemma 4.27.

□

Lemma 4.31 Let Γ_{0}; Ω; y: … ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B: if (Γ, Δ^{u}); Ω; Δ^{1} ⊢ c M_{1}^{1} … M_{j}^{1} : A_{j+1} →^{1} … →^{1}

A_{n} →^{1} B, then for every 1 ≤ i ≤ j there are Δ_{i}^{u}, Δ_{i}^{1} such that (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} and 1. ∀x ∈ Δ^{1}.∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{1}. 1’. ∀x ∈ Δ^{1}.¬∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{u}.

2. ∀i : 1 ≤ i ≤ j . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ^{u} ∪ Δ^{1}. Proof: By induction on j similarly to Lemma 4.28. □ Corollary 4.32 Rule →^{1} E_{n}^{y} is derivable and invertible. Proof: As in Corollary 4.29, using Lemma 4.30 and 4.31. □

We are now ready to address soundness and completeness of intersection: Theorem 4.33 For any simple linear term N_{1} and N_{2} without shared variables such that Ψ ⊢ N_{1} : A and Ψ ⊢ N_{2} : A, if Ψ ⊢ M ∈ ∥N_{1}∥ : A and Ψ ⊢ M ∈ ∥N_{2}∥ : A, then there is N such that Ψ ⊢ N_{1} ∩ N_{2} ⇒ N : A and Ψ ⊢ M ∈ ∥N∥ : A. Proof: By simultaneous induction on the structure of D_{1} :: Ψ ⊢ M ∈ ∥N_{1}∥ : A and D_{2} :: Ψ ⊢ M ∈ ∥N_{2}∥ : A. Case: D_{1}, D_{2} end in grFlx; by Remark 4.22 and the left-to-right direction of Lemma 4.26. Case: D_{1} ends in grFlx and D_{2} ends in grApp: there are two cases depending whether the head of N_{2} is a

constant or a bound variable:

Imit Ψ ⊢ M ∈ ∥c \overline{Q_{n}^{1}}∥  By hypothesis
M ≡ c \overline{M_{n}^{1}} and D_{i}^{2} :: Ψ ⊢ M_{i} ∈ ∥Q_{i}∥ for all 1 ≤ i ≤ n  By sub-derivation
Ψ ⊢ c \overline{M_{n}^{1}} ∈ ∥E Φ∥  By hypothesis
c \overline{M_{n}^{1}} ↓ t Φ, where t ≡ λΦ . c \overline{t_{n}^{1}}  By sub-derivation
Γ; Ω; Δ ⊢ c \overline{t_{n}^{1}} : B  For Γ; Ω; Δ ⊢ Φ ok
(Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ t_{i} : A_{i}  For some Δ_{i}^{u}, Δ_{i}^{u} satisfying 1 and 2, by inversion on rule →^{1} E_{c}^{n}

(Corollary 4.29)

D_{i}^{1} :: Ψ ⊢ M_{i} ∈ ∥E_{i} Φ_{i}∥  By rule grFlx choosing Φ_{i} such that (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ Φ_{i} ok
D_{i} :: Ψ ⊢ E_{i} Φ_{i} ∩ Q_{i} ⇒ N_{i} for 1 ≤ i ≤ n and
Ψ ⊢ M_{i} ∈ ∥N_{i}∥  By IH on D_{i}^{1}, D_{i}^{2} since the proviso is satisfied
D :: Ψ ⊢ E Φ ∩ c \overline{Q_{n}^{1}} ⇒ c \overline{N_{n}^{1}}  By rule ∩F R^{c}
Ψ ⊢ c \overline{M_{n}^{1}} ∈ ∥c \overline{N_{n}^{1}}∥  By rule grApp

Proj Proceed as above, but using inversion on rule →^{1} E_{y}^{n}, i.e. Corollary 4.32. Case: D_{2} ends in grFlx and D_{1} ends in grApp: symmetrical to the above. Case: D_{1}, D_{2} end in grLam:

Draft of July 6, 2000

Ψ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. N_{1}∥  By hypothesis
D′_{1} :: Ψ, x:A ⊢ M ∈ ∥N_{1}∥  By sub-derivation
Ψ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. N_{2}∥  By hypothesis
D′_{2} :: Ψ, x:A ⊢ M ∈ ∥N_{2}∥  By sub-derivation
D′ :: Ψ, x:A ⊢ N_{1} ∩ N_{2} ⇒ N and Ψ, x:A ⊢ M ∈ ∥N∥  By IH on D′_{1}, D′_{2}
Ψ ⊢ λx^{u}:A. N_{1} ∩ λx^{u}:A. N_{2} ⇒ λx^{u}:A. N  By rule
Ψ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. N∥  By rule

Case: D_{1}, D_{2} end in grApp: a straightforward appeal to the inductive hypothesis as in the above case.

□

For the other direction, we are going to prove a stronger result:

Theorem 4.34 For any simple linear term N_{1} and N_{2} without shared variables such that Ψ ⊢ N_{1} : A and Ψ ⊢ N_{2} : A, for every N such that Ψ ⊢ N_{1} ∩ N_{2} ⇒ N if Ψ ⊢ M ∈ ∥N∥ : A, then Ψ ⊢ M ∈ ∥N_{1}∥ : A and Ψ ⊢ M ∈ ∥N_{2}∥ : A .

Proof: By induction on the structure of D :: Ψ ⊢ N_{1} ∩ N_{2} ⇒ N and inversion on D′ :: Ψ ⊢ M ∈ ∥N∥ : A.

Case: D ends in ∩F F; by Remark 4.22 and the right-to-left direction of Lemma 4.26.

Case: D ends in ∩F R.

D :: Ψ ⊢ E Φ ∩ c \overline{Q_{n}^{1}} ⇒ c \overline{N_{n}^{1}}  By hypothesis
D_{i} :: Ψ ⊢ E Φ_{i} ∩ Q_{i} ⇒ N_{i}, 1 ≤ i ≤ n  By sub-derivation
Ψ ⊢ c \overline{M_{n}^{1}} ∈ ∥c \overline{N_{n}^{1}}∥  By hypothesis
Ψ ⊢ M_{i} ∈ ∥N_{i}∥  By inversion
Ψ ⊢ M_{i} ∈ ∥Q_{i}∥ and Ψ ⊢ M_{i} ∈ ∥E_{i} Φ_{i}∥  By IH on D_{i}
M_{i} ↓ t Φ_{i}, where t ≡ λΦ_{i} . t_{i} such that (Ψ_{i}, D_{i}^{u}); Ω; Δ_{i}^{1} ⊢ t_{i} : A_{i} By rule grF lx for (Ψ_{i}, D_{i}^{u}); Ω; Δ_{i}^{1} ⊢ Φ_{i} ok
Γ; Ω; Δ ⊢ c \overline{t_{n}^{1}} : a  By rule →^{1} E_{c}^{n} (Lemma 4.27), since the proviso satisfies 1, 2
Ψ ⊢ c \overline{M_{n}^{1}} ∈ ∥E Φ∥  By rule grFlx
Ψ ⊢ c \overline{M_{n}^{1}} ∈ ∥c \overline{Q_{n}^{1}}∥  By rule grApp

Case: D ends in ∩F R^{y}. Proceed as above, but using Lemma 4.30.

Case: D ends in ∩L; by IH as in Theorem 4.33

Case: D ends in ∩RR; ditto.

□

Corollary 4.35 (Adequacy of Pattern Intersection) Fix a signature Σ. For every simple linear term N_{1} and N_{2} without shared variables such that Γ ⊢ N_{1} : A and Γ ⊢ N_{2} : A, for every M, Γ ⊢ M ∈ ∥N_{1}∥ : A and Γ ⊢ M ∈ ∥N_{2}∥ : A iff Γ ⊢ M ∈ ∥N_{1} ∩ N_{2}∥ : A.

Proof: From Theorem 4.33 and 4.34. □

4.4 The Algebra of Strict Terms

An interesting and natural question is wondering whether complementation is involutive. The answer is of course positive, since the latter is a boolean property and the complement operation has been shown to satisfy “tertium non datur” and the principle of non-contradiction. Rather than proving involution in isolation, we will show that every other boolean property is satisfied. As the complement of a term is possibly a finite set of terms we need to extend the intersection and complement operations to finite sets of terms. For the sake of readability, we shall define this the empty context. It is clear, although cumbersome, how to generalize it. We also drop the type information.

Definition 4.36 If M and N are finite sets of linear simple terms of type A, define:

M ⋂ N =^{def} {Q | Q ∈ M ∩ N, M ∈ M, N ∈ N }
Not(M) =^{def}  ⋂_{M∈M} Not(M)

Those operations on set of terms satisfy the same properties that ‘singleton’ intersection and complementation do.

Corollary 4.37 (Adequacy of Set Intersection) If N_{1}, N_{2} are finite sets of linear simple terms of type A, then Γ ⊢ M ∈ ∥N_{1}∥ : A and Γ ⊢ M ∈ ∥N_{2}∥ : A iff Γ ⊢ M ∈ ∥N_{1} ⋂ N_{2}∥ : A.

Proof: Γ ⊢ M ∈ ∥N_{1}∥ : A and Γ ⊢ M ∈ ∥N_{2}∥ : A iff there is N_{1} ∈ N_{1} and N_{2} ∈ N_{2} such that Γ ⊢ M ∈ ∥N_{1}∥ : A and Γ ⊢ M ∈ ∥N_{2}∥ : A iff, by Corollary 4.35, Γ ⊢ M ∈ ∥N_{1} ∩ N_{2}∥ : A iff, by definition, Γ ⊢ M ∈ ∥N_{1} ⋂ N_{2}∥ : A. □

Corollary 4.38 (Set Partition Lemma) Let N be a finite set of linear simple terms of type A:

1. (Disjointness) It is not the case that Γ ⊢ M ∈ ∥N ∥ : A and Γ ⊢ M ∈ ∥Not(N)∥ : A.

2. (Exhaustivity) Γ ⊢ M ∈ ∥N ∥ : A or Γ ⊢ M ∈ ∥Not(N)∥ : A.

Proof:

1. Assume Γ ⊢ M ∈ ∥N ∥ : A and Γ ⊢ M ∈ ∥Not(N)∥ : A. By rule gr_{i}, Γ ⊢ M ∈ ∥N∥ : A, for some N ∈ N. By definition, Γ ⊢ M ∈ ∥ ⋂_{N∈N} Not(N)∥ : A; by (repeated application of) Corollary 4.35 Γ ⊢ M ∈ ∥Not(N)∥ : A, for every N ∈ N, impossible by the Partition Lemma.

2. Similarly to the above.

□

It is therefore possible^{3}to organize the set of finite sets of simple terms over a given signature, call it T_{F} in a boolean algebra under set union, patterns intersection and complementation, by taking equality as extensional identity (on sets of ground terms), that is, in symbols:

N_{1} ≃ N_{2} iff ∥N_{1}∥ = ∥N_{2}∥

We now list some basic properties of intersection, which follows from Corollary 4.35 and will be useful next.

Corollary 4.39 Let M, N be simple linear terms of type A:

1. M ∩ M ≃ {M}.

2. M ∩ N ≃ Γ ⊢ N ∩ M.

Theorem 4.40 Consider the algebra of finite sets of simple terms ⟨T_{F} , ∅, ∪, ⋂, Not⟩ under set union, pattern intersection and complementation. Then the following holds:

1. M ⋂ M ≃ M.

2. M ⋂ N ≃ N ⋂ M.

3. M ⋂(N ∪ P) ≃ (M ⋂ N) ∪ (M ⋂ P).

4. M ⋂(N ⋂ P) ≃ (M ⋂ N) ⋂ P.

3FIXED 5. Not(Not(M)) ≃ M.

Draft of July 6, 2000

6. Not(T_{F}) ≃ ∅.

7. Not(∅) ≃ T_{F}. Proof: From Corollary 4.39, 4.37 and 4.38. □ Corollary 4.41 The algebra ⟨T_{F} , ∅, ∪, ⋂, Not⟩ of finite sets of simple linear terms is boolean. Proof: Theorem 4.40 confirms that the above operators satisfy the boolean algebra axioms. □

Corollary 4.41 guarantees that any other boolean operation is definable: indeed complementation and intersection alone allows to define the relative complement operation: Definition 4.42 Given M and N finite sets of terms of type A:

M − N =^{def} M ⋂(Not(N))

The adequacy of this encoding follows immediately from the Partition Lemma and soundness and completeness of intersection. Corollary 4.43 Γ ⊢ M ∈ ∥M∥ − ∥N ∥ iff Γ ⊢ M ∈ ∥M − N ∥ . Proof: Γ ⊢ M ∈ ∥M∥ − ∥N ∥ iff Γ ⊢ M ∈ ∥M∥ and Γ ⊢ M ∉ ∥N∥ for every N ∈ N iff (Corollary 4.38) Γ ⊢ M ∈ ∥M∥ and Γ ⊢ M ∈ ∥Not(N)∥ iff (Corollary 4.35) Γ ⊢ M ∈ ∥M ⋂(Not(N))∥ iff by definition Γ ⊢ M ∈ ∥M − N ∥. □

It is notable that the ∪ operator must be set-theoretic union rather than anti-unification or generalization, as traditional in lattice-theoretic investigations of the algebra of terms [Plo71]. The problem is the intrinsic classical nature of complementation which is not compatible with the very irregular structure of the lattice of terms where anti-unification is interpreted as the lowest upper bound. Indeed, De Morgan’s rules would fail, namely, denoting anti-unification with ‘∨′:

Not(s(0) ∨ s(s(0))) = Not(s(X)) = 0 ≠ Not(s(0)) ∩ Not(s(s(0))) = {0, s(s(s(X)))}

We end this chapter with a preview of how term complement will be used as a building block of the clause complement algorithm. Example 4.44 We can combine Example 2.6 and 2.8:

Not{(app (lam (λx^{u}:exp. E x^{u})) F), lam(λx^{u}:exp. app (E x^{o}) x)} = Not(app (lam (λx^{u}:exp. E x^{u})) F) ⋂ Not(lam(λx^{u}:exp. app (E x^{0}) x)) =

{lam (λx^{u}:exp. (H x^{u})),

app (app H H′) H′′} ⋂

{lam(λx^{u}:exp. app (H x^{1}) (H′ x^{u})),

lam(λx^{u}:exp. app (H x^{u}) (app (H′ x^{u}) (H′′x^{u}))), lam(λx^{u}:exp. app (H x^{u}) (lam(λy^{u}:exp. H′ x^{u} y^{u}))), lam(λx^{u}:exp. lam(λy^{u}:exp. H x^{u} y^{u})), lam(λx^{u}:exp. x), app H H′} =

{lam(λx^{u}:exp. app (H x^{1}) (H′ x^{u})),

lam(λx^{u}:exp. app (H x^{u}) (app (H′ x^{u}) (H′′ x^{u}))), lam(λx^{u}:exp. app (H x^{u}) (lam(λy^{u}:exp. H′ x^{u} y^{u})))

lam(λx^{u}:exp. lam(λy^{u}:exp. H′ x^{u} y^{u})),
lam(λx^{u}:exp. x),
app (app H H′) H′′}

Draft of July 6, 2000

Thus given the ‘program’:

\begin{aligned}betarx & : & isredx(app (lam (λx^{u}:exp. E x^{u})) F). \\ etarx & : & isredx(lam(λx^{u}:exp. app (E x^{0}) x)). \end{aligned}

Computing the complement of each head as in Example 4.44 yields the complementary program:

\begin{aligned}nb1 & : & non isredx(lam(λx^{u}:exp. app (H x^{1}) (H′ x^{u}))). \\ nb2 & : & non isredx(lam(λx^{u}:exp. app (H x^{u}) (app (H′ x^{u}) (H′′ x^{u})))). \\ nb3 & : & non isredx(lam(λx^{u}:exp. app (H x^{u}) (lam(λy^{u}:exp. H′ x^{u} y^{u})))). \\ nb4 & : & non isredx(lam(λx^{u}:exp. lam(λy^{u}:exp. H x^{u} y^{u}))). \\ nbr & : & non isredx(lam(λx^{u}:exp. x)). \\ nb6 & : & non isredx(app (app H H′) H′′ ). \end{aligned}

4.5 Summary

In this part of the dissertation, we have been concerned with the relative complement problem in a setting where patterns may contain binding operators, so-called higher-order patterns. Higher-order patterns inherit many pleasant properties from the first-order case, even for complex type theories. Unfortunately, the complement operation does not generalize as smoothly. The complement of a partially applied higher-order pattern cannot be described by a pattern, or even a by finite set of patterns. The formulation of the problem suggests that we should consider a λ-calculus with an internal notion of strictness so that we can directly express that a term must depend on a given variable. For reasons of symmetry and elegance we have also added the dual concept of invariance expressing that a given term does not depend on a given variable. We have developed such a calculus, so that we can show that for a suitable embedding in our calculus simply-typed patterns have the following properties:

1. The complement of a linear pattern is a finite set of linear patterns.

2. Unification of two patterns is decidable and leads to a finite set of most general unifiers.

Consequently, finite sets of linear patterns in the strict λ-calculus are closed under complement and unification. If we think of finite sets of linear patterns as representing the set of all their ground instances, then they form a boolean algebra under simple union, intersection (implemented via unification) and the complement operation.

Elimination of Negation in Clauses

The transformational approach to negation in normal programs has a somewhat long history, see [Nai86] for a survey of the early 80’s. The idea was to implement negation using inequalities, so that the complement of any predicate occurring negatively in a program is synthesized to obtain an equivalent definite program. This was first proposed in [ST84].

5.1 The Completion

At the risk of being trivial, let us start by asking naively what the complement of a program should be; if we see the latter as a set of (possibly mutually recursive) predicate definitions, its negation would be the set of the negation of those definitions. Thus, let us concentrate on a program definition as our target and consider the simplest case, i.e. that of a single clause q(0) on the signature of numerals. Our first instinct would be to use the Not algorithm and by computing Not(0) = s(X) assert ∀X:nat. ¬q(s(X)); this is indeed the right thing to do, but we need to justify it formally. We can look at the definition q(0) as a degenerate case (that is with trivial condition) of inductive definition; an equivalent formulation would be:

∀X:nat. q(X) ← X =^{·} 0.

for an object-logic equality symbol ‘=^{·}’, which simply expresses the condition X =^{·} 0 for atoms to be in the inductive definition of q. The next step is to enforce the minimality condition by saying that the latter is the only way to belong to the definition. One way to achieve that is by exchanging the ← connective into a biconditional ↔:

∀X:nat. q(X) ↔ X =^{·} 0.

This is in a nutshell Clark’s very fortunate idea of the completion of a program [Cla78]. What is left is describing how to interpret the equality relation; this is accomplished by the so-called Clark’s equality theory, that is the axioms of free equality: namely, the usual equality axioms including congruence, plus the axioms for finite trees. Indeed, this theory is the axiomatic and proof-theoretic rendering of the unification algorithm, for a proof see for example Stärk’s thesis [Stä92]. For instance, the following is free equality over numerals:

(Dec) : ∀x, y : s(x) = s(y) → x = y
(Clh) : ∀x : 0 ≠ s(x)
(Ock) : ∀x : x ≠ t[x]  if x occurs properly in t[x]
(DCA) : ∀x : x = 0 ∨ ∃y : x = s(y)

The last axiom is the Domain Closure Axiom [MMP88], which is required to give a complete axiomatization of finite trees over finite signatures. Since we will not consider unification so far, we will keep this relation uninterpreted; thus those axioms do not play any role, which is handy, as it allows us to dispense with the issue of the compatibility of DCA with dynamic extensions on the signature.

∀x . even(x) ↔ x = 0 ∨ ∃y . x = s(s(y)) ∧ even(y)

⇝_{cp}

∀x . ¬even(x) ↔ ¬(x = 0 ∨ ∃y . x = s(s(y)) ∧ even(y)) ⇝_{nnf}

∀x . ¬even(x) ↔ x ≠^{·} 0 ∧ (∀y . x ≠^{·} s(s(y)) ∨ ¬even(y))

⇝_{lift}

∀x . ¬even(x) ↔ x ≠^{·} 0 ∧ ∀y . x ≠^{·} s(s(y)) ∨ (∃y . x = s(s(y)) ∧ ¬even(y))

⇝_{dnf}

∀x . ¬even(x) ↔ (x ≠^{·} 0 ∧ ∀y . x ≠^{·} s(s(y))) ∨ (x ≠^{·} 0 ∧ ∃y . x = s(s(y)) ∧ ¬even(y))

⇝_{disunify(x≠^{·}0∧∀y:x≠^{·}s(s(y)))}

∀x . ¬even(x) ↔ x = s(0) ∨ (x ≠^{·} 0 ∧ ∃y . x = s(s(y)) ∧ ¬even(y))

⇝_{disunify(x≠^{·}0∧∃y:x=s(s(y)))}

∀x . ¬even(x) ↔ x = s(0) ∨ (∃y . x = s(s(y)) ∧ ¬even(y)) ⇝_{prettyp}

\begin{matrix}odd(s(0)). \\ odd(s(s(Y))) ← odd(Y). \end{matrix}

Figure 5.1: Synthesis of the predicate odd

Of course, definitions are usually more interesting than a simple clause, so let’s step to next simplest example, even numbers:

\begin{matrix}even(0). \\ even(s(s(Y))) ← even(Y). \end{matrix}

To turn this code into a minimal inductive definition, we need to normalize the conjunction of clauses, a process described for example in [AB94]. The net result is the axiom:

∀x.even(x) ↔ x = 0 ∨ ∃y.x = ss(y) ∧ even(y)

One way to obtain the complement definition, that is odd, would be to reason classically on the completed program by taking the contrapositive of the completion. Let me offer the following rational reconstruction. We may use rewrite rules to achieve conversion into negation normal form (nnf) and into disjunctive normal form (dnf), plus some more massage to preserve the original positive bindings in clauses. Once this is done, we need a way to solve the possibly universally quantified dis-equalities we have created. A call of the disunification algorithm described in Section 2.2 (disunify(…)) is enough to obtain a solved form, from which we can recover the intended negated program. This is best explained in Figure 5.1, which uses the subcomputation of ∀y : z ≠^{·} 0 ∧ z ≠^{·} s(s(y)), detailed in Example 2.2.

Following this drift, an extensive project started in Pisa under the name of intensional negation [BMPT87, MMP88, BMPT90, ABT90, MPRT90b, FBM93]. In particular [BMPT90] computes the set-theoretic complement of the terms in the negative predicate compiling away the inequalities. The authors restrict to a class of left-linear non-stratified program called flat, where all predicates are defined by a single clause (and hence we have no disjunction in the completion) and such that if a head contains non-variable terms, the body must be a single literal. With some painful source-to-source transformations, programs can be turned in and out of this format. Thanks to this, the transformation of the completion delineated above yields only disequation of the form x ≠^{·} t, which the Not algorithm can solve.

If we discard for the moment the problematic issue of local variables, i.e. variables that appear in the body but not in the head of a clause (as they turn out to become universally quantified in an extensional sense during the completion transformation), this seems at first sight fairly convincing. On the other hand, managing control of disunification and rewrite rules requires some ingenuity as the following example shows:

Example 5.1 Consider the usual program for membership in lists:

\begin{matrix}member(X, X.XS). \\ member(X, Y.Y S) ← member(X, Y S). \end{matrix}

Its completion is

∀z, zs(member(z, zs) ↔ ∃x, xs(zs = x.xs ∧ z = x) ∨
∃x, y, ys(zs = y.ys ∧ z = x ∧ member(x, ys)))

The synthesis of its negation is depicted in Figure 5.2. Not only disunification is more complex, as there are a few choices of variables where the Explosion rule can be applied, but propositional transformations are difficult to direct as well.

Working with flat programs is not a real alternative, since some form of partial evaluation is needed to recover some structure in the target program. In fact, the more mature version presented in [FBM93] embraces the constraint logic programming approach. We will instead give a completely deterministic algorithm to compute the negation of programs. This is based on solving the relative complement problem by pairing term complement with unification and is proven correct by Corollary 4.41; that is, we do not need full disunification as we can solve, for example x ≠^{·} 0 ∧ ∀y : x ≠^{·} s(s(y)) by computing Not(0) ∩ Not(s(s(Y)).

There is one further, more basic difficulty with the completion-based approaches; they use transformations that are intrinsically classical and turn out to preserve the operational semantics, only because in Horn logic classical and intuitionistic provability coincide. We discuss this issue further in Section 5.3. We will instead lift the boolean operations we have introduced on (simple) terms to clauses (programs) and we shall prove that they still satisfies the usual boolean rules; in particular we will verify that clause complementation fulfills exclusivity and exhaustivity. This high-level ‘boolean’ language will eventually be compiled into a version of HHF that is amenable of a complete uniform proof search strategy. We offer an informal discussion next (Section 5.2).

5.2 Introduction to HHF Complementation

Consider the following judgment to check whether a lambda terms is linear^{1}, if every functional subterm uses each of its arguments exactly once:

e_{1} linear e_{2} linear
linear·
(e_{1} e_{2}) linear

Λx . e linear in x  \frac{u}{x linear} ; ⋮ ; e linear

linearλ^{x,u}
Λx . e linear

\frac{λ}{Λx . x linear in x}

Λx . e linear in x

λ^{y}

Λx . Λy . e linear in x

Λx . e_{1} linear in x
1·
Λx . (e_{1} e_{2}) linear in x

Λx . e_{2} linear in x

2·

Λx . (e_{1} e_{2}) linear in x comp(member) ⇝_{cp}

1Do not confuse this notion with the one which refers to a term not having repeated occurrences of the same existential variable.

Draft of July 6, 2000

∀z, zs(¬member(z, zs) ↔  ∀x, xs(zs ≠^{·} x.xs ∨ z ≠^{·} x) ∧

∀x, y, ys(zs ≠^{·} y.ys ∨ z ≠^{·} x ∨ ¬member(x, ys))

⇝_{lift}

∀z, zs(¬member(z, zs) ↔  ∀x, xs(zs ≠^{·} x.xs ∨ z ≠^{·} x) ∧

∀x, y, ys(zs ≠^{·} y.ys ∨ z ≠^{·} x) ∨

∃x, y, ys . (zs = y.ys ∨ z = x) ∧ ¬member(x, ys)

⇝_{dnf}

∀z, zs(¬member(z, zs) ↔  (d1) ∀x, y, xs, ys . (zs ≠^{·} x.xs ∨ z ≠^{·} x) ∧ (zs ≠^{·} y.ys ∨ z ≠^{·} x)

(d2) ∀x, xs, (zs ≠^{·} x.xs ∨ z ≠^{·} x) ∧

∃x, y, ys . (zs = y.ys ∧ z = x) ∧ ¬member(x, ys)

(d1) ⟼_{E+R(zs=nil)(1.1)}

(d1.1) ∀(nil ≠^{·} x.xs ∨ z ≠^{·} x) ∧ (nil ≠^{·} y.ys ∨ z ≠^{·} x) ∧ zs = nil

⟼_{Cl(T)^{∗}}

zs = nil

⇝_{prettyp}

                              nonmember(X, nil)

(d1) ⟼_{E+R(zs=w.ws)(1.2)}

(d1.2) ∃w, ws∀x, y, xs, ys.(w.ws ≠^{·} x.xs ∨ z ≠^{·} x) ∧

(w.ws ≠^{·} y.ys ∨ z ≠^{·} x) ∧ zs = w.ws

⟼_{UE2(x,y,xs,ys)}^{∗}

∃w(w ≠ z)

⇝_{prettyp}

⟨⟩

(d2) ⇝_{disunify(∀x,xs(zs≠^{·}x.xs∨z≠^{·}x))}

⟼_{UE2(x,y,xs,ys)}^{∗}

x ≠ y ∧ ∃y, ys . zs = y.ys ∧ z = x

⟼_{norm}

∃y, ys(zs = y.ys ∧ z ≠ x)

⇝_{prettyp}

nonmember(X, Y.Y S) ← X ≠ Y, nonmember(X, Y S).

Figure 5.2: Synthesis of the nonmember predicate

Intuitively, we check for linearity of a function making sure that the it is linear in its first argument (judgment ‘Λx . e linear in x’) and then recurring on the rest of the expression. Note the rule ‘ linearλ^{x,u}’ is hypothetical in u and parametric in x; rule λ^{y} is instead only parametric in x.

Frameworks based on HHF provide an ideal syntax to represent these judgments; namely, via the usual encoding introduced in Example 2.6:

Example 5.2

linlam : linear(lam λx . E x)
← linx(λx . E x)
← (∀x:exp. linear(x) → linear(E x)).
linapp : linear(app E_{1} E_{2})
← linear(E_{1})
← linear(E_{2}).
linxx : linx(λx . x).
linxap1 : linx(λx . app (E_{1} x) E_{2})
← linx(λx . E_{1} x).
linxap2 : linx(λx . app E_{1} (E_{2} x))
← linx(λx . E_{2} x).
linxlm : linx(λx . lam(λy . E x y))
← (∀y:exp. linx(λx . E x y)).

The judgment and its implementation is clearly a decision procedure. It does make sense to ask ourselves what is its complement. An expression is not linear if there is some function which either does not use its argument or uses it more than once. We first observe that, since linear is a relation defined via exhaustive and exclusive patterns term complementation does not play a role. Then, the complement of linapp does not pose any problem, as it is a Horn clause: an application in not linear if either the first element or the second in not linear.

¬linapp : ¬linear(app E_{1} E_{2})
← ¬linear(E_{1}) ∨ ¬linear(E_{2}).

A lambda expression in not linear in two cases: first it is not linear in its first argument:

¬linlam1 : ¬linear(lam(λx . E x))
← ¬linx(λx . E x).

Secondly, if its body is not linear. Now, this poses new problems, as we have to negate a hypothetical and parametric clause. Let us follow our nose and reason by example: suppose we are given, in the empty context a goal linear(lam(λx . lam(λy . x))), which is unprovable, since the second lambda term is not linear in y; the proof tree yields the failure leaf linx(λx . z), for a new parameter z, in the context z:exp; linear(z). Our guiding intuition is that we want to mimic a failure derivation so as to provide a successful derivation from the negative definition, i.e. a proof of ¬linx(λx . z) from z:exp; linear(z); this shows one prominent feature of complementation of an HHF formula: negation ‘skips’ over ∀ and →, since it needs to mirror failure from assumptions.

Let us turn to complementing the judgment ‘ linear in x’. A first point to note in that, by encoding an object expression ‘e’ with a pattern variable, we must make sure that in clause linxap1,linxap2 the variable x does not occur in the argument which is not checked. We thus embed the clause in the strict λ-calculus and ‘E’ in the simple term ‘E x^{0}’. For the sake of readability we do this only for the two aforementioned clause and we also hide ()^{u} annotations.

linxap1 : linx(λx . app (E_{1} x) (E_{2} x^{0}))
← linx(λx . E_{1} x).
linxap2 : linx(λx . app (E_{1} x^{0}) (E_{2} x))
← linx(λx . E_{2} x).

Via term complementation and intersection in the strict λ-calculus we obtain, among others:

¬linxap0 : ¬linx(λx . app (E_{1} x^{1}) (E_{2} x^{1})).

Moreover, as in the case of top-level application, the complement of linxap_{i} holds if the body does not hold:

¬linxap1 : ¬linx(λx . app (E_{1} x) (E_{2} x^{0}))
← ¬linx(λx . E_{1} x)
¬linxap2 : ¬linx(λx . app (E_{1} x^{0}) (E_{2} x))
← ¬linx(λx . E_{2} x).

Now, let us examine clause linxlm and let us reconsider the failure leaf linx(λx . z) from the context z:exp; linear(z). In a first attempt, let us consider what the complement would be according to the idea above:

¬^{?} linxlm : ¬linx(λx . lam(λy . E x y))
← (∀y:exp. ¬linx(λx . E x y)).

However, there is no way to obtain a proof of ¬linx(λx . z) from the current context. Indeed, the linxlm clause does not carry enough information by itself so that its complement can mimic the failure proof. In a sense that we will make precise, the clause, and in turn its predicate definition is not assumption-complete: once it has introduced a new parameter, the clause only specifies how to use it in a positive context. It is up to us to synthesize its dynamic negative definition, in this case exactly ¬linx(λx . z). More generally, it is a characteristic of HHF that the negation of a clause is not enough to determine the behavior of a program under complementation. We will have to insert (via a source-to-source transformation) additional structure in a predicate definition in order to completely determine the provability and failure of goals which mention parameters. By observing the structure of all possible assumption that a predicate definition can make, we will augment those assumptions with their negative definition. In particular, we first augment the clause

linxlm:

aug_{D}(linxlm) : linx(λx . lam(λy . E x y))
← (∀y:exp. ¬linx(λx . y) → linx(λx . E x y)).

so that, by complementation, we obtain

¬aug_{D}(linxlm) : ¬linx(λx . lam(λy . E x y))
← (∀y:exp. ¬linx(λx . y) → ¬linx(λx . E x y)).

Moreover, we need to do the same with the linlam clause, since the linx predicate may occur as a subgoal:

aug_{D}(linlam) : linear(lam(λx . E x))
← linx(λx . E x)
← (∀x:exp. (¬linx(λy . x) ∧ linear(x)) → ¬linear(E x)).

In summary the negative program is:

¬linapp : ¬linear(app E_{1} E_{2})
← ¬linear(E_{1}) ∨ ¬linear(E_{2}).
¬linlam1 : ¬linear(lam(λx . E x))
← ¬linx(λx . E x)
∨ (∀x:exp. (¬linx(λy . x) ∧ linear(x)) → ¬linear(E x)).

¬linxap0 : ¬linx(λx . app (E_{1} x^{1}) (E_{2} x^{1})).
¬linxap1 : ¬linx(λx . app (E_{1} x) (E_{2} x^{0}))
← ¬linx(λx . E_{1} x).
¬linxap2 : ¬linx(λx . app (E_{1} x^{0}) (E_{2} x))
← ¬linx(λx . E_{2} x).
¬linxap3 : ¬linx(λx . app (E_{1} x) (E_{2} x)) ← ¬linx(λx . E_{1} x) ∧ ¬linx(λx . E_{2} x).
¬linxlm : ¬linx(λx . lam(λy . E x y))
← (∀y:exp. ¬linx(λx . y) → ¬linx(λx . E x y)).

While it is not impossible^{2} to manually come up with this program by writing predicate definitions formalizing when terms are strict (that is, variable arguments occur at least once) and vacuous(that is, arguments are guaranteed not to occur) and then by merging them in the correct fashion, it would be better to have this done automatically, especially considering changes or extensions of the original program.

Unfortunately the procedure we have outlined is not possible in general. Consider a clause encoding the introduction rule for implication in natural deduction, which can be used to check whether an implicational formula trivially holds:

Example 5.3

form : type
imp : form → form → form
a : form
b : form
impi : nd(A imp B) ← (nd(A) → nd(B)).

Following our earlier remark its complement would be:

¬impi1 : ¬nd(a)
¬impi2 : ¬nd(b)
¬^{?} impi : ¬nd(A imp B) ← (nd(A) → ¬nd(B)).

Apparently, this specification is incorrect since both nd(a imp a) and ¬nd(a imp a) are derivable from the empty context. We can isolate one major problem: in clause impi, the assumption nd(A) that is dynamically added to the (static) definition of the nd predicate overlaps with the head of the clause. A symmetrical problem can occur when dynamic and static clauses do differ but their complements do not. Suppose we introduce a predicate which checks if a number is even and non zero as follows:

e : ev(s(s(N))) ← (ev(0) → ev(N)).

Again, our naive algorithm would incorrectly yield:

¬e1 : ¬ev(0).
¬e2 : ¬ev(s(0)).
¬^{?} e : ¬ev(s(s(N))) ← (∀M:nat. ¬ev(s(M)) → ¬ev(N)).

2For what is worth, the first three versions of such a program I wrote were mistaken.

Draft of July 6, 2000

Thus both ev(s(s(0))) and ¬ev(s(s(0))) are incorrectly provable. The problem here is the overlapping between the of assumption ev(0) and the complement of the head of the e clause.

We have thus isolated two main issues:

1. Exhaustivity: we need to enrich clauses so that every (ground) goal or its negation is provable.

2. Exclusivity: we need to isolate a significant fragment where it is not the case that both a goal and its negation are provable.

We will describe in Section 6.6 a procedure that we call augmentation, which, by enriching the program with the complement of assumptions will, will achieve exhaustivity (Section 6.8); moreover, we will achieve exclusivity with the restriction to complementable programs, formally introduced in Figure 6.7. To anticipate the idea, a clause is complementable if every assumption is parametric in some eigenvariable. We will try to motivate in Section 5.4 why this fragment is adequate to the practice of logical frameworks. Section 5.5 reviews some related work in the area of NF and embedded implication.

5.3 Background

Traditionally, a completion construction for the NF rule is an extension of a program, say E(P) such that, in a logic L equipped with a provability and finite failure relation, say ⊢_{L} and ⊣⊢_{L} and a negation sign ¬, for any given goal G and a consequence relation ⊧_{L}, (ideally) it holds:

1. ⊢_{L} G iff E(P) ⊧_{L} G.

2. ⊣⊢_{L} G iff E(P) ⊧_{L} ¬G .

Many such constructions have been proposed for Horn logic, starting from the Closed World Assumption (CWA) [Rei78]. The Clark completion [Cla78] is perhaps the most successful proof-theoretic and finitary explanation of NF : the main idea is that clauses in a predicate definition should be seen as an iff-definition, thus enforcing the minimality condition of its inductive definition; this would correspond, in model-theoretic terms, to the existence of a least intended model. The if-part states the condition to belong to the inductive definition, while the only-if part excludes everything else, thus providing a computable approximation to the CWA. This is well understood and agreed as far as Horn logic is concerned and confirmed by the completeness of finite failure w.r.t. the completion [Apt90].

As observed first by Gabbay [Gab85], the positive logic of embedded implication is not classical but intuitionistic (actually minimal). When coupled with negation as failure in all its generality, its meta-logic fails to have some straightforward logic properties, as detailed in Section 5.5. The key difference lies in the constructive interpretation of implication and its delicate interplay with negation. While a completion construction is possible, it is not equivalent to the adjoining of the only-if part of the program. This is intrinsically due not only to the non-monotonic nature of such definitions, but also to the operational semantic of failure: a goal D → G fails iff from the (scoped) assumption D we have that G fails. Let us try to mirror this with a logical connective:

¬(D → G) =^{?} D → ¬G

Similarly for parametric judgments:

¬(∀x:A. G) =^{?} ∀x:A. ¬G

No standard logic of negation satisfies the above rules. In particular, it is erroneous to formulate Clark’s completion using Nelson’s strong negation [Nel49], which is currently held as the meta-logic of negation elimination in the Horn setting [GL90, Pea90]. Indeed, strong negation brings too much duality to intuitionistic logic as it is pushed in through connectives and quantifiers; in particular if ∼ denotes strong negation the following holds:

∼ (D → G) ↔ D∧ ∼ G
∼ (∀x:A. G) ↔ ∃x:A. ∼ G

Strong negation may be “the logic of information structures” [Wan93], as far as Horn logic is concerned, but it is definitely not the meta-logic of negation elimination in logical frameworks based on HHF. It is not simply a question to endow intuitionism with a semi-classical notion of negation, while preserving the disjunction and existential property. The hard point is not negation in itself, but its interaction with a more operational Brower-Heyting-Kolmogorov interpretation of implication.

Example 5.4 Consider the program consisting only of the clause a ← (b → c); the standard completion would be

a ↔ (b → c) ∧ ¬b ∧ ¬c.

Now, ‘a’ fails and hence ‘¬a’ should follow from the iff-completion: still ‘a’ intuitionisticallly (yet not minimally) follows, while ‘¬a’ is logically independent exactly due to the failure of Equation (5.1).

We explore in Section 5.5 how this issue has been investigated in the literature. This is relevant to our enterprise because:

• In the Horn setting, the iff-completion has been the preferred way to logically motivate the transformational approach to negation, as we have seen in Section 5.1.

• In [GO98] the authors persuasively argue that the unrestricted addition of NF to languages such as N-Prolog requires the switch to a (three-valued) modal logic.

Since we need to express the negation of a predicate in the same language where the predicate is formulated, we choose to restrict the set of programs we deem complementable in a novel and extensive way. This will help to close the gap between the two poles usually associated to classic and intuitionistic logic programming, i.e. the closed versus open world assumption. We will define a class of programs which extend the current database in a specific regular way, by ensuring that static and dynamic clauses never overlap. This property extends w.r.t. the complement program and thus has the side effect of guaranteeing the consistency of the completion. Finally we will require every goal to conform to such a schema context. We call this approach the Regular World Assumption (RWA). We argue next (Section 5.4) that this class of programs is just what the doctor ordered for logical frameworks.

5.4 Motivation

Embedded implication in intuitionistic logic programming has been successfully used in various areas of logic programming; we can roughly divide those into:

• Meta-programming, namely specifying and implementing (the meta-theory of) deductive systems.

• Hypothetical reasoning in databases [GR84, BMV89, Bon94] or simulating imperative-style programming [BM90].

• Incorporating modules and local predicate definitions [Mil89c, GMR92, KNW93] and state encapsulation in object-oriented programming [HM90].

We now try to motivate why the restriction of complementation to parametric implication (formally defined in Section 6.5) is pragmatically adequate for our intended application.

While implementing deductive systems embedded implication is usually coupled with higher-order abstract syntax to represent scoping constructs: the latter are typically used to traverse operators like abstractions, quantification and, more pervasively, to represent rules with hypothetical premises. In this application implications are typically ‘covered’ by an intensional universal quantifier which express the parametricity of the assumption. Dozens of examples can be found for instance in [Pfe92]. One counter-example I am aware of is when using a logic framework to encode derivability in an object logic: here meta-logic contexts are used to manage object logic hypotheses, as in Example 5.1. We feel that this case in not typical; first of all it is questionable (and out of the scope of a logical framework) to complement recursive enumerable predicates such as general provability. Even if we limit ourselves to decision procedures as propositional logic, we are in a sense asking for a self-referential use of implication as we wish to represent implications in the object logic with the same in the meta-logic. In this case, though we have no formal proof of this, we think we have to use ad hoc techniques such as explicit management of hypotheses say as lists; a similar approach is taken in [DM97].

Modules are usually closed assumptions and I doubt negation is useful at this level. Local definitions, as an auxiliary reverse3 procedure hidden inside the naive reverse procedure are typical only in higher-order logic programming languages as λProlog, and require full predicate quantification. We conjecture that some of those programs can be complemented if there is no overlap between static and dynamic clauses. As far as object-oriented programming is concerned, more recent research [BDLM00] has now moved on to linear logic programming languages.

The possibility to simulate the availability of global variables in logic programming has been advocated [GO98] as the main motivation of the intertwined and unrestricted use of negation and embedded implication. We contend that sometimes that can be resolved with a refined notion of context as the one available in linear logic programming: this has also the side-effect of by-passing the issue of non-stratification.

We now exemplify how to eliminate negation from non-stratified N-Prolog programs. We cannot say at the moment whether this transformation can be generalized and eventually mechanized. The following example (taken from [GO98]) is a non-stratified program to compute the parity of a relation encoded as n entries of the form r(X), where ‘\+’ denotes negation-as-failure:

Example 5.5 (Parity)

\begin{matrix}even ← \+ odd. \\ odd ← r(X), \+ mark(X), (mark(X) → even). \end{matrix}

We can write a Lolli program [HM94] based on the same algorithm, where the linear context contains the entries of the relation and the initial token off; let −∘ and ⊗ denote linear implication and conjunction:

even ∘− r(X) ⊗ off ⊗ (on −∘ odd).
even ∘− off.
odd ∘− r(X) ⊗ on ⊗ (off −∘ even).
odd ∘− on.

The tensors consume the relation and turn on or off the switch accordingly to the parity of the relation.

We can make a similar remark about the relative pronoun gap parsing example in Categorical Grammars [PM90] which in [BM90] is treated with intuitionistic implication plus NF . Hodas [Hod94] has shown how this can be dealt with much more elegantly again with linear implication.

5.5 Related Work

In the 90’s there has been some interest in combining NF with what is known as intuitionistic logic programming. The underlying languages, with the exception of [Har93], are either versions of N-Prolog or clausal intuitionistic logic. Due to the inherently difficulty with universal quantification mentioned in Subsection 1.5.2, the treatment is deprived of parametric goals. The emphasis is not on the transformational approach but to combine the non-monotonic nature of NF with the capability of embedded implication to dynamically update the current program. We will not detail here the proposed semantics (stable models [Dun92], monotonic Kripke-like models [Har89], non-monotonic perfect [BM90] or three-valued [GO98] models).

Gabbay [Gab85] pointed out that NF coupled with embedded implication seems to lead to curious paradoxes, at the point of making the whole enterprise not logically sound. This problem arises already when dealing with (propositional) normal clauses. They can be summarized as follows (taken from [NL92]).

1. Failure of transitivity, or, in other words, non-eliminability of the cut rule. Let P be:

\begin{matrix}a ← b ∧ \+ c. \\ b ← c. \end{matrix}

Now, P ⊢ c → b and P ⊢ b → a, as c is undefined, but c → a is not provable from P.

2. Failure of weakening. Let P be:

b ← \+ a.

Then P ⊢ b but a → b is not provable from P.

3. “Pathology of negative information”, i.e. P ⊢ \+ (A → B) iff P ⊢ A → \+ B.

There are several solutions to this riddle:

• A modal completion [GO98].

• A syntactic distinction between implications [BM90].

• A syntactic distinction between predicates [Har93].

We detail the latter next, but let us state, for the record, our position:

1. Provability must take into account the context where the query is attempted: in case 1. the first query is not allowed, since b is a predicate which must be called from an empty context.

2. Similarly, a → b is not a legitimate query as b must be queried in the empty context.

3. This is indeed the operational semantics of failure of hypothetical judgments; the issue is giving a logical justification of that and the challenge is to give it without changing the logic underneath.

5.5.1 NF in Clausal Intuitionistic Logic

We can regard Clausal Intuitionistic Logic as a close cousin of uniform proofs independently developed by McCarthy in the late eighties [McC88a, McC88b]. NF in this setting has been investigated in Bonner’s thesis [Bon91] and is summarized in [Bon94]. The framework in [BM90] is hypothetical Datalog (with possibly infinite constants) and embedded implications. They assume a notion of negation-stratification and develop an awkward proof-theory parameterized by strata; a non-monotonic preferred Kripke model theory is presented and adequacy is demonstrated. They offer the following solution to the aforementioned paradoxes: the implication sign is really two distinct connectives, one for clauses and one for goals. Clause implication is interpreted classically and it is transitive, while goal implication is not and must be interpreted nonmonotonically. Indeed the latter has a modal semantic which takes into account the extension of a context as a shift in worlds (in the Kripke sense). While we favor a syntactic distinction between goals and clauses, the uniform proof approach views implication as logical (intuitionistic) implication whose different behavior is simply dictated by its introduction and elimination rule. Moreover we do not aim to deal with arbitrary extensions. We have hinted in the previous section how linear logic programming can address examples in this paper which are outside the fragment we are able to treat.

5.5.2 NF and N-Prolog

This approach has been investigated first at the propositional level in [NL92] and then for first-order N-Prolog in [GO98]:

“In order to understand N-Prolog computations with NF , we must adopt a dynamic view of success and failure […] we cannot determine what goals succeed or fail from a program unless we determine what goal succeeds or fail from arbitrary^{3} extension of the program” [NL92] pp. 258.

The main idea is again that a computation of an implicational goal D → G from P entails a shift to another world where P ∪ D holds. The authors propose a completion construction as an explanation of negation-as-failure. The completion is formulated as an infinite theory such that comp_{n}(P) is used to evaluate a goal G roughly if we need n extensions of the program to compute G: for example for a clause a ← (b → c) then a is provable iff comp(P ∪ b) entails c and a is false iff comp(P ∪ b) entails ¬c. Note that comp(P ∪ b) is different from comp(P) ∪ b or comp(P) ∪ comp(b). Moreover, due to the possible nonmonotonicity of arbitrary extensions comp(P) and comp(P ∪ b) may be jointly inconsistent: the modality represents then the shift of context. The completion construction does not seem to generalize immediately to universally quantified goals. The right kind of logic turns out to be a three-valued version of K4. The authors prove soundness and completeness of ESLDNF derivability w.r.t. a Kripke-Kleene fixpoint construction for a notion of non-floundering programs. The three-valued approach avoids the restriction to stratified programs.

3Emphasis is mine.

Draft of July 6, 2000

5.5.3 NF in First-Order Uniform Proofs

Harland’s thesis [Har91b] is an in-depth analysis of Uniform Proofs and NF at the first-order level. Unfortunately, his approach, though sound, is not adequate to our purposes, as we shall argue next. Harland inherits the traditional ‘boolean’ attitude w.r.t. the closed world assumption: predicates are either completely defined (CWA), as in the append program, or incomplete (OWA); while this distinction, he maintains, is essentially semantic and therefore enforced by user declarations, the latter coincide with the programs where temporary assumptions are made, i.e. clauses with embedded implications. Thus NF would make sense only for the former, since how will you apply the CWA to something that is by definition incomplete? Therefore those programs would require some form of real (say minimal) negation, much as in [Mil89c, Mom92]. Technically, this is achieved by distinguishing, for all predicates occurring in the signature, those which appear negatively versus positively in the body of clauses. The two sets are required to be disjoint. This of course simplifies the later development, but, unfortunately, if a predicate which appears negatively, i.e. it is assumed, cannot occur positively, then it will never be used in the derivation. Its assumption is totally irrelevant to the computation and may be discarded from the program. This fragment therefore collapses to normal programs with extensional quantification. While it is possible to enforce differently the distinction between complete and incomplete predicates, we are indeed interested to apply negation to incomplete predicates, although in a restricted fashion.

Then Harland shows how to formulate the completion as a first-order HHF formulae so as to simulate NF as derivability in the uniform proof system. The executable completion is formulated through contraposition. Programs are assumed to be locally stratified, hence the completion is consistent. Thus Harland identifies the completed program with its iff-completion, though he correctly has ¬(D → G) = D → ¬G. This operational interpretation of the augment instruction w.r.t. negation is nevertheless inconsistent with its formulation in the completion, where negation is interpreted classically insofar as the negative completion of Q ← G is seen as ¬(Q ∧ ¬G); again this holds only because NF cannot be applied to incomplete predicates. The classical attitude carries over to universal quantification, which is only allowed to be extensional. Harland so does not stress the intrinsic connection between implication and parametric universal quantification. Extensionality is achieved through covering as in [MMP88], though the role of the DCA (Domain Closure Axiom) is not made explicit. Therefore Harland is not able to correlate extensional uniform proofs with intuitionistic provability plus DCA. This is not surprising since its partition between complete and incomplete predicates restricts the AUGMENT rule so that its operational provability relations are not conservative extensions of standard uniform provability: this makes the usual proof-theoretic adequacy impossible. Moreover no operational semantics for coverings is described: not only is the role of free variables introduced by coverings unclear, but the extensional rules are totally non-deterministic w.r.t. the choice of the correct covering.

An equality/inequality solver on the Herbrand universe is described and used to solve inequalities stemming from the completed definitions: this algorithm is different from the traditional uncover algorithm as it does not return the most general solution but a possibly infinite enumeration of the latter; this permits not to left linearize the program.

5.5.4 Partial Inductive Definitions

Partial Inductive Definitions ([Hal91]) are a generalization of inductive definitions [Acz77] to definiens containing implications and in a finitary version ([Eri93]) of parametric quantification: they also incorporate a proof-theoretical notion of closure somehow as in the CWA, but brought upon by the principle of definitional reflection. In a logical setting, following [SH93], we take an intuitionistic sequent calculus parameterized by a set of definitions, i.e. a finite set of clauses b ⇐ G, where b ranges over atomic predicates possibly with free variables. For a definition D, we call D(a) = {σG | b ⇐ G ∈ D, a = σb}. In the spirit of the “clauses-as-rules” paradigm [HSH90, HSH91] we add for every defined atom a, the rules

\begin{aligned}Γ ⊢ G G ∈ D(a) \\ & D − R \\ Γ ⊢ a \end{aligned} \begin{aligned}\{σΓ, σG ⊢ A : σ = mgu(a, b), b ⇐ G ∈ D\} \\ & D − L \\ Γ, a ⊢ A \end{aligned}

Call this DR(D), for a given set of definitions D. The first rule corresponds to backchaining on the definitional clauses, while the second, in its ω-version, reflect the closure clause of (partial) inductive definitions. They can be seen as right and left introduction rules for the atomic proposition a: This feature is used in the programming language GCLA [MAK91] which allows both functional and logic programming style. Search is conducted on sequents Γ ⊢ G and it is clearly not amenable of a uniform proof approach, since focusing is impossible as at any time each of the assumption in the antecedent may be expanded via D − L. Indeed, without mentioning the issue of contraction, control in this setting has proven to be a major problem and this has lead to GCLA II, which is a middle ground between a logic programming language and a tactic theorem prover [Kre92].

One basic problem is the failure of global cut-elimination: as discussed in [SH93], in order to reduce an atomic cut formula through the D−L/D−R reduction, we may generate a cut with a more complex definiens formula. Definitions are called total if they enjoy cut-elimination, otherwise they are partial. Classes of total definitions include:

• Implication-free programs.

• Contraction-free logics.

• Stratified program w.r.t. negation.

• Stratified program w.r.t. implication [DM97].

In the latter case, predicates are assigned levels: the latter are then extended to formulae, so as to forbid recursion through negative occurrences; the level of an implication is essentially the order of its type: definitions are allowed only if the level of the heads is strictly greater than the level of the body: for instance a ⇐ b → a is allowed while a ⇐ a → b is not. This excludes every left-recursive definition.

Definitional reflection has been claimed to bring in a proof-theoretic notion of negation, although it would be more accurate to say that it allows a meta-level notion of closure. Intuitively, D − L works as the only-if clause of the completion: a proof of ⊢ ¬a is a proof of a ⊢ ⊥. This has been formalized by Schroeder-Heister who has proven [SH93] the equivalence between comp(P) and DR(P)∪(x = x ⇐ ⊤), where the latter clause, thanks to definitional reflection, suffices to define free equality. This result holds for any kind of definition and does not depend on cut-elimination. This has been hailed by the GCLA group as a major benefit of allowing definitional reflection, in so far as negative goals are simply a special case of implicational ones and therefore should be able to compute answer substitutions. This claim has some validity as far as normal stratified programs and ground goals are concerned: indeed they may yield only sequents such that if the antecedent is non-empty, it must be atomic and the consequent is ⊥: then D −L must be used to introduce a definiens from a lower stratum. As mentioned above, search is here cut-free. Thus for example, ¬even(s(0)) is provable as follows, suppressing here any mention of the (empty) parameter context:

\frac{D − L}{def(even), even(s(0)) ⊢ ⊥}

→ R def(even) ⊢ even(s(0)) → ⊥

since the definiens of even(s(0)) is empty.

The equivalence with the completion holds irrespectively of the presence of local variables. In this remark, then this approach would seem to have an edge on the transformational one since it does not need extensional quantification.

Example 5.6 Consider a graph edge(a, b), edge(b, c): the deduction of path(b, a) ⊢ ⊥ leads to the conjunctive goals {(edge(b, a) ⊢ ⊥), (edge(b, Z) ∧ path(Z, a) ⊢ ⊥)}, where Z is a local logic variable; then there is a computation which reduces to ⊥ … ⊢ ⊥.

On the other hand, some of the familiar problems with negative goals arises when concerned with open queries. When logic variables are allowed PID’s give the usual unsound reading to existential queries and one is faced again with the question of failure substitutions. For example the query def(even) ⊢ ∃x¬even(x) yields def(even), even(X) ⊢ ⊥; the rule D − L will loop, being unable to compute to what amounts, in our terms, to Not(0) ∩ Not(s(s(Y))). In other terms, definitional reflection uses unification to consider the given definition as a minimal inductive definition, but this does not allow to compute values that lies outside this very definition,

I am not aware of any implementation of the ω-rule for the purpose of enhancing a logic language with negation. As a matter of fact, the rule of definitional reflection used in GCLA is the weaker ‘logical’ version [MAK91] which does not imply in general the completion.

Notwithstanding the similarity, PID’s give a striking different operational semantics to HHF. Consider for example the definition a ⇐ b → c: then the sequent ⊢ ¬a has no cut-free proofs, while ⊢ a is provable against the operational intuition of HHF:

\frac{D − L}{b ⊢ c} ; → −R ; ⊢ b → c

D − R
⊢ a

Here, since b has no definition, it is assumed to be false and hence entails anything. This means that D − L is not conservative w.r.t. the positive fragment, i.e. the former rule may be used in proving positive atoms. In the complementation approach instead, positive and negative fragments are disjoint and exclusive. This is not surprising since, as mentioned above, the equivalence with the iff completion induces an operational semantics of failure which is distinct from the one typical of HHF. Moreover definitional reflection does not match well with parametric judgments. Consider a goal ·; def(even) ⊢ ¬open lam(λx . x), which is clearly unprovable: a naive logic programming interpreter augmented with definitional reflection will eventually yield the goal ·; def(even), ∀x: exp. open x ⊢ ⊥. In the failed derivation of the same positive goal, a goaloriented strategy would introduce a new parameter and try the goal y:exp; def(even) ⊢ open y. Yet, the same idea does not work when definitional reflection is allowed as now the universal in on the left and we can only do (inverted) universal elimination.

The main confusion, in general, lies in attempting to give a naive goal-oriented reading to a sequent calculus augmented with the definitional reflection rule. The latter is instead a meta-level closure operator; this is indeed how it is used in meta-logics as M_{2} [SP98] and F Oλ^{ΔIN} [MM97]. If we try to use it as a logic programming engine for HHF with negation, i.e. we add introduce logical variables and dynamic assumptions, it breaks down and reveal its meta-theoretic nature. We also remark that adopting our restriction to complementable programs ( formally introduced in Figure 6.7) would not help, as far as logic programming is concerned. Instead, we conjecture that the proof of cut-elimination given in [MM00] can be extended to those programs, allowing to enhance the range of F Oλ^{ΔIN} significantly.

Clause Complementation

In this chapter we introduce the source language and its uniform proofs system. Before formalizing the restriction to terminating programs, we establish the fundamental notion of context schema. This allows to enforce the Regular World Assumption (RWA), on which clause complementation is built. Finally, we discuss how to give an operational semantics to our system.

6.1 The Logic

We will use the following slightly unusual source language. Again, we fix a signature Σ in advance which would otherwise clutter the presentation; let M⃗, N⃗ be sequences of simple terms:

Atoms Q ::= q M⃗ | ¬q M⃗
Goals G ::= Q | ⊤ | ⊥ | M⃗ =^{·} N⃗ | M⃗ ≠^{·} N⃗ |
G_{1} ∧ G_{2} | G_{1} ∨ G_{2} | D → G | ∀x:A. G |
Clauses D ::= ⊤ | ⊥ | Q | D ← G | D_{1} ∧ D_{2} | D_{1} ∨ D_{2} | ∀x:A. D

First and foremost, we restrict ourselves to clauses of at most third-order, that is we allow HHF which only make Horn assumptions. This simplifies the presentation of the complement algorithm, but it is not an unsurmountable obstacle; we comment on this and other restrictions in the Conclusions (Chapter 7). Differently form standard presentation of HHF, we do not allow existential goals. This rules out open queries and local variables, as well as spares us from the heavy machinery of mixed prefixes [Mil92]. On the other hand, we allow disjunction between clauses, equality and inequality. While disjunction among clauses will be eliminated, inequalities will survive, although they will always be solvable at run-time by a simple syntactic check, as we will see in due time (Section 6.9). This simplifies their treatment in type-theoretic languages such as Twelf, where, in general, (in)equalities should be viewed as types inhabited by appropriate proof terms. The tokens ⊤, ⊥ may be decorated with a predicate symbol, as explained in Subsection 6.1.2 and Definition 6.21. Finally, we remark that ‘¬’ is not a connective, but a name constructor for atomic formulae.

Parameter Contexts Γ ::= · | Γ, x:A
Assumptions D ::= ⊤ | D ∧ D

We call a pair of concrete context and assumption Γ; D, such that all parameters occurring in D are mentioned in Γ, a (run-time) context. We make the usual conventions on contexts, in particular we avoid mentioning the leading · and ⊤ elements.

We use the notation D ⊑ P ∧ D to indicate that D is a top-level conjunct in the P or in D.1 We now introduce the uniform proofs judgments for provability and denial in Figure 6.1 and for immediate

implication and denial in Figure 6.2. While the system for denial is introduced for technical reasons, namely the proof of the Exhaustivity Theorem 6.35, it is of independent interest, since it provide evidence (that is proof terms) for non-provability. A similar system was presented in [Har91b], although in a simplified

\frac{⊢ ⊤}{Γ; D ⊢_{P} ⊤}  \frac{⊬⊥}{Γ; D ⊬_{P} ⊥}

\begin{matrix}M⃗ = N⃗ \\ ⊢ & =^{·} \\ Γ; D ⊢_{P} M⃗ =^{·} N⃗ \end{matrix}  \begin{matrix}M⃗ ≠ N⃗ \\ ⊬ & =^{·} \\ Γ; D ⊬_{P} M⃗ =^{·} N⃗ \end{matrix}

\begin{aligned}M⃗ ≠ N⃗ \\ & ⊢≠^{·} \\ Γ; D ⊢_{P} M⃗ ≠^{·} N⃗ \end{aligned}  \begin{aligned}M⃗ = N⃗ \\ & ⊬≠^{·} \\ Γ; D ⊬_{P} M⃗ ≠^{·} N⃗ \end{aligned}

\begin{aligned}Γ; D ⊢_{P} G_{1}  Γ; D ⊢_{P} G_{2} \\ & ⊢∧ \\ Γ; D ⊢_{P} G_{1} ∧ G_{2} \end{aligned}  \begin{aligned}Γ; D ⊬_{P} G_{1}  Γ; D ⊬_{P} G_{2} \\ & ⊬∨ \\ Γ; D ⊬_{P} G_{1} ∨ G_{2} \end{aligned}

\begin{aligned}Γ; D ⊢_{P} G_{1} \\ & ⊢ ∨_{1} \\ Γ; D ⊢_{P} G_{1} ∨ G_{2} \end{aligned}  \begin{aligned}Γ; D ⊬_{P} G_{1} \\ & ⊬ ∧_{1} \\ Γ; D ⊬_{P} G_{1} ∧ G_{2} \end{aligned}

\begin{aligned}Γ; D ⊢_{P} G_{2} \\ & ⊢ ∨_{2} \\ Γ; D ⊢_{P} G_{1} ∨ G_{2} \end{aligned}  \begin{aligned}Γ; D ⊬_{P} G_{2} \\ & ⊬ ∧_{2} \\ Γ; D ⊬_{P} G_{1} ∧ G_{2} \end{aligned}

\begin{aligned}Γ; (D ∧ D) ⊢_{P} G \\ & ⊢ → \\ Γ; D ⊢_{P} D → G \end{aligned}  \begin{aligned}Γ; (D ∧ D) ⊬_{P} G \\ & ⊬ → \\ Γ; D ⊬_{P} D → G \end{aligned}

\begin{aligned}(Γ, y:A); D ⊢_{P} [y/x]G \\ & ⊢∀^{y} \\ Γ; D ⊢_{P} ∀x:A. G \end{aligned}  \begin{aligned}(Γ, y:A); D ⊬_{P} [y/x]G \\ & ⊬∀^{y} \\ Γ; D ⊬_{P} ∀x:A. G \end{aligned}

\begin{aligned}Γ; D ⊢_{P} P ∧ D>>Q \\ & ⊢ & atm \\ Γ; D ⊢_{P} Q \end{aligned}  \begin{aligned}Γ; D ⊬_{P} P ∧ D>>Q \\ & ⊬ & atm \\ Γ; D ⊬_{P} Q \end{aligned}

Figure 6.1: Provability and denial

setting without parametric judgments. We remark that the systems for denial will instead not be needed in the proof of exclusivity (Theorem 6.34).

Due to the presence of ‘∨’ as a clause constructor, uniform proofs are not complete w.r.t. intuitionistic logic. We will remedy this situation in Section 6.9.2. The rules are depicted (when possible) in two columns where every row displays a positive rule and its negative counterpart.

Γ; D ⊢_{P} G  Program P and assumption D uniformly entail G.
Γ; D ⊬_{P} G  Program P and assumption D uniformly deny G.
Γ; D ⊢_{P} D>>Q Clause D from P ∧ D immediately entails atom Q.
Γ; D ⊬_{P} D>>Q Clause D from P ∧ D immediately denies atom Q.

We briefly comment on the rules: the (in)equalities rules simply mirror the object logic symbols =^{·}, ≠^{·} in meta-level (in)equality. The denial rules for implication and universal quantification reflect the operational semantics of unprovability that we have discussed earlier. Note that ≯>∀ is an infinitary rule, due to the meta-linguistic extensional universal quantification on all terms. Rule ≯>∀ must be read as: for every welltyped term n in parameter context Γ, ∀x:A. D immediately denies Q if so does [n/x]D. Rules ⊢ ∀, ⊬ ∀ are instead parametric in the new eigenvariable, say y; the ()^{y} superscript reminds us of the parameter condition on y, e.g. that y does not occur free in Γ; D nor in G. We will use this notation in any other parametric rule.

Differently from the latter, we will also use global eigenvariables, say u (see for example rule ⟹^{D} ∀ in Figure 6.3); this expresses the fact that in those rules the relation holds for any term; those parameters are therefore analogous to logic variables. We will pervasively utilize this notation; however, to avoid notational

6.1. THE LOGIC  79
\frac{>>⊥}{Γ; D ⊢_{P} ⊥>>Q}  \frac{≯>⊤}{Γ; D ⊬_{P} ⊤>>Q}

Γ ⊢ t : A Γ; D ⊢_{P} [t/x]D>>Q

>>∀

Γ; D ⊢_{P} ∀x:A. D>>Q

for all n Γ ⊢ n : A Γ; D ⊬_{P} [n/x]D>>Q

≯>∀

Γ; D ⊬_{P} ∀x:A. D>>Q

\begin{matrix}Γ; D ⊢_{P} D_{1}>>Q \\ >> & ∧_{1} \\ Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q \end{matrix}  \begin{matrix}Γ; D ⊬_{P} D_{1}>>Q \\ ≯> & ∨_{1} \\ Γ; D ⊬_{P} D_{1} ∨ D_{2}>>Q \end{matrix}
\begin{matrix}Γ; D ⊢_{P} D_{2}>>Q \\ >> & ∧_{2} \\ Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q \end{matrix}  \begin{matrix}Γ; D ⊬_{P} D_{2}>>Q \\ ≯> & ∨_{2} \\ Γ; D ⊬_{P} D_{1} ∨ D_{2}>>Q \end{matrix}

Γ; D ⊢_{P} D_{1}>>Q Γ; D ⊢_{P} D_{2}>>Q

>>∨

Γ; D ⊢_{P} D_{1} ∨ D_{2}>>Q Γ; D ⊬_{P} D_{1}>>Q Γ; D ⊬_{P} D_{2}>>Q

≯>∧

Γ; D ⊬_{P} D_{1} ∧ D_{2}>>Q

Γ; D ⊢_{P} D>>Q Γ; D ⊢_{P} G >> →

Γ; D ⊢_{P} D ← G>>Q

\begin{matrix}Γ; D ⊬_{P} D>>Q \\ ≯> & →_{1} \\ Γ; D ⊬_{P} D ← G>>Q \end{matrix}  \begin{matrix}Γ; D ⊬_{P} G \\ ≯> & →_{2} \\ Γ; D ⊬_{P} D ← G>>Q \end{matrix}

Figure 6.2: Immediate entailment and denial clutter, when possible we shall not keep an explicit record of global parameters, but we agree to implicitly gather them in a pool Φ, which we can access when needed, in particular to type-check substitutions, see next 6.1.1.

Draft of July 6, 2000

For the sake of conciseness we will often use in this thesis the following rule schema, where J (X, R) is a judgment involving a token X ranging over a set T and a relation R:

\begin{aligned}X ∈ T \\ & R X \\ J (X, R) \end{aligned}

6.1.1 Substitutions

We will need the notion of well-typed substitutions:

Substitutions σ ::= ϵ | σ, t/x

For σ = σ′, t/x, we say that x is defined in σ. We require all variables defined in a substitution to be distinct: we use dom(σ) for the set of variables defined in σ and cod(σ) for the variables occurring in the substituting terms. We assume them to be disjoint. Notation: [t/x]E denotes the substitution of x with t in an well-formed expression E. More in general we denote with [σ]E the application of σ to E. We will also need an operation of composition, say σ_{1} · σ_{2}, such that [σ_{1} · σ_{2}]E = [σ_{2}]([σ_{1}]E).

The judgment Γ ⊢ σ : Φ formalizes that σ is a valid well-typed substitution w.r.t. Γ.

\frac{ϵ·}{· ⊢ ϵ : ·}  \begin{aligned}Γ ⊢ t : A  Γ ⊢ σ : Φ \\ & σΦ \\ Γ ⊢ σ, t/x : (Φ, x : A) \end{aligned}

6.1.2 ⊤-Normalization

We show in this section how to put every program in a normalized format w.r.t. assumptions so that every goal in the scope of an universal quantifier depends on some assumption, possibly the trivial clause ⊤. This has also the effect of ‘localizing’ the trivial assumption to its atom, a property will be very useful while performing augmentation, see Section 6.6.

We first state some basic properties of provability.

Lemma 6.1 (Weakening)

1. If Γ; D ⊢ G, then:

(a) (Γ, x:A); D ⊢ G.

(b) Γ; (D ∧ D) ⊢ G.

2. If Γ; D ⊢ D>>Q, then:

(a) (Γ, x:A); D ⊢ D>>Q.

(b) Γ; (D ∧ D′) ⊢ D>>Q.

Proof: A straightforward mutual induction on the given derivations. □

In the proof of Theorem 6.5 we will need the following form of Strengthening:

Lemma 6.2 (⊤-Strengthening)

1. If Γ; (D ∧ ⊤) ⊢ G, then Γ; D ⊢ G.

2. If Γ; (D ∧ ⊤) ⊢ D>>Q, then Γ; D ⊢ D>>Q.

Proof: By an easy mutual induction on the structure of the given derivations. □

Normalization is realized in Figure 6.3 by the two judgments D ⟹^{D^{⊤}} D^{⊤} and Γ; D ⊢ G ⟹^{G^{⊤}} G^{⊤}. The only interesting case is when we reach an atomic goal: if no parameter has been introduced, the clause does not require any normalization. If Γ; D is non-empty, we adopt a brute-force approach and add the trivial clause for every predicate in the signature. This is largely unnecessary, but gives a very simple account of mutually recursion, without an explicit appeal to a call graph. As a matter of fact, we would really need to ⊤-normalize an atom Q with the trivial clause for every predicate that is mutually recursive to Q and such the type of the parameter in the context is not subordinate [Vir99] to the type of Q. On the other hand Theorems 6.4 and 6.5 ensures, as obvious, that this program transformation is harmless, since it preserves provability and denial. Moreover, we will engineer the rule for clause complementation so that the irrelevant ⊤_{q} will be inactive. We will remove those irrelevant augmentations in a final pass (Section 6.9.2).

Example 6.3 Consider the lambda clause in the open program:

oplam : ∀E:exp → exp. open (lam E)
← ∀x:exp. open (E x).

oplam ⟹^{D^{⊤}} oplam^{⊤}, i.e.

oplam^{⊤} : ∀E:exp → exp. open (lam E)
← (∀x:exp. ⊤_{open} → open (E x)).

Consider this fragment of code involving two of mutually recursive predicates:

qlam : ∀E:exp → exp. q (lam E)
← ∀x:exp. p (E x).
papp : ∀E_{1} :exp. ∀E_{2} :exp. p (app E_{1} E_{2})
← q E_{1} ∧ p E_{2}.

Then:

qlam^{⊤} : ∀E:exp → exp. q (lam E)
← (∀x:exp. ⊤_{p} ∧ ⊤_{q} → p (E x)).

In examples, we will not mention inactive ⊤ clauses.

We start by showing that this transformation preserves run-time provability.

Theorem 6.4 Let Γ′; D′ ⊢ G ⟹^{G^{⊤}} G^{⊤}, D ⟹^{D^{⊤}} D^{⊤}, D ⟹^{D^{⊤}} D^{⊤} and Γ ⊢ θ : Φ.

1. If Γ; [θ]D ⊢ [θ]G, then Γ; [θ]D^{⊤} ⊢ [θ]G^{⊤}.

2. If Γ; [θ]D ⊢ [θ]D>>[θ]Q, then Γ; [θ]D^{⊤} ⊢ [θ]D^{⊤}>>[θ]Q.

Proof: By mutual induction on the structure of the derivation of γ :: Γ; [θ]D ⊢ [θ]G and inversion on

γ′ :: Γ′; D′ ⊢ G ⟹^{G^{⊤}} G^{⊤} together with δ :: Γ; [θ]D ⊢ [θ]D>>[θ]Q and inversion on δ′ :: D ⟹^{D^{⊤}} D^{⊤}. We sketch only some cases:

Case: γ ends in ⊢ At and γ′ is ⟹^{G^{⊤}} X, ⟹^{G^{⊤}} At-emp: trivial.

Case: γ ends in ⊢ At and γ′ ends in ⟹^{G^{⊤}} At:

Γ; [θ]D ⊢ [θ]Q  By hypothesis
Γ; [θ]D ⊢ [θ](P ∧ D)>>[θ]Q  By sub-derivation
Γ; [θ]D^{⊤} ⊢ [θ]P ∧ D^{⊤}>>[θ]Q  By IH 2
Γ; ([θ]D^{⊤} ∧ (⋀_{p∈Σ} ⊤_{p})) ⊢ [θ]P ∧ D^{⊤}>>[θ]Q  By repeated Weakening
Γ; ([θ]D^{⊤} ∧ (⋀_{p∈Σ} ⊤_{p})) ⊢ [θ]Q  By rule ⊢ At
Γ; [θ]D^{⊤} ⊢ (⋀_{p∈Σ} ⊤_{p}) → [θ]Q  By rule ⊢→
Γ; [θ]D ⊢ [θ]Q^{⊤}  By rule ⟹^{G^{⊤}} At

X ∈ {⊤, ⊥} or (dis)eq

⟹^{G^{⊤}} X

Γ; D ⊢ X ⟹^{G^{⊤}} X

\frac{⟹^{G^{⊤}} At-emp}{·; ⊤ ⊢ Q ⟹^{G^{⊤}} Q}  \frac{⟹^{G^{⊤}} At}{Γ; D ⊢ Q ⟹^{G^{⊤}} ( ⋀_{p∈Σ} ⊤_{p} → Q)}

Γ; (D ∧ D) ⊢ G ⟹^{G^{⊤}} G^{⊤} D ⟹^{D^{⊤}} D^{⊤}

⟹^{G^{⊤}}→

Γ; D ⊢ D → G ⟹^{G^{⊤}} D^{⊤} → G^{⊤}

(Γ, y:A); D ⊢ [y/x]G ⟹^{G^{⊤}} [y/x]G^{⊤}

⟹^{G^{⊤}} ∀^{y}

Γ; D ⊢ ∀x:A. G ⟹^{G^{⊤}} ∀x:A. G^{⊤}

Γ; D ⊢ G_{1} ⟹^{G^{⊤}} G_{1}^{⊤} Γ; D ⊢ G_{2} ⟹^{G^{⊤}} G_{2}^{⊤}

⟹^{G^{⊤}} ∧

Γ; D ⊢ G_{1} ∧ G_{2} ⟹^{G^{⊤}} G_{1}^{⊤} ∧ G_{2}^{⊤}

Γ; D ⊢ G_{1} ⟹^{G^{⊤}} G_{1}^{⊤} Γ; D ⊢ G_{2} ⟹^{G^{⊤}} G_{2}^{⊤}

⟹^{G^{⊤}} ∨

Γ; D ⊢ G_{1} ∨ G_{2} ⟹^{G^{⊤}} G_{1}^{⊤} ∨ G_{2}^{⊤}

X ∈ {Q, ⊤, ⊥}

⟹^{D^{⊤}} X

X ⟹^{D^{⊤}} X

·; ⊤ ⊢ G ⟹^{G^{⊤}} G^{⊤} D ⟹^{D^{⊤}} D^{⊤}

⟹^{D^{⊤}}→

(G → D) ⟹^{D^{⊤}} G^{⊤} → D^{⊤}

[u/x]D ⟹^{D^{⊤}} [u/x]D^{⊤}

⟹^{D^{⊤}} ∀^{u}

∀x:A. D ⟹^{D^{⊤}} ∀x:A. D^{⊤}

\begin{aligned}D_{1} ⟹^{D^{⊤}} D_{1}^{⊤}  D_{2} ⟹^{D^{⊤}} D_{2}^{⊤} \\ & ⟹^{D^{⊤}} ∧ \\ D_{1} ∧ D_{2} ⟹^{D^{⊤}} D_{1}^{⊤} ∧ D_{2}^{⊤} \end{aligned}  \begin{aligned}D_{1} ⟹^{D^{⊤}} D_{1}^{⊤}  D_{2} ⟹^{D^{⊤}} D_{2}^{⊤} \\ & ⟹^{D^{⊤}} ∨ \\ D_{1} ∨ D_{2} ⟹^{D^{⊤}} D_{1}^{⊤} ∨ D_{2}^{⊤} \end{aligned}

Figure 6.3: ⊤-Normalization The other cases follows immediately by IH 1 and 2.

Draft of July 6, 2000

□

Now, the converse:

Theorem 6.5 Let Γ′; D′ ⊢ G ⟹^{G^{⊤}} G^{⊤}, D ⟹^{D^{⊤}} D^{⊤}, D ⟹^{D^{⊤}} D^{⊤} and Γ ⊢ θ : Φ.

1. If Γ; [θ]D^{⊤} ⊢ [θ]G^{⊤}, then Γ; [θ]D ⊢ [θ]G.

2. If Γ; [θ]D^{⊤} ⊢ [θ]D^{⊤}>>[θ]Q, then Γ; [θ]D ⊢ [θ]D>>[θ]Q.

Proof: By mutual induction on the structure of γ :: Γ; [θ]D^{⊤} ⊢ [θ]G^{⊤} and δ :: Γ; [θ]D^{⊤} ⊢ [θ]D^{⊤}>>[θ]Q, as above but using ⊤-Strengthening (Lemma 6.2) in place of Weakening. □

An analogous result can be proven w.r.t. failure; the latter would require ⊤-Weakening and Strengthening w.r.t. the (immediate) denial relation. On the other hand, the above result will suffice, if we restrict to terminating programs as we will do in Section 6.3. First, we need to establish a theory of context schemata

6.2 Context Schemata

In this Section we address the properties of contexts^{1}.

Hereditary Harrop formulae differ from Horn clauses in that they may dynamically extend the current signature and program; this is reflected in the provability (and denial) relation which is parameterized by a run-time context Γ; D. As we have argued before (Section 5.5) we cannot obtain closure under clause complementation for the full logic of HHF, but we have to restrict ourselves to a smaller (but significant) fragment. This in turn entails that we have to make sure that during execution whenever an assumption is made, the latter stays in the fragment we have isolated. Technically, we proceed as follows:

• We extract from the static definition of a predicate the general ‘template’ of a legal assumption.

• We require dynamic assumptions to conform to this template.

We thus introduce the notion of schema satisfaction, for which we will need the following data structure: a schema context abstracts over all possible instantiation of a run-time context. To account for that, we introduce a quantifier-like operator, say SOME Φ. D, which takes a clause and existentially bounds its free variables, i.e. the global parameters occurring in D. We use the following reification of schemata: do not confuse ‘∥’, which is used to represent schema alternatives in the object language with ‘|’ which does the same in our informal meta-language.

Contexts Schemata S ::= ∘ | S∥(Γ; SOME Φ. D)

Example 6.6 The schema context grammar induced by the linear predicate (Example 5.2) is as follows:

S_{linear} = ∘ | S_{linear}∥x:exp; linear(x) | S_{linear}∥x:exp; ⊤_{linx}

while a possible run-time context is

y_{1}:exp, y_{2}:exp, y_{3}:exp; ⊤_{linx} ∧ ⊤_{linx} ∧ linear(y_{3})

Since every possible assumption is closed, there is no existential binding. Consider instead the clauses for type-checking in the simply typed calculus:

ofapp : ∀E_{1}, E_{2} :exp. ∀T_{1}, T_{2}, T:tp.
of (app E_{1} E_{2}) T_{2}
← of E_{1} (arrow T_{1} T_{2})
← of E_{2} T_{1}.
oflam : ∀E:exp → exp. ∀T_{1}, T_{2} :tp.
of lam(E) (arrow T_{1} T_{2})
← (∀x:exp. of x T_{1} → of (E x) T_{2}).

1This section is inspired by Schürmann’s treatment of similar material in his dissertation [Sch00].

Draft of July 6, 2000

Then the schema context is:

S_{of} = ∘ | S_{of}∥x:exp; SOME u : tp. of x u

where ‘u’ is a global parameter.

We will also need to disambiguate blocks in run-time contexts; overlapping may indeed happen when the alternatives in a context schema are not disjoint. For example, suppose we are given the following schema and partial run-time context:

S = ∘ | S∥x:exp; p(x) | S∥x:exp; p(x) ∧ q(x)
y_{1}:exp, y_{2}:exp; p(y_{1}) ∧ p(y_{2})

It is not uniquely determined whether, say, p(y_{2}) is an instance of the first alternative or a prefix of the second one. To determine that, we simply modify the provability and denial rules ⊢ At and ⊬ At by ‘packaging’ run-time contexts into blocks with a bracket operator ⌈ ⌉. Intuitively, a block is complete when an atomic conclusion is reached during the deduction. It is therefore bracketed when the run-time context is passed to the immediate implication judgment.

\begin{aligned}⌈Γ⌉; ⌈D⌉ ⊢_{P} P ∧ ⌈D⌉>>Q \\ & ⊢ & At \\ Γ; D ⊢_{P} Q \end{aligned}  \begin{aligned}⌈Γ⌉; ⌈D⌉ ⊬_{P} P ∧ ⌈D⌉>>Q \\ & ⊬ & At \\ Γ; D ⊬_{P} Q \end{aligned}

Still, we need to ‘flatten’ blocks, so that re-bracketing during execution will be immaterial on already delimited blocks; we thus require the bracket operator to satisfy the following absorption-distribution law:

⌈⌈Γ⌉, Γ′⌉ = ⌈Γ⌉, ⌈Γ′⌉
⌈⌈D⌉ ∧ D′⌉ = ⌈D⌉ ∧ ⌈D′⌉

We are now ready to introduce schema satisfaction; this is accomplished by the following judgments:

• ⊧_{S} D: clause D satisfies schema S.

• Γ; D \ G < S: (partially completed) run-time context Γ; D together with goal G satisfies schema S.

• Γ; D < S: (completed) run-time context Γ; D satisfies schema S.

• Γ ⊢ Γ′; D′ ∈ S: block Γ′; D′ in context Γ occurs in schema S.

First, we say that a completed block occurs in a schema when the block is an alphabetic variant of some instantiation of one of the alternatives of the schema;

Γ ⊢ θ : Φ (Γ′; D′) ≡_{α} (Γ′′; [θ]D) ∈_{1}

Γ ⊢ (Γ′; D′) ∈ S∥(Γ′′; SOME Φ. D)

\begin{aligned}Γ ⊢ (Γ′; D′) ∈ S \\ & ∈_{2} \\ Γ ⊢ (Γ′; D′) ∈ S∥(Γ′′; D) \end{aligned}

Let us now analyze the rules in Figure 6.4. The empty run-time context is an instance of every schema. Moreover if Γ′ and D′ are completed blocks which occur in S, as denoted by the block notation, then (Γ, ⌈Γ′⌉); (D ∧ ⌈D′⌉) is an instance of S, provided that D′ is a valid clause. Thus we need to define the instance relation simultaneously to clause (and in turn to goal) satisfaction. The judgment ⊧_{S} D is merely auxiliary to the Γ; D \ G < S one: here we mimic the construction on the run-time schema until, in the base case, we check whether the resulting context is an instance of the given schema.

The following Lemma ensures that when an assumption D is pulled from a legal run-time context, i.e. which satisfies a given schema, so does D.

Lemma 6.7 If Γ; D < S and D ⊑ D, then ⊧_{S} D.

Proof: By induction on the structure of the derivation of π :: Γ; D < S.

X ∈ {Q, ⊤, ⊥} or (dis)eq Γ; D < S

\X

Γ; D \ X < S

Γ; D \ G_{1} < S Γ; D \ G_{2} < S

\∧

Γ; D \ G_{1} ∧ G_{2} < S

Γ; D \ G_{1} < S Γ; D \ G_{2} < S

\∨

Γ; D \ G_{1} ∨ G_{2} < S
(Γ, y:A); D \ [y/x]G < S

\∀^{y}

Γ; D \ ∀x:A. G < S

⊧_{S} D Γ; (D ∧ D) \ G < S

\ →

Γ; D \ D → G < S

\begin{aligned}X ∈ \{Q, ⊤⊥\} \\ & ⊧_{S} X \\ ⊧_{S} X \end{aligned}

⊧_{S} D_{1} ⊧_{S} D_{2}

⊧_{S} ∧

⊧_{S} D_{1} ∧ D_{2} ⊧_{S} D_{1} ⊧_{S} D_{2}

⊧_{S} ∨

⊧_{S} D_{1} ∨ D_{2}

\begin{aligned}⊧_{S} [u/x]D \\ & ⊧_{S} ∀^{u} \\ ⊧_{S} ∀x:A. D \end{aligned}

⊧_{S} D ·; ⊤ \ G < S

⊧_{S}→

⊧_{S} G → D

\frac{<_{1}}{·; ⊤ < S}  \begin{aligned}Γ ⊢ (Γ′; D′) ∈ S ⊧_{S} D′ (Γ; D) < S \\ & <_{2} \\ (Γ, ⌈Γ′⌉); (D ∧ ⌈D′⌉) < S \end{aligned}

Figure 6.4: Judgments Γ; D \ G < S, ⊧_{S} D and Γ; D < S Case:

Draft of July 6, 2000

π = \frac{<_{1}}{·; ⊤ < S}

Then D = ⊤ and immediately

π′ = \frac{⊧_{S} ⊤}{·; ⊤ ⊧_{S} ⊤}

Case:

π = \begin{aligned}Γ′′ ⊢ (Γ′; D′) ∈ S ⊧_{S} D′ (Γ′′; D′′) < S \\ & <_{2} \\ (Γ′′, ⌈Γ′⌉); (D′′ ∧ ⌈D′⌉) < S \end{aligned}

Subcase: D ≡ D′
⊧_{S} D′  By hypothesis
Subcase: D ⊑ D′′
Γ′′; D′′ < S  By sub-derivation
⊧_{S} D  By IH

□

We can also show that schema satisfaction is closed under substitution:

Lemma 6.8 Let Γ; D < S and Γ ⊢ θ : Φ.

1. If ⊧_{S} D, then ⊧_{S} [θ]D.

2. If Γ; D \ G < S, then Γ; [θ]D \ [θ]G < S.

3. If Γ; D < S then Γ; [θ]D < S.

Proof: By a straightforward mutual induction on the structure of π :: ⊧_{S} D, γ :: Γ; D \ G < S and σ :: Γ; D < S. □

6.2.1 Schema Extraction

Roughly, we extract a context schema by collecting all negative occurrences in a goal. In fact, those will be dynamically added to the static program under evaluation. This is achieved by the judgment Γ; D ⊢_{Φ} G ⟹^{G} S. The latter is mutually recursive to the judgment ⊢_{Φ} D ⟹^{D} S which collects schemata for each clause in the given program, as depicted in Figure 6.5. When an atomic goal is reached, the current list of parameters and assumptions is returned, with the correct existential binding inferred from the context of global variables. With the notation Φ_{D} we mean the restriction of context Φ to the free variables of D, i.e. {u:A | u ∈ dom(Φ), u ∉ F V (D)}. We make the convention to absorb schema alternatives which are α-variants. Moreover the empty run-time context behaves as a left and right zero element for ∥, i.e. :

(Γ; D∥·; ⊤) = (·; ⊤∥Γ; D) = Γ; D

Finally ∥ is commutative.

Example 6.9 If P is the program in Example 5.2, P ⟹^{D} x:exp; linear(x)∥x:exp; ⊤_{linx}.

We aim to show that if a schema context is extracted by a program, the latter satisfies the former. First, we need to establish two weakening lemmata w.r.t. schema alternatives:

Lemma 6.10 If Γ ⊢ Γ′; D′ ∈ S then Γ ⊢ Γ′; D′ ∈ S′∥S.

Proof: By a straightforward induction on the structure of π :: Γ; D ∈ S. □

X ∈ {Q, ⊤, ⊥} or (dis)eq

⟹^{G} X

Γ; D ⊢_{Φ} X ⟹^{G} Γ; SOME Φ_{D}. D

Γ; (D ∧ D) ⊢_{Φ} G ⟹^{G} S_{1} D ⟹^{D} S_{2}

⟹^{G}→

Γ; D ⊢_{Φ} D → G ⟹^{G} S_{1}∥S_{2}

(Γ, y:A); D ⊢_{Φ} [y/x]G ⟹^{G} S

⟹^{G} ∀^{y}

Γ; D ⊢_{Φ} ∀x:A. G ⟹^{G} S

Γ; D ⊢_{Φ} G_{1} ⟹^{G} S_{1} Γ; D ⊢_{Φ} G_{2} ⟹^{G} S_{2}

⟹^{G} ∧

Γ; D ⊢_{Φ} G_{1} ∧ G_{2} ⟹^{G} S_{1}∥S_{2}

Γ; D ⊢_{Φ} G_{1} ⟹^{G} S_{1} Γ; D ⊢_{Φ} G_{2} ⟹^{G} S_{2}

⟹^{G} ∨

Γ; D ⊢_{Φ} G_{1} ∨ G_{2} ⟹^{G} S_{1}∥S_{2}

X ∈ {Q, ⊤, ⊥}

⟹^{D} X

⊢_{Φ} X ⟹^{D} ·; ⊤

·; ⊤ ⊢_{Φ} G ⟹^{G} S_{1} ⊢_{Φ} D ⟹^{D} S_{2}

⟹^{D}→

⊢_{Φ} (G → D) ⟹^{D} S_{1}∥S_{2}

⊢_{Φ,u:A} [u/x]D ⟹^{D} S

⟹^{D} ∀^{u}

⊢_{Φ} ∀x:A. D ⟹^{D} S

⊢_{Φ} D_{1} ⟹^{D} S_{1} ⊢_{Φ} D_{2} ⟹^{D} S_{2}

⟹^{D} ∧

⊢_{Φ} D_{1} ∧ D_{2} ⟹^{D} S_{1}∥S_{2}

⊢_{Φ} D_{1} ⟹^{D} S_{1} ⊢_{Φ} D_{2} ⟹^{D} S_{2}

⟹^{D} ∨

⊢_{Φ} D_{1} ∨ D_{2} ⟹^{D} S_{1}∥S_{2}

Figure 6.5: Extracting contexts schemata

Draft of July 6, 2000

Note also that Γ ⊢ Γ′; D′ ∈ S′∥S iff Γ ⊢ Γ′; D′ ∈ S∥S′. Lemma 6.11 (Schema Weakening) Let Γ; D < S. Then

1. If ⊧_{S} D, then ⊧_{S∥S′} D.

2. If Γ; D \ G < S, then Γ; D \ G < S∥S′.

3. If Γ; D < S then Γ; D < S∥S′. Proof: By mutual induction on the structure of π :: ⊧_{S} D, γ :: Γ; D \ G < S and σ :: Γ; D < S. We show the crucial cases: Case:

π = \begin{aligned}X ∈ \{Q, ⊤, ⊥\} \\ & ⊧_{S} X \\ ⊧_{S} X \end{aligned}

Trivially

π′ = \begin{aligned}X ∈ \{Q, ⊤, ⊥\} \\ & ⊧_{S} X \\ ⊧_{S∥S′} Q \end{aligned}

Case:

π = \begin{aligned}⊧_{S} D ·; ⊤ \ G < S \\ & ⊧_{S}→ \\ ⊧_{S} G → D \end{aligned}

⊧_{S} D  By sub-derivation
⊧_{S∥S′} D  By IH 1
·; ⊤ \ G < S  By sub-derivation
·; ⊤ \ G < S∥S′  By IH 2
⊧_{S∥S′} G → D  By rule ⊧_{S}→

Case:

γ = X ∈ {Q, ⊤, ⊥} or (dis)eq Γ; D < S \X Γ; D \ X < S
Γ; D < S  By sub-derivation
Γ; D < S∥S′  By IH 3
Γ; D \ X < S∥S′  By rule \X

Case:

γ = \begin{aligned}⊧_{S} D Γ; D ∧ D \ G < S \\ & \ → \\ Γ; D \ D → G < S \end{aligned}

⊧_{S} D  By sub-derivation
⊧_{S∥S′} D  By IH 1
Γ; D ∧ D \ G < S  By sub-derivation
Γ; (D ∧ D) \ G < S∥S′  By IH 2
Γ; D \ D → G < S∥S′  By rule \ →

Case:

σ = \frac{<_{1}}{·; ⊤ < S}

Then immediately:

σ′ = \frac{<_{1}}{·; ⊤ < S∥S′}

Case:

σ = \begin{aligned}Γ ⊢ (Γ′; D′) ∈ S ⊧_{S} D′ (Γ; D) < S \\ & <_{2} \\ (Γ, ⌈Γ′⌉); (D ∧ ⌈D′⌉) < S \end{aligned}

Γ; D < S  By sub-derivation
Γ; D < S∥S′  By IH 3
Γ ⊢ Γ′; D′ ∈ S  By sub-derivation
Γ ⊢ Γ′; D′ ∈ S∥S′  By Lemma 6.10
⊧_{S} D′  By sub-derivation
⊧_{S∥S′} D  By IH 1
(Γ, ⌈Γ′⌉); (D ∧ ⌈D′⌉) < S∥S′  By rule <_{2}
□

We are now ready to show that if a program yields a schema, then every instance of a clause used at run-rime will comply with the schema. We need to generalize this statement to take into account instances of goals as well; in the latter case, we need to synchronize the schema accumulator in Γ′; D′ ⊢ G ⟹^{G} S with the possibly incomplete run-time context Γ; D. A fortiori the result holds for compile-time contexts as well, by taking Γ; D as ·; ⊤.

Theorem 6.12 (Extracted Schema Satisfaction) Let Γ ⊢ θ : Φ.

1. If ⊢_{Φ} D ⟹^{D} S, then ⊧_{S} [θ]D.

2. If Γ′; D′ ⊢_{Φ} G ⟹^{G} S, ⊧_{S} D′ and Γ; D < S, then (Γ, Γ′); (D ∧ [θ]D′) \ [θ]G < S.

Proof: By mutual induction on the structure of π :: D ⟹^{D} S and γ :: Γ′; D′ ⊢_{Φ} G ⟹^{G} S.

Case:

π = \begin{aligned}X ∈ \{Q, ⊤, ⊥\} \\ & ⟹^{D} X \\ ⊢_{Φ} X ⟹^{D} ·; ⊤ \end{aligned}

⊧_{·;⊤} X  By rule ⊧_{S} X

Case:

π = \begin{aligned}⊢_{Φ} D_{1} ⟹^{D} S_{1} ⊢_{Φ} D_{2} ⟹^{D} S_{2} \\ & ⟹^{D} ∧ \\ ⊢_{Φ} D_{1} ∧ D_{2} ⟹^{D} S_{1}∥S_{2} \end{aligned}

⊢_{Φ} D_{1} ⟹^{D} S_{1}  By sub-derivation
⊢_{Φ} D_{2} ⟹^{D} S_{2}  By sub-derivation
⊧_{S_{1}} [θ]D_{1}  By IH 1
⊧_{S_{2}} [θ]D_{2}  By IH 1
⊧_{S_{1}∥S_{2}} [θ]D_{1}  By Lemma 6.11
⊧_{S_{1}∥S_{2}} [θ]D_{2}  By Lemma 6.11
⊧_{S_{1}∥S_{2}} [θ]D_{1} ∧ [θ]D_{2}  By rule ⊧_{S} ∧
⊧_{S_{1}∥S_{2}} [θ](D_{1} ∧ D_{2})  By subst.

Case: π ends in ⟹^{D} ∨: analogously to the above.

Case: π ends in ⟹^{D} ∀^{y}: by an immediate appeal to IH 1.

Case:

π = \begin{aligned}·; ⊤ ⊢_{Φ} G ⟹^{G} S_{1} ⊢_{Φ} D ⟹^{D} S_{2} \\ & ⟹^{D}→ \\ ⊢_{Φ} (G → D) ⟹^{D} S_{1}∥S_{2} \end{aligned}

⊢_{Φ} D ⟹^{D} S_{2}  By sub-derivation
⊧_{S_{2}} [θ]D  By IH 1
⊧_{S_{1}∥S_{2}} [θ]D  By Lemma 6.11
·; ⊤ ⊢_{Φ} G ⟹^{G} S_{1}  By sub-derivation
·; ⊤ < S_{1}  By rule <_{1}
·; ⊤ \ [θ]G < S_{1}  By IH 2
·; ⊤ \ [θ]G < S_{1}∥S_{2}  By Lemma 6.11
⊧_{S_{1}∥S_{2}} [θ]G → [θ]D  By rule ⊧_{S}→

Case:

γ = X ∈ {Q, ⊤, ⊥} or (dis)eq ⟹^{G} X Γ′; D′ ⊢_{Φ} X ⟹^{G} Γ′; SOME Φ_{D′}. D′

Γ′; [θ]D′ ≡_{α} Γ′; [θ]D′  By hypothesis
Γ ⊢ Γ′; [θ]D′ ∈ Γ′; SOME Φ_{D′}. D′  By rule ∈_{1}
Γ; D < Γ′; SOME Φ_{D′}. D′  By hypothesis
⊧_{Γ′;(SOME Φ_{D′} . D)} D′  By hypothesis
⊧_{Γ′;(SOME Φ_{D′} . D)} [θ]D′  By Lemma 6.8
(Γ, ⌈Γ′⌉); (D ∧ ⌈[θ]D′⌉) < Γ′; SOME Φ_{D′}. D′  By rule <_{2}
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]X < Γ′; SOME Φ_{D′}. D′  By rule \X

Case:

γ = \begin{aligned}(Γ′, y:A); D′ ⊢_{Φ} [y/x]G ⟹^{G} S \\ & ⟹^{G} ∀^{y} \\ Γ′; D′ ⊢_{Φ} ∀x:A. G ⟹^{G} S \end{aligned}

(Γ′, y:A); D′ ⊢_{Φ} [y/x]G ⟹^{G} S  By sub-derivation
(Γ, Γ′, y:A); (D ∧ [θ]D′) \ [θ] · [y/x]G < S  By IH 2
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]∀x:A. G < S  By rule \∀^{y}

Case:

γ = \begin{aligned}Γ′; (D′ ∧ D) ⊢_{Φ} G ⟹^{G} S_{1} ⊢_{Φ} D ⟹^{D} S_{2} \\ & ⟹^{G}→ \\ Γ′; D′ ⊢_{Φ} D → G ⟹^{G} S_{1}∥S_{2} \end{aligned}

⊢_{Φ} D ⟹^{D} S_{2}  By sub-derivation
⊧_{S_{2}} [θ]D  By IH 1
⊧_{S_{1}∥S_{2}} [θ]D  By Lemma 6.11
Γ; D < S_{1}  By hypothesis
Γ′; (D′ ∧ D) ⊢_{Φ} G ⟹^{G} S_{1}  By sub-derivation
(Γ, Γ′); (D ∧ [θ]D′ ∧ [θ]D) \ [θ]G < S_{1}  By IH 2
(Γ, Γ′); (D ∧ [θ]D′ ∧ [θ]D) \ [θ]G < S_{1}∥S_{2}  By Lemma 6.11
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]D → [θ]G < S_{1}∥S_{2}  By rule \ →

Case:

γ = \begin{aligned}Γ′; D′ ⊢_{Φ} G_{1} ⟹^{G} S_{1} Γ′; D′ ⊢_{Φ} G_{2} ⟹^{G} S_{2} \\ & ⟹^{G} ∧ \\ Γ′; D′ ⊢_{Φ} G_{1} ∧ G_{2} ⟹^{G} S_{1}∥S_{2} \end{aligned}

Draft of July 6, 2000

Γ′; D′ ⊢_{Φ} G_{1} ⟹^{G} S_{1}  By sub-derivation
Γ; D < S_{1}  By hypothesis
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]G_{1} < S_{1}  By IH 2
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]G_{1} < S_{1}∥S_{2}  By Lemma 6.11
Γ′; D′ ⊢_{Φ} G_{2} ⟹^{G} S_{2}  By sub-derivation
Γ; D < S_{2}  By hypothesis
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]G_{2} < S_{2}  By IH 2
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]G_{2} < S_{1}∥S_{2}  By Lemma 6.11
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]G_{1} ∧ [θ]G_{2} < S_{1}∥S_{2}  By rule \∧

Case: γ ends in ⟹^{G} ∨: similarly to the above. to IH 2.

□

6.2.2 Context Preservation

We aim to prove that execution preserves contexts, provided that the program itself and the input goal satisfy a schema; that is, that every subgoal which arises in any given successful or failed (immediate and non-immediate sub-derivation) satisfies the same context schema.

Note that we have already established schema extraction (Theorem 6.12), that is we assume that P ⟹^{D} S. We write π′ < π to say that π′ is a strict subproof of π, i.e. π′ ≤ π if π′ < π or π′ = π.

Theorem 6.13 (Context Preservation w.r.t. Provability) Let ⊧_{S} P and D ⊑ (P∧D). For any Γ; D < S, if (π :: Γ; D ⊢_{P} G and Γ; D \ G < S) or (ι :: Γ; D ⊢_{P} D>>Q and ⊧_{S} D), then:

1. for every subproof π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S.

2. for every subproof ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′.

Proof: By^{2}mutual induction on the structure of π :: Γ; D ⊢_{P} G and ι :: Γ; D ⊢_{P} D>>Q.

Case: π = Γ; D ⊢_{P} ⊤: trivial.

Case:

π = \begin{matrix}π_{1} \\ Γ; D ∧ D ⊢_{P} G \end{matrix} ; ⊢→ ; Γ; D ⊢_{P} D → G

Subcase: π′ = π: trivial.

Subcase: π′ < π: then π′ ≤ π_{1}.

π_{1} :: Γ; D ∧ D ⊢_{P} G  By sub-derivation
Γ; D \ D → G < S  By hypothesis
Γ; D ∧ D \ G < S  By inversion
ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′ and
π′_{1} :: Γ′; (D′ ∧ D′) ⊢_{P} G′ and Γ′; (D′ ∧ D′) \ G′ < S  By IH
π′ :: Γ′; D′ ⊢_{P} D′ → G′ and Γ′; D′ \ D′ → G′ < S  By rule

Case:

π \begin{matrix}π_{1} \\ (Γ, y:A); D ⊢_{P} [y/x]G \end{matrix} ; ⊢ ∀^{y} ; Γ; D ⊢_{P} ∀x:A. G

Subcase: π′ = π: trivial.

2FIXED Subcase: π′ < π: then π′ ≤ π_{1}.

Draft of July 6, 2000

π_{1} :: (Γ, y:A); D ⊢_{P} [y/x]G  By sub-derivation
Γ; D \ ∀x:A. G < S  By hypothesis
(Γ, y:A); D \ [y/x]G < S  By inversion

ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′ and

π′_{1} :: (Γ′, y:A); D′ ⊢_{P} [y/x]G′ and (Γ′, y:A); D′ \ [y/x]G′ < S  By IH
π′ :: Γ′; D′ ⊢_{P} ∀x:A. G′ and Γ′; D′ \ ∀x:A. G′ < S  By rule

Case: π ends in ⊢ ∧, ⊢ ∨_{1}, ⊢ ∨_{2}: similarly. Case:

π = \begin{matrix}ι \\ Γ; D ⊢_{P} P ∧ D>>Q \end{matrix} ; ⊢ At ; Γ; D ⊢_{P} Q

Subcase: π′ = π: trivial. Subcase: π′ < π: then π′ ≤ ι.

Subcase: ι_{1} :: Γ; D ⊢_{P} D>>Q, for D ⊑ D  By sub-derivation
⊧_{S} D  By hypothesis
π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and
ι′_{1} :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′  By IH
Γ′; D′ ⊢_{P} Q′ and Γ′; D′ \ Q′ < S  By rule
Subcase: ι_{1} :: Γ; D ⊢_{P} D>>Q, for D ⊑ D  By sub-derivation
⊧_{S} D  By Lemma 6.7
π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and
ι′_{1} :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′  By IH
Γ′; D′ ⊢_{P} Q′ and Γ′; D′ \ Q′ < S  By rule

Case: ι :: Γ; D ⊢_{P} ⊥>>Q: trivial. Case:

ι = \begin{matrix}ι_{1} \\ Γ; D ⊢_{P} D_{1}>>Q \end{matrix} ; >>∧_{1} ; Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q

Subcase: ι′ = ι: trivial. Subcase: ι′ < ι: then ι′ ≤ ι_{1}:

⊧_{S} D_{1} ∧ D_{2}  By hypothesis
⊧_{S} D_{1} and ⊧_{S} D_{2}  By inversion
ι_{1} :: Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation

π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and

ι′_{1} :: Γ′; D′ ⊢_{P} D′_{1}>>Q and ⊧_{S} D′_{1}  By IH
ι′ :: Γ′; D′ ⊢_{P} D′_{1} ∧ D′_{2}>>Q and ⊧_{S} D′_{1} ∧ D′_{2}  By rule

Case: ι ends in >>∧_{2}. Symmetrical. Case:

ι = \begin{matrix}ι_{1} \\ Γ; D ⊢_{P} [t/x]D>>Q \end{matrix} ; >>∀ ; Γ; D ⊢_{P} ∀x:A. D>>Q

Subcase: ι′ = ι: trivial. Subcase: ι′ < ι: then ι′ ≤ ι_{1}.

Draft of July 6, 2000

ι_{1} :: Γ; D ⊢_{P} [t/x]D>>Q  By sub-derivation
⊧_{S} ∀x:A. D  By hypothesis
⊧_{S} [u/x]D  By inversion
⊧_{S} [t/u, u/x]D  By substitution

π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and

ι′_{1} :: Γ′; D′ ⊢_{P} [t/x]D′>>Q and ⊧_{S} [t/x]D′  By IH
ι′ :: Γ′; D′ ⊢_{P} ∀x:A. D′>>Q and ⊧_{S} ∀x:A. D′  By rule

Case:

ι = \begin{aligned}\begin{matrix}ι_{1} \\ Γ; D ⊢_{P} D>>Q \end{matrix} & \begin{matrix}π_{1} \\ Γ; D ⊢_{P} G \end{matrix} \\ & >> → \\ Γ; D ⊢_{P} G → D>>Q \end{aligned}

Subcase: ι′ = ι: trivial. Subcase: ι′ < ι:

Subcase: ι′ ≤ ι_{1}

ι_{1} :: Γ; D ⊢_{P} D>>Q and π_{1} :: Γ; D ⊢_{P} G  By sub-derivation
⊧_{S} G → D  By hypothesis
Γ; D \ G < S and ⊧_{S} D  By inversion

π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and

ι′_{1} :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′  By IH
ι′ :: Γ′; D′ ⊢_{P} G′ → D′>>Q and ⊧_{S} G′ → D′  By rule

Subcase: ι′ ≤ π_{1}: analogously. Case: ι ends in >>∨, >>∀: similarly.

□

We establish an analogous result w.r.t. denial.

Theorem 6.14 (Context Preservation w.r.t. Denial) Let ⊧_{S} P and D ⊑ (P ∧ D): for any Γ; D < S, if ( π :: Γ; D ⊬_{P} G and Γ; D \ G < S ) or ( ι :: Γ; D ⊬_{P} D>>Q and ⊧_{S} D), then:

1. for every subproof π′ :: Γ′; D′ ⊬_{P} G′ and Γ′; D′ \ G′ < S.

2. for every subproof ι′ :: Γ′; D′ ⊬_{P} D′>>Q and ⊧_{S} D′.

Proof: By mutual induction on the structure of π :: Γ; D ⊬_{P} G and ι :: Γ; D ⊬_{P} D>>Q, similarly to the case of provability. We show only some cases: Case:

π = \begin{matrix}π_{1} \\ Γ; (D ∧ D) ⊬_{P} G \end{matrix} ; ⊬ → ; Γ; D ⊬_{P} D → G

Subcase: π′ = π: trivial. Subcase: π′ < π: then π′ ≤ π_{1}:

Γ; (D ∧ D) ⊬_{P} G  By sub-derivation
Γ; D \ D → G < S  By hypothesis
Γ; D ∧ D \ G < S  By inversion

ι′ :: Γ′; D′ ⊬_{P} D′>>Q and ⊧_{S} D′ and

π′ :: Γ; (D′ ∧ D′) ⊬_{P} G′ and Γ; (D′ ∧ D′) \ G′ < S  By IH
π′′ :: Γ′; D′ ⊬_{P} (D′ → G′) and Γ′; D′ \ (D′ → G′) < S  By rule

Case:

ι = \begin{matrix}ι_{1} \\ Γ; D ⊬_{P} G \end{matrix} ; ≯>→_{1} ; Γ; D ⊬_{P} D ← G>>Q

Subcase: ι′ = ι: trivial. Subcase: ι′ < ι: then ι′ ≤ ι_{1}:

ι_{1} :: Γ; D ⊬_{P} G  By sub-derivation
⊧_{S} G → D  By hypothesis
Γ; D \ G < S and ⊧_{S} D  By inversion

π′ :: Γ′; D′ ⊬_{P} G′ and Γ′; D′ \ G′ < S and

ι′ :: Γ′; D′ ⊬_{P} D′>>Q and ⊧_{S} D′  By IH
ι′′ :: Γ′; D′ ⊬_{P} (D′ ← G′)>>Q and ⊧_{S} (D′ ← G′)  By rule

Case:

ι = \begin{matrix}ι_{1} \\ Γ; D ⊬_{P} D>>Q \end{matrix} ; ≯>→_{2} ; Γ; D ⊬_{P} D ← G>>Q

Subcase: ι′ = ι: trivial. Subcase: ι′ < ι: then ι′ ≤ ι_{1}:

ι_{1} :: Γ; D ⊬_{P} D>>Q  By sub-derivation
⊧_{S} G → D  By hypothesis
Γ; D \ G < S and ⊧_{S} D  By inversion

π′ :: Γ′; D′ ⊬_{P} G′ and Γ′; D′ \ G′ < S and

ι′ :: Γ′; D′ ⊬_{P} D′>>Q and ⊧_{S} D′  By IH
ι′′ :: Γ′; D′ ⊬_{P} (D′ ← G′)>>Q and ⊧_{S} (D′ ← G′)  By rule

Case:

ι = \begin{matrix}ι_{1} \\ for all n Γ; D ⊬_{P} [n/x]D>>Q \end{matrix} >>∀ Γ; D ⊬_{P} ∀x:A. D>>Q

Subcase: ι′ = ι: trivial. Subcase: ι′ < ι: then ι′ ≤ ι_{1}.

⊧_{S} ∀x:A. D  By hypothesis
⊧_{S} [u/x]D  By inversion
For all ι_{1} :: Γ; D ⊬_{P} [n/x]D>>Q  By sub-derivation
For all ⊧_{S} [n/u, u/x]D  By substitution

π′ :: Γ′; D′ ⊬_{P} G′ and Γ′; D′ \ G′ < S and

For all ι′_{1} :: Γ′; D′ ⊬_{P} [n/x]D′>>Q and ⊧_{S} [n/x]D′  By IH
ι′ :: Γ′; D′ ⊬_{P} ∀x:A. D′>>Q and ⊧_{S} ∀x:A. D′  By rule
□

6.3 Terminating Programs

We now introduce terminating programs. The notion of termination that we adopt is the very strong universal one, as it is known in logic programming [SD94]. This is abstractly achieved by means of a relation between goals or between goals and clause heads, namely ‘≺’, with the intended meaning of “G_{1} [G] can arise as a subgoal of G_{2} [D]”. Intuitively, a program terminates if it yields an ordering relation which admits no infinite descending chains. This is defined in Figure 6.6. We do not commit here to actual ways to verify the latter property. This issue is explored, in the higher-order setting, for example in [RP96]. More formally:

Ordering R ::= · | R, G ≺ D | R, G_{1} ≺ G_{2}

Let P ⟹^{D} R and take the stable (that is, closed under substitutions) and transitive closure of R, call it [R]. We say that P is terminating, denoted P ↓, whenever [R] is well-founded.

Example 6.15 If even defines the even number, even⟹^{D} even(X) ≺ even(s(s(X))). Furthermore the closure of this relation is well-founded as it can be proven say by induction on X. Consider instead the following:

∀E:exp. ∀M:nat.
p (lam E) M
← (∀x:exp. (∀N:nat. p x (s N) ← p x (s N)) → p (E x) M).

The clause is not terminating as the subgoal relation contains the pair [y/x](p x s(N) ≺ p x s(N)), which yields an infinite descending chain (p y (s 0)) ≺ (p y (s 0)) ≺ . . ..

Finally^{3}, we define when a schema is terminating:

\frac{∘ ↓}{∘ ↓}  \begin{aligned}Γ ⊢ D ↓  S ↓ \\ & ∥ ↓ \\ S∥Γ; SOME Φ. D ↓ \end{aligned}

Since Φ ranges over F V (D) \ Γ, we verify the termination of D in the Γ context.

Lemma 6.16

1. If Γ ⊢ D ⟹^{D} R and D ⊑ D such that Γ ⊢ D ⟹^{D} R′, then R′ ⊆ R.

2. If Γ ⊢ G ⟹^{G} R, G′ ≺ G and Γ ⊢ G′ ⟹^{G} R′, then R′ ⊆ R.

Proof: By a straightforward mutual induction on the structure of Γ ⊢ D ⟹^{D} R′ and Γ ⊢ G′ ⟹^{G} R′. □

Corollary 6.17 If Γ ⊢ D ↓ and D ⊑ D, then D ↓.

Proof: By definition, Γ ⊢ D ↓ if Γ ⊢ D ⟹^{D} R and [R] is well-founded; by Lemma 6.16 Γ ⊢ D ⟹^{D} R′, and R′ ⊆ R. Thus [R′] is well-founded, and D ↓. □

Lemma 6.18 Let S ↓. If Γ; D < S and D ⊑ D, then D ↓.

Proof: By induction on the structure of S ↓, using Corollary 6.17. □

We can now prove that if a program is terminating, a non-proof of any ground G is a denial of G; we are going to reason classically that either there is a proof of G, or there is not such a proof. We recall that ⊬_{P} is the denial relation introduced in Figure 6.1 and 6.2.

Theorem 6.19 (Termination) Let P ↓ and S ↓ be a schema such that ⊧_{S} P and Γ; D < S: for any ground G, if not Γ; D ⊢_{P} G, then Γ; D ⊬_{P} G.

Proof: We generalize this to:

1. If not Γ; D ⊢_{P} G, then Γ; D ⊬_{P} G.

2. For every D ⊑ P ∧ D, if not Γ; D ⊢_{P} D>>Q, then Γ; D ⊬_{P} D>>Q.

3ADDED

Draft of July 6, 2000

X ∈ {Q, ⊤, ⊥} or (dis)eq

⟹^{G} X

Γ ⊢ X ⟹^{G} ·

Γ ⊢ G ⟹^{G} R_{1} Γ ⊢ D ⟹^{D} R_{2}

⟹^{G}→

Γ ⊢ D → G ⟹^{G} R_{1}, R_{2}, G ≺ D → G

Γ, y:A ⊢ G ⟹^{G} R

⟹^{G} ∀^{y}

Γ ⊢ ∀x:A. G ⟹^{G} R, [y/x]G ≺ ∀x:A. G

Γ ⊢ G_{1} ⟹^{G} R_{1} Γ ⊢ G_{2} ⟹^{G} R_{2}

⟹^{G} ∧

Γ ⊢ G_{1} ∧ G_{2} ⟹^{G} R_{1}, R_{2}, G_{1} ≺ G_{1} ∧ G_{2}, G_{2} ≺ G_{1} ∧ G_{2}

Γ ⊢ G_{1} ⟹^{G} R_{1} Γ ⊢ G_{2} ⟹^{G} R_{2}

⟹^{G} ∨

Γ ⊢ G_{1} ∨ G_{2} ⟹^{G} R_{1}, R_{2}, G_{1} ≺ G_{1} ∨ G_{2}, G_{2} ≺ G_{1} ∨ G_{2},

X ∈ {Q, ⊤, ⊥}

⟹^{D} X

Γ ⊢ X ⟹^{D} ·

Γ ⊢ D ⟹^{D} R_{1} Γ ⊢ G ⟹^{G} R_{2}

⟹^{D}→

Γ ⊢ (G → D) ⟹^{D} R_{1}, R_{2}, G ≺ D

Γ ⊢ [u/x]D ⟹^{D} R

⟹^{D} ∀^{u}

Γ ⊢ ∀x:A. D ⟹^{D} R

Γ ⊢ D_{1} ⟹^{D} R_{1} Γ ⊢ D_{2} ⟹^{D} R_{2}

⟹^{D} ∧

Γ ⊢ D_{1} ∧ D_{2} ⟹^{D} R_{1}, R_{2}

Γ ⊢ D_{1} ⟹^{D} R_{1} Γ ⊢ D_{2} ⟹^{D} R_{2}

⟹^{D} ∨

Γ ⊢ D_{1} ∨ D_{2} ⟹^{D} R_{1}, R_{2}

Figure 6.6: Generation of the subgoal relation We proceed by mutual induction on the goal ordering induced by P terminating and on the structure of D: we start with 2. Since D is an instance of a terminating clause either from the program or the run-time context, by stability and Corollary 6.18, it is terminating as well.

Draft of July 6, 2000

Case: D = ⊥: trivial.

Case: D = ⊤.

\frac{>>⊤}{Γ; D ⊬_{P} ⊤>>Q}

Case: D = D_{1} ← G_{1}. Either Γ; D ⊢_{P} G_{1} or not Γ; D ⊢_{P} G_{1} and Γ; D ⊢_{P} D_{1}>>Q or not Γ; D ⊢_{P} D_{1}>>Q. By termination of D_{1} ← G_{1}, G_{1} ≺ D_{1}, hence we can apply the IH to G_{1}: There are four sub-cases:

1. Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊢_{P} D_{1} ← G_{1}>>Q  By rule >> →
2. Not Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊬_{P} G_{1}  By IH 1
Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊬_{P} D_{1} ← G_{1}>>Q  By rule >> →_{2}
3. Γ; D ⊢_{P} G_{1}  Subcase
Not Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊬_{P} D_{1}>>Q  By IH 2
Γ; D ⊬_{P} D_{1} ← G_{1}>>Q  By rule >> →_{1}
4. Not Γ; D ⊢_{P} G_{1}  Subcase
Not Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊬_{P} D_{1}>>Q  By IH 2
Γ; D ⊬_{P} D_{1} ← G_{1}>>QBy rule  By rule >> →_{1}

Case: D = D_{1} ∨ D_{2}.

1. Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊢_{P} D_{2}>>Q  Subcase
Γ; D ⊢_{P} D_{1} ∨ D_{2}>>Q  By rule >>∨
2. Γ; D ⊢_{P} D_{1}>>Q  Subcase
Not Γ; D ⊢_{P} D_{2}>>Q  Subcase
Γ; D ⊬_{P} D_{2}>>Q  By IH 2
Γ; D ⊬_{P} D_{1} ∨ D_{2}>>Q  By rule
3. Γ; D ⊢_{P} D_{2}>>Q  Subcase
Not Γ; D ⊬_{P} D_{1}>>Q  Subcase
Γ; D ⊬_{P} D_{1}>>Q  By IH 2
Γ; D ⊬_{P} D_{1} ∨ D_{2}>>Q  By rule
4. Not Γ; D ⊢_{P} D_{1}>>Q  Subcase
Not Γ; D ⊢_{P} D_{2}>>Q  Subcase
Γ; D ⊬_{P} D_{1}>>Q  By IH 2
Γ; D ⊬_{P} D_{2}>>Q  By IH 2
Γ; D ⊬_{P} D_{1} ∨ D_{2}>>Q  By rule

Case: D = D_{1} ∧ D_{2}.

1. Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊢_{P} D_{2}>>Q  Subcase
Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q  By rule >>∧

2. Γ; D ⊢_{P} D_{1}>>Q  Subcase
Not Γ; D ⊢_{P} D_{2}>>Q  Subcase
Γ; D ⊬_{P} D_{2}>>Q  By IH 2
Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q  By rule
3. Γ; D ⊢_{P} D_{2}>>Q  Subcase
Not Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊬_{P} D_{1}>>Q  By IH 2
Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q  By rule
4. Not Γ; D ⊢_{P} D_{1}>>Q  Subcase
Γ; D ⊬_{P} D_{1}>>Q  By IH 2
Not Γ; D ⊢_{P} D_{2}>>Q  Subcase
Γ; D ⊬_{P} D_{2}>>Q  By IH 2
Γ; D ⊬_{P} D_{1} ∧ D_{2}>>Q  By rule

Case: D = ∀x : A. D′. For some ground Γ ⊢ t : A, Γ; D ⊢_{P} [t/x]D′>>Q or for all ground t, not Γ; D ⊢_{P}

[t/x]D′>>Q:

1. Γ; D ⊢_{P} [t/x]D′>>Q  Subcase
Γ; D ⊢_{P} ∀x:A. D′>>Q  By rule >>∀
2. For all t ground not Γ; D ⊢_{P} [t/x]D′>>Q  Subcase
For all t ground Γ; D ⊬_{P} [t/x]D′>>Q  By IH 2
Γ; D ⊬_{P} ∀x:A. D′>>Q  By rule

Case: G = ⊤: trivially true. Case: G = ⊥:

\frac{⊬ ⊥}{Γ; D ⊬_{P} ⊥}

Case: G = Q: either Γ; D ⊢_{P} P ∧ D>>Q or for not Γ; D ⊢_{P} P ∧ D>>Q:

1. Γ; D ⊢_{P} P ∧ D>>Q  Subcase
Γ; D ⊢_{P} Q  By rule
2. Not Γ; D ⊢_{P} P ∧ D>>Q  Subcase
Γ; D ⊬_{P} P ∧ D>>Q  By IH 2
Γ; D ⊬_{P} Q  By rule

Case: G = G_{1} ∧ G_{2}:

1. Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊢_{P} G_{2}  Subcase
Γ; D ⊢_{P} G_{1} ∧ G_{2}  By rule
2. Γ; D ⊢_{P} G_{1}  Subcase
Not Γ; D ⊢_{P} G_{2}  Subcase
Γ; D ⊬_{P} G_{2}  By IH 1
Γ; D ⊬_{P} G_{1} ∧ G_{2}  By rule
3. Γ; D ⊢_{P} G_{2}  Subcase
Not Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊬_{P} G_{1}  By IH 1
Γ; D ⊬_{P} G_{1} ∧ G_{2}  By rule
4. Not Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊬_{P} G_{1}  By IH 1
Not Γ; D ⊢_{P} G_{2}  Subcase
Γ; D ⊬_{P} G_{2}  By IH 1
Γ; D ⊬_{P} G_{1} ∧ G_{2}  By rule

Draft of July 6, 2000

6.4. COMPLEMENTABLE CLAUSES  99

Case: G = G_{1} ∨ G_{2}:

1. Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊢_{P} G_{2}  Subcase
Γ; D ⊢_{P} G_{1} ∨ G_{2}  By rule
2. Γ; D ⊢_{P} G_{1}  Subcase
Not Γ; D ⊢_{P} G_{2}  Subcase
Γ; D ⊬_{P} G_{2}  By IH 1
Γ; D ⊢_{P} G_{2} ∨ G_{1}  By rule
3. Γ; D ⊢_{P} G_{2}  Subcase
Not Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊬_{P} G_{1}  By IH 1
Γ; D ⊢_{P} G_{2} ∨ G_{1}  By rule
4. Not Γ; D ⊢_{P} G_{1}  Subcase
Γ; D ⊬_{P} G_{1}  By IH 1
Not Γ; D ⊢_{P} G_{2}  Subcase
Γ; D ⊬_{P} G_{2}  By IH 1
Γ; D ⊬_{P} G_{1} ∨ G_{2}  By rule

Case: G = ∀x:A. G′: for a new parameter y, (Γ, y:A); D ⊢_{P} [y/x]G′ or not (Γ, y:A); D ⊢_{P} [y/x]G′:

1. (Γ, y:A); D ⊢_{P} [y/x]G′  Subcase
Γ; D ⊢_{P} ∀x:A. G′  By rule
2. Not (Γ, y:A); D ⊢_{P} [y/x]G′  Subcase
(Γ, y:A); D ⊢_{P} [y/x]G′  By IH 1
Γ; D ⊬_{P} ∀x:A. G′  By rule

Case: G = D′ → G′:

1. Γ; (D ∧ D′) ⊢_{P} G′  Subcase
Γ; D ⊢_{P} D′ → G′  By rule
2. Not Γ; (D ∧ D′) ⊢_{P} G′  Subcase
Γ; (D ∧ D′) ⊬_{P} G′  By IH 1
Γ; D ⊬_{P} D′ → G′  By rule

Case: The (dis)equality case follows immediately from the decidability of the =^{·}, ≠^{·} rules.

□

6.4 Complementable Clauses

We restrict ourselves to programs with:

• Complementable clauses as defined in Figure 6.7.

• Rules of the form ∀(Q ← G), such that every (input) term in Q is rigid.

• Parameters of base type and occurring only in head position, called Shallow Parameter Expressions:

SPE e_{x} ::= x : a | λx . e_{x}

We do not formalize here the former assumptions on terms; note that the rigidity restriction applies only to predicates mutually recursive to non-Horn ones – see the comment at the end of the proof of Theorem 6.34.

Draft of July 6, 2000

100  CHAPTER 6. CLAUSE COMPLEMENTATION
X ∈ {⊤, ⊥} or (dis)eq
cg X
Γ; D ⊢ X compl
\frac{cgAt}{Γ; ⊤ ⊢ Q compl}

for all D ⊑ D : dom(Γ) ∩ par(D) ≠ ∅

cgAt∩

Γ; D ⊢ Q compl

Γ; (D ∧ D) ⊢ G compl Γ; D ⊢ D compl

cg →

Γ; D ⊢ D → G compl
(Γ, y:a); D ⊢ [y/x]G compl

cg∀^{y}

Γ; D ⊢ ∀x:a. G compl

Γ; D ⊢ G_{1} compl Γ; D ⊢ G_{2} compl

cg∧

Γ; D ⊢ G_{1} ∧ G_{2} compl

Γ; D ⊢ G_{1} compl Γ; D ⊢ G_{2} compl

cg∨
Γ; D ⊢ G_{1} ∨ G_{2} compl
X ∈ {⊤, ⊥}

cd X Γ; D ⊢ X compl

Γ; D ⊢ D compl Γ; D ⊢ G compl

cd ← Γ; D ⊢ D ← G compl

Γ; D ⊢ [u/x]D compl

cd∀^{u} Γ; D ⊢ ∀x:A. D compl

Γ; D ⊢ D_{1} compl Γ; D ⊢ D_{2} compl

cd∧ Γ; D ⊢ D_{1} ∧ D_{2} compl

Γ; D ⊢ D_{1} compl Γ; D ⊢ D_{2} compl

cd∨ Γ; D ⊢ D_{1} ∨ D_{2} compl

Figure 6.7: Complementable clause and goal: Γ; D ⊢ D compl and Γ; D ⊢ G compl Example 6.20 The clause encoding the introduction rule for implication in natural deduction from Example 5.1 is not complementable:

Draft of July 6, 2000

impi : nd(A imp B) ← (nd(A) → nd(B)).

On the other hand, the following is allowed by rule At:

oplam^{⊤} : ∀E:exp → exp. open (lam E)
← (∀x:exp. ⊤_{open} → open (E x)).

The restriction on goal and clause yields this revised grammar:

Clauses D ::= ⊤ | ⊥ | ∀(Q ← G) | D_{1} ∧ D_{2} | D_{1} ∨ D_{2}
Goals G ::= Q | ⊤ | ⊥ | M⃗ =^{·} N⃗ | M⃗ ≠^{·} N⃗ |
G_{1} ∧ G_{2} | G_{1} ∨ G_{2} | D → G | ∀x:a. G

We use ∀(Q ← G) as a normal form for ‘rules’, where the quantifier bounds every free variable in Q ← G. This has the technical advantage to provide a handle for both the head of a clause and the set of all its free variables at the same time, which will be crucial to describe the complement algorithm. In particular, ‘facts’ are represented by ∀(Q) ← ⊤, although in examples we will omit to mention the body. We accordingly specialize the immediate implication and denial rules as follows:

Γ ⊢ σ : F V (N⃗) \ Γ  Γ; D ⊢_{P} [σ]N⃗ =^{·} M⃗  Γ; D ⊢_{P} [σ]G
>> →
Γ; D ⊢_{P} ∀(q N⃗ ← G)>>q M⃗

for all θ Γ ⊢ θ : F V (N⃗) \ Γ Γ; D ⊬_{P} [θ]N⃗ =^{·} M⃗

≯>→_{1}
Γ; D ⊬_{P} ∀(q N⃗ ← G)>>q M⃗
Γ ⊢ σ : F V (N⃗) \ Γ  Γ; D ⊬_{P} [σ]N⃗ ≠^{·} M⃗  ⊬_{P} [σ]G
≯>→_{2}
Γ; D ⊬_{P} ∀(q N⃗ ← G)>>q M⃗

We remark that the ‘guards’ in the immediate denial rules are constructed so as to make the positive and negative judgment mutually independent. Thus ≯> →_{1} says that a clause ∀(q N⃗ ← G) denies a goal q M⃗ if for all well-typed substitutions θ [θ]N⃗ and M⃗ clashes. Rule ≯> →_{2} instead attributes denial with the same conclusion due to ‘failure’ in the body.

Clause complementation is takes definition-wise. We cluster a program in a conjunction of possibly mutually recursive predicate definitions; We accomplish this with the following:

Definition 6.21 (Γ ⊢ def(q, D))

Γ ⊢ def(q, ⊤) = ⊤_{q}
Γ ⊢ def(q, ⊥) = ⊥_{q}
Γ ⊢ def(q, ∀(Q ← G)) = ∀(Q ← G)  if Q ≡ q M⃗
Γ ⊢ def(q, ∀(Q ← G)) = ⊤_{q}  otherwise
Γ ⊢ def(q, D_{1} ∧ D_{2}) = Γ ⊢ def(q, D_{1}) ∧ Γ ⊢ def(q, D_{2})
Γ ⊢ def(q, D_{1} ∨ D_{2}) = Γ ⊢ def(q, D_{1}) ∨ Γ ⊢ def(q, D_{2})

If D = P, i.e. the underlying program (seen as a conjunction of clauses), we call · ⊢ def(q, P) the static definition of q and avoid mentioning the parameter context when it can be inferred from the context. If Γ; D is a conjunction of a run-time context, we call the latter the dynamic definition of q. As a special case, an undefined predicate q, i.e. a predicate which occurs in a body of a clause but not as a head is represented by the empty conjunction ⊤_{q}. Conversely ⊥_{q} denotes the universal definition for q. We agree to consider ⊤_{q} (⊥_{q} resp. ) as the zero (one) element for conjunction and disjunction and implicitly apply the appropriate absorption operations; for example:

⊤_{q} ∧ ∀(q M⃗ ← G) = ∀(q M⃗ ← G)

. We overload the notation D ⊑ D in the case D ⊑ Γ ⊢ def(q, P ∧ D) to indicate the relation that satisfies the following rules:

\frac{D ∈ \{⊤, ⊥, ∀(Q ← G)\}}{D ⊑ D}  \frac{D_{1} ⊑ D  D_{2} ⊑ D}{D_{1} ∧ D_{2} ⊑ D}  \frac{D_{1} ⊑ D  D_{2} ⊑ D}{D_{1} ∨ D_{2} ⊑ D}

The immediate implication and denial judgments is specialized as obvious:

Γ; D ⊢_{P} D>>Q Clause D from Γ ⊢ def(q, P ∧ D) immediately entails atom Q.
Γ; D ⊬_{P} D>>Q Clause D from Γ ⊢ def(q, P ∧ D) immediately denies atom Q.

In particular, the ‘At’ rules are:

D ⊑ def(Q, P ∧ D) ⌈Γ⌉; ⌈D⌉ ⊢_{P} D>>Q
⊢ At Γ; D ⊢_{P} Q
D ⊑ def(Q, P ∧ D) ⌈Γ⌉; ⌈D⌉ ⊬_{P} D>>Q
⊬ At
Γ; D ⊬_{P} Q

Accordingly, we also specialized the rule for schema satisfaction: we use ρ to denote a global substitution, e.g. such that dom(ρ) is a set of new global parameters.

·; ⊤ \ [ρ]G < S
⊧_{S}→^{ρ}
⊧_{S} ∀(Q ← G)>>q M⃗

It is clear that all the above rules are derived rules of inference, as can be proven by a straightforward induction on the number of free variables in N⃗.

6.4.1 Normalization of Input Variables

We present in Figure 6.8 the rules for normalization of input variables. Since we are currently working with the restriction to ground goals, those are all the variables which are universally quantified in the head of a clause. When they occur positively in dynamic assumptions, they will carry some instantiation. It helps to simplify the presentation of the clause complementation algorithm if we forbid this kind of occurrence. The idea it to replace every positive occurrence of an input variable in an assumption with a new (local) universal variable, which is then constrained to be equal to the input ones.

Example 6.22 Consider the typing clause for lambda terms:

oflam : ∀E:exp → exp. ∀T_{1}, T_{2} :tp.
of (lam E) (arrow T_{1} T_{2})
← (∀x:exp. of x T_{1} → of (E x) T_{2}).

As T_{1} is an input term occurring positively in the assumption ‘of x T_{1}’, normalization of input variables inserts a new variable T and constrains it to be equal to T_{1}:

oflam′ : ∀E:exp → exp. ∀T_{1}, T_{2} :tp.
of (lam E) (arrow T_{1} T_{2})

(∀T:tp. of x T ← T =^{·} T_{1}) →

of (E x) T_{2}).

This procedure is realized by the judgments:

• D ↦^{D} D′: clause normalization.

• Γ ⊢_{Φ} G ↦^{G} G′: goal normalization.

• Φ; Γ ⊢ D ↦ D′: assumption normalization w.r.t. global parameters in Φ.

• Λ; Φ; Γ ⊢ M ↦ M′, E: term M normalizes to term M′ returning a conjunction of equations E w.r.t. bound (Γ), global (Φ) and existential (Λ) variables.

The first three judgments simply recur on the structure of clauses, goal and assumptions, keeping track of bound, global and existential variables in assumptions, until we normalize an assumption ∀(Q ← G): here we descend in every term by introducing new local existential variable and binding them to the global one by an equation E. For the sake of conciseness, we do this for the simply-typed fragment; the generalization to the strict one is immediate. In rule ↦^{D}←^{ρ} we introduce in the global context all the global parameters in the domain of ρ with the appropriate typing.

It is clear, although very tedious, to verify that this transformation preserves provability and denial,

Lemma 6.23 Assume Λ; Φ; Γ ⊢ M ↦ M′, E; for every ground N, every Γ; D, Γ; D ⊢ M =^{·} N iff Γ; D ⊢

M′ =^{·} N ∧ E.

Proof: By a straightforward induction on the structure of Λ; Φ; Γ ⊢ M ↦ M′, E. □

Lemma 6.24 Let Γ ⊢ θ : Φ and Φ; Γ ⊢ D ↦ D′. For every D, it holds Γ; [θ]D ⊢ [θ]D>>Q iff Γ; [θ]D ⊢ [θ]D′>>Q.

Proof: By a straightforward induction on the structure of Φ; Γ ⊢ D ↦ D′, using Lemma 6.23. □

Theorem 6.25 Let Γ ⊢ θ : Φ D ↦^{D} D′ and Γ ⊢_{Φ} G ↦^{G} G′:

1. Γ; [θ]D ⊢ [θ]D>>Q iff Γ; [θ]D ⊢ [θ]D′>>Q.

2. Γ; [θ]D ⊢ [θ]G iff Γ; [θ]D ⊢ [θ]G′.

Proof: By a straightforward mutual induction on the structure of D ↦^{D} D′ and Γ ⊢_{Φ} G ↦^{G} G′, using Lemma 6.24. □

6.5 The Clause Complement Algorithm

We now introduce in Figure 6.9 and Figure 6.10 the rules for static and dynamic clause complementation. Consider a rule ∀(q M⃗ ← G); its complement must contain a ‘factual’ part motivating failure due to clash with the head; the remainder Not_{G}(G) expresses failure in the body, if any. Clause complementation must discriminate whether this rule belongs to the static or dynamic definition of a predicate. In the first case all the relevant information is already present in the head of the clause and we can use the term complementation algorithm described in Chapter 4. This is accomplished by the rule Not_{D} →, where a set of negative facts is built via term complementation Not(M⃗) applied in the empty context to the (vector of) terms in the clause head; namely ⋀_{N⃗∈·⊢Not(M⃗)} ∀(¬(q N⃗) ← ⊤); moreover the negative counterpart of the source clause is obtained via complementation of the body. The Partition Lemma (Corollary 4.21) guarantees the soundness and completeness of this case.

Assumption complementation is realized by the judgment Γ ⊢ Notα(D), which can be seen as a type directed parameter-conscious version of clause complementation. In a first approximation, we can think of complementation of assumptions, which are by definition parametric in some x, as static clause complementation w.r.t. x. Informally, for an atomic assumption, say q M_{1} … M_{i−1} e_{x} M_{i+1} … M_{n}, its complement can be taken as Not_{D}(q_{e_{x}} M_{1} … M_{i−1} M_{i+1} … M_{n}). This is accomplished in two phases: first, e_{x} is propagated in every position 1 ≤ i ≤ n holding a rigid term of compatible type, but different from e_{x} itself. This alone builds an element of the complement set. Secondly, the idea is to can apply term complementation ‘around’ e_{x}. In particular, if M_{i} is a variable, by normalization of input variables, it must be a local one and term complement does not contribute anything as expected. If M_{i} is a parameter expression or a compound term,

104  CHAPTER 6. CLAUSE COMPLEMENTATION
\begin{aligned}D_{1} ↦^{D} D′_{1}  D_{2} ↦^{D} D′_{2} \\ & ↦^{D} ∧ \\ D_{1} ∧ D_{2} ↦^{D} D′_{1} ∧ D′_{2} \end{aligned}  \begin{aligned}D_{1} ↦^{D} D′_{1}  D_{2} ↦^{D} D′_{2} \\ & ↦^{D} ∨ \\ D_{1} ∨ D_{2} ↦^{D} D′_{1} ∨ D′_{2} \end{aligned}
\begin{aligned}X ∈ \{⊤, ⊥\} \\ & ↦^{D} X \\ X ↦^{D} X \end{aligned}  \begin{aligned}· ⊢_{dom(ρ)} [ρ]G ↦^{G} [ρ]G′ \\ & ↦^{D}←^{ρ} \\ ∀(Q ← G) ↦^{D} ∀(Q ← G′) \end{aligned}
X ∈ {⊤, ⊥, Q} or (dis)eq

↦^{G} X

Γ ⊢_{Φ} X ↦^{G} X

\begin{aligned}Γ, y:A); D ⊢_{Φ} [y/x]G ↦^{G} [y/x]G′ \\ & ↦^{G} ∀^{y} \\ Γ ⊢_{Φ} ∀x:a. G ↦^{G} ∀x:a. G′ \end{aligned}

Φ; Γ ⊢ D ↦ D′ Γ; D ∧ D ⊢_{Φ} G ↦^{G} G′

↦^{G}→

Γ ⊢_{Φ} (D → G) ↦^{G} (D′ → G′)

\begin{aligned}Γ ⊢_{Φ} G_{1} ↦^{G} G′_{1}  Γ ⊢_{Φ} G_{2} ↦^{G} G′_{2} \\ & ↦^{G} ∧ \\ Γ ⊢_{Φ} G_{1} ∧ G_{2} ↦^{G} G′_{1} ∧ G′_{2} \end{aligned}  \begin{aligned}Γ ⊢_{Φ} G_{1} ↦^{G} G′_{1}  Γ ⊢_{Φ} G_{2} ↦^{G} G′_{2} \\ & ↦^{G} ∨ \\ Γ ⊢_{Φ} G_{1} ∨ G_{2} ↦^{G} G′_{1} ∨ G′_{2} \end{aligned}
\frac{bv}{Λ; Φ; (Γ, x:A) ⊢ x ↦ x, ⊤}  \begin{aligned}Z new \\ & iv \\ Λ; (Φ, u:A); Γ ⊢ u ↦ Z, Z =^{·} u \end{aligned}  \frac{lv}{(Λ, x:A); Φ; Γ ⊢ x ↦ x, ⊤}
Λ; Φ; Γ ⊢ M_{1} ↦ M′_{1}, E_{1} Λ; Φ; Γ ⊢ M_{2} ↦ M′_{2}, E_{2}
App
Λ; Φ; Γ ⊢ M_{1} M_{2} ↦ M′_{1} M′_{2}, E_{1} ∧ E_{2}

\begin{aligned}Λ; Φ; (Γ, x:A) ⊢ M ↦ M′, E \\ & λ \\ Λ; Φ; Γ ⊢ λx:A. M ↦ λx:A. M′, E \end{aligned}

Λ = F V (\overline{M_{n}}) \ (Γ ∪ Φ) Λ; Φ; Γ ⊢ M_{1} ↦ M′_{1}, E_{1} … Λ; Φ; Γ ⊢ M_{n} ↦ M′_{n}, E_{n} ↦→

Φ; Γ ⊢ ∀(q \overline{M_{n}} ← G) ↦ ∀(q \overline{M′_{n}} ← E_{1} ∧ … ∧ E_{n} ∧ G)

X ∈ {⊤, ⊥}

↦ X Φ; Γ ⊢ X ↦ X

\begin{aligned}Φ; Γ ⊢ D_{1} ↦ D′_{1} Φ; Γ ⊢ D_{2} ↦ D′_{2} \\ & ↦ ∧ \\ Φ; Γ ⊢ D_{1} ∧ D_{2} ↦ D′_{1} ∧ D′_{2} \end{aligned} \begin{aligned}Φ; Γ ⊢ D_{1} ↦ D′_{1} Φ; Γ ⊢ D_{2} ↦ D′_{2} \\ & ↦ ∨ \\ Φ; Γ ⊢ D_{1} ∨ D_{2} ↦ D′_{1} ∨ D′_{2} \end{aligned}

Figure 6.8: Clause, goal, assumption and term normalization

Draft of July 6, 2000

\frac{Not_{D}⊤}{Not_{D}(⊤) = ⊥}  \frac{Not_{D}⊥}{Not_{D}(⊥) = ⊤}
· ⊢ Not_{G}(G) = G′

Not_{D} ←

Not_{D}(∀(q M⃗ ← G)) = ⋀_{N⃗∈·⊢Not(M⃗)} ∀(¬(q N⃗) ← ⊤) ∧ ∀(¬q M⃗ ← G′)

Not_{D}(D_{1}) = D′_{1} Not_{D}(D_{2}) = D′_{2}
Not∧
Not_{D}(D_{1} ∧ D_{2}) = D′_{1} ∨ D′_{2}
Not_{D}(D_{1}) = D′_{1} Not_{D}(D_{2}) = D′_{2}
Not∨
Not_{D}(D_{1} ∨ D_{2}) = D′_{1} ∧ D′_{2}

Figure 6.9: Clause Complementation: Not_{D}(D) = D′

we simply take the term complement of the former term, with the notable difference of passing the current parameter context to term complement.

However, not all parameters are born alike; in many situations, a parametric judgment is used simply to descend into a scoping construct, while the parameter itself does not play a role w.r.t. provability and denial. Consider, for example, the following program that checks whether a universal formula is a D-clause:

form, term : type.
all : (term → form) → form).
isd : form → o
isdall : ∀D:term → form. isd (all D)
← ∀x:term. isd (D x).

This phenomenon is known in the literature under the name of subordination and has been extensively studies in the dependent typed context [Vir99]. In the simply typed setting, this relation collapses to merely checking whether the type of the parameters is equal to the target type of some argument of the predicate. More formally, we say that x:A is relevant to Q if head(Q) ≡ q, Σ(q) = A_{1}, …, A_{n} → o and for some 1 ≤ i ≤ n it holds that target(A_{i}) ≡ A; we denote this with xR^{i}q. In the above example, as term ≢ form, then x : term is not relevant to isd : form → o. Wrt. clause complementation, if the parameter x is not relevant to q, we do not need to build complementary facts out of it, although they would not impact soundness, i.e. Exclusivity (Theorem 6.34).

We concentrate on rules Notα⊤ and Notα →. The notation [e_{x}/Z_{i}]\overline{Z_{n}} is an abbreviation for Z_{1} … Z_{i−1} e_{x} Z_{i+1} … Z_{n}, where the Z’s are fresh logic variables; similarly for [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}}. The main loop goes as follows:

• Choose a parameter x:a ∈ Γ.

• Propagate e_{x} in every ‘odd’ position.

• Locate a type A_{i} such that x is relevant to Q at i:

– Complement D w.r.t. x and i.

– Repeat for every relevant position i.

• Repeat for every x.

106  CHAPTER 6. CLAUSE COMPLEMENTATION

\frac{Notα⊥}{Γ ⊢ Notα(⊥) = ⊤}

Σ(q) = A_{1} → ⋯ → A_{n} → o

Notα⊤

Γ ⊢ Notα(⊤_{q}) = ⋀_{x∈dom(Γ)}( ⋀_{1≤i≤n,xR^{i}q} Not_{x}^{C}(⊤_{q}))

Γ ⊢ Not_{G}(G) = G′

Notα ←

Γ ⊢ Notα(∀(q \overline{M_{n}} ← G)) = ( ⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{M_{n}}) ∧ ( ⋀_{1≤i≤n,xR^{i}q} Γ ⊢ Not_{x}^{i}(q \overline{M_{n}}))) ∧ ∀(¬q \overline{M_{n}}) ← G′)

Γ ⊢ Notα(D_{1}) = D′_{1} Γ ⊢ Notα(D_{2}) = D′_{2}

Not∧

Γ ⊢ Notα(D_{1} ∧ D_{2}) = D′_{1} ∨ D′_{2}

Γ ⊢ Notα(D_{1}) = D′_{1} Γ ⊢ Notα(D_{2}) = D′_{2}

Not∨
Γ ⊢ Notα(D_{1} ∨ D_{2}) = D′_{1} ∧ D′_{2}

M_{i} : A_{i} rigid, · ⊢ sh(x, A_{i}) = e_{x}, M_{i} ≢ e_{x}

Not_{x}^{C}

Not_{x}^{C}(q \overline{M_{n}}) = ⋀_{1≤i≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{i}]\overline{Z_{n}}

M_{i} ≡ e_{x}

Not_{x}^{i}

Γ ⊢ Not_{x}^{i}(q \overline{M_{n}}) = ⋀_{1≤j≤n}^{j≠i}( ⋀_{N∈(Γ⊢Not(M_{j}))}(∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}}))

\frac{e_{x}At}{Γ ⊢ sh(x, a) = x}  \begin{aligned}Γ, y:A ⊢ sh(x, B) = e_{x} \\ & e_{x} →^{y} \\ Γ ⊢ sh(x, A → B) = λy:A. e_{x} \end{aligned}

Figure 6.10: Assumption complementation: Γ ⊢ Notα(D) = D′

Draft of July 6, 2000

Rule Notα → is the most complicated one: fixed a parameter x, there are two ways in which an atomic assumption q M_{1} … M_{i−1} e_{x} M_{i+1} … M_{n}, needs to be complemented. First, any atom with same head with a term N_{j} ≡ e_{x} for i ≠ j is in the complement of the former. Moreover, since they do differ in one coordinate, we may as well leave open every other term. This is encoded in rule Not_{x}^{C}. Of course, we have to make sure that N_{j} is not flex and that the type is appropriate. Since x is passed as a parameter, the Γ ⊢ sh(x, A) judgment builds a shallow parameter expression as required by the type of the position in q where it ought to occur.

Secondly, we have to take into account the case M_{i} ≡ e_{x}: here we can build a set of complementary facts by pivoting on e_{x} and making another position different. Luckily, we can achieve this via a call to term complementation and build a set of complementary facts similarly to clause complementation. The difference is that we pass to term complementation, as a context, the set of parametric bound variables. Finally, both processes are repeated for every M_{i}.

Notice the different treatment of the trivial clause ⊤ by rules Not_{D}⊤ and Notα⊤: if no parameter has been assumed, then ⊤ truly stands for the empty predicate definition and its complement is the universal definition ⊥. If, on the other side Γ is not empty, it means that ⊤_{q} has been introduced during the ⊤- normalization preprocessing phase and has been localized to the predicate q. Here we need to construct a new negative assumption w.r.t. q, x, i in case ⊤_{q} is the only dynamic definition of q. As ⊤_{q} carries no information at all concerning q, the most general negative assumption is added. This is accomplished again by rule Not_{x}^{C}, where we make the convention to view ⊤_{q} as a degenerate case of q \overline{M_{n}} where the sequence \overline{M_{n}} is empty (and thus the condition trivially satisfied).

The remaining (common) rules for static and dynamic clause complementation simply recur on the program respecting the duality of conjunction and disjunction w.r.t. negation. This a somewhat delicate point and therefore we discuss it in some details. Intuitively, negative clauses stemming from the complement of a clause in the definition of a predicate need to be considered simultaneously. In fact, if an goal is unprovable from its definition, then its negation must be provable from the complement of each clause of its definition; symmetrically if it is provable then its negation must be unprovable from the complement of at least one. What we have described coincides the operational semantics of an operator, which works exactly as disjunction. This is arguably at odd with the commonly held goal-oriented interpretation of the sequent calculus as uniform proofs, since case analysis makes the latter incomplete w.r.t. minimal logic (but see [NL95] for ways to incorporate the former in the framework of uniform proofs). In Section 6.9.2 we will show how to ‘compile away’ all occurrences of ∨ in clauses. This is an higher-order equivalent of the intersection operator ‘@’ described in [BMPT90] and will restore completeness of uniform proofs

Goal complementation, that is the judgment Not_{G}(G) depicted in Figure 6.11 is straightforward, since it only brings the body into a normalized format; namely, in what we may call parametric negation normal form, to stress the distinction from classical negation normal form or even from negation normal form in constructive logics as extension of intuitionism with strong negation [Nel49]. This re-iterates the problem with strong negation we have hinted in Section 5.3; negation is pushed inward but jumps over parametrichypothetical judgments to respect the operational interpretation of unprovability.

As a final remark, we note again that we must take the complementation of a program, seen as a conjunction, predicate definition-wise rather that clause-wise. In fact, it would be incorrect to simply negate a program as it would introduce disjunctions rather than conjunction among predicate definitions. The same remark applies to the ‘dynamic’ program D. Formally, given a fixed signature Σ_{P} and a program P:

Not_{D}(P) = ⋀_{q∈Σ_{P}} Not_{D}(def(q, P))

Similarly for a (possibly run-time) context^{4}Γ; D:

Γ ⊢ Notα(D) = ⋀_{q∈Σ_{P}} Γ ⊢ Notα(def(q, D))

Note that if Γ; D is a run-time context, it consists of a conjunction of blocks, i.e. it has the form Γ′′, ⌈Γ′⌉; D′′ ∧ ⌈D′⌉; in this case the definition of q consists of the conjunction of the definition for every

4FIXED

Draft of July 6, 2000

\frac{Not_{G}⊤}{Γ ⊢ Not_{G}(⊤) = ⊥}  \frac{Not_{G}⊥}{Γ ⊢ Not_{G}(⊥) = ⊤}

\frac{Not =^{·}}{Γ ⊢ Not_{G}(M⃗ =^{·} N⃗) = (M⃗ ≠^{·} N⃗)}  \frac{Not ≠^{·}}{Γ ⊢ Not_{G}(M⃗ ≠^{·} N⃗) = (M⃗ =^{·} N⃗)}

\frac{Not_{G}At}{Γ ⊢ Not_{G}(Q) = ¬Q}

Γ, y:a ⊢ Not_{G}([y/x]G) = [y/x]G′
Not_{G}∀^{y}
Γ ⊢ Not_{G}(∀x:a. G) = ∀x:a. G′

Γ ⊢ Not_{G}(G_{1}) = G′_{1} Γ ⊢ Not_{G}(G_{2}) = G′_{2}

Not∧
Γ ⊢ Not_{G}(G_{1} ∧ G_{2}) = G′_{1} ∨ G′_{2}

Γ ⊢ Not_{G}(G_{1}) = G′_{1} Γ ⊢ Not_{G}(G_{2}) = G′_{2}

Not∨
Γ ⊢ Not_{G}(G_{1} ∨ G_{2}) = G′_{1} ∧ G′_{2}

Γ ⊢ Not_{G}(G) = G′

Not_{G} →
Γ ⊢ Not_{G}(D → G) = D → G′

Figure 6.11: Goal complementation: Γ ⊢ Not_{G}(G) = G′

block, namely: Γ′ ⊢ def(q, D′)∧Γ′′ ⊢ def(q, D′′). We abbreviate Not_{D}(def(q)) in def(¬q). If P^{+} is the source program, we use P^{−} for Not_{D}(P).

Finally, we provide an example, which, even though is somewhat a special case of the general procedure, assumption complementation being trivial, it helps to clarify the rules for clause and goal complementation in isolation. We refer to the next Section (6.6) for more complex examples. We use ∀F_{1}, F_{2} : A. X as an abbreviation of ∀F_{1} :A. ∀F_{2} :A. X.

Example 6.26 A λ-expression is closed if it has no occurrence of free variables; let z : exp be a constant:

cloz : closed z.
clolam : ∀E:exp. closed (lam E) ← (∀x:exp. (closed x → closed (E x).)
cloapp : ∀E_{1} :exp. ∀E_{2} :exp. closed (app E_{1} E_{2}) ← closed E_{1} ∧ closed E_{2}.

Now, def(closed) = cloz ∧ clolam ∧ cloapp. Note that x:exp ⊢ Notα(closed x) = ⊤. Therefore:

def(¬closed) = Not_{D}(cloz) ∨ Not_{D}(clolam) ∨ Not_{D}(cloapp)

Not_{D}(cloz) = ⋀_{N∈Not(z)} ¬∀(closed N)
= (∀F:exp. ¬closed (lam F)) ∧ ∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2}).
Not_{D}(clolam) = ⋀_{N∈Not(lam E)} ∀(¬closed N) ∧
∀E:exp. ¬closed (lam E) ← Not_{G}(∀x:exp. (closed x → closed (E x))
= ¬closed z ∧ (∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2})) ∧
∀E:exp. ¬closed (lam E) ← (∀x:exp. (closed x → ¬closed (E x)).

\begin{aligned}X ∈ \{⊤, ⊥\} \\ & aug_{D}X \\ aug_{D}(X) = X \end{aligned}

aug_{D}(D_{1}) = D_{1}^{a} aug_{D}(D_{2}) = D_{2}^{a} aug_{D}∧

aug_{D}(D_{1} ∧ D_{2}) = D_{1}^{a} ∧ D_{2}^{a}

aug_{D}(D_{1}) = D_{1}^{a} aug_{D}(D_{2}) = D_{2}^{a} aug_{D}∨

aug_{D}(D_{1} ∨ D_{2}) = D_{1}^{a} ∨ D_{2}^{a}

Γ; D ⊢ aug_{G}([ρ]G) = [ρ]G^{a}
aug_{D} ←^{ρ}

aug_{D}(∀(Q ← G)) = ∀(Q ← G^{a})

Figure 6.12: Clause augmentation: aug_{D}(D) = D^{a}

Not_{D}(cloapp) = ⋀_{N∈Not(app E_{1} E_{2}))} ¬∀(closed N) ∧

∀E_{1}, E_{2} :exp. ¬closed (app E_{1} E_{2}) ← Not_{G}(closed E_{1} ∧ closed E_{2})

= ¬closed z ∧ (∀F:exp. ¬closed(lam F)) ∧

∀E_{1}, E_{2} :exp. ¬closed (app E_{1} E_{2}) ← ¬closed E_{1} ∨ ¬closed E_{2}.

If you want to see the definition simplified, please skip to Example 6.41 and the final result in Example 6.45.

6.6 Augmentation

Now that we have discussed how to perform clause, assumption and goal complementation, we synchronize it together in a phase we call augmentation, which simply inserts the correct assumption complementation in a goal and in turn in a clause. We give one judgment to augment a program, aug_{D}(D), depicted in 6.12. which merely recurs on the structure of clauses until it calls goal augmentation, Γ; D ⊢ aug_{G}(G) (Figure 6.12). The latter traverses a goal collecting parameters in Γ and assumptions in D. When it reaches an atom, either it stops, as no parameter has been introduced, or it passes Γ, D to assumption complementation.

Some examples will make the whole process clear; consider the copy program on λ-terms:

cpapp : ∀E_{1}, E_{2}, F_{1}, F_{2} :exp.
copy (app E_{1}E_{2}) (app F_{1}F_{2})
← copy E_{1} F_{1}
← copy E_{2} F_{2}.
cplam : ∀E:exp → exp. ∀F:exp → exp.
copy (lam E) (lam F)
← (∀x:exp. copy x x
→ copy (E x) (F x)).

The augmentation judgment aug_{D}(cplam) calls aug_{G}(∀x:exp. copy x x → copy (E x) (F x)), which collects the context x:exp; copy x x and calls x:exp ⊢ Notα(copy x x). We start by noting that Not_{x}^{C}(copy x x) = ⊤, since the conditions on rule Not_{x}^{C} are not satisfied. Then, note that x:exp ⊢ Not(x) = {lam F′, app F_{1} F_{2}}. This yields:

x:exp ⊢ Not_{1}^{x}(copy x x) = (∀F′, F_{1}, F_{2} :exp. ¬copy x (lam F′) ∧ ¬copy x (app F_{1} F_{2}))

X ∈ {⊤, ⊥} or (dis)eq

aug_{G}X

Γ; D ⊢ aug_{G}(X) = X

\frac{aug_{G}At^{⊤}}{·; ⊤ ⊢ aug_{G}(Q) = Q}

Γ ⊢ Notα(D) = D_{¬}

aug_{G}At

Γ; D ⊢ aug_{G}(Q) = D_{¬} → Q

Γ; (D ∧ D) ⊢ aug_{G}(G) = G^{a} aug_{G} →

Γ; D ⊢ aug_{G}(D → G) = D → G^{a}

(Γ, y:a); D ⊢ aug_{G}([y/x]G) = [y/x]G^{a}
aug_{G}∀^{y}

Γ; D ⊢ aug_{G}(∀x:a. G) = ∀x:a. G^{a}

Γ; D ⊢ aug_{G}(G_{1}) = G_{1}^{a} Γ; D ⊢ aug_{G}(G_{2}) = G_{2}^{a} aug_{G}∧

Γ; D ⊢ aug_{G}(G_{1} ∧ G_{2}) = G_{1}^{a} ∧ G_{2}^{a}

Γ; D ⊢ aug_{G}(G_{1}) = G_{1}^{a} Γ; D ⊢ aug_{G}(G_{2}) = G_{2}^{a} aug_{G}∨

Γ; D ⊢ aug_{G}(G_{1} ∨ G_{2}) = G_{1}^{a} ∨ G_{2}^{a}

Figure 6.13: Goal augmentation: Γ; D ⊢ aug_{G}(G) = G^{a}

Symmetrically:

x:exp ⊢ Not_{2}^{x}(copy x x) = ∀F′′, F_{3}, F_{4} :exp. ¬copy (lam F′′) x ∧ ¬copy (app F_{3} F_{4}) x)

This will yield the augmented clause:

aug_{D}(cplam) : ∀E:exp → exp. ∀F:exp → exp.
copy (lam E) (lam F)
← (∀x:exp.
(∀F′, F′′, F_{1}, F_{2}, F_{3}, F_{4} :exp.
¬copy x (lam F′) ∧ ¬copy x (app F_{1} F_{2}) ∧
¬copy (lam F′′) x ∧ ¬copy (app F_{3} F_{4}) x)
→ copy x x → copy (E x) (F x)).

while of course, aug_{D}(cpapp) = cpapp, as enforced by aug_{G}At⊤. If we had a two-parameter version of copy:

cplam′ : ∀E:exp → exp. ∀F:exp → exp.
copy′ (lam E) (lam F)
← (∀x:exp. ∀y:exp. (copy′ x y)
→ copy′ (E x) (F y)).

Then we would get first:

Not_{x}^{C}(copy′ x y) = (∀E′′:exp. ¬copy′ E′′ x)
Not_{y}^{C}(copy′ x y) = (∀F′′:exp. ¬copy′ y F′′).

Secondly, by computing, respectively, for Γ = x:exp, y:exp, Γ ⊢ Not(y) and Γ ⊢ Not(x):

Γ ⊢ Not_{1}^{x}(copy′ x y) = (∀F_{0}, F_{1}, F_{2} :exp. ¬copy′ x (lam F_{0}) ∧ ¬copy′ x (app F_{1} F_{2}) ∧ ¬copy′x x)
Γ ⊢ Not_{2}^{y}(copy′ x y) = (∀F′_{0}, F′_{1}, F′_{2} :exp. ¬copy′ (lam F′_{0}) y ∧ ¬copy′ (app F′_{1} F′_{2}) y ∧ ¬copy′ y y)

yielding the augmented clause:

aug_{D}(cplam′) : ∀E:exp → exp. ∀F:exp → exp.
copy′ (lam E) (lam F)
← (∀x:exp. ∀y:exp.
(∀E′:exp. ¬copy′ E′ x) ∧
(∀F′:exp. ¬copy′ y F′) ∧
∀(¬copy′ x (lam F_{0}) ∧ ¬copy′ x (app F_{1} F_{2}) ∧ ¬copy′x x ∧
¬copy′ (lam F′_{0}) y ∧ ¬copy′ (app F′_{1} F′_{2}) y ∧ ¬copy′ y y)
→ copy′ x y → copy′ (E x) (F y)).

Note that by static analysis of copy', we know that x will never end up in the second argument of copy' and symmetrically this applies to y, too. Thus the call to Not_{x}^{C}, Not_{y}^{C} are, in this case, useless; however since this kind of data flow analysis is in general undecidable, the augmentation procedure inserts the negation of a clause for every ‘odd’ position relevant to the pivot parameter. Now, consider the typing clause for lambda terms:

oflam : ∀E:exp → exp. ∀T_{1}, T_{2} :tp.
of (lam E) (arrow T_{1} T_{2})
← (∀x:exp. of x T_{1} → of (E x) T_{2}).

As T_{1} is an input term, normalization of input variables inserts the appropriate equation, where oflam ↦^{D}

oflam':

oflam′ : ∀E:exp → exp. ∀T_{1}, T_{2} :tp.
of (lam E) (arrow T_{1} T_{2})

(∀T:tp. of x T ← T =^{·} T_{1}) →

of (E x) T_{2}).

Both Not_{x}^{C} and Not_{x}^{1} generate no contribution; in particular x:exp ⊢ Not_{x}^{1}(∀T : tp. of x T) calls the Not_{x}^{i} rule, but term complementation (applied to the existential variable T) yields the trivial clause. Therefore, by Not_{G}(T =^{·} T_{1}), augmentation will result into:

aug_{D}(oflam) : ∀E:exp → exp. ∀T_{1}, T_{2} :tp.
of (lam E) (arrow T_{1} T_{2})
← (∀x:exp. of x T_{1} →

(∀T:tp. ¬of x T ← T ≠^{·} T_{1}) →

of (E x) T_{2}).

Consider now a predicate which counts the number of bound variables in a lambda-term:

cntlam : ∀E:exp → exp. ∀N:nat.

cnt (lam E) N

← (∀x:exp. cnt x s(0) →
cnt (E x) N).

The call to x:exp ⊢ Notα(cnt x s(0)) leads to Not_{x}^{1}(cnt x s(0)), since, again, Not_{x}^{C} does not contribute: Not_{x}^{i} collects the term complement of s(0) in the empty context, that is {0, s(s(M))}:

aug_{D}(cntlam) : ∀E:exp → exp. ∀N:nat.
cnt (lam E) N
← (∀x:exp. (¬cnt x 0 ∧ ∀M:nat. ¬cnt x s(s(M)))
→ cnt (E x) N).

Let us see how rule Notα⊤ enters the picture: recall the ⊤-normalized linx lambda clause:

linxlam : ∀E:exp → exp → exp.
linx (λx . lam(λy . E x y))
← (∀z:exp. ⊤_{linx} → linx (λx . E x z)).

The judgment z:exp; ⊤_{linx} ⊢ aug_{G}(linx E x z) triggers the rule Notα⊤; in turn · ⊢ sh(z, exp → exp) = λy . z and thus Not_{1}^{z}(⊤_{linx}) = ¬linx (λx . z):

aug_{D}(linxlam) : ∀E:exp → exp → exp.
linx (λx . lam(λy . E x y))
← (∀z:exp. ¬linx (λx . z) → linx (λx . E x z)).

Example 6.27 Let us apply the complement algorithm to the linx predicate definition; note the vacuous application E_{2} x^{0}:

linxx : linx(λx . x).
linxap1 : linx(λx . app (E_{1} x) (E_{2} x^{0})) ← linx(λx . E_{1} x).
linxap2 : linx(λx . app (E_{1} x^{0}) (E_{2} x)) ← linx(λx . E_{2} x).
aug_{D}(linxlm) : linx(λx . lam(λy . E x y)) ← (∀y:exp. ⊤_{linx} → linx(λx . E x y)).
Not_{D}(def(linx)) =
Not_{D}(linxx) ∨ Not_{D}(linxap1) ∨ Not_{D}(linxap2) ∨ Not_{D}(linxlm) =
(¬linx(λx . app (E_{1} x) (E_{2} x)) ∧ ¬linx(λx . lam(λy . (E x y)))) ∨
(¬linx(λx . x) ∧ ¬linx(λx . lam(λy . (E x y))) ∧ ¬linx(λx . app (E_{1} x) (E_{2} x^{1}))
∧ ¬linx(λx . app (E_{1} x) (E_{2} x^{0})) ← ¬linx(λx . E_{1} x)) ∨
(¬linx(λx . x) ∧ ¬linx(λx . lam(λy . (E x y))) ∧ ¬linx(λx . app (E_{1} x^{1}) (E_{2} x))
← ¬linx(λx . app (E_{1} x^{0}) (E_{2} x)) ← ¬linx(λx . E_{2} x)) ∨
(¬linx(λx . x) ∧ ¬linx(λx . app (E_{1} x) (E_{2} x))
∧ ¬linx(λx . lam(λy . (E x y))) ← (∀y:exp. ¬linx(λx . y) → ¬linx(λx . E x y))).

We prove that augmented clauses and goals satisfy the augmented schema, where we define Γ; aug_{D}(D) as Γ; D ∧ ¬D, for Γ ⊢ Notα(D) = ¬D and

\frac{aug∘}{aug(∘) = ∘}

aug(S) = S^{a} aug_{D}(D) = D^{a}
aug∥
aug(S∥(Γ; SOME Φ. D)) = S^{a}∥(Γ; SOME Φ. D^{a})

Now, the usual lemma on schema membership:

Lemma 6.28 If Γ ⊢ Γ′; D′ ∈ S then Γ ⊢ Γ′; aug_{D}(D′) ∈ aug(S).

Proof: By induction on the structure of π :: Γ; D ∈ S. Case:

Γ ⊢ θ : Φ (Γ′; D′) ≡_{α} (Γ′′; θD) ∈_{1}

Γ ⊢ (Γ′; D′) ∈ S∥(Γ′′; SOME Φ. D)

Γ′; D′ ≡_{α} Γ′′; [θ]D  By sub-derivation
Γ′; aug_{D}(D′) ≡_{α} Γ′′; [θ]aug_{D}(D)  By definition
Γ′; aug_{D}(D′) ∈ aug(S)∥Γ′′; SOME Φ. aug_{D}(D)  By rule ∈_{1}
Γ′; aug_{D}(D′) ∈ aug(S∥Γ′′; SOME Φ. D)  By rule aug∥

Case: π ends in ∈_{2}: by IH.

□

We use ⊧_{S^{a}} aug_{D}(D) for ⊢ aug_{D}(D) = D^{a} and ⊧_{S^{a}} D^{a}; analogously for aug_{G}(G). Lemma 6.29 (Schema Augmentation) Let Γ; D < S and aug(S) = S^{a}. Then:

1. If ⊧_{S} D, then ⊧_{S^{a}} aug_{D}(D).

2. If Γ; D \ G < S, then Γ; D \ aug_{G}(G) < S^{a}.

3. If Γ; D < S then Γ; aug_{D}(D) < S^{a}. Proof: By mutual induction on the structure of π :: ⊧_{S} D, γ :: Γ; D \ G < S and σ :: Γ; D < S. We show the crucial cases: Case:

π = \begin{aligned}X ∈ \{Q, ⊤, ⊥\} \\ & ⊧_{S} X \\ ⊧_{S} X \end{aligned}

Immediately Γ; D ⊢ aug_{D}(X) = X and

π′ = \begin{aligned}X ∈ \{Q, ⊤, ⊥\} \\ & ⊧_{S} X \\ ⊧_{S^{a}} X \end{aligned}

Case:

π = \begin{aligned}·; ⊤ \ [ρ]G < S \\ & ⊧_{S}→^{σ} \\ ⊧_{S} ∀(G → Q) \end{aligned}

·; ⊤ \ [ρ]G < S  By sub-derivation
·; ⊤ \ aug_{G}([ρ]G) < S^{a}  By IH 2
⊧_{S^{a}} aug_{G}([ρ]G) → [ρ]Q  By rule ⊧_{S}→
⊧_{S^{a}} aug_{D}(∀(G → Q))  By rule aug_{D} →

Case:

γ = X ∈ {⊤, ⊥} or (dis)eq Γ; D < S \X Γ; D \ X < S
Γ; D < S  By sub-derivation
Γ; aug_{D}(D) < S^{a}  By IH 3
Γ; D ⊢ aug_{G}(X) = X  By rule aug_{G}X
Γ; aug_{D}(D) \ X < S^{a}  By rule \X

Draft of July 6, 2000

Case:

γ = \begin{aligned}Γ; D < S \\ & \At \\ Γ; D \ Q < S \end{aligned}

By sub-derivation Γ; D < S; there are two ways to augment an atom:

Subcase: ·; ⊤ ⊢ aug_{G}(Q) = Q:

·; ⊤ < S^{a}  By rule <_{1}
·; ⊤ \ Q < S^{a}  By rule aug_{G}At⊤
·; ⊤ \ aug_{G}(Q) < S^{a}  By rule \At

Subcase: Γ; D ⊢ aug(Q) = Notα(D) → Q:

Γ; aug_{D}(D) < S^{a}  By IH 3
Γ; aug_{D}(D) \ Q < S^{a}  By rule \At
Γ; D ∧ Notα(D) \ Q < S^{a}  By def. of aug_{D}(D)
Γ; D \ Notα(D) → Q < S^{a}  By rule aug_{G}At
Γ; D \ aug_{G}(Q) < S^{a}  By rule \ →

Case:

γ = \begin{aligned}⊧_{S} D Γ; D ∧ D \ G < S \\ & \ → \\ Γ; D \ D → G < S \end{aligned}

⊧_{S} D  By sub-derivation
⊧_{S^{a}} aug_{D}(D)  By IH 1
Γ; D ∧ D \ G < S  By sub-derivation
Γ; D ∧ D \ aug_{G}(G) < S^{a}  By IH 2
Γ; D \ D → aug_{G}(G) < S^{a}  By rule \ →
Γ; D \ aug_{G}(D → G) < S^{a}  By rule aug_{G} →

Case:

σ = \frac{<_{1}}{·; ⊤ < S}

Then immediately:

σ′ = \frac{<_{1}}{·; ⊤ < S^{a}}

Case:

σ = \begin{aligned}Γ ⊢ (Γ′; D′) ∈ S ⊧_{S} D′ (Γ; D) < S \\ & <_{2} \\ (Γ, ⌈Γ′⌉); (D ∧ ⌈D′⌉) < S \end{aligned}

Γ; D < S  By sub-derivation
Γ; aug_{D}(D) < S^{a}  By IH 3
Γ ⊢ Γ′; D′ ∈ S  By sub-derivation
Γ′; aug_{D}(D′) ∈ S^{a}  By Lemma 6.28
⊧_{S} D′  By sub-derivation
⊧_{S^{a}} aug_{D}(D′)  By IH 1
(Γ, ⌈Γ′⌉); aug_{D}(D) ∧ aug_{D}(⌈D′)⌉) < S^{a}  By rule <_{2}
(Γ, ⌈Γ′⌉); aug_{D}(D ∧ ⌈D′⌉) < S^{a}  By rule aug_{D}∧
□

The following Lemma ensures that augmented clauses are closed under negation. In particular, for Γ; D < S^{a}, if D ∈ D, so is Γ ⊢ Notα(D). We use Γ; D\Not_{G}(G) < S^{a} for Not_{G}(G) = G_{¬} and Γ; D\G_{¬} < S^{a}. Similarly for Not_{D}(D). We will need the following technical remark:

Remark 6.30 If M⃗ is a simple term, then ⊧_{S^{a}} ⋀_{N⃗∈Not(M⃗)} ∀(¬(q N⃗) ← ⊤). Proof: By rules ⊧_{S^{a}} ∧, ⊧_{S} ∀, ⊧_{S^{a}}→, \⊤, ⊧_{S} At, \At. □ Lemma 6.31 (Negative Schema Augmentation) Let Γ; D < S^{a}. Then:

1. If ⊧_{S^{a}} aug_{D}(D), then ⊧_{S^{a}} Not_{D}(aug_{D}(D)).

2. If Γ; D \ aug_{G}(G) < S^{a}, then Γ; D \ Not_{G}(aug_{G}(G)) < S^{a}. Proof: By mutual induction on the structure of π :: ⊧_{S^{a}} aug_{D}(D) and γ :: Γ; D \ aug_{G}(G) < S^{a}. Case:

π = \frac{⊧_{S^{a}} ⊥}{⊧_{S^{a}} aug_{D}(⊥)}

By rule aug_{D}(⊥) = ⊥ and ⊢ Not_{D}(⊥) = ⊤: thus

π′ = \frac{⊧_{S^{a}} ⊤}{⊧_{S^{a}} ⊤}

Case:

π = \frac{⊧_{S^{a}} ⊤}{⊧_{S^{a}} aug_{D}(⊤)}

By rule aug_{D}(⊤) = ⊤ and ⊢ Not_{D}(⊤) = ⊥: thus

π′ = \frac{⊧_{S^{a}} ⊥}{⊧_{S^{a}} ⊥}

Case: π ends in ⊧_{S^{a}} aug_{D}(∀(q M⃗ ← G)):

⊧_{S^{a}} (∀(q M⃗) ← aug_{G}(G))  By rule aug_{D} →
·; ⊤ \ aug_{G}([ρ]G) < S^{a}  By inversion on rule ⊧_{S}→
·; ⊤ \ Not_{G}(aug_{G}([ρ]G)) < S^{a}  By IH 2
⊧_{S^{a}} [ρ](¬q M⃗)  By rule ⊧_{S^{a}} At
⊧_{S^{a}} ∀(¬q M⃗ ← Not_{G}(aug_{G}(G)))  By rule ⊧_{S^{a}}→
⊧_{S^{a}} ⋀_{N⃗∈Not(M⃗)} ∀(¬(q N⃗))  By Remark 6.30
⊧_{S^{a}} ⋀_{N⃗∈Not(M⃗)} ∀(¬(q N⃗) ← ⊤) ∧ ∀(¬q M⃗ ← Not_{G}(aug_{G}(G)))  By rule ⊧_{S^{a}} ∧
⊧_{S^{a}} Not_{D}(∀(q M⃗) ← aug_{G}(G))  By rule Not_{D} →
⊧_{S^{a}} Not_{D}(aug_{D}(∀(q M⃗ ← G)))  By rule aug_{D} →

Case: π ends in ⊧_{S^{a}} aug_{D}(D_{1} ∧ D_{2}):

⊧_{S^{a}} aug_{D}(D_{1}) ∧ aug_{D}(D_{2})  By rule aug_{D}∧
⊧_{S^{a}} aug_{D}(D_{1}) and ⊧_{S^{a}} aug_{D}(D_{2})  By rule ⊧_{S} ∧
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1})) and ⊧_{S^{a}} Not_{D}(aug_{D}(D_{2}))  By IH 1
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1})) ∨ Not_{D}(aug_{D}(D_{2}))  By rule ⊧_{S} ∨
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1}) ∧ aug_{D}(D_{2}))  By rule Not_{D}∧
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1} ∧ D_{2}))  By rule aug_{D}∧

Case: π ends in ⊧_{S^{a}} aug_{D}(D_{1} ∨ D_{2}):

⊧_{S^{a}} aug_{D}(D_{1}) ∨ aug_{D}(D_{2})  By rule aug_{D}∨
⊧_{S^{a}} aug_{D}(D_{1}) and ⊧_{S^{a}} aug_{D}(D_{2})  By rule ⊧_{S} ∨
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1})) and ⊧_{S^{a}} Not_{D}(aug_{D}(D_{2}))  By IH 1
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1})) ∧ Not_{D}(aug_{D}(D_{2}))  By rule ⊧_{S} ∧
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1}) ∨ aug_{D}(D_{2}))  By rule Not_{D}∨
⊧_{S^{a}} Not_{D}(aug_{D}(D_{1} ∨ D_{2}))  By rule aug_{D}∨

Draft of July 6, 2000

Case: γ ends in Γ; D \ aug_{G}(⊤) < S^{a}:

Γ; D \ ⊤ < S^{a}  By rule aug_{G}⊤
Γ; D < S^{a}  By sub-derivation
Γ; D ⊢ Not_{G}(⊤) = ⊥  By rule Not_{G}⊤
Γ; D \ ⊥ < S^{a}  By rule \⊥

Case: γ ends in Γ; D \ aug_{G}(⊥) < S^{a}:

Γ; D \ ⊥ < S^{a}  By rule aug_{G}⊥
Γ; D < S^{a}  By sub-derivation
Γ; D ⊢ Not_{G}(⊥) = ⊤  By rule Not_{G}⊥
Γ; D \ ⊤ < S^{a}  By rule \⊥

Case: γ ends in Γ; D \ aug_{G}(M⃗ =^{·} N⃗) < S^{a}:

Γ; D \ M⃗ =^{·} N⃗ < S^{a}  By rule aug_{G} =^{·}
Γ; D < S^{a}  By sub-derivation
Γ; D ⊢ Not_{G}(M⃗ =^{·} N⃗) = (M⃗ ≠^{·} N⃗)  By rule Not_{G} =^{·}
Γ; D \ M⃗ ≠^{·} N⃗ < S^{a}  By rule \ ≠^{·}

Case: γ ends in Γ; D \ aug_{G}(M⃗ ≠^{·} N⃗) < S^{a}:

Γ; D \ M⃗ ≠^{·} N⃗ < S^{a}  By rule aug_{G} ≠^{·}
Γ; D < S^{a}  By sub-derivation
Γ; D ⊢ Not_{G}(M⃗ ≠^{·} N⃗) = (M⃗ =^{·} N⃗)  By rule Not_{G} ≠^{·}
Γ; D \ M⃗ =^{·} N⃗ < S^{a}  By rule \ ≠^{·}

Case: γ ends in Γ; D \ aug_{G}(Q) < S^{a}: By sub-derivation Γ; D < S^{a}; there are two ways to augment an atom:

Subcase: ·; ⊤ ⊢ aug_{G}(Q) = Q:

·; ⊤ \ Q < S^{a}  By rule \At
·; ⊤ \ ¬Q < S^{a}  By rule Not_{G}At
·; ⊤ \ Not_{G}(Q) < S^{a}  By rule Not_{G} →
·; ⊤ \ Not_{G}(aug_{G}(Q)) < S^{a}  By rule aug_{G}At⊤

Subcase: Γ; D ⊢ alg(Q) = Notα(D) → G:

Γ; D \ Notα(D) → Q < S^{a}  By rule aug_{G}At
Γ; (D ∧ Notα(D)) \ Q < S^{a}  By rule \ →
Γ; (D ∧ Notα(D)) < S^{a}  By sub-derivation
Γ; (D ∧ Notα(D)) \ ¬Q < S^{a}  By rule \At
Γ; D \ Notα(D) → ¬Q < S^{a}  By rule \ →
Γ; D \ Notα(D) → Not_{G}(Q) < S^{a}  By rule Not_{G}At
Γ; D \ Not_{G}(Notα(D) → Q) < S^{a}  By rule Not_{G} →
Γ; D \ Not_{G}(aug_{G}(Q)) < S^{a}  By rule aug_{G}At

Case: γ ends in Γ; D \ aug_{G}(D → G) < S^{a}:

Γ; D \ aug_{D}(D) → aug_{G}(G) < S^{a}  By rule aug_{G} →
⊧_{S^{a}} aug_{D}(D) and Γ; (D ∧ D) \ aug_{G}(G) < S^{a}  By rule \ →
Γ; (D ∧ aug_{D}(D)) \ Not_{G}(aug_{G}(G)) < S^{a}  By IH 2
Γ; D \ aug_{D}(D) → Not_{G}(aug_{G}(G)) < S^{a}  By rule \ →
Γ; D \ Not_{G}(aug_{D}(D) → aug_{G}(G)) < S^{a}  By rule Not_{G} →
Γ; D \ Not_{G}(aug_{G}(D → G)) < S^{a}  By rule aug_{G} →

Case: γ ends in Γ; D \ aug_{G}(∀x:a. G) < S^{a}:

Γ; D \ ∀x:a. aug_{G}(G) < S^{a}  By rule aug_{G}∀
(Γ, y:A); D \ [y/x]aug_{G}(G) < S^{a}  By rule \∀
(Γ, y:A); D \ [y/x]Not_{G}(aug_{G}(G)) < S^{a}  By IH 2
Γ; D \ ∀x:a. Not_{G}(aug_{G}(G)) < S^{a}  By rule \∀
Γ; D \ Not_{G}(∀x:a. aug_{G}(G)) < S^{a}  By rule Not_{G}∀
Γ; D \ Not_{G}(aug_{G}(∀x:a. G)) < S^{a}  By rule aug_{G}∀

Case: γ ends in Γ; D \ aug_{G}(G_{1} ∨ G_{2}) < S^{a}:

Γ; D \ aug_{G}(G_{1}) ∨ aug_{G}(G_{2}) < S^{a}  By rule aug_{G}∨
Γ; D \ aug_{G}(G_{1}) < S^{a} and Γ; D \ aug_{G}(G_{2}) < S^{a}  By rule \∨
Γ; D \ Not_{G}(aug_{G}(G_{1})) < S^{a} and Γ; D \ Not_{G}(aug_{G}(G_{2})) < S^{a}  By IH 2
Γ; D \ Not_{G}(aug_{G}(G_{1})) ∧ Not_{G}(aug_{G}(G_{2}) < S^{a}  By rule \∧
Γ; D \ Not_{G}(aug_{G}(G_{1}) ∨ aug_{G}(G_{2})) < S^{a}  By rule Not_{G}∨
Γ; D \ Not_{G}(aug_{G}(G_{1} ∨ G_{2})) < S^{a}  By rule aug_{G}∨

Case: γ ends in Γ; D \ aug_{G}(G_{1} ∧ G_{2}) < S^{a}:

Γ; D \ aug_{G}(G_{1}) ∧ aug_{G}(G_{2}) < S^{a}  By rule aug_{G}∧
Γ; D \ aug_{G}(G_{1}) < S^{a} and Γ; D \ aug_{G}(G_{2}) < S^{a}  By rule \∧
Γ; D \ Not_{G}(aug_{G}(G_{1})) < S^{a} and Γ; D \ Not_{G}(aug_{G}(G_{2})) < S^{a}  By IH 2
Γ; D \ Not_{G}(aug_{G}(G_{1})) ∨ Not_{G}(aug_{G}(G_{2}) < S^{a}  By rule \∨
Γ; D \ Not_{G}(aug_{G}(G_{1}) ∧ aug_{G}(G_{2})) < S^{a}  By rule Not_{G}∧
Γ; D \ Not_{G}(aug_{G}(G_{1} ∧ G_{2})) < S^{a}  By rule aug_{G}∧
□

We can combine the two latter lemmata 6.29 and 6.31 to prove that augmentation guarantees that static and dynamic clauses are closed under complementation.

Corollary 6.32 (Closure under Complementation) If ⊧_{S} D, then ⊧_{S^{a}} Not_{D}(aug_{D}(D)).

6.7 Exclusivity

We are now in the position to prove the main result of this Chapter, namely that clause complementation satisfies the boolean rules of negation, in the form of exclusivity and exhaustivity. We remark that this holds due to the fact that context schemata allow to pose only ‘well-behaved’ goals. For example, consider the query G ≡ ¬even(0) → even(s(s(0))), which is such that both ·; ⊤ ⊢_{even} G and ·; ⊤ ⊢_{¬even} Not_{G}(G) are provable. By definition of schema satisfaction, this is not a legal query. Similarly, the following counterexample to exhaustivity ·; ⊤ ⊢_{even} ∀x : nat. even(x) is not allowed. Moreover, the Context Preservation Theorems (Theorem 6.13 and 6.14) guarantees that, from allowed run-time contexts and goals, only allowed subgoals are generated.

We will need the following obvious fact:

Lemma 6.33 If Γ ⊢ M : A and M is rigid, so is every N such that N ∈ (Γ ⊢ Not(M)).

Proof: By a straightforward induction on the structure of Γ ⊢ Not(M). □

We use Γ; D ⊢_{P} Not_{G}(G) for Γ ⊢ Not_{G}(G) = G′ and Γ; D ⊢_{P} G′; also, Γ; D ⊢_{P} Not_{D}(D)>>¬Q for Not_{D}(D) = D′ and Γ; D ⊢_{P} D′>>¬Q; similarly for Notα. We use P to denote the conjunction of a positive program P^{+} and its negation P^{−} = Not_{D}(P^{+}).

Theorem 6.34 (Exclusivity) Let ⊧_{S^{a}} aug_{D}(P) and Γ; D < S^{a}. For every goals such that Γ; D \ G < S^{a}, It is not the case that there is S^{+} :: Γ; D ⊢_{P} G and there is S^{−} :: Γ; D ⊢_{P} Not_{G}(G).

Proof: We generalize this to;

2.1 Let D ⊑ def(q, P): It is not the case that I^{+} :: Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P} Not_{D}(D)>>Not_{G}(Q). By mutual induction on the structure of I^{+} and S^{+}, by assuming their existence:

Case:

I^{+} = \frac{>>⊥}{Γ; D ⊢_{P} ⊥_{q}>>Q}

But there can be no proof of ¬Q from Not_{D}(⊥_{q}) = ⊤_{q}.

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} [σ]G \\ & >> → \\ Γ; D ⊢_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Not_{D}(∀(q \overline{N_{n}} ← G))>>¬q \overline{M_{n}}:

Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}}  By sub-derivation
· ⊢ \overline{M_{n}} ∈ ∥\overline{N_{n}}∥ (∗)  By definition of of ∥ ∥
S_{1}^{+} :: Γ; D ⊢_{P} [σ]G  By sub-derivation
Γ; D ⊢_{P} ⋀_{\overline{S_{n}}∈·⊢Not(\overline{N_{n}})} ∀(¬q \overline{S_{n}} ← ⊤) ∧ ∀(¬q \overline{N_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By rule Not_{D} →
Subcase: Γ; D ⊢_{P} ⋀_{\overline{S_{n}}∈·⊢Not(\overline{N_{n}})} ∀(¬q \overline{S_{n}} ← ⊤)>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ∀(¬q \overline{S_{n}} ← ⊤)>>¬q \overline{M_{n}} for some \overline{S_{n}}  By inversion
Γ; D ⊢_{P} [θ](¬q \overline{S_{n}}) ← ⊤>>¬q \overline{M_{n}} for some θ  By inversion
Γ; D ⊢_{P} [θ]\overline{S_{n}} =^{·} \overline{M_{n}}  By inversion
· ⊢ \overline{M_{n}} ∈ ∥Not(\overline{N_{n}})∥  By definition of ∥ ∥
⊥  By term exclusivity with (∗)
Subcase: Γ; D ⊢_{P} ∀(¬q \overline{N_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} Not_{G}([σ]G)  By inversion
⊥  By IH 1 w.r.t. S_{1}^{+}

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{1}>>Q Γ; D ⊢_{P} D_{2}>>Q \\ & >>∨ \\ Γ; D ⊢_{P} (D_{1} ∨ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Not_{D}(D_{1} ∨ D_{2})>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} D_{2}>>Q  By sub-derivation
Γ; D ⊢_{P} Not_{D}(D_{1}) ∧ Not_{D}(D_{2})>>¬Q  By rule Not_{D}∨
Subcase: Γ; D ⊢_{P} Not_{D}(D_{1})>>¬Q  By inversion
⊥  By IH 2.1
Subcase: Γ; D ⊢_{P} Not_{D}(D_{2})>>¬Q  By inversion
⊥  By IH 2.1

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{1}>>Q \\ & >>∧ \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Not_{D}(D_{1} ∧ D_{2})>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} Not_{D}(D_{1}) ∨ Not_{D}(D_{2})>>¬Q  By rule Not_{D}∧
Γ; D ⊢_{P} Not_{D}(D_{1})  By inversion
⊥  By IH 2.1

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{2}>>Q \\ & >>∧ \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Not_{D}(D_{1} ∧ D_{2})>>¬Q:

Γ; D ⊢_{P} D_{2}>>Q  By inversion
Γ; D ⊢_{P} Not_{D}(D_{1}) ∨ Not_{D}(D_{2})>>¬Q  By rule Not_{D}∧
Γ; D ⊢_{P} Not_{D}(D_{2})>>¬Q  By inversion
⊥  By IH 2.1

2.2 Let D ⊑ def(q, P) and D′ ⊑ def(q, D). It is not the case that I^{+} :: Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P}

Notα(D′)>>¬Q. By simultaneous induction on the structure of I^{+} and I^{−}:

No case for I^{+} ends in >>⊤ Case:

I^{+} = \frac{>>At}{Γ; D ⊢_{P} ⊥_{q}>>Q}

But by schema satisfaction there can be no formula in the dynamic definition of q. Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} [σ]\overline{S_{n}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} [σ]G \\ & >> → \\ Γ; D ⊢_{P} ∀(q \overline{S_{n}} ← G)>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Notα(∀(q \overline{T_{n}} ← H))>>¬q \overline{M_{n}}.

Γ; D ⊢_{P} [σ]\overline{S_{n}} =^{·} \overline{M_{n}}  By sub-derivation
Γ; D ⊢_{P} [σ]S_{i} =^{·} M_{i} for every 1 ≤ i ≤ n (∗)  By sub-derivation

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{T_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{T_{n}}))) ∧ ∀(¬q \overline{T_{n}}) ← Not_{G}(G)>>¬q \overline{M_{n}}

By rule Notα →

Subcase: Γ; D ⊢_{P} Not_{x}^{C}(q \overline{T_{n}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{1≤j≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{j}]\overline{Z_{n}}>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{j}  By inversion
⊥  From line (∗) and S_{j} rigid
Subcase: Γ; D ⊢_{P} ⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{T_{n}})>>¬q \overline{M_{n}} for a fixed x  By inversion
Γ; D ⊢_{P} Not_{x}^{i}(q \overline{T_{n}})>>¬q \overline{M_{n}}  By inversion

Γ; D ⊢_{P} ⋀_{1≤j≤n} ⋀_{N∈Γ⊢Not(T_{j})}(∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}})>>¬q \overline{M_{n}}

By rule Not_{x}^{i} →

Γ; D ⊢_{P} e_{x} =^{·} M_{i}  By inversion
⊥  From line (∗) and S_{i} rigid
Subcase: Γ; D ⊢_{P} ∀(¬q \overline{T_{n}} ← Not_{G}(H))>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} [θ]\overline{T_{n}} =^{·} \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{j} for some 1 ≤ j ≤ n  By complementable clause
⊥  From line (∗) and S_{j} rigid

Case: I^{+} ends in >> →, I^{−} ends in >>⊥: But there can be no proof of ¬Q from Γ ⊢ Notα(⊥_{q}) = ⊤_{q}. Case: I^{+} ends in >> →, I^{−} ends in >>⊤:

Subcase: Γ = · or for all x ∈ dom(Γ), for all i, 1 ≤ i ≤ n it is not the case that xR^{i}q: then

Γ ⊢ Notα(⊤_{q}) = ⊤_{q} and an be no proof of ¬Q from ⊤_{q}.

Subcase: else Γ ⊢ Notα(⊤_{q}) = ⋀_{x∈dom(Γ)}(⋀_{1≤i≤n,xR^{i}q} Not_{x}^{C}(⊤_{q})); fix x, i:

Γ; D ⊢_{P} Not_{x}^{C}(⊤_{q})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{1≤i≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{j}]\overline{Z_{n}}>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{j}  By inversion
⊥  Above line and rigidity restriction on S_{j} (∗).

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{1}>>Q Γ; D ⊢_{P} D_{2}>>Q \\ & >>∨ \\ Γ; D ⊢_{P} (D_{1} ∨ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢ Notα(D′)>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
⊥  By IH 2.2

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{1}>>Q \\ & >>∧_{1} \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢ Notα(D′)>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
⊥  By IH 2.2

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{2}>>Q \\ & >>∧_{2} \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢ Notα(D′)>>¬Q: Symmetric to the above. Case:

I^{−} = Γ; D ⊢_{P} Notα(D′_{1})>>¬Q >>∧_{1} Γ; D ⊢_{P} Notα(D′_{1} ∨ D′_{2})>>¬Q

and I^{−} ends in Γ; D ⊢ D>>Q. By IH 2.2 Case:

I^{−} = Γ; D ⊢_{P} Notα(D′_{2})>>¬Q >>∧_{2} Γ; D ⊢_{P} Notα(D′_{1} ∨ D′_{2})>>¬Q

and I^{−} ends in Γ; D ⊢ D>>Q. By IH 2.2. Case:

I^{−} = Γ; D ⊢_{P} Notα(D′_{1})>>¬Q Γ; D ⊢_{P} Notα(D′_{2})>>¬Q >>∨ Γ; D ⊢_{P} Notα(D′_{1} ∧ D′_{2})>>¬Q

and I^{−} ends in Γ; D ⊢ D>>Q. By IH 2.2.

2.3 Let D ⊑ def(q, D) and D′ ⊑ def(q, P). It is not the case that I^{+} :: Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P} Not_{D}(D′)>>¬Q. By simultaneous induction on the structure of I^{+} and I^{−}. Note that by the restriction to complementable programs, some SPE e_{x} occurs in D; we thus use the notation \overline{N_{e_{x}}^{i}}.

No case for for I^{+} ends in >>⊤. No case for for I^{+} ends in >>⊥, since by the restriction to complementable clauses, ⊥ cannot occur as an assumption.

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} [σ]\overline{N_{e_{x}}^{i}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} [σ]H \\ & >> → \\ Γ; D ⊢_{P} ∀(q \overline{N_{e_{x}}^{i}} ← H)>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Not_{D}(∀(q \overline{S_{n}} ← G))>>¬q \overline{M_{n}}.

Γ; D ⊢_{P} [σ]\overline{N_{e_{x}}^{i}} =^{·} \overline{M_{n}}  By sub-derivation
Γ; D ⊢_{P} e_{x} =^{·} M_{i} (∗) for some 1 ≤ i ≤ n  By sub-derivation
Γ; D ⊢_{P} ⋀_{\overline{T_{n}}∈·⊢Not(\overline{S_{n}})} ∀(¬q \overline{T_{n}} ← ⊤) ∧ ∀(¬q \overline{S_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By rule Not_{D} →

Subcase: Γ; D ⊢_{P} ⋀_{\overline{T_{n}}∈·⊢Not(\overline{S_{n}})} ∀(¬q \overline{T_{n}} ← ⊤)>>q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ∀(¬q \overline{T_{n}} ← ⊤)>>q \overline{M_{n}} for some \overline{T_{n}} ∈ · ⊢ Not(\overline{S_{n}})  By inversion
Γ; D ⊢_{P} [θ](¬q \overline{T_{n}} ← ⊤)>>¬q \overline{M_{n}} for some θ  By inversion
Γ; D ⊢_{P} [θ]\overline{T_{n}} =^{·} \overline{M_{n}}  By inversion
Γ; D ⊢_{P} [θ]T_{i} =^{·} M_{i}  By inversion
⊥  (∗) and Lemma 6.33 on above line
Subcase: Γ; D ⊢_{P} ∀(¬q \overline{S_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} [θ′]\overline{S_{n}} =^{·} \overline{M_{n}}  By inversion
Γ; D ⊢_{P} [θ′]S_{i} =^{·} M_{i}  By inversion
⊥  From line (∗) and S_{i} rigid.

No case for I^{+} ends in >> →, I^{−} ends in >>⊥: if ⊤_{q} is the only definition for q, then by schema satisfaction ∀(q \overline{N_{e_{x}}^{i}} ← H) could not be an assumption. No case for I^{+} ends in >> →, I^{−} ends in >>⊥: ditto.

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{1}>>Q \\ & >>∧_{1} \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢ Not_{D}(D′)>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
⊥  By IH 2.2

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{2}>>Q \\ & >>∧_{2} \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢ Not_{D}(D′)>>¬Q: Symmetric to the above. Case:

I^{−} = Γ; D ⊢_{P} Not_{D}(D′_{1})>>¬Q >>∧_{1} Γ; D ⊢_{P} Not_{D}(D′_{1} ∨ D′_{2})>>¬Q

and I^{−} ends in Γ; D ⊢ D>>Q. By IH 2.3 Case:

I^{−} = Γ; D ⊢_{P} Not_{D}(D′_{2})>>¬Q >>∧_{2} Γ; D ⊢_{P} Not_{D}(D′_{1} ∨ D′_{2})>>¬Q

and I^{−} ends in Γ; D ⊢ D>>Q. By IH 2.3. Case:

I^{−} = Γ; D ⊢_{P} Not_{D}(D′_{1})>>¬Q Γ; D ⊢_{P} Not_{D}(D′_{2})>>¬Q >>∨ Γ; D ⊢_{P} Not_{D}(D′_{1} ∧ D′_{2})>>¬Q

and I^{−} ends in Γ; D ⊢ D>>Q. By IH 2.3.

2.4 Let D ⊑ def(q, D) and D′ ⊑ def(q, D). There are two main cases, according to whether D and D′

belong to the same block (and in this case it suffices to consider D ≡ D′) or not:

1. It is not the case that I^{+} :: Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P} Notα(D)>>¬Q. By mutual induction on the structure of I^{+} and S^{+}.

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} [σ]G \\ & >> → \\ Γ; D ⊢_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Notα(∀(q \overline{N_{n}} ← G))>>¬q \overline{M_{n}}.

Draft of July 6, 2000

S_{1}^{+} :: Γ; D ⊢_{P} [σ]G  By sub-derivation
Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}}  By sub-derivation

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{N_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{N_{n}}))) ∧ ∀(¬q \overline{N_{n}}) ← Not_{G}(G)>>¬q \overline{M_{n}}

By rule Notα →

Γ; D ⊢_{P} [σ]N_{i} =^{·} M_{i} (+) for all 1 ≤ i ≤ n  By inversion
Γ ⊢ M_{i} ∈ ∥N_{i}∥ (∗) for all 1 ≤ i ≤ n  By inversion

Subcase: [σ]N_{i} ≢ e_{x}, [σ]N_{i} rigid:

Γ; D ⊢_{P} Not_{x}^{C}(q \overline{N_{n}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{1≤i≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{j}]\overline{Z_{n}}>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{j}  By inversion
⊥  Above line and (+).

Subcase: [σ]N_{i} ≡ e_{x}:

Γ; D ⊢_{P} (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{N_{n}})))>>[σ]¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} Not_{x}^{i}(\overline{N_{n}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{1≤i≤n} ⋀_{N∈Γ⊢Not(M_{i})} ∀(¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}} ← ⊤)>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{N∈Γ⊢Not(M_{i})} ∀(¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}} ← ⊤)>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} M_{i} =^{·} [θ]N  By inversion
Γ ⊢ M_{i} ∈ ∥N∥ for some N ∈ Γ ⊢ Not(N_{i})  By definition of ∥ ∥
⊥  By term exclusivity (4.21) with line (∗)
Subcase: Γ; D ⊢_{P} ¬∀(q \overline{N_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} Not_{G}([σ]G)  By inversion
⊥  By IH 1 on S_{1}^{+}

Case: I^{+} ends in >>∨, >>∧, >>∀: by IH 2.4.1 similarly to case 2.1 with Notα in place of Not_{D}.

2. It is not the case that I^{+} :: Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P} Notα(D′)>>¬Q. By simultaneous

induction on the structure of I^{+} and I^{−}: No case for I^{+} ends in >>⊤. No case for I^{+} ends in >>⊥, by restriction to complementable clauses and schema satisfaction. No case for I^{+} ends in >> →, I^{−} ends in >>⊥, as above.

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} [σ]\overline{N_{i}^{y}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} [σ]G \\ & >> → \\ Γ; D ⊢_{P} ∀(q \overline{N_{i}^{y}} ← G)>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Notα(∀(q \overline{S_{n}} ← G′))>>¬q \overline{M_{n}}, from a different block.

S_{1}^{+} :: Γ; D ⊢_{P} [σ]G  By sub-derivation
Γ; D ⊢_{P} [σ]\overline{N_{i}^{y}} =^{·} \overline{M_{n}}  By sub-derivation

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{S_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{S_{n}}))) ∧ ∀(¬q \overline{S_{n}}) ← Not_{G}(G′)>>¬q \overline{M_{n}}

By rule Notα →, y ≢ x

Γ; D ⊢_{P} [σ]N_{i} =^{·} M_{i} (+) for all 1 ≤ i ≤ n  By inversion

Subcase: [σ]N_{i} ≢ e_{y}, [σ]N_{i} rigid:

Γ; D ⊢_{P} Not_{x}^{C}(q \overline{S_{n}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{1≤i≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{j}]\overline{Z_{n}}>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{j}  By inversion
⊥  Above line, N_{j} rigid and (+).

Subcase: [σ]N_{i} ≡ e_{y}:

⊥  Above line, eigenvariable condition and (+).

Subcase: Γ; D ⊢_{P} ¬∀(q \overline{S_{n}} ← Not_{G}(G′))>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} [σ]\overline{S_{n}} =^{·} \overline{M_{n}}  By inversion
⊥  Above line, eigenvariable condition and (+).

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} [σ]G \\ & >> → \\ Γ; D ⊢_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Notα(⊤_{q}))>>¬q \overline{M_{n}}, from a different block.

S_{1}^{+} :: Γ; D ⊢_{P} [σ]G  By sub-derivation
Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}}  By sub-derivation

Γ; D ⊢_{P} ⋀_{x∈dom(Γ)}(⋀_{1≤i≤n,xR^{i}q} Not_{x}^{C}(⊤_{q})>>¬q \overline{M_{n}}

By rule Notα⊤

Γ; D ⊢_{P} [σ]N_{i} =^{·} M_{i} (+) for all 1 ≤ i ≤ n  By inversion
Γ ⊢ M_{i} ∈ ∥N_{i}∥ (∗) for all 1 ≤ i ≤ n  By inversion

[σ]N_{i} ≢ e_{x}, [σ]N_{i} rigid

Γ; D ⊢_{P} Not_{x}^{C}(q \overline{N_{n}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} ⋀_{1≤i≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{j}]\overline{Z_{n}}>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{j}  By inversion
⊥  Above line and (+).

Case:

I^{+} = \begin{aligned}Γ; D ⊢_{P} D_{1}>>Q \\ & >>∧_{1} \\ Γ; D ⊢_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢ Notα(D′)>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
⊥  By IH 2.4.2

Case: I^{+} ends in >>∧_{1}, >>∨, I^{−} ends in >>∧_{i}, >>∨: analogously by IH 2.4.2. 1 By induction on the structure of S^{+}. Case:

S^{+} = Γ; D ⊢_{P} def(q, P ∧ D)>>Q ⊢ atm Γ; D ⊢_{P} Q

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(Q):

Γ; D ⊢_{P} def(q, P ∧ D)>>Q  By sub-derivation
Γ; D ⊢_{P} ¬Q  By rule Not_{G}At
Γ; D ⊢_{P} def(¬q, P ∧ D)>>¬Q  By inversion
Subcase: Γ; D ⊢_{P} Not_{D}(def(q, P))  By definition
⊥  By IH 2.i, i ∈ {1, 3} according to D static or dynamic
Subcase: Γ; D ⊢_{P} Notα(def(q, D))  By definition
⊥  By IH 2.i, i ∈ {2, 4} according to D static or dynamic

Case:

S^{+} = \begin{aligned}Γ; D ⊢_{P} G_{1} Γ; D ⊢_{P} G_{2} \\ & ⊢ ∧ \\ Γ; D ⊢_{P} G_{1} ∧ G_{2} \end{aligned}

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(G_{1} ∧ G_{2})

Γ; D ⊢_{P} G_{1}  By sub-derivation
Γ; D ⊢_{P} G_{2}  By sub-derivation
Γ; D ⊢_{P} Not_{G}(G_{1}) ∨ Not_{G}(G_{2})  By rule Not_{G}∧

Draft of July 6, 2000

Subcase: Γ; D ⊢_{P} Not_{G}(G_{1})  By inversion
⊥  By IH 1
Subcase: Γ; D ⊢_{P} Not_{G}(G_{2})  By inversion
⊥  By IH 1

Case:

S^{+} = \begin{aligned}Γ; D ⊢_{P} G_{1} \\ & ⊢ ∨ \\ Γ; D ⊢_{P} G_{1} ∨ G_{2} \end{aligned}

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(G_{1} ∨ G_{2})

Γ; D ⊢_{P} G_{1}  By sub-derivation
Γ; D ⊢_{P} Not_{G}(G_{1}) ∧ Not_{G}(G_{2})  By rule Not_{G}∨
Γ; D ⊢_{P} Not_{G}(G_{1})  By inversion
⊥  By IH 1

Case:

S^{+} = \begin{aligned}Γ; D ⊢_{P} G_{2} \\ & ⊢ ∨ \\ Γ; D ⊢_{P} G_{1} ∨ G_{2} \end{aligned}

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(G_{1} ∨ G_{2}). Symmetrical.

Case:

S^{+} = \begin{aligned}(Γ, y:A); D ⊢_{P} [y/x]G′ \\ & ⊢∀^{∗} \\ Γ; D ⊢_{P} ∀x:a. G′ \end{aligned}

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(∀x:a. G′):

(Γ, y:A); D ⊢_{P} [y/x]G′  By sub-derivation
(Γ, y:A); D ⊢_{P} Not_{G}([y/x]G′)  By rule Not_{G}∀
⊥  By IH 1

Case:

S^{+} = \begin{aligned}Γ; (D ∧ D′) ⊢_{P} G′ \\ & ⊢ → \\ Γ; D ⊢_{P} D′ → G′ \end{aligned}

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(D′ → G′):

Γ; (D ∧ D′) ⊢_{P} G′  By sub-derivation
Γ; D ⊢_{P} D′ → Not_{G}(G′)  By rule Not_{G} →
Γ; (D ∧ D′) ⊢_{P} Not_{G}(G′)  By inversion
⊥  By IH 1

Case: The (dis)equality case follows from the decidability of the (dis)equality judgment.

□

Note that the proof goes through as there is no ‘bad’ interaction between the static and dynamic definition of a predicate; namely in sub-case 2.2 there is no overlap between a clause from def(q, P) and def(¬q, D) since in every atomic assumption there must be an occurrence of a new parameter and every term at the same position in a program clause head must be rigid. Symmetrically for 2.3. Sub-case 2.4 holds analogously to the first case 2.1, which is based on term exclusivity (Corollary 4.21). In the latter case, it suffices to consider, for D ⊑ def(q, P), only Γ; D ⊢_{P} D>>Q and Γ; D ⊢_{P} Not_{D}(D)>>¬Q, because the positive definition is a conjunction, while the negative one is a disjunction; 2.4 needs to discriminate whether the two dynamic assumptions belong to the same block: if so the same remark applies. If not, the (pivot) eigenvariable condition ensures non-overlapping.

The condition for programs to require clause heads with rigid terms may seem too restrictive; the natural way to relax it, requiring that only one of those terms which occur in the same position of a parameter in each assumption needs to be rigid, turns out to be inconsistent; in fact, the property needs to be preserved in the negative program as well. Consider the following counterexample:

plam : p (lam E) (lam F) ← ∀x:exp. p (E x) (F x).
papp : p (app E_{1} E_{2}) F.

Augmentation will insert the clause ∀(¬p x H ∧ ¬p H′ x), which now overlaps with ¬papp. As a result both p (lam(λx:exp. app x x)) (lam(λy:exp. y)) and its negation are provable.

As we remarked earlier, the rigidity condition applies only to predicate definitions which are mutually recursive to non-Horn ones. Thus, any such program which uses a ‘catch-all’ clause is those positions is forbidden; nevertheless it is easy to avoid catch-all clauses via explicit coercion or (sometimes) partial evaluation. Finally, we remark that any other (decidable) condition which avoids overlap between static and dynamic clauses will do; the one we have proposed is statically checkable, certainly not ‘ad hoc’ and has been dictated by the practice of logical frameworks.

6.8 Exhaustivity

Theorem 6.35 (Exhaustivity) Let ⊧_{S^{a}} aug_{D}(P) and Γ; D < S^{a}. For every goal G such that Γ; D\G < S^{a}, if Γ; D ⊬_{P} G then Γ; D ⊢_{P} Not_{G}(G).

Proof: Note that Γ; D ⊢_{P} def(¬q, P ∧ D)>>¬Q iff so does every disjunct. We generalize this to:

1. If S^{−} :: Γ; D ⊬_{P} G, then S^{+} :: Γ; D ⊢_{P} Not_{G}(G).

2.1 If D ⊑ def(Q, P) I^{−} :: Γ; D ⊬_{P} D>>Q, then I^{+} :: Γ; D ⊢_{P} Not_{D}(D)>>¬Q.

2.2 If D ⊑ def(Q, D) I^{−} :: Γ; D ⊬_{P} D>>Q, then I^{+} :: Γ; D ⊢_{P} Notα(D)>>¬Q.

The proof is by mutual induction on the structure of S^{−} and I^{−}. We start with part 2.1:

2.1

Case:

I^{−} = \frac{≯>⊤}{Γ; D ⊬_{P} ⊤>>Q}

Then Not_{D}(⊤) = ⊥ and

I^{+} = \frac{>>⊥}{Γ; D ⊢_{P} ⊥>>¬Q}

Case:

I^{−} = for all θ Γ; D ⊬_{P} [θ]\overline{N_{n}} =^{·} \overline{M_{n}} ≯> →^{1} Γ; D ⊬_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{n}}

for all θ Γ; D ⊬_{P} [θ]\overline{N_{n}} =^{·} \overline{M_{n}}  By sub-derivation
for all θ [θ]\overline{N_{n}} ≠ \overline{M_{n}}  By rule ⊬=^{·}
· ⊢ \overline{M_{n}} ∉ ∥\overline{N_{n}}∥  By definition of ∥ ∥
· ⊢ \overline{M_{n}} ∈ ∥Not(\overline{N_{n}})∥  By term exhaustivity (4.21)
\overline{M_{n}} = [σ]\overline{S_{n}} for some σ and \overline{S_{n}} ∈ · ⊢ Not(\overline{N_{n}})  By definition of ∥ ∥
Γ; D ⊢_{P} \overline{M_{n}} =^{·} [σ]\overline{S_{n}}  By rule ⊢=^{·}
Γ; D ⊢_{P} ∀(¬q \overline{S_{n}} ← ⊤)>>¬q \overline{M_{n}}  By rule >>∀
Γ; D ⊢_{P} ⋀_{\overline{S_{n}}∈·⊢Not(\overline{N_{n}})} ∀(¬q \overline{S_{n}} ← ⊤)>>¬q \overline{M_{n}}  By appropriate applications of rule >>∧
Γ; D ⊢_{P} ⋀_{\overline{S_{n}}∈·⊢Not(\overline{N_{n}})} ∀(¬q \overline{S_{n}} ← ⊤) ∧ ∀(¬q \overline{M_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By rule >>∧_{1}
Γ; D ⊢_{P} Not_{D}(∀(q \overline{N_{n}} ← G)>>¬q \overline{M_{n}})  By rule Not_{D}>>

Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} [σ]\overline{N_{n}} ≠^{·} \overline{M_{n}} Γ; D ⊬_{P} [σ]G \\ & ≯>→_{2} \\ Γ; D ⊬_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{n}} \end{aligned}

Γ; D ⊬_{P} [σ]\overline{N_{n}} ≠^{·} \overline{M_{n}}  By sub-derivation
Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{n}}  By rule ⊢≠^{·}
Γ; D ⊬_{P} [σ]G  By sub-derivation
Γ; D ⊢_{P} Not_{G}[σ](G)  By IH 1
Γ; D ⊢_{P} ∀(¬q \overline{N_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By rule >> →
Γ; D ⊢_{P} ⋀_{\overline{S_{n}}∈·⊢Not(\overline{N_{n}})} ∀(¬q \overline{S_{n}} ← ⊤) ∧ ∀(¬q \overline{N_{n}} ← Not_{G}(G))>>¬q \overline{M_{n}}  By rule >>∧_{2}
Γ; D ⊢_{P} Not_{D}(∀(q \overline{N_{n}} ← G))>>¬q \overline{M_{n}}  By rule Not_{D} →

Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} D_{1}>>Q \\ & ≯>∨_{1} \\ Γ; D ⊬_{P} (D_{1} ∨ D_{2})>>Q \end{aligned}

Γ; D ⊬_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} Not_{D}(D_{1})>>¬Q  By IH 2.1
Γ; D ⊢_{P} Not_{D}(D_{1}) ∧ Not_{D}(D_{2})>>¬Q  By rule >>∧_{1}
Γ; D ⊢_{P} Not_{D}(D_{1} ∨ D_{2})>>¬Q  By rule Not_{D}∨

Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} D_{2}>>Q \\ & ≯>∨_{2} \\ Γ; D ⊬_{P} (D_{1} ∨ D_{2})>>Q \end{aligned}

Symmetrical to the above. Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} D_{1}>>Q Γ; D ⊬_{P} D_{2}>>Q \\ & ≯>∧ \\ Γ; D ⊬_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

Γ; D ⊬_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊬_{P} D_{2}>>Q  By sub-derivation
Γ; D ⊢_{P} Not_{D}(D_{1})>>¬Q  By IH 2.1
Γ; D ⊢_{P} Not_{D}(D_{2})>>¬Q  By IH 2.1
Γ; D ⊢_{P} Not_{D}(D_{1}) ∨ Not_{D}(D_{2})>>¬Q  By rule >>∨
Γ; D ⊢_{P} Not_{D}(D_{1} ∧ D_{2})>>¬Q  By rule Not_{D}∧

2.2 Recall that q \overline{M_{e_{x}}^{i}} stands for q M_{1} … M_{i−1} e_{x} M_{i+1} … M_{n}, for x:A ∈ Γ:

Case:

I^{−} = \frac{≯>⊤}{Γ; D ⊬_{P} ⊤_{q}>>q \overline{M_{e_{x}}^{i}}}

Γ; D ⊢_{P} [\overline{M_{e_{x}}^{i}}/\overline{Z_{n}}]\overline{Z_{n}} =^{·} \overline{M_{e_{x}}^{i}}  By rule ⊢=^{·}
Γ; D ⊢_{P} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{i}]\overline{Z_{n}}\overline{Z_{n}}>>¬q \overline{M_{e_{x}}^{i}}  By rule >>∀
Γ; D ⊢_{P} Not_{x}^{C}(⊤_{q})>>¬q \overline{M_{e_{x}}^{i}}  By rule Not_{x}^{C}
Γ; D ⊢_{P} ⋀_{x∈dom(Γ)} ⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(⊤_{q})>>¬q \overline{M_{e_{x}}^{i}}  By appropriate applications of rule >>∧
Γ; D ⊢_{P} Notα(⊤_{q})>>¬q \overline{M_{e_{x}}^{i}}  By rule Notα⊤

Case:

I^{−} = x:a ∈ Γ, for all θ Γ; D ⊬_{P} \overline{N_{n}} =^{·} \overline{M_{e_{x}}^{i}} ≯> →^{1} Γ; D ⊬_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{e_{x}}^{i}}

for all θ Γ; D ⊬_{P} [θ]\overline{N_{n}} =^{·} q \overline{M_{e_{x}}^{i}} and x:a ∈ Γ  By sub-derivation

Draft of July 6, 2000

Subcase: e_{x} ≠^{·} [θ]N_{i}, N_{i} rigid by definition for some 1 ≤ i ≤ n:

Γ; D ⊢_{P} [\overline{M_{e_{x}}^{i}}/\overline{Z_{n}}]\overline{Z_{n}} =^{·} \overline{M_{e_{x}}^{i}}  By rule ⊢=^{·}
Γ; D ⊢_{P} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{i}]\overline{Z_{n}}>>¬q \overline{M_{e_{x}}^{i}}  By rule >>∀

Γ; D ⊢_{P} (⋀_{1≤i≤n} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q [e_{x}/Z_{i}]\overline{Z_{n}})>>¬q \overline{M_{e_{x}}^{i}}

By appropriate applications of rule >>∧

Γ; D ⊢_{P} Not_{x}^{C}(q \overline{N_{n}})>>¬q \overline{M_{e_{x}}^{i}}  By rule Not_{x}^{C}

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{M_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Γ ⊢ Not_{x}^{i}(q \overline{M_{n}}))) ∧ ∀(¬q \overline{M_{n}}) ← G′>>¬q \overline{M_{e_{x}}^{i}}

By appropriate applications of rule >>∧

Γ; D ⊢_{P} Notα(∀(q \overline{N_{n}} ← G))>>¬q \overline{M_{e_{x}}^{i}}  By rule Notα →

Subcase: e_{x} =^{·} [θ]N_{i}, M_{j} ≠^{·} [θ]N_{j} for 1 ≤ i, j ≤ n, i ≠ i:

for all θ [θ]N_{j} ≠ M_{j}  By rule ⊬=^{·}
Γ ⊢ M_{j} ∉ ∥N_{j}∥  By definition of ∥ ∥
Γ ⊢ M_{j} ∈ ∥Not(N_{j})∥  By term exhaustivity (4.21)
M_{j} = [σ]N for some σ and N ∈ Γ ⊢ Not(N_{j})  By definition of ∥ ∥
Γ; D ⊢_{P} M_{j} =^{·} [σ]N  By rule ⊢=^{·}
Γ; D ⊢_{P} ∀(¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}} ← ⊤)>>¬q \overline{M_{e_{x}}^{i}}  By rule >> →

Γ; D ⊢_{P} ⋀_{N∈Γ⊢Not(M_{j})} ∀(¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}} ← ⊤)>>¬q \overline{M_{e_{x}}^{i}}

By appropriate applications of rule >>∧

Γ; D ⊢_{P} ⋀_{1≤j≤n} ⋀_{N∈Γ⊢Not(M_{j})} ∀(¬q [e_{x}/Z_{i}, N/Z_{j}]\overline{Z_{n}} ← ⊤)>>¬q \overline{M_{e_{x}}^{i}}

By appropriate applications of rule >>∧

Γ; D ⊢_{P} Not_{x}^{i}(\overline{N_{n}})>>¬q \overline{M_{e_{x}}^{i}}  By rule Not_{x}^{i}

Γ; D ⊢_{P} (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(\overline{N_{n}})>>¬q \overline{M_{e_{x}}^{i}}

By appropriate applications of rule >>∧

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{M_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{M_{n}})))>>¬q \overline{M_{e_{x}}^{i}}

By appropriate applications of rule >>∧

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{M_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{M_{n}}))) ∧ ∀(¬q \overline{M_{n}} ← G′)>>¬q \overline{M_{e_{x}}^{i}}

By rule >>∧_{2}

Γ; D ⊢_{P} Notα(∀(q \overline{N_{n}} ← G))>>¬q \overline{M_{e_{x}}^{i}}  By rule Notα →

Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} [σ]\overline{N_{n}} ≠^{·} \overline{M_{e_{x}}^{i}} Γ; D ⊬_{P} [σ]G \\ & ≯>→_{2} \\ Γ; D ⊬_{P} ∀(q \overline{N_{n}} ← G)>>q \overline{M_{e_{x}}^{i}} \end{aligned}

Γ; D ⊬_{P} [σ]\overline{N_{n}} ≠^{·} \overline{M_{e_{x}}^{i}}  By sub-derivation
Γ; D ⊢_{P} [σ]\overline{N_{n}} =^{·} \overline{M_{e_{x}}^{i}}  By rule ⊢≠^{·}
Γ; D ⊬_{P} [σ]G  By sub-derivation
Γ; D ⊢_{P} Not_{G}[σ](G)  By IH 1
Γ; D ⊢_{P} ∀(¬q \overline{N_{n}} ← Not_{G}(G))>>¬q \overline{M_{e_{x}}^{i}}  By rule >> →

Γ; D ⊢_{P} (⋀_{x∈dom(Γ)} Not_{x}^{C}(q \overline{M_{n}}) ∧ (⋀_{1≤i≤n,xR^{i}q} Not_{x}^{i}(q \overline{M_{n}}))) ∧ ∀(¬q \overline{M_{n}}) ← G′>>¬q \overline{M_{e_{x}}^{i}}

By rule >>∧_{2}

Γ; D ⊢_{P} Notα(∀(q \overline{N_{n}} ← G))>>¬q \overline{M_{e_{x}}^{i}}  By rule Notα →

Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} D_{1}>>Q \\ & ≯>∨_{1} \\ Γ; D ⊬_{P} (D_{1} ∨ D_{2})>>Q \end{aligned}

Γ; D ⊬_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} Notα(D_{1})>>¬Q  By IH 2.2
Γ; D ⊢_{P} Notα(D_{1}) ∧ Notα(D_{2})>>¬Q  By rule >>∧_{1}
Γ; D ⊢_{P} Notα(D_{1} ∨ D_{2})>>¬Q  By rule Notα∨

Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} D_{2}>>Q \\ & ≯>∨_{2} \\ Γ; D ⊬_{P} (D_{1} ∨ D_{2})>>Q \end{aligned}

Symmetrical to the above Case:

I^{−} = \begin{aligned}Γ; D ⊬_{P} D_{1}>>Q Γ; D ⊬_{P} D_{2}>>Q \\ & ≯>∧ \\ Γ; D ⊬_{P} (D_{1} ∧ D_{2})>>Q \end{aligned}

Γ; D ⊬_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊬_{P} D_{2}>>Q  By sub-derivation
Γ; D ⊢_{P} Notα(D_{1})>>¬Q  By IH 2.2
Γ; D ⊢_{P} Notα(D_{2})>>¬Q  By IH 2.2
Γ; D ⊢_{P} Notα(D_{1}) ∨ Notα(D_{2})>>¬Q  By rule >>∨
Γ; D ⊢_{P} Notα(D_{1} ∧ D_{2})>>¬Q  By rule Not_{D}∧

1 Case:

S^{−} = Γ; D ⊬_{P} def(Q, P ∧ D)>>Q ⊬ atm Γ; D ⊬_{P} Q

Subcase: D ⊑ def(Q, P)

Γ; D ⊬_{P} D>>Q  By sub-derivation
Γ; D ⊢_{P} Not_{D}(D)>>¬Q  By IH 2.1
Γ; D ⊢_{P} def(¬Q, P)>>¬Q  By repeated applications of rule >>∨
Γ; D ⊢_{P} Not_{G}(Q)  By rule ⊢ At

Subcase: D ⊑ def(Q, D)

Γ; D ⊬_{P} D>>Q  By sub-derivation
Γ; D ⊢_{P} Notα(D)>>¬Q  By IH 2.2
Γ; D ⊢_{P} def(¬Q, D)>>¬Q  By repeated applications of >>∨
Γ; D ⊢_{P} Not_{G}(Q)  By rule ⊢ At

Case:

S^{−} = \frac{⊬ ⊥}{Γ; D ⊬_{P} ⊥}

Then Not_{G}(⊥) = ⊤ = ⊤ and

S^{+} = \frac{⊢ ⊤}{Γ; D ⊢_{P} Not_{G}(⊤)}

Case:

S^{−} = \begin{aligned}Γ; D ⊬_{P} G_{1} Γ; D ⊬_{P} G_{2} \\ & ⊬ ∨ \\ Γ; D ⊬_{P} (G_{1} ∨ G_{2}) \end{aligned}

Γ; D ⊬_{P} G_{1}  By sub-derivation
Γ; D ⊬_{P} G_{2}  By sub-derivation
Γ; D ⊢_{P} Not_{G}(G_{1})  By IH 1
Γ; D ⊢_{P} Not_{G}(G_{2})  By IH 1
Γ; D ⊢_{P} Not_{G}(G_{1}) ∧ Not_{G}(G_{2})  By rule ⊢ ∧
Γ; D ⊢_{P} Not_{G}(G_{1} ∨ G_{2})  By rule Not_{G}∧

Case:

S^{−} = \begin{aligned}Γ; D ⊬_{P} G_{1} \\ & ⊬ & ∧_{1} \\ Γ; D ⊬_{P} (G_{1} ∧ G_{2}) \end{aligned}

Draft of July 6, 2000

Γ; D ⊬_{P} G_{1}  By sub-derivation
Γ; D ⊢_{P} Not_{G}(G_{1})  By IH 1
Γ; D ⊢_{P} Not_{G}(G_{1}) ∨ Not_{G}(G_{2})  By rule ⊢ ∨
Γ; D ⊢_{P} Not_{G}(G_{1} ∧ G_{2})  By rule Not_{G}∨

Case:

S^{−} = \begin{aligned}Γ; D ⊬_{P} G_{2} \\ & ⊬ & ∧_{2} \\ Γ; D ⊬_{P} (G_{1} ∧ G_{2}) \end{aligned}

Symmetrical to the above.

Case:

S^{−} = \begin{aligned}Γ; D ∧ D′ ⊬_{P} G′ \\ & ⊬ → \\ Γ; D ⊬_{P} D′ → G′ \end{aligned}

Γ; D ∧ D′ ⊬_{P} G′  By sub-derivation
Γ; D ∧ D′ ⊢_{P} Not_{G}(G′)  By IH 1
Γ; D ⊢_{P} D′ → Not_{G}(G′)  By rule ⊢→
Γ; D ⊢_{P} Not_{G}(D′ → G′)  By rule Not_{G} →

Case:

S^{−} = \begin{aligned}(Γ, y:a); D ⊬_{P} [y/x]G′ \\ & ⊬ ∀ \\ Γ; D ⊬_{P} ∀x:a. G′ \end{aligned}

(Γ, y:a); D ⊬_{P} [y/x]G′  By sub-derivation
(Γ, y:a); D ⊢_{P} [y/x]Not_{G}(G′)  By IH 1
(Γ, y:a); D ⊢_{P} ∀x:a. Not_{G}(G′)  By rule ⊢ ∀
Γ; D ⊢_{P} Not_{G}(∀x:a. G′)  By rule Not_{G}∀

Case: (dis)equations: immediate.

□

Corollary 6.36 Clause complementation satisfies the boolean rules of negation.

6.9 Refinements

In the following sections we will move towards an operational semantics for our language.

6.9.1 More on Termination

We prove that clause complementation preserve termination, so that a negative program can be used as a decision procedure if so is its positive counterpart. First some preliminaries: define Not(R) as follows:

Not(·) = ·
Not(R, G_{1} ≺ G_{2}) = Not(R), Not_{G}(G_{1}) ≺ Not_{G}(G_{2})

Observe that, by the restriction to clauses of the form ∀(Q ← G), it is sufficient to consider only goal complementation. It is clear that negation is preserved under relation union, that is:

Not(R_{1}, R_{2}) = Not(R_{1}), Not(R_{2})

We will also need the following technical Lemma, stating that goal complementation commutes with substitution:

Lemma 6.37 Let Γ ⊢ θ : Φ. Γ ⊢_{Φ} Not_{G}([θ]G) = Γ ⊢_{Φ} [θ]Not_{G}(G).

Proof: By a simple induction on the structure of the derivation of Γ ⊢_{Φ} Not_{G}(G). □

Lemma 6.38 If [R] is well-founded, so is [Not(R)].

Proof: Suppose [Not(R]) is not well-founded. Then there is an infinite descending chain … ≺ [θ]G_{i} ≺ … ≺ [θ]G_{2} ≺ [θ]G_{1}. By definition of Not(R) there is G′_{i} such that Not_{G}(G′_{i}) = G_{i} and that G′_{i} ≺ G′_{i−1} ∈ R for some i ∈ ω. Since by Lemma 6.37 Not_{G}([θ]G_{i}) = [θ]Not_{G}(G_{i}), then [R] allows an infinite descending chain … ≺ [θ]G′_{i} ≺ … ≺ [θ]G′_{2} ≺ [θ]G′_{1}, impossible. □

The final piece is to show that the relation induced by the complement of a program is the complement of the relation induced by the program itself.

Lemma 6.39

1. If π :: D ⟹^{D} R then Not_{D}(D) ⟹^{D} Not(R).

2. If α :: D ⟹^{D} R then Notα(D) ⟹^{D} Not(R).

3. If γ :: Γ ⊢ G ⟹^{G} R then Γ ⊢ Not_{G}(G) ⟹^{G} Not(R).

Proof: By induction on the structure of the given derivations. We prove some selected cases:

Case: π :: ⊤ ⟹^{D} ·; Not_{D}(⊤) = ⊥ ⟹^{D} · = Not(·).

Case: π ends in ∀(q \overline{M_{n}} ← G) ⟹^{D} R, [ρ]G ≺ [ρ]q \overline{M_{n}}, for a global substitution ρ:

· ⊢ [ρ]G ⟹^{G} R  By sub-derivation
· ⊢ Not_{G}([ρ]G) ⟹^{G} Not(R)  By IH 2
∀(¬q \overline{M_{n}} ← Not_{G}(G)) ⟹^{D} Not(R), Not(G) ≺ ¬q \overline{M_{n}}  By rule ⟹^{D}→
⋀_{\overline{N_{n}}∈Not(\overline{M_{n}})} ∀(¬q \overline{N_{n}}) ⟹^{D} ·  By rule ⟹^{D} ∧
⋀_{\overline{N_{n}}∈Not(\overline{M_{n}})} ∀(¬q \overline{N_{n}}) ∧ ∀(¬q \overline{M_{n}} ← Not_{G}(G)) ⟹^{D} Not(R), Not(G) ≺ ¬q \overline{M_{n}}  By rule ⟹^{D} ∧
⋀_{\overline{N_{n}}∈Not(\overline{M_{n}})} ∀(¬(q \overline{N_{n}})) ∧ ∀(¬q \overline{M_{n}} ← Not_{G}(G)) ⟹^{D} Not(R), Not(G) ≺ Not_{G}(q \overline{M_{n}})By rule Not_{G}At
Not_{D}(∀(q \overline{M_{n}} ← G)) ⟹^{D} Not(R, G ≺ ¬q \overline{M_{n}})  By def. of Not(R)

Case: γ :: Q ⟹^{G} ·; Not_{D}(Q) = ¬Q ⟹^{D} · = Not(·).

Case: γ ends in Γ ⊢ G_{1} ∧ G_{2} ⟹^{G} R_{1}, R_{2}, G_{1} ≺ G_{1} ∧ G_{2}, G_{2} ≺ G_{1} ∧ G_{2}:

Γ ⊢ G_{1} ⟹^{G} R_{1} and Γ ⊢ G_{2} ⟹^{G} R_{2}  By sub-derivation
Γ ⊢ Not_{G}(G_{1}) ⟹^{G} Not(R_{1}) and Γ ⊢ Not_{G}(G_{2}) ⟹^{G} Not_{G}(R_{2})  By IH 2
Γ ⊢ Not(G_{1}) ∨ Not_{G}(G_{2}) ⟹^{G} Not(R_{1}), Not(R_{2}),
Not_{G}(G_{1}) ≺ Not_{G}(G_{1}) ∨ Not_{G}(G_{2}), Not_{G}(G_{2}) ≺ Not_{G}(G_{1}) ∨ Not_{G}(G_{2})  By rule
Γ ⊢ Not(G_{1} ∧ G_{2}) ⟹^{G} Not(R_{1}), Not(R_{2}),
Not_{G}(G_{1}) ≺ Not_{G}(G_{1} ∧ G_{2}), Not_{G}(G_{2}) ≺ Not(G_{1} ∧ G_{2})  By rule
Γ ⊢ Not(G_{1} ∧ G_{2}) ⟹^{G} Not(R_{1}, R_{2}, G_{1} ≺ G_{1} ∧ G_{2}, G_{2} ≺ G_{1} ∧ G_{2})  By union and def. of Not(R)
□

Corollary 6.40 If P is terminating, so is Not_{D}(P).

Proof: By definition, P ↓ if P ⟹^{D} R and [R] is well-founded: by Lemma 6.39 Not_{D}(P) ⟹^{D} Not(R) and by Lemma 6.38 [Not(R)] is well-founded. Thus Not_{D}(P) ↓ . □

\frac{∨⊤D}{⊤ ∨ D \ ⊤}  \frac{∨D⊤}{D ∨ ⊤ \ ⊤}
\frac{∨⊥D}{⊥ ∨ D \ D}  \frac{∨D⊥}{D ∨ ⊥ \ D}

\frac{∨AtAt}{∀(q N⃗_{1} ← G_{1}) ∨ ∀(q N⃗_{2} ← G_{2}) \ ∀(q N⃗_{1} ← (N⃗_{1} =^{·} N⃗_{2}) ∧ G_{1} ∧ G_{2})}

q ≢ q′ ∨AtAt ≢

∀(q N⃗_{1} ← G_{1}) ∨ ∀(q′ N⃗_{2} ← G_{2}) \ ⊤

\begin{aligned}D_{1} ∨ D_{2} \ D  D′_{1} ∨ D_{2} \ D′ \\ & ∨ ∨ L \\ (D_{1} ∨ D′_{1}) ∨ D_{2} \ D ∨ D′ \end{aligned}  \begin{aligned}D_{1} ∨ D_{2} \ D  D′_{1} ∨ D_{2} \ D′ \\ & ∨ ∧ L \\ (D_{1} ∧ D′_{1}) ∨ D_{2} \ D ∧ D′ \end{aligned}

\begin{aligned}D_{1} ∨ D_{2} \ D  D′_{1} ∨ D_{2} \ D′ \\ & ∨ ∨ R \\ D_{2} ∨ (D_{1} ∨ D′_{1}) \ D ∨ D′ \end{aligned}  \begin{aligned}D_{1} ∨ D_{2} \ D  D′_{1} ∨ D_{2} \ D′ \\ & ∨ ∧ R \\ D_{2} ∨ (D_{1} ∧ D′_{1}) \ D ∧ D′ \end{aligned}

Figure 6.14: ∨-Elimination: D_{1} ∨ D_{2} \ D

6.9.2 Elimination of ∨

We now show how to eliminate the ∨ operator preserving provability; this will recover uniformity in proofsearch. We generalize the approach in [BMPT90], where the operation was defined as follows: for m_{1} : Q_{1} ← G_{1} and m_{2} : Q_{2} ← G_{2}:

m_{1} ∨ m_{2} = θ(Q_{1} ← G_{1} ∧ G_{2}) where θ = mgu(Q_{1}, Q_{2})

As we remarked earlier, the ∨ operator was introduced to preserve the duality under negation between conjunction and disjunction in clauses. Its use, as a clause constructor, is limited to clauses in the same predicate definition and therefore it can be eliminated simulating unification in the definition. Yet, the strict higher-order unification problem is quite complex and potentially even more so complicated by the mixed quantifier structure of HHF, though this is not the case for our language. Moreover, we have already in our language variable-variable (dis)equations stemming from left-linearization and normalization of input variables. Finally, we have defined unification of simple terms in Section 4.3 as an intersection operation. This has greatly simplified the presentation, but does not immediately give us a notion of most general unifiers seen as sets of substitutions. We thus choose to compile our source into an intermediate language which makes unification problems explicit as simple equational problems in the style of the unification logic introduced in [Pfe91a]. We can perform unification as constraint simplification as used in Elf [Pfe89] and Twelf [SP98] in a later stage that we do not describe here.

We adapt the residuation technique used in [Pfe92] to compile immediate implication into resolution. We define the judgment D_{1} ∨ D_{2} \ D in Figure 6.14 by simultaneous induction on D_{1} and D_{2}, with the intended meaning of ‘D_{1} ∨ D_{2} compiles to D’.

Example 6.41 Continuing Example 6.26, recall that:

Not_{D}(cloz) =
∀F:exp. ¬closed (lam F) ∧ (∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2})).
Not_{D}(clolam) =
¬closed z ∧ ∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2}) ∧
∀E:exp. ¬closed (lam E) ← ∀x:exp. (closed x → ¬closed (E x)).

132  CHAPTER 6. CLAUSE COMPLEMENTATION

Removing trivially unsatisfiable clauses, the computation of Not_{D}(cloz) ∨ Not_{D}(clolam) \ D results in:

\begin{matrix}∀E:exp. ¬closed (lam E) ← (∀x:exp. closed x → ¬closed (E x)) ∧ \\ ∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2}). \end{matrix}

Going back to the linx example:

Not_{D}(linxx) ∨ Not_{D}(linxap1) =

(¬linx(λx . app (E_{1} x) (E_{2} x)) ∧ ¬linx(λx . lam(λy . (E x y)))) ∨
(¬linx(λx . x) ∧ ¬linx(λx . lam(λy . (E x y))) ∧ ¬linx(λx . app (E_{1} x) (E_{2} x^{1}))
∧ ¬linx(λx . app (E_{1} x) (E_{2} x^{0})) ← ¬linx(λx . E_{1} x))

Not_{D}(linxx) ∨ Not_{D}(linxap1) \ D, where

D =

¬linx(λx . app (E_{1} x) (E_{2} x^{1})) ∧
¬linx(λx . app (E_{1} x) (E_{2} x^{0})) ← ¬linx(λx . E_{1} x) ∧
¬linx(λx . lam(λy . E x y)).

The following lemma guarantees that compilation preserves run-time immediate entailment: Lemma 6.42 Let D_{1} ∨ D_{2} \ D: for every ground substitution Γ ⊢ θ : Φ, Γ; D ⊢ [θ](D_{1} ∨ D_{2})>>Q iff Γ; D ⊢ [θ]D>>Q. Proof: (→). By induction on the structure of π :: D_{1} ∨ D_{2} \ D. Case: π ends in ∨⊤D, ∨AtAt ≢: trivially true. Case: π ends in ∨⊥D, ∨At⊥: immediate. Case:

π = \frac{∨atm}{∀(q N⃗_{1} ← G_{1}) ∨ ∀(q N⃗_{2} ← G_{2}) \ ∀(q N⃗_{1} ← (N⃗_{1} =^{·} N⃗_{2}) ∧ G_{1} ∧ G_{2})}

Γ; D ⊢_{P} [θ](∀(q N⃗_{1} ← G_{1}) ∨ ∀(q N⃗_{2} ← G_{2}))>>q N⃗  By hypothesis
Γ; D ⊢_{P} [θ](∀(q N⃗_{1} ← G_{1}))>>q N⃗ and [θ](∀(q N⃗_{2} ← G_{2}))>>q N⃗  By inversion
Γ; D ⊢_{P} [θ · σ_{1}]N⃗_{1} =^{·} N⃗ and Γ; D ⊢_{P} [θ · σ_{1}]G_{1}  By inversion
Γ; D ⊢_{P} [θ · σ_{2}]N⃗_{2} =^{·} N⃗ and Γ; D ⊢_{P} [θ · σ_{2}]G_{2}  By inversion
Γ; D ⊢_{P} [θ · σ_{1}]N⃗_{1} =^{·} [θ · σ_{2}]N⃗_{2}  By replacement

Γ; D ⊢_{P} [θ · σ_{1} · σ_{2}]N⃗_{1} =^{·} [θ · σ_{1} · σ_{2}]N⃗_{2} ∧ [θ · σ_{1} · σ_{2}]G_{1} ∧ [θ · σ_{1} · σ_{2}]G_{2}

By composition of ground substitution

Γ; D ⊢_{P} [θ](∀(q N⃗_{1} ← (N⃗_{1} =^{·} N⃗_{2}) ∧ G_{1} ∧ G_{2}))>>q N⃗  By rule

Case: π ends in ∨At∧, ∨At∨, ∨∧, ∨∨: by an immediate appeal to the IH. (←): similarly. □ We remark that, using again terminating programs, the above Lemma covers immediate denial as well.

We now extend the effect of the above compilation on a program:

Draft of July 6, 2000

6.9. REFINEMENTS  133

Definition 6.43

(⊤)^{∨_{D}} = ⊤
(⊥)^{∨_{D}} = ⊥
(∀(Q ← G))^{∨_{D}} = ∀(Q ← (G)^{∨_{G}})
(D_{1} ∧ D_{2})^{∨_{D}} = (D_{1})^{∨_{D}} ∧ (D_{2})^{∨_{D}}
(D_{1} ∨ D_{2})^{∨_{D}} = D  where (D_{1})^{∨_{D}} ∨ (D_{2})^{∨_{D}} \ D
(X)^{∨_{G}} = X  X ∈ {⊤, ⊥, Q, (dis)eq}
(G_{1} ∧ G_{2})^{∨_{G}} = (G_{1})^{∨_{G}} ∧ (G_{2})^{∨_{G}}
(G_{1} ∨ G_{2})^{∨_{G}} = (G_{1})^{∨_{G}} ∨ (G_{2})^{∨_{G}}
(D → G)^{∨_{G}} = (D)^{∨_{D}} → (G)^{∨_{G}}
(∀x:a. G)^{∨_{G}} = ∀x:a. (G)^{∨_{G}}

Theorem 6.44 (Elimination of ∨) For every ground substitution Γ ⊢ θ : Φ 1. S :: Γ; D ⊢_{P} [θ]G iff (S)^{∨}) :: Γ; ([θ]D)^{∨_{D}} ⊢_{P} ([θ]G)^{∨_{G}};

2. I :: Γ; D ⊢_{P} [θ]D>>Q iff (I)^{∨} :: −; ([θ]D)^{∨_{D}} ⊢_{P} ([θ]D)^{∨_{D}}>>Q. Proof: (→). By a straightforward mutual induction on the structure of the given derivations: we show the crucial case. Case: (I)^{∨} ends in >>∨:

Γ; D ⊢_{P} [θ]D_{1}>>Q and Γ; D ⊢_{P} [θ]D_{2}>>Q  By sub-derivation
Γ; ([θ]D)^{∨_{D}} ⊢_{P} ([θ]D_{1})^{∨_{D}}>>Q and Γ; ([θ]D)^{∨_{D}} ⊢_{P} ([θ]D_{2})^{∨_{D}}>>Q  By IH 2
Γ; ([θ]D)^{∨_{D}} ⊢_{P} ([θ]D_{1})^{∨_{D}} ∨ ([θ]D_{2})^{∨_{D}}>>Q  By rule >>∨
Γ; ([θ]D)^{∨_{D}} ⊢_{P} [θ](D_{1} ∨ D_{2})^{∨_{D}}>>Q  By Lemma 6.42

(←). Similarly. □ The same remark w.r.t. termination applies.

We finish up this Chapter by completing our two running example, where in a final pass we have also:

• Renamed negative predicates with more suggestive names.

• Removed irrelevant occurrences of ⊤.

• Hidden the irrelevant augmentation in the final negative clause.

• Brought clauses to the ‘core’ languages syntax, as in LF. Example 6.45 Concluding Example 6.26 and 6.41 the final definition of ¬closed is:

oplam : ∀E:exp. open (lam E) ← ∀x:exp. open (E x).
opap1 : ∀E_{1}, E_{2} :exp. open (app E_{1} E_{2}) ← open E_{1}.
opap2 : ∀E_{1}, E_{2} :exp. open (app E_{1} E_{2}) ← open E_{2}.

where we have hidden the irrelevant assumption closed x in oplam and renamed ‘¬closed’ into open. Example 6.46 The final definition of ¬linear and in turn ¬linx is:

Draft of July 6, 2000

¬linapp1 : ¬linear(app F G) ← ¬linear(F).
¬linapp2 : ¬linear(app F G) ← ¬linear(G).
¬linlam1 : ¬linear(lam λx . E x) ← ¬linx(λx . E x).
¬linlam2 : ¬linear(lam λx . E x)
← (∀y:exp. (¬linx(λx . y) ∧ linear(y)) → ¬linear(E y)).
¬linxap1 : ¬linx(λx . app (F x^{1}) (G x^{1})).
¬linxap2 : ¬linx(λx . app (F x^{0}) (G x)^{0}).
¬linxap3 : ¬linx(λx . app (F x^{1}) (G x^{0})) ← ¬linx(λx . F x^{1}).
¬linxap4 : ¬linx(λx . app (F x^{0}) (G x^{1})) ← ¬linx(λx . G x^{1}).
¬linxlm : ¬linx(λx . lam(λy . E x y)) ←
(∀y:exp. ¬linx(λx . y) → ¬linx(λx . E x y)).

6.10 Summary

In this Chapter we have given a complement algorithm for a significant fragment of third order Hereditary Harrop Formulae, by adapting the idea of elimination of negation introduced in [ST84] for Horn logic. This has the neat effect that negation and its problems are eliminated, i.e. we avoid any extension to the (meta) language. This has entailed finding a middle ground between the Closed World Assumption usually associated with negation and the Open World Assumption typical of logical frameworks. Our solution is to restrict the set of programs we deem deniable in a novel way, so as to enforce a Regular Word Assumption (RWA): we define a class of programs whose dynamic assumptions extend the current database in a specific regular way. Technically, this regularity under dynamic extension is calibrated so as to ensure that static and dynamic clauses never overlap. This property extends to the negative program; in a sense, we maintain a distinction between static and dynamic information, but at a much finer level, i.e. inside the definition of a predicate. The resulting fragment is very rich, as it captures the essence of the usage of hypothetical and parametric judgments in a logical framework; namely, that they are intrinsically combined to represent scoping constructs in the object language.

Conclusions and Future Work

The importance of higher-order logical frameworks and logic programming languages that depend on intuitionistic logic, open-world assumptions (changing contexts), and lambda-abstractions is becoming more apparent and their use more widespread. Recent research is attempting to increase their expressivity, while preserving the conciseness and elegance of their representation techniques. The issue of negation has to be appreciated in that context. A good understanding of negation in such settings will significantly enhance the expressive strengths of such specification languages.

In this dissertation we have presented a solution to this long-standing issue in logical frameworks endowed with a logic programming interpretation. The solution offered by our approach has the net (and neat) effect that negation and its problems are eliminated, i.e. we avoid any extension to the (meta) language.

Although the transformational approach to negation has been investigated in traditional logic programming, this is a novel approach to addressing negative information in the higher-order intuitionistic setting. Many of the techniques from Horn programs do not carry over directly, so creative solutions had to be found to adapt the idea to the higher-order setting. In particular, we had to:

1. Formulate a strict λ-calculus which is closed under term complement.

2. Find a notion of negation normal forms which is compatible with the operational semantics required by Hereditary Harrop Formulae (HHF).

3. Introduce the Regular World Assumption (RWA) as a way to reconcile the intrinsic tension between the Closed World Assumption, associated with negation, and the Open World Assumption typical of languages with embedded implication.

Elimination of negation is particularly tuned to logical frameworks: although the problems connected with negation are analogous to logical frameworks and logic programming, the solution does not need to be the same. In this sense out approach is not a panacea. For example, it is definitely non appropriate in presence of even a small database of facts. Although the typing discipline goes a long way to limit the combinatorial explosion of negative facts, often a different approach is more fruitful; consider a small database recording the age of some people. It would be painful to negate say age k s^{34}(0) by inferring non-age k 0… non-age k s^{33}(0), non-age k s^{35}(X) . In this case the use of some form of constructive negation is preferable, possibly in the form of disequations, i.e. non-age k Z ← Z ≠^{·} s^{34}(0). This area, to date, has not been explored at all in the higher-order case.

Before discussing how to extend our approach beyond some of the current limitations, we take on again the main technical restriction, i.e. to complementable programs as defined in Figure 6.7^{1}. As we have argued, the key to a successful and implementable pairing of negation and hypothetical judgments is to keep separate at any time static and dynamic information in a program. We have achieved this by requiring every assumption to be parametric, a property which is preserved by the negative program. The eigenvariable condition enforced by the operational semantics of HHF together with the rigidity restriction does the rest.

1We discuss the issue of local variables later, see Subsection 7.1.4.

Draft of July 6, 2000

We have argued that this restriction is a most natural one w.r.t. the intended application; in our experience, it covers the overwhelming majority of actual Twelf and λProlog code. This of course does not mean that there are no useful programs which lie outside of this class; it is indeed entirely possible to use hypothetical judgments in isolation from parametric ones. We have argued in Section 5.4 how sometimes this can be avoided by resorting to a finer notion of context such as the one offered in linear logic. Otherwise, it is always possible to eliminate the offending implications by introducing an explicit management of contexts. For instance, we can revisit Example 5.1 and transform

impi : nd(A imp B) ← (nd(A) → nd(B)).

into:

impi′ : nd(A imp B) ← nd2(A, B)
impi1 : nd2(A, A).
impi2 : nd2(C, A imp B) ← nd2(C, B)
impi3 : nd2(C, A imp B) ← nd2(A, B).

Although this goes against the spirit of logical frameworks based on intuitionistic logic programming , which owes part of its success to the capability of representing object-logics contexts via the meta-level scoping mechanism of embedded implication, this is not unheard of, and it is actually proposed in [MM97]. Besides, this transformation will of course be localized only to those predicates we need to complement.

7.1 Lifting Restrictions

We now address some of the restrictions which can in fact be lifted; in doing so we will consider an example which is not currently treated:

Example 7.1 Consider the following extension of the copy clauses to a third and fourth order constructs, respectively callcc and reset:

callcc : ((exp → exp) → exp) → exp.
reset : (((exp → exp) → exp) → exp) → exp
cpcallcc : cp (callcc λc:exp → exp. E c) (callcc λd:exp → exp. F d)
← (∀c:exp → exp.
(∀x:exp. ∀y:exp. cp (c x) (c y) ← cp x y)
→ cp (E c) (F c)).
cpreset : cp (reset λf:(exp → exp) → exp. E f) (reset λg:(exp → exp) → exp. F g)
← (∀f:(exp → exp) → exp.
(∀c, d:exp → exp.
cp (f c) (f d))
← (∀x, y:exp. cp x y → cp (c x) (d y))
→ cp (E f) (F f))

7.1.1 Parameters Restrictions

The restriction to parameters of base type seems to be the less complicated to lift, if we still require them to occur only in head position. We thus would redefine the class of Shallow Parameter Expressions (SPE) as:

SPE e_{x} ::= x : A | λx . e_{x} | (e_{x} M)^{k}

This will allow to complement the third-order cpcallcc clause:

c:exp → exp ⊢ Notα(∀x, y:exp. cp (c x) (c y) ← cp x y) =
∀(¬cp (c x) (lam E) ∧ ¬cp (c x) (app E_{1} E_{2}) ∧
¬cp (lam F) (c y) ∧ ¬cp (app F_{1} F_{2}) (c y) ∧
¬cp (c x) (c y) ← ¬cp x y).

The condition for parameter to occur at head position instead is orthogonal, since it is a sufficient condition for maintaining non-overlapping between dynamic and static clauses; that is, of course, the main technical idea behind the exclusivity proof. A clause can indeed be complementable, i.e. every assumption is parametric, but if the eigenvariable does not occur in head position in the assumption, then the nonoverlapping requirement may not be immediately verifiable. If we can detect by static program analysis or by any other means that no overlapping will result, then those clauses too can be promoted.

7.1.2 Extension to Any Order

We currently treat only the third-order case, that is we allow HHF which only make Horn assumptions. In this way, generally speaking, judgments on goals were only trivially recursive with the ones on clauses, since the latter would not make any new assumption. Allowing arbitrary assumptions requires instead this recursion to be unbounded. In general, most of the times we simply need to modify those judgments by passing around their contexts. To be concrete, let us consider for instance the issue of schema extraction; in the n-ary case, schemata ought to be hereditarely closed. In fact, if a HHF belongs to a schema, the latter ought to take into account any further assumption that the former may yield. The aforementioned modifications of the extraction judgments in Figure 6.5 will do the trick:

Γ; D ⊢ G ⟹^{G} S_{1} Γ; D ⊢ D ⟹^{D} S_{2}

⟹^{D}→

Γ; D ⊢ (G → D) ⟹^{D} S_{1}∥S_{2}

…

Γ; (D ∧ D) ⊢ G ⟹^{G} S_{1} Γ; D ⊢ D ⟹^{D} S_{2}

⟹^{G}→

Γ; D ⊢ D → G ⟹^{G} S_{1}∥S_{2}

For example we can extract the following schema from the extended definition of cp:

def(cp) ⟹^{D} x : exp; cp x x∥
c : exp → exp; (∀x, y:exp. cp x y → cp (c x) (c y))∥

f : (exp → exp) → exp; (∀c, d:exp → exp. cp (f c) (f d) ← (∀x, y:exp. cp x y → cp (c x) (c y)))

In this case only the schema alternative induced by the cpreset clause needs to be hereditarely closed with x : exp; cp x x; but this is already provided by the (schema extracted from the) cplam clause.

Similar changes apply to the other judgments; in particular, augmentation is generalized, so that goals which can make dynamic assumptions will be recursively augmented as well. Formally:

Γ; D ⊢ aug_{D}(D) = D^{a} Γ; (D ∧ D) ⊢ aug_{G}(G) = G^{a} aug_{G} →

Γ; D ⊢ aug_{G}(D → G) = D^{a} → G^{a}

We can therefore complement a fourth-order clause such as cpreset, where, for the sake of readability, we have not expanded the calls to Notα(D):

¬cpreset : ¬cp (reset λf:(exp → exp) → exp. E f) (reset λg:(exp → exp) → exp. F g)
← (∀f:(exp → exp) → exp.

(∀c, d:exp → exp.
(∀x, y:exp. cp x y ∧ Notα(cp x y) → ¬cp (c x) (d y))
→ ¬cp (f c) (f d) ∧ Notα(cp (f c) (f d)
→ ¬cp (E f) (F f))

7.1.3 Open Queries

One of the more widespread criticism to negation-as-failure (NF ) is that it cannot return answer substitutions; in fact, if it is not restricted to ground goals it may return unsound solutions, as detailed in Section 1.4. On the other hand, one of the bright spots of elimination of negation is the positivization of negative information, which can now be queried as regular (HHF) clauses. In particular, negative open queries are simply positive queries to the complement program and thus will return a witness if one exists. However, open queries are not accounted for in the theory we have developed so far. Indeed, we have used programs just as decision procedures, i.e. such that for every ground goal only yes/no answers can be returned. This does not need to be the case; open queries can be allowed in so far as enough ‘directionality’ is retained in the query. In fact, if we can split the arguments of a query in an input and output sequences so that termination (in the input elements) can still be determined, the proof of exclusivity will go through, provided that the no-overlapping requirement holds. However, this is almost infallibly the case, because parameters tend to occur in input position; in fact, as we have already remarked, parametric judgments are typically used to traverse scoping constructs and most of the times termination can be proven w.r.t. those terms. The idea is to give modes to predicate definitions: let q : A_{1} → … → A_{n} → o and mode(q) = m_{1}, …, m_{n} be a mode for q, where each m_{i} is either + (input) or − (output) [RP96]. More complex moding systems have been proposed in the literature about traditional logic programming , but this one may be pragmatically adequate for our purposes.Now, given m_{q} consisting of a sequence of m ≥ 1 +’s and n ≥ 0 -’s, if we can show that def(q) is terminating w.r.t. m_{q} and, in case it is a non-Horn definition, if def(q) is parametric in at least one position i such that 1 ≤ i ≤ m, then the query ∀\overline{x_{m}}. ∃\overline{y_{n}}. q \overline{x_{m}} \overline{y_{n}} is allowed. This can be recursively extended as usual to any goal (and clause). To make the discussion more concrete, let us return to the copy example. The results in Chapter 6 guarantees the following, for an appropriate context schema Γ; D:

• ∀x:exp. ∀y:exp either Γ; D ⊢ cp x y or Γ; D ⊢ ¬cp x y.

• ∀x:exp. ∀y:exp it is not the case Γ; D ⊢ cp x y and Γ; D ⊢ ¬cp x y.

But of course we may be interested in finding a y such that the above holds. By noting that copy can be shown to be terminating only with one term instantiated, we can consider say x as input and y as output. Additionally, we can check that the non-overlapping condition still holds in this case; thus we can establish:

• ∀x:exp either ∃y:exp such that Γ; D ⊢ cp x y or Γ; D ⊢ ¬cp x y.

• ∀x:exp it not the case that ∃y:exp such that Γ; D ⊢ cp x y and Γ; D ⊢ ¬cp x y.

7.1.4 Local Variables Revisited

Allowing non-ground queries has sometimes the side-effect of overcoming the strict restriction to programs without local variables. In certain cases, in fact, we can lift the local variable to the head of the clause (and possibly embed it in a constructor); thus, the variable is no more (intrinsically) existentially quantified in the body and will not cause any problem during complementation; moreover, we do not change the arity of the predicate definition, although the latter too is possible. If we can still prove the program terminating, that is the local variable plays no role in the termination argument, then we can use that predicate definition leaving the ex-local variable as an output value only. For example, we can revisit the program for type-checking in the simply typed calculus; if we change application to allow the type of the argument to the function, that is:

app : exp → exp → tp → exp.
ofapp : of (app E_{1} E_{2} T_{1}) T_{2}

← of E_{1} (arrow T_{1} T_{2})
← of E_{2} T_{1}
oflam : of (lam E) (arrow T_{1} T_{2})
← (∀x:exp. of x T_{1} → of (E x) T_{2}).

Then we can apply (a slight modification of) our complement algorithm, yielding:

¬app1 : ¬of (app E_{1} E_{2} T_{1}) T_{2}
← ¬of E_{1} (arrow T_{1} T_{2}).
¬app2 : ¬of (app E_{1} E_{2} T_{1}) T_{2}
← of E_{1} (arrow T_{1} T_{2})
← ¬of E_{2} T_{1}.
¬aug_{D}(oflam) : ¬of (lam E) (arrow T_{1} T_{2})
← (∀x:exp. of x T_{1} →

(∀T:tp. ¬of x T ← T ≠^{·} T_{1}) →

¬of (E x) T_{2}).

Of course, this lifting of local variables is not sound in general; in the former case, it is doable because T_{1} remains in output position, as (possibly higher-order) mode analysis guarantees. On the other hand, for example, it will not work for predicates as graph reachability:

\begin{matrix}path(X, Y) ← edge(X, Y). \\ path(X, Y) ← edge(X, Z) ∧ path(Z, Y). \end{matrix}

Here, the local variable Z becomes an input argument to the recursive call for path. It is our opinion that the issue of local variables during complementation does not have a universal solution. Approaches which embrace the extensional nature of universal quantification brought in by the negation of existential quantifiers [BMPT90, ABT90] are not satisfactory and robust enough to carry over to logical frameworks with intensional universal quantification. On the other end of the spectrum, the idea to simply keep those universally quantified predicates as constraints, such as in [BLLM94] will pay some run-time overhead. We instead conjecture that (sound) variable lifting may be enough for a sufficiently interesting class of programs w.r.t. our intended application. In fact, it goes along well with the rigidity restriction we have already to enforce to obtain exclusivity of complementation.

7.2 Extensions

The techniques we have described in this dissertation applies to a framework such as L_{λ}; we briefly comment on how to extend elimination of negation to richer languages.

7.2.1 Beyond Patterns

Term complementation and intersection require higher-order patterns; both λProlog and Twelf allow any (well-typed) terms, although they are dealt with differently. Since we have (dis)equations in our language, we can apply an idea analogous to normalization of input variables 6.4.1 and replace occurrence of non-patterns with fresh variables in those predicates we intend to complement, and constrain those variable to be equal to the replaced term. This is close to what happens in the Twelf implementation and allow the constraints handling mechanism to work its magic. If the framework is not constraint-oriented, it is well-known how to compile away the offending non-pattern occurrence via appropriate substitution predicates implemented through the copy clauses [Lia95].

7.2.2 Richer Type Theories

The approach we have chosen is tailored to satisfy the requirements of more complex logical frameworks than L_{λ}; thus, we now mark some observations on how elimination of negation can be extended to richer type theories.

Polymorphism

Different degrees (in the λ-cube) of polymorphism have been advocated as a feature in logical frameworks. Of course, the more expressive the type theory, the more complicated its meta-theory. Pfenning has given an algorithm for patterns unification and generalization in the Calculus of Constructions [Pfe91b]. Even if we stick to the fully applied case, term complementation may be fairly difficult to achieve in general. Languages such as λProlog instead offer the more manageable prenex (ML-like) polymorphism. In this case, a version of term complementation able to deal with polymorphic constructors, such as a polymorphic cons, should be feasible. In many ways, the problems are analogous to negation in presence of predicate quantification (see next entry 7.2.3), namely the tension between a static operation as complementation and the possible instantiations offered by polymorphism.

Dependent Types

Almost all the design decisions we have taken while addressing the issue of negation in a logical frameworkhave been motivated by the ease to extend the latter to a framework as LF/ Twelf. The very idea to allow negation by elimination owes to the attempt to preserving the adequacy of the extraordinary representation power of dependent types, while at the same time avoid to interfering with the underlying logic programming engine, which makes Twelf a unique unified meta-language for the theory and meta-theory of deductive systems. While we fall short in this dissertation to addressing dependent types directly, we believe that the machinery we have developed is robust enough for this extension. One novel problem that we can already foresee is related to the interaction between term complementation and empty types. In the simply-typed fragment we can assume every type to be inhabited, but this property is obviously undecidable in the more powerful setting. This turns out to be problematic when complementing variables; at first sight, it not clear what the complement of Γ ⊢ Not(E \overline{x_{n}}) : a M would be. One possibility is to restrict variable complementation at type a M, perhaps such that M has no internal structure at all, i.e. it is empty or just a term variable; this would cover all the examples in this dissertation. Another one could be ‘approximating’ complementation in the simply-typed fragment and then sift out the resulting complement set, in view of dependencies.

7.2.3 Predicate Quantification

In the logic programming community the term ‘higher-order ’ is usually identified with the possibility of quantifying on predicates, in the effort to simulate the first-class functions capability of functional programming languages. This is a sometimes a source of misunderstandings (let me mention Hilog [CKW93] which has a higher-order syntax and allows arbitrary terms to appear in places where predicates, functions and atomic formulas occur in predicate calculus, but its semantics is strictly first-order) and it may be overrated, at least as far as logical frameworks are concerned, as the success of frameworks such as those based on LF testify. Nevertheless, this is a useful, though not essential, feature and has been utilized for example in implementation of proof-carrying code with λProlog [AF99]. Although we have not investigated the issue in depth, it seems that clause complementation can be sometimes applied in this extended sense. For instance, let some be a predicate of type (nat → o) → natlist → o, which selects the first element in a list of numbers for which a given predicate holds P : nat → o:

shd : some (λx:nat. P x) (cons y ys)

← (P y).

stl : some (λx:nat. P x) (cons y ys)

← some (λx:nat. P x) ys.

The application of our algorithm would yield:

¬snil : ¬some (λx:nat. P x) nil
¬stl : ¬some (λx:nat. P x) (cons y ys)
← Not_{G}(P y) ∧ ¬some (λx:nat. P x) ys.

Since we cannot foresee the structure of the goal (P y) at compile-time, we delay the computation of Not_{G}(P y) until the instantiation is known. Of course, we cannot allow unrestricted instantiations, but we need to restrict P to conform to the possible context schema. This will prevent goals such as some (λx: nat. ¬even(x) → even(s(s(x))) (cons 0 nil), which will destroy exclusivity.

Of course, the above example is too simple-minded in at least one respect; we did not define term complementation on terms with some internal logical structure. The only reason the some predicate was complementable is because the predicate occurring inside a term is simply a variable, making term complement trivial. In the general case, clause heads can contain arbitrary complex terms of type o. The approach we have developed so far does not seem to capture those phenomena except in the simplest form.

7.3 Implementation Issues

A strict logical framework can be directly implemented with very minor adaptations of well-known techniques used for its linear cousins such as Lolli [Hod94, CHP97] and LLF [Cer96]. Although we argue that strictness is a useful and ubiquitous concept which deserves to be offered as a primitive notion in a logical framework, this is not the only choice.

In fact, Girard would be quick to point out that it not necessary to take strictness as a primitive at all, since linear logic is flexible enough to express the notion of ‘must occur’ already. Indeed, strict implication can be embedded into linear logic by simply defining A →^{1} B as A −∘A → B. This is of course true, but notice that while this translation will indeed retain provability, it not faithful to the structure of proofs. Since in a logical framework as LF we are also concerned with the structure of terms, this embedding is not adequate. For example, the strict term λx^{1}. c x^{1} x^{1} corresponds to both λx^{g}λy^{u}.c x^{g} y^{u} and λx^{g}λy^{u}.c y^{u} x^{g}, where the ( )^{g} notation refers to linear abstraction and application. Even if we are just considering proof search (and not terms) there are too many distinct derivations of A −∘A → B when compared to A →^{1} B. So when we take a theorem in strict logic, embed it, and run a logical frameworksuch as LLF, we incur into a fair amount of additional non-determinism. On the other hand, the strict λ-calculus captures exactly the right properties in an elegant way and can be developed from first principles. In summary, the linear λ-calculus here does not apply; even though it is clearly possible to compile strict functions to linear ones, this compilation preserves only truth, but not the structure of proofs.

Moreover, as far as negation is concerned, we can safely remain in an intuitionistic setting. The drawback is that we have to decorate source programs whose clause heads (hereditarely) contain partially applied terms with appropriate occurrences of the vacuous predicate we have mentioned in Section 2.5. The latter, under negation, is transformed in the strict one. Strict unification does not need to be considered, since every term remains in the fully-applied fragment.

For example, if we are encoding a term say ⌜Λx. e⌝ with the side condition that x ∉ F V (e), we usually represent e with a pattern variable E, which does not depend on x. For example, reconsider clause linxap1:

linxap1 : linx(λx . app (E_{1} x) E_{2}) ← linx(λx . E_{1} x).

The latter may be rewritten as:

linxap1′ : linx(λx . app (E_{1} x) (E_{2} x)) ← vacuous(λx . E_{2} x) ∧ linx(λx . E_{1} x).

where vacuos(λx . E_{2} x) enforces that x does not occur in E_{2} x. The negation transformation will convert those annotations in (pre-compiled) strict ones. Pursuing further this example, the complement of linxap1' will include:

¬linxap1′ : ¬linx(λx . app (E_{1} x) (E_{2} x)) ← strict(λx . E_{2} x) ∧ ¬linx(λx . E_{1} x).

This kind of decoration of programs is a relatively small price to pay compared to the hassle of implementing a strict calculus, only for the purpose of allowing full clause complementation; consider for example the lack so far of a crucial ingredient such as the type reconstruction algorithm (although one for a related calculus is presented in Wright’s dissertation [Wri92]). Moreover, for every signature, the definition of the predicate vacuous is completely trivial, while the one for strict is type-directed and can be automatically inferred, in the style of Miller’s copy clause [Mil89b]. On the other hand, this approach is less workable when lifting the restriction to ground goals; in the presence of open queries, in fact, those annotations would induce an undesirable ‘generate-and-test’ operational semantics: for example, the vacuous predicate would generate vacuous terms to be then checked for, in this case, linearity. It may be possible to internalize the strictness annotations as boolean constraints [HP97], in analogy to the linear case; if so, that would work very well with logical frameworks such as Twelf(X) [Vir99] which have a declarative notion of constraints.

7.4 Additional Topics

7.4.1 Higher-Order Program Algebra

Several authors have investigated the algebra of logic programs to address modularity and meta-level issues [O’K85, MP88, SW92]. In particular in [MPRT90a] the authors describe a program algebra for Horn clauses without local variables under clause complement, set union and intersection. Since they interpret negation as finite failure, exhaustivity does not hold. In fact, what they call a “constructive version of a boolean algebra” is exactly what Rasiowa [BR57] calls “quasi pseudo Boolean algebras”, that is distributive lattices which satisfy the axioms of strong negation restricted to Horn logic.

We can extend the idea of logic program algebra to a significant fragment of (third-order) HHF. In our case we take equality (≃) as operational equivalence under appropriate run-time contexts [Har92]; for every program P_{1}, P_{2} (seen as conjunction of predicate definitions) which satisfy a common context schema S, for every run-time context Γ; D < S and for every ground G:

P_{1} ≃ P_{2} iff (Γ; D ⊢_{P_{1}} G iff Γ; D ⊢_{P_{2}} G)

Then we can organize the set of (finite) programs into a boolean algebra under union ‘∧’ (lub), intersection ‘∨’ (glb), complement ‘Not_{D}’, empty program ‘⊤’ (zero) and universal program ‘⊥’ (one). Corollary 6.36 confirms that negation is boolean. Moreover, the rules for Not_{G}, Not_{D} have been engineered to respect De Morgan’s laws.

It could be interesting to study the applicability of those ideas to modularity of higher-order logic programs, in particular to the modular construction of knowledge-based systems; for example a user could collect in a module P_{1} all the positive knowledge about a predicate and in another, say P_{2}, all the negative ones (that is, the cases where the predicate does not hold). This is useful when dealing with defaults and exceptions. The system would be able to compose those modules via boolean manipulations.

7.4.2 Strictness in Explicit Substitutions

It is our contention that the strict λ-calculus that we have introduced to formulate term complementation has an independent interest in the investigation of sub-structural logics. Not only our types system is simpler and (we claim) more elegant of the ones presented in the literature (reviewed in Section 3.3), but the introduction of the notion of vacuous variables can be useful in a variety of contexts, beyond strictness analysis. One example is the study of explicit substitutions [ACCL91] in resource-conscious λ-calculi: for example, in [GPR98] and refined in [CdPR99], the authors propose a system of explicit substitutions for intuitionistic linear logic over unit, lollipop, tensor and bang, where variables can either be linear or intuitionistic. The calculus is not optimal for several reasons, to start with the need for commutative conversions. One technical issue which could be improved is the substitution “extension operator” which accounts for term to be substituted and comes in three flavors: intuitionistic, linear and ‘used’ linear. to mark a term which has already been linearly substituted. We conjecture that the availability of a well-behaved theory of vacuous variables can offer a simpler analysis of the above point.

Bibliography

[AAB92] J. M. Dunn A. Anderson and N.D. Belnap. Entailment. The Logic of Relevance and Necessity, volume 2. Princeton University Press, 1992.

[AAB^{+}95] Johan Andersson, Stefan Andersson, Kent Boortz, Mats Carlsson, Hans Nilsson, Thomas Sjöland, and Johan Widen. SICStus prolog user’s manual. Technical Report T93-01, Swedish Institute of Computer Science, 1995.

[AB75] A. Anderson and N.D. Belnap. Entailment. The Logic of Relevance and Necessity, volume 1. Princeton University Press, 1975.

[AB90] Krzysztof R. Apt and Marc Bezem. Acyclic programs. In Peter Warren, David H.D.; Szerdei, editor, Proceedings of the 7th International Conference on Logic Programming (ICLP ’90), pages 617–633, Jerusalem, June 1990. MIT Press.

[AB94] K. Apt and R. Bol. Logic programming and negation. Journal of Logic Programming, 19/20:9– 72, May/July 1994.

[ABT90] D. Pedreschi A. Brogi, P. Mancarella and F. Turini. Universal quantification by case analysis. In Proc. ECAI-90, pages 111–116, 1990.

[ABW88] K. Apt, H. Blair, and A. Walker. Towards a theory of declarative knowledge. In Jack Minker, editor, Foundations of Deductive Databases, chapter 2, pages 89–148. Morgan Kaufmann, 1988.

[ACCL91] M. Abadi, L. Cardelli, P.-L. Curien, and J.-J. Lévy. Explicit substitutions. Journal of Functional Programming, 1(4):375–416, 1991.

[Acz77] Peter Aczel. An introduction to inductive definitions. In J. Barwise, editor, Handbook of Mathematical Logic, volume 90 of Studies in Logic and the Foundations of Mathematics, chapter C.7, pages 739–782. North-Holland, Amsterdam, 1977.

[AF99] Andrew W. Appel and Amy P. Felty. Lightweight lemmas in lambda prolog. In Danny De Schreye, editor, Proceedings of the International Conference on Logic Programming (ICLP’99), pages 411–425, Las Cruces, New Mexico, December 1999. MIT Press.

[Apt90] Krzysztof R. Apt. Logic programming. In J. van Leewen, editor, Handbook of Theoretical Computer Science, volume B: Formal Models and Semantics, chapter 10, pages 493–574. The MIT Press, New York, N.Y., 1990.

[Bar80] H. P. Barendregt. The Lambda-Calculus: Its Syntax and Semantics. North-Holland, 1980.

[BDLM00] Bugliesi, Delzanno, Liquori, and Martelli. Object calculi in linear logic. JLC: Journal of Logic and Computation, 10, 2000.

[Bel74] N.D. Belnap. Functions which really depend on their argument. Manuscript, 1974.

[Bel93] N. D. Belnap. Life in the undistributed middle. In K. Dosen and P. Schroeder-Heister, editors, Substructural Logics, pages 31–42. Oxford University Press, 1993.

[BF93] Clement A. Baker-Finch. Relevance and contraction: A logical basis for strictness and sharing analysis. Technical Report ISE RR 34/94, University of Canberra, 1993.

[BLLM94] P. Bruscoli, F. Levi, G. Levi, and M. C. Meo. Compilative constructive negation in constraint logic programs. In Sophie Tiso, editor, Proc. Trees in Algebra and Programming - CAAP’94, 19th International Colloquium, volume 787, pages 52–76. Springer, 1994.

[BM90] Anthony J. Bonner and L. Thorne McCarty. Adding negation-as-failure to intuitionistic logic programming. In Saumya Hermenegildo Manuel Debray, editor, Proceedings of the 1990 North American Conference on Logic Programming, pages 671–693, Austin, TX, October 1990. MIT Press.

[BMPT87] R. Barbuti, Paolo Mancarella, Dino Pedreschi, and Franco Turini. Intensional negation of logic programs. In Proceedings ofTapsoft87, volume 259 of LNCS, pages 96–110, Austin, TX, October 1987. Springer Verlag Press.

[BMPT90] Roberto Barbuti, Paolo Mancarella, Dino Pedreschi, and Franco Turini. A transformational approach to negation in logic programming. Journal of Logic Programming, 8:201–228, 1990.

[BMV89] A. J. Bonner, L. T. McCarty, and K. Vadaparty. Expressing Database Queries with Intuitionistic Logic. In Ewing L. Lusk and Ross A. Overbeek, editors, Proceedings of the North American Conference on Logic Programming, pages 831–850, Cleveland, Ohio, USA, 1989.

[Bol88] A. W. Bollen. Conditional Logic Programming. PhD thesis, Australian National University, 1988.

[Bol90] A. W. Bollen. Relevant logic programming. Journal of Automated Reasoning, 7(4):563–586, December 1990.

[Bon91] A.J. Bonner. Hypothetical Reasoning in Deductive Databases. PhD thesis, Rutgers University, October 1991.

[Bon94] A.J. Bonner. Hypothetical reasoning with intuitionistic logic. In R. Demolombe and T. Imielinski, editors, Non-Standard Queries and Answers, volume 306 of Studies in Logic and Computation, pages 187–219. Oxford University Press, 1994.

[BR57] A. Bialynicki-Birula and H. Rasiowa. On the representation of quasi-boolean algebras. Bulletin de L’académie Polonaise des Sciences, 5:259–261, 1957.

[CdPR99] Iliano Cervesato, Valeria de Paiva, and Eike Ritter. Explicit substitutions for linear logical frameworks: Preliminary results. In A. Felty, editor, Proceedings of the Worskshop on Logical Frameworks and Meta-Languages — LFM’99, Paris, France, 28 September 1999.

[Cer96] Iliano Cervesato. A Linear Logical Framework. PhD thesis, Dipartimento di Informatica, Università di Torino, February 1996.

[CF58] H. B. Curry and R. Feys. Combinatory Logic. North-Holland, Amsterdam, 1958.

[Cha88] D. Chan. Constructive negation based on the completed databases. In R. A. Kowalski and K. A. Bowen, editors, Proc. Fifth International Conference and Symposium on Logic Programming, pages 111–125, Seattle, Washington, August 15-19 1988.

[Cha89] D. Chan. An Extension of Constructive Negation and its Application in Coroutining. In Ewing L. Lusk and Ross A. Overbeek, editors, Proceedings of the North American Conference on Logic Programming, pages 477–496, Cleveland, Ohio, USA, 1989.

[CHP97] Iliano Cervesato, Joshua S. Hodas, and Frank Pfenning. Efficient resource management for linear logic proof search. Theoretical Computer Science, 1997. To appear in a special issue on Proof Search in Type-Theoretic Languages, D. Galmiche, editor.

[Chu41] A. Church. The Calculi of Lambda Conversion. Princeton University Press, 1941.

[Chu51] A. Church. The weak theory of implication. In Kontrolliertes. Karl Albert, 1951.

[CKW93] Weidong Chen, Michael Kifer, and David S. Warren. Hilog: A foundation for higher-order logic programming. Journal of Logic Programming, 15(3):187–230, February 1993.

[CL89] Hubert Comon and Pierre Lescanne. Equational problems and disunification. Journal of Symbolic Computation, 7(3–4):371–425 (or 371–426??), March–April 1989.

[Cla78] K. L. Clark. Negation as failure. In H. Gallaire and J. Minker, editors, Logic and Databases, pages 293–322. Plenum Press, New York, 1978.

[Col84] A. Colmerauer. Equations and Inequations on Finite and Infinite Trees. In Proceedings of the International Conference on Fifth Generation Computer Systems (FGCS-84), pages 85–99, Tokyo, Japan, November 1984. ICOT.

[Com88] H. Comon. Unification et disunification. Théories et applications. Thèse de Doctorat d’Université, Institut Polytechnique de Grenoble (France), 1988.

[Com91] H. Comon. Disunification: a survey. In J-L. Lassez and G.Plotkin, editors, Computational Logic. MIT Press, Cambridge,MA, 1991.

[Com98] H. Comon. About proofs by consistency. Lecture Notes in Computer Science, 1379:136–??, 1998.

[CP96] Iliano Cervesato and Frank Pfenning. A linear logical framework. In E. Clarke, editor, Proceedings of the Eleventh Annual Symposium on Logic in Computer Science, pages 264–275, New Brunswick, New Jersey, July 1996. IEEE Computer Society Press.

[dB80] N.G. de Bruijn. A survey of the project AUTOMATH. In J.P. Seldin and J.R. Hindley, editors, To H.B. Curry: Essays in Combinatory Logic, Lambda Calculus and Formalism, pages 579–606. Academic Press, 1980.

[dB91] N.G. de Bruijn. A plea for weaker frameworks. In G. Huet and G. Plotkin, editors, Logical Frameworks, pages 40–67. Cambridge University Press, 1991.

[DM97] Raymond Dowell and Dale Miller. A logic for reasoning with higher-order abstract syntax: An extended abstract. In Glynn Winskel, editor, Proceedings of the Twelfth Annual Symposium on Logic in Computer Science, pages 434–445, Warsaw, Poland, June 1997.

[DPS97] Joëlle Despeyroux, Frank Pfenning, and Carsten Schürmann. Primitive recursion for higherorder abstract syntax. In R. Hindley, editor, Proceedings of the Third International Conference on Typed Lambda Calculus and Applications (TLCA’97), pages 147–163, Nancy, France, April 1997. Springer-Verlag LNCS. An extended version is available as Technical Report CMU-CS-96-172, Carnegie Mellon University.

[Dun92] P. M. Dung. Declarative semantics of hypothetical logic programming with negation as failure. In E. Lamma and P. Mello, editors, Proceedings of the Third International Workshop on Extensions of Logic Programming (ELP ’92), volume 660 of LNAI, pages 45–58, Bologna, Italy, February 1992. Springer Verlag.

[Eri93] Lars-Henrik Eriksson. Finitary Partial Inductive Definitions and General Logic. PhD thesis, Department of Computer and System Sciences, Royal Institute of Technology, Stockholm, 1993.

[Fag97] François Fages. Constructive negation by pruning. Journal of Logic Programming, 32(2):85–118, August 1997.

[FBM93] G. Levi F. Bruscoli, F. Levi and M.C. Meo. Intensional negation in constraint logic programming. In D. Sacca, editor, Proc. GULP93, pages 359–373, 1993.

[FRTW88] Norman Foo, Anand Rao, Andrew Taylor, and Adrian Walker. Deduced relevant types and constructive negation. In Robert A. Kowalski and Kenneth A. Bowen, editors, Proceedings of the Fifth International Conference and Symposium on Logic Programming, pages 126–139, Seatle, 1988. ALP, IEEE, The MIT Press.

[Gab85] Dov M. Gabbay. N-Prolog: An extension of Prolog with hypothetical implications II. Logical foundations and negation as failure. Journal of Logic Programming, 2(4):251–283, December 1985.

[Gab91] Dov Gabbay. Modal provability foundations for negation by failure, in extensions of logic programming. In Peter Schroeder-Heister, editor, Extensions of Logic Programming: International Workshop, Tübingen FRG, December 1989, volume 475 of Lecture Notes in Artificial Intelligence, pages 179–222. Springer-Verlag, 1991.

[GdQ92] Dov M. Gabbay and Ruy J. G. B. de Queiroz. Extending the Curry-Howard interpretation to linear, relevant and other resource logics. The Journal of Symbolic Logic, 57(4):1319–1365, December 1992.

[GH78] J. Guttag and J. Horning. The algebraic specification of abstract data types. Acta Informatica, 10(1):27–52, 1978.

[GL90] Michael Gelfond and Vladimir Lifschitz. Logic programs with classical negation. In David H.D. Szerdei Peter Warren, editor, Proceedings of the 7th International Conference on Logic Programming (ICLP ’90), pages 579–597, Jerusalem, June 1990. MIT Press.

[GMR92] L. Giordano, A. Martelli, and G. Rossi. Extending Horn clause logic with implication goals. Theoretical Computer Science, 95(1):43–74, March 1992.

[GO98] Laura Giordano and Nicola Olivetti. Negation as failure and embedded implication. Journal of Logic Programming, 36(2):91–147, August 1998.

[GPR98] Neil Ghani, Valeria De Paiva, and Eike Ritter. Linear explicit subsitutions. Technical Report CSR-98-2, University of Birmingham, School of Computer Science, March 1998.

[GR84] Dov M. Gabbay and U. Reyle. N-Prolog: An extension of Prolog with hypothetical implications I. Journal of Logic Programming, 1(4):319–355, December 1984.

[GR87] Jean H. Gallier and Stan Raatz. Hornlog: A graph-based interpreter for general Horn clauses. Journal of Logic Programming, 4(2):119–155, June 1987.

[GS86] Dov M. Gabbay and Marek J. Sergot. Negation as inconsistency I. Journal of Logic Programming, 3(1):1–35, April 1986.

[Hal91] L. Hallnas. Partial inductive definitions. Theoretical Computer Science, 87(1):115–147, July 1991.

[Har89] J. Harland. A Kripke-like Model for Negation as Failure. In Ewing L. Lusk and Ross A. Overbeek, editors, Proceedings of the North American Conference on Logic Programming, pages 626–644, Cleveland, Ohio, USA, 1989.

[Har91a] James Harland. A clausal form for the completion of logic programs. In Koichi Furukawa, editor, Proceedings of the 8th International Conference on Logic Programming, pages 711–725. MIT, June 1991.

[Har91b] James Harland. On Hereditary Harrop Formulae as a Basis for Logic Programming. PhD thesis, Edinburgh, January 1991.

[Har92] James Harland. On normal forms and equivalence for logic programs. In Krzysztof Apt, editor, Proceedings of the Joint International Conference and Symposium on Logic Programming, pages 146–160, Washington, USA, 1992. The MIT Press.

[Har93] James Harland. Success and failure for hereditary Harrop formulae. Journal of Logic Programming, 17(1):1–29, October 1993.

[Hel77] G. Helmann. Completeness of the normal typed fragment of the λ-system u. Journal of Philosophical Logic, 1977.

[Hey56] A. Heyting. Intuitionism, an Introduction. North-Holland, Amsterdam, 3 edition, 1956.

[HHP93] 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.

[HM90] Joshua S. Hodas and Dale Miller. Representing objects in a logic programming language with scoping constructs. In Peter Warren, David H.D.; Szerdei, editor, Proceedings of the 7th International Conference on Logic Programming (ICLP ’90), pages 511–528, Jerusalem, June 1990. MIT Press.

[HM94] Joshua Hodas and Dale Miller. Logic programming in a fragment of intuitionistic linear logic. Information and Computation, 110(2):327–365, 1994. A preliminary version appeared in the Proceedings of the Sixth Annual IEEE Symposium on Logic in Computer Science, pages 32–42, Amsterdam, The Netherlands, July 1991.

[Hod94] Joshua S. Hodas. Logic Programming in Intuitionistic Linear Logic: Theory, Design, and Implementation. PhD thesis, University of Pennsylvania, Department of Computer and Information Science, 1994.

[HP96] M. Hanus and C. Prehofer. Higher-order narrowing with definitional trees. In Proc. Seventh International Conference on Rewriting Techniques and Applications (RTA’96), pages 138–152. Springer LNCS 1103, 1996.

[HP97] J. Harland and D. Pym. Resource-distribution via Boolean constraints. In William McCune, editor, Proceedings of the 14th International Conference on Automated deduction, volume 1249 of LNAI, pages 222–236, Berlin, July 13–17 1997. Springer.

[HSH90] L. Hallnas and P. Schroeder-Heister. A proof-theoretic approach to logic programming: Clauses as rules. Journal of Logic and Computation, 1(2):635-660, October 1990.

[HSH91] L. Hallnas and P. Schroeder-Heister. A proof-theoretic approach to logic programming: Programs as definitions. Journal of Logic and Computation, 1(5):261-283, October 1991.

[Isa98] Isabelle. System home page, October 1998. Version 98-1.

[Jen91] Thomas P. Jensen. Strictness Analysis in Logical Form. In John Hughes, editor, Functional Programming Languages and Computer Architectures, volume 523 of Lecture Notes in Computer Science, pages 352–366, Harvard, Massachusetts, USA, 1991. Springer, Berlin.

[JLLM91] M.J. Maher J-L. Lassez and K. Marriot. Elimination of negation in term algebras. In A. Tarlecki, editor, Mathematical Foundations of Computer Science, pages 1–16, Berlin, jul 1991. Springer-Verlag.

[Kah87] Gilles Kahn. Natural semantics. In Proceedings of the Symposium on Theoretical Aspects of Computer Science, pages 22–39. Springer-Verlag LNCS 247, 1987.

[KL87] Claude Kirchner and Pierre Lescanne. Solving disequations. In Proceedings, Symposium on Logic in Computer Science, pages 347–352, Ithaca, New York, 22–25 June 1987. The Computer Society of the IEEE.

[KNW93] Keehand Kwon, Gopalan Nadathur, and Debra Sue Wilson. Implementing a notion of modules in the logic programming language λProlog. In E. Lamma and P. Mello, editors, Proceedings of the Third International Workshop on Extensions of Logic Programming, pages 359–393, Bologna, Italy, February 1993. Springer-Verlag LNAI 660.

[Kre92] Per Kreuger. GCLA II. a definitional approach to control. Technical Report R92:09, SICS, 1992.

[Lia95] Chuck Liang. Object-Level Substitution, Unification and Generalization in Meta-Logic. PhD thesis, University of Pennsylvania, August 1995.

[Lif99] Vladimir Lifschitz. Answer set planning. In D. De Schreye, editor, Proceedings of the International Conference on Logic Programming (ICLP’99), pages 23–35. MIT Press, 1999.

[Llo93] J. W. Lloyd. Foundations of Logic Programming, Second Extended Edition. Springer-Verlag, 1993.

[LM87] J.-L. Lassez and K. Marriot. Explicit representation of terms defined by counter examples. Journal of Automated Reasoning, 3(3):301–318, September 1987.

[LMR92] J. Lobo, J. Minker, and A. Rajasekar. Foundations of Disjunctive Logic Programming. MIT press, Cambridge, Massachusetts, 1992.

[LT84] J. W. Lloyd and R. W. Topor. Making PROLOG more expressive. LOGIC PROGRAM. (USA) ISSN: 0743-1066, 1(3):225–40, October 1984.

[Lug94] D. Lugiez. Higher-order disunification: Some decidable cases. In J.-P. Jouannaud, editor, Proceedings of the First International Conference on Constraints in Computational Logics, pages 121–135, Munich, Germany, September 1994. Springer-Verlag LNCS 845.

[Lug95] D. Lugiez. Positive and negative results for higher-order disunification. Journal of Symbolic Computation, 20(4):431–470, October 1995.

[Mah88] M. Maher. Complete Axiomatizations of the Algebras of finite, infinite and rational Trees. In Proc. third Annual Symposium on Logic in Computer Science, pages 348–359. Computer Society Press, July 1988.

[Mak87] Johann A. Makowsky. Why Horn formulas matter in computer science: Initial structures and generic examples. Journal of Computer and System Sciences, 34:266–292, 1987.

[MAK91] L. Hallnass Martin Aronson, L-H. Eriksson and P. Kreuger. A survey of GCLA: a definitional approach to logic programming. In Peter Schroeder-Heister, editor, Proceedings of the First International Workshop on Extensions of Logic Programming, volume 1050 of 475, pages 19– 34, Berlin, March28–30 1991. Springer.

[Mal71] A.I. Mal’cev. Complete axiomatixation of classes of locally free algebrae of varioud type. In The metamathematics of algebraic systems: Collected papers, 1936–1967, pages 262–289. North-Holland, 1971.

[McC88a] L. Thorne McCarty. Clausal intuistionistic logic: I. Fixed point semantics. Journal of Logic Programming, 5(1):1–31, March 1988.

[McC88b] L. Thorne McCarty. Clausal intuitionistic logic II. Tableau proof procedure. Journal of Logic Programming, 5:93–132, 1988.

[Mil89a] Dale Miller. Lexical scoping as universal quantification. In G. Levi and M. Martelli, editors, Proceedings of the Sixth International Conference on Logic Programming, pages 268–283, Lisbon, Portugal, June 1989. MIT Press.

[Mil89b] Dale Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. In Peter Schroeder-Heister, editor, Proceedings of the International Workshop on Extensions of Logic Programming, pages 253–281, Tübingen, Germany, 1989. Springer-Verlag LNAI 475.

[Mil89c] Dale Miller. A logical analysis of modules in logic programming. Journal of Logic Programming, 6(1-2):79–108, January 1989.

[Mil91] Dale Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. Journal of Logic and Computation, 1(4):497–536, 1991.

[Mil92] Dale Miller. Unification under a mixed prefix. Journal of Symbolic Computation, 14:321–358, 1992.

[Mil94] Dale Miller. A multiple-conclusion meta-logic. In S. Abramsky, editor, Ninth Annual IEEE Symposium on Logic in Computer Science, pages 272–281, Paris, France, July 1994.

[MM82] Alberto Martelli and Ugo Montanari. An efficient unification algorithm. ACM Transactions on Programming Languages and Systems, 4(2):258–282, April 1982.

[MM97] Raymond McDowell and Dale Miller. A logic for reasoning with higher-order abstract syntax: An extended abstract. In Glynn Winskel, editor, Proceedings of the Twelfth Annual Symposium on Logic in Computer Science, pages 434–445, Warsaw, Poland, June 1997.

[MM00] Raymond McDowell and Dale Miller. Cut-elimination for a logic with definitions and induction,. Theoretical Computer Science, 231(231):91–119, 2000.

[MMP88] Paolo Mancarella, Simone Martini, and Dino Pedreschi. Complete logic Programs with domainclosure Axiom. Journal of Logic Programming, 5:263–276, 1988.

[MN89] J. Maluszyński and T. Näslund. Fail Substitutions for Negation as Failure. In Ewing L. Lusk and Ross A. Overbeek, editors, Proceedings of the North American Conference on Logic Programming, pages 461–476, Cleveland, Ohio, USA, 1989.

[MNPS91] 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.

[Mom92] Alberto Momigliano. Minimal negation and hereditary Harrop formulae. In Anil Nerode and Mikhail Taitslin, editors, Proceedings of Logical Foundations of Computer Science (Tver ’92), volume 620 of LNCS, pages 326–335, Berlin, Germany, July 1992. Springer.

[MP88] Paolo Mancarella and Dino Pedreschi. An algebra of logic programs. In Robert A. Kowalski and Kenneth A. Bowen, editors, Proceedings of the Fifth International Conference and Symposium on Logic Programming, pages 1006–1023, Seattle, 1988. ALP, IEEE, The MIT Press.

[MP91] Spiro Michaylov and Frank Pfenning. Natural semantics and some of its meta-theory in Elf. In L.-H. Eriksson, L. Hallnäs, and P. Schroeder-Heister, editors, Proceedings of the Second International Workshop on Extensions of Logic Programming, pages 299–344, Stockholm, Sweden, January 1991. Springer-Verlag LNAI 596.

[MP93] Spiro Michaylov and Frank Pfenning. Higher-order logic programming as constraint logic programming. In Position Papers for the First Workshop on Principles and Practice of Constraint Programming, pages 221–229, Newport, Rhode Island, April 1993. Brown University.

[MPRT90a] Paolo Mancarella, Dino Pedreschi, Marina Rondinelli, and Marco Tagliatti. Algebraic properties of a class of logic programs. In Saumya Debray and Manuel Hermenegildo, editors, Proceedings of the 1990 North American Conference on Logic Programming, pages 23–39, Austin, 1990. ALP, MIT Press.

[MPRT90b] Paolo Mancarella, Dino Pedreschi, Marina Rondinelli, and Marco Tagliatti. Algebraic properties of a class of logic programs. In Saumya Debray and Manuel Hermenegildo, editors, Proceedings of the 1990 North American Conference on Logic Programming, pages 23–39, Austin, 1990. ALP, MIT Press.

[Myc80] Alan Mycroft. The theory and practice of transforming call-by-need to call-by-value. In Proceedings of the 4th International Symposium on Programming, volume 83 of Lecture Notes in Computer Science, pages 269–281. Springer Verlag, 1980.

[Nai86] Lee Naish, editor. Negation and Control in Prolog, volume 238 of Lecture Notes in Computer Science. Springer Verlag, 1986.

[Nel49] D. Nelson. Constructive falsity. Journal of Symbolic Logic, pages 16–26, 1949.

[Nip91] Tobias Nipkow. Higher-order critical pairs. In G. Kahn, editor, Sixth Annual IEEE Symposium on Logic in Computer Science, pages 342–349, Amsterdam, The Netherlands, July 1991.

[Nip93] Tobias Nipkow. Orthogonal higher-order rewrite systems are confluent. In M. Bezem and J.F. Groote, editors, Proceedings of the International Conference on Typed Lambda Calculi and Applications, pages 306–317, Utrecht, The Netherlands, May 1993.

[NL92] Olivetti N. and Terracini L. N-Prolog and the equivalence of logic program. Journal of Logic Language and Information, 5:253-3392, 1992.

[NL95] Gopalan Nadathur and Donald W. Loveland. Uniform proofs and disjunctive logic programming. In D. Kozen, editor, Proceedings of the Tenth Annual Symposium on Logic in Computer Science, pages 148–155, San Diego, California, June 1995. IEEE Computer Society Press. Available as Technical Report CS-1994-40, Department of Computer Science, Duke University, December 1994.

[NM88] Gopalan Nadathur and Dale Miller. An overview of λProlog. In Kenneth A. Bowen and Robert A. Kowalski, editors, Fifth International Logic Programming Conference, pages 810– 827, Seattle, Washington, August 1988. MIT Press.

[O’K85] R. A. O’Keefe. Towards an algebra for constructing logic programs. In Proceedings of the International Symposium on Logic Programming, pages 152–161. IEEE Computer Society, Technical Committee on Computer Languages, The Computer Society Press, July 1985.

[PE88] Frank Pfenning and Conal Elliott. Higher-order abstract syntax. In Proceedings of the ACM SIGPLAN ’88 Symposium on Language Design and Implementation, pages 199–208, Atlanta, Georgia, June 1988.

[Pea90] David Pearce. Reasoning with negative information, II: Hard negation, strong negation and logic programs. In H. Pearce, D.; Wansing, editor, Proceedings of the International Workshop on Nonclassical Logics and Information Processing, volume 619 of LNAI, pages 63–79, Berlin, FRG, November 1990. Springer Verlag.

[Pet81] G. L. Peterson. Myths about the mutual exclusion problem. Information Processing Letters, 12(3):115–116, June 1981.

[Pfe89] Frank Pfenning. Elf: A language for logic definition and verified meta-programming. In Fourth Annual Symposium on Logic in Computer Science, pages 313–322, Pacific Grove, California, June 1989. IEEE Computer Society Press.

[Pfe91a] 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.

[Pfe91b] Frank Pfenning. Unification and anti-unification in the Calculus of Constructions. In Sixth Annual IEEE Symposium on Logic in Computer Science, pages 74–85, Amsterdam, The Netherlands, July 1991.

[Pfe92] Frank Pfenning. Computation and deduction. Unpublished lecture notes, 277 pp. Revised May 1994, April 1996, May 1992.

[Pfe93] Frank Pfenning. Refinement types for logical frameworks. In Herman Geuvers, editor, Informal Proceedings of the Workshop on Types for Proofs and Programs, pages 285–299, Nijmegen, The Netherlands, May 1993.

[Pfe99] Frank Pfenning. Logical frameworks. In Alan Robinson and Andrei Voronkov, editors, Handbook of Automated Reasoning. Elsevier Science Publishers, 1999. In preparation.

[PG86] David L. Poole and Randy Goebel. Gracefully adding negation and disjunction to Prolog. In Ehud Shapiro, editor, Proceedings of the Third International Conference on Logic Programming, Lecture Notes in Computer Science, pages 635–641, London, 1986. Springer-Verlag.

[Plo71] G. D. Plotkin. A further note on inductive generalization. In Machine Intelligence, volume 6, pages 101–124. Edinburgh University Press, 1971.

[PM90] Remo Pareschi and Dale Miller. Extending definite clause grammars with scoping constructs. In David H. D. Warren and Peter Szeredi, editors, Proceedings of Seventh International Conference on Logic Programming, pages 373–389, Jerusalem, Israel, June 1990. MIT Press.

[Pym99] David J. Pym. On bunched predicate logic. In G. Longo, editor, Proceedings of the 14th Annual Symposium on Logic in Computer Science (LICS’99), pages 183–192, Trento, Italy, July 1999. IEEE Computer Society Press.

[Rei78] R. Reiter. On closed world databases. In Gallaire and Minker, editors, Logic and Databases, pages 55–76. Plenum Press, New York, 1978.

[RL92] David W. Reed and Donald W. Loveland. A comparison of three Prolog extensions. Journal of Logic Programming, 12(1-2):25–50, January 1992.

[Rob65] J. Alan Robinson. A machine-oriented logic based on the resolution principle. Journal of the ACM, 12(1):23–41, January 1965.

[RP96] Ekkehard Rohwedder and Frank Pfenning. Mode and termination checking for higher-order logic programs. In Hanne Riis Nielson, editor, Proceedings of the European Symposium on Programming, pages 296–310, Linköping, Sweden, April 1996. Springer-Verlag LNCS 1058.

[Sch00] Carsten Schürmann. Automating the meta theory of deductive systems. PhD thesis, Carnegie Mellon University, 2000.

[SD94] Danny De Schreye and Stefaan Decorte. Termination of logic programs: the never-ending story. The Journal of Logic Programming, 19 & 20:199–260, May 1994.

[SH93] Peter Schroeder-Heister. Rules of definitional reflection. In M. Vardi, editor, Proceedings of the Eighth Annual IEEE Symposium on Logic in Computer Science, pages 222–232, Montreal, Canada, June 1993.

[She85] John C. Shepherdson. Negation as failure II. The Journal of Logic Programming, 2(3):185–202, Oktober 1985.

[She88] J. C. Shepherdson. Negation in logic progamming. In J. Minker, editor, Found. of Deductive Databases and Logic Programming, page 19. Morgan Kaufmann, San Mateo, CA, 1988.

[She89] J. C. Shepherdson. A sound and complete semantics for a version of negation as failure. Theoretical Computer Science, 65(3):343–371, July 1989.

[Sny91] Wayne Snyder. A proof theory for general unification. Birkhauser, Boston, 1991.

[SP98] Carsten Schürmann and Frank Pfenning. Automated theorem proving in a simple meta-logic for LF. In Claude Kirchner and Hélène Kirchner, editors, Proceedings of the 15th International Conference on Automated Deduction (CADE-15), pages 286–300, Lindau, Germany, July 1998. Springer-Verlag LNCS 1421.

[ST84] T. Sato and H. Tamaki. Transformational logic program synthesis. In International Conference on Fifth Generation Computer Systems, 1984.

[Stä92] R. F. Stärk. The Proof Theory of Logic Programs with Negation. PhD thesis, University of Berne, Switzerland, 1992.

[Sti88] Mark E. Stickel. A Prolog Technology Theorem Prover: implementation by an extended Prolog compiler. Journal of Automated Reasoning, 4:353–380, 1988.

[Stu95] Peter J. Stuckey. Negation and constraint logic programming. Information and Computation, 118(1):12–33, April 1995.

[SW92] D. T. Sannella and L. A. Wallen. A calculus for the construction of modular Prolog programs. Journal of Logic Programming, 12(1-2):147–177, January 1992.

[Thi84] Jean Jacques Thiel. Stop losing sleep over incomplete data type specifications. In Ken Kennedy, editor, Conference Record of the 11th Annual ACM Symposium on Principles of Programming Languages, pages 76–82, Salt Lake City, UT, jan 1984. ACM Press.

[TMM89] Kuo Tsung-Min and Prateek Mishra. Strictness Analysis: A New Perspective Based on Type Inference. In FPCA ’89, Functional Programming Languages and Computer Architecture, London, UK, September 11–13, 1989. ACM Press, New York.

[TS84] H. Tamaki and T. Sato. Unfold/fold transformation of logic programs. In Sten-Åke Tärnlund, editor, Proceedings of the Second International Conference on Logic Programming, pages 127– 138, Uppsala, 1984.

[Vir99] Roberto Virga. Higher-Order Rewriting with Dependent Types. PhD thesis, Department of Mathematical Sciences, Carnegie Mellon University, 1999. Forthcoming.

[Wad90] P. Wadler. Is there a use for linear logic. Technical report, University of Glasgow, 1990.

[Wal87] M. Wallace. Negation by constraints: A sound and efficient implementation of negation in deductive databases. In Proceedings of the Fifth International Conference and Symposium on Logic Programming, pages 253–263, San Francisco, August - September 1987. IEEE, Computer Society Press.

[Wan93] Heinrich Wansing. The logic of information structures, volume 681 of Lecture Notes in Artificial Intelligence and Lecture Notes in Computer Science. Springer-Verlag Inc., New York, NY, USA, 1993. Revision of the author’s doctoral thesis (Fachbereich Philosophie und Sozialwissenschaften I of the Free University of Berlin).

[WBF93] D. A. Wright and C. A. Baker-Finch. Usage analysis with natural reduction types. In Lecture Notes in Computer Science, volume 724, pages 254–266, 1993.

[WM91] Larry Wos and William McCune. Automated theorem proving and logic programming: A natural symbiosis. Journal of Logic Programming, 11(1):1–53, July 1991.

[Wri91] D. A. Wright. A new technique for strictness analysis. In TAPSOFT ’91. Springer-Verlag, New York, NY, 1991. Lecture Notes in Computer Science 494.

[Wri92] D. A. Wright. Reduction types and intensionality in the lambda-calculus. PhD thesis, University of Tasmania, September 1992.

[Wri96] David A. Wright. Linear, strictness and usage logics. In Michael E. Houle and Peter Eades, editors, Proceedings of Conference on Computing: The Australian Theory Symposium, pages 73–80, Townsville, January 29–30 1996. Australian Computer Science Communications.