This action might not be possible to undo. Are you sure you want to continue?

**Building a knowledge base: an example
**

Michael Gelfond

a

and Alfredo Gabaldon

b

a

Department of Computer Science, University of Texas at El Paso, El Paso, TX 79968, USA

E-mail: mgelfond@cs.utep.edu

b

Department of Computer Science, University of Toronto, Toronto, Canada M5S 3G4

E-mail: alfredo@cs.toronto.edu

The main goal of this paper is to illustrate applications of some recent developments

in the theory of logic programming to knowledge representation and reasoning in com-

mon sense domains. We are especially interested in better understanding the process of

development of such representations together with their speciﬁcations. We build on the

previous work of Gelfond and Przymusinska in which the authors suggest that, at least

in some cases, a formal speciﬁcation of the domain can be obtained from speciﬁcations

of its parts by applying certain operators on speciﬁcations called speciﬁcation constructors

and that a better understanding of these operators can substantially facilitate the program-

ming process by providing the programmer with a useful heuristic guidance. We discuss

some of these speciﬁcation constructors and their realization theorems which allow us to

transform speciﬁcations built by applying these constructors to declarative logic programs.

Proofs of two such theorems, previously announced in a paper by Gelfond and Gabaldon,

appear here for the ﬁrst time. The method of specifying knowledge representation problems

via speciﬁcation constructors and of using these speciﬁcations for the development of their

logic programming representations is illustrated by design of a simple, but fairly powerful

program representing simple hierarchical domains.

1. Introduction

“The only effective way to raise the conﬁdence level of a program signiﬁcantly is to

give a proof of its correctness. But one should not ﬁrst make the program and then

prove its correctness, because then the requirement of providing the proof would

only increase the poor programmer’s burden. On the contrary: the programmer

should let correctness proof and program grow hand in hand. ...If one ﬁrst asks

oneself what the structure of a convincing proof would be and, having found this,

then construct a program satisfying this proof ’s requirements, then these correctness

concerns turn out to be a very effective heuristic guidance.”

E. Dijkstra, The Humble Programmer

The main goal of this paper is to illustrate applications of some recent develop-

ments in the theory of logic programming to knowledge representation and reasoning

in common sense domains. The paper is written in the framework of the declarative

logic programming paradigm which strives to reduce a substantial part of the pro-

© J.C. Baltzer AG, Science Publishers

166 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

gramming process to the description of objects comprising the domain of interest and

relations between these objects. After such a description is produced by a program-

mer, it can be queried to establish truth or falsity of statements about the domain or

to ﬁnd objects satisfying various properties. The software development process in

this paradigm starts with a natural language description of the domain which, after

a necessary analysis and elaboration, is described in mathematical terms. The main

purpose of this initial mathematical speciﬁcation is to be understood by the people

involved in the development of the system and to serve as a contract between the

system speciﬁers and implementors. This speciﬁcation is then gradually transformed

by implementors into an executable program satisfying the speciﬁcation. (The process

will of course normally require more than one iteration.) There are many languages

which can be used during various stages of this transformation. This paper adopts the

view from [26] where the authors argue that for a rather broad class of knowledge

representation problems the process of representing knowledge can be divided into

three (mutually dependent) parts:

• Elaboration of a natural language description of the domain can be done in a lan-

guage of functional speciﬁcations – possibly incomplete deﬁnitions of new relations

between objects of the domain of discourse given in terms of the old, known re-

lations.

1

These speciﬁcations can be deﬁned by a speciﬁer directly in a simple

set-theoretic language, or they can be built from previously deﬁned speciﬁcations

with the help of speciﬁcation constructors – simple functions from speciﬁcations

to speciﬁcations. This method is applicable when our knowledge representation

problem can be parameterized with respect to some possible inputs. (A good dis-

cussion on the importance of explicitly specifying input and output of knowledge

representation problems in AI can be found in [30].)

• On the second stage implementors of the system are given the functional speciﬁ-

cation f constructed during the ﬁrst stage of the process. Now they are confronted

with the task of representing f in a logical language with a precisely described

entailment relation. Gelfond and Przymusinska [26] advocate the use of a language

A-Prolog of logic programs with two types of negation and the answer set semantics.

The choice is determined by the ability of A-Prolog to represent default assump-

tions, i.e., statements of the form “Elements of the class A normally (typically, as

a rule) have property P”, epistemic statements “P is unknown”, “P is possible”,

and other types of statements needed for describing common sense domains. Other

important factors are the simplicity of the semantics, strong expressive power of the

language, existence of a mathematical theory providing a basis for proving prop-

erties of programs in A-Prolog, and the availability of query answering systems

which can be used for rapid prototyping.

2

There are other reasons but we will not

1

In precise terms, a functional speciﬁcation consists of two signatures σi and σo and a (possibly partial)

function f which maps sets of ground literals over σi into sets of ground literals over σo.

2

There is a variety of query-answering systems which can be used to compute answers to queries in

A-Prolog. A simple meta-interpreter build on top of Prolog or XSB [10] proved to be sufﬁcient for

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 167

discuss them in this paper. The alternative approach which uses logic programs

with well-founded semantics and its extensions can be found in [1].

At the end of the second stage the implementor will have a logic program π which,

taken in conjunction with a collection X of facts about known relations of f, will

entail exactly those facts about the new relations which belong to f(X). Programs

of this sort are called lp-functions. In [26] the authors suggest that the construction

of π from f can be substantially facilitated by mathematical results relating speci-

ﬁcation constructors to some operations on logic programs. Such results are called

realization theorems. They can provide an implementor with a useful heuristic

guidance and the means to establish correctness of his programs. Several examples

of such theorems and their applications will be given in the following sections.

• At the last stage of the process, the lp-function π representing functional speciﬁca-

tion f will be transferred into an efﬁcient logic program Π computing (or approx-

imating) the entailment relation of π. Unlike π, the construction of Π will depend

signiﬁcantly on the choice of query answering system used by the implementors.

For instance, the use of standard Prolog interpreter may require modiﬁcation of π

which includes the cut operator of Prolog to avoid loops or to improve efﬁciency.

The use of XSB will avoid some of these problems but will require the choice of

predicates to be tabled, etc.

Space limitations preclude us from giving any serious comparison of our ap-

proach with other methodologies of representing knowledge. Moreover, we believe

that such a comparison can only be done when all of these methodologies are more

fully developed. Still a short remark is in order. At the moment, the speciﬁcation

language most frequently used for the ﬁrst formal reﬁnement of a problem is probably

the language of ﬁrst-order logic (FOL). As others before us we conjecture that FOL

is not fully adequate for our purpose. Its expressive power is insufﬁcient to deﬁne

even fairly simple f-speciﬁcations such as transitive closure of database relations. It

also does not seem to be the best language for representing defaults, epistemic state-

ments, and other types of “common sense” knowledge. These observations are well

known and led to various extensions of FOL which allow nonmonotonic reasoning.

Our preference for a less powerful A-Prolog is similar to our preference of Modula 2

over ADA. Since, as was shown in [7,22], programs of A-Prolog can be viewed as

theories of Reiter’s default logic [40], we hope that those who prefer power over

simplicity can still beneﬁt from this work. The next question to answer is “Why not

to use the language of logic programming during the ﬁrst stage of the development

process?” What are the advantages of ﬁrst formulating the problem in terms of func-

the purposes of this paper. Description of such a meta-interpreter build on top of SLDNF of Prolog

can be found in section 4. For more complicated programs, especially for those which have multiple

stable models, this interpreter will go into a loop or answer unknown to too many interesting queries.

Roughly speaking this happens because Prolog and XSB do not allow reasoning by cases. This type

of reasoning is incorporated in a more powerful system, called SLG [9], which was successfully used

to answer queries in the presence of multiple stable models. A different type of engine, [11,17,36],

are based on algorithms for computing stable models of programs without function symbols.

168 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

tional speciﬁcations? There are two reasons why we do that. The ﬁrst advantage

of the language of f-speciﬁcations over A-Prolog is its simplicity. The construction

of f requires knowledge of a simple set-theoretic notation together with deﬁnitions

of a (hopefully small) collection of speciﬁcation constructors. The speciﬁer involved

at the ﬁrst stage of the process does not need to know anything about the semantics

of A-Prolog. Another possible advantage of translating a natural language description

of a problem into an f-speciﬁcation f is the ability to use the structure of f and the

corresponding realization theorems for reducing the construction of π

f

to the construc-

tion of simpler programs. One of the main goals of this paper is to demonstrate, by

way of example, how this can be achieved. Finally, we want to mention that in this

paper we are mainly interested in the ﬁrst two stages of the development process. In

this sense our approach is complementary to the work on program development in

Prolog (see, for instance, [14]). (See, however, proposition 13.)

The paper is organized as follows. In the next two sections we review the

answer set semantics of logic programs and the notions of f-speciﬁcation and lp-

function. In the next section we give a ﬁrst example of applying our methodology to

solving a knowledge representation problem associated with a simple type of taxonomic

hierarchy. (This and other problems related to inheritance reasoning are commonly

used to test strengths and weaknesses of various nonmonotonic formalisms.) We start

with specifying the problem in terms of functional speciﬁcations, representing it by a

declarative logic program, and showing that this program can be correctly executed

by the Prolog interpreter. In the process we introduce a speciﬁcation constructor,

called incremental extension, and give a realization theorem for it. The knowledge

representation problem discussed in this section assumes completeness of knowledge.

In the next section we consider the situation when this assumption is relaxed and our

knowledge of some relations from the domain of the problem becomes incomplete.

The new speciﬁcation is obtained from the original one by applying a speciﬁcation

constructor called input opening. We discuss the deﬁnition of this constructor, its

decomposition into two simpler constructors, interpolation and domain completion, and

the corresponding realization theorems. (These theorems were stated in [20] without

proofs, and hence their proofs are included in this paper.) Finally, in the last section,

we discuss one more knowledge representation problem deﬁned in terms of another

speciﬁcation constructor, called input extension. Somewhat surprisingly, the resulting

class of programs formalizes inheritance reasoning with incomplete information which

was not previously considered.

2. Logic programs

In this section we give a brief introduction to the answer set semantics for logic

programs with two kinds of negation [23].

3

For a more detailed discussion see [5,31].

3

For programs without classical negation the answer set semantics coincides with the stable model

semantics of [21].

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 169

The language of a logic program, like a typed ﬁrst-order language, is de-

termined by its signature σ, consisting of types (types(σ)), object constants for

each type τ (obj(τ, σ)), and typed function and predicate constants (func(σ) and

pred(σ), respectively). Signature σ

1

is a sub-signature of signature σ

2

if types(σ

1

) ⊆

types(σ

2

), func(σ

1

) ⊆ func(σ

2

), pred(σ

1

) ⊆ pred(σ

2

), and for each type τ which

belongs to both signatures, obj(τ, σ

1

) = obj(τ, σ

2

); σ = σ

1

∪ σ

2

if elements of σ

are unions of the corresponding elements of σ

1

and σ

2

. Terms are built as in the

corresponding typed ﬁrst-order language; positive literals (or atoms) have the form

p(t

1

, . . . , t

n

), where t’s are terms of proper types and p is a predicate symbol of ar-

ity n; negative literals are of the form ¬p(t

1

, . . . , t

n

). (Logical connective ¬ in the

context of logic programming is called “classical”, or “explicit”, or “strong” nega-

tion.) Literals of the form p(t

1

, . . . , t

n

) and ¬p(t

1

, . . . , t

n

) are called contrary. By l

we denote a literal contrary to l. Literals and terms not containing variables are called

ground. The sets of all ground terms, atoms and literals over σ will be denoted by

terms(σ), atoms(σ) and lit(σ), respectively. For a set P of predicate symbols from σ,

atoms(P, σ) (lit(P, σ)) will denote the sets of ground atoms (literals) of σ formed with

predicate symbols from P. Consistent sets of ground literals over signature σ are

called states of σ and denoted by states(σ).

A rule is an expression of the form

l

0

← l

1

, . . . , l

m

, not l

m+1

, . . . , not l

n

, (1)

where n 0, l

i

’s are literals and not is a logical connective called negation as

failure [12,39].

A pair {σ, π} where σ is a signature and π is a collection of rules over σ is

called a logic program. (We often denote such pairs by their second element π. The

corresponding signature will be denoted by σ(π).)

If r is a rule of type (1) then head(r) = {l

0

}, pos(r) = {l

1

, . . . , l

m

}, neg(r) =

{l

m+1

, . . . , l

n

}. For any program π, head(π) =

r∈π

head(r). Similarly, for pos and

neg. Sometimes, not l

i

, . . . , not l

i+k

will be denoted by not({l

i

, . . . , l

i+k

}).

Unless otherwise stated, we assume that l’s in rule (1) are ground. Rules with

variables will be used as a shorthand for the sets of their ground instantiations. Vari-

ables will be denoted by capital letters.

The answer set semantics of a logic program π assigns to π a collection of answer

sets – sets of ground literals over signature σ(π) of π corresponding to beliefs which

can be built by a rational reasoner on the basis of rules of π. Under this semantics the

rule (1) can be viewed as a constraint on such beliefs and is read as “if literals l

1

, . . . , l

m

are believed to be true and there is no reason to believe that literals l

m+1

, . . . , l

n

are

true then the reasoner must believe l

0

”. We say that literal l ∈ lit(σ(π)) is true in an

answer set S of π if l ∈ S; l is false in S if l ∈ S; π entails l (π |= l) if l is true in

all answer sets of π. We say that π’s answer to a query l ∈ lit(σ(π)) is yes if π |= l,

no if π |= l, and unknown otherwise.

To give a deﬁnition of answer sets of logic programs, let us ﬁrst consider programs

without negation as failure.

170 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

• The answer set of a program π not containing negation as failure not is the smallest

(in the sense of set-theoretic inclusion) subset S of lit(σ(π)) such that

(i) for any rule l

0

← l

1

, . . . , l

m

from π, if l

1

, . . . , l

m

∈ S, then l

0

∈ S,

(ii) if S contains a pair of contrary literals, then S = lit(σ(π)).

It can easily be shown that every program π that does not contain negation as failure

has a unique answer set, which will be denoted by ans(π).

• Now let π be an arbitrary logic program without variables. For any set S of literals,

let π

S

be the logic program obtained from π by deleting

(i) each rule that has an occurrence of not l in its body with l ∈ S, and

(ii) all occurrences of not l in the bodies of the remaining rules.

Clearly, π

S

does not contain not, and hence its answer set is already deﬁned. If this

answer set coincides with S, then we say that S is an answer set of π. In other words,

the answer sets of π are characterized by the equation

S = ans

_

π

S

_

. (2)

A logic program is said to be consistent if it has a consistent answer set.

4

It is not

difﬁcult to show that any answer set of a consistent program is consistent.

We conclude our short introduction by presenting a theorem useful for computing

the set of consequences of logic programs. This process can be sometimes simpliﬁed

by “splitting” the program into parts. We say that a set U of literals splits a program

π if, for every rule r of π, pos(r) ∪ neg(r) ⊆ U whenever head(r) ∈ U. If U splits π

then the set of rules in π whose heads belong to U will be called the base of π (relative

to U). We denote the base of π by base(π, U). The rest of the program (called the

top of π) will be denoted by top(π, U). Whenever possible the reference to U will be

omitted.

Consider for instance a program π

1

consisting of the rules

q(a) ← not q(b), q(b) ← not q(a), r(a) ← q(a), r(a) ← q(b).

Then U = {q(a), q(b)} is a splitting set of π

1

, base(π

1

, U) consists of the ﬁrst two

rules while top(π

1

, U) consists of the last two.

Let U be a splitting set of a program π. For any set V ⊆ U, by red(π, V ) we

denote the program obtained from top(π, U) by

(1) deleting each rule r such that pos(r) ∩ (U \ V ) = ∅ or neg(r) ∩ V = ∅,

(2) replacing the body of each remaining rule r by pos(r) \ U ∪ not(neg(r) \ U).

Theorem 1 (Splitting set theorem, [32]). Let U be a splitting set of a program π.

A consistent set of literals is an answer set of π iff it can be represented in the form

S

1

∪S

2

, where S

1

is an answer set of base(π, U) and S

2

is an answer set of red(π, S

1

).

4

A set of literals is consistent if it does not contain contrary literals.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 171

The theorem suggests the following approach to computing consistent answer sets of a

program π which is split by some set U. First ﬁnd all the answer sets of the program

base(π, U). For each such set S

1

, compute the program red(π, S

1

), and ﬁnd all its

answer sets. For each such set S

2

form a union S

1

∪S

2

. The consistent unions found

in this way are the consistent answer sets of π. Consider, for instance, program π

1

above. Then the program

q(a) ← not q(b), q(b) ← not q(a)

is the base of π

1

with respect to U. It has answer sets S

1

= {q(a)} and S

2

= {q(b)}.

The corresponding reducts are

red(π

1

, S

1

) = red(π

1

, S

2

) = r(a) ←

and, by the splitting set theorem, the answer sets of π

1

are {q(a), r(a)} and {q(b), r(a)}.

In the context of logic programming, the splitting set theorem and its generalizations

ﬁrst appeared in [32]. Similar results for autoepistemic logic can be found in [25].

3. F-speciﬁcations and lp-functions

In some cases a knowledge representation problem consists in representing a

(possibly partial) deﬁnition of new relations between objects of the problem domain

which is given in terms of previously known relations between these objects. Such a

deﬁnition can be mathematically described as a function f which maps states of an

input signature σ

i

into the states of an output signature σ

o

. The states of σ

i

are called

input states. They contain all the currently available information about the old, given

relations. Similarly, the states of σ

o

are called output states; f(X) contains all we

may know about deﬁned relations given an input state X. We follow [25] and call a

triple consisting of such a function f together with input and output signatures σ

i

(f)

and σ

o

(f) a functional speciﬁcation; dom(f) will denote the domain of f.

5

The following example shows how a simple knowledge representation problem

can be reﬁned in terms of f-speciﬁcations.

Example 2. Consider the following informal speciﬁcation of a knowledge representa-

tion problem:

• Formalize the assertion “x has a PhD iff x is a faculty”. Given a complete list

of faculty your formalization should entail all the available information about PhD

degrees of people from this list. Use unary predicate constants faculty and phd.

5

This view is common in databases where one of the most important knowledge representation problems

consists in deﬁning new relations (views) in terms of basic relations stored in the database tables.

Unlike our case however databases normally assume the close world assumption and hence only need

to represent positive information. As a result, views can be viewed as functions from sets of atoms

to sets of atoms.

172 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

Despite its simplicity, the above speciﬁcation is slightly ambiguous. Its possible

reﬁnements may depend on the form of representation of a “complete list of faculty”.

We look at two different representations of this list deﬁned by two f-speciﬁcations f

0

and g

0

. The speciﬁcations have the same signatures:

• input signature σ

i

consisting of individual names, say, mike, john and mary and a

unary relation symbol faculty;

• output signature σ

o

consisting of the same individual names and a unary predicate

symbol phd.

Function f

0

is deﬁned on complete states of σ

i

.

6

Obviously, for any X ∈ dom(f

0

)

f

0

(X) =

_

phd(c): faculty(c) ∈ X

_

∪

_

¬phd(c): ¬faculty(c) ∈ X

_

.

Similarly, function g

0

is deﬁned on sets of ground atoms of σ

i

:

g

0

(X) =

_

phd(c): faculty(c) ∈ X

_

∪

_

¬phd(c): faculty(c) / ∈ X

_

.

Making an early distinction between these two speciﬁcations of our informal

problem helps to eliminate possible difﬁculties which may appear later in the devel-

opment process.

Example 3. Now let us look at a slightly different informal speciﬁcation. Assume

that the language of our domain is determined, as in example 2, by signatures σ

i

and σ

o

but, unlike that example, the available information about faculty can be in-

complete. For instance, we may know that Mike is a faculty, John is not, but have

no relevant information about Mary. This can be represented by an incomplete set

of literals {faculty(mike), ¬faculty(john)}. In general, the input of the corresponding

f-speciﬁcation

˜

f

0

consists of (possibly incomplete) states of σ

i

and

˜

f

0

can be deﬁned

as follows:

˜

f

0

(X) =

´ X∈c(X)

f

0

_

´

X

_

where c(X) is the set of all complete supersets of X from dom(f

0

). Notice that the

new speciﬁcation is deﬁned in terms of f

0

and can be viewed as an interpolation of

function f

0

from complete to all input states (see section 5 for more details). It is

easy to see that

˜

f

0

computes all possible information about PhD degrees which can be

obtained from X and f

0

.

To further reﬁne the above f-speciﬁcations we will use the notion of lp-function

from [6].

Deﬁnition 4. A four-tuple π = {π, σ

i

(π), σ

o

(π), dom(π)} where

(1) π is a logic program (with some signature σ(π)),

6

A set X of literals over signature σ is called complete if for any l ∈ lit(σ), l ∈ X or l ∈ X.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 173

(2) σ

i

(π), σ

o

(π) are sub-signatures of σ(π) called input and output signatures of π,

respectively,

(3) dom(π) ⊆ states(σ

i

(π))

is called lp-function if for any X ∈ dom(π) program π ∪ X is consistent, i.e., has a

