Contents

1 Introduction 5

2 The Relative Complement Problem 7 2.1 The Not Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2 Disunification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3 Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.4 Complementing Higher-Order Patterns . . . . . . . . . . . . . . . 14 2.5 Partially Applied Terms . . . . . . . . . . . . . . . . . . . . . . . 18

3 A Strict λ-Calculus 21 3.1 Strict Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.2 The Canonical Form Theorem . . . . . . . . . . . . . . . . . . . . 34 3.3 Related Work on Strictness . . . . . . . . . . . . . . . . . . . . . 35

4 The Complement Problem for Patterns 43

4.1 Towards Complementation . . . . . . . . . . . . . . . . . . . . . . 43 4.1.1 Simple Terms . . . . . . . . . . . . . . . . . . . . . . . . . 44 4.1.2 Full Application . . . . . . . . . . . . . . . . . . . . . . . 49

4.2 The Complement Algorithm . . . . . . . . . . . . . . . . . . . . . 53 4.3 Unification of Simple Terms . . . . . . . . . . . . . . . . . . . . 58 4.4 The Algebra of Strict Terms . . . . . . . . . . . . . . . . . . . . . 67

5 Towards Elimination of Negation in Clauses 71 5.1 The Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.2 Introduction to HHF Complementation . . . . . . . . . . . . . . 74 5.3 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5.4 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 5.5 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.5.1 NF in Clausal Intuitionistic Logic . . . . . . . . . . . . . 84 5.5.2 NF and N-Prolog . . . . . . . . . . . . . . . . . . . . . . . 85 5.5.3 NF in first-order Uniform Proofs . . . . . . . . . . . . . . 85 5.5.4 PID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 6 Clause Complementation 91

6.1 The Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 6.1.1 Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.1.2 ⊤-Normalization . . . . . . . . . . . . . . . . . . . . . . . 95

6.2 Terminating Programs . . . . . . . . . . . . . . . . . . . . . . . . 99 6.3 Context Schemata . . . . . . . . . . . . . . . . . . . . . . . . . . 105

6.3.1 Schema Extraction . . . . . . . . . . . . . . . . . . . . . . 106 6.3.2 Context Preservation . . . . . . . . . . . . . . . . . . . . . 112

6.4 Clause Complementation . . . . . . . . . . . . . . . . . . . . . . 117 6.5 Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 6.6 Exclusivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 6.7 Exhaustivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 6.8 Refinements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

6.8.1 More on Termination . . . . . . . . . . . . . . . . . . . . 148 6.8.2 Elimination of ∨ . . . . . . . . . . . . . . . . . . . . . . . 149 6.8.3 Constraint Simplification . . . . . . . . . . . . . . . . . . 152

List of Figures

2.1 Some disunification rules . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 M is a fully applied pattern: Γ ⊢_{Σ} M f.a. . . . . . . . . . . . . . 16

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

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

4.1 Full application translation: Γ ⊢ M ⟷ N . . . . . . . . . . . . 50 4.2 Ground instance: Γ ⊢ M ∈ ∥N∥ : A . . . . . . . . . . . . . . . . . 52

5.1 odd Synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.2 Synthesis of the nonmember predicate . . . . . . . . . . . . . . . . 75

6.1 Provability and Denial . . . . . . . . . . . . . . . . . . . . . . . . 93 6.2 Immediate Entailment and Denial . . . . . . . . . . . . . . . . . 94 6.3 ⊤-Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 6.4 Generation of the Subgoal Relation . . . . . . . . . . . . . . . . . 100 6.5 Judgments Γ; D \ G < S, ⊧_{S} D and Γ; D < S . . . . . . . . . . . 107 6.6 Extracting Contexts Schemata . . . . . . . . . . . . . . . . . . . 108 6.7 Complementable clause and goal: D compl and Γ; D ⊢ G compl . 118 6.8 Clause Complementation: Not_{D}(D) = D′ . . . . . . . . . . . . . 119 6.9 Assumption Complementation: Γ ⊢ Notα(D) = D′ . . . . . . . . 120 6.10 Goal Complementation: Not_{G}(G) = G′ . . . . . . . . . . . . . . . 122 6.11 Clause Augmentation: aug_{D}(D) = D^{a} . . . . . . . . . . . . . . . 125 6.12 Goal Augmentation: Γ; D ⊢ aug_{G}(G) = G_{a} . . . . . . . . . . . . . 126 6.13 ∨-Elimination: D_{1} ∨ D_{2} \ D . . . . . . . . . . . . . . . . . . . . . 150

4  LIST OF FIGURES

Chapter 1

Introduction

Not ready yet.

Chapter 2

The Relative Complement Problem

An open term t can be in a given signature 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 that to the notion of relative complement; this corresponds to compute 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) format of equational problem [Com91], where the z_{i}’s are free.

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

With no loss of generality we will take n = 1.

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

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 March 25, 2000

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}∥, or a simpler (∃-degenerate) case of equational problem:

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

Now we turn to how to solve the relative complement problem.

2.1 The Not Algorithm

We present the ‘Not’ algorithm for first-order terms that specializes [LM87] and is at the heart of Barbuti et al.’s approach [BMPT90b]. 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 type τ_{i} and the z’a are new free variables of correct typing:

Not(z : τ)  = ∅ : τ
Not(f(\overline{t_{n}}) : τ) =
\{g(\overline{z_{p}}) : τ | for all g ∈ Σ distinct from f\} ∪
{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 (this has some analogy with the problems raised in in [FRTW88]). For example, Not(s(x).nil) does not yield only the desired {nil, 0.nil, y.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 itself of complementation without an underlying type discipline makes little sense, not only from a computational 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 evaluation of Not.

A complement operator must satisfy the following desiderata:

1. (Exclusivity) It is not the case that M is both a ground instance of N and of ¬(N).

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

That is, the Not algorithm ought to behave as a complementation operator on sets of ground terms. This cannot be achieved unless we restrict to linear terms. In other words, intensional representation 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—as well as the uncover—algorithm incorrectly yields:

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

In fact, Lassez & Marriot [LM87] have been the first ones to point out that the complement algorithm is correct only for linear terms: complement of nonlinear ones do not have a straightforward finite representation.

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 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 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 in [BMPT90b]. Miller [Mil89a] has shown how to automatically infer the equality predicate (the socalled copy clause) for any type. However, for any order grater than the first, this clauses are not Horn ones 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 couple 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_{n})∥

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 [Com91]. 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.

From an historic perspective this field became defined when it was realized by Martelli & Montanari (if not by Herbrand) that first-order unification can be seen as a transformation on set of equations. On the other hand the work of Mal’cev [Mal71] on the decidability and complete axiomability of the theory of equational algebras is clearly an ancestor. The definition of Prolog-II introduced first-class disequation. 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. As we have seen, those problems are systems of disequation with universally quantified variables. 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 therefore 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 R terminates: irreducible formulae are in solved form and have the same set of solutions of the original problem.

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

\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 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 parameter.

Figure 2.1: Some disunification rules

Thus a disunification algorithm over finite trees will solve complement problems, eventually providing values for free variables.

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

• 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 in three big chunks:

• 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, which is clearly motivated by the domain closure axiom (DCA) [MMP88]. We list below 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 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.2 and gloss over normalization steps 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.

Example 2.4

∀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)}^{∗} ⊥

Note that disunification overcomes the difference between linear and nonlinear terms in the difference between various 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 w.r.t. (relative) complement problems. Implementing disunification entails managing the non-deterministic application of a few 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.2 is likely to be attainable for complement problems, control is a major problem. We argue that using disunification for this purpose is unnecessarily general. 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 higherorder 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 theoretic 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 prototypical uncover algorithm proposed in [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 disjunct, 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 sufficiently 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 (finite1) 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 inductionless induction or proof by consistency [Com98] are under scrutiny. This is connected to the idea of the so-called inductive reducibility property. Roughly, given a rewrite system, a term t is inductively irreducible, i.e. its set of irreducible instances is obtained by computing the complement of the latter into the LHS of the system.

We now switch gears and discuss the extension of the relative complement problems 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 or complement also arise frequently. In this Chapter 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]. 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 introduce 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 prop. We thus complement only terms with no inner logical structure. The kind of programs that we discuss here do not require predicate quantification. Note of course that this is the restriction intrinsic in the LF type theory and implemented in Twelf.

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

Second, the treatment differentiates depending on whether the term to be complemented is fully applied or not, which we define in Figure 2.4. In the latter case 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. For fully applied terms instead, we proceed similarly to firstorder with an additional case for lambda expressions and 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. We first analyze this case.

The language of the simply-typed λ-calculus is as follows, where we use a to for atomic types, c for term-level constants, and x for term-level variables.

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 useful notion of normal form 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 Section 3.1. See this section for further discussion and an inductive definition of canonical forms.

We denote existential variables of type A (also called logical variables, metavariables, 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. 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).

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.1.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.

While, as we will see, the class of patterns is not closed under complement, 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}. 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

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

fa Pat

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

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

fa Lam

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

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

fa App

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

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

Definition 2.5 (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 the Z’s are fresh variables of opportune typing, m ≥ 0 and

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

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

Corollary 2.6 For c ∈ Γ ∪ Σ, Γ ⊢ Not(c : a) = diff_{Γ}(c : 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.7 Consider the untyped λ-calculus.

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.

Σ = exp : type, lam : (exp → exp) → exp, app : exp → exp → exp

The representation function is given by.

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

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 . x : exp → exp):

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

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

⌜(λ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). The complement of the right-hand side considered as a pattern with respect to the empty context contains every top-level λ-abstraction plus every application where the first argument is not an abstraction:

¬(app (lam (λx:exp. (E x)) F)) = {lam (λx:exp. H x), app (app H_{1} H_{2}) H_{3}}

Thus the negation of the betardx(app (lam (λx:exp. E x)) F) predicate is:

\begin{matrix}¬betardx(lam (λx:exp. H x)) \\ ¬betardx(app (app H_{1} H_{2}) H_{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.8 Take the signature of numerals:

n ::= 0 | s(n)

and the problem · ⊢ Not(λf:n. f0 : (n → n) → n).

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

2.5 Partially Applied Terms

Consider a predicate on the signature Σ_{lam} true if a unary function does not depend on its argument:

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

Intuitively the complement should be a predicate, say strict, true when the function does use its arguments. One way to encode 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 parametrical clauses.

Example 2.9 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 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 (Ex) x)

where E does depend on x.

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. More in general, 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 leftlinearization 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)dependency constraints in a type theory which explicitly take into account the occurrence issue, acknowledging the similarity with having type information as predicates in logic programs. 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 (and an abstractor), 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 each argument may occur: for example

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

A first try. Let \overline{x_{n}}, \overline{y_{m}} be two list 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})\}

While the complement of terms with strict application is:

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

Example 2.10

· ⊢ 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 or not of occurrence. We need a notation which captures the ‘non-occurring’ 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 establish some basic properties as normalization. The next Chapter 4.1 introduces a restriction of the language for which complementation is possible (Section 4.2). 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 of sets of terms and Section applies the result to the transformational approach to negation in higher-order logic programs.

3.1 Strict Types

As we have seen in the preceding Chapter, the complement of a partially applied pattern in the simply-typed λ-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

22  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}}

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.

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.0.1 (Inversion) All rules in λ^{→^{l}} are invertible.