consistent answer set.

For any X ∈ dom(π),

π(X)

def

=

_

l: l ∈ lit

_

σ

o

(π)

_

, π ∪ X |= l

_

.

We say that an lp-function π represents an f-speciﬁcation f if π and f have the same

input and output signatures and domain and for any X ∈ dom(f), f(X) = π(X).

Let E be an inference engine which takes as an input a logic program π and a

ground literal l. We will say that an lp-function π is computable by E if for any query

l ∈ lit(σ

o

) and any X ∈ dom(π), E(π ∪ X, l) returns yes if l ∈ π(X), no if l ∈ π(X),

and unknown otherwise.

Example 5. It is easy to show that f-speciﬁcation f

0

from example 2 can be repre-

sented by lp-function π

f

0

with signature σ consisting of types, objects, and predicate

symbols of σ

i

(f

0

) and predicate symbol phd and the rules:

phd(P) ←faculty(P),

¬phd(P) ←¬faculty(P).

_

π

f

0

The input and output signatures of π

f

0

are the same as those of f

0

and dom(π

f

0

) =

dom(f

0

). An alternative representation π

(f

0

) can also be given by replacing the rules

of π

f

0

by the rules

phd(P) ←faculty(P),

¬phd(P) ←not faculty(P).

_

π

f

0

It is also easy to see that the restriction π

g

0

of π

f

0

on the dom(g

0

) is an lp-function

representing g

0

.

Now let us consider f-speciﬁcation

˜

f

0

from example 3. One can show that the

lp-function π

˜

f

0

whose rules are those of π

f

0

and signatures and domain are those of

˜

f

0

, represents

˜

f

0

. This means that π

f

0

is elaboration tolerant with respect to allowing

new, incomplete inputs, i.e., the change of speciﬁcation from f

0

to

˜

f

0

does not require

any changes in π

f

0

. This is certainly not the case for the second representation of f

0

.

In this sense, π

f

0

is superior to π

f

0

.

Since all the lp-functions above are (efﬁciently) computable by a slight modiﬁ-

cation of the Prolog interpreter the reﬁnement process stops here.

7

7

Of course, by considering only ground queries we limit ourselves to a very restricted notion of

computability of lp-function f by inference engine E. It can of course be extended to allow queries

from σo(f) with variables but then the function πg

0

will stop being computable due to ﬂoundering.

This again can be remedied by introducing types like person, degree, etc., and modifying our program

174 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

To complete this section we give several deﬁnitions and results which proved to

be useful for reasoning about lp-functions.

An lp-function π is called monotonic if for any X, Y from dom(π) such that

X ⊆ Y , π(X) ⊆ π(Y ).

The absolute value of a literal l (symbolically, |l|) is l if l is positive, and l

otherwise.

Deﬁnition 6. Let π be a logic program with signature σ. A signing of π is a set

S ⊆ atoms(σ) such that

(1) for any rule (1) from π, either |l

0

|, . . . , |l

m

| ∈ S, |l

m+1

|, . . . , |l

n

| / ∈ S or

|l

0

|, . . . , |l

m

| / ∈ S, |l

m+1

|, . . . , |l

n

| ∈ S,

(2) for any atom l ∈ S, ¬l does not appear in π.

If a program has a signing, we say that it is signed [29,44]. The notion of signing

for ﬁnite logic programs without classical negation was introduced by Kunen [29], who

used it as a tool in his proof that, for a certain class of programs, two different semantics

of logic programs coincide. Turner in [44] extends the deﬁnition to the class of logic

programs with two kinds of negation. Obviously, programs without negation as failure

are signed with an empty signing.

Signed programs enjoy several important properties which make them attractive

from the standpoint of knowledge representation. In particular:

1. Signed programs without explicit negation are consistent. This is a special case

of a more general theorem by Fages [19].

2. If π is signed and consistent then the set of consequences of the program under

the answer set semantics coincides with its set of consequences under the well-

founded semantics [37,46]. Notice this result shows that interpreters, such as XSB,

which compute the well founded semantics of logic programs, can also be used

to compute the consequences of such programs under the answer set semantics.

We will however be especially interested in the following monotonicity theorem.

Theorem 7 (Monotonicity theorem, Turner). If an lp-function π has a signing S such

that S ∩ (lit(σ

i

) ∪ lit(σ

o

)) = ∅ then π is monotonic.

This result is a special case of a substantially more general result from [45].

Example 8. Consider an lp-function π

2

with input signature σ

i

= {{a, b, c}, {p, r}},

output signature σ

o

= {{a, b, c}, {q}}, dom(π

2

) = states(σ

i

) and logic program π

2

consisting of the following rules:

q(X) ←p(X), not ab(X),

¬q(X) ←r(X),

ab(X) ←not ¬r(X).

_

¸

_

¸

_

π

2

accordingly or by using a query answering system with constructive negation [8,38]. For the sake of

readability we will only consider ground queries.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 175

It is easy to see that lp-function π

2

has a signing consisting of atoms formed by pred-

icate ab. The signing satisﬁes the condition of theorem 7, and hence π

2

is monotonic.

It is worth noticing that π

2

considered as a logic program is nonmonotonic. The ad-

dition of extra rules (or facts) about ab can force us to withdraw previous conclusions

about q. Monotonicity is however preserved for inputs from σ

i

.

4. An example: is-nets on closed domains

In this section, we illustrate the notions of functional speciﬁcation and lp-function

by using them to solve a knowledge representation problem associated with a simple

type of taxonomic hierarchy, called is-nets. The problem of specifying and representing

is-nets is commonly used to test strengths and weaknesses of various nonmonotonic

formalisms. Logic programming approaches to this problem (which assume complete-

ness of its domain) can be found in [1,33]. Modiﬁcations of this example will be used

throughout the rest of the paper.

An is-net N can be viewed as a combination of graphs N

s

and N

d

where N

s

describes the (proper) subclass relation between classes and N

d

consists of positive

and negative defeasible links connecting classes with properties. The latter represent

defaults: “elements of class c normally satisfy (do not satisfy) property p”. As usual

we assume that N

s

is acyclic and that a class c and a property p can be connected by

at most one link. We use (possibly indexed) letters o, c, p, and d to denote objects,

classes, properties and defaults respectively. Figure 1(a) gives a pictorial representation

of a net. Here c

1

, . . . , c

5

are classes and p is a property. Links from c

5

to p and from

c

4

to p represent positive and negative defaults while the other links represent the

subclass relationship.

There are many knowledge representation problems which can be associated with

a net N. We start with the simplest one, when N is viewed as an informal speciﬁcation

of a function f

N

which takes as an input the links of N together with a collection I of

positive links from objects to classes (see ﬁgure 1(b)). We denote the resulting graph

Figure 1. A simple taxonomic hierarchy.

176 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

by N(I) and assume that for any object o and class c from N(I), o is an element

of c iff N(I) contains a path from o to c. Similarly, c

1

is a (proper) subclass of c

2

iff there is a path from c

1

to c

2

. Given N(I), the function f

N

computes all possible

conclusions about relations subclass, is and has which a rational agent can obtain from

this net.

8

Our ability to represent an input of f

N

by positive links only is justiﬁed by

our assumption that, at least with respect to objects included in N(I), the net N(I)

contains complete information about relations is and subclass. Accordingly, we call

f

N

a closed domain speciﬁcation of N.

In what follows we will be interested in applying our methodology for providing

a rigorous speciﬁcation of this function and for ﬁnding its logic programming repre-

sentation. Later we consider more complex knowledge representation problems which

can also be associated with N.

4.1. Specifying the problem

We start by playing the role of a speciﬁer and give a precise deﬁnition of function

f

N

using the language of f-speciﬁcations. To this goal, we ﬁrst ﬁx three collections

of object constants for objects, classes and properties of the nets. The corresponding

types will be denoted by τ

o

, τ

c

, and τ

p

. Constants of the fourth type (τ

d

) will be used

to name the nets default links. Next we identify graphs N

s

and N

d

with the collection

of literals of the form subclass

0

(c

1

, c

2

), default(d, c, p, +), and default(d, c, p, −) which

correspond to the links of these graphs. (The last parameter in default is used to

distinguish positive and negative links.) A set I of links from objects to classes will

be identiﬁed with the collection of the corresponding statements of the form is

0

(o, c).

Function f

N

will be constructed as a combination of three simpler functions f

s

, f

i

and

f

d

:

(a) An f-speciﬁcation f

s

will take as an input a net N

s

– a collection of atoms

subclass

0

(c

i

, c

j

) where c

i

, c

j

are classes connected by a link of N

s

and return

the complete set of literals, formed by the predicate symbol subclass, deﬁning

the transitive closure of the input; both, input and output signatures of f

s

have

the same object constants of the type τ

c

, and predicate symbols subclass

0

and

subclass, respectively.

(b) An f-speciﬁcation f

i

takes as an input a complete set of subclass-literals (repre-

senting transitive and asymmetric relations subclass) together with the set I of

atoms is

0

(o, c) representing links from objects to classes; f

i

returns the complete

set of is-literals representing the membership relation deﬁned by the input. In-

put and output signatures of f

i

have object constants of two types, τ

o

and τ

c

;

pred(σ

i

(f

i

)) = {is

0

, subclass} while pred(σ

o

(f

i

)) = {is}.

(c) We also need a more complex f-speciﬁcation f

d

deﬁned as follows:

8

is(o, c) stands for “object o is an element of class c”; has(o, p) means that “object o has property p”.

Both predicates are typed.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 177

• The input signature σ

i

(f

d

) of f

d

consists of object constants of three types, τ

o

, τ

c

,

and τ

d

and predicate symbols is, subclass, and default. The output signature

σ

o

(f

d

) consists of object constants of the types τ

o

and τ

p

and predicate symbol

has.

• dom(f

d

) consists of states of σ

i

(f

d

) which are complete with respect to is and

subclass and satisfy the constraints:

9

←is(o, c

1

),

subclass(c

1

, c

2

),

¬is(o, c

2

).

←subclass(c, c).

←default(d, c, p, +),

default(d, c, p, −).

• For any X ∈ dom(f

d

), has(o, p) ∈ f

d

(X) iff there are d

1

and c

1

such that

(i) default(d

1

, c

1

, p, +) ∈ X,

(ii) is(o, c

1

) ∈ X,

(iii) for any default(d

2

, c

2

, p, −) ∈ X,

¬is(o, c

2

) ∈ X or subclass(c

1

, c

2

) ∈ X.

This condition corresponds to the Inheritance Principle [43] which says that

more speciﬁc defaults override less speciﬁc ones.

Similarly for ¬has(o, p).

(d) To complete the construction of f

N

we will need the following notation: for any

α ⊆ pred(σ) and X ⊂ lit(σ) by [X]

α

we denote the set of literals from X formed

by predicate symbols from α.

Now the f-speciﬁcation f

N

will be deﬁned as follows:

• the input signature of f

N

consists of object constants of the types τ

o

, τ

c

, τ

d

and

predicate symbols is

0

, subclass

0

, default;

• the output signature of f

N

consists of objects constants of the types τ

o

, τ

c

, τ

p

and predicate symbols subclass, is, has;

• dom(f

N

) = {X: X ⊆ atoms(σ

i

(f

N

))};

10

9

A constraint is a rule of the form ← ∆ where ∆ is a list of literals from some signature σ. A set

X ∈ states(σ) satisﬁes the constraint ← ∆ if ∆ ⊆ X. X satisﬁes a collection C of constraints if it

satisﬁes every constraint in C.

10

The domain of fN can be alternatively represented by complete sets of literals of σi(fN). The resulting

speciﬁcation will be isomorphic to fN and used when convenient.

178 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

• f

N

is deﬁned by combining functions f

s

, f

i

and f

d

as follows:

Y

0

(X) =f

s

_

[X]

subclass

0

_

,

Y

1

(X) =f

i

_

Y

0

(X) ∪ [X]

is

0

_

,

Y

2

(X) =f

d

_

Y

0

(X) ∪ Y

1

(X) ∪ [X]

default

_

,

f

N

(X) =Y

0

(X) ∪ Y

1

(X) ∪ Y

2

(X).

Note that this deﬁnition does not require any sophisticated mathematics. In particular,

it presupposes no knowledge of logic programming.

It is worth noticing that we can view f

N

as being constructed from f-speciﬁcations

f

d

, f

s

and f

i

by a speciﬁcation constructor called incremental extension [26]. Since

this fact will be useful later in our search for an lp-function representing f

N

we recall

the corresponding deﬁnition.

11

For simplicity we only consider signatures which agree

on their common types, i.e., if τ ∈ σ

1

∩ σ

2

then obj(τ, σ

1

) = obj(τ, σ

2

).

Deﬁnition 9. The f-speciﬁcation f ◦ g is called the incremental extension of g by f if

it satisﬁes the following conditions:

(1) σ

i

(f ◦ g) = σ

i

(g) ∪ σ

i

(f),

(2) σ

o

(f ◦ g) = σ

o

(g) ∪ σ

o

(f),

(3) X ∈ dom(f ◦ g) if

[X]

pred(σi(g))

∈ dom(g) and [X]

pred(σi (f))\pred(σo(g))

∪ g([X]

pred(σi(g))

) ∈ dom(f),

(4) f ◦ g(X) = f([X]

pred(σi (f))\pred(σo(g))

∪ g([X]

pred(σi(g))

)) ∪ g([X]

pred(σi(g))

).

It is easy to see that the deﬁnition of f

N

above can be rewritten as

f

N

= f

d

◦ (f

i

◦ f

s

). (3)

4.2. Building the declarative representation

Now let us assume the role of an implementor, who just received the above

deﬁnition of f

N

and is confronted with the task of building a computable lp-function

representing f

N

. (Recall that we will only be interested in getting answers to ground

queries formed by predicates subclass, is, and has.) According to our methodology,

we will ﬁrst ignore the computability requirement and concentrate on correctness of

our representation viewed as a declarative logic program.

11

The deﬁnition we give in this paper actually extends that in [26].

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 179

We start with a representation for f

s

. Since N

s

is acyclic, it is easy to show that

f

s

can be represented by the program π

s

:

subclass(C

1

, C

2

) ←subclass

0

(C

1

, C

2

).

subclass(C

1

, C

2

) ←subclass

0

(C

1

, C

3

),

subclass(C

3

, C

2

).

¬subclass(C

1

, C

2

) ←not subclass(C

1

, C

2

).

_

¸

¸

¸

_

¸

¸

¸

_

π

s

It is equally easy to show that f

i

can be represented by an lp-function

is(O, C) ←is

0

(O, C).

is(O, C

2

) ←is

0

(O, C

1

),

subclass(C

1

, C

2

).

¬is(O, C) ←not is(O, C).

_

¸

¸

¸

_

¸

¸

¸

_

π

i

In our next step we need to ﬁnd a representation π

fi◦fs

of the speciﬁcation f

i

◦ f

s

.

For simple lp-functions like π

i

and π

s

we can directly check that this can be done by

combining the rules of π

i

and π

s

. As was shown in [25], however, this is not always

the case, i.e., there are f-speciﬁcations f, g represented by lp-functions π

f

and π

g

such

that π

f

∪ π

g

does not represent f ◦ g. The following realization theorem (which is

a slight modiﬁcation of a similar theorem from [25]) is useful for eliminating this

possibility.

Theorem 10 (Realization theorem for incremental extension). Let f and g be

f-speciﬁcations represented by lp-functions π

f

and π

g

, respectively, and let π

f◦g

=

π

f

∪ π

g

.

12

A 4-tuple π

f◦g

= {π

f◦g

, σ

i

(f ◦ g), σ

o

(f ◦ g), dom(f ◦ g)} is an lp-function

representing f ◦ g if π

f

and π

g

satisfy the following conditions:

(1) for any X ∈ dom(π

g

) and any answer sets A

1

and A

2

of π

g

∪ X,

A

1

∩ lit(σ

o

(π

g

)) = A

2

∩ lit(σ

o

(π

g

)),

(2) lit(σ(π

f

)) ∩ lit(σ(π

g

)) ⊆ lit(σ

o

(π

g

)),

(3) head(π

f

) ∩ lit(σ(π

g

)) = ∅.

It is easy to see that functions π

i

and π

s

deﬁned above satisfy the conditions of

the theorem, which justiﬁes our construction.

12

Recall that π = π1 ∪ π2 if σ(π) = σ(π1) ∪ σ(π2) and the rules of π

f◦g

consist of rules of π

f

and πg.

Note that this deﬁnition is applicable to programs with and without variables.

180 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

To continue our search for an lp-function representing the speciﬁcation f

N

we need to

ﬁnd a representation of f

d

. To this goal let us consider a program π

d

:

has(X, P) ←default(D, C, P, +),

is(X, C),

not exceptional(X, D, +).

¬has(X, P) ←default(D, C, P, −),

is(X, C),

not exceptional(X, D, −).

exception(E, D

1

, +) ←default(D

1

, C, P, +),

default(D

2

, E, P, −),

not subclass(C, E).

exception(E, D

1

, −) ←default(D

1

, C, P, −),

default(D

2

, E, P, +),

not subclass(C, E).

exceptional(X, D, S) ←exception(E, D, S),

is(X, E).

_

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

_

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

_

π

d

The signature of this program is obtained from σ

f

d

by adding predicate constants

exception and exceptional. The statement exception(e, d, +) reads as “the positive de-

fault d is not applicable to elements of the class e”; the statement exceptional(o, d, +)

states that “the positive default d is not applicable to the object o of the domain”;

similarly for negative defaults. The program uses a standard logic programming repre-

sentation of defaults and their exceptions (see, for instance, [5]). We would like π

d

to

be viewed as an lp-function whose input and output signatures are the same as those

of f

d

and whose domain is dom(f

d

), i.e., we need the following:

Proposition 11. For any X ∈ dom(f

d

), program π

d

∪ X is consistent.

Proof (sketch). A program π

d

∪X can be viewed as a logic program Π without classi-

cal negation in a language which contains new predicate symbols ¬is, ¬subclass, ¬has.

This program is stratiﬁed [2] and has therefore a unique answer set A [21]. As shown

in [22], A is also the unique answer set of π

d

∪ X iff A does not contain contrary

literals. Since literal l belongs to an answer set A of a program Π (not containing

classical negation) iff there is a rule in Π whose head is l and whose body is sat-

isﬁed by A [34], we need to show that there are no rules r

1

and r

2

with the heads

has(o, p), ¬has(o, p) whose bodies are satisﬁed by A. Suppose that there are c

1

and

c

2

such that default(d

1

, c

1

, p, +) ∈ A, default(d

2

, c

2

, p, −) ∈ A, is(x, c

1

) ∈ A and

is(x, c

2

) ∈ A. Since a class c and property p can be connected by at most one link,

c

1

= c

2

. Since the net N

s

is acyclic, subclass(c

1

, c

2

) / ∈ A or subclass(c

2

, c

1

) / ∈ A.

Therefore, exceptional(x, d

1

, +) or exceptional(x, d

2

, −) is also in A, i.e., at least one

of the rules r

1

, r

2

has a body which is not satisﬁed by A.

Now we can show correctness of our construction.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 181

Proposition 12. Lp-function π

d

represents f

d

, i.e., for any X ∈ dom(f

d

), π

d

(X) =

f

d

(X).

Proof (sketch). In the previous proof we showed that π

d

∪X has a unique consistent

answer set. Let us denote it by A.

Since a literal l belongs to a consistent answer set A of the program iff there is

a rule with l in the head whose body is satisﬁed by A, we have that has(o, c

1

) ∈ A iff

there are literals default(d

1

, c

1

, p, +), is(o, c

1

) ∈ A and exceptional(o, d

1

, +) / ∈ A. This

happens iff default(d

1

, c

1

, p, +) ∈ N

d

, is(o, c

1

) ∈ X and for any default(d

2

, c

2

, p, −) ∈

N

d

, is(o, c

2

) / ∈ X or subclass(c

1

, c

2

) ∈ N

s

. Since X is complete, is(o, c

2

) / ∈ X iff

¬is(o, c

2

) ∈ X and therefore, has(o, p) ∈ π

d

(X) iff has(o, p) ∈ f(X). A similar

argument works for negative literals.

To complete our search for a representation of f

N

we use the construction from

theorem 10. It is easy to see that programs π

fi◦fs

and π

d

satisfy the conditions of the

theorem and hence π

f

N

= {π

f

N

, σ

i

(f

N

), σ

o

(f

N

), dom(f

N

)} where

π

f

N

= π

s

∪ π

i

∪ π

d

(4)

represents f

N

.

4.3. Answering queries

Now we are ready for the implementation stage of our design. This stage crucially

depends on the choice of inference engine we use to answer queries to π

f

N

. Since

Prolog is the most popular logic programming language to date, we base this engine

on the Prolog interpreter. To do that we must ﬁrst replace all occurrences of negative

literals ¬p(t

1

, . . . , t

n

) in π

f

N

by np(t

1

, . . . , t

n

). The resulting program can be viewed

as a Prolog program with variables. We consider an inference engine A deﬁned as a

simple meta-interpreter which takes a query q and a program π as an input. If q is an

atom, A makes two calls to the Prolog interpreter; one with parameters q and π and

another with parameters nq, π. If the ﬁrst query is answered yes, the meta-interpreter

A returns yes; if yes is the answer to the second query, A returns no; otherwise the

answer is unknown. Similarly, if q is a negative literal. The meta-interpreter is deﬁned

for programs which do not entail q and ¬q (for any query q).

Proposition 13. The lp-function π

f

N

is computable by A.

Proof (sketch). Let us start by listing the questions which need to be addressed to

prove this proposition. First, it is well known that, for some programs, the Prolog

interpreter may produce unsound results. This may happen because of the absence

of the occur-check which, in some cases, is necessary for soundness of the SLDNF

resolution, or because the interpreter may ﬂounder, i.e., may select for resolution a goal

of the form not q where q contains an uninstantiated variable. Second, the interpreter

182 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

may fail to terminate. Even if we show that for any X ∈ dom(f

N

) and ground query q,

the interpreter which takes π

f

N

∪ X and q as an input terminates, does not ﬂounder,

and does not require the occur-check, the soundness of our result is guaranteed only

with respect to the unsorted grounding of π

f

N

, i.e., the grounding of π

f

N

by terms of

signature σ

u

obtained from signature σ(f

N

) by removing types and type information.

In what follows we brieﬂy discuss how these questions can be addressed.

(a) We show that for any X ∈ dom(π

f

N

) and query q ∈ lit(σ

o

(f

N

)) the program

π

f

N

∪ X ∪ {← q} is occur-check free, i.e., the uniﬁcation algorithm used by

Prolog interpreters never selects a step requiring the occur-check. To prove this

we need a notion of mode [13] – a function assigning + or − to each parameter

of a predicate symbol p from the language of program π. If the parameter in a

position i of p is assigned +, then i is called an input position. Otherwise it is

called an output position. In our further discussion we need the following mode

m

0

of the program π

f

N

:

has(+, +)

¬has(+, +)

default(−, −, −, −)

is

0

(−, −)

is(+, +)

¬is(+, +)

subclass

0

(−, −)

subclass(+, +)

¬subclass(+, +)

exceptional(+, +, +)

exception(−, −, −)

A rule r of a program π is called well-moded with respect to a mode m if:

(i) Every variable occurring in an input position of a literal l from the body of r

occurs either in an input position of the head or in an output position of some

literal from the body that precedes l.

(ii) Every variable occurring in an output position of the head occurs in an input

position of the head, or in an output position of a literal from the body.

A program π is well-moded with respect to m if all its rules are. It is not difﬁcult

to check that the program π

f

N

∪ X is well-moded with respect to mode m

0

.

Apt and Pellegrini in [4] showed that if a program π is well-moded with respect

to some mode m and there is no rule in π whose head contains more than one

occurrence of the same variable in its output positions then π is occur-check free

with respect to any ground query. The mode m

0

satisﬁes these conditions and

therefore answering query q to π

f

N

∪ X does not require the occur-check.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 183

(b) To prove that a query q ∈ lit(σ

o

(f

N

)) to π

f

N

∪ X does not ﬂounder we use

another theorem from [4,42]: if program π is well-moded with respect to some

mode assignment m and all predicate symbols occurring in π under not are moded

completely by input then a ground query to π does not ﬂounder. Again, the mode

m

0

satisﬁes this property. From (a) and (b) we can conclude that if the Prolog

interpreter terminates on query q to program π then there is an SLDNF resolution

derivation of q from π.

(c) The termination of π

f

N

∪ X follows from [3] where the authors gave a notion

of acceptable program and proved that for such programs the Prolog interpreter

terminates on ground queries. It is easy to check that π

f

N

∪ X is acceptable.

(d) Let gr(π, σ) denote the set of all ground instantiations of π by ground terms of σ.

From soundness of SLDNF resolution with respect to stable model semantics of

logic programs we can now conclude that, given a query q ∈ lit(σ

o

(f

N

)) and the

program π

f

N

∪X, the Prolog interpreter answers yes iff gr(π

f

N

, σ

u

(f

N

)) ∪X |= q.

We need to show that gr(π

f

N

, σ

u

(f

N

)) ∪ X |= q iff gr(π

f

N

, σ(f

N

)) ∪ X |= q.

In [35] McCain and Turner showed that to guarantee this property we need to check

that π

f

N

is stable and predicate-order-consistent. The notion of stability is based

on the program having a mode satisfying certain properties. It is easy to check

that the mode m

0

deﬁned above satisﬁes these conditions. The predicate-order-

consistency of this program follows immediately from the absence of function

symbols and the absence of negative edges from a predicate symbol to itself in

the dependency graph of π

f

N

.

5. Opening closed domain speciﬁcations

In this section we introduce another knowledge representation problem associated

with is-nets and demonstrate how a speciﬁcation constructor, called input opening, can

be used to specify and represent this problem.

5.1. Specifying the problem

So far we have assumed that net N(I) contains complete information about

relations default, subclass and is. In the process of development and modiﬁcation of

the system this assumption may become too strong and the speciﬁer may decide to

limit it to some of the relations or even to completely remove it from the speciﬁcation.

In this section we will consider a case when information about defaults and subclasses

is still complete but information about the membership relation can be incomplete.

Pictorially, the input to a net will be represented by positive and negative links from

objects to classes (see ﬁgure 1(c)). These links will be recorded by literals of the form

is(o, c) and ¬is(o, c). (Notice that here we use is instead of is

0

which was used in

the previous speciﬁcation. This change is not essential and is done only to simplify

the presentation.) Obviously, not any collection I of such links is consistent with our

184 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

interpretation of the net N. To ensure consistency I must not contain contrary literals,

and the is and subclass relations deﬁned by N(I) must satisfy the constraint:

←is(o, c

1

),

subclass(c

1

, c

2

),

¬is(o, c

2

).

(5)

Now the net N can be viewed as an informal speciﬁcation of the function f

◦

N

which

takes as an input the links of N together with I ∈ lit(is) and returns all conclusions

about relations subclass, is and has which a rational agent can obtain from N and I.

(Such a function f

◦

N

will be called the open domain speciﬁcation of N.) The problem

is to precisely deﬁne the set of all such conclusions. To do that we use the represen-

tation of N and functions f

s

and f

d

from the previous section. Function f

s

remains

unchanged; f

d

however needs to be modiﬁed since we do not necessarily have enough

information to provide it with input complete with respect to is. To modify f

d

the

speciﬁer may use a speciﬁcation constructor called input opening which removes the

closed world assumption from (some or all) input predicates of a speciﬁcation. To

deﬁne this constructor we ﬁrst need the following terminology.

Let D be a collection of states over some signature σ and let α ⊆ pred(σ).

Predicates from α are called open; the other predicates from pred(σ) are called closed.

A state X of σ is called an α-state if for any l ∈ lit(pred(σ \ α)), l ∈ X or l ∈ X.

The set of all α-states of σ will be denoted by α-states(σ). A set X ∈ states(σ) is

called D-consistent if there is

´

X ∈ D such that X ⊆

´

X;

´

X is called a D-cover of X.

For instance, in our example the only open predicate of σ

i

(f

d

) will be is; D will

be the set of all possible complete inputs X to f

d

such that

(i) [X]

subclass,default

= N ∪ N, where N ⊆ atoms(default, subclass) which represents

the net N and

N =

_

¬l: l ∈ atoms(default, subclass) ∧ l / ∈ N

_

,

(ii) X satisﬁes the constraint (5).

It is easy to see that for the net N from ﬁgure 1(c) the set N ∪ N ∪ {is(o

1

, c

1

),

is(o

2

, c

2

)} is D-consistent while N ∪ N ∪ {is(o

1

, c

1

), is(o

2

, c

2

), ¬is(o

2

, c

3

)} is not.

The set of all D-covers of a set X is denoted by c(D, X). The set of all

D-consistent α-states of σ is called the α-interior of D and is denoted by D

α

. An

f-speciﬁcation f deﬁned on a collection of complete states of σ

i

(f) is called closed

domain speciﬁcation.

Deﬁnition 14 (Input opening). Let f be a closed domain speciﬁcation with domain

D and α ⊆ pred(σ(f)). An f-speciﬁcation f

α

is called the input opening of f with

respect to α if

σ

i

_

f

α

_

= σ

i

(f), σ

o

_

f

α

_

= σ

i

(f) ∪ σ

o

(f), (6)

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 185

dom

_

f

α

_

= D

α

, (7)

f

α

(X) =

´ X∈c(D,X)

f

_

´

X

_

∪

´ X∈c(D,X)

´

X. (8)

The open domain f-speciﬁcation f

◦

N

of a net N can be deﬁned as

f

◦

N

= f

α

d

◦ f

s

. (9)

As was shown in [20] the input opening f

α

of f can be further decomposed using

two simpler speciﬁcation constructors called interpolation and domain completion. To

deﬁne these constructors we need the following deﬁnitions.

Deﬁnition 15. A set X ∈ states(σ) is called maximally informative with respect to a

set D ⊆ states(σ) if X is D-consistent and

X =

´ X∈c(D,X)

´

X. (10)

Consider, for instance, the net N from ﬁgure 1(b). The set

N

s

∪ N

s

∪

_

is(o

1

, c

1

), is(o

1

, c

3

), is(o

1

, c

5

), is(o

2

, c

2

), is(o

2

, c

3

), is(o

2

, c

5

)

_

is maximally informative with respect to the set of all complete input states of N,

while the set

N

s

∪ N

s

∪

_

is(o

1

, c

1

), is(o

2

, c

2

)

_

is not.

Deﬁnition 16 (Interpolation). Let f be a closed domain f-speciﬁcation with domain D

and α ⊆ pred(σ

i

(f)). By

¯

D we denote the set of all α-states of σ

i

(f) which are

maximally informative with respect to D. F-speciﬁcation

˜

f

α

with the same signatures

as f and the domain

¯

D is called the interpolation of f if

˜

f

α

(X) =

´ X∈c(D,X)

f

_

´

X

_

. (11)

This is a slight generalization of the notion of interpolation introduced in [6],

where the authors only considered interpolations of functions deﬁned by general logic

programs.

Deﬁnition 17 (Domain completion). Let D be a collection of complete states over

signature σ and α ⊆ pred(σ). The domain completion of D with respect to α is a

function

˜

f

α

D

which maps D-consistent α-states of σ into their maximally informative

supersets.

186 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

The following proposition follows almost immediately from the deﬁnitions.

Proposition 18. For any closed domain f-speciﬁcation f with domain D,

f

α

=

˜

f

α

◦

˜

f

α

D

. (12)

Proof. First note that by deﬁnition of f

α

and

˜

f

α

D

, X ∈ dom(f

α

) iff X ∈ D

α

. Let

X ∈ D

α

and Y =

˜

f

α

D

(X). By deﬁnition of

˜

f

α

D

and

˜

f

α

, Y ∈ dom(

˜

f

α

). By deﬁnition

of incremental extension,

˜

f

α

◦

˜

f

α

D

(X) = Y ∪

˜

f

α

(Y ). Moreover, by deﬁnition of

˜

f

α

,

˜

f

α

(Y ) =

´ X∈c(D,Y )

f(

´

X). Clearly, c(D, Y ) = c(D, X) and hence

˜

f

α

(Y ) =

´ X∈c(D,X)

f(

´

X). Finally, by deﬁnition of domain completion, f

α

(X) =

˜

f

α

◦

˜

f

α

D

(X).

From proposition 18 and equation (9) we have that the open domain speciﬁcation

f

◦

N

can be given by equation

f

◦

N

= ˜ g

α

◦ ˜ g

α

D

◦ f

s

, (13)

where g = f

d

, α = {is} and D = dom(f

d

).

5.2. Realization theorems for domain completion and interpolation

Equation (13) above suggests that a representation for f

◦

N

can be constructed

from lp-functions representing ˜ g

α

and ˜ g

α

D

. In the construction of these functions we

will be aided by realization theorems for domain completions and interpolations.

5.3. Domain completion

Let C be a collection of constraints over signature σ, α ⊆ pred(σ), and D be a

collection of complete states of σ satisfying C. We will be interested in representing

the domain completion of D with respect to α. Such a representation is especially

simple for constraints which are binary with respect to α, i.e., constraints whose

bodies contain exactly two literals from lit(α). By the disjunctive image d(c) of a

binary constraint

c =←l

1

, l

2

, Γ (14)

where l

1

, l

2

∈ lit(α) we mean the disjunction l

1

∨ l

2

; by d(C) we denote the set of

disjunctive images of constraints from C. A set C of binary constraints is said to be

indeﬁnite if there is no l ∈ lit(σ) such that d(C) |= l or d(C) |= l.

Notice that the set of constraints {← p, q; ← ¬p, q} (where p, q ∈ α) is not

indeﬁnite.

Let ˜ π

D

be a program obtained from C by replacing each constraint ← l

1

, l

2

, Γ

by the rules

l

1

← l

2

, Γ,

l

2

← l

1

, Γ.

_

˜ π

D

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 187

Theorem 19 (Realization theorem for domain completion). Let C be a collection of

binary constraints over signature σ, α ⊆ pred(σ) and D a collection of complete states

of σ satisfying C. If C is indeﬁnite then a four-tuple {˜ π

D

, σ, σ, D

α

} is an lp-function

which represents the domain completion

˜

f

α

D

of D.

In the proof of this theorem, which appears below, we use the following lemmas.

Lemma 20. Let X ∈ D

α

. Then for any

´

X ∈ c(D, X) there is a set A ⊆

´

X which is

the answer set of ˜ π

D

∪ X.

Proof. Since X ∈ D

α

we have that c(D, X) is not empty. Let

´

X ∈ c(D, X). By

deﬁnition of c(D, X),

´

X is complete and satisﬁes the constraints from C. This implies

that

´

X is closed under the rules of ˜ π

D

. Consider a (possibly inﬁnite) sequence X

i

of

sets of literals such that

• X

0

=

´

X,

• X

i+1

is a proper subset of X

i

, which contains X and is closed under the rules of

˜ π

D

.

Let A =

X

i

. A contains X and is closed under the rules of ˜ π

D

. (Suppose l

1

← l

2

, Γ

is a rule from ˜ π

D

and Γ, l

2

∈ A. Then, for every i, l

2

, Γ ∈ X

i

. Since X

i

is closed

under the rules, l

1

is also in X

i

and hence in A). Obviously, there is no smaller set

of literals closed under ˜ π

D

∪ X, i.e., A is one of its answer sets. Since our program

does not contain negation as failure, A is its only answer set.

The following corollary follows immediately from this lemma.

Corollary 21. For all X ∈ D

α

,

• ˜ π

D

∪ X is consistent,

• ˜ π

D

(X) ⊆

´ X∈c(D,X)

´

X.

Lemma 22. If X ∈ D

α

, then for every

´

X ∈ c(D, X), ˜ π

D

(

´

X) =

´

X.

Proof. By deﬁnition of c(D, X),

´

X is consistent. Thus to prove the lemma it only

remains to show that

´

X is closed under the rules of ˜ π

D

. Let l ← l

, Γ be any rule in

˜ π

D

and assume that Γ, l

∈

´

X. By deﬁnition of ˜ π

D

there is a constraint ← l, l

, Γ ∈ C.

Hence l / ∈

´

X. By deﬁnition of D,

´

X is complete and therefore l ∈

´

X.

Lemma 23. For all X ∈ D

α

, ˜ π

D

(X) ⊇

´ X∈c(D,X)

´

X.

188 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

Proof. Consider an arbitrary X ∈ D

α

and suppose that the lemma is false, i.e., that

there is a literal l such that

l ∈

´ X∈c(D,X)

´

X but l / ∈ ˜ π

D

(X). (15)

By lemma 22, the above is equivalent to

l ∈

´ X∈c(D,X)

˜ π

D

_

´

X

_

but l / ∈ ˜ π

D

(X). (16)

We will ﬁrst show that, under this assumption,

l / ∈ ˜ π

D

(X). (17)

Suppose it does, i.e., l ∈ ˜ π

D

(X). Then, since X ∈ D

α

, there is

´

X ∈ D containing

X. Since ˜ π

D

does not contain negation as failure, we have that

˜ π

D

(X) ⊆ ˜ π

D

_

´

X

_

.

This implies that l ∈ ˜ π

D

(

´

X) which contradicts assumption (16). Hence (17) holds.

Now we will construct a set Z ∈ c(D, X) containing l. By corollary 21, ˜ π

D

(X)

is consistent. Since it contains no negation as failure it has exactly one answer set,

say, A. Let

C

= {← l

1

, l

2

: ← l

1

, l

2

, Γ ∈ C, Γ ⊆ A},

P

1

=

_

l

i

: l

i

∈ ˜ π

D

(X) or l

i

∈ ˜ π

D

(X)

_

, and

P

2

= lit(α) \ P

1

.

Let C

1

be a collection of constraints from C

such that l

1

or l

2

is in A, and let

C

2

= C

\ C

1

.

Notice that no literal l

i

occurring in constraints from C

2

belongs to P

1

. (If it

were the case then we would have that l

i

∈ A or l

i

∈ A. The former is impossible

since it would place the constraint containing this literal into C

1

. The latter is also

impossible since in this case the second literal from this constraint would be falsiﬁed

by A, again placing it in C

1

.) By construction, P

2

is closed under ¬, i.e., for any

l

i

∈ lit(σ) if l

i

∈ P

2

then so is l

i

. This implies that if l

i

belongs to a constraint of C

2

then l

i

, l

i

∈ P

2

and, therefore, interpretations of C

2

can be viewed as complete and

consistent sets of literals from P

2

. From (16) and (17) we have that l ∈ P

2

. Since

C is indeﬁnite so is C

2

and therefore there is an interpretation B of C

2

which makes

d(C

2

) true and l false. Now let

Z = A∪ B.

To show that Z is complete consider two cases: If l

i

/ ∈ lit(α) then, since X ∈ D

α

,

we have that l

i

∈ X or l

i

∈ X and hence either l

i

or l

i

is in A. Otherwise, l

i

∈ P

1

or l

i

∈ P

2

. If l

i

∈ P

1

then, by deﬁnition of P

1

, l

i

∈ A or l

i

∈ A. For l

i

∈ P

2

completeness follows from the construction of B.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 189

Consistency follows from consistency of A and B and the fact that if l

i

∈ B

then l

i

/ ∈ A.

It is also easy to check that, by construction, Z satisﬁes the constraints C and

hence, Z ∈ c(D, X). This contradicts our assumption that l ∈

´ X∈c(D,X)

´

X and

therefore the lemma holds.

Proof of theorem 19. We need to show that for all X ∈ D

α

,

˜

f

α

D

(X) = ˜ π

D

(X). By

deﬁnition of domain completion, this is equivalent to

˜ π

D

(X) =

´ X∈c(D,X)

´

X

which follows immediately from corollary 21 and lemma 23.

5.4. Interpolation

Now we discuss a realization theorem for interpolation of f-speciﬁcations. Let

σ be a signature, α ⊆ pred(σ), and D be a collection of complete α-states of σ.

Function f deﬁned on the interior D

α

of D is called separable if

´ X∈c(D,X)

f(

´

X) ⊆ f(X)

or, equivalently, if for any X ∈ dom(f) and any output literal l such that l / ∈ f(X)

there is

´

X ∈ c(D, X) such that l / ∈ f(

´

X).

The following propositions give simple sufﬁcient conditions for separability

which may help to better understand this notion.

Proposition 24. Let D be the set of complete states over some signature σ

i

, α =

pred(σ

i

), and let π be an lp-function deﬁned on D

α

= states(σ

i

), such that

1. The sets of input and output predicates of π are disjoint and input literals do not

belong to the heads of π.

2. For any l ∈ σ

i

, l / ∈ lit(π) or l / ∈ lit(π). (Here by lit(π) we mean the collection of

all literals which occur in the rules of the ground instantiation of π.)

Then π is separable.

Proof (sketch). Let X ∈ dom(π) and consider the set

X

∗

=X ∪

_

l: l / ∈ X, l ∈ lit(π)

_

∪

_

l: l ∈ atoms(σ

i

), ¬l / ∈ X, l / ∈ lit(π), ¬l / ∈ lit(π)

_

.

By condition (2), X

∗

is consistent. Since it is also complete by construction we have

that X

∗

∈ dom(π). By condition (1) lit(σ

i

) is a splitting set of programs π ∪ X and

π ∪ X

∗

. By the splitting set theorem and condition (1) we have that for any output

190 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

literal l, l ∈ π(X) iff red(π, X) |= l and l ∈ π(X

∗

) iff red(π, X

∗

) |= l. But by

construction of X

∗

and the deﬁnition of red, red(π, X) = red(π, X

∗

), hence l ∈ π(X)

iff l ∈ π(X

∗

) and therefore, π is separable.

The next example shows that the last condition is essential.

Example 25. Let σ

i

be a signature consisting of object constant a and predicate con-

stant p, and consider D = {{p(a)}, {¬p(a)}} and a function f

1

deﬁned on D

α

by the

program

q(a) ← p(a)

q(a) ← ¬p(a)

where σ

o

(f

1

) consists of a and q. Let X = ∅. Obviously, f