As it can be inspected. 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.1 (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.2 (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 dependencies, 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 mentined.

Theorem 3.3 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}

Draft of March 25, 2000

Case

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

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

Case D ends in →^{u} I or →^{1} I: the thesis follows 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

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 = Γ; (Ω, x:C); Δ ⊢ M : A →^{0} B (Γ, Ω, Δ, x:C); ·; · ⊢ N : A →^{0} E Γ; (Ω, x:C); Δ ⊢ M N^{0} : B

D_{1} :: Γ; (Ω, 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 =

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

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

D_{1} :: (Γ, Δ_{N}); (Ω, x:C); Δ_{M} ⊢ M : A →^{1} B  By sub-derivation
(Γ, x:C, Δ_{N}); Ω; Δ_{M} ⊢ M : A →^{1} B  By IH on D_{1}
D_{2} :: (Γ, Δ_{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.4 (Loosening^{0}) If Γ; (Ω, Φ); Δ ⊢ M : A then (Γ, Φ); Ω; Δ ⊢ M : A. Proof: By repeated application of Theorem 3.3. □ Theorem 3.5 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}

Γ; Ω; (Δ, 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

Draft of March 25, 2000

Case D ends in →^{1}. There are two subcases:

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.6 (Loosening^{1}) If Γ; Ω; Δ ⊢ M : A then (Γ, Δ); Ω; · ⊢ M : A. Proof: By repeated application of Theorem 3.5. □ Theorem 3.7 (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 induction on the height of the derivation D of M : C. We show the crucial steps.

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}

Draft of March 25, 2000

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 = \begin{aligned}(Γ, x:A, y:B); Ω; · ⊢ M : C \\ & →^{u} I \\ (Γ, x:A); Ω; · ⊢ λy^{u}:B. M : A →^{u} B \end{aligned}

(Γ, 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
Γ; Ω; Δ ⊢ [N/x](λy^{u}:B. M) : A →^{u} B  By subst.

Case D ends with another introduction rule: 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 subst.

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 1.

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 = (Γ, Δ_{N}); (Ω, y:B); (Δ_{M}, x:A) ⊢ Q : C →^{0} I (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ λx^{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 subst.

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 Γ; (Ω); (Δ_{M}, x:A, Δ_{N}) ⊢ P Q^{u}

D_{1} :: (Γ, Δ_{N}); Ω; (Δ_{M}, x:A) ⊢ P : B →^{u} C  By sub-derivation
E :: (Γ, Δ_{M}); Ω; Δ_{N} ⊢ N : A  By hypothesis
Γ; Ω; (Δ_{M}, x:A, , Δ_{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 subcases:

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

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

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

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

□

Theorem 3.8 (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
(Γ, 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. Similarly, using 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 of 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.9 (Subject Reduction) If Γ; Ω; Δ ⊢ M : A and M ⟶^{β} M′ then Γ; Ω; Δ ⊢ M′ : A.

Proof: By cases on M:

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.

Γ; Ω; (Δ_{P} , Δ_{Q}) ⊢ (λx^{1} :B. P)Q^{1} : A  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.10 (Subject Expansion) If Γ; Ω; Δ ⊢ M : A →^{k} B and M ⟶^{η̄}

M′ then Γ; Ω; Δ ⊢ M′ : A →^{k} B.

Proof: By cases on k:

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 establish a sort of consistency property of the type system, in so far as a term can be typed only by exclusive contexts. That will be central in the proof of disjointness of term complementation (Theorem 4.18):

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

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

Case

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

but there can be no proof of c : A from Γ; Ω; x:C.

Case

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

but there can be no proof of y : A from (Γ, y:A); Ω; x:C.

Case

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

but there can be no proof of y : C from Γ; Ω; (x:C, y:A).

Draft of March 25, 2000

Case

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

but there can be no proof of x : A from Γ; (Ω, x:A); ·. Case

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

and

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

Γ; Ω; (Δ, x:C, y:B) ⊢ M : A  By sub-derivation of D
Γ; (Ω, x:C); (Δ, y:B) ⊢ M : A  By sub-derivation of D′
⊥  By IH

Case D ends in →^{u} I, →^{0} I. The result follows analogously by IH. Case D ends in →^{u} E, →^{0} E. The result follows by IH on the leftmost sub-

derivations. Case D ends in →^{1} E: there are two subcases:

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

and D′ =

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

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

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

x ∈ Δ_{N} Symmetrically.

□

Corollary 3.12 (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.

Draft of March 25, 2000

Proof: By Loosening^{1} and Loosening^{0} on Lemma 3.11. □

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 →^{l} B | = | A | →^{u} | 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.13 (Conservativity) If Γ; Ω; Δ ⊢_{λ^{\underrightarrow{l}}} M : A, then | Γ |, | Ω |, | Δ | ⊢_{λ^{→}}| M | : | A |.

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

3.2 The Canonical Form Theorem

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 Fig. 3.2:

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

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

Theorem 3.14 (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]. □

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

We will also need the typing rule and the the canonical form for existential variables. We write Φ^{k} for x_{1}^{k} … x_{n}^{k}, where x_{1} … x_{n} ∈ dom(Φ). The notation π(Φ) stands for a permutation of dom(Φ).

π(Φ) = dom(Γ^{u}, Ω^{0}, Δ^{1})

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

\begin{aligned}Γ; Ω; Δ ⊢ E_{A} \overline{x_{n}^{k}} : P \\ & cP at \\ Γ; Ω; Δ ⊢ E_{A} \overline{x_{n}^{k}} ↓ P \end{aligned}

Remark 3.14.1 Exclusivity holds for open patterns as well.

Proof: Assume that both Γ; Ω; (Δ, x:C) ⊢ E Φ : A and Γ; (Ω, x:C); Δ ⊢ E Φ : A. Then π(Φ) = dom(Γ^{u}, Ω^{0}, Δ^{1}, x^{1}) and π(Φ) = dom(Γ^{u}, Ω^{0}, x^{0}, Δ^{1}), 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 combinatorK. 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 functions, 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 alternative basis. Those are the axioms of what Church called weak implicational logic, 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^{1} and climaxed with the publication of the first volume of Entailment [AB75]. Following Girard’s and Belnap’s [Bela] 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.

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

Draft of March 25, 2000

On an unrelated front, starting with Mycroft’s seminal paper [Myc80], compiletime 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 to (the implicational fragment of) relevance logic and explicitly connected the two areas, although both [Belb] and [Hel77] had previously recognized the link between strictness and relevance^{2}.

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.

2Note 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 March 25, 2000

The author goes on (see also [WBF]) 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 proposition of the form

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

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 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. 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 paper 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 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 its approach to relevant, i.e. in our terminology strict logic programming as part of its dissertation on ‘Conditional Logic Programming’ [Bol88]. He makes a (weak) case of its usefulness in applications 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 in a 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.

\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} \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

Draft of March 25, 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 ↓ P

cAt Γ; Ω; Δ ⊢ M ⇑ P

(Γ, 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}}

Draft of March 25, 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]

The Complement Problem for Patterns

4.1 Towards Complementation

[Points to keep in mind:

• Need to introduce logic variables more smoothly

• Does exclusivity hold for logic variables? (Yes) Check Remark 3.14.1

• Does exhaustivity hold for any closed simple term? (No) Provide a counterexample. Tightening fails for non-simple closed terms, i.e. for intuitionistic application.

• Proof of Lemma 4.3

]

Now that we have developed a calculus which is potentially strong enough to represent the negation 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 satisfies the usual boolean rules for negation:

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

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

Unfortunately, while the first property follows quite easily from Corollary 3.12, it turns out that the exhaustivity does not hold in general as we allow logic variables in partially applied terms. However, our algorithm is sound and complete for the fragment which results from the natural embedding of the original simply-typed λ-calculus which is sufficient for our main goal, that is its use as a subroutine of clause complementation (see Section 6.4). This entails two separate phases:

• Restrict to a class of terms (that we call simple) for which exhaustivity can be established.

• Bring to full application those terms.

4.1.1 Simple Terms

Recall that we 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.

Example 4.1 ( ) Continuing Example 2.7, 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 λ-terms into a fragment of strict terms via two mutually recursive functions ()^{−} and ()^{+}. First, the definition on types.

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

We extend it to canonical terms (including existential variables), signatures, and contexts as follows:

(λ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^{+}
(Σ, P:type)^{+} = Σ^{+}, P: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, which we call:

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

We sometimes abridge (… (h M_{1})^{1} … M_{n})^{1} in h \overline{M_{n}^{1}}. Note that, by the restriction to η-long β-normal forms, such terms as well as applications of pattern variables must be of base type.

In the following, for every judgment J on simple terms, we will shorten Γ·; ⊤ ⊢ J into Γ ⊢ J.

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

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

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.13) 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 :: Γ ⊢ M ⇑ A and D′ :: Γ ⊢ M ↓ A.

Case

D′ = \begin{aligned}c:A ∈ Σ \\ & atm var \\ Γ ⊢ c ↓ A \end{aligned}

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

\frac{cIdc}{Γ^{+} ⊢ c^{+} ↓ A^{+}}

Draft of March 25, 2000

Case

D′ = \frac{atm var}{(Γ, x:A) ⊢ x ↓ A}

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

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

Case

D′ = \begin{aligned}Γ ⊢ M ↓ B → A Γ ⊢ N ⇑ B \\ & atm app \\ Γ ⊢ M N ↓ A \end{aligned}

Γ ⊢ 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)^{+})^{1} ↓ A^{+}  By the embedding

Case

D′ = \begin{aligned}Γ ⊢ E_{A} \overline{x_{n}} : P \\ & can P at \\ Γ ⊢ E_{A} \overline{x_{n}} ↓ P \end{aligned}

Γ ⊢ E_{A} \overline{x_{n}} : P  By sub-derivation
Γ^{+} ⊢ F_{A^{−}} \overline{x_{n}^{u}} : P  By Lemma 4.3
Γ^{+} ⊢ F_{A^{−}} \overline{x_{n}^{u}} ↓ P  By rule cP at
Γ^{+} ⊢ (E_{A} \overline{x_{n}})^{+} : P^{+}  By the embedding

Case

D = \begin{aligned}Γ ⊢ M ↓ P \\ & can atm \\ Γ ⊢ M ⇑ P \end{aligned}

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

Case

D = \begin{aligned}Γ, x:A ⊢ M ⇑ B \\ & can lam \\ Γ ⊢ λx:A. M ⇑ A → B \end{aligned}

Draft of March 25, 2000

Γ, 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 drop the ()^{±} embedding annotations from terms, types and contexts. We may also hide the ()^{1} decoration from strict application of constants in examples.

We can now prove the crucial tightening lemma. It expresses 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 such that (Γ, x:C); Ω; Δ ⊢ M ⇑↓ A. Then:

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

2. Γ; Ω; (Δ, 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 thesis.

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 thesis.

Case

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

Then

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

and by weakening the thesis.

Draft of March 25, 2000

48  CHAPTER 4. THE COMPLEMENT PROBLEM FOR PATTERNS

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 thesis. Case

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

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

hence the thesis by weakening.

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

hence the thesis 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 thesis 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 the IH:

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

hence by weakening the thesis.

Draft of March 25, 2000

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

hence by weakening the thesis.

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

hence by weakening the thesis.

4. Symmetrical to 3.

□

We remark that the proof breaks down if we allow intuitionistic application, namely in the sub-case where the leftmost derivation is vacuous in x and the rightmost is strict in x.

Corollary 4.6 Let M be a simple closed patterns such that (Γ, Ω, Δ, x:C)·; ⊤ ⊢ M ⇑↓ A; then

1. either Γ; Ω; (Δ, x:C) ⊢ M ⇑↓ A or (Γ, Ω, Δ); ·; x:C ⊢ M ⇑↓ A.

2. either Γ; (Ω, x:C); Δ ⊢ M ⇑↓ A or (Γ, Ω, Δ); ·; x:C; ⊢ M ⇑↓ A.

Proof: 1. (Γ, Ω, Δ, x:C)·; ⊤ ⊢ M ⇑↓ A  By hypothesis

Γ; ·; (Ω, Δ, x:C) ⊢ M ⇑↓ A or Γ; (Ω, Δ, x:C); · ⊢ M ⇑↓ A

By repeated application of Lemma 4.5

Γ; Ω; (Δ, x:C) ⊢ M ⇑↓ A or Γ; (Ω, Δ, x:C); · ⊢ M ⇑↓ A

By Loosening^{1} Ω

Γ; Ω; (Δ, x:C) ⊢ M ⇑↓ A or (Γ, Ω, Δ); x:C; · ⊢ M ⇑↓ A By Loosening^{0} Ω, Δ

2. Similarly to above.

□

4.1.2 Full Application

It simplifies 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. We furthermore permute the argument to the standard order, which also does not affect the set of ground instances of linear patterns. In slight abuse of notation we call the resulting terms fully applied.

We describe 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

\frac{Trn Pat}{(Γ, Ω) ⊢ E π(Γ^{u}) ⟷ Z Γ^{u} Ω^{0}}

Γ, x:A ⊢ M ⟷ N

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

Γ ⊢ M_{1} ⟷ N_{1} ⋯ Γ ⊢ M_{n} ⟷ N_{n} Trn App

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

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

specialized to simple terms, it is clear how to generalize this judgment to the canonical forms of any strict term. The notation π(Γ) stands for a permutation of dom(Γ).

Example 4.7 ( ) Recall the simple term from Example 2.9:

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.4:

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, that we still call:

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:

[I think this holds for any strict terms and irrelatively to canonical forms. If so, it should sit in the previous chapter ]

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. 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
□

Draft of March 25, 2000

M ≡ t \overline{x_{n}^{k}} · ⊢ t : A

grF lx

Γ ⊢ M ∈ ∥E_{A} \overline{x_{n}^{k}}∥ : P
(Γ, x:A); Ω; Δ ⊢ M ∈ ∥N∥ : B

grLam

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

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

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

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.1.2 Γ ⊢ M ∈ ∥N∥ : A formalizes conditions for a simple term M to be a ground instance of 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.9.1 Γ ⊢ M ∈ ∥E_{A} \overline{x_{n}^{k}}∥ : P iff M ≡ t \overline{x_{n}^{k}} and · ⊢ t : A iff t ≡ λ\overline{x_{n}^{k}} . S and if \overline{x_{n}^{k}} = (Γ^{u}, Ω^{0}, Δ^{1}) then Γ; Ω; Δ ⊢ S : P.

This fact will be heavily used in the following.

Lemma 4.10 (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.

[Really??]

Now we can prove that the the full application translation preserves the set of ground instances.

Theorem 4.11 (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 Trn Pat:

(→) (Γ, Ω) ⊢ M ∈ ∥E_{B} π(Γ^{u})∥  By assumption
M ≡ t π(Γ^{u}) and · ⊢ t : B  By inversion
Γ·; ⊤ ⊢ S : A  By Remark 4.9.1
Γ·; ⊤ ⊢ 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′  By Remark 4.9.1
Γ·; ⊤ ⊢ M ∈ ∥F_{B′} Γ^{u}Ω^{0}∥  By rule
(←) (Γ, Ω)·; ⊤ ⊢ M ∈ ∥F_{B′} Γ^{u}Ω^{0}∥  By assumption
M ≡ t′ Γ^{u}Ω^{0} for · ⊢ t′ : B′  By inversion
Γ; Ω; · ⊢ S : A  By Remark 4.9.1
Γ; Ω; · ⊢ S ⇑↓ A  By the canonical form Theorem
Γ; ·; · ⊢ S ⇑↓ A  By Irrelevance (Lemma 4.9)
Γ; ·; · ⊢ S : A  By soundness of canonicity
Γ·; ⊤ ⊢ M ∈ ∥E_{B} π(Γ^{u})∥  By rule and Remark 4.9.1

Case D ends in Trn Lam or Trn App: 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 threevalued 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.12 (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}
Not F lx

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

no rule for k = u

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

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

Not App^{1}

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

∃i:1 ≤ i ≤ n Γ ⊢ Not(M_{i}) ⇒ N : A_{i}
Not App^{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} : P

where the Z’s are fresh logic variables of correct typing, h ∈ Σ ∪ Γ and Γ ⊢ h : A_{1} →^{1} … →^{1} A_{n} →^{1} P. 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 ∈ ∥N ∥ : A, when Γ ⊢ Not(N) = N and Γ ⊢ M ∈ ∥N ∥ : A. This in turn holds by inversion if there is a Q such that Γ ⊢ Not(N) ⇒ Q.

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.13 ( ) 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.14 ( ) Take the signature of numerals: Not(λx^{u}λy^{u}. s(M 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(N x^{0}y^{u})^{1}, λx^{u}λy^{u}. s(N′ x^{u}y^{1})^{1}} We can now revisit^{1} Example 2.9:

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.15 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 Not F lx: immediate. Case

D = Γ, x:A ⊢ Not(M) ⇒ N : B Not Lam Γ ⊢ Not(λx^{u}:A. M) ⇒ λx^{u}:A. N : A → 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} P m ≥ 0, h ≢ g Not App^{1} Γ ⊢ Not(h \overline{M_{n}^{1}}) ⇒ (… (g (Z_{1}Γ^{u}))^{1} … (Z_{m}Γ^{u}))^{1} : P

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

Γ ⊢ Not(M_{i}) ⇒ N : A_{i} 1 ≤ i ≤ n
Not App^{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} : P

By sub-derivation and 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.

1To 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 March 25, 2000

□

Corollary 4.16 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 abridge Not(l) in −l. We start with soundness:

Theorem 4.17 Let Γ ⊢ N : A be simple linear pattern and assume there is a 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 Not F lx. First observe that E \overline{x_{n}^{l}} can be seen as E Φ^{u}Ω^{0}Δ^{1} x^{d}, where x is determined; indeed if x is undetermined, the result holds trivially. Assume Γ ⊢ M ∈ ∥E Φ^{u}Ω^{0}Δ^{1} x^{d}∥ and Γ ⊢ M ∈ ∥F Φ^{u}Ω^{u}Δ^{u} x^{−d}∥ for some d ∈ {1, 0}. Then it holds that both Φ; Ω; (Δ, x:A) ⊢ M : C and (Φ, Ω, Δ); x:A; · ⊢ M : C or Γ; (Ω, x:A); Δ ⊢ M : C and (Γ, Ω, Δ); ·; x:A ⊢ M : C, depending on the polarity of d. Both cases are impossible by Corollary 3.12.

Case D ends in Not App^{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 Not App^{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}

By hypothesis

Γ ⊢ Not(N_{i}) ⇒ Q, for some 1 ≤ i ≤ n  By sub-derivation
Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h \overline{N_{n}^{1}}∥  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}∥

By assumption

Γ ⊢ M_{i} ∈ ∥N_{i}∥  By inversion
Γ ⊢ M_{i} ∈ ∥Q∥  By inversion
⊥  By IH

Case D ends in Not Lam:

Γ ⊢ Not(λx^{u}:A. N) ⇒ λx^{u}:A. Q  By hypothesis
Γ, x:A ⊢ Not(N) ⇒ Q  By sub-derivation
Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. N∥  By hypothesis

Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. Q∥  By assumption
Γ, x:A ⊢ M ∈ ∥N∥  By inversion
Γ, x:A ⊢ M ∈ ∥Q∥,  By inversion
⊥  By IH

□

Note that soundness is based on Corollary 3.12, which holds for any strict term: thus disjointness does not require simple terms. We are now ready to prove exhaustivity of complementation.

Theorem 4.18 Assume Γ ⊢ N : A is simple linear pattern and there is a Q such that Γ ⊢ Not(N) ⇒ Q : A: then, either Γ ⊢ M ∈ ∥N∥ : A or Γ ⊢ M ∈ ∥Q∥ : A.

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

Case D ends in Not F lx. Again observe that E \overline{x_{n}^{l}} can be seen as E Φ^{u}Ω^{0}Δ^{1} x^{d}, where x is determined; indeed if x is undetermined, the result holds trivially; by Corollary 4.6 either Γ; (Ω, x:C); Δ ⊢ M : A or (Γ, Ω, Δ); ·; x:C; ⊢ M : A and either Γ; Ω; (Δ, x:C) ⊢ M : A or (Γ, Ω, Δ); ·; x:C ⊢ M : A, depending on the polarity of d. Thus Γ ⊢ M ∈ ∥E Φ^{u}Ω^{0}Δ^{1} x^{d}∥ or Γ ⊢ M ∈ ∥F Φ^{u}Ω^{u}Δ^{u} x^{−d}∥ for some d ∈ {1, 0}.

Case D ends in Not App^{1}. Let M be a ground term g \overline{M_{m}} where g ∈ Σ ∪ Γ, g ≢ h. Then clearly Γ ⊢ g \overline{M_{m}} ∈ ∥g (Z_{1}Γ^{u})^{1} … (Z_{m}Γ^{u})^{1}∥, hence the thesis by weakening.

Case D ends in Not App^{2}.

Γ ⊢ Not(N_{i}) ⇒ Q for some 1 ≤ i ≤ n  By sub-derivation
Γ ⊢ h \overline{N_{n}^{1}} : P  By assumption
Γ ⊢ N_{i} : A_{i}  By inversion
Γ ⊢ M_{i} ∈ ∥N_{i}∥ : A_{i} or Γ ⊢ M_{i} ∈ ∥Q∥ : A  By IH
Subcase Γ ⊢ M_{i} ∈ ∥N_{i}∥ : A_{i}  By assumption
Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h \overline{N_{n}^{1}}∥ : P  by rule grApp

hence the thesis by weakening

Subcase Γ ⊢ M_{i} ∈ ∥Q∥ : A  By assumption
Γ ⊢ M_{j} ∈ ∥(Z_{j}Γ^{u})^{1}∥ for some j ≠^{·} i, 1 ≤ j ≤ n  By rule grF lx

Γ ⊢ h \overline{M_{n}^{1}} ∈ ∥h (Z_{1}Γ^{u})^{1} … (Z_{i−1}Γ^{u})^{1} N^{1} (Z_{i+1}Γ^{u})^{1} … (Z_{m}Γ^{u})^{1}∥ : P

by rule grApp

hence, by weakening the result.

Case D ends in Not Lam.

Γ, x:A ⊢ Not(N) ⇒ Q  By sub-derivation
Γ, x:A ⊢ M ∈ ∥N∥ : B or Γ ⊢ M ∈ ∥Q∥ : B  By IH

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

hence the thesis by weakening

Subcase Γ ⊢ M ∈ ∥Q∥ : B  By assumption
Γ ⊢ λx^{u}:A. M ∈ ∥λx^{u}:A. Q∥ : A →^{u} B  by rule

hence the thesis by weakening.

□

Corollary 4.19 (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.17, exhaustivity by Theorem 4.18. □

4.3 Unification of Simple Terms

As we observed earlier in Chapter 2, we can solve a relative complement problem coupling complementation and intersection. We thus address now the task of giving an algorithm for unification of linear higher-order patterns.

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

We use Φ for (contexts) of labeled bound variables, i.e. what we called \overline{x_{n}^{k}} and if x^{k} ∈ Φ, we say that Φ(x) = k. We then extend the intersection operations to these contexts; remember that full application entails that we only intersect context that are the same modulo different labeling:

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

Let Φ_{1} = Γ_{1}; Ω_{1}; Δ_{1} and Φ_{2} = Γ_{2}; Ω_{2}; Δ_{2}; if Φ_{1} ∩ Φ_{2} is defined, we call those contexts compatible.

Remark 4.19.1 Ψ ⊢ M ∈ ∥E_{A} Φ_{1} ∩ Φ_{2}∥ iff M ≡ λΦ_{1} ∩ Φ_{2} . S such that Γ; Ω; Δ ⊢ S : A, where

Γ = (Γ_{1} ∩ Γ_{2})
Ω = (Ω_{1}, Ω_{2})
Δ = (Δ_{1}, Δ_{2})

Indeed, x ∈ Γ iff x ∈ Γ_{1} and x ∈ Γ_{2}; moreover x ∈ Ω iff either x ∈ Ω_{1} ∪ Γ_{2} or x ∈ Ω_{2} ∪ Γ_{1}. Analogously for x ∈ Δ.

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.20 (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}) : P}

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}} : P

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}} : P
h ∈ Γ ∪ Σ Γ ⊢ M_{1} ∩ N_{1} ⇒ Q_{1} : A_{1} ⋯ Γ ⊢ M_{n} ∩ N_{n} ⇒ Q_{n} : A_{n}
∩A
Γ ⊢ h \overline{M_{n}^{1}} ∩ h \overline{N_{n}^{1}} ⇒ h \overline{Q_{n}^{1}} : P
Γ, x:A ⊢ M ∩ N ⇒ Q : B

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

where the H’s are fresh variables of correct 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, it does occur in the RHS: hence it ought to occur in the LHS: moreover, since it did occur, it is set to u in the rest of the computation, as there are no more requirements on that variable, therefore the modified condition on y takes into account that the head of an application constitutes a strict occurrence.

• 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.21 ( ) 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 gratest 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.22 ( ) 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}}.

[Move this lemma in the previous chapter]

Lemma 4.23 Let Γ_{1}; Ω_{1}; Δ_{1} ⊢ M : A and Γ_{2}; Ω_{2}; Δ_{2} ⊢ M : A be compatible type assignments; 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 structure of D_{1} :: Γ_{1}; Ω_{1}; Δ_{1} ⊢ M : A and D_{2} :: Γ_{2}; Ω_{2}; Δ_{2} ⊢ M : A.

Case

D_{1} = \begin{aligned}c:A ∈ Σ \\ & Con \\ Γ_{1}; Ω_{1} · ⊢ c : C \end{aligned} D_{2} = \begin{aligned}c:A ∈ Σ \\ & Con \\ Γ_{2}; Ω_{2} · ⊢ c : A \end{aligned}

Then

E = \begin{aligned}c:A ∈ Σ \\ & Con \\ (Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); · ⊢ c : A \end{aligned}

Case

D_{1} = \frac{Id^{u}}{(Γ_{1}, x:A); Ω_{1} · ⊢ x : A} D_{2} = \frac{Id^{u}}{(Γ_{2}, x:A); Ω_{2} · ⊢ x : A}

Then

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

Case

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

Then

E = \frac{Id^{1}}{(Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); x:A ⊢ x : A}

Draft of March 25, 2000

Case

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

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

(Γ_{1}, x:A); Ω_{1}; Δ_{1} ⊢ M : B  By inversion
(Γ_{2}, x:A); Ω_{2}; Δ_{2} ⊢ M : B  By inversion
(Γ_{1}, x:A) ∩ (Γ_{2}, x:A); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : B  By IH
(Γ_{1} ∩ Γ_{2}, x:A); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : B  By De Morgan
(Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ λx^{u}:A. M : A →^{u} B  By rule

Case D_{i} ends in →^{0} I, →^{1} I: similarly.

Case

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

and

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

(Γ_{1}, Δ_{N}^{1}); Ω_{1}; Δ_{M}^{1} ⊢ M : A →^{1} B  By inversion
(Γ_{2}, Δ_{N}^{2}); Ω_{2}; Δ_{M}^{2} ⊢ M : A →^{1} B  By inversion
(Γ_{1}, Δ_{N}^{1}) ∩ (Γ_{2}, Δ_{N}^{2}); (Ω_{1}, Ω_{2}); (Δ_{M}^{1}, Δ_{M}^{2}) ⊢ M : A →^{1} B  By IH
(Γ_{1}, Δ_{M}^{1}) ∩ (Γ_{2}, Δ_{M}^{2}); (Ω_{1}, Ω_{2}); (Δ_{N}^{1}, Δ_{N}^{2}) ⊢ N : A  By IH
(Γ_{1} ∩ Γ_{2}, Δ_{N}^{1}, Δ_{N}^{2}); (Ω_{1}, Ω_{2}); (Δ_{M}^{1}, Δ_{M}^{2}) ⊢ M : A →^{1} B By Remark 4.19.1
(Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{M}^{1}, Δ_{M}^{2}, Δ_{N}^{1}, Δ_{N}^{2}) ⊢ N : A  By rule

Case D_{i} ends in →^{u} E, →^{0} E: similarly.

(←). Similarly by induction on the structure of the derivation of (Γ_{1} ∩ Γ_{2}); (Ω_{1}, Ω_{2}); (Δ_{1}, Δ_{2}) ⊢ M : A. □

We introduce two n-ary strict application rules, one which correspond to the imitation step and the other to projection; they will be needed in the proof of Theorem 4.30 and 4.31.

(Γ, Δ_{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

Draft of March 25, 2000

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 Γ′; Ω; Δ′ ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B such that Δ′ = {y} or Δ′ = ·∧y ∈ Γ′,

Γ′ ∪ Δ′ = Γ ∪ Δ and 1. ∀x ∈ Δ . ∃i : 1 ≤ i ≤ n . x ∈ Δ_{i}^{1}.

2. ∀i : 1 ≤ i ≤ n . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ. We proceed to show that both are derivable and invertible rules.

Lemma 4.24 Let (Γ, Δ^{u}); Ω; · ⊢ 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 ∈ Δ^{1}.¬∃i : 1 ≤ i ≤ j . x ∈ Δ_{i}^{u}.

2. ∀i : 1 ≤ i ≤ j . Δ_{i}^{u} ∪ Δ_{i}^{1} = Δ^{u} ∪ Δ^{1}. Proof: By induction on j.

j = 0 (Γ, Δ^{u}); Ω; · ⊢ c : A_{1} →^{1} … →^{1} A_{n} →^{1} B  By hypothesis
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 and

x ∈ Δ_{+}^{1} ↔ x ∈ Δ_{j+1}^{1} ∪ Δ^{1} ∧ x ∈ Δ_{+}^{u} ↔ x ∈ Δ^{u} ∩ Δ_{j+1}^{u}  By rule →^{1} E

We now show that the last step satisfy the condition on rule →^{1} E:

1. x ∈ Δ_{+}^{1}  By assumption
x ∈ Δ_{j+1}^{1} ∪ Δ^{1}  As x ∈ Δ_{+}^{1} ↔ x ∈ Δ_{j+1}^{1} ∪ Δ^{1}
x ∈ Δ_{j+1}^{1}  Case

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

x ∈ Δ^{1}  Case
x ∈ Δ_{i}^{1}, for some 1 ≤ i ≤ j  By IH

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

1’. x ∈ Δ_{+}^{u}  By assumption
x ∈ Δ^{u}  As x ∈ Δ_{+}^{u} ↔ x ∈ Δ^{u} ∩ Δ_{j+1}^{u}
x ∈ Δ_{+}^{u} → ¬∃i:1 ≤ i ≤ j . x ∈ Δ_{i}^{1}  By IH

Draft of March 25, 2000

2. Δ_{+}^{1} ∪ Δ_{+}^{u} = Δ^{1} ∪ Δ^{u}  By rule
∀i:1 ≤ i ≤ j . Δ_{i}^{1} ∪ Δ_{i}^{u} = Δ^{1} ∪ Δ^{u}  By IH
∀i:1 ≤ i ≤ j . Δ_{i}^{1} ∪ Δ_{i}^{u} = Δ_{+}^{1} ∪ Δ_{+}^{u}  By replacement

□

Lemma 4.25 Let (Γ, Δ^{u}); Ω; · ⊢ 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 (Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} for

1 ≤ i ≤ j.

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}, where

Proof: By induction on j.

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

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

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

x ∈ Δ_{+}^{1} ↔ x ∈ Δ_{j+1}^{1} ∪ Δ^{1} ∧ x ∈ Δ_{+}^{u} ↔ x ∈ Δ^{u} ∩ Δ_{j+1}^{u}By inversion on rule →^{1} E
(Γ, Δ_{i}^{u}); Ω; Δ_{i}^{1} ⊢ M_{i} : A_{i} for 1 ≤ i ≤ j  By IH

since the conditions on the rule are satisfied as in the above Lemma 4.24.

□

Corollary 4.26 Rule →^{1} E_{n}^{c} is derivable and invertible.

Proof: For derivability, use Lemma 4.24 with j = n, Δ^{u} = ·, Δ^{1} = Δ; conditions 1. and 2. are immediately satisfied. Ditto w.r.t. invertibility, using Lemma 4.25. □

Lemma 4.27 Let (Γ, Δ^{u})′; Ω; Δ′ ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B, where Δ′ = {y} or Δ′ = ·∧y ∈ (Γ, Δ^{u})′ and (Γ, Δ^{u})′∪Δ′ = Γ∪Δ^{u}∪Δ^{1}. 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}.

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.

j = 0 (Γ, Δ^{u})′; Ω; Δ′ ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B  By hypothesis
(Γ, Δ^{u}); Ω; Δ^{1} ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B  By the condition

j + 1 Similar to the same case in Lemma 4.24.

□

Lemma 4.28 Let (Γ, Δ^{u})′; Ω; Δ′ ⊢ y : A_{1} →^{1} … →^{1} A_{n} →^{1} B, where Δ′ = {y} or Δ′ = · ∧ y ∈ (Γ, Δ^{u})′ and (Γ, Δ^{u})′ ∪ Δ′ = Γ ∪ Δ^{u} ∪ Δ^{1}. If (Γ, Δ^{u}); Ω; Δ^{1} ⊢

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

1 ≤ i ≤ j 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.25. □

Corollary 4.29 Rule →^{1} E_{n}^{y} is derivable and invertible.

Proof: As in Corollary 4.26. □

Note how the side conditions in the n-ary rules mirrors the proviso on the intersection rules. Firstly notice that if Φ(x) = 0 then x ∈ Ω which is unchanged in the premises; thus ∀i : 1 ≤ i ≤ n.Φ_{i}(x) = 0. Similarly for Φ(x) = u. Finally, if Φ(x) = 1, the first condition is equal to ∃i : 1 ≤ i ≤ n.Φ_{i}(x) = 1, while the requirement ∀j : 1 ≤ i ≤ n, j ≠^{·} i.Φ_{i}(x) = u is met by Loosening^{1}. As far as the ∩F R^{y} rule is concerned the assumption on Γ′, Δ′ is equivalent to the additional proviso.

We are now ready to address soundness and completeness of intersection:

Theorem 4.30 Let Γ ⊢ N_{1} ∩ N_{2} ⇒ N : A. If Γ ⊢ M ∈ ∥N_{1}∥ : A and Γ ⊢ M ∈ ∥N_{2}∥ : A, then Γ ⊢ M ∈ ∥N∥ : A.

Proof: By induction on the structure of D :: Γ ⊢ N_{1} ∩ N_{2} ⇒ N : A.

Case D ends in ∩F F; by Remark 4.19.1 and the left-to-right direction of Lemma 4.23.

Case D ends in ∩F R^{c}:

D :: Γ ⊢ E Φ ∩ c \overline{Q_{n}^{1}} ⇒ c \overline{N_{n}^{1}}  By hypothesis
D_{i} :: Γ ⊢ E_{i} Φ_{i} ∩ Q_{i} ⇒ N_{i} and 1 ≤ i ≤ n with proviso By sub-derivation
Γ ⊢ M ∈ ∥c \overline{Q_{n}^{1}}∥  By hypothesis
M ≡ c \overline{M_{n}^{1}} and D_{i}^{2} :: Γ ⊢ M_{i} ∈ ∥Q_{i}∥ for 1 ≤ i ≤ n  By inversion
Γ ⊢ c \overline{M_{n}^{1}} ∈ ∥E Φ∥  By hypothesis
c \overline{M_{n}^{1}} ≡ t Φ, where t ≡ λΦ . c \overline{t_{n}} for Φ ⊢ c \overline{t_{n}}^{1} : P  By inversion
Φ_{i} ⊢ t_{i} : A_{i}  By inversion on rule →^{1} E_{c}^{n} (Lemma 4.25)
D_{i}^{1} :: Γ ⊢ M_{i} ∈ ∥E_{i} Φ_{i}∥  By rule grF lx
Γ ⊢ M_{i} ∈ ∥N_{i}∥  By IH on D_{i}, D_{i}^{1}, D_{i}^{2}
Γ ⊢ c \overline{M_{n}^{1}} ∈ ∥c \overline{N_{n}^{1}}∥  By rule

Case D ends in ∩F R^{y}. Proceed as above, but using invasion on rule →^{1} E_{y}^{n}, i.e. Lemma 4.27.

Case D ends in ∩L:

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

Case D ends in ∩A; by a straightforward appeal to the inductive hypothesis as in the above case.

□

Theorem 4.31 If Γ ⊢ N_{1} ∩ N_{2} ⇒ N and Γ ⊢ 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.

Case D ends in ∩F F; by Remark 4.19.1 and the right-to-left direction of Lemma 4.23.

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} ∈ ∥Q_{i}∥ and Γ ⊢ M_{i} ∈ ∥E_{i} Φ_{i}∥  By IH on D_{i}
M_{i} ≡ t Φ, where t ≡ λΦ . t_{i} for Φ_{i} ⊢ t_{i} : A_{i}  By rule grF lx
Φ ⊢ c \overline{t_{n}^{1}} : P  By rule →^{1} E_{c}^{n} (Lemma 4.24)
Γ ⊢ c \overline{M_{n}^{1}} ∈ ∥E Φ∥  By rule
Γ ⊢ c \overline{M_{n}^{1}} ∈ ∥c \overline{Q_{n}^{1}}∥  By rule

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

Case D ends in ∩L; by IH as in Theorem 4.30

Case D ends in ∩A; ditto.

□

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

Proof: From Theorem 4.30 and 4.31. □

We now list some basic properties of intersection, which follows from Corollary 4.32 and will be useful in the next Section.

Corollary 4.33 Let M, N be simple linear terms of type A:

1. Γ ⊢ M ∩ M = {M}.

2. Γ ⊢ M ∩ N = Γ ⊢ N ∩ M.

4.4 The Algebra of Strict Terms

An interesting and natural question is wondering whether complementation is involutive. As the complement of a term is possibly a set of terms we need to extend the intersection and complement operations to sets of terms. For the sake of readability, we define it in the empty context. It is clear, altough cumbersome how to generalize it. We also drop the type information.

Definition 4.34 If M and N are sets of 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.35 (Adequacy of Set Intersection) If N_{1}, N_{2} are 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.32, Γ ⊢ M ∈ ∥N_{1} ∩ N_{2}∥ : A iff, by definition, Γ ⊢ M ∈ ∥N_{1} ⋂ N_{2}∥ : A. □

Corollary 4.36 (Set Partition Lemma) Let N be a linear simple term of type A:

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

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

Proof:

1. By the Partition Lemma, Γ ⊢ M ∈ ∥N∥ : A or Γ ⊢ M ∈ ∥Not(N)∥ : A, for every N ∈ N. Assume Γ ⊢ M ∈ ∥N∥ : A; then Γ ⊢ M ∈ ∥N ∥ : A and finally Γ ⊢ M ∈ ∥N ∥ : A or Γ ⊢ M ∈ ∥Not(N)∥ : A. Otherwise assume Γ ⊢ M ∈ ∥Not(N)∥ : A, for every N ∈ N. Then by Corollary 4.32 Γ ⊢ M ∈ ∥ ⋂_{N∈N} Not(N)∥ : A, so by definition Γ ⊢ M ∈ ∥Not(N)∥ : A and finally Γ ⊢ M ∈ ∥N ∥ : A or Γ ⊢ M ∈ ∥Not(N)∥ : A.

2. Similarly to the above.

□

We can know answer positively the question whether complementation is involutive. The Partition Lemma tell us in fact that complementation is essentially boolean. It is thherefore possible to organize the set of sets of simple terms over a given signature, call it T_{Σ} in a boolean algebra ⟨T_{Σ}, ∅, ∪, ⋂, Not⟩ under set union, patterns intersection and complementation.

Theorem 4.37 Consider the algebra ⟨T_{Σ}, ∅, ∪, ⋂, Not⟩ under set union, patterns intersection and complementation. Then the following holds:

1. M ⋂ M = M.

2. M ⋂ N = M ⋂ N.

3. M ⋂(N ∪ P) = (M ⋂ N) ∪ (M ⋂ P).

4. M ⋂(N ⋂ P) = (M ⋂ N) ⋂ P.

5. Not(Not(M)) = M.

6. Not(T_{Σ}) = ∅.

7. Not(∅) = T_{Σ}.

Proof: From Corollary 4.33, 4.35 and 4.36. □

Corollary 4.38 The algebra ⟨T_{Σ}, ∅, ∪, ⋂, Not⟩ of simple linear terms is boolean.

Proof: Theorem 4.37 confirms that the above operators satisfy the boolean algebra axioms. □

Corollary 4.38 guarantees that any other boolean operation is definable: indeed complementation and intersection alone allows to define the relative complement operation:

Definition 4.39 Given M and N 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.40 Γ ⊢ M ∈ ∥M∥ − ∥N ∥ iff Γ ⊢ M ∈ ∥M − N ∥ .

Proof: Γ ⊢ M ∈ ∥M∥ − |N ∥ iff Γ ⊢ M ∈ ∥M∥ and Γ ⊢ M ∉ ∥N∥ for every N ∈ N iff (Corollary 4.36) Γ ⊢ M ∈ ∥M∥ and Γ ⊢ M ∈ ∥Not(N)∥ iff (Corollary 4.32) Γ ⊢ M ∈ ∥M ⋂(NotN)∥ iff by definition Γ ⊢ M ∈ ∥M − N ∥. □

[ Insert a remark (and counter-example) on why ∪ must be settheoretic union rather than anti-unification? ]

Example 4.41 ( ) We can therefore combine Example 2.7 and 2.9:

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_{1} H_{2}) H_{3}} ⋂

{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′′}

Example 4.42 ( )

\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.41 yields the complementary facts:

\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_{4} x^{u}H_{5} x^{u}))) \\ nb3 & : & non isredx(lam(λx^{u}:exp. app (H x^{u}) (lam(λy^{u}:exp. H_{6} x^{u} y^{u})))) \\ nb4 & : & non isredx(lam(λx^{u}:exp. lam(λy^{u}:exp. H_{3} x^{u} y^{u}))) \\ nbr & : & non isredx(lam(λx^{u}:exp. x)) \\ nb6 & : & non isredx(app (app H_{1} H_{2}) H_{3} ) \end{aligned}

Towards 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 the original program P is synthesized so as to obtain an equivalent definite program P^{c}. This was first proposed in [ST84].

5.1 The Completion

At the risk of being trivial, let us start to ask naively what the complement of a program should be; if we see the latter as a conjunction of possibly mutually recursive predicate definitions, its negation would be the conjunction 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(Z) assert ∀Z : nat. ¬q(s(Z)); 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 id by exchanging the ← connective into a biconditional ↔:

∀X:nat. q(X) ↔ X =^{·} 0

72CHAPTER 5. TOWARDS ELIMINATION OF NEGATION IN CLAUSES

This is in the 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: that is 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 example, 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 dispensed us to deal with the issue of the compatibility of DCA with dynamic extensions on the signature.

Of course, definitions are usually more interesting than a simple clause, so let’s step to next simplest example, even numbers:

even(0).

even(s(s(Y))) :- even(Y).

To turn this code into a minimal inductive definition, we need to normalize the disjunction of the 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 the use rewrite rules to achieve conversion into negation normal form (nnf) and conversion 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 disequalities 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 ??, which uses the subcomputation of ∀y : z ≠^{·} 0 ∧ z ≠^{·} ssy, detailed in Example 2.4.

This was pretty much suggested in the early 80’s by Sato & Tamaki in [ST84]. In this seminal paper they isolate what is essentially still the right framework: locally stratified many-sorted programs, with no local variables. The authors informally showed that the finite failure set of such a coincides with the success set of the transformed program. They did not offer an explicit mechanism to ∀x . even(x) ↔ x = 0 ∨ ∃y . x = ss(y) ∧ even(y)

⇝_{cp}

∀x . ¬even(x) ↔ ¬(x = 0 ∨ ∃y . x = ss(y) ∧ even(y)) ⇝_{nnf}

∀x . ¬even(x) ↔ x ≠^{·} 0 ∧ (∀y . x ≠^{·} ss(y) ∨ ¬even(y))

⇝_{lift}

∀x . ¬even(x) ↔ x ≠^{·} 0 ∧ ∀y . x ≠^{·} ss(y) ∨ (∃y . x = ss(y) ∧ ¬even(y))

⇝_{dnf}

∀x . ¬even(x) ↔ (x ≠^{·} 0 ∧ ∀y . x ≠^{·} ss(y)) ∨ (x ≠^{·} 0 ∧ ∃y . x = ss(y) ∧ ¬even(y))

⇝_{disunify(x≠^{·}0∧∀y:x≠^{·}ss(y))}

∀x . ¬even(x) ↔ x = s(0) ∨ (x ≠^{·} 0 ∧ ∃y . x = ss(y) ∧ ¬even(y))

⇝_{disunify(x≠^{·}0∧∃y:x=ss(y))} ^{1}

∀x . ¬even(x) ↔ x = s(0) ∨ (∃y . x = ss(y) ∧ ¬even(y)) ⇝_{prettyp}

odd(s(0)).

odd(s(s(Y))) :- odd(Y).

Figure 5.1: odd Synthesis

handle inequalities, but relied on the intuitive semantics of ‘non-unifiable’, thus they incurred in the fallacy of allowing non-left linear clauses. This was fixed in [LM87], as we have seen, in the general context of explicit representation of generalization and refined in [JLLM91]; there it is shown that such an algorithm may simplify those constraints into a solved form, but also that this elimination is not achievable in general.

After this was established, an extensive project started in Pisa under the name of intensional negation [BMPT90a, MMP88, BMPT90b, ABT90, MPRT90, FBM93]. In particular [BMPT90b] 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:

member(X,X.XS).

member(X,Y.YS):- member(X,YS).

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.1. Not only disunification is more complex, as there are a few choices of variables to explode, but propositonal 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 citeBruscoli93 embraces the contraint logic programming approach. We will instead give a completely deterministic algorithm to compute the negation of programs. This is based on pairing term complement with unification and is proven correct by Corollary 4.38; 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 be operationally equivalent, 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 augmented with Herbrand constraints 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 in linear, if every functional subterm uses each of its arguments exactly once: comp(member) ⇝_{cp}

∀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.YS) : −X ≠ Y, nonmember(X, YS).

Figure 5.2: Synthesis of the nonmember predicate

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
λ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

Intuitively, we check for linearity of a function making sure that the latter 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.7:

linlam : linear(lam λx . E x)
← linx(lam λ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 them 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(lam(λx . E x)).

Secondly, if its body is not linear. Now, this poses a new problem, as we have to negate a hypothetical and parametric clause. 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 . y), for a new parameter y, in the context y:exp; linear(y). 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 . y) from y:exp; linear(y); this shows one prominent feature of complementation of an HHF formula: negation ‘skips’ over ∀ and →, since it need to mirror failure from assumptions.

Let us turn to complementing linear in x. A first point to note in that, by encoding an expression ‘e’ with a pattern variable, we must make sure that in clause linxap1,linxap2 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 in the strict λ-calculus we obtain, among others:

¬linx1 : ¬linx(λx . app (E_{1} x) (E_{2} x^{1})).
¬linx2 : ¬linx(λx . app (E_{1} x^{1}) (E_{2} x)).

Moreover, as in the case of top-level application, the complement of linxapi hold 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 . y) form the context y:exp; linear(y). In a first attempt, according to the idea above, let us consider what the complement would be:

¬^{?} 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 . y) from the current context. Indeed, the linxlm clause does not carry to 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 assumptioncomplete: 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 definition, in this case exactly ¬linx(λx . y). 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)).

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(lam λx . E x) ∨

(∀x:exp. linear(x) → ¬linear(E x)).

¬linx1 : ¬linx(λx . app (E_{1} x) (E_{2} x^{1})).
¬linx2 : ¬linx(λx . app (E_{1} x^{1}) (E_{2} 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).
¬linxlm : ¬linx(λx . lam(λy . E x y))
← (∀y:exp. ¬linx(λx . y) → ¬linx(λx . E x y)).

While it is not impossible to manually come up with this program by writing a definition for strict and vacuous and then merging them in the correct fashion, it would be better to have this dome 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.2

Σ : form:type, imp:form → form → form, a:form, b:form, c:form
impi : nd(A imp B) ← (nd(A) → nd(B)).

Following our earlier remark its complement would be:

¬impi1 : ¬nd(a)
¬impi2 : ¬nd(b)
¬impi3 : ¬nd(c)
¬^{?} 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) which 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 cause do differ but their complements do not. Suppose we introduce a predicate which checks is 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))) ← (¬ev(s(0)) → ¬ev(N)).

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.5 a procedure that we call augmentation, which, by enriching the program with the complement of assumptions will, will achieve exhaustivity (6.7); 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 in 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}, it holds:

1. If ⊢_{L} G, then E(P) ⊧_{L} G.

2. If ⊣⊢_{L} G, then 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 N-F : 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 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 of 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.3 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 as:

• In the Horn setting, the iff-completion has been the preferred way to logically motivate the transformational approach to negation, as detailed in Section 5.1.

• In [GO98] the authors persuasively argue that the unrestricted addition of NF to 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. 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 [?].

We now try to motivate why the restriction of complementation to parametric implication (formally defined in Section 6.4) 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, we have not investigated the issue so far.

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.4 (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 empty; let −∘ and ⊗ denote linear implication and conjunction:

even ← r(X) ∧ (empty −∘ full ⊗ odd).
even ← full.
odd ← r(X) ∧ (full −∘ empty ⊗ even).
odd ← empty.

5.5 Related Work

Recently 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 ??, 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 to 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 form 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 McCarty 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 non-monotonically.

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 succeeds or fail from a program unless we determine what goal succeeds or fail from arbitrary^{2} 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.

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 appears negatively versus positively in the body of clauses. The two sets are required to be disjoint. This of course simplify 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.

2Emphasis is mine.

Draft of March 25, 2000

Then Harland shows how to formulate the completion as an object fohh 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 programs 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 semantic for coverings is described: not only the role of free variables introduced by coverings is 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 PID

Partial Inductive Definitions ([Hal91]) are a generalization of inductive definitions [Acz77] to definiens containing implications and in a finitary version ([Eri93]) 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 then 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 metalevel 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, if we suppress here mention of the 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.5 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 no 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 attempted derivation of the positive goal, a goal-oriented strategy would introduce a new parameter and try the goal y:exp; defp(even) ⊢ open y. Yet, the same idea does not work when definitional reflection is allowed as not 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 goaloriented reading to a sequent calculus augmented with the definitional reflection rule. The latter is instead a sort of meta-level closure operator; this is indeed how it is used in meta-logics as M_{2} [SP98] and F OLDN [MM97]. If we try to use it as a logic programming engine for HHF with negation, ie we add introduce logical variables and dynamic assumptions, it breaks down and reveal its metatheoretic nature. We also remark that restricting to RWA programs 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 complementable programs, allowing to extend F OLDN significantly.

Clause Complementation

In this chapter we introduce the source language and its uniform proof system. After 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: 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 | ∃x:A. G
Clauses D ::= ⊤ |⊥| Q | D ← G | D_{1} ∧ D_{2} | D_{1} ∨ D_{2} | ∀x:A. D

Differently form standard presentation of HHF, we allow disjunction between clauses, equality and inequality. While disjunction among clauses will be eliminated, (in)equalities containing parameters will not. This means that in typetheoretic languages such as Twelf they need to be viewed as types inhabited by appropriate proof terms. However, since (in)equalities will be treated exclusively as constraints, we will not need a complicate treatment as in Martin-Löf’s type theory. The tokens ⊤ and ⊥ may be decorated with a predicate symbol. 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.

Definition 6.1 (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, ∀x:A. D) = ∀x:A. def(q, D)
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. If D is a conjunction of run-time assumptions, 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 use the notation D ∈ def(q, P ∧ D) to indicate that D is a top-level conjunct in the definition of q.

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. 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.8.2. The rules are depicted (when possible) in two columns where every row displays a positive rule and its negative counterpart. We remark that the systems for denial will not be needed in the proof of exclusivity (Theorem 6.23).

Γ; 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 def(q, P ∧ D) immediately entails atom Q.
Γ; D ⊬_{P} D>>Q Clause D from def(q, 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. Note that ≯>∀ and ⊬ ∃ are infinitary rules, due to the meta-linguistic extensional universal quantification on all terms. Rule ≯>∀ must be read as: for every well-typed term n in parameter context Γ, ∀x: A. D immediately denies Q if so does [n/x]D. Analogously for ⊬ ∃. 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 rules ⟹^{D} ∀ and ⟹^{G} ∃ in Figure 6.3); this expresses the fact that in those rules the relation holds for any term and are therefore synonymous to logic variables. We will pervasively utilize this notation and to avoid notational

6.1. THE LOGIC  93
\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}
Γ ⊢ t : A Γ; D ⊢_{P} [t/x]G

⊢ ∃ Γ; D ⊢_{P} ∃x:A. G

for all n Γ ⊢ n : A Γ; D ⊬_{P} [n/x]G

⊬ ∃

Γ; D ⊬_{P} ∃x:A. G
\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} def(Q, P ∧ D)>>Q \\ & ⊢ & At \\ Γ; D ⊢_{P} Q \end{aligned}  \begin{aligned}Γ; D ⊬_{P} def(Q, P ∧ D)>>Q \\ & ⊬ & At \\ Γ; D ⊬_{P} Q \end{aligned}

Figure 6.1: Provability and Denial

Draft of March 25, 2000

94  CHAPTER 6. CLAUSE COMPLEMENTATION
\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, we shall not keep an explicit record, but we agree to implicitly gather them in a pool Φ, which we can access when needed.

Draft of March 25, 2000

The denial rules for implication and universal quantification reflect the operation semantics of unprovability that we have discussed earlier. 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

Since we have introduced meta-level extensional quantification we will have to introduce valid substitutions. Soundness requires the latter not only to be well-typed, but also to correctly deal with quantifier alternations, in so that substitution terms for essentially existential variables must respect the eigenvariable restriction brought in by parametric rules. We do not develop the usual theory of well-typed substitutions; we simply assume that t can be given the type associated to x.

Substitutions σ ::= ϵ | σ, t/x

The judgment Γ ⊢ σ formalizes that σ is a valid substitution w.r.t. Γ, where par(t) denotes the set of parameters occurring in t:

\frac{ϵ}{Γ ⊢ ϵ}  \begin{aligned}par(t) ⊆ Γ  Γ ⊢ σ \\ & σ \\ Γ ⊢ σ, t/x \end{aligned}

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).

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.5. Some caution must be exercised to discriminate whether the universal quantifier contributes or not to the provability of the goal in its scope.

We first state some basic properties of provability.

Lemma 6.2 (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.6 we will need the following form of Strengthening:

Lemma 6.3 (⊤-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 need any normalization. Similarly if D is non-trivial. If Γ is non-empty, there is the possibility that the type of the introduced parameter is subordinate [Vir99] to the type of the atom considered. In this case there is no need for us to introduce the trivial assumption. More formally, we say that x:A is relevant to Q if head(Q) ≡ q, Σ(q) = A_{1}, …, A_{n} → prop and for some 1 ≤ i ≤ n it holds that target(A_{i}) ≡ A; we denote this with xR^{i}q. Thus we ⊤-normalize Q only when there is a parameter in the context which is relevant to Q.

Example 6.4 Consider the lambda clause in the open program:

oplam : ∀E:exp → exp. open (lam E) ←
∀x:exp. open (E x).

As x:exp is relevant to open:exp → prop , oplam ⟹^{D} oplam^{⊤}, i.e.

oplam^{⊤} : ∀E:exp → exp. open (lam E) ←
(∀x:exp. ⊤_{open} → open (E x)).

Now consider Σ = form, term:type, all:(term → form) → form, isd:form → prop and the clause:

isdall : ∀D:term → form. isd (all D) ←

∀x:term. isd (D x).

X ∈ {⊤, ⊥} or (dis)eq

⟹^{G} X

Γ; D ⊢ X ⟹^{G} X

\frac{AtΓ emp}{·; ⊤ ⊢ Q ⟹^{G} Q}

D ≢ ⊤

AtD non-emp

Γ; D ⊢ Q ⟹^{G} Q

\begin{aligned}xR^{i}q \\ & AtxR^{i}q \\ (Γ, x:A); ⊤ ⊢ Q ⟹^{G} ⊤_{q} → Q \end{aligned}  \begin{aligned}x R̸^{i}q \\ & Atx R̸^{i}q \\ (Γ, x:A); ⊤ ⊢ Q ⟹^{G} Q \end{aligned}

Γ; (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 ⊢ [u/x]G ⟹^{G} [u/x]G^{⊤}

⟹^{G} ∃^{u}

Γ; 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 Here as term ≢ form, then x:term is not relevant to isd:form → prop and

Draft of March 25, 2000

isdall^{⊤} ⟹^{D} isdall.

We start by showing that this transformation preserves run-time provability.

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 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, (AtΓ emp): trivial.

Case γ ends in ⊢ At and γ′ ends in At rel:

Γ; [θ]D ⊢ [θ]Q  By hypothesis
Γ; [θ]D ⊢ [θ]D>>[θ]Q  By sub-derivation
D ⟹^{D} D^{⊤}  By hypothesis
Γ; [θ]D^{⊤} ⊢ [θ]D^{⊤}>>[θ]Q  By IH 2
Γ; ([θ]D^{⊤} ∧ ⊤_{q}) ⊢ [θ]D^{⊤}>>[θ]Q  By Weakening
Γ; ([θ]D^{⊤} ∧ ⊤_{q}) ⊢ [θ]Q  By rule ⊢ At
Γ; [θ]D^{⊤} ⊢ ⊤_{q} → [θ]Q  By rule ⊢→
Γ; [θ]D ⊢ [θ]Q^{⊤}  By rule At⊤ rel

Case γ ends in ⊢ At and γ′ is (AtD non-emp), (At non-rel): by IH 2.

□

Now, the converse:

Theorem 6.6 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.3) 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 do next.

6.2 Terminating Programs

We now introduce terminating programs. This is abstractly achieved by means of a relation between goals, namely G_{1} ≺ G_{2}, with the intended meaning of “G_{1} can arise as a subgoal of G_{2}”. Intuitively, a program terminates if it yields an ordering relation which admits no infinite descending chains. This is defined in Figure 6.4. 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 and transitive closure of R. We say that P is terminating whenever the former is well-founded.

Example 6.7 def(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)) ≺ . . ..

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 remark that ⊬_{P} is the denial relation introduced in Figure 6.1 and 6.2.

Theorem 6.8 (Termination) Assume P is terminating: for any ground G, if not Γ; D ⊢_{P} G, then Γ; D ⊬_{P} G.

Proof: We generalize this to: let D be a ground instance of def(q, P ∧ D):

1. If not Γ; D ⊢_{P} G, then Γ; D ⊬_{P} G.

2. If not Γ; D ⊢_{P} D>>Q, then Γ; D ⊬_{P} >>Q.

We proceed by mutual induction on the goal ordering induced by P terminating and on the structure of D:

Case D =⊥: trivial.

Case D = ⊤.

\frac{>>⊤}{Γ; D ⊬_{P} ⊤>>Q}

Draft of March 25, 2000

100  CHAPTER 6. CLAUSE COMPLEMENTATION
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 ⟹^{G} R

⟹^{G} ∃

Γ ⊢ ∃x:A. G ⟹^{G} R, 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

D ⟹^{D} R

⟹^{D} ∀

∀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.4: Generation of the Subgoal Relation Case D = D_{1} ← G_{1}. Either Γ; D ⊢_{P} G_{1} or not Γ; D ⊢_{P} G_{1} and Γ; D ⊢_{P} D_{1}>>Q

Draft of March 25, 2000

or not Γ; D ⊢_{P} D_{1}>>Q. Since D_{1} ← G_{1} is an istance of a terminating clause, by stability, it is terminating as well: 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
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
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}>>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
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} ⊢_{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

\frac{⊬⊥}{Γ; D ⊬_{P}⊥}

Case Either Γ; D ⊢_{P} def(q, P ∧ D)>>Q or not Γ; D ⊢_{P} def(q, P ∧ D)>>Q:

1. Γ; D ⊢_{P} def(q, P ∧ D)>>Q  Subcase
Γ; D ⊢_{P} Q  By rule
2. Not Γ; D ⊢_{P} def(q, P ∧ D)>>Q  Subcase
Γ; D ⊬_{P} def(q, P ∧ D)>>Q  By IH 2
Γ; D ⊬_{P} Q  By rule

Case Either Γ; D ⊢_{P} G_{1} or not Γ; D ⊢_{P} G_{1} and either Γ; D ⊢_{P} G_{2} or not Γ; D ⊢_{P} 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

Case Either Γ; D ⊢_{P} G_{1} or not Γ; D ⊢_{P} G_{1} and either Γ; D ⊢_{P} G_{2} or not Γ; D ⊢_{P} G_{2}: Γ; D ⊬_{P} 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 Either for some ground Γ ⊢ t : A, Γ; D ⊢_{P} [t/x]G or for all t not Γ; D ⊢_{P} [t/x]G:

1. Γ ⊢ t : A  By hypothesis
Γ; D[t/x] ⊢_{P} G  Subcase
Γ; D ⊢_{P} ∃x:A. G  By rule
2. For all ground t not Γ; D ⊢_{P} [t/x]G  Subcase
Γ; D ⊬_{P} [t/x]G  By IH 1
Γ; D ⊬_{P} ∃x:A. G  By rule

Case 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
Γ; [y/x]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
Γ; [, y/x]D ⊬_{P} ∀x:A. G  By rule

Case Γ; (D ∧ D) ⊢_{P} G or not Γ; (D ∧ D) ⊢_{P} 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.3 Context Schemata

In this Section, we address the properties of contexts^{1}. We restrict to secondorder programs, specifically to programs which make only Horn assumptions; this is enough to achieve satisfaction of boolean axioms for the algebra of clause complementation.

Hereditary Harrop formulae differ form 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 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; 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. Φ = F V (D). As usual, we implicitly annotate those variables with their types. This is achieved by 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)

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. To achieve 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.

⌈Γ⌉; ⌈D⌉ ⊢_{P} def(Q, P ∧ D)>>Q
⊢ At Γ; D ⊢_{P} Q
⌈Γ⌉; ⌈D⌉ ⊬_{P} def(Q, P ∧ D)>>Q
⊬ At
Γ; D ⊬_{P} Q

1This section is inspired by Schürmann’s treatment of similar material in his forthcoming dissertation [].

Draft of March 25, 2000

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 define when a run-time context is an instance of a schema. 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. We restrain from giving rules for substitutions; we simply mention that the codomain is Φ, i.e. the global parameters introduced by the ⊧_{S} ∀ and \∃ rules, while the domain is Γ.

(Γ′; 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.5. 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.

6.3.1 Schema Extraction

Roughly, we extract a context schema by collecting all negative occurrences in a goal: 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.6. When an atomic goal is reached, the current list of parameter and assumption is returned, with the correct existential binding. We make the convention to absorb schema alternatives which are αvariants. Moreover the empty run-time context behave as a left and right zero element for ∥, i.e.

(Γ; D∥·; ⊤) = (·; ⊤∥)Γ; D = Γ; D

Finally ∥ is commutative.

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.9 If Γ; D ∈ S then Γ; D ∈ S′∥S.

Proof: By a straightforward induction on the structure 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
Γ; D \ [u/x]G < S
\∃^{u}
Γ; D \ ∃x:A. G < S
(Γ, y:A); D \ [y/x]G < S

\∀^{y}

Γ; D \ ∀x:A. G < S

⊧_{S} D Γ; (D ∧ D) \ G < S

\ →

Γ; D \ D → G < S

X ∈ {Q, ⊤ ⊥}

⊧_{S} X

⊧_{S} X

⊧_{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.5: Judgments Γ; D \ G < S, ⊧_{S} D and Γ; D < S

Draft of March 25, 2000

X ∈ {Q, ⊤, ⊥} or (dis)eq F V (D) = Φ

⟹^{G} X

Γ; D ⊢ X ⟹^{G} Γ; SOME Φ .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 ⊢ [u/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/x]D ⟹^{D} S

⟹^{D} ∀^{y}

∀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.6: Extracting Contexts Schemata

Draft of March 25, 2000

6.3. CONTEXT SCHEMATA  109

Note also that Γ; D ∈ S′∥S iff Γ; D ∈ S∥S′. Lemma 6.10 (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 \ →

Draft of March 25, 2000

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.9
⊧_{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.11 (Extracted Schema Satisfaction) Let Γ ⊢ θ, where dom(θ) = F V (D′) ∪ F V (D):

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

Draft of March 25, 2000

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.10
⊧_{S_{1}∥S_{2}} [θ]D_{2}  By Lemma 6.10
⊧_{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.10
·; ⊤ ⊢ 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.10
⊧_{S_{1}∥S_{2}} [θ]G → [θ]D  By rule ⊧_{S}→

Case

γ = X ∈ {Q, ⊤, ⊥} or (dis)eq F V (D′) = Φ ⟹^{G} X Γ′; D′ ⊢ X ⟹^{G} Γ′; SOME Φ .D′

Γ′; [θ]D′ ≡_{α} Γ′; [θ]D′  By hypothesis
Γ′; [θ]D′ ∈ Γ′; SOME Φ .D′  By rule ∈_{1}
Γ; D < Γ′; SOME Φ .D′  By hypothesis
⊧_{Γ′;SOME Φ .D′} [θ]D′  By hypothesis
(Γ, Γ′); (D ∧ [θ]D′) < Γ′; SOME Φ .D′  By rule <_{2}
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]X < Γ′; SOME Φ .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}

Draft of March 25, 2000

(Γ′, 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.10
Γ; 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.10
(Γ, Γ′); (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}

Γ′; 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.10
Γ′; 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.10
(Γ, Γ′); (D ∧ [θ]D′) \ [θ]G_{1} ∧ [θ]G_{2} < S_{1}∥S_{2}  By rule \∧

Case γ ends in ⟹^{G} ∨: similarly to the above.

Case γ ends in ⟹^{G} ∃^{y}: by an immediate appeal to IH 2.

□

6.3.2 Context Preservation

We aim to prove that execution preserves contexts, provided that the program itself and the input goal satisfy the extracted schema; that is, that every subgoal which arises in any given successful or failed (immediate and non-immediate sub-derivation) satisfies the context 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.12 If Γ; D < S and D ∈ D, then ⊧_{S} D.

Proof: By induction on the structure of the derivation of π :: Γ; D < S.

Case

π = \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

□

Finally, the proof of context preservation; note that we have already established schema extraction (Theorem 6.11), that is we assume that P ⟹^{D} S.

Theorem 6.13 (Context Preservation w.r.t. Provability) Let ⊧_{S} P and D ∈ def(Q, 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.

Case π ends in Γ; D ⊢_{P} ⊤: trivial.

Case π ends in Γ; D ⊢_{P} D → G:

Γ; D ∧ D ⊢_{P} G  By sub-derivation
Γ; D \ D → G < S  By hypothesis
Γ; D ∧ D \ G < S  By inversion

for any ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′ and

for any π′ :: Γ′; (D′ ∧ D′) ⊢_{P} G′ and Γ′; (D′ ∧ D′) \ G′ < S  By IH
for any π′ :: Γ′; D′ ⊢_{P} D′ → G′ and Γ′; D′ \ D → G′ < S  By rule

Case π ends in Γ; D ⊢_{P} ∀x:A. G:

(Γ, 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

for any ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′ and

for any π′ :: (Γ′, y:A); D′ ⊢_{P} [y/x]G′ and (Γ′, y:A); D′ \ [y/x]G′ < S By IH
for any π′′ :: Γ′; D′ ⊢_{P} ∀x:A. G′ and Γ′; D′ \ ∀x:A. G′ < S  By rule

Case π ends in ⊢ ∧, ⊢ ∨_{1}, ⊢ ∨_{2}, ⊢ ∃: similarly by IH.

Case π ends in Γ; D ⊢_{P} Q:

Subcase ι :: Γ; D ⊢_{P} D>>Q, for D ∈ def(Q, P)  By sub-derivation
⊧_{S} D  By hypothesis
for any π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and
for any ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′  By IH
Subcase ι :: Γ; D ⊢_{P} D>>Q, for D ∈ def(Q, D)  By sub-derivation
⊧_{S} D  By Lemma 6.12
for any π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and
for any ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′  By IH

Case ι :: Γ; D ⊢_{P}⊥ >>Q: trivial.

Case ι :: Γ; D ⊢_{P} D_{1} ∧ D_{2}>>Q:

⊧_{S} D_{1} ∧ D_{2}  By hypothesis
⊧_{S} D_{1} and ⊧_{S} D_{2}  By inversion
Subcase Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
for any π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and
for any ι′ :: Γ′; D′ ⊢_{P} D′_{1}>>Q and ⊧_{S} D′_{1}  By IH
for any ι′′ :: Γ′; D′ ⊢_{P} D′_{1} ∧ D′_{2}>>Q and ⊧_{S} D′_{1} ∧ D′_{2}  By rule
Subcase Γ; D ⊢_{P} D_{2}>>Q  Symmetrical

Case ι :: Γ; D ⊢_{P} ∀x:A. D>>Q

Γ; 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

for any π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and

for any ι′ :: Γ′; D′ ⊢_{P} [t/x]D′>>Q and ⊧_{S} [t/x]D′  By IH
for any ι′′ :: Γ′; D′ ⊢_{P} ∀x:A. D′>>Q and ⊧_{S} ∀x:A. D′  By rule

Case ι :: Γ; D ⊢_{P} G → D>>Q:

Γ; D ⊢_{P} D>>Q and Γ; D ⊢_{P} G  By sub-derivation
⊧_{S} G → D  By hypothesis
Γ; D \ G < S and ⊧_{S} D  By inversion

for any π′ :: Γ′; D′ ⊢_{P} G′ and Γ′; D′ \ G′ < S and

for any ι′ :: Γ′; D′ ⊢_{P} D′>>Q and ⊧_{S} D′  By IH
for any ι′′ :: Γ′; D′ ⊢_{P} G′ → D′>>Q and ⊧_{S} G′ → D′  By rule

Case ι ends in >>∨, >>∀: similarly by IH.

□

We establish an analogous result w.r.t. denial. We recall that the statement must be generalized to account for the meta-level extensional quantification brought in by the ≯>∀, ⊬ ∃ rules; at the same time those substitution terms should be disjoint with the global parameters which are instantiated while satisfying the schema: formally, for our implicit pool of global parameters Φ, we require dom(θ) ∩ Φ = ∅.

Theorem 6.14 (Context Preservation w.r.t. Denial) Let θ be a well-typed substitution such that Γ ⊢ θ. Let ⊧_{S} P and D ∈ def(Q, P∧D); for any Γ; [θ]D < S, if ( π :: Γ; [θ]D ⊬_{P} [θ]G and Γ; [θ]D\[θ]G < S ) or ( ι :: Γ; [θ]D ⊬_{P} [θ]D>>[θ]Q and ⊧_{S} [θ]D), then for all θ′:

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, as above. We show only some cases:

Case

π = for all n, θ Γ ⊢ n : A Γ; [θ]D ⊬_{P} [θ, n/x]G ⊬ ∃ for all θ Γ; [θ]D ⊬_{P} [θ]∃x:A. G

for all θ , n Γ; [θ]D ⊬_{P} [θ, n/x]G  By sub-derivation
for all θ Γ; [θ]D \ [θ]∃x:A. G < S  By hypothesis
for all θ Γ; [θ]D \ [θ, u/x]G < S  By inversion
for all θ , n Γ; [θ]D \ [θ, n/u, u/x]G  By substitution

for any ι′ :: Γ′; [θ′]D′ ⊬_{P} [θ′]D′>>[θ′]Q and ⊧_{S} [θ′]D′ and

for any π′ :: Γ′; [θ′]D′ ⊬_{P} [θ′, n/x]G′ and Γ′; [θ′]D′ \ [θ′, n/x]G′ < S By IH
for any π′′ :: Γ′; [θ′]D′ ⊬_{P} [θ′]∃x:A. G′ and Γ′; [θ′]D′ \ [θ′]∃x:A. G′ < S By rule

Case

π = for all θ Γ; ([θ]D ∧ [θ]D) ⊬_{P} [θ]G ⊬ → Γ; [θ]D ⊬_{P} [θ]D → [θ]G

for all θ Γ; ([θ]D ∧ [θ]D) ⊬_{P} [θ]G  By sub-derivation
for all θ Γ; [θ]D \ [θ]D → [θ]G < S  By hypothesis
for all θ Γ; [θ]D ∧ [θ]D \ [θ]G < S  By inversion

for any ι′ :: Γ′; [θ′]D′ ⊬_{P} [θ′]D′>>[θ′]Q and ⊧_{S} [θ′]D′ and

for any π′ :: Γ; ([θ′]D′ ∧ [θ′]D′) ⊬_{P} [θ′]G′ and Γ; ([θ′]D′ ∧ [θ′]D′) \ [θ′]G′ < S By IH
for any π′′ :: Γ′; [θ′]D′ ⊬_{P} [θ′](D′ → G′) and Γ′; [θ′]D′ \ [θ′](D′ → G′) < S By rule

Case

ι = for all θ Γ; [θ]D ⊬_{P} [θ]G ≯>→_{1} for all θ Γ; [θ]D ⊬_{P} [θ]D ← [θ]G>>[θ]Q

for all θ Γ; [θ]D ⊬_{P} [θ]G  By sub-derivation
for all θ ⊧_{S} [θ]G → [θ]D  By hypothesis
for all θ Γ; [θ]D \ [θ]G < S and ⊧_{S} [θ]D  By inversion

for any π′ :: Γ′; [θ′]D′ ⊬_{P} G′ and Γ′; [θ′]D′ \ G′ < S and

for any ι′ :: Γ′; [θ′]D′ ⊬_{P} [θ′]D′>>[θ′]Q and ⊧_{S} [θ′]D′  By IH
for any ι′′ :: Γ′; [θ′]D′ ⊬_{P} [θ′](D′ ← G′)>>[θ′]Q and ⊧_{S} [θ′](D′ ← G′)By rule

Case

ι = for all θ Γ; [θ]D ⊬_{P} [θ]D>>[θ]Q ≯>→_{2} for all θ Γ; [θ]D ⊬_{P} [θ]D ← [θ]G>>[θ]Q

for all θ Γ; [θ]D ⊬_{P} [θ]D>>[θ]Q  By sub-derivation
for all θ ⊧_{S} [θ]G → [θ]D  By hypothesis
for all θ Γ; [θ]D \ [θ]G < S and ⊧_{S} [θ]D  By inversion

for any π′ :: Γ′; [θ′]D′ ⊬_{P} [θ′]G′ and Γ′; [θ′]D′ \ [θ′]G′ < S and

for any ι′ :: Γ′; [θ′]D′ ⊬_{P} [θ′]D′>>[θ′]Q and ⊧_{S} [θ′]D′  By IH
for any ι′′ :: Γ′; [θ′]D′ ⊬_{P} [θ′](D′ ← G′)>>[θ′]Q and ⊧_{S} [θ′](D′ ← G′)By rule
□

6.4 Clause Complementation

We restrict to programs with:

• Complementable clauses of the form Q ← G such that the head of every term in Q is rigid.

• Parameters of base type and occurring only in head position, called Shallow Parameter Expressions.

We do not formalize here the former assumptions on terms; note that the constructor restriction applies only to non-Horn predicate definitions and can be relaxed significantly, see the comment and the end of the proof of Theorem 6.23. We do give a definition of complementable clause in Figure 6.7.

Example 6.15 The clause encoding the introduction rule for implication in natural deduction from Example 5.1 is not complementable:

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 same rule promotes the following:

isdall : ∀D:term → form. isd (all D) ←
∀x:term. isd (D x).

The restriction on goal and clause yields this revised grammar:

Clauses D ::= ⊤ |⊥| Q ← G | D_{1} ∧ D_{2} | D_{1} ∨ D_{2} | ∀x:a. D
Goals G ::= Q | ⊤ |⊥| M⃗ =^{·} N⃗ | M⃗ ≠^{·} N⃗ |
G_{1} ∧ G_{2} | G_{1} ∨ G_{2} | D → G | ∀x:a. G

Note that ‘facts’ are represented, in a standardized way, by Q ← ⊤, although in examples we will omit to mention the body if it is ⊤. We accordingly specialize the immediate implication and denial rules as follows:

Γ; D ⊢_{P} N⃗ =^{·} M⃗ Γ; D ⊢_{P} G >> →

Γ; D ⊢_{P} (q N⃗ ← G)>>q M⃗

Γ; D ⊬_{P} N⃗ ≠^{·} M⃗ ⊬_{P} G

≯>→_{2}

Γ; D ⊬_{P} (q N⃗ ← G)>>q M⃗

Γ; D ⊬_{P} N⃗ =^{·} M⃗

≯>→_{1}
Γ; D ⊬_{P} (q N⃗ ← G)>>q M⃗

118  CHAPTER 6. CLAUSE COMPLEMENTATION
X ∈ {⊤, ⊥} or (dis)eq

G X Γ; D ⊢ X compl

\frac{At}{Γ; ⊤ ⊢ Q compl} D ∈ D → dom(Γ) ∩ par(D) ≠ ∅

At∩

Γ; D ⊢ Q compl

Γ; (D ∧ D) ⊢ G compl D compl

→

Γ; D ⊢ D → G compl
(Γ, y:a); D ⊢ [y/x]G compl

∀^{y} ∀x:a. G compl

Γ; D ⊢ G_{1} compl Γ; D ⊢ G_{2} compl

∧

Γ; D ⊢ G_{1} ∧ G_{2} compl

Γ; D ⊢ G_{1} compl Γ; D ⊢ G_{2} compl

∨

Γ; D ⊢ G_{1} ∨ G_{2} compl

\begin{aligned}X ∈ \{⊤, ⊥\} \\ & D X \\ X compl \end{aligned}

·; ⊤ ⊢ G compl ←

Q ← D compl [u/x]D compl

∀^{u} ∀x:A. D compl

D_{1} compl D_{2} compl

∧
D_{1} ∧ D_{2} compl
D_{1} compl D_{2} compl
∨
D_{1} ∨ D_{2} compl

Figure 6.7: Complementable clause and goal: D compl and Γ; D ⊢ G compl

Draft of March 25, 2000

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 N⃗ and M⃗ clashes. Rule ≯> →_{2} instead attributes denial with the same conclusion due to ‘failure’ in the body. If we use ∀(D) to denote the universal closure of (all) the free variables in D, then following is a derived rule of inference:

Γ ⊢ σ Γ; D ⊢_{P} σN⃗ =^{·} M⃗

∀σ>>

Γ; D ⊢_{P} ∀(q N⃗ ← ⊤)>>q M⃗

As it can be proven by a straightforward induction on the number of free variables in N⃗.

\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) = D′
Not_{D}∀
Not_{D}(∀x:A. D) = ∀x:A. D′
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.8: Clause Complementation: Not_{D}(D) = D′

We now introduce in Figure 6.8 and Figure 6.9 the rules for static and dynamic clause complementation. Consider a rule q M⃗ ← G ∈ def(q); 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⃗), namely

120  CHAPTER 6. CLAUSE COMPLEMENTATION

\frac{Notα ⊥}{Γ ⊢ Notα(⊥) = ⊤}

\frac{Notα⊤}{Γ ⊢ Notα(⊤_{q}) = ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(⊤_{q})}

Not_{G}(G) = G′

Notα ←

Γ ⊢ Notα(q ← G) = ( ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q)) ∧ (¬q ← G′)

Γ ⊢ Notα(D) = D′

Notα∀
Γ ⊢ Notα(∀x:A. D) = ∀x:A. D′

Γ ⊢ 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}

Σ(q) = A_{1} → ⋯ → A_{n} → prop · ⊢ sh(x, A_{i}) = e_{x}

Not_{x}^{i}⊤

Not_{x}^{i}(⊤_{q}) = ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q \overline{Z_{e_{x}}^{i}} ← ⊤ Σ(q) = A_{1} → ⋯ → A_{n} → prop · ⊢ sh(x, A_{i}) = e_{x}

Not_{x}^{i}At

Not_{x}^{i}(q \overline{M_{n}}) = ⋀_{1≤j≤n}^{j≠i}(∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q \overline{Z_{e_{x}}^{i}} ← M_{j} ≠^{·} Z_{j})

\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.9: Assumption Complementation: Γ ⊢ Notα(D) = D′ ⋀_{N⃗∈Not(M⃗)} ∀(¬(q N⃗) ← ⊤), whose fresh free variables are universally closed; moreover the negative counterpart of the source clause is obtained via complementation of the body. The original quantification is retained thanks to rule Not_{D}∀.

Draft of March 25, 2000

Otherwise, 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}). However, most of the those arguments, which at compile time are variables, will be instantiated at run-time: therefore it would be incorrect to compute their complement as empty. Since we cannot foresee this instantiation, we achieve term complementation via the introduction of disequations. This is achieved by the judgment Γ ⊢ Notα(D); note that the latter is type directed and can be see as constraintsbased version of term complementation. We briefly comment on rules Notα⊤ and Notα →:

• Pivot on x:a ∈ Γ.

• Locate a type A_{i} such that x is relevant to Q at i.

• Complement D w.r.t. x and i, by introducing the appropriate disequation.

• Repeat for every relevant x and i.

• Special case: if no x is relevant, the trivial program is returned.

The judgment is not optimized since if M_{j} is essentially existential, an unsatisfiable clause is built; moreover, if it is a ground term, we add a disequation, rather then computing the term complement. We can perform constraint simplification in a separated phase, see Section 6.8.3.

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. The rule Not_{x}^{i}⊤ allows to build 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. 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; finally, the notation \overline{Z_{e_{x}}^{i}} abridges Z_{1} … Z_{i−1} e_{x} Z_{i+1} … Z_{n}, where the Z’s are fresh logic variables.

The other 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 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). First, we remark that the ∨ is available uniquely as a program constructor and can therefore be used only in the focusing phase of deductions;in (Section 6.8.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 [BMPT90b]. This will restore completeness of uniform proofs

\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}

Not_{G}(G) = G′

Not_{G}∀
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.10: Goal Complementation: Not_{G}(G) = G′

Goal complemenation, that is the judgment Not_{G}(G) depicted in Figure 6.10, 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 parametric-hypothetical judgments to respect the operational interpretation of unprovability.

As a final remark, we note 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, fixed a signature Σ_{P} and given a program P:

Not_{D}(P) = ⋀_{q∈Σ_{P}} Not_{D}(def(q, P))

Similarly for a conjunction of dynamic assumptions D:

Notα(D) = ⋀_{q∈Σ_{P}} Notα(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).

The following example is somehow a special case of the general procedure, as assumption complementation is trivial, but it is useful to clarify in isolation the rules for clause and goal complementation. We refer to the next Section (6.5) for more complex examples.

Example 6.16 An λ-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. 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)).

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.29 and the final result in Example 6.33.

6.5 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 insert the correct assumption complementation in a goal and in turn in a clause. We give one judgment to augment a program, aug_{D}(D), which merely recurs on the structure of clauses until it calls goal augmentation, Γ; D ⊢ aug_{G}(G). 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:

\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}

aug_{D}([u/x]D) = [u/x]D^{a}
aug_{D}∀^{u}
aug_{D}(∀x:a. D) = ∀x:a. D^{a}

aug_{D}(D) = D^{a} ·; ⊤ ⊢ aug_{G}(G) = G_{a} aug_{D} ←

aug_{D}(D ← G) = D^{a} ← G_{a}

Figure 6.11: Clause Augmentation: aug_{D}(D) = D^{a}

Example 6.17 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 procedure aug_{D}(cplam) yields aug_{G}(∀x : exp. copy x x → copy (E x) (F x)), which collects x:exp; copy x x and calls x:exp ⊢ Notα(copy x x).

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}([u/x]G) = [u/x]G^{a}

aug_{G}∃^{u}

Γ; 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.12: Goal Augmentation: Γ; D ⊢ aug_{G}(G) = G_{a}

First Not_{1}^{x}(copy x x) = (∀E′:exp. ¬copy E′ x ← x ≠^{·} E′), secondly Not_{2}^{x}(copy x x) =

(∀F′:exp. ¬copy x F′ ← x ≠^{·} F′), yielding:

aug_{D}(cplam) : ∀E:exp → exp. ∀F:exp → exp.
copy (lam E) (lam F)
← (∀x:exp.

(∀E′:exp. ¬copy E′ x ← x ≠^{·} E′) ∧

(∀F′:exp. ¬copy x F′ ← x ≠^{·} F′) →

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, i.e.

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 four calls, namely to:

Not_{1}^{x}(copy′ x y) = (∀E′:exp. ¬copy′ x E′ ← x ≠^{·} E′)
Not_{2}^{x}(copy′ x y) = (∀E′′:exp. ¬copy′ E′′ x ← x ≠^{·} E′′)
Not_{1}^{y}(copy′ x y) = (∀F′:exp. ¬copy′ x F′ ← y ≠^{·} F′)
Not_{2}^{y}(copy′ x y) = (∀F′′:exp. ¬copy′ F′′ y ← y ≠^{·} F′′)

yielding the augmented clause:

aug_{D}(cplam′) : ∀E:exp → exp. ∀F:exp → exp.
copy′ (lam E) (lam F)
← (∀x:exp. ∀x:exp.

(∀E′:exp. ¬copy′ E′ x ← x ≠^{·} E′) ∧

(∀E′′:exp. ¬copy′ x E′′ ← x ≠^{·} E′) ∧

(∀F′:exp. ¬copy′ x F′ ← x ≠^{·} F′) ∧

(∀F′′:exp. ¬copy′ F′′ y ← y ≠^{·} F′′) →

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_{2}^{x}, Not_{1}^{y} are useless; however since this kind of data flow analysis is in general undecidable, the augmentation procedure inserts the negation of a clause for every position relevant to the pivot parameter.

Take 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, the correspondent diseqution is inserted:

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 to perform instantiation of a binding operator (in the pattern fragment):

inlam : ∀E:exp → exp. ∀F:exp.
inst (lam E) F
← (∀x:exp. (∀H:exp. copy x H)
→ copy (E x) F).

The call to x:exp ⊢ Notα(∀H:exp. copy x H) leads to Not_{x}^{1}(∀H:exp. copy x H), which yields the unsatisfiable clause ∀H : exp. ∀Z : exp. ¬copy x Z ← Z ≠^{·} H,

while Not_{x}^{2}(∀H : exp. copy x H) yields ∀Z : exp. ¬copy x Z ← Z ≠^{·} x. The

augmentation will simply to

aug_{D}(inlam) : ∀E:exp → exp. ∀F:exp.
inst (lam E) F

← (∀x:exp. (∀H:exp. copy x H) ∧

(∀Z:exp. ¬copy x Z ← Z ≠^{·} x)

→ copy (E x) F).

Let us see how rule Not_{x}^{i}⊤ 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_{x}^{i}⊤; 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)).

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.18 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.19 (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}

Draft of March 25, 2000

Case

π = \begin{aligned}⊧_{S} D ·; ⊤ \ G < S \\ & ⊧_{S}→ \\ ⊧_{S} G → D \end{aligned}

⊧_{S} D  By sub-derivation
⊧_{S^{a}} aug_{D}(D)  By IH 1
·; ⊤ \ G < S  By sub-derivation
·; ⊤ \ aug_{G}(G) < S^{a}  By IH 2
⊧_{S^{a}} aug_{G}(G) → aug_{D}(D)  By rule ⊧_{S}→
⊧_{S^{a}} aug_{D}(G → D)  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

Case

γ = \begin{aligned}Γ; D < S \\ & \At \\ Γ; D \ Q < S \end{aligned}

Subcase ·; ⊤ < S  By sub-derivation
·; ⊤ < S^{a}  By rule <_{1}
·; ⊤ ⊢ Q < S^{a}  By rule aug_{G}At⊤
·; ⊤ \ aug_{G}(Q) < S^{a}  By rule \At
Subcase Γ; D < S  By sub-derivation
Γ; aug_{D}(D) < S^{a}  By IH 3
Γ; aug_{D}(D) \ Q < S^{a}  By rule \Q
Γ; 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.18
⊧_{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}∧
□

Lemma 6.20 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. □

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).

Lemma 6.21 (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}} ⊤}

Draft of March 25, 2000

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}} aug_{D}(q M⃗) ← aug_{G}(G)  By rule aug_{D} →
⊧_{S^{a}} ¬q M⃗  By rule ⊧_{S^{a}} At
·; ⊤ \ aug_{G}(G) < S^{a}  By rule ⊧_{S}→
·; ⊤ \ Not_{G}(aug_{G}(G)) < S^{a}  By IH 2
⊧_{S^{a}} ¬q M⃗ ← Not_{G}(aug_{G}(G))  By rule ⊧_{S^{a}}→
⊧_{S^{a}} ⋀_{N⃗∈Not(M⃗)} ∀(¬(q N⃗))  By Lemma 6.20

⊧_{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 aug_{D} →
⊧_{S^{a}} Not_{D}(aug_{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}(∀x:a. D):

⊧_{S^{a}} ∀x:a. aug_{D}(D)  By rule aug_{D}∀
⊧_{S^{a}} [u/x]aug_{D}(D)  By rule ⊧_{S^{a}} ∀
⊧_{S^{a}} [u/x]Not_{D}(aug_{D}(D))  By IH 1
⊧_{S^{a}} ∀x:a. Not_{D}(aug_{D}(D))  By rule ⊧_{S^{a}} ∀
⊧_{S^{a}} Not_{D}(∀x:a. aug_{D}(D))  By rule Not_{D}∀
⊧_{S^{a}} Not_{D}(aug_{D}(∀x:a. D))  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}∨

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}:

Subcase ·; ⊤ \ Q < S^{a}  By rule aug_{G}At⊤
·; ⊤ < S^{a}  By sub-derivation
·; ⊤ \ ¬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 \ 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.19 and 6.21 to prove that augmentation guarantees that static and dynamic clauses are closed under complementation.

Corollary 6.22 (Closure under Complementation) If ⊧_{S} D, then ⊧_{S^{a}} Not_{D}(aug_{D}(D)).

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, because context schemata allows 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 the following counter-example 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.

6.6 Exclusivity

We use Γ; D ⊢_{P} Not_{G}(G) for Not_{G}(G) = G′ and Γ; D ⊢_{P} G′; Γ; D ⊢_{P} Not_{D}(D)>>¬Q for Not_{D}(D) = D′ and Γ; D ⊢_{P} D′>>¬Q; similarly for Notα. Recall that D ∈ def(q, P ∧D) denotes that D is a top-level conjunct in the static or dynamic definition of q. Similarly, D ∈ def(¬q, P ∧ D) denotes that D is a top-level disjunct in the static or dynamic definition of ¬q. We use P to denote the conjunction of a positive program P^{+} and its negation P^{−} = Not_{D}(P^{+}). Finally, since by Corollary 6.22 a (run-time) context is closed under negation D′ ∈ def(¬q, D) iff D′ ≡ Notα(D) for D ∈ def(¬q, D).

Theorem 6.23 (Exclusivity) Let aug_{D}(P) ⟹^{D} S^{a} and Γ; D < S^{a}. For every goals such that ·; ⊤ \ G < S^{a}, it is not the case that both Γ; D ⊢_{P} G and Γ; D ⊢_{P} Not_{G}(G).

Proof: We generalize this to; let D ∈ def(q, P ∧ D):

1. It is not the case that there is S^{+} :: Γ; D ⊢_{P} G and there is S^{−} :: Γ; D ⊢_{P} Not_{G}(G).

2. It is not the case that I^{+} :: Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P} D′>>Not_{G}(Q), for all D′ ∈ def(¬q, P ∧ D).

We proceed by mutual induction on the structure of I^{+} and S^{+}, by assuming their existence. Note that immediately Not_{G}(Q) = ¬Q. Moreover, the negative definition implies an atom iff so does every disjunct; thus it will suffice to show absurdity for one of the latter. The second statement thus unfolds in four distinct cases:

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)>>¬Q.

Case

I^{+} = \frac{>> ⊥}{Γ; D ⊢_{P}⊥ >>Q}

But there can be no proof of ¬Q from Not_{D}(⊥) = ⊤.

Draft of March 25, 2000

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 def. 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

Case

I^{+} = \begin{aligned}Γ ⊢ t : A Γ; D ⊢_{P} [t/x]D>>Q \\ & >>∀ \\ Γ; D ⊢_{P} ∀x:A. D>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Not_{D}(∀x:A. D)>>¬Q:

Γ; D ⊢_{P} [t/x]D>>Q  By sub-derivation
Γ; D ⊢_{P} ∀x:A. Not_{D}(D)>>¬Q  By rule Not_{D}∀
Γ; D ⊢_{P} [t/x]Not_{D}(D)>>¬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} >>D′¬Q.

Case

I^{+} = \frac{>>At}{Γ; D ⊢_{P}⊥ >>Q}

But there can be no proof of ¬Q from Notα(⊥) = ⊤.

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{N_{e_{x}}^{i}} ← H)>>¬q \overline{M_{n}}, where q \overline{N_{e_{x}}^{i}} ← H ∈ def(q, D).

Γ; D ⊢_{P} \overline{S_{n}} =^{·} \overline{M_{n}}  By sub-derivation
Γ; D ⊢_{P} S_{i} =^{·} M_{i} 1 ≤ i ≤ n (∗)  By sub-derivation

Γ; D ⊢_{P} ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}}) ∧ (¬q \overline{N_{e_{x}}^{i}} ← Not_{G}(H))>>¬q \overline{M_{n}} By rule Notα →

Subcase Γ; D ⊢_{P} ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}})>>¬q \overline{M_{n}} By inversion
Γ; D ⊢_{P} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}})>>¬q \overline{M_{n}}  By inversion

Γ; D ⊢_{P} ⋀_{1≤j≤n,j≠i}(∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q \overline{Z_{x}^{i}} ← N_{j} ≠^{·} Z_{j})>>¬q \overline{M_{n}}

By rule Not_{x}^{i} →

Γ; D ⊢_{P} ∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q \overline{Z_{e_{x}}^{i}} ← N_{j} ≠^{·} Z_{j}>>¬q \overline{M_{n}}By inv.

Γ; D ⊢_{P} [σ]\overline{Z_{e_{x}}^{i}} =^{·} \overline{M_{n}}  By inv. and x ∉ dom(σ)
Γ; D ⊢_{P} e_{x} =^{·} M_{i}  By inversion
⊥  From above line (∗) and constructor restriction on S_{i}
Subcase Γ; D ⊢_{P} ¬q \overline{N_{e_{x}}^{i}} ← Not_{G}(H)>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} \overline{N_{e_{x}}^{i}} =^{·} \overline{M_{n}}  By inversion
Γ; D ⊢_{P} e_{x} =^{·} M_{i}  By inversion
⊥  From above line (∗) and constructor restriction on S_{i}

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′_{1} ∨ D′_{2})>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} D_{2}>>Q  By sub-derivation
Γ; D ⊢_{P} Notα(D′_{1}) ∧ Notα(D′_{2})>>¬Q  By rule Notα∨
Subcase Γ; D ⊢_{P} Notα(D′_{1})>>¬Q  By inversion
⊥  By IH 2.2
Subcase Γ; D ⊢_{P} Notα(D′_{2})>>¬Q  By inversion
⊥  By IH 2.2

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′_{1} ∧ D′_{2})>>¬Q:

Γ; D ⊢_{P} D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} Notα(D′_{1}) ∨ Notα(D′_{2})>>¬Q  By rule Notα∧
Γ; D ⊢_{P} Notα(D′_{1})  By inversion
⊥  By IH 2.2

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′_{1} ∧ D′_{2})>>¬Q:

Γ; D ⊢_{P} D_{2}>>Q  By inversion
Γ; D ⊢_{P} Notα(D′_{1}) ∨ Notα(D′_{2})>>¬Q  By rule Notα∧
Γ; D ⊢_{P} Notα(D′_{2})>>¬Q  By inversion
⊥  By IH 2.2

Case

I^{+} = \begin{aligned}Γ ⊢ t : A Γ; D ⊢_{P} [t/x]D_{1}>>Q \\ & >>∀ \\ Γ; D ⊢_{P} ∀x:a. D_{1}>>Q \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Notα(∀x:a. D′)>>¬Q:

Draft of March 25, 2000

Γ; D ⊢_{P} [t/x]D_{1}>>Q  By sub-derivation
Γ; D ⊢_{P} ∀x:A. Notα(D′)>>¬Q  By rule Notα∀
Γ; D ⊢_{P} [t/x]Notα(D′)>>¬Q  By inversion
⊥  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} D′>>¬Q. 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} (∗) 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{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
⊥  Above line, (∗) and eigenvariable condition
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 above line (∗) and constructor restriction on S_{i}

Case I^{+} ends in >>∨, >> ∧ >>∀: symmetric to case 2.2. 2.4 Let D ∈ def(q, D) and D′ ∈ def(¬q, D). It is not the case that I^{+} ::

Γ; D ⊢_{P} D>>Q and I^{−} :: Γ; D ⊢_{P} D′>>¬Q. Case

I^{+} = \begin{aligned}Γ; D ⊢_{P} \overline{N_{e_{x}}^{i}} =^{·} \overline{M_{n}} Γ; D ⊢_{P} G \\ & >> → \\ Γ; D ⊢_{P} q \overline{N_{e_{x}}^{i}} ← G>>q \overline{M_{n}} \end{aligned}

and I^{−} ends in Γ; D ⊢_{P} Notα(q \overline{N_{e_{x}}^{i}} ← G)>>¬q \overline{M_{n}}.

S_{1}^{+} :: Γ; D ⊢_{P} G  By sub-derivation
Γ; D ⊢_{P} \overline{N_{e_{x}}^{i}} =^{·} \overline{M_{n}}  By sub-derivation
Γ; D ⊢_{P} N_{j} =^{·} M_{j} (+) 1 ≤ i, j ≤ n, i ≠ j  By inversion

Γ; D ⊢_{P} ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}}) ∧ (¬q \overline{N_{e_{x}}^{i}}) ← Not_{G}(G))>>¬q \overline{M_{n}} By rule Notα →

Draft of March 25, 2000

Subcase Γ; D ⊢_{P} ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}})>>¬q \overline{M_{n}} By inversion
Γ; D ⊢_{P} ⋀_{xR^{i}q} Not_{x}^{i}(q\overline{N_{e_{x}}^{i}})>>¬q \overline{M_{n}}  By inversion
Γ; D ⊢_{P} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}})>>¬q \overline{M_{n}}  By inversion

Γ; D ⊢_{P} ⋀_{1≤j≤n,j≠i}(∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q \overline{Z_{e_{x}}^{i}} ← Z_{j} ≠^{·} N_{j})>>¬q \overline{M_{n}}

By inversion

Γ; D ⊢_{P} (∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q \overline{Z_{e_{x}}^{i}} ← Z_{j} ≠^{·} N_{j})>>¬q \overline{M_{n}}

By inversion

Γ; D ⊢_{P} [M_{j}/Z_{j}]Z_{j} ≠^{·} N_{j}  By inversion
⊥  Above line and (+)
Subcase Γ; D ⊢_{P} ¬q \overline{N_{e_{x}}^{i}} ← 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 as in case 2.1 with Notα in place of Not_{D}.

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} D>>Q for D ∈ def(q, P ∧ D)  By sub-derivation
Γ; D ⊢_{P} ¬Q  By rule Not_{G}At
Γ; D ⊢_{P} def(¬q, PD)>>¬Q  By inversion
Γ; D ⊢_{P} D′>>¬Q for D′ ∈ def(¬q, P ∧ D)  By inversion
⊥  By IH 2

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}∧
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})

Draft of March 25, 2000

Γ; 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
Γ; D ⊢_{P} Not_{G}(G_{2})  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. DG′ \end{aligned}

and S^{−} ends in Γ; D ⊢_{P} Not_{G}(∀x:a. DG′):

(Γ, y:A); D ⊢_{P} [y/x]G′  By sub-derivation
Γ; D ⊢_{P} ∀x:a. DNot_{G}(G′)  By rule Not_{G}∀
(Γ, y:A); D ⊢_{P} [y/x]Not_{G}(G′)  By inversion
⊥  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 subcase 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 start with a constructor . Symmetrically for 2.3. Subcase 2.4 holds because an appropriate disequation is inferred; this approximates what happens in the first case 2.1, which is based on term exclusivity (Corollary 4.19). 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; the same remark applies when the definition is dynamic (2.4).

The requirement for programs to only allow clause heads with rigid terms may seem too restrictive and we thus comment on it. As we remarked earlier, it applies only to non-Horn predicate definitions; secondly, if q \overline{M_{n}} ← G ⟹^{G} S is a hhf formula and say q N_{e_{x}}^{i} is in S for some 1 ≤ i ≤ n, then only M_{i} must be rigid. However, any program which uses a ‘catch-all‘ clause is forbidden; nevertheless it is easy to avoid catch-all clauses via coercion. Finally, we remark that any other (decidable) condition which avoids overlap between static and dynamic clauses will do; the one we have proposed is certainly not ‘ad hoc’ and is dictated by the practice of logical frameworks.

6.7 Exhaustivity

Theorem 6.24 (Exhaustivity) Let aug_{D}(P) ⟹^{D} S^{a} and Γ; D < S^{a}. For every goal G such that ·; ⊤ \ 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: let θ, σ be well-typed substitutions such that Γ ⊢ σ, Γ ⊢ θ:

1. If for all θ S^{−} :: Γ; θD ⊬_{P} θG, then there is a σ such that S^{+} :: Γ; σD ⊢_{P} σNot_{G}(G).

2.1 If, for all θ and D ∈ def(Q, P) I^{−} :: Γ; θD ⊬_{P} θD>>θQ, then here is a σ such that I^{+} :: Γ; σD ⊢_{P} σNot_{D}(D)>>σ¬Q.

2.2 If, for all θ and D ∈ def(Q, D) I^{−} :: Γ; θD ⊬_{P} θD>>θQ, then here is a σ such that I^{+} :: Γ; σD ⊢_{P} σNotα(D)>>σ¬Q.

The proof is by mutual induction on the structure of S^{−} and I^{−}.

2.1

Case

I^{−} = \frac{≯>⊤}{for all θ Γ; θD ⊬_{P} ⊤>>θQ}

as, for all θ θ⊤ = ⊤. Then Not_{D}(⊤) =⊥= σ ⊥ and

I^{+} = \frac{>> ⊥}{Γ; θD ⊢_{P}⊥ >>σ¬Q}

Case

I^{−} = for all θ Γ; θD ⊬_{P} θ\overline{N_{n}} =^{·} θ\overline{M_{n}} ≯> →^{1} for all θ Γ; θD ⊬_{P} θ(q \overline{N_{n}} ← G)>>θq \overline{M_{n}}

for all θ Γ; θD ⊬_{P} θ\overline{N_{n}} =^{·} θ\overline{M_{n}}  By sub-derivation
\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.19)
\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}} some σ By rule and composition of subst.
Γ; σ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 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 >>∧

Γ; σD ⊢_{P} σNot_{D}(q \overline{N_{n}} ← G)>>σ¬q \overline{M_{n}}  By rule Not_{D}>>

Case

I^{−} = for all θ Γ; θD ⊬_{P} θ\overline{N_{n}} ≠^{·} θ\overline{M_{n}} for all θ Γ; θD ⊬_{P} θG ≯>→_{2} for all θ Γ; θD ⊬_{P} θ(q \overline{N_{n}} ← G)>>θq \overline{M_{n}}

for all θ Γ; θD ⊬_{P} θ\overline{N_{n}} ≠^{·} θ\overline{M_{n}}  By sub-derivation
Γ; σD ⊢_{P} σ\overline{N_{n}} =^{·} σ\overline{M_{n}}  By rule ⊢≠^{·}
for all θ Γ; θ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 >>∧

Γ; σD ⊢_{P} σNot_{D}(q \overline{N_{n}} ← G)>>σ¬q \overline{M_{n}}  By rule Not_{D} →

Case

I^{−} = for all θ Γ; θD ⊬_{P} θD_{1}>>θQ ≯>∨_{1} for all θ Γ; θD ⊬_{P} θ(D_{1} ∨ D_{2})>>θq
for all θ Γ; θ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^{−} = for all θ Γ; θD ⊬_{P} θD_{2}>>θQ ≯>∨_{2} for all θ Γ; θD ⊬_{P} θ(D_{1} ∨ D_{2})>>θq

Symmetrical to the above Case

I^{−} = for all θ Γ; θD ⊬_{P} θD_{1}>>θQ for all θ Γ; θD ⊬_{P} θD_{2}>>θQ ≯>∧ for all θ Γ; θD ⊬_{P} θ(D_{1} ∧ D_{2})>>θQ

for all θ Γ; θD ⊬_{P} θD_{1}>>θQ  By sub-derivation
for all θ Γ; θ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∧

Case

I^{−} = for all θ, n, Γ; θD ⊬_{P} θ · [n/x]D>>θQ ≯>∀ for all θ Γ; θD ⊬_{P} θ∀x:A. D>>θQ
for all θ, n, Γ; θD ⊬_{P} θ · [n/x]D>>θQ  By sub-derivation
Γ; σD ⊢_{P} σ · [t/x]Not_{D}(D)>>σ¬Q  By IH 2.1
Γ; σD ⊢_{P} σ∀x:A. Not_{D}(D)>>σ¬Q  By rule >>∀
Γ; σD ⊢_{P} σNot_{D}(∀x:A. D)>>σ¬Q  By rule Not_{D}∀

{2.2 \atop Case}

I^{−} = \frac{≯>⊤}{for all θ Γ; D ⊬_{P} ⊤_{q}>>θq \overline{M_{e_{x}}^{i}}}

Draft of March 25, 2000

\overline{M_{n}} = \overline{M_{n}}  By hypothesis
Γ; 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 \overline{Z_{e_{x}}^{i}}>>σ¬q \overline{M_{e_{x}}^{i}}  By rule >>∀
Γ; D ⊢_{P} σNot_{x}^{i}(⊤_{q})>>σ¬q \overline{M_{e_{x}}^{i}}  By rule Not_{x}^{i}⊤
Γ; D ⊢_{P} σ ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(⊤_{q})>>σ¬q \overline{M_{e_{x}}^{i}}  By rule >>∧
Γ; D ⊢_{P} σNotα(⊤_{q})>>σ¬q \overline{M_{e_{x}}^{i}}  By rule Notα⊤

Case

I^{−} = for all θ Γ; θD ⊬_{P} θ\overline{N_{e_{x}}^{i}} =^{·} θ\overline{M_{e_{x}}^{i}} ≯> →^{1} for all θ Γ; θD ⊬_{P} θ(q \overline{N_{e_{x}}^{i}} ← G)>>θq \overline{M_{e_{x}}^{i}}

for all θ Γ; θD ⊬_{P} θ\overline{N_{e_{x}}^{i}} =^{·} q \overline{M_{e_{x}}^{i}}  By sub-derivation
for all θ Γ; θD ⊬_{P} θN_{j} =^{·} θM_{j} for some 1 ≤ j ≤ n, j ≠ i By rule ⊬=^{·}
Γ; σD ⊢_{P} σN_{j} ≠^{·} σM_{j}  By rule ⊢≠^{·}
Γ; σD ⊢_{P} σ · [\overline{M_{e_{x}}^{i}}/\overline{Z_{n}}](¬q Z_{e_{x}}^{i} ← N_{j} ≠^{·} Z_{j})>>σ¬q \overline{M_{e_{x}}^{i}}By rule >> →

Γ; σD ⊢_{P} σ(∀Z_{1} :A_{1}…. ∀Z_{n}:A_{n}. ¬q Z_{e_{x}}^{i} ← N_{j} ≠^{·} Z_{j})>>σ¬q \overline{M_{e_{x}}^{i}}

By rule >>∀

Γ; σD ⊢_{P} σNot_{x}^{i}(q \overline{N_{e_{x}}^{i}} ← ⊤)>>σ¬q \overline{M_{e_{x}}^{i}} some 1 ≤ i ≤ n, i ≠ j

By rule Not_{x}^{i}At

Γ; σD ⊢_{P} σNot_{x}^{i}(q \overline{N_{e_{x}}^{i}})>>σ¬q \overline{M_{e_{x}}^{i}}  By rule >>∧

Γ; σD ⊢_{P} σ ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{N_{e_{x}}^{i}}) ∧ ¬(q \overline{N_{e_{x}}^{i}} ← G)>>σ¬q \overline{M_{e_{x}}^{i}}

By rule >>∧

Γ; σD ⊢_{P} σNotα(q \overline{N_{e_{x}}^{i}} ← G)>>σ¬q \overline{M_{e_{x}}^{i}}  By rule Notα →

Case

I^{−} = for all θ Γ; θD ⊬_{P} θ\overline{N_{e_{x}}^{i}} ≠^{·} θ\overline{M_{e_{x}}^{i}} for all θ Γ; θD ⊬_{P} θG ≯>→_{2} for all θ Γ; θD ⊬_{P} θ(q \overline{N_{e_{x}}^{i}} ← G)>>θq \overline{M_{e_{x}}^{i}}

for all θ Γ; θD ⊬_{P} θ\overline{N_{e_{x}}^{i}} ≠^{·} θ\overline{M_{e_{x}}^{i}}  By sub-derivation
Γ; σD ⊢_{P} σ\overline{N_{e_{x}}^{i}} =^{·} σ\overline{M_{e_{x}}^{i}}  By rule ⊢≠^{·}
for all θ Γ; θD ⊬_{P} θG  By sub-derivation
Γ; σD ⊢_{P} σNot_{G}(G)  By IH 1
Γ; σD ⊢_{P} σ(¬q \overline{N_{e_{x}}^{i}} ← Not_{G}(G))>>σ¬q \overline{M_{e_{x}}^{i}}  By rule >> →

Γ; σD ⊢_{P} σ ⋀_{x∈dom(Γ)} ⋀_{xR^{i}q} Not_{x}^{i}(q \overline{M_{e_{x}}^{i}}) ∧ ¬q \overline{M_{e_{x}}^{i}} ← Not_{G}(G))>>σ¬q \overline{M_{e_{x}}^{i}}

By rule >>∧

Γ; σD ⊢_{P} σNotα(q \overline{N_{e_{x}}^{i}} ← G)>>σ¬q \overline{M_{e_{x}}^{i}}  By rule Notα →

Case

I^{−} = for all θ Γ; θD ⊬_{P} θD_{1}>>θQ ≯>∨_{1} for all θ Γ; θD ⊬_{P} θ(D_{1} ∨ D_{2})>>θq
for all θ Γ; θ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^{−} = for all θ Γ; θD ⊬_{P} θD_{2}>>θQ ≯>∨_{2} for all θ Γ; θD ⊬_{P} θ(D_{1} ∨ D_{2})>>θq

Symmetrical to the above Case

I^{−} = for all θ Γ; θD ⊬_{P} θD_{1}>>θQ for all θ Γ; θD ⊬_{P} θD_{2}>>θQ ≯>∧ for all θ Γ; θD ⊬_{P} θ(D_{1} ∧ D_{2})>>θQ

for all θ Γ; θD ⊬_{P} θD_{1}>>θQ  By sub-derivation
for all θ Γ; θ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∧

Case

I^{−} = for all θ, n, Γ; θD ⊬_{P} θ · [n/x]D>>θQ ≯>∀ for all θ Γ; θD ⊬_{P} θ∀x:A. D>>θQ
for all θ, n, Γ; θD ⊬_{P} θ · [n/x]D>>θQ  By sub-derivation
Γ; σD ⊢_{P} σ · [t/x]Notα(D)>>σ¬Q  By IH 2.2
Γ; σD ⊢_{P} σ∀x:A. Notα(D)>>σ¬Q  By rule >>∀
Γ; σD ⊢_{P} σNotα(∀x:A. D)>>σ¬Q  By rule Notα∀

Case

S^{−} = for all θ Γ; θD ⊬_{P} θdef(Q, P ∧ D)>>θQ ⊬ atm for all θ Γ; θD ⊬_{P} θQ

Subcase D ∈ def(Q, P)

for all θ Γ; θD ⊬_{P} θD>>θQ  By sub-derivation
Γ; σD ⊢_{P} σNot_{D}(D)>>σ¬Q  By IH 2.1
Γ; σD ⊢_{P} σdef(¬Q, P)>>¬Q  By rule >>∨
Γ; σD ⊢_{P} σNot_{G}(Q)  By rule ⊢ At

Subcase D ∈ def(Q, D)

for all θ Γ; θD ⊬_{P} θD>>θQ  By sub-derivation
Γ; σD ⊢_{P} σNotα(D)>>σ¬Q  By IH 2.2
Γ; σD ⊢_{P} σdef(¬Q, D)>>¬Q  By rule >>∨
Γ; σD ⊢_{P} σ(Q)  By rule ⊢ At

Case

S^{−} = \frac{⊬ ⊥}{Γ; θD ⊬_{P} ⊥}

Then Not_{G}(⊥) = σ⊤ = ⊤ and

S^{+} = \frac{⊢ ⊤}{Γ; σD ⊢_{P} σNot_{G}(⊤)}

Draft of March 25, 2000

Case

S^{−} = for all θ Γ; θD ⊬_{P} θG_{1} for all θ Γ; θD ⊬_{P} θG_{2} ⊬ ∨ for all θ Γ; θD ⊬_{P} θ(G_{1} ∨ G_{2})
for all θ Γ; θD ⊬_{P} θG_{1}  By sub-derivation
for all θ Γ; θ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^{−} = for all θ Γ; θD ⊬_{P} θG_{1} ⊬ ∧_{1} for all θ Γ; θD ⊬_{P} θ(G_{1} ∧ G_{2})
for all θ Γ; θ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^{−} = for all θ Γ; θD ⊬_{P} θG_{2} ⊬ ∧_{2} for all θ Γ; θD ⊬_{P} θ(G_{1} ∧ G_{2})

Symmetrical to the above. Case

S^{−} = for all θ Γ; θD ∧ θD ⊬_{P} θG′ ⊬ → for all θ Γ; θD ⊬_{P} θ(D′ → G′)
for all θ Γ; θ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} σ(D′ → Not_{G}(G′))  By rule Not_{G} →
Γ; σD ⊢_{P} σNot_{G}(D′ → G′)  By subst.

Case

S^{−} = for all θ (Γ, y:A); θD ⊬_{P} θ · [y/x]G ⊬∀ Γ; θD ⊬_{P} θ∀x:A. G′
for all θ (Γ, 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.

□

6.8 Refinements

In the following Subsections we will move towards an operational semantics for our language.

6.8.1 More on Termination

In this section we prove that clause complementation preserve termination, so that a negative program can be used as decision procedure if so is its positive counterpart. First some preliminaries: call [R] the stable and transitive closure of the subgoal ordering defined in Figure 6.4. 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 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.25 For any substitution θ, Not_{G}([θ]G) = [θ]Not_{G}(G).

Proof: By a simple induction on the structure of Not_{G}(G). □

Lemma 6.26 If [R] is well-founded, so is [Not(R)].

Proof: Suppose [Not(R]) is not well-founded. Then it includes a cycle … ≺ [θ]G_{i} ≺ … ≺ [θ]G_{2} ≺ [θ]G_{1}. By definition of Not(R) there are G′_{i} such that Not_{G}(G′_{i}) = G_{i} and that G′_{i} ≺ G′_{i} + 1 ∈ R for i ∈ ω. Since by Lemma 6.25 Not_{G}([θ]G_{i}) = [θ]Not_{G}(G_{i}), then [R] allows a cycle … ≺ [θ]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.27

1. If π :: D ⟹^{D} R then Not_{D}(D) ⟹^{D} Not(R).

2. 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}}:

· ⊢ G ⟹^{G} R  By sub-derivation
· ⊢ Not_{G}(G) ⟹^{G} Not(R)  By IH 2
⋀_{\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
Not_{D}(q \overline{M_{n}} ← G) ⟹^{D} Not(R, G ≺ q \overline{M_{n}})  By rule

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 rule
□

Corollary 6.28 If P is terminating, so is Not_{D}(P).

Proof: By definition, P is terminating if P ⟹^{D} R and [R] is well-founded: by Lemma 6.27 Not_{D}(P) ⟹^{D} Not(R) and by Lemma 6.26 [Not(R)] is well-founded. Thus Not_{D}(P) is terminating. □

6.8.2 Elimination of ∨

We now show how to eliminate the ∨ operator preserving provability; this will recover uniformity in proof-search. We generalize the approach in [BMPT90b], where the operation was defined as follows: for m1 : Q_{1} ← G_{1} and m2 : Q_{2} ← G_{2}:

m1 ∨ m2 = θ(Q_{1} ← G_{1} ∧ G_{2}) where θ = mgu(Q_{1}, Q_{2})

As we remarked earlier, the ∨ operator was introduced to preserve the duality between conjunction and disjunction in clauses. Its use 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 even more so complicated by the mixed quantifier structure of hhf. Moreover, we have already in our language parameter (dis)equations introduced by the augmentation procedure, as well as variable-variable (dis)equations stemming from left-linearization. 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 then perform constraint simplification as used in Elf [Pfe89] and Twelf [SP98].

\frac{∨⊤}{⊤ ∨ D \ ⊤}

\frac{∨atm}{(q N⃗_{1} ← G_{1}) ∨ (q N⃗_{2} ← G_{2}) \ q N⃗_{1} ← (N⃗_{1} =^{·} N⃗_{2}) ∧ G_{1} ∧ G_{2}}

([u/x]D_{1}) ∨ D_{2} \ [u/x]D

∨∀ (∀x:A. D_{1}) ∨ D_{2} \ ∀x:A. D

D_{1} ∨ D_{2} \ D D′_{1} ∨ D_{2} \ D′

∨∧

(D_{1} ∧ D′_{1}) ∨ D_{2} \ D ∧ D′

Figure 6.13: ∨-Elimination: D_{1} ∨ D_{2} \ D

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.13 by induction on (normalized) D_{1}, with the intended meaning of ‘D_{1} ∨ D_{2} compiles to D’: As usual, we add the rules symmetric to ∨⊤, ∨∀, ∨∧. Note that residuation is undefined for clauses with different heads; yet we could make the judgment total by agreeing to compile them to ⊤.

Example 6.29 Continuing Example 6.16; 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)).

Let us compute Not_{D}(cloz) ⊗ Not_{D}(clolam) \ D:

∀F:exp. ¬closed (lam F) ← (lam F) =^{·} z ∧

∀F, F_{1}, F_{2} :exp. ¬closed (lam F) ← (lam F) =^{·} (app F_{1} F_{2}) ∧

∀E:exp. ¬closed (lam E) ← (∀x:exp. closed x → ¬closed (E x)) ∧

∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2}) ← (app F_{1} F_{2}) =^{·} z ∧

∀F, F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2}) ← (app F_{1} F_{2}) =^{·} (lam F) ∧

∀F_{1}, F_{2} :exp. ¬closed (app F_{1} F_{2}).

Note that only the third and last clause are satisfiable.

The following lemma guarantees that compilation preserves immediate entailment:

Lemma 6.30 Let D_{1} ∨ D_{2} \ D: Γ; 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 \⊤. Trivially true. 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} N⃗_{1} =^{·} N⃗ and Γ; D ⊢_{P} G_{1}  By inversion
Γ; D ⊢_{P} N⃗_{2} =^{·} N⃗ and Γ; D ⊢_{P} G_{2}  By inversion
Γ; D ⊢_{P} N⃗_{1} =^{·} N⃗_{2}  By replacement
Γ; D ⊢_{P} q N⃗_{1} ← (N⃗_{1} =^{·} N⃗_{2}) ∧ G_{1} ∧ G_{2}>>q N⃗  By rule (s)

Case π ends in ∨∧, ∨∀: by an immediate appeal to the IH. (←): completely analogous. □ We remark that, using again terminnating programs, the above Lemma covers immediate denial as well.

We now extend the effect of the above compilation on a program: Definition 6.31

(⊤)^{∨_{D}} = ⊤
(⊥)^{∨_{D}} = ⊥
(Q ← G)^{∨_{D}} = Q ← (G)^{∨_{G}}
(D_{1} ∧ D_{2})^{∨_{D}} = (D_{1})^{∨_{D}} ∧ (D_{2})^{∨_{D}}
(∀x:A. D)^{∨_{D}} = ∀x:A. (D)^{∨_{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}}
(∃x:A. G)^{∨_{G}} = ∃x:A. (G)^{∨_{G}}

Theorem 6.32 (Elimination of ∨)

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 >>∨:

Draft of March 25, 2000

Γ; 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.30

(←). Similarly. □

The same remark w.r.t. termination applies.

6.8.3 Constraint Simplification

In this section we hint on how to bring clauses stemming from complementation into their final format by simplifying, whenever possible, the disequation introduced by the Notα → rule. This entails the following:

• Solving existential variable-ground term disequations by computing the complement of the latter.

• Removing unsatisfiable variable-variable disequations.

In a final pass we may also:

• Remove irrelevant occurrences of ⊤.

• Hide the irrelevant augmentation in the final negative clause.

• If so desired and when possible, bring clauses to the ‘core’ languages syntax, as in LF.

Example 6.33 Continuing Example 6.16 and 6.29 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 solved all disequations, which are in this case trivial groundground checks, hidden the irrelevant assumption closed x and renamed ‘¬closed’ into open.

Example 6.34 The final definition of ¬linear and in turn ¬linx is:

¬linapp1 : ¬linear(app E_{1} E_{2}) ← ¬linear(E_{1}).
¬linapp2 : ¬linear(app E_{1} E_{2}) ← ¬linear(E_{2}).
¬linlam1 : ¬linear(lam λx . E x) ← ¬linx(lam λx . E x)
.¬linlam2 : ¬linear(lam λx . E x) ← ∀x:exp. linear(E x).
¬linx1 : ¬linx(λx . app (E_{1} x) (E_{2} x^{1})).
¬linx2 : ¬linx(λx . app (E_{1} x) (E_{2} x^{1})).

6.8. REFINEMENTS  153
¬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 . y) → ¬linx(λx . E x y)).

Draft of March 25, 2000

Bibliography

[AB75] A. Anderson and N.D. Belnap. Entailment. The Logic of Relevance and Necessity, volume 1. Princeton University Press, 1975.

[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, S, 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.

[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.

[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.

[Bela] N. D. Belnap. Life in the undistributed middle. In Substructural Logics.

[Belb] N.D. Belnap. Functions which really depend on their argument.

[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.

[BMPT90a] 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 1990. Springer Verlag Press.

[BMPT90b] 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.

[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.

[Chu41] A. Church. The Calculi of Lambda Conversion. Princeton University Press, 1941.

[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.

[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 higher-order 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.

[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, Seattle, Washington, 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, to appear, 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.

[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.

[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.

[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.

[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.

[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.

[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.

[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.

[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.

[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.

[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 lambdaabstraction, 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 lambdaabstraction, function variables, and simple unification. Journal of Logic and Computation, 1(4):497–536, 1991.

[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 domain-closure 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, Seatle, 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.

[MPRT90] 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.

[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.

[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.

[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.

[PR92] Frank Pfenning and Ekkehard Rohwedder. Implementing the metatheory of deductive systems. In D. Kapur, editor, Proceedings of the 11th International Conference on Automated Deduction, pages 537–551, Saratoga Springs, New York, June 1992. Springer-Verlag LNAI 607.

[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.

[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 L-NCS 1058.

[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.

[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.

[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.

[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).

[WBF] D. A. Wright and C. A. Baker-Finch. Usage analysis with natural reduction types. In Lecture Notes in Computer Science.

[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 TAP-SOFT ’91. Springer-Verlag, New York, NY, 1991. Lecture Notes in Computer Science 494.

[Wri92] D. A. Wright. Reduction types and intensionality in the lambdacalculus. 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.