1

(X) = ∅ while

´ X∈c(D,X)

f

1

(

´

X) = {q(a)} and hence f

1

is not separable.

In some cases, to establish separability of an lp-function π it is useful to represent

π as the union of its independent components and to reduce the question of separability

of π to separability of these components. This can be done in the following way: Let

π be an lp-function with input signature σ

i

and output signature σ

o

. We assume

that the input literals of π do not belong to the heads of rules of π. We say that π

is decomposable into independent components π

0

, . . . , π

n

if π = π

0

∪ · · · ∪ π

n

and

lit(π

m

) ∩ lit(π

k

) ⊆ lit(σ

i

) for any k = m.

Proposition 26. Let π

0

, . . . , π

n

be independent components of lp-function π. Then:

(i) for any 0 k n, four-tuple {π

k

, σ

i

, σ

o

, dom(π)} is an lp-function,

(ii) if π

k

is separable for any 0 k n then so is π.

Proof. The proposition follows immediately from the splitting set theorem and deﬁ-

nition of separability.

Example 27. Consider σ, α and D from example 25 and let function f

2

with the

output signature consisting of a, q

1

and q

2

be deﬁned by a program

(1) q

1

(a) ← p(a),

(2) q

2

(a) ← ¬p(a).

Obviously, π can be decomposed into independent components π

1

and π

2

consisting

of rules (1) and (2), respectively. By proposition 24, π

1

and π

2

are separable, and

hence, by proposition 26, so is π.

The following simple observation proves to be useful for constructing interpola-

tions.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 191

Theorem 28 (Realization theorem for interpolation). Let f be a closed domain speciﬁ-

cation with domain D represented by an lp-function π and let ˜ π be the result of replac-

ing some occurrences of input literals l in pos(π) by not l. If {˜ π, σ

i

(f), σ

o

(f), dom(

˜

f)}

is a separable and monotonic lp-function then it represents the interpolation

˜

f of f.

Proof. Let ˜ π be a separable and monotonic lp-function. To show that it represents

˜

f, we need to show that

˜ π(X) =

´ X∈c(D,X)

π

_

´

X

_

.

From the separability of ˜ π we have one direction, namely that

´ X∈c(D,X)

π

_

´

X

_

⊆ ˜ π(X).

By monotonicity, if X ⊆

´

X, then ˜ π(X) ⊆ ˜ π(

´

X). Hence,

˜ π(X) ⊆

´ X∈c(D,X)

˜ π

_

´

X

_

.

Clearly, for any complete set

´

X, ˜ π(

´

X) = π(

´

X). Therefore,

˜ π(X) ⊆

´ X∈c(D,X)

π

_

´

X

_

.

Corollary 29. Let f, π and ˜ π be as in theorem 28. If ˜ π = {˜ π, σ

i

(f), σ

o

(f), dom(

˜

f)}

is a separable lp-function with a signing S such that S ∩ (lit(σ

i

) ∪ lit(σ

o

)) = ∅ then it

represents the interpolation

˜

f of f.

The corollary follows immediately from theorems 7 and 28.

5.5. The declarative representation of open nets

In this section we will go back to the task of building a computable lp-function

π

◦

representing the open domain speciﬁcation f

◦

N

. Recall that f

◦

N

is deﬁned via

incremental extension and three f-speciﬁcations: ˜ g

α

, ˜ g

α

D

and f

s

where g = f

d

and

α = {is} (13). We start with ﬁnding a representation ˜ π of ˜ g

α

. Theorem 28 will provide

an important heuristic guidance for this construction. In particular, we will look for

a transformation from this theorem which will turn the lp-function π (section 4.2)

representing g into a monotonic lp-function. The only transformation achieving this

goal is that of replacing the rule deﬁning predicate exceptional in π by the rule

exceptional(X, D, S) ←exception(E, D, S),

not ¬is(X, E). (18)

192 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

Let us denote the resulting program by ˜ π and use corollary 29 to prove the following

proposition.

Proposition 30. ˜ π represents ˜ g

α

.

Proof (sketch). We need to show that ˜ π is an lp-function and that it is separable and

monotonic.

1. (Consistency.) Let D be the domain of g = f

d

and

¯

D be the domain of ˜ g.

(Recall that dom(g) consists of complete states of σ

i

(g) which satisfy the constraints (5)

and dom(˜ g) is the set of all {is}-states of σ

i

(g) which are maximally informative with

respect to D). Let X ∈ dom(˜ π). To show that π

0

= ˜ π ∪ X is consistent we use an

argument similar to that which we used to prove consistency of π∪X in proposition 11.

We use renaming to reduce ˜ π to a program without ¬; use its stratiﬁability to entail

existence of a unique answer set and show that this answer set is consistent.

2. (Separability.) Let X ∈

¯

D and consider an output literal l / ∈ ˜ π(X). Let

us ﬁrst assume that l = has(x, p). We need to construct a cover

´

X of X such that

l / ∈ ˜ π(

´

X). We say that a class e is p-negative if there is a negative link from e to p in

N; a p-negative class e can defeat has(x, p) if ¬is(x, e) / ∈ X. Let E

0

be the set of all

classes which can defeat has(x, p) and consider

E =E

0

∪

_

c: ∃e (e ∈ E

0

and subclass(e, c) ∈ N)

_

,

U =X ∪

_

is(x, e): e ∈ E

_

, and

´

X =U ∪

_

¬is(o, c): is(o, c) / ∈ U

_

.

We show that

(a)

´

X is a cover of X,

(b) l / ∈ ˜ π(

´

X).

(a) By construction,

´

X is complete and consistent. We need to show that it

satisﬁes the constraints (5).

Consider arbitrary o, c

1

and c

2

such that subclass(c

1

, c

2

) ∈ N and is(o, c

1

) ∈

´

X.

First let us consider the case when is(o, c

1

) ∈ X. Then any cover of X must contain

is(o, c

2

). Since X is maximally informative, is(o, c

2

) ∈ X, and hence by consistency

of

´

X the constraints (5) are satisﬁed. Suppose now that is(o, c

1

) / ∈ X. If o is not x,

then ¬is(o, c

1

) ∈

´

X and constraints (5) are satisﬁed by consistency of

´

X. If o is x, then

c

1

, c

2

∈ E and, by construction, is(x, c

2

) ∈

´

X. Consistency of

´

X again guarantees

that constraints (5) are satisﬁed.

(b) Since

´

X is complete and consistent and lit(is) is a splitting set of ˜ π, we have

that red(π,

´

X) = red(˜ π,

´

X) and hence π ∪

´

X is consistent iff ˜ π ∪

´

X is consistent.

Consistency of π ∪

´

X was established before and hence ˜ π ∪

´

X is also consistent and

has a consistent answer set S. As shown in [34], has(x, p) ∈ S iff there is class c such

that default(d, c, p, +) ∈ N, is(x, c) ∈

´

X, exceptional(x, d, +) / ∈ S. Let c satisfy this

condition and consider two cases:

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 193

(i) is(x, c) ∈ X.

Then, since l / ∈ ˜ π(X), we have that for every class e such that exception(e, d, +) ∈

S, ¬is(x, e) / ∈ X. By construction of

´

X this implies that ¬is(x, e) / ∈ S,

exceptional(x, d, +) ∈ S, and therefore has(x, p) / ∈ ˜ π(

´

X).

(ii) is(x, c) / ∈ X.

Then is(x, c) ∈ U. By construction of U we have that there is a class e such that

default(d

2

, e, p, −) ∈ N, ¬is(x, e) / ∈ X and either e = c or subclass(e, c) ∈ N. By

construction we have that is(x, e) ∈ U. Since our graph is acyclic, we have that

exception(e, d, +) ∈ S, exceptional(x, d, +) ∈ S and therefore has(x, p) / ∈ ˜ π(

´

X).

A similar argument works for l = ¬has(x, p).

3. (Monotonicity.) Let X

1

, X

2

∈ dom(˜ π) and X

1

⊂ X

2

. To show that

(i) ˜ π(X

1

) ⊂ ˜ π(X

2

)

we ﬁrst use the splitting set theorem to eliminate from π

1

= ˜ π ∪X

1

and π

2

= ˜ π ∪X

2

all the occurrences of literals from lit(default). Since X

1

and X

2

are is-states of σ

i

we

have that [X

1

]

{default}

= [X

2

]

{default}

and hence

(ii) top(π

1

, lit(default)) = top(π

2

, lit(default)).

Let us denote this program by π

**. By the splitting set theorem
**

(iii) π

**(X) = ˜ π(X) for any X ∈ dom(˜ π).
**

Now observe that the set S = atoms({exception, exceptional)} is a signing for π

and

that S ∩(lit(σ

i

(π) ∪lit(σ

o

(π))) = ∅. The monotonicity condition follows from (iii) and

theorem 7 and the conclusion of our proposition becomes an immediate consequence

of theorem 28.

To complete the construction of representation π

◦

of f

◦

N

we need to ﬁnd a rep-

resentation ˜ π

D

of the domain completion of D = dom(g) with respect to α = {is}.

Recall that D is the collection of complete states of σ

i

(g) satisfying constraints (5).

These constraints are binary with respect to α. It is also easy to see that they are

indeﬁnite and hence we can use the construction from theorem 19. The corresponding

program ˜ π

D

consists of the rules

is(O, C

2

) ←is(O, C

1

), subclass(C

1

, C

2

), (19)

¬is(O, C

1

) ←¬is(O, C

2

), subclass(C

1

, C

2

). (20)

Proposition 31. ˜ π

D

represents ˜ g

α

D

.

Proof. Follows immediately from theorem 19.

Finally, we can show that

Proposition 32. π

◦

= ˜ π ∪ ˜ π

D

∪ π

s

represents f

◦

N

.

194 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

Proof. Follows immediately from the equation (13), propositions 30, 31, theorem 10,

and the fact that ˜ π, ˜ π

D

and π

s

have unique answer sets.

As in the case of closed nets, proposition 32 shows the correctness of π

◦

with

respect to our speciﬁcation if π

◦

is viewed as a declarative program. However, due

to the left recursion in rules (19) and (20), π

◦

is not computable with respect to our

interpreter A. To achieve computability we need to change the order of literals in the

bodies of these rules. The resulting program π

◦

will look as follows:

has(X, P) ←default(D, C, P, +),

is(X, C),

not exceptional(X, D, +).

¬has(X, P) ←default(D, C, P, −),

is(X, C),

not exceptional(X, D, −).

exception(E, D

1

, +) ←default(D

1

, C, P, +),

default(D

2

, E, P, −),

not subclass(C, E).

exception(E, D

1

, −) ←default(D

1

, C, P, −),

default(D

2

, E, P, +),

not subclass(C, E).

exceptional(X, D, S) ←exception(E, D, S),

not ¬is(X, E).

is(O, C

2

) ←subclass(C

1

, C

2

),

is(O, C

1

).

¬is(O, C

1

) ←subclass(C

1

, C

2

),

¬is(O, C

2

).

subclass(C

1

, C

2

) ←subclass

0

(C

1

, C

2

).

subclass(C

1

, C

2

) ←subclass

0

(C

1

, C

3

),

subclass(C

3

, C

2

).

¬subclass(C

1

, C

2

) ←not subclass(C

1

, C

2

).

_

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

_

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

_

π

◦

Its computability can be shown by an argument similar to that in proposition 13. Notice

that if we were to use an inference engine based on XSB which includes a form of

loop checking, no changes in the rules (19) and (20) would be needed.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 195

6. A simple generalization

In this section we generalize the knowledge representation problem associated

with a net N by allowing strict (non-defeasible) links from objects to properties to

belong to the net’s input (see ﬁgure 2). We show that this generalization can be easily

incorporated into the design. To do that we use another speciﬁcation constructor

from [26], called input extension.

Deﬁnition 33. Let f be a functional speciﬁcation with disjoint sets of input and output

predicates. An f-speciﬁcation f

∗

with input signature σ

i

(f)+σ

o

(f) and output signature

σ

o

(f) is called input extension of f if

(1) f

∗

is deﬁned on elements of dom(f) possibly expanded by consistent sets of literals

from σ

o

(f),

(2) for every X ∈ dom(f), f

∗

(X) = f(X),

(3) for any Y ∈ dom(f

∗

) and any l ∈ lit(σ

o

(f)),

(i) if l ∈ Y then l ∈ f

∗

(Y ),

(ii) if l / ∈ Y and l / ∈ Y then l ∈ f

∗

(Y ) iff l ∈ f(Y ∩ lit(σ

i

(f)).

A new problem associated with a net N can be deﬁned by f-speciﬁcation

f

∗

= g

∗

◦ ˜ g

α

D

◦ f

s

, (21)

where g

∗

is the input extension of ˜ g

α

.

To ﬁnd an lp-function representing g

∗

we will use the following transformation

from [26].

Deﬁnition 34. Let π be an lp-function. The result of replacing every rule

l

0

← l

1

, . . . , l

m

, not l

m+1

, . . . , not l

n

Figure 2. Hierarchy with links from objects to properties.

196 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

of π with l

0

∈ lit(σ

◦

(f)) by the rule

l

0

← l

1

, . . . , l

m

, not l

m+1

, . . . , not l

n

, not l

0

is called the guarded version of π and is denoted by ˆ π.

The following theorem is useful for constructing lp-functions representing input

extensions.

Theorem 35 (Realization theorem for input extension [26]). Let f be a speciﬁcation

represented by lp-function π with signature σ. If the set U = lit(σ)\lit(σ

◦

) is a splitting

set of π dividing π into two components π

2

= top(π, U) and π

1

= base(π, U), then

lp-function π

∗

= π

1

∪ ˆ π

2

represents the input extension f

∗

of f.

The representation π

∗

of input extension g

∗

of ˜ g

α

is obtained by replacing the

has rules in π

◦

(section 5.5) by

has(x, p) ←default(d, c, p, +),

is(x, c),

not exceptional(x, d, +),

not ¬has(x, p).

¬has(x, p) ←default(d, c, p, −),

is(x, c),

not exceptional(x, d, −)

not has(x, p).

_

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

_

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

¸

_

The following proposition follows immediately from equation (21), the construction

of π

∗

, and theorems 35 and 10.

Proposition 36.

(i) π

∗

represents g

∗

,

(ii) π

∗

∪ ˜ π

D

∪ π

s

represents f

∗

.

This example again demonstrates that speciﬁcation constructors and their real-

ization theorems provided a useful heuristic guidance for specifying knowledge repre-

sentation problems and for building program provably satisfying these speciﬁcations.

7. Conclusions

In this paper we discussed a systematic methodology of solving certain types

of knowledge representation problems in logic programming. The methodology was

illustrated by a detailed development of solutions of several knowledge representation

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 197

problems associated with simple taxonomic hierarchies. In each case we started with a

functional speciﬁcation of a problem constructed from speciﬁcations of simpler prob-

lems with the help of speciﬁcation constructors, and used various realization theorems

to guide the process of representing these speciﬁcations by declarative programs of

A-Prolog. We also demonstrated how these programs can be transformed into exe-

cutable programs of Prolog and XSB. The paper also contains previously unpublished

proofs of several realization theorems.

Even though the formalization of inheritance reasoning was extensively studied

in the AI literature [15,16,18,24,27,28,41,47], the emphasis on precise speciﬁcations of

the problems allowed us to come up with a clearer picture of dependencies of various

types of inheritance reasoning on the closed and open world assumptions about the

problem domain and on the type of the allowed updates. In particular, we addressed

the question of reasoning in open nets, which, to the best of our knowledge, was never

investigated before. We are currently working on studying the applicability of our

approach to more general forms of inheritance, to reasoning about actions and change,

and to several other domains. The results so far seem to be rather promising.

Acknowledgements

Many people contributed to the development of ideas presented in this paper and

we cannot name all of them here. We would like to mention however our collab-

orators who directly contributed to this approach – H. Przymusinska, C. Baral and

O. Kosheleva. Our thanks to them and to all the others. The authors are grateful to

the anonymous referees for their comments and suggestions for improving the paper.

The ﬁrst author acknowledges the support of NASA under grant NCCW-0089.

References

[1] J.J. Alferes and L.M. Pereira, Reasoning with Logic Programming, Lecture Notes in Artiﬁcial

Intelligence (Springer, Berlin, 1996).

[2] K. Apt, H. Blair and A. Walker, Towards a theory of declarative knowledge, in: Foundations of

Deductive Databases and Logic Programming, ed. J. Minker (Morgan Kaufmann, San Mateo, CA,

1988) pp. 89–148.

[3] K. Apt and D. Pedreschi, Proving termination in general Prolog programs, in: Proc. of the In-

ternational Conference on Theoretical Aspects of Computer Software, Lecture Notes in Computer

Science, Vol. 526 (Springer, Berlin, 1991) pp. 265–289.

[4] K. Apt and A. Pellegrini, On the occur-check free logic programs, ACM Trans. Programming

Languages and Systems 16(3) (1994) 687–726.

[5] C. Baral and M. Gelfond, Logic programming and knowledge representation, J. Logic Programming

12 (1994) 1–80.

[6] C. Baral, M. Gelfond and O. Kosheleva, Expanding queries to incomplete databases by interpolating

general logic programs, J. Logic Programming 35 (1998) 195–230.

[7] N. Bidoit and C. Froidevaux, Minimalism subsumes default logic and circumscription, in: Proc. of

LICS-87 (1987) pp. 89–97.

198 M. Gelfond, A. Gabaldon / Building a knowledge base: an example

[8] D. Chan, Constructive negation based on the completed databases, in: Proc. 5th International

Conference and Symposium on Logic Programming (1988) pp. 111–125.

[9] W. Chen, Extending Prolog with nonmonotonic reasoning, J. Logic Programming 27(2) (1996)

169–183.

[10] W. Chen, T. Swift and D. Warren, Efﬁcient top-down computation of queries under the well-founded

semantics, J. Logic Programming 24(3) (1995) 161–201.

[11] P. Cholewinski, W. Marek and M. Truszczynski, Default reasoning system DeReS, in: Proc. of

KR-96 (1996) pp. 518–528.

[12] K. Clark, Negation as failure, in: Logic and Data Bases, eds. H. Gallaire and J. Minker (Plenum

Press, NY, 1978) pp. 293–322.

[13] P. Dembinski and J. Maluszynski, AND-parallelism with intelligent backtracking for annotated logic

programs, in: Logic Programming: Proc. of the International Symposium on Logic Programming,

eds. V. Saraswat and K. Ueda (1985) pp. 25–38.

[14] Y. Deville, Logic Programming: Systematic Program Development (Addison-Wesley, Reading, MA,

1990).

[15] P.M. Dung and T.C. Son, Nonmonotonic inheritance, argumentation, and logic programming, in:

Proceedings of LPNMR (1995) pp. 316–329.

[16] P.M. Dung and T.C. Son, An argumentation-theoretic approach to reasoning with speciﬁcity, in:

Proceedings of KR ’96 (1996) pp. 407–418.

[17] T. Eiter, N. Leone, C. Mateis, G. Pfeifer and F. Scarcello, A deductive system for non-monotonic

reasoning, in: Proc. 4th LPNMR, Lecture Notes in Computer Science, Vol. 1265 (Springer, Berlin,

1997) pp. 363–374.

[18] D. Etherington and R. Reiter, On inheritance hierarchies with exceptions, in: Proceedings of AAAI-

83 (1983) pp. 104–108.

[19] F. Fages, Consistency of Clark’s completion and existence of stable models, J. Methods Logic

Comput. Sci. 1(1) (1994) 51–60.

[20] M. Gelfond and A. Gabaldon, From functional speciﬁcations to logic programs, in: Logic Program-

ming: Proc. of the 1997 International Symposium, ed. J. Maluszynski (1997) pp. 355–371.

[21] M. Gelfond and V. Lifschitz, The stable model semantics for logic programming, in: Logic Program-

ming: Proc. of the 5th International Conference and Symposium, eds. R. Kowalski and K. Bowen

(1988) pp. 1070–1080.

[22] M. Gelfond and V. Lifschitz, Logic programs with classical negation, in: Logic Programming:

Proc. of the 7th International Conference, eds. D. Warren and P. Szeredi (1990) pp. 579–597.

[23] M. Gelfond and V. Lifschitz, Classical negation in logic programs and disjunctive databases, New

Generation Computing 9 (1991) 365–385.

[24] M. Gelfond and H. Przymusinska, Formalization of inheritance reasoning in autoepistemic logic,

Fund. Inform. 13 (1990) 403–445.

[25] M. Gelfond and H. Przymusinska, On consistency and completeness of autoepistemic theories,

Fund. Inform. 16(1) (1992) 59–92.

[26] M. Gelfond and H. Przymusinska, Towards a theory of elaboration tolerance: logic programming

approach, J. Software Eng. Knowledge Eng. 6(1) (1996) 89–112.

[27] J.F. Horty, Some direct theories of non-monotonic inheritance, in: Handbook of Logic in Artiﬁcial

Intelligence and Logic Programming, eds. D. Gabbay, C. Hogger and J.A. Robinson (1994).

[28] J.F. Horty, R.H. Thomason and D.S. Touretzky, A skeptical theory of inheritance in nonmonotonic

semantic networks, Artiﬁcial Intelligence 42(2–3) (1990) 311–348.

[29] K. Kunen, Signed data dependencies in logic programs, J. Logic Programming 7(3) (1989) 231–245.

[30] V. Lifschitz, Restricted monotonicity, in: Proc. of AAAI-93 (1993) pp. 432–437.

[31] V. Lifschitz, Foundations of logic programming, in: Principles of Knowledge Representation,

ed. G. Brewka (CSLI Publications, 1996) pp. 69–128.

M. Gelfond, A. Gabaldon / Building a knowledge base: an example 199

[32] V. Lifschitz and H. Turner, Splitting a logic program, in: Proc. 11th ICLP, ed. P. Van Hentenryck

(1994) pp. 23–38.

[33] F. Lin, A study of nonmonotonic reasoning, Ph.D. thesis, Stanford University (1991).

[34] W. Marek and V.S. Subrahmanian, The relationship between logic program semantics and non–

monotonic reasoning, in: Proc. of the 6th International Conference on Logic Programming,

eds. G. Levi and M. Martelli (1989) pp. 600–617.

[35] N. McCain and H. Turner, Language independence and language tolerance in logic programs, in:

Proc. of the 11th International Conference on Logic Programming (1994) pp. 38–57.

[36] L. Niemela and P. Simons, Efﬁcient implementation of the well-founded and stable model semantics,

in: Proc. of JICSLP-96 (MIT Press, Cambridge, MA, 1996).

[37] L. Pereira and J. Alferes, Well-founded semantics for logic programs with explicit negation, in:

Proc. of the 10th European Conference on Artiﬁcial Intelligence (1992) pp. 102–106.

[38] T. Przymusinki, On constructive negation in logic programming, in: Proc. of the North American

Conference of Logic Programming (1989) pp. 16–20.

[39] R. Reiter, On closed world data bases, in: Logic and Data Bases, eds. H. Gallaire and J. Minker

(Plenum Press, New York, 1978) pp. 119–140.

[40] R. Reiter, A logic for default reasoning, Artiﬁcial Intelligence 13(1–2) 81–132.

[41] L.A. Stein, Resolving ambiguity in non-monotonic inheritance hierarchies, Artiﬁcial Intelligence

55(2–3) (1992) 259–310.

[42] K. Stroetmann, A completeness result for SLDNF-resolution, J. Logic Programming 15(4) (1993)

337–355.

[43] D. Touretzky, The Mathematics of Inheritance Systems (Morgan Kaufmann, Los Altos, CA, 1986).

[44] H. Turner, A monotonicity theorem for extended logic programs, in: Proc. 10th ICLP, ed. D.S. War-

ren (1993) pp. 567–585.

[45] H. Turner, Signed logic programs, in: Proc. of ILPS, ed. M. Bruynooghe (1994) pp. 61–75.

[46] A. Van Gelder, K. Ross and J. Schlipf, The well-founded semantics for general logic programs,

Journal of the ACM 38(3) (1991) 620–650.

[47] X. Wang, J.H. You and L.Y. Yuan, A default interpretation of defeasible network, in: Proceedings

of the 15th International Joint Conference on Artiﬁcial Intelligence (IJCAI-97) (1997) pp. 156–161.

166

M. Gelfond, A. Gabaldon / Building a knowledge base: an example

gramming process to the description of objects comprising the domain of interest and relations between these objects. After such a description is produced by a programmer, it can be queried to establish truth or falsity of statements about the domain or to ﬁnd objects satisfying various properties. The software development process in this paradigm starts with a natural language description of the domain which, after a necessary analysis and elaboration, is described in mathematical terms. The main purpose of this initial mathematical speciﬁcation is to be understood by the people involved in the development of the system and to serve as a contract between the system speciﬁers and implementors. This speciﬁcation is then gradually transformed by implementors into an executable program satisfying the speciﬁcation. (The process will of course normally require more than one iteration.) There are many languages which can be used during various stages of this transformation. This paper adopts the view from [26] where the authors argue that for a rather broad class of knowledge representation problems the process of representing knowledge can be divided into three (mutually dependent) parts: • Elaboration of a natural language description of the domain can be done in a language of functional speciﬁcations – possibly incomplete deﬁnitions of new relations between objects of the domain of discourse given in terms of the old, known relations.1 These speciﬁcations can be deﬁned by a speciﬁer directly in a simple set-theoretic language, or they can be built from previously deﬁned speciﬁcations with the help of speciﬁcation constructors – simple functions from speciﬁcations to speciﬁcations. This method is applicable when our knowledge representation problem can be parameterized with respect to some possible inputs. (A good discussion on the importance of explicitly specifying input and output of knowledge representation problems in AI can be found in [30].) • On the second stage implementors of the system are given the functional speciﬁcation f constructed during the ﬁrst stage of the process. Now they are confronted with the task of representing f in a logical language with a precisely described entailment relation. Gelfond and Przymusinska [26] advocate the use of a language A-Prolog of logic programs with two types of negation and the answer set semantics. The choice is determined by the ability of A-Prolog to represent default assumptions, i.e., statements of the form “Elements of the class A normally (typically, as a rule) have property P ”, epistemic statements “P is unknown”, “P is possible”, and other types of statements needed for describing common sense domains. Other important factors are the simplicity of the semantics, strong expressive power of the language, existence of a mathematical theory providing a basis for proving properties of programs in A-Prolog, and the availability of query answering systems which can be used for rapid prototyping.2 There are other reasons but we will not

1

In precise terms, a functional speciﬁcation consists of two signatures σi and σo and a (possibly partial) function f which maps sets of ground literals over σi into sets of ground literals over σo . 2 There is a variety of query-answering systems which can be used to compute answers to queries in A-Prolog. A simple meta-interpreter build on top of Prolog or XSB [10] proved to be sufﬁcient for

M. Gelfond, A. Gabaldon / Building a knowledge base: an example

167

discuss them in this paper. The alternative approach which uses logic programs with well-founded semantics and its extensions can be found in [1]. At the end of the second stage the implementor will have a logic program π which, taken in conjunction with a collection X of facts about known relations of f , will entail exactly those facts about the new relations which belong to f (X). Programs of this sort are called lp-functions. In [26] the authors suggest that the construction of π from f can be substantially facilitated by mathematical results relating speciﬁcation constructors to some operations on logic programs. Such results are called realization theorems. They can provide an implementor with a useful heuristic guidance and the means to establish correctness of his programs. Several examples of such theorems and their applications will be given in the following sections. • At the last stage of the process, the lp-function π representing functional speciﬁcation f will be transferred into an efﬁcient logic program Π computing (or approximating) the entailment relation of π. Unlike π, the construction of Π will depend signiﬁcantly on the choice of query answering system used by the implementors. For instance, the use of standard Prolog interpreter may require modiﬁcation of π which includes the cut operator of Prolog to avoid loops or to improve efﬁciency. The use of XSB will avoid some of these problems but will require the choice of predicates to be tabled, etc. Space limitations preclude us from giving any serious comparison of our approach with other methodologies of representing knowledge. Moreover, we believe that such a comparison can only be done when all of these methodologies are more fully developed. Still a short remark is in order. At the moment, the speciﬁcation language most frequently used for the ﬁrst formal reﬁnement of a problem is probably the language of ﬁrst-order logic (FOL). As others before us we conjecture that FOL is not fully adequate for our purpose. Its expressive power is insufﬁcient to deﬁne even fairly simple f-speciﬁcations such as transitive closure of database relations. It also does not seem to be the best language for representing defaults, epistemic statements, and other types of “common sense” knowledge. These observations are well known and led to various extensions of FOL which allow nonmonotonic reasoning. Our preference for a less powerful A-Prolog is similar to our preference of Modula 2 over ADA. Since, as was shown in [7,22], programs of A-Prolog can be viewed as theories of Reiter’s default logic [40], we hope that those who prefer power over simplicity can still beneﬁt from this work. The next question to answer is “Why not to use the language of logic programming during the ﬁrst stage of the development process?” What are the advantages of ﬁrst formulating the problem in terms of functhe purposes of this paper. Description of such a meta-interpreter build on top of SLDNF of Prolog can be found in section 4. For more complicated programs, especially for those which have multiple stable models, this interpreter will go into a loop or answer unknown to too many interesting queries. Roughly speaking this happens because Prolog and XSB do not allow reasoning by cases. This type of reasoning is incorporated in a more powerful system, called SLG [9], which was successfully used to answer queries in the presence of multiple stable models. A different type of engine, [11,17,36], are based on algorithms for computing stable models of programs without function symbols.

we want to mention that in this paper we are mainly interested in the ﬁrst two stages of the development process.) We start with specifying the problem in terms of functional speciﬁcations. The ﬁrst advantage of the language of f-speciﬁcations over A-Prolog is its simplicity. and give a realization theorem for it. we discuss one more knowledge representation problem deﬁned in terms of another speciﬁcation constructor. and the corresponding realization theorems. Somewhat surprisingly. (These theorems were stated in [20] without proofs. interpolation and domain completion. and hence their proofs are included in this paper. and showing that this program can be correctly executed by the Prolog interpreter.) The paper is organized as follows. Finally. In the next section we give a ﬁrst example of applying our methodology to solving a knowledge representation problem associated with a simple type of taxonomic hierarchy. Gelfond. [14]). . in the last section. called input extension. The knowledge representation problem discussed in this section assumes completeness of knowledge. Logic programs In this section we give a brief introduction to the answer set semantics for logic programs with two kinds of negation [23]. The speciﬁer involved at the ﬁrst stage of the process does not need to know anything about the semantics of A-Prolog. called incremental extension. however.168 M. proposition 13.) Finally. its decomposition into two simpler constructors. The new speciﬁcation is obtained from the original one by applying a speciﬁcation constructor called input opening. by way of example. 3 For programs without classical negation the answer set semantics coincides with the stable model semantics of [21]. A. One of the main goals of this paper is to demonstrate. representing it by a declarative logic program. 2. In this sense our approach is complementary to the work on program development in Prolog (see. The construction of f requires knowledge of a simple set-theoretic notation together with deﬁnitions of a (hopefully small) collection of speciﬁcation constructors. We discuss the deﬁnition of this constructor. In the next section we consider the situation when this assumption is relaxed and our knowledge of some relations from the domain of the problem becomes incomplete. (This and other problems related to inheritance reasoning are commonly used to test strengths and weaknesses of various nonmonotonic formalisms. In the next two sections we review the answer set semantics of logic programs and the notions of f-speciﬁcation and lpfunction.3 For a more detailed discussion see [5.31]. (See. Another possible advantage of translating a natural language description of a problem into an f-speciﬁcation f is the ability to use the structure of f and the corresponding realization theorems for reducing the construction of πf to the construction of simpler programs. Gabaldon / Building a knowledge base: an example tional speciﬁcations? There are two reasons why we do that. for instance. In the process we introduce a speciﬁcation constructor. how this can be achieved. the resulting class of programs formalizes inheritance reasoning with incomplete information which was not previously considered.

lm }. By l we denote a literal contrary to l. . object constants for each type τ (obj(τ . . . . A. σ2 ). We say that π’s answer to a query l ∈ lit(σ(π)) is yes if π | l. . . σ)). is determined by its signature σ. . . . atoms(P . func(σ1 ) ⊆ func(σ2 ). or “strong” negation. . . like a typed ﬁrst-order language. . Consistent sets of ground literals over signature σ are called states of σ and denoted by states(σ). Variables will be denoted by capital letters. . positive literals (or atoms) have the form p(t1 . . The corresponding signature will be denoted by σ(π). . (1) where n 0. ln }. σ = σ1 ∪ σ2 if elements of σ are unions of the corresponding elements of σ1 and σ2 . respectively. li ’s are literals and not is a logical connective called negation as failure [12. not li . tn ) are called contrary. not ln . Terms are built as in the corresponding typed ﬁrst-order language.39]. Gabaldon / Building a knowledge base: an example 169 The language of a logic program. and for each type τ which belongs to both signatures. for pos and neg. . σ) (lit(P . tn ). atoms(σ) and lit(σ). . Under this semantics the rule (1) can be viewed as a constraint on such beliefs and is read as “if literals l1 . . σ1 ) = obj(τ . . . or “explicit”. . A pair {σ. l is false in S if l ∈ S. Literals and terms not containing variables are called ground. . head(π) = r∈π head(r). and typed function and predicate constants (func(σ) and pred(σ). σ)) will denote the sets of ground atoms (literals) of σ formed with predicate symbols from P . tn ). negative literals are of the form ¬p(t1 . . = To give a deﬁnition of answer sets of logic programs. not lm+1 . lm are believed to be true and there is no reason to believe that literals lm+1 . . . where t’s are terms of proper types and p is a predicate symbol of arity n. .M. not li+k will be denoted by not({li . li+k }). . . . . . We say that literal l ∈ lit(σ(π)) is true in an = answer set S of π if l ∈ S. pred(σ1 ) ⊆ pred(σ2 ). . The sets of all ground terms. tn ) and ¬p(t1 . atoms and literals over σ will be denoted by terms(σ). = no if π | l. .) If r is a rule of type (1) then head(r) = {l0 }. . . π} where σ is a signature and π is a collection of rules over σ is called a logic program. . . π entails l (π | l) if l is true in all answer sets of π. (We often denote such pairs by their second element π. Signature σ1 is a sub-signature of signature σ2 if types(σ1 ) ⊆ types(σ2 ). neg(r) = {lm+1 . Sometimes. (Logical connective ¬ in the context of logic programming is called “classical”. . respectively). The answer set semantics of a logic program π assigns to π a collection of answer sets – sets of ground literals over signature σ(π) of π corresponding to beliefs which can be built by a rational reasoner on the basis of rules of π. .) Literals of the form p(t1 . . . Similarly. For a set P of predicate symbols from σ. lm . . we assume that l’s in rule (1) are ground. . pos(r) = {l1 . . Gelfond. consisting of types (types(σ)). Unless otherwise stated. . . and unknown otherwise. Rules with variables will be used as a shorthand for the sets of their ground instantiations. let us ﬁrst consider programs without negation as failure. obj(τ . . . A rule is an expression of the form l0 ← l1 . ln are true then the reasoner must believe l0 ”. . For any program π.

base(π1 . Whenever possible the reference to U will be omitted. q(b) ← not q(a). pos(r) ∪ neg(r) ⊆ U whenever head(r) ∈ U . A consistent set of literals is an answer set of π iff it can be represented in the form S1 ∪ S2 . Let U be a splitting set of a program π. We conclude our short introduction by presenting a theorem useful for computing the set of consequences of logic programs. (2) replacing the body of each remaining rule r by pos(r) \ U ∪ not(neg(r) \ U ). 4 A set of literals is consistent if it does not contain contrary literals.170 M. [32]). . if l1 . Gelfond.4 It is not difﬁcult to show that any answer set of a consistent program is consistent. then S = lit(σ(π)). In other words. . by red(π. . If this answer set coincides with S. • Now let π be an arbitrary logic program without variables. Theorem 1 (Splitting set theorem. It can easily be shown that every program π that does not contain negation as failure has a unique answer set. then we say that S is an answer set of π. . Let U be a splitting set of a program π. . . Then U = {q(a). lm ∈ S. where S1 is an answer set of base(π. and (ii) all occurrences of not l in the bodies of the remaining rules. r(a) ← q(a). for every rule r of π. Gabaldon / Building a knowledge base: an example • The answer set of a program π not containing negation as failure not is the smallest (in the sense of set-theoretic inclusion) subset S of lit(σ(π)) such that (i) for any rule l0 ← l1 . and hence its answer set is already deﬁned. (2) A logic program is said to be consistent if it has a consistent answer set. If U splits π then the set of rules in π whose heads belong to U will be called the base of π (relative to U ). . The rest of the program (called the top of π) will be denoted by top(π. U ) by (1) deleting each rule r such that pos(r) ∩ (U \ V ) = ∅ or neg(r) ∩ V = ∅. For any set S of literals. Clearly. Consider for instance a program π1 consisting of the rules q(a) ← not q(b). U ). This process can be sometimes simpliﬁed by “splitting” the program into parts. We say that a set U of literals splits a program π if. U ) consists of the last two. We denote the base of π by base(π. (ii) if S contains a pair of contrary literals. π S does not contain not. U ). . U ) and S2 is an answer set of red(π. then l0 ∈ S. For any set V ⊆ U . lm from π. V ) we denote the program obtained from top(π. S1 ). U ) consists of the ﬁrst two rules while top(π1 . which will be denoted by ans(π). r(a) ← q(b). . let π S be the logic program obtained from π by deleting (i) each rule that has an occurrence of not l in its body with l ∈ S. the answer sets of π are characterized by the equation S = ans π S . A. q(b)} is a splitting set of π1 .

r(a)}. In the context of logic programming. First ﬁnd all the answer sets of the program base(π. Use unary predicate constants faculty and phd. For each such set S1 . Gabaldon / Building a knowledge base: an example 171 The theorem suggests the following approach to computing consistent answer sets of a program π which is split by some set U . and ﬁnd all its answer sets. S1 ). the states of σo are called output states. the splitting set theorem and its generalizations ﬁrst appeared in [32]. compute the program red(π. 5 This view is common in databases where one of the most important knowledge representation problems consists in deﬁning new relations (views) in terms of basic relations stored in the database tables. Gelfond. For each such set S2 form a union S1 ∪ S2 .5 The following example shows how a simple knowledge representation problem can be reﬁned in terms of f-speciﬁcations. Then the program q(a) ← not q(b). The states of σi are called input states. f (X) contains all we may know about deﬁned relations given an input state X. U ). dom(f ) will denote the domain of f . . for instance. S1 ) = red(π1 . F-speciﬁcations and lp-functions In some cases a knowledge representation problem consists in representing a (possibly partial) deﬁnition of new relations between objects of the problem domain which is given in terms of previously known relations between these objects. q(b) ← not q(a) is the base of π1 with respect to U . It has answer sets S1 = {q(a)} and S2 = {q(b)}. given relations. A. Unlike our case however databases normally assume the close world assumption and hence only need to represent positive information. by the splitting set theorem. Given a complete list of faculty your formalization should entail all the available information about PhD degrees of people from this list. Such a deﬁnition can be mathematically described as a function f which maps states of an input signature σi into the states of an output signature σo . As a result. We follow [25] and call a triple consisting of such a function f together with input and output signatures σi (f ) and σo (f ) a functional speciﬁcation. The corresponding reducts are red(π1 . views can be viewed as functions from sets of atoms to sets of atoms. Similarly. They contain all the currently available information about the old. The consistent unions found in this way are the consistent answer sets of π. 3. Similar results for autoepistemic logic can be found in [25]. Example 2. Consider the following informal speciﬁcation of a knowledge representation problem: • Formalize the assertion “x has a PhD iff x is a faculty”. the answer sets of π1 are {q(a). Consider. program π1 above. S2 ) = r(a) ← and. r(a)} and {q(b).M.

function g0 is deﬁned on sets of ground atoms of σi : / g0 (X) = phd(c): faculty(c) ∈ X ∪ ¬phd(c): faculty(c) ∈ X . Gelfond. as in example 2. for any X ∈ dom(f0 ) f0 (X) = phd(c): faculty(c) ∈ X ∪ ¬phd(c): ¬faculty(c) ∈ X . Function f0 is deﬁned on complete states of σi . Assume that the language of our domain is determined. mike. σi (π). • output signature σo consisting of the same individual names and a unary predicate symbol phd. 6 A set X of literals over signature σ is called complete if for any l ∈ lit(σ). For instance. A. Example 3. the available information about faculty can be incomplete. unlike that example. In general. To further reﬁne the above f-speciﬁcations we will use the notion of lp-function from [6]. say. Now let us look at a slightly different informal speciﬁcation. the above speciﬁcation is slightly ambiguous. Similarly. dom(π)} where (1) π is a logic program (with some signature σ(π)). A four-tuple π = {π. The speciﬁcations have the same signatures: • input signature σi consisting of individual names.172 M. John is not. It is ˜ easy to see that f0 computes all possible information about PhD degrees which can be obtained from X and f0 . ¬faculty(john)}. We look at two different representations of this list deﬁned by two f-speciﬁcations f0 and g0 . Notice that the new speciﬁcation is deﬁned in terms of f0 and can be viewed as an interpolation of function f0 from complete to all input states (see section 5 for more details). σo (π). Gabaldon / Building a knowledge base: an example Despite its simplicity. Its possible reﬁnements may depend on the form of representation of a “complete list of faculty”.6 Obviously. by signatures σi and σo but. Making an early distinction between these two speciﬁcations of our informal problem helps to eliminate possible difﬁculties which may appear later in the development process. l ∈ X or l ∈ X. the input of the corresponding ˜ ˜ f-speciﬁcation f0 consists of (possibly incomplete) states of σi and f0 can be deﬁned as follows: ˜ f0 X f0 (X) = X∈c(X) where c(X) is the set of all complete supersets of X from dom(f0 ). This can be represented by an incomplete set of literals {faculty(mike). we may know that Mike is a faculty. john and mary and a unary relation symbol faculty. Deﬁnition 4. but have no relevant information about Mary. .

incomplete inputs. (3) dom(π) ⊆ states(σi (π)) is called lp-function if for any X ∈ dom(π) program π ∪ X is consistent. i. ¬phd(P ) ← ¬faculty(P ). ¬phd(P ) ← not faculty(P ). A.. Example 5. by considering only ground queries we limit ourselves to a very restricted notion of computability of lp-function f by inference engine E. and predicate symbols of σi (f0 ) and predicate symbol phd and the rules: phd(P ) ← faculty(P ). the change of speciﬁcation from f0 to f0 does not require any changes in πf0 . no if l ∈ π(X). and modifying our program . For any X ∈ dom(π).M. This again can be remedied by introducing types like person. An alternative representation π (f0 ) can also be given by replacing the rules of πf0 by the rules phd(P ) ← faculty(P ).e. One can show that the lp-function πf0 whose rules are those of πf0 and signatures and domain are those of ˜ ˜ ˜ f0 . Gelfond. We say that an lp-function π represents an f-speciﬁcation f if π and f have the same input and output signatures and domain and for any X ∈ dom(f ). E(π ∪ X. represents f0 . degree. etc.e. f (X) = π(X). Since all the lp-functions above are (efﬁciently) computable by a slight modiﬁcation of the Prolog interpreter the reﬁnement process stops here. π ∪ X | l . It can of course be extended to allow queries from σo (f ) with variables but then the function πg0 will stop being computable due to ﬂoundering. has a consistent answer set.7 7 Of course. respectively. Gabaldon / Building a knowledge base: an example 173 (2) σi (π). σo (π) are sub-signatures of σ(π) called input and output signatures of π. i. This is certainly not the case for the second representation of f0 .. objects. ˜ Now let us consider f-speciﬁcation f0 from example 3. It is easy to show that f-speciﬁcation f0 from example 2 can be represented by lp-function πf0 with signature σ consisting of types. = π(X) = l: l ∈ lit σo (π) . l) returns yes if l ∈ π(X). πf0 It is also easy to see that the restriction πg0 of πf0 on the dom(g0 ) is an lp-function representing g0 . πf0 def The input and output signatures of πf0 are the same as those of f0 and dom(πf0 ) = dom(f0 ). We will say that an lp-function π is computable by E if for any query l ∈ lit(σo ) and any X ∈ dom(π). This means that πf0 is elaboration tolerant with respect to allowing ˜ new. πf0 is superior to πf0 . Let E be an inference engine which takes as an input a logic program π and a ground literal l.. In this sense. and unknown otherwise.

Consider an lp-function π2 with input signature σi = {{a. An lp-function π is called monotonic if for any X. If a program has a signing. . . For the sake of readability we will only consider ground queries. two different semantics of logic programs coincide. who used it as a tool in his proof that. . . 2.44]. π(X) ⊆ π(Y ). . Signed programs enjoy several important properties which make them attractive from the standpoint of knowledge representation. programs without negation as failure are signed with an empty signing. .174 M. |l|) is l if l is positive. . Gelfond. and l otherwise. b. In particular: 1. |ln | ∈ S. Signed programs without explicit negation are consistent. for a certain class of programs. π 2 ab(X) ← not ¬r(X). {q}}. |lm | ∈ S. accordingly or by using a query answering system with constructive negation [8. . . A. A signing of π is a set S ⊆ atoms(σ) such that (1) for any rule (1) from π. Gabaldon / Building a knowledge base: an example To complete this section we give several deﬁnitions and results which proved to be useful for reasoning about lp-functions. |lm+1 |. not ab(X). / (2) for any atom l ∈ S. we say that it is signed [29. b. |lm+1 |. . ¬l does not appear in π. r}}. Theorem 7 (Monotonicity theorem. . output signature σo = {{a. . The notion of signing for ﬁnite logic programs without classical negation was introduced by Kunen [29]. Y from dom(π) such that X ⊆ Y . Obviously. . . . Notice this result shows that interpreters. . c}. such as XSB. The absolute value of a literal l (symbolically. We will however be especially interested in the following monotonicity theorem. |ln | ∈ S or / |l0 |. Turner in [44] extends the deﬁnition to the class of logic programs with two kinds of negation.46].38]. which compute the well founded semantics of logic programs. This is a special case of a more general theorem by Fages [19]. This result is a special case of a substantially more general result from [45]. Example 8. If π is signed and consistent then the set of consequences of the program under the answer set semantics coincides with its set of consequences under the wellfounded semantics [37. Deﬁnition 6. ¬q(X) ← r(X). can also be used to compute the consequences of such programs under the answer set semantics. . Turner). either |l0 |. c}. {p. dom(π2 ) = states(σi ) and logic program π2 consisting of the following rules: q(X) ← p(X). Let π be a logic program with signature σ. If an lp-function π has a signing S such that S ∩ (lit(σi ) ∪ lit(σo )) = ∅ then π is monotonic. |lm | ∈ S.

Gelfond. . and d to denote objects. We use (possibly indexed) letters o. The problem of specifying and representing is-nets is commonly used to test strengths and weaknesses of various nonmonotonic formalisms. The latter represent defaults: “elements of class c normally satisfy (do not satisfy) property p”. we illustrate the notions of functional speciﬁcation and lp-function by using them to solve a knowledge representation problem associated with a simple type of taxonomic hierarchy. Logic programming approaches to this problem (which assume completeness of its domain) can be found in [1. There are many knowledge representation problems which can be associated with a net N . c5 are classes and p is a property. An is-net N can be viewed as a combination of graphs Ns and Nd where Ns describes the (proper) subclass relation between classes and Nd consists of positive and negative defeasible links connecting classes with properties.33]. . classes. Here c1 . and hence π2 is monotonic. We denote the resulting graph Figure 1. properties and defaults respectively. . An example: is-nets on closed domains In this section. The addition of extra rules (or facts) about ab can force us to withdraw previous conclusions about q. .M. called is-nets. A simple taxonomic hierarchy. As usual we assume that Ns is acyclic and that a class c and a property p can be connected by at most one link. Links from c5 to p and from c4 to p represent positive and negative defaults while the other links represent the subclass relationship. p. Gabaldon / Building a knowledge base: an example 175 It is easy to see that lp-function π2 has a signing consisting of atoms formed by predicate ab. The signing satisﬁes the condition of theorem 7. . We start with the simplest one. It is worth noticing that π2 considered as a logic program is nonmonotonic. Figure 1(a) gives a pictorial representation of a net. A. c. Modiﬁcations of this example will be used throughout the rest of the paper. when N is viewed as an informal speciﬁcation of a function fN which takes as an input the links of N together with a collection I of positive links from objects to classes (see ﬁgure 1(b)). Monotonicity is however preserved for inputs from σi . 4.

c. subclass} while pred(σo (fi )) = {is}. τc . fi returns the complete set of is-literals representing the membership relation deﬁned by the input. Input and output signatures of fi have object constants of two types. A. we call fN a closed domain speciﬁcation of N . formed by the predicate symbol subclass. Accordingly. and τp . (b) An f-speciﬁcation fi takes as an input a complete set of subclass-literals (representing transitive and asymmetric relations subclass) together with the set I of atoms is0 (o.) A set I of links from objects to classes will be identiﬁed with the collection of the corresponding statements of the form is0 (o. input and output signatures of fs have the same object constants of the type τc . In what follows we will be interested in applying our methodology for providing a rigorous speciﬁcation of this function and for ﬁnding its logic programming representation. pred(σi (fi )) = {is0 . (c) We also need a more complex f-speciﬁcation fd deﬁned as follows: 8 is(o. . both. Specifying the problem We start by playing the role of a speciﬁer and give a precise deﬁnition of function fN using the language of f-speciﬁcations. τo and τc .8 Our ability to represent an input of fN by positive links only is justiﬁed by our assumption that. respectively. we ﬁrst ﬁx three collections of object constants for objects. (The last parameter in default is used to distinguish positive and negative links. is and has which a rational agent can obtain from this net. The corresponding types will be denoted by τo . and default(d. To this goal. p. deﬁning the transitive closure of the input. Gabaldon / Building a knowledge base: an example by N (I) and assume that for any object o and class c from N (I). c2 ). the function fN computes all possible conclusions about relations subclass. Given N (I).1. default(d. Similarly. p) means that “object o has property p”. +). c). c) representing links from objects to classes. Later we consider more complex knowledge representation problems which can also be associated with N . cj ) where ci . o is an element of c iff N (I) contains a path from o to c. −) which correspond to the links of these graphs. the net N (I) contains complete information about relations is and subclass. has(o. c. and predicate symbols subclass0 and subclass. fi and fd : (a) An f-speciﬁcation fs will take as an input a net Ns – a collection of atoms subclass0 (ci .176 M. c1 is a (proper) subclass of c2 iff there is a path from c1 to c2 . classes and properties of the nets. Next we identify graphs Ns and Nd with the collection of literals of the form subclass0 (c1 . at least with respect to objects included in N (I). Function fN will be constructed as a combination of three simpler functions fs . Constants of the fourth type (τd ) will be used to name the nets default links. Gelfond. 4. Both predicates are typed. p. c) stands for “object o is an element of class c”. cj are classes connected by a link of Ns and return the complete set of literals.

has. c1 . c2 ). subclass0 . A set X ∈ states(σ) satisﬁes the constraint ← ∆ if ∆ ⊆ X. 9 . +). −) ∈ X.10 A constraint is a rule of the form ← ∆ where ∆ is a list of literals from some signature σ. p) ∈ fd (X) iff there are d1 and c1 such that (i) default(d1 . +) ∈ X. τd and predicate symbols is0 . and τd and predicate symbols is. has(o. • dom(fd ) consists of states of σi (fd ) which are complete with respect to is and subclass and satisfy the constraints:9 ← is(o. τp and predicate symbols subclass. p. The resulting speciﬁcation will be isomorphic to fN and used when convenient. subclass(c1 . • For any X ∈ dom(fd ). ¬is(o. (ii) is(o. (iii) for any default(d2 . c1 ). (d) To complete the construction of fN we will need the following notation: for any α ⊆ pred(σ) and X ⊂ lit(σ) by [X]α we denote the set of literals from X formed by predicate symbols from α. c2 ) ∈ X. τc . c. c1 ) ∈ X. • the output signature of fN consists of objects constants of the types τo . A. −). The output signature σo (fd ) consists of object constants of the types τo and τp and predicate symbol has. Gelfond. X satisﬁes a collection C of constraints if it satisﬁes every constraint in C.M. ¬is(o. c2 ). p. • dom(fN ) = {X: X ⊆ atoms(σi (fN ))}. Similarly for ¬has(o. This condition corresponds to the Inheritance Principle [43] which says that more speciﬁc defaults override less speciﬁc ones. Gabaldon / Building a knowledge base: an example 177 • The input signature σi (fd ) of fd consists of object constants of three types. subclass. p. default(d. is. τc . τo . and default. c. 10 The domain of fN can be alternatively represented by complete sets of literals of σi (fN ). c). ← default(d. p. Now the f-speciﬁcation fN will be deﬁned as follows: • the input signature of fN consists of object constants of the types τo . c2 . default. p). τc . c2 ) ∈ X or subclass(c1 . ← subclass(c.

is. and has. fs and fi by a speciﬁcation constructor called incremental extension [26]. (4) f ◦ g(X) = f ([X]pred(σi (f ))\pred(σo (g)) ∪ g([X]pred(σi (g)) )) ∪ g([X]pred(σi (g)) ). . (Recall that we will only be interested in getting answers to ground queries formed by predicates subclass. (3) X ∈ dom(f ◦ g) if [X]pred(σi (g)) ∈ dom(g) and [X]pred(σi (f ))\pred(σo (g)) ∪ g([X]pred(σi (g)) ) ∈ dom(f ).e. A. It is easy to see that the deﬁnition of fN above can be rewritten as fN = fd ◦ (fi ◦ fs ). 4.11 For simplicity we only consider signatures which agree on their common types.2. Deﬁnition 9. σ2 ).) According to our methodology. i. The f-speciﬁcation f ◦ g is called the incremental extension of g by f if it satisﬁes the following conditions: (1) σi (f ◦ g) = σi (g) ∪ σi (f ). In particular. fN (X) = Y0 (X) ∪ Y1 (X) ∪ Y2 (X). (2) σo (f ◦ g) = σo (g) ∪ σo (f ). Gabaldon / Building a knowledge base: an example • fN is deﬁned by combining functions fs . Note that this deﬁnition does not require any sophisticated mathematics. σ1 ) = obj(τ . who just received the above deﬁnition of fN and is confronted with the task of building a computable lp-function representing fN . it presupposes no knowledge of logic programming. Building the declarative representation Now let us assume the role of an implementor. we will ﬁrst ignore the computability requirement and concentrate on correctness of our representation viewed as a declarative logic program. Gelfond. 11 (3) The deﬁnition we give in this paper actually extends that in [26]. It is worth noticing that we can view fN as being constructed from f-speciﬁcations fd ..178 M. Since this fact will be useful later in our search for an lp-function representing fN we recall the corresponding deﬁnition. if τ ∈ σ1 ∩ σ2 then obj(τ . Y2 (X) = fd Y0 (X) ∪ Y1 (X) ∪ [X]default . Y1 (X) = fi Y0 (X) ∪ [X]is0 . fi and fd as follows: Y0 (X) = fs [X]subclass0 .

g represented by lp-functions πf and πg such that πf ∪ πg does not represent f ◦ g. C2 ) ← not subclass(C1 . C). C3 ). A1 ∩ lit(σo (πg )) = A2 ∩ lit(σo (πg )). C2 ). Since Ns is acyclic.M.. this is not always the case. dom(f ◦ g)} is an lp-function representing f ◦ g if πf and πg satisfy the following conditions: (1) for any X ∈ dom(πg ) and any answer sets A1 and A2 of πg ∪ X. C2 ). (2) lit(σ(πf )) ∩ lit(σ(πg )) ⊆ lit(σo (πg )). and let πf ◦g = πf ∪ πg . Note that this deﬁnition is applicable to programs with and without variables. σi (f ◦ g). is(O. there are f-speciﬁcations f . respectively. C). C2 ). Gelfond. C1 ). Let f and g be f-speciﬁcations represented by lp-functions πf and πg . Gabaldon / Building a knowledge base: an example 179 We start with a representation for fs . C) ← is0 (O. Theorem 10 (Realization theorem for incremental extension). It is easy to see that functions πi and πs deﬁned above satisfy the conditions of the theorem. subclass(C1 . The following realization theorem (which is a slight modiﬁcation of a similar theorem from [25]) is useful for eliminating this possibility. C2 ). . In our next step we need to ﬁnd a representation πfi ◦fs of the speciﬁcation fi ◦ fs . C) ← not is(O. It is equally easy to show that fi can be represented by an lp-function is(O. A. it is easy to show that fs can be represented by the program πs : subclass(C1 . As was shown in [25]. ¬subclass(C1 . σo (f ◦ g). For simple lp-functions like πi and πs we can directly check that this can be done by combining the rules of πi and πs .12 A 4-tuple πf ◦g = {πf ◦g . 12 Recall that π = π1 ∪ π2 if σ(π) = σ(π1 ) ∪ σ(π2 ) and the rules of πf ◦g consist of rules of πf and πg . π s subclass(C3 . πi subclass(C1 . which justiﬁes our construction. (3) head(πf ) ∩ lit(σ(πg )) = ∅. however. C2 ) ← subclass0 (C1 .e. C2 ) ← subclass0 (C1 . i. C2 ) ← is0 (O. ¬is(O.

similarly for negative defaults. / / c1 = c2 . c2 ) ∈ A or subclass(c2 . C. +). +) ← default(D1 . P . A program πd ∪X can be viewed as a logic program Π without classical negation in a language which contains new predicate symbols ¬is.e. not subclass(C. c2 . −) ∈ A. for instance. c1 ) ∈ A. c2 ) ∈ A. P . c1 . p). ¬has(X. Since a class c and property p can be connected by at most one link. we need to show that there are no rules r1 and r2 with the heads has(o. not exceptional(X. C. E). is(X. D. d not subclass(C. +). p) whose bodies are satisﬁed by A. −). . ¬has. We would like πd to be viewed as an lp-function whose input and output signatures are the same as those of fd and whose domain is dom(fd ). A is also the unique answer set of πd ∪ X iff A does not contain contrary literals. subclass(c1 . d. D. P ) ← default(D. −) is also in A. −) ← default(D1 . S).. exception(E. C. Proof (sketch). exceptional(x. is(x. C. P ) ← default(D. C). not exceptional(X. S) ← exception(E. −). at least one of the rules r1 . P . P . the statement exceptional(o. For any X ∈ dom(fd ). d2 . Therefore. Suppose that there are c1 and c2 such that default(d1 . Now we can show correctness of our construction. is(X. default(d2 ..180 M. D. D.e. P . The program uses a standard logic programming representation of defaults and their exceptions (see. c1 ) ∈ A and is(x. +). D1 . E). ¬has(o. E). d. −). As shown in [22]. program πd ∪ X is consistent. d1 . is(X. P . p. Gabaldon / Building a knowledge base: an example To continue our search for an lp-function representing the speciﬁcation fN we need to ﬁnd a representation of fd . +). A. i. p. [5]). default(D2 . The signature of this program is obtained from σfd by adding predicate constants exception and exceptional. Since literal l belongs to an answer set A of a program Π (not containing classical negation) iff there is a rule in Π whose head is l and whose body is satisﬁed by A [34]. −). i. +) states that “the positive default d is not applicable to the object o of the domain”. r2 has a body which is not satisﬁed by A. we need the following: Proposition 11. Since the net Ns is acyclic. E. exception(E. +) or exceptional(x. exceptional(X. π default(D2 . E. D1 . The statement exception(e. Gelfond. +) reads as “the positive default d is not applicable to elements of the class e”. This program is stratiﬁed [2] and has therefore a unique answer set A [21]. ¬subclass. To this goal let us consider a program πd : has(X. C). +) ∈ A.

Gabaldon / Building a knowledge base: an example 181 Proposition 12. +). c1 ) ∈ A iff / there are literals default(d1 .M. p. Let us start by listing the questions which need to be addressed to prove this proposition. if yes is the answer to the second query. c1 ) ∈ A and exceptional(o.3. p. has(o. This may happen because of the absence of the occur-check which. c1 ) ∈ X and for any default(d2 . To complete our search for a representation of fN we use the construction from theorem 10.e. A returns no. dom(fN )} where πfN = πs ∪ πi ∪ πd represents fN . A makes two calls to the Prolog interpreter. Since a literal l belongs to a consistent answer set A of the program iff there is a rule with l in the head whose body is satisﬁed by A. . Answering queries Now we are ready for the implementation stage of our design. Proof (sketch). the meta-interpreter A returns yes. i. Gelfond. we have that has(o. p) ∈ πd (X) iff has(o. . This stage crucially depends on the choice of inference engine we use to answer queries to πfN . c1 . If the ﬁrst query is answered yes. The resulting program can be viewed as a Prolog program with variables. Proposition 13. is(o. If q is an atom. is(o. p) ∈ f (X). c2 ) ∈ X and therefore. for any X ∈ dom(fd ). πd (X) = fd (X). d1 . +) ∈ A. c2 ) ∈ X or subclass(c1 . Second. To do that we must ﬁrst replace all occurrences of negative literals ¬p(t1 . or because the interpreter may ﬂounder. is(o.. . i. Since X is complete. A. for some programs. Proof (sketch). π. This happens iff default(d1 . is(o. . We consider an inference engine A deﬁned as a simple meta-interpreter which takes a query q and a program π as an input. otherwise the answer is unknown. The meta-interpreter is deﬁned for programs which do not entail q and ¬q (for any query q).. σi (fN ). in some cases. . . is necessary for soundness of the SLDNF resolution. . c2 ) ∈ Ns . the Prolog interpreter may produce unsound results. we base this engine on the Prolog interpreter. . −) ∈ Nd . p. one with parameters q and π and another with parameters nq. tn ). σo (fN ). c2 .e. Since Prolog is the most popular logic programming language to date. 4. c1 . Let us denote it by A. it is well known that. the interpreter (4) . Similarly. In the previous proof we showed that πd ∪ X has a unique consistent answer set. if q is a negative literal. may select for resolution a goal of the form not q where q contains an uninstantiated variable. Lp-function πd represents fd . The lp-function πfN is computable by A. A similar argument works for negative literals. tn ) in πfN by np(t1 . It is easy to see that programs πfi ◦fs and πd satisfy the conditions of the theorem and hence πfN = {πfN . c2 ) ∈ X iff / / ¬is(o. +) ∈ Nd . First.

Apt and Pellegrini in [4] showed that if a program π is well-moded with respect to some mode m and there is no rule in π whose head contains more than one occurrence of the same variable in its output positions then π is occur-check free with respect to any ground query. Otherwise it is called an output position. the interpreter which takes πfN ∪ X and q as an input terminates. . or in an output position of a literal from the body. the uniﬁcation algorithm used by Prolog interpreters never selects a step requiring the occur-check. −) A rule r of a program π is called well-moded with respect to a mode m if: (i) Every variable occurring in an input position of a literal l from the body of r occurs either in an input position of the head or in an output position of some literal from the body that precedes l. (a) We show that for any X ∈ dom(πfN ) and query q ∈ lit(σo (fN )) the program πfN ∪ X ∪ {← q} is occur-check free. −. +) ¬has(+. A program π is well-moded with respect to m if all its rules are.e. does not ﬂounder. Even if we show that for any X ∈ dom(fN ) and ground query q. −. It is not difﬁcult to check that the program πfN ∪ X is well-moded with respect to mode m0 . (ii) Every variable occurring in an output position of the head occurs in an input position of the head. +) exception(−. In what follows we brieﬂy discuss how these questions can be addressed. +) ¬is(+. +) default(−. −.. Gelfond. Gabaldon / Building a knowledge base: an example may fail to terminate. then i is called an input position. i.e. A. +) ¬subclass(+. i. −) subclass(+.182 M. the grounding of πfN by terms of signature σu obtained from signature σ(fN ) by removing types and type information. If the parameter in a position i of p is assigned +. +) subclass0 (−. and does not require the occur-check. The mode m0 satisﬁes these conditions and therefore answering query q to πfN ∪ X does not require the occur-check. −) is0 (−. +. In our further discussion we need the following mode m0 of the program πfN : has(+. −) is(+. +) exceptional(+. To prove this we need a notion of mode [13] – a function assigning + or − to each parameter of a predicate symbol p from the language of program π. the soundness of our result is guaranteed only with respect to the unsorted grounding of πfN ..

σu (fN )) ∪ X | q iff gr(πfN . 5. σu (fN )) ∪ X | q. Pictorially. (Notice that here we use is instead of is0 which was used in the previous speciﬁcation. It is easy to check that πfN ∪ X is acceptable.) Obviously.M. (d) Let gr(π. the input to a net will be represented by positive and negative links from objects to classes (see ﬁgure 1(c)). the mode m0 satisﬁes this property. Gelfond. Gabaldon / Building a knowledge base: an example 183 (b) To prove that a query q ∈ lit(σo (fN )) to πfN ∪ X does not ﬂounder we use another theorem from [4. given a query q ∈ lit(σo (fN )) and the program πfN ∪ X. subclass and is. σ) denote the set of all ground instantiations of π by ground terms of σ. Opening closed domain speciﬁcations In this section we introduce another knowledge representation problem associated with is-nets and demonstrate how a speciﬁcation constructor. The predicate-orderconsistency of this program follows immediately from the absence of function symbols and the absence of negative edges from a predicate symbol to itself in the dependency graph of πfN . c) and ¬is(o. σ(fN )) ∪ X | q.42]: if program π is well-moded with respect to some mode assignment m and all predicate symbols occurring in π under not are moded completely by input then a ground query to π does not ﬂounder. In the process of development and modiﬁcation of the system this assumption may become too strong and the speciﬁer may decide to limit it to some of the relations or even to completely remove it from the speciﬁcation. called input opening. Specifying the problem So far we have assumed that net N (I) contains complete information about relations default. Again. The notion of stability is based on the program having a mode satisfying certain properties. c). In [35] McCain and Turner showed that to guarantee this property we need to check that πfN is stable and predicate-order-consistent. From soundness of SLDNF resolution with respect to stable model semantics of logic programs we can now conclude that. These links will be recorded by literals of the form is(o. the Prolog interpreter answers yes iff gr(πfN .1. (c) The termination of πfN ∪ X follows from [3] where the authors gave a notion of acceptable program and proved that for such programs the Prolog interpreter terminates on ground queries. This change is not essential and is done only to simplify the presentation. = = = We need to show that gr(πfN . not any collection I of such links is consistent with our . In this section we will consider a case when information about defaults and subclasses is still complete but information about the membership relation can be incomplete. 5. can be used to specify and represent this problem. It is easy to check that the mode m0 deﬁned above satisﬁes these conditions. From (a) and (b) we can conclude that if the Prolog interpreter terminates on query q to program π then there is an SLDNF resolution derivation of q from π. A.

Gelfond. c3 )} is not. To deﬁne this constructor we ﬁrst need the following terminology. X). / (ii) X satisﬁes the constraint (5). c1 ). σo f α = σi (f ) ∪ σo (f ). For instance. An f-speciﬁcation f deﬁned on a collection of complete states of σi (f ) is called closed domain speciﬁcation. A. (5) ◦ Now the net N can be viewed as an informal speciﬁcation of the function fN which takes as an input the links of N together with I ∈ lit(is) and returns all conclusions about relations subclass. X is called a D-cover of X. c1 ). The set of all D-consistent α-states of σ is called the α-interior of D and is denoted by Dα . To ensure consistency I must not contain contrary literals. The set of all α-states of σ will be denoted by α-states(σ). c2 ). Let f be a closed domain speciﬁcation with domain D and α ⊆ pred(σ(f )). Let D be a collection of states over some signature σ and let α ⊆ pred(σ). The set of all D-covers of a set X is denoted by c(D. Predicates from α are called open.default = N ∪ N . An f-speciﬁcation f α is called the input opening of f with respect to α if σi f α = σi (f ).) The problem is to precisely deﬁne the set of all such conclusions. is and has which a rational agent can obtain from N and I. c2 ). A state X of σ is called an α-state if for any l ∈ lit(pred(σ \ α)). subclass) ∧ l ∈ N . is(o2 . subclass(c1 . where N ⊆ atoms(default. ¬is(o. To do that we use the representation of N and functions fs and fd from the previous section. c1 ). (6) . l ∈ X or l ∈ X. c2 )} is D-consistent while N ∪ N ∪ {is(o1 . in our example the only open predicate of σi (fd ) will be is. Deﬁnition 14 (Input opening). A set X ∈ states(σ) is called D-consistent if there is X ∈ D such that X ⊆ X. c2 ). is(o2 .184 M. the other predicates from pred(σ) are called closed. ◦ (Such a function fN will be called the open domain speciﬁcation of N . D will be the set of all possible complete inputs X to fd such that (i) [X]subclass. ¬is(o2 . fd however needs to be modiﬁed since we do not necessarily have enough information to provide it with input complete with respect to is. To modify fd the speciﬁer may use a speciﬁcation constructor called input opening which removes the closed world assumption from (some or all) input predicates of a speciﬁcation. Function fs remains unchanged. Gabaldon / Building a knowledge base: an example interpretation of the net N . It is easy to see that for the net N from ﬁgure 1(c) the set N ∪ N ∪ {is(o1 . subclass) which represents the net N and N = ¬l: l ∈ atoms(default. and the is and subclass relations deﬁned by N (I) must satisfy the constraint: ← is(o.

c3 ). (11) This is a slight generalization of the notion of interpolation introduced in [6]. for instance. Let f be a closed domain f-speciﬁcation with domain D and α ⊆ pred(σi (f )). c5 ) is maximally informative with respect to the set of all complete input states of N . Gabaldon / Building a knowledge base: an example 185 dom f α = Dα . (8) f X ∪ X∈c(D. (10) Consider. is(o2 . . By D we denote the set of all α-states of σi (f ) which are ˜ maximally informative with respect to D. is(o2 . c2 ) is not. Let D be a collection of complete states over signature σ and α ⊆ pred(σ). c3 ). is(o1 . where the authors only considered interpolations of functions deﬁned by general logic programs. F-speciﬁcation f α with the same signatures as f and the domain D is called the interpolation of f if ˜ f α(X) = X∈c(D. Deﬁnition 15.X) (7) X. c5 ). Deﬁnition 17 (Domain completion). c1 ). To deﬁne these constructors we need the following deﬁnitions. while the set Ns ∪ N s ∪ is(o1 . Gelfond.M. is(o2 .X) fα X. A set X ∈ states(σ) is called maximally informative with respect to a set D ⊆ states(σ) if X is D-consistent and X= X∈c(D.X) f X . f α (X) = X∈c(D. c1 ). A. The set Ns ∪ N s ∪ is(o1 . the net N from ﬁgure 1(b). c2 ). The domain completion of D with respect to α is a ˜α function fD which maps D-consistent α-states of σ into their maximally informative supersets. (9) As was shown in [20] the input opening of f can be further decomposed using two simpler speciﬁcation constructors called interpolation and domain completion. Deﬁnition 16 (Interpolation).X) ◦ The open domain f-speciﬁcation fN of a net N can be deﬁned as ◦ α fN = fd ◦ fs . is(o1 . is(o2 .

We will be interested in representing the domain completion of D with respect to α. Gabaldon / Building a knowledge base: an example The following proposition follows almost immediately from the deﬁnitions. f α ◦ fD (X) = Y ∪ f α (Y ). l2 ← l1 .3. X∈c(D. 5. Gelfond. = = Notice that the set of constraints {← p. X ∈ dom(f α ) iff X ∈ Dα . by deﬁnition of domain completion.2. c(D. Γ ˜ by the rules l1 ← l2 . Proposition 18. q} (where p.e. By deﬁnition ˜ ˜ ˜ ˜ X∈D D D ˜α ˜ ˜ of incremental extension. Clearly. Domain completion Let C be a collection of constraints over signature σ. α ⊆ pred(σ). by deﬁnition of α . l2 ∈ lit(α) we mean the disjunction l1 ∨ l2 . f α (X) = f α ◦f α (X). ˜ ˜α f α = f α ◦ fD . Γ. f α (Y ) = ˜ ˜ ˜ f f (X). i. In the construction of these functions we ˜ ˜α will be aided by realization theorems for domain completions and interpolations. by d(C) we denote the set of disjunctive images of constraints from C.. By deﬁnition of f α and f α . By the disjunctive image d(c) of a binary constraint c =← l1 . q. Moreover. Finally. A. Realization theorems for domain completion and interpolation ◦ Equation (13) above suggests that a representation for fN can be constructed from lp-functions representing gα and gD . Y ) = c(D. (12) ˜α Proof. l2 . α = {is} and D = dom(fd ). 5. Γ (14) where l1 . A set C of binary constraints is said to be indeﬁnite if there is no l ∈ lit(σ) such that d(C) | l or d(C) | l. ← ¬p. ˜ ˜α (13) where g = fd . l2 . Such a representation is especially simple for constraints which are binary with respect to α. Y ∈ dom(f α ). πD ˜ .186 M.Y ) ˜ ˜ f (X). q ∈ α) is not indeﬁnite.X) D From proposition 18 and equation (9) we have that the open domain speciﬁcation ◦ fN can be given by equation ◦ fN = gα ◦ gD ◦ fs . Let α and Y = f α (X). First note that by deﬁnition of f α and fD . Γ. For any closed domain f-speciﬁcation f with domain D. X) and hence f α (Y ) = X∈c(D. Let πD be a program obtained from C by replacing each constraint ← l1 . and D be a collection of complete states of σ satisfying C. constraints whose bodies contain exactly two literals from lit(α).

If X ∈ Dα . Lemma 20. . Since Xi is closed ˜ under the rules. α ⊆ pred(σ) and D a collection of complete states of σ satisfying C. This implies that X is closed under the rules of πD . Proof. ˜ Proof. X is consistent. • Xi+1 is a proper subset of Xi . Then. X). A. Let l ← l . If C is indeﬁnite then a four-tuple {˜D .M. Let C be a collection of binary constraints over signature σ. Γ be any rule in ˜ πD and assume that Γ. For all X ∈ Dα . l1 is also in Xi and hence in A). Obviously. X). Since X ∈ Dα we have that c(D. By deﬁnition of πD there is a constraint ← l. for every i.X) X. ˜ • πD (X) ⊆ X∈c(D. Γ ˜ is a rule from πD and Γ. l2 ∈ A. then for every X ∈ c(D. ˜ Lemma 23. By deﬁnition of D. In the proof of this theorem. ˜ ˜ Lemma 22. Γ ∈ Xi . Gabaldon / Building a knowledge base: an example 187 Theorem 19 (Realization theorem for domain completion). X). there is no smaller set of literals closed under πD ∪ X. Dα } is an lp-function π ˜α which represents the domain completion fD of D. Corollary 21. For all X ∈ Dα . X) is not empty. Let X ∈ c(D. which contains X and is closed under the rules of πD . Γ ∈ C. l2 . A contains X and is closed under the rules of πD . πD (X) = X.e. l . l ∈ X. X is complete and satisﬁes the constraints from C. ˜ Let A = Xi . A is its only answer set. A is one of its answer sets. σ. Since our program ˜ does not contain negation as failure. X). Let X ∈ Dα . πD (X) ⊇ X∈c(D. By deﬁnition of c(D. Then for any X ∈ c(D. Gelfond.X) X. X) there is a set A ⊆ X which is the answer set of πD ∪ X. ˜ ˜ / Hence l ∈ X. The following corollary follows immediately from this lemma. X is complete and therefore l ∈ X. Consider a (possibly inﬁnite) sequence Xi of ˜ sets of literals such that • X0 = X.. i. we use the following lemmas. which appears below. By deﬁnition of c(D. • πD ∪ X is consistent. Thus to prove the lemma it only remains to show that X is closed under the rules of πD . (Suppose l1 ← l2 . σ.

Otherwise.X) X but l ∈ πD (X). If li ∈ P1 then. li ∈ P1 or li ∈ P2 . under this assumption. ˜ Now we will construct a set Z ∈ c(D. This implies that if li belongs to a constraint of C2 then li . Γ ⊆ A}. / we have that li ∈ X or li ∈ X and hence either li or li is in A. For li ∈ P2 completeness follows from the construction of B. li ∈ P2 and. i. interpretations of C2 can be viewed as complete and consistent sets of literals from P2 . by deﬁnition of P1 . Now let Z = A ∪ B. i. Let C = {← l1 .X) πD X but l ∈ πD (X). therefore. again placing it in C1 . The latter is also impossible since in this case the second literal from this constraint would be falsiﬁed by A. Notice that no literal li occurring in constraints from C2 belongs to P1 . To show that Z is complete consider two cases: If li ∈ lit(α) then. l ∈ πD (X).. the above is equivalent to l∈ X∈c(D. P1 = li : li ∈ πD (X) or li ∈ πD (X) .. Gelfond. for any li ∈ lit(σ) if li ∈ P2 then so is li . since X ∈ Dα . Hence (17) holds. X) containing l.e. Γ ∈ C. P2 is closed under ¬. Since C is indeﬁnite so is C2 and therefore there is an interpretation B of C2 which makes d(C2 ) true and l false.188 M. li ∈ A or li ∈ A. /˜ (17) Suppose it does. say. ˜ ˜ P2 = lit(α) \ P1 . Since πD does not contain negation as failure. A. l2 : ← l1 . ˜ ˜ ˜ This implies that l ∈ πD (X) which contradicts assumption (16). i. Since it contains no negation as failure it has exactly one answer set. A. and Let C1 be a collection of constraints from C such that l1 or l2 is in A. . there is X ∈ D containing ˜ X. we have that ˜ πD (X) ⊆ πD X .) By construction. that there is a literal l such that l∈ X∈c(D. and let C2 = C \ C1 . (If it were the case then we would have that li ∈ A or li ∈ A. Gabaldon / Building a knowledge base: an example Proof. Consider an arbitrary X ∈ Dα and suppose that the lemma is false. By corollary 21. since X ∈ Dα . l2 . Then..e. From (16) and (17) we have that l ∈ P2 .e. /˜ (15) By lemma 22. l ∈ πD (X). ˜ /˜ (16) We will ﬁrst show that. πD (X) is consistent. The former is impossible since it would place the constraint containing this literal into C1 .

X) X and therefore the lemma holds. It is also easy to check that. Function f deﬁned on the interior Dα of D is called separable if f (X) ⊆ f (X) X∈c(D. The sets of input and output predicates of π are disjoint and input literals do not belong to the heads of π.X) or. (Here by lit(π) we mean the collection of all literals which occur in the rules of the ground instantiation of π. X) such that l ∈ f (X). α ⊆ pred(σ).X) X which follows immediately from corollary 21 and lemma 23. 5. Z satisﬁes the constraints C and hence. By the splitting set theorem and condition (1) we have that for any output / X ∗ = X ∪ l: l ∈ X. ¬l ∈ X. this is equivalent to πD (X) = ˜ X∈c(D. Proof (sketch). X). and D be a collection of complete α-states of σ. Gabaldon / Building a knowledge base: an example 189 Consistency follows from consistency of A and B and the fact that if li ∈ B / then li ∈ A. ˜α ˜ Proof of theorem 19. Interpolation Now we discuss a realization theorem for interpolation of f-speciﬁcations. such that 1. Gelfond. α = pred(σi ).M.) Then π is separable. / / 2. Let X ∈ dom(π) and consider the set ∪ l: l ∈ atoms(σi ). By condition (1) lit(σi ) is a splitting set of programs π ∪ X and π ∪ X ∗ . For any l ∈ σi . l ∈ lit(π) . Z ∈ c(D. fD (X) = πD (X). and let π be an lp-function deﬁned on Dα = states(σi ).4. l ∈ lit(π) or l ∈ lit(π). This contradicts our assumption that l ∈ X∈c(D. if for any X ∈ dom(f ) and any output literal l such that l ∈ f (X) / there is X ∈ c(D. Proposition 24. Let D be the set of complete states over some signature σi . By deﬁnition of domain completion. l ∈ lit(π). We need to show that for all X ∈ Dα . / / / By condition (2). equivalently. / The following propositions give simple sufﬁcient conditions for separability which may help to better understand this notion. ¬l ∈ lit(π) . Since it is also complete by construction we have that X ∗ ∈ dom(π). A. by construction. X ∗ is consistent. Let σ be a signature.

Example 25. But by = = construction of X ∗ and the deﬁnition of red. l ∈ π(X) iff red(π. π can be decomposed into independent components π1 and π2 consisting of rules (1) and (2). X) = red(π. . πn be independent components of lp-function π. This can be done in the following way: Let π be an lp-function with input signature σi and output signature σo . four-tuple {πk . Let σi be a signature consisting of object constant a and predicate constant p. . . . Example 27. The proposition follows immediately from the splitting set theorem and deﬁnition of separability. . Consider σ. X ∗ ) | l.X) 1 In some cases. by proposition 26. to establish separability of an lp-function π it is useful to represent π as the union of its independent components and to reduce the question of separability of π to separability of these components. f1 (X) = ∅ while f (X) = {q(a)} and hence f1 is not separable. σi . and consider D = {{p(a)}. Then: (i) for any 0 k n. Obviously. σo . q1 and q2 be deﬁned by a program (1) q1 (a) ← p(a). Gabaldon / Building a knowledge base: an example literal l. We assume that the input literals of π do not belong to the heads of rules of π. red(π. A. By proposition 24. . Let X = ∅. {¬p(a)}} and a function f1 deﬁned on Dα by the program q(a) ← p(a) q(a) ← ¬p(a) where σo (f1 ) consists of a and q. so is π. respectively. π is separable. k n then so is π. dom(π)} is an lp-function. Let π0 . Proposition 26. π1 and π2 are separable. . . We say that π is decomposable into independent components π0 . X ∗ ). hence l ∈ π(X) iff l ∈ π(X ∗ ) and therefore. X∈c(D. X) | l and l ∈ π(X ∗ ) iff red(π. α and D from example 25 and let function f2 with the output signature consisting of a. πn if π = π0 ∪ · · · ∪ πn and lit(πm ) ∩ lit(πk ) ⊆ lit(σi ) for any k = m. Obviously. . Gelfond. and hence. The next example shows that the last condition is essential. (ii) if πk is separable for any 0 Proof.190 M. (2) q2 (a) ← ¬p(a). The following simple observation proves to be useful for constructing interpolations.

5.2) representing g into a monotonic lp-function. we need to show that f π (X) = ˜ X∈c(D. Gelfond. ˜ Corollary 29. π (X) = π(X). Hence. we will look for a transformation from this theorem which will turn the lp-function π (section 4. The corollary follows immediately from theorems 7 and 28. We start with ﬁnding a representation π of gα . E). D. Let π be a separable and monotonic lp-function. Let f . g α and f where g = f and incremental extension and three f-speciﬁcations: g ˜D ˜ s d α = {is} (13). π and π be as in theorem 28. dom(f )} ˜ of f . if X ⊆ X. If {˜ . Let f be a closed domain speciﬁcation with domain D represented by an lp-function π and let π be the result of replac˜ ˜ π ing some occurrences of input literals l in pos(π) by not l. namely that ˜ π X ⊆ π (X). σo (f ). S) ← exception(E. ˜ π (X) ⊆ ˜ X∈c(D. dom(f )} ˜ ˜ π is a separable lp-function with a signing S such that S ∩ (lit(σi ) ∪ lit(σo )) = ∅ then it ˜ represents the interpolation f of f . σo (f ). A. Recall that fN is deﬁned via α . not ¬is(X. S). From the separability of π we have one direction.X) π X . The declarative representation of open nets In this section we will go back to the task of building a computable lp-function ◦ ◦ π ◦ representing the open domain speciﬁcation fN . σi (f ).X) By monotonicity. Therefore. is a separable and monotonic lp-function then it represents the interpolation f Proof. In particular. (18) .5. The only transformation achieving this goal is that of replacing the rule deﬁning predicate exceptional in π by the rule exceptional(X. σi (f ).X) π X . ˜ ˜ π (X) ⊆ ˜ X∈c(D.M. If π = {˜ .X) π X . ˜ X∈c(D. ˜ Clearly. Gabaldon / Building a knowledge base: an example 191 Theorem 28 (Realization theorem for interpolation). D. Theorem 28 will provide ˜ ˜ an important heuristic guidance for this construction. To show that it represents ˜ ˜. for any complete set X. then π (X) ⊆ π (X).

) Let D be the domain of g = fd and D be the domain of g . is(o.) Let X ∈ D and consider an output literal l ∈ π (X). c1 ) ∈ X. Suppose now that is(o. We need to show that it satisﬁes the constraints (5). (Recall that dom(g) consists of complete states of σi (g) which satisfy the constraints (5) and dom(˜) is the set of all {is}-states of σi (g) which are maximally informative with g respect to D). p. d. We show that (a) X is a cover of X. π ˜ Consistency of π ∪ X was established before and hence π ∪ X is also consistent and ˜ has a consistent answer set S. X) and hence π ∪ X is consistent iff π ∪ X is consistent. and hence by consistency / of X the constraints (5) are satisﬁed. c2 ) ∈ N and is(o. p) and consider E = E0 ∪ c: ∃e (e ∈ E0 and subclass(e. Gabaldon / Building a knowledge base: an example Let us denote the resulting program by π and use corollary 29 to prove the following ˜ proposition. To show that π0 = π ∪ X is consistent we use an π ˜ argument similar to that which we used to prove consistency of π∪X in proposition 11. c. use its stratiﬁability to entail ˜ existence of a unique answer set and show that this answer set is consistent. c2 ∈ E and. p). We use renaming to reduce π to a program without ¬. +) ∈ S. (b) l ∈ π (X). Consistency of X again guarantees that constraints (5) are satisﬁed. (Separability. a p-negative class e can defeat has(x. A. c) ∈ X. As shown in [34]. then ¬is(o. c) ∈ N ) . Since X is maximally informative. p) if ¬is(x. c2 ). exceptional(x. X) = red(˜ . e) ∈ X. / . ˜ 1. we have ˜ that red(π. (b) Since X is complete and consistent and lit(is) is a splitting set of π . We need to show that π is an lp-function and that it is separable and ˜ monotonic. (Consistency. Proposition 30. Let X ∈ dom(˜ ). c1 ) ∈ X. ˜ ˜ Proof (sketch). has(x.192 M. +) ∈ N . Let c satisfy this / condition and consider two cases: and X = U ∪ ¬is(o. c) ∈ U . Consider arbitrary o. First let us consider the case when is(o. c1 and c2 such that subclass(c1 . 2. We need to construct a cover X of X such that l ∈ π (X). c2 ) ∈ X. X is complete and consistent. Then any cover of X must contain is(o. Gelfond. /˜ (a) By construction. c1 ) ∈ X. If o is not x. is(x. We say that a class e is p-negative if there is a negative link from e to p in /˜ N . c): is(o. Let E0 be the set of all / classes which can defeat has(x. p) ∈ S iff there is class c such that default(d. If o is x. is(x. U = X ∪ is(x. Let / ˜ us ﬁrst assume that l = has(x. π represents gα . c2 ) ∈ X. by construction. c1 ) ∈ X and constraints (5) are satisﬁed by consistency of X. e): e ∈ E . then c1 .

Then. ˜ Recall that D is the collection of complete states of σi (g) satisfying constraints (5). π 3. C2 ). The monotonicity condition follows from (iii) and theorem 7 and the conclusion of our proposition becomes an immediate consequence of theorem 28. d. c) ∈ N . C2 ). e) ∈ S. Now observe that the set S = atoms({exception. / / exceptional(x. exceptional)} is a signing for π and that S ∩ (lit(σi (π) ∪ lit(σo (π))) = ∅. we can show that ◦ ˜ ˜ Proposition 32. and therefore has(x. Since our graph is acyclic. since l ∈ π (X). d. c) ∈ U . / Then is(x. e) ∈ X. d. πD represents gD . Follows immediately from theorem 19.) Let X1 . By construction of U we have that there is a class e such that / default(d2 . C1 ) ← ¬is(O. A. Gelfond. The corresponding program πD consists of the rules ˜ is(O. we have that exception(e. / ˜ A similar argument works for l = ¬has(x. c) ∈ X. exceptional(x. X2 ∈ dom(˜ ) and X1 ⊂ X2 . (19) (20) Finally. we have that for every class e such that exception(e. subclass(C1 . c) ∈ X. e) ∈ U . p). (Monotonicity. Let us denote this program by π . By construction we have that is(x. Gabaldon / Building a knowledge base: an example 193 (i) is(x. By the splitting set theorem ˜ π (iii) π (X) = π (X) for any X ∈ dom(˜ ). . π ◦ = π ∪ πD ∪ πs represents fN . +) ∈ S. /˜ (ii) is(x. e.M. subclass(C1 . C1 ). d. It is also easy to see that they are indeﬁnite and hence we can use the construction from theorem 19. By construction of X this implies that ¬is(x. C2 ) ← is(O. −) ∈ N . ¬is(O. p. ¬is(x. ◦ To complete the construction of representation π ◦ of fN we need to ﬁnd a representation πD of the domain completion of D = dom(g) with respect to α = {is}. +) ∈ /˜ S. ¬is(x. These constraints are binary with respect to α. e) ∈ X and either e = c or subclass(e. Proposition 31. +) ∈ S. Since X1 and X2 are is-states of σi we have that [X1 ]{default} = [X2 ]{default} and hence (ii) top(π1 . lit(default)). p) ∈ π (X). C2 ). lit(default)) = top(π2 . +) ∈ S and therefore has(x. p) ∈ π (X). ˜ ˜α Proof. To show that (i) π (X1 ) ⊂ π (X2 ) ˜ ˜ we ﬁrst use the splitting set theorem to eliminate from π1 = π ∪ X1 and π2 = π ∪ X2 ˜ ˜ all the occurrences of literals from lit(default).

propositions 30. C1 ) ← subclass(C1 . ¬subclass(C1 . not ¬is(X. C1 ). C2 ). E. C. C. is(X. +). theorem 10. E). P . P . ¬is(O. ¬has(X. πD and πs have unique answer sets. C2 ). E). Gelfond. However. −). C2 ). P . E). not exceptional(X. D. default(D2 . exceptional(X. E. π◦ not subclass(C. +). is(O. C2 ) ← subclass0 (C1 . proposition 32 shows the correctness of π ◦ with respect to our speciﬁcation if π ◦ is viewed as a declarative program. D. Follows immediately from the equation (13). ¬is(O. ˜ ˜ As in the case of closed nets. exception(E. and the fact that π . Its computability can be shown by an argument similar to that in proposition 13. −). +) ← default(D1 . not exceptional(X. A. −). C2 ) ← not subclass(C1 . . not subclass(C. C). D1 . C. C2 ). π ◦ is not computable with respect to our interpreter A. P . due to the left recursion in rules (19) and (20). C). 31. C2 ). C. exception(E. To achieve computability we need to change the order of literals in the bodies of these rules. C2 ) ← subclass0 (C1 . default(D2 . P . subclass(C3 . subclass(C1 . +). D. C3 ). D. subclass(C1 . −) ← default(D1 . S) ← exception(E. P . C2 ). Gabaldon / Building a knowledge base: an example Proof. C2 ) ← subclass(C1 . −). no changes in the rules (19) and (20) would be needed. Notice that if we were to use an inference engine based on XSB which includes a form of loop checking. P ) ← default(D. +).194 M. is(X. D1 . P ) ← default(D. The resulting program π ◦ will look as follows: has(X. is(O. S).

. We show that this generalization can be easily incorporated into the design. . A simple generalization In this section we generalize the knowledge representation problem associated with a net N by allowing strict (non-defeasible) links from objects to properties to belong to the net’s input (see ﬁgure 2). (i) if l ∈ Y then l ∈ f ∗ (Y ). . An f-speciﬁcation f ∗ with input signature σi (f )+σo(f ) and output signature σo (f ) is called input extension of f if (1) f ∗ is deﬁned on elements of dom(f ) possibly expanded by consistent sets of literals from σo (f ). . f ∗ (X) = f (X). . called input extension. To do that we use another speciﬁcation constructor from [26]. Hierarchy with links from objects to properties. Gabaldon / Building a knowledge base: an example 195 6. lm . ˜α (21) ˜ where g∗ is the input extension of gα . not ln Figure 2. not lm+1 . . The result of replacing every rule l0 ← l1 . Let π be an lp-function. .M. . / / A new problem associated with a net N can be deﬁned by f-speciﬁcation f ∗ = g∗ ◦ gD ◦ fs . Deﬁnition 34. A. . To ﬁnd an lp-function representing g∗ we will use the following transformation from [26]. Deﬁnition 33. (ii) if l ∈ Y and l ∈ Y then l ∈ f ∗ (Y ) iff l ∈ f (Y ∩ lit(σi (f )). Gelfond. (3) for any Y ∈ dom(f ∗ ) and any l ∈ lit(σo (f )). Let f be a functional speciﬁcation with disjoint sets of input and output predicates. (2) for every X ∈ dom(f ).

+). then ˆ lp-function π ∗ = π1 ∪ π2 represents the input extension f ∗ of f . . . Let f be a speciﬁcation represented by lp-function π with signature σ. The following proposition follows immediately from equation (21).196 M. Proposition 36. p) ← default(d. Gelfond. . This example again demonstrates that speciﬁcation constructors and their realization theorems provided a useful heuristic guidance for specifying knowledge representation problems and for building program provably satisfying these speciﬁcations. is(x. (i) π ∗ represents g∗ . the construction of π ∗ . is(x. not ln . U ) and π1 = base(π. c). d. p. c. p. . The representation π ∗ of input extension g∗ of gα is obtained by replacing the ˜ ◦ (section 5. not l0 is called the guarded version of π and is denoted by π . p). . A. not lm+1 . p) ← default(d. If the set U = lit(σ)\lit(σ◦ ) is a splitting set of π dividing π into two components π2 = top(π. ˜ (ii) π ∗ ∪ πD ∪ πs represents f∗. Conclusions In this paper we discussed a systematic methodology of solving certain types of knowledge representation problems in logic programming. . d. c). Gabaldon / Building a knowledge base: an example of π with l0 ∈ lit(σ◦ (f )) by the rule l0 ← l1 . 7. +). ¬has(x. c. and theorems 35 and 10. not ¬has(x.5) by has rules in π has(x. −). . p). ˆ The following theorem is useful for constructing lp-functions representing input extensions. not exceptional(x. Theorem 35 (Realization theorem for input extension [26]). The methodology was illustrated by a detailed development of solutions of several knowledge representation . −) not has(x. not exceptional(x. U ). . lm .

The ﬁrst author acknowledges the support of NASA under grant NCCW-0089. Our thanks to them and to all the others. On the occur-check free logic programs. Gelfond. 89–148. The authors are grateful to the anonymous referees for their comments and suggestions for improving the paper.16. Pellegrini.41.24.M.18. We are currently working on studying the applicability of our approach to more general forms of inheritance. and to several other domains. Minker (Morgan Kaufmann. Baral and O. was never investigated before. J. J. Gabaldon / Building a knowledge base: an example 197 problems associated with simple taxonomic hierarchies. Expanding queries to incomplete databases by interpolating general logic programs. 1996). M. 526 (Springer. in: Foundations of Deductive Databases and Logic Programming. Alferes and L.47]. The paper also contains previously unpublished proofs of several realization theorems. of LICS-87 (1987) pp. Baral. Reasoning with Logic Programming. Apt. J. we addressed the question of reasoning in open nets. and used various realization theorems to guide the process of representing these speciﬁcations by declarative programs of A-Prolog. to reasoning about actions and change. in: Proc. We would like to mention however our collaborators who directly contributed to this approach – H. Lecture Notes in Computer Science. We also demonstrated how these programs can be transformed into executable programs of Prolog and XSB. Apt and D. Gelfond and O. Lecture Notes in Artiﬁcial Intelligence (Springer. The results so far seem to be rather promising. . Pereira. Berlin. [7] N.M. Kosheleva. Przymusinska. of the International Conference on Theoretical Aspects of Computer Software. 89–97. References [1] J.28. Vol. Towards a theory of declarative knowledge. Baral and M. Froidevaux. in: Proc. which. [4] K. [6] C. Kosheleva. Bidoit and C. In each case we started with a functional speciﬁcation of a problem constructed from speciﬁcations of simpler problems with the help of speciﬁcation constructors. Logic programming and knowledge representation. Gelfond. [5] C. Acknowledgements Many people contributed to the development of ideas presented in this paper and we cannot name all of them here. C. [2] K. San Mateo. to the best of our knowledge. Logic Programming 12 (1994) 1–80. CA. ACM Trans.27. Minimalism subsumes default logic and circumscription. Proving termination in general Prolog programs. Blair and A. Walker. 265–289. Even though the formalization of inheritance reasoning was extensively studied in the AI literature [15. A. the emphasis on precise speciﬁcations of the problems allowed us to come up with a clearer picture of dependencies of various types of inheritance reasoning on the closed and open world assumptions about the problem domain and on the type of the allowed updates. Programming Languages and Systems 16(3) (1994) 687–726. Pedreschi. In particular. Apt and A. H. Berlin. ed. 1991) pp. 1988) pp.J. Logic Programming 35 (1998) 195–230. [3] K.

Berlin. Logic Programming 27(2) (1996) 169–183. 1996) pp. [26] M. [9] W. Lifschitz. Gabaldon / Building a knowledge base: an example [8] D. R. in: Logic Programming: Proc. in: Proc. Gallaire and J. Restricted monotonicity. 5th International Conference and Symposium on Logic Programming (1988) pp. MA. Maluszynski (1997) pp. Logic Programming 24(3) (1995) 161–201. Logic Programming 7(3) (1989) 231–245. Reading. Constructive negation based on the completed databases. Lifschitz. Maluszynski. Vol. Przymusinska. Son. argumentation. of the 5th International Conference and Symposium. Przymusinska. eds. Bowen (1988) pp. Pfeifer and F. G. 1070–1080. N. Formalization of inheritance reasoning in autoepistemic logic.M. Saraswat and K. [30] V. Hogger and J. in: Logic Programming: Proc. 432–437. 363–374. eds.A. of KR-96 (1996) pp. of the International Symposium on Logic Programming. Chan. Consistency of Clark’s completion and existence of stable models. Swift and D. C. Lifschitz. [24] M. Default reasoning system DeReS. in: Logic Programming: Proc. H. Fund. Gelfond. On inheritance hierarchies with exceptions. [23] M. 104–108. [31] V. [22] M. AND-parallelism with intelligent backtracking for annotated logic programs. Gabaldon. Eiter. of the 7th International Conference. 1(1) (1994) 51–60. eds. [17] T. Logic programs with classical negation. 16(1) (1992) 59–92. An argumentation-theoretic approach to reasoning with speciﬁcity. Chen. Przymusinska. V. in: Logic Programming: Proc. Truszczynski. Gelfond and V. in: Proc. Leone.M. Kunen. [25] M. J. Clark. From functional speciﬁcations to logic programs. in: Handbook of Logic in Artiﬁcial Intelligence and Logic Programming. eds. Szeredi (1990) pp. Logic Programming: Systematic Program Development (Addison-Wesley. Warren. 518–528. in: Logic and Data Bases. 316–329. Software Eng. 13 (1990) 403–445. NY. Dung and T. 1978) pp. 1990). Gelfond and V. J. Knowledge Eng. [18] D. Towards a theory of elaboration tolerance: logic programming approach. in: Principles of Knowledge Representation. Reiter. J. in: Proceedings of KR ’96 (1996) pp. Gelfond and A. Dembinski and J. D. Sci. Lecture Notes in Computer Science. and logic programming.C. [16] P. Touretzky.S. C. [14] Y. 25–38. 69–128. Methods Logic Comput. Foundations of logic programming. 1997) pp. of AAAI-93 (1993) pp. Warren and P. Dung and T. [21] M.F. W. G. 4th LPNMR. Gelfond and V. Etherington and R. Gelfond and H. Robinson (1994). Deville. Brewka (CSLI Publications. R. 579–597. The stable model semantics for logic programming. eds. Ueda (1985) pp. [12] K. Classical negation in logic programs and disjunctive databases. Kowalski and K. [11] P. Marek and M. in: Proc. [15] P.C. Gelfond and H. Signed data dependencies in logic programs. 1265 (Springer. On consistency and completeness of autoepistemic theories. Horty. A skeptical theory of inheritance in nonmonotonic semantic networks. 407–418. 355–371. 111–125. Nonmonotonic inheritance. in: Proceedings of AAAI83 (1983) pp. Fund. [10] W. Mateis. T. . Negation as failure. ed. J. Thomason and D. in: Proc. Horty. J. Gelfond and H.H. [20] M. Scarcello. Extending Prolog with nonmonotonic reasoning. in: Proceedings of LPNMR (1995) pp. [19] F. of the 1997 International Symposium. Chen. Inform. [13] P. Cholewinski. Lifschitz. New Generation Computing 9 (1991) 365–385. [27] J. Lifschitz. ed. [28] J. D. Gabbay.F. [29] K.198 M. Fages. 293–322. 6(1) (1996) 89–112. A. Artiﬁcial Intelligence 42(2–3) (1990) 311–348. Inform. J. Efﬁcient top-down computation of queries under the well-founded semantics. Minker (Plenum Press. Some direct theories of non-monotonic inheritance. A deductive system for non-monotonic reasoning. Son.

.D. Stanford University (1991). The Mathematics of Inheritance Systems (Morgan Kaufmann. of JICSLP-96 (MIT Press. Reiter. [45] H.M. 1986). M. Stroetmann. Turner. Lifschitz and H.S. 23–38. You and L. New York. A default interpretation of defeasible network. ed. of ILPS. Turner. Artiﬁcial Intelligence 13(1–2) 81–132. Los Altos. A. of the 6th International Conference on Logic Programming. Signed logic programs. McCain and H. Subrahmanian. in: Proc. J. [38] T. Efﬁcient implementation of the well-founded and stable model semantics. Artiﬁcial Intelligence 55(2–3) (1992) 259–310. in: Proceedings of the 15th International Joint Conference on Artiﬁcial Intelligence (IJCAI-97) (1997) pp. [43] D. Gelfond. Niemela and P. ed. 1996). Ross and J. of the 10th European Conference on Artiﬁcial Intelligence (1992) pp. On closed world data bases. The well-founded semantics for general logic programs. Well-founded semantics for logic programs with explicit negation.S. Bruynooghe (1994) pp. Yuan. [44] H. Pereira and J. [42] K. P. [36] L.A. [33] F. Van Hentenryck (1994) pp. The relationship between logic program semantics and non– monotonic reasoning. A logic for default reasoning. 61–75. A study of nonmonotonic reasoning. eds. 567–585. Turner. Van Gelder. [35] N. On constructive negation in logic programming. Minker (Plenum Press. Resolving ambiguity in non-monotonic inheritance hierarchies. Ph. Gallaire and J. CA. [41] L. [40] R.H. [34] W. Schlipf. Marek and V. Simons. of the 11th International Conference on Logic Programming (1994) pp. Lin. Splitting a logic program. eds. 156–161. [39] R. in: Logic and Data Bases. D. Wang. [37] L. J.Y. Reiter. Levi and M. Language independence and language tolerance in logic programs. 600–617. Cambridge. Martelli (1989) pp. in: Proc. Logic Programming 15(4) (1993) 337–355. Alferes. Gabaldon / Building a knowledge base: an example 199 [32] V. 11th ICLP. ed. 10th ICLP. 1978) pp. Journal of the ACM 38(3) (1991) 620–650. Przymusinki. G. 16–20. thesis. in: Proc. H. Turner. 119–140. MA. 38–57. Touretzky. A completeness result for SLDNF-resolution. K. [46] A. in: Proc. Stein. in: Proc. in: Proc. in: Proc. Warren (1993) pp. in: Proc. of the North American Conference of Logic Programming (1989) pp. A monotonicity theorem for extended logic programs. 102–106. [47] X.

- prolog the programming language
- Prolog
- Planning.4
- Math Logic
- KRR Lecture 1 Intro
- donini.ps
- Artificial Intelligence Slides
- Matthew Wampler-Doty CV
- h 0734150
- Rafee Ebrahim Kamouna
- lintt.pdf
- clase54
- Mathematical Logic 2
- logic
- From CLF to Lollimon
- Ross Berg Completeness
- -Modal Logic-PhDthesis_Marchignoli
- Tri Consequences
- Critical Thinking - Ch 9
- Well Posednessphilo
- PredicateLogic
- History of Logic 3
- Propositional Calculus
- 2005_09_19_egre
- JUNGK Resumo Ingles
- QUESTION BANK FOR ARTIFICIAL INTELLIGENCE REGULATION 2013
- VARZI - Modal Logic - Class Notes
- Trivial Ism
- Advice to a Young Logician
- Aggregated Stuff
- Building a Knowledge Base - An Example

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd