0% found this document useful (0 votes)
6 views

SS01 01 020

Uploaded by

Sarvesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SS01 01 020

Uploaded by

Sarvesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

From: AAAI Technical Report SS-01-01. Compilation copyright © 2001, AAAI (www.aaai.org). All rights reserved.

On the Foundations of Answer Set Programming


V.W. Marek
Department of Computer Science
University of Kentucky
J.B. Remmel
Department of Mathematics
University of California, San Diego

Abstract Programming, the constraints act on the individual el-


ements of Herbrand base of the program while the con-
Schlipf (Schlipf 1995) provedthat the Stable LogicPro- straint clauses in ASPact more globally in that they
grammingsolves all NPdecision problems. Weextend
Schlipf’s result to all search problemsin the class NP. place restrictions on what subsets of the Herbrand base
Moreover, we do this in a uniform way as defined in can be acceptable answers for the ASP program. For
(Marek & Truszczyfiski 1999). Specifically, we show example, suppose that we have a problem H whose so-
that there is a single DATALOG ~ program Pr~ so lutions are subsets of some Herbrand base H. In order
that for every Turing machine T, every polynomial to solve the problem, an ASP programmer essentially
with nonnegativecoedicients p, every positive integer writes a logic program P that describes the constraints
n and an input cr of size at most n over a fixed al- on the subsets of H which can be answers to II. The
phabet E there is a polynomial-time encoding of the basic idea is that the program P should have the prop-
machine Mand the input as an extensional database erty that there is an easy decoding of solutions of II
edbM,p,, so that there is a one-to-one correspondence from stable models of P and that all solutions of II can
between the stable models of edbM,p,, U P~ and ac-
cepting computations of the machineMthat reach the be obtained from a stable model of P through this de-
final state in at most p(n) steps. The decodingof com- coding. The program P is then submitted to the ASP
putations form stable modelsis done in polynomial(in engine such as smodels (Niemel~i & Simons 1996), ally
fact linear), timeas well. (Eiter & al. 1998) or DeReS(Cholewhiski & al. 1999)
which computes the stable models of the program P.
Introduction Thus the ASP engine finds the stable models of the
program (if any exists) and we read-off the solutions
The main motivation for this paper comes from re-
to II from these stable models. Notice that the idea
cent developments in Knowledge Representation, es- here is that all solutions are equally good in the sense
pecially the appearance of a new generation of sys- that any solution found in the process described above
tems (Niemel~i & Simons 1996; Eiter:& al. 1998; is acceptable. Currently, the systems based on ASP
CholewiSski & al. 1999) based on the so-called An- paradigm are being tested on the problems related to
swer Set Programming (ASP) paradigm (Niemel~i 1998; planning (Lifschitz 1999; Niemel~i 1998), product con-
Cadoli & Palipoli 1998; Marek & Truszczy~ski 1999; figuration (T. Soininen & I. Niemel~i 1999), combina-
Lifschitz 1998; 1999; East & Truszczyflski 2000). In
torial optimization problems (Cholewir~ski & al. 1999;
particular, these systems suggest that we need to re- Niemel~i 1998) and other domains.
visit one of the basic issues in the foundations of ASP,
namely, how can we characterize what such ASP sys- It is a well knownfact that the semantics of exist-
tems can theoretically compute. Throughout this pa- ing Logic Programming systems such as Prolog have
per, we shall focus on one particular ASPformalism, serious problems. For instance, the unification algo-
namely, the Stable Semantics for Logic Programs (SLP) rithm used by most dialects of Prolog do not enforce
(Gelfond & Lifschitz 1988) and related systems. the occur check and hence these systems can produce
note that the underlying methods of ASP are similar incorrect results (Apt &Pellegrini 1994). Moreover, the
to those used in Logic Programming(Colmerauer & al. processing strategies of Prolog and similar languages
1973; Apt 1990) and Constraint Programming (Jaffar have the effect that correct logic programs can be non-
& Maher 1994; Marriott & Stuckey 1998). That is, terminating (Apt & Pedreschi 1994). While good pro-
like Logic Programming, ASP is a declarative formal- gramming techniques can overcome these problems, it
ism and the semantics of all ASPsystems are based on is clear that such deficiencies have been limiting the
logic. Like Constraint Programming, certain clauses of appeal of the Logic Programming systems for ordinary
an ASP program act as constraints. There is a fun- programmers or system analysts. The promise of ASP
damental difference between ASP programs and Con- and, in particular, of SLPand its extensions, e.g. Dis-
straint Logic programs, however. That is, in Constraint junctive Logic Programming,(Eiter & al. 1998), is that

¯. . ..’::. ,’.~.,...,.
.’....
’1’24 " , ....’" : ........
a new generation of Logic Programming systems can throughT. In effect, thisresult showsthattheproblem
be built which have a clear semantics and are easier of findinga stable model fora finite predicate logic pro-
to program than the previous generation of Logic Pro- gramisequivalent to finding an infinite paththrough an
gramming systems. In particular, both of the prob- infinitely branching recursive tree.Oneconsequence of
lems referred to above, namely, the occur check prob- thisresultis thattheproblem of determining whether
lem and the termination problem, do not exist in SLP. a finitepredicate logicprogram hasa stablemodelis
Of course, there is a price to pay, namely, SLP sys- a ~-complete. Moreover, the resultof (Marek& al.
tems only accept programs without function symbols. 1994)givesus someideaaboutthestructure of thefam-
Consequently, one of the basic data structures used in ilyof stablemodelsof theprogram. A complete charac-
Prolog, namely, the term formed from function sym- terizationof families of stable models of logicprograms
bols, variables and constants, is not available in SLP. in termsof inverse-Scott topology has beenfoundin
Thus SLP systems require the programmer to explic- (Ferry1994).Moreresults on thestructure of thefam-
itly construct manydata structures. In this sense, SLP ilyof stablemodelsof theprograms can be foundin
is similar to languages such as Perl (Wail & ai. 2000) (Cenzer& Remmel1999).
where finite functions and arrays are used to build data Allthe results mentioned in theprevious paragraph
structures. In SLP programming, predicates are used showthatstable semantics forlogicprograms admitting
to construct the required data structures and constraint function symbols canbe usedonlyin a verylimited set-
type clauses are used to ensures that the predicates be- ting.Thisis precisely whattheXSB systemdoes(Rao
have properly with respect to semantics of the program. & ai.1997).The ASPsystemssuchas thosementioned
SLP programs are always terminating because the Her- above,proposea moreradicalsolution to theproblem
brand base is finite and hence there are only a finite set of complexity of stablemodelsof logicprograms with
of stable models. In addition, the order of the clauses function symbols, namely,we shouldabandonfunction
of the program does not affect the set of stable models symbols entirely. Oncethisis accepted, thesemantics of
of the program). Finally the stable semantics of logic logicprogram canbe defined in twostages. First, weas-
programs is well understood so that SLP programs have sumethattheprogram is interpreted overtheHerbrand
clearsemantics. universe of theprogram, although, in principle, sucha
We notethatrestriction thatASP programsdo not restriction is notnecessary. Thus,givena logicprogram
havefunction symbols is absolutely crucial. First,it P, we assume,as in standard LogicProgramming, that
is wellknownthatonceone allowsfunctionsymbols theuniverse is determined by theconstants explicitly
in a logicprogramP, thenHerbrand basebecomesin- occurringin P. Thesetof theseconstants is finite. The
finite. Moreover, thestablemodelsof logicprograms program is grounded in theseconstants andtheresult-
withfunctionsymbolscanbe immensely complex. The ingprogram Ps is a propositional logicprogram. In the
firstresultwhichshowedthatthesetof stablemod- secondstage,we computestablemodelsof theprogram
els can be complexcan be foundin (Apt & Blair P9 andthosearethestablemodelsof P. Theprocess of
1990).Forstratified logicprograms (Apt& ai.1988; grounding is performed by a separate grounding engine
Przymusiriski 1986), theperfect modelis theunique sta- suchas Iparse(Niemel~i & Simons1996)andtheresult
blemodelof thatprogram (Gelfond & Lifschitz 1988). is passedto theenginecomputing thestablemodels. It
Apt and Blair(Apt & Blair1990)showedthat per- is nowclearthatthefeatures of SLPmentioned above,
fectmodelsof stratified logicprograms capture pre- i.e.,theabsence of occurcheckandtermination prob-
ciselythearithmetic sets.Thatis,theyshowthatfor lemsand the independence of the semantics fromthe
a givenarithmetic setX of natural numbers, thereis ordering of theclausesof the program, automaticaily
a finitestratified logicprogram Px suchthatin the hold.Thatis,sincegrounding usesonlyverylimited
perfect modelof Px,somepredicate Px is satisfied by partof unification, theoccurcheckproblem is elimi-
precisely thenumbers in X. Thisis a powerful result nated.The spaceof candidates for stablemodelsis
limiting hopesforany meaningful practical program- finiteandso thereis no termination problem. Finally,
mingwithstratified programs if we allowfunction sym- thestablesemantics of propositional programs doesnot
bols.The resultof (Apt& Blair1990)was extended depend on theorderof clauses (although theprocessing,
in (Blair& ai.1995)whereit is shownthatthestable ofcourse, does).
modelsof a locally stratified program cancapture any The language of logicprogramming withoutfunction
setin thehyperarithmetic hierarchy. In (Marek& ai. symbolshas beenstudiedby the databasecommunity
1994)it is shownthatthereis a uniform translation of in expectation thatit couldleadto new,morepow-
treescontained in w<~intologicprograms so thatgiven erful,database languages (Ullman1988).It is called
an infinitely branching recursive treeT C ~<~,there DATALOG and some database systems such as DB2
is a finitepredicate logicprogram PT suchthatthere implementHorn partof DATALOG.The factthat ad-
is an effective one-to-one degreepreserving correspon- mitting negation in thebodies of clauses leadsto multi-
dencebetween stablemodelsof P andinfinite branches plestablemodelswas unacceptable fromthe database
perspective. Hence the semanticsof DATALOGwith
1However it is the case that the orderof the clauses does negation usedin database community waseithera well-
affect the processing time of the ASPengine. founded semantics (VanGelder& ai.1991)(thatis

125
leastthree-valued stablemodel(PrzymusiSski 1990)), pableto simulating polynomial timenondeterministic
or othersomewhat non-intuitive semantics suchas the TaringMachines. Thatis, givenany polynomial time
inflationary semantics (Abiteboul & al.1995). nondeterministic TaringmachineM and any inputa,
Themainpurpose of thispaperisto revisit theques- thereis a setof factsCM,,suchthata stable modelof
tionof whatcanbe computed by logicprograms with- PUCM,,codesan accepting computation of M started
out functions symbolsunderthe stablemodelseman- with inputa and and any acceptingcomputation of
tics.As we willseein a moment, thequestion itself M startedon inputa is codedby somestablemodel
requires somefine-tuning. First,letus lookatthecase of P u CM,,.Thisresultswillshowthatlogicpro-
of finitepropositional programs. Herethesituation is gramswithoutfunction symbols underthestablelogic
simple.LetAt be a set of propositional atoms.Let semantics cancaptureprecisely theset of NP-search
~" be a finite antichainof subsets of At (i.e.whenever problems.Ourproofof thisresultusesessentially the
X, Y E ~’,X C Y thenX ----Y).Thenthereis a logic sametechnique usedby Cook(Cook1971)in his proof
program Pyso that~risprecisely theclassofallstable of theNP-completeness of thesatisfiability problem.
modelsof Py (Marek& TruszczySski 1993).Moreover, Thatis,giventhe run-time polynomial boundp(z)for
thefamilyof stablemodelsof anyprogram P formsan M, stablemodelsof P tJ CM,~encodesthesequence of
antichain. Thusin thefinitepropositional logicpro- stepsof lengthp(n)whichoccurin an accepting com-
gramcase,we havea complete characterization. How- putationof M startedon a if ~ has lengthn. More
ever,thisresultdoesnottellus anything aboutthe precisely,givea nondeterministic polynomialtimeTur-
uniformity and theeffectiveness of theconstruction. ing machineM, theclausesCM,~willincorporate the
The problemof whetherthereexistsa stablemodel descriptionof M as thepartof theinstance description
of a propositional programis NP-complete (Marek (extensional database) to theprogramP. The input
Truszczyfiski 1991).For the DATALOG(withnega- willalsobe a partof theextensional database.Call
tion), an analogous result hasbeenobtained in (Schlipf thisextensional databaseedbM,p,,. Thesizeof edbM,p,,
1995). is polynomial in the sizeof M, I~I,and theexponent
To refine, our question about what can be computed of p. Therewillbe a one-to-one polynomialtimecor-
by logic programs without functions symbols under the respondence betweenthe computations of themachine
stablemodelsemantics, we firstintroduce thenotion M thatreachthefinalaccepting statein at mostp(n)
of searchproblem(Garey& Johnson1979)and of stepsandthestablemodelsof P U edbM,p,~. Thusall
uniformlogicprogram(Marek& Truszczydski 1999). searchproblems in classNP canbe solvedby a uniform
A searchproblem is a set8 of finiteinstances (Garey logicprogram. Theconverse implication is,of course,
& Johnson 1979).Forexample, thesearchproblem may obvious.
be to findHamiltonian pathsin a graphso thattheset We shallalsoshowthatwe can applythesametech-
ofinstances oftheproblem isthesetofallfinite graphs. niquesto construct a metainterpreter forstablelogic
Givenan instance I E 8, we havea setSt of solutions programming. Specifically, we showthatthe search
to 8 for instance I. For example, in our Hamiltonian problemof findinga stablemodelsforpropositional
pathproblem, givena finitegraphI, St is thesetof logicprogram canalsobe solvedby meansof a uniform
all Hamiltonian pathsof I. An algorithm solvesthe logicprogram. Specifically, we represent anyproposi-
problem 8 if it returns a solution s E St whenever St tionallogicprogramby a setof propositional atoms
is non-empty, and returns "empty" otherwise. Decision thatserveas an extensional database fora metainter-
problemsare specialcasesof searchproblems. Now preter. In fact,we canconstruct twosuchmetainter-
consider a searchproblem8. Assumethatthereexists preterswithdifferent properties.In thispaper, wecon-
structa simpleonethatcomputes stablemodelsforso-
1. a polynomial timeencodingedb8underwhichevery called0-2programs. A resultdueto Blair(Blair & al.
instance I of8 is mapped toa finite setof atomsand
1999)showsthateverypropositional programcan be
2. a single logic programPa such that there is a polyno- semirepresented in thesenseof (Marek& Truszczyfiski
mial time computable function sols(., .) such that for 1993)by a 0-2 logicprogram andthattherepresenta-
every instance I of 8, sols(I, .) mapsthe set of stable tioncan be computed in lineartime.A morecomplex
models of the edba(I) U onto th e se t of sol utions metainterpreter thatdirectly computes stablemodels
Sz of/. canbe constructed alongthelinesof theproofof The-
In such a situation, we say that the search problem 8 orem2 below.Dueto the spacelimitations, we shall
is solved by a uniform logic program. Schlipf (Schlipf notgiveanydetails aboutthissecondmetainterpreter.
1995) has shown that the class of decision problems in
NP is captured precisely by uniform logic programs. Technical preliminaries
Specifically he proved that a decision problem is solved
by a uniform logic programif and only if it is in NP. In this section we formally introduce several notions
The goal of our paper is to prove the strengthening that will be needed for the proof of our result.
of this result. Namely we will prove that the Schlipf First, we introduce the set of logic programs that
result remains true if we deal with search problems. we will study. Wewill consider here only so called
DATALOG ~ programs. Specifically, a clause is an ex-
Weshall exhibit a single logic program P that is ca-

126
pression of the form most we reach the final step in at most p(n) steps for
any input of length n. Given a nondetrrninistic Turing
P(X)+- qtiX),...
,qm(X),-~ ,-~ r,(X)(1)
rliX),... machine M with a runtime polynomial p, we modify
wherep,qi,..., q,n,r1,.¯ ¯,rn areatoms, possibly with the usual operation of Min the following ways.
variables and/or constants. A program is a finitesetP (1) Weshall assume 6(f, a) = {(f, a, A)} for all a ¯
of clauses of theform(1).Eachprogram determines its (2) Given an input z of length n, instead of immediately
language (basedon thepredicates occurring in thepro- halting whenwe first get to state f reading a symbol a,
gram),Herbrand universe U (setof all constant terms we just keep executing the instruction (f, a, A) until
occurring in theprogram), and Herbrand baseHp (the have completed p(n) steps. That is, we remain in state
setof all groundatomsof thelanguage). Sincethere f, we never move, and we never change any symbols on
is no function symbolsin our programs, bothHerbrand the tape after we get to state f.
universe andHerbrand basearefinite.
A groundinstance of theclauseC of theform(1) Uniform coding of Turing Machines by
theresultof a simultaneous substitution of constants a Logic Program
for variables occurring in C. Givena programP, Po In this section we describe a logic program used for the
is thepropositional programconsisting of allground uniform coding of the operation of Turing machines.
substitutions ofclauses of P. This program P is the core part of our encoding of NP-
Givena propositional programP and a set M C Hp, search problems. The encoding of the input, specific
the Gelfond-Lifschitz transform of P by meansof M, machine, and the run-time bound will all be encoded
GL(P, M) is the program GL(P, M) arising from P as by a collection of facts, i.e. of ground atoms.
follows. First, eliminate all clauses C in P such that for Firstly, we need to define the language (i.e. a signa-
some j, 1 _< j _< n, rj E M. Finally, in any remaining ture) of the program P. Here is the collection of atoms
clauses, we eliminate all negated atoms. The resulting (predicate symbols) that we use for description of
set of clauses forms a program, GL(P, M), which is a Wealso explain the use for each symbol.
Horn program and hence if possesses a least model IVM.
Wesay that Mis a stable model of the propositional time(X) for "X is a time step".
program P if M = ArM. Finally, we say that M is a lasttime(X) for "X is the last time step".
stable model of a DATALOG "~ program P, if M is a
cell(X) for "X is a cell number".
stable model of the propositional program Pg.
A nondeterministic Turing Machine is a structure of symb(X) for "X is a symbol".
the form M= (Q, E, r, D, 6, s, f) where Q is a finite set state(S) for "S is a state".
of states, E is a finite alphabet of input symbols. We
will assume that B is an additional symbol such that action(X) for "X ¯ (L, R, A}’.
B ~ E. The symbol B will denote "Blank". The set rwct(Y, T) for "the read-write head is reading cell
r = E u {B} is the set of tape symbols. The set D of at time T".
movedirections will consist of elements L, R, and A (L rest(X, T) for "machine M is in state X at time T".
is a "move left" symbol, R is a "move right" symbol,
and A is "stay put" symbol). The function 6 : Q x otherrzost(X, T) for "machine Mis in state other than
X at time T".
PiQ x F x D) is the transition function of the machine
M. The state s ¯ Q is the start state, and f ¯ Q is the syct(X, Y, T) for "s symbol X is in cell Y at time T".
final state. To visualize the behavior of the machine M othersyct(X, Y, Z) for "symbol other than X is in cell
we talk about the read-write head of the machine. The Y at time T".
read-write head of the machine is always in some state
from set Q. As usual, a Turing machine M operates on delta(X, Y, X1, Y1, Z) for "the triple (X1, Y1, Z) is
executable instruction when the read-write head is
a tape. The tape could be thought as starting at the cell
in state X and reads Y." (This five-place relation
with the index 1 and containing infinitely manycells i
for i > 0 to the right. However, when we consider a represents the transition function 6).
polynomial time nondeterministic Turing machine, M, r~ogoodiX, Y) for "the read-write head is in state X
with run time polynomial p(z), then on any input cr and reads the symbol Y, but there is no instruction
length n, an accepting computation can affect at most to execute."
the first p(n) cells of the tape. Thusin such a situation, instiX, Y, Z) for "( X, Y, Z) is an instruction".
there is no loss in only considering tapes of length p(n).
Hence in what follows, one can implicitly assume that ezinst(X, Y, Z, T) for "machine M executes the in-
that the tape is finite. struction (X, Y, Z) at time T". Here we assume
A runtime polynomial p of a nondeterministic Taring that instruction ( X, Y, Z) is executed at the start of
machine M is a polynomial of the form p(z) = ao any given time step T > 1 and that the instruction
(X, Y, Z) was chosen by Mat the previous time step.
alx +... + akz~ where each ai ¯ N = {0, 1, 2,...} and
ah ~ 0. If p is the runtime polynomial for M, then candidateexinstiX, Y, Z, T) for "( X, Y, Z) is one of
on any input of size n, M computes an answer in at the instructions that could be executed at time T".

127
otherezinst(X, Y, Z, T) for "the instruction (X, Y, Z) (3.1.4) ezinst(f, X, A, W) +-- time(T), time(W),
is not executed at time T". succ( T, W), symb(X ), cell (Y), rwct T),
syct(X, Y, T), rwst(f ,
succ(X, Y) for "Y = X + 1"
Case 2. The read-write state is ql at time t where q/
neq(X, Y) for "X ~ Y" f and we are reading symbol aj at time t, but
A is a propositional letter. 6(qi,ai) = 0. We have two clauses that ensure
that we can not get into this situation in a stable
Whenwe encode a specific machine, input and run-
model.
time, we will need constants. Notice that in the pro-
gram P that we will write, there should be no constants. (3.2.1) A *-- time(T), cell(Y), symb( X), state(g),
rwst( Z, T), syct( X, Y, T), nogood(Z),--A
Wewill not be absolutely strict in this respect in this
Case 3. The read-write state is qi at time t where ql ~ f
paper. In the program P described below, we use five
constants l, r,,~, f and 1. These constants can easily and t ~ p(n), we are reading symbol aj at time
be eliminated by replacing the explicit use of such con- and
stunts by new one-place unary predicates pred-lambda, ~(ql,aj) = {(qlo, ajo,Tko),-.., (qi,, aj,,Tk,)}
pred-r etc. Then, in the extensional database, we need Our next clauses are designed to ensure that there
only ensure that pred-lambda is satisfied only by ~, is a unique instruction to be executed at time t.
pred-r is only satisfied by r, etc.
The following will be the constants that will be used (3.3.1) eandidateexinst( S1, X1, Z, W) +-- state(S),
in our description of time, cell numbers, cell contents state(S1), symb( X ), symb( X1), action(g),
and specific machines. The last two families of con- time(T), time(W), suce(T, W), rwet(Y,
stunts will be "machine-dependent", since we did not syct ( X, Y, T), rwst( S, T), delta(S, X, X1, Z).
specify any restrictions on the finite sets Q and ~]. (1)
(3.3.2) exinst(S, X, Z, W) +-- state(S), symb(X),
constant symbols 0, 1,... ,p(n) where n is the length action(Z), time (W), candidateexinst ( S, X, Z,
of the input a, p is the runtime polynomial. (2) -,otherexinst( S, X, Z, W).
qo,...,qp+l , where Q = {qo,...,q~-l}, and we will
assume that s = q0 and f = qp+l. (3) al,...,a~+l (3.3.3) otherexinst( S, X, Z, W) +-- state(S), state(S1),
symb( X ), symb( X1) , action(Z), action(Z1),
where E = {al,... ,at}, and B (blank symbol) is ar+l exinst( S1, X1, Z1, W), neq( S1)
(4) r, l, A. Weare now ready to write the program
(3.3.4) otherexinst(S, X, Z, W) +-- state(S), state(S1),
1. Our first three clauses will ensure that in a stable symb( X ), symb( X1), action(Z), action(Z1),
model, the read-write head is in exactly one state at exinst(S1, X1, Z1, W), neq(X, X1).
any given time t. (3.3.5) otherexinst( S, X, Z, W) ~-- state(S), state(S1),
(1.1) A +- time(T), state(X), state(Y), symb( X), symb( X1), action(Z), action(Z1),
rwst( X, T), rwst(Y, T), neq( X, Y ), ezinst( S1, X1, Z1, W), neq( Z1)
(1.2) rwst(X,T) +-- time(T),state(X), 4. Executing the next instruction. These clauses de-
-~otherrwst( X, T). scribe the computation process, i.e. the change in
(1.3) otherrwst( X, T) ~- time(T), state(X), state(Y), time, the state of the read-write head, the content of
rwst(Y, T), neq(X, tape, and the position of the read-write head.
2. Our next three clauses will ensure that in a stable (4.1.1) (Inertia rule - dealing with the content of cells that
do not change)
model, there is exactly one symbol in cell y at any
syct(X, Y, W) ~ time(T), time(W), succ(T,
given time t. symb(X), cell(Y), cell(g), neq(Y, Z), rwct(
(2.1) A ~ time(T), cell(Y), symb(X), symb(X1), syct(X, Y, T).
syct(X, Y, T), syct(X1, Y, T), neq(X, X1), --A. (4.1.2) (Content of the cell changes according to instruc-
(2.2) syct(X, Y, T) ~- time(T), cell(Y), symb(X), tion)
~othersyct ( X , Y, T) syct(X, Y, W) 4-- time(T), time(W), succ(T;
(2.3) othersyct(X, Y, T) 4- time(T), cell(Y), symb(X), symb( X), cell(Y), state(S), action(Z),
symb( X1), syct( X1, Y, T), neq(X, X1). exinstr( S, X, Z, W), rwct(Y,
3. These clauses describe the operation of the Turing (4.2) (Changing the state of the read-write head accord-
ing to instruction)
machine.
rwst( S, W) ~- time(T), time(W), succ(T,
Case 1. The read-write head is in the final state f. symb( X), ceU(Y), state(S), action(Z),
(3.1.1) rwst(f, W) ~ time(T), time(W), succ(T, exinstr( S, X, Z, W), rwct(Y,
rwst(f ,T) (4.3.1) (Movingthe read-write head left, if at a cell with
(3.1.2) rwct(Y, W) +-- time(T), time(W), succ(T, index that is different from 1)
cell(Y), rwct(Y, T), rwst(/, rwct(Y, W) +-- time(T), time(W), suce(T,
(3.1.3) syct(X, Y, W) ~ time(T), time(W), succ(T, symb(X), cell(Y), cell(Z), neq( 1), succ(Y, Z),
symb(X ), cell(Y), syct( X, Y, T), rwst(f exinstr( S, X, 1, W), rwct( Z,

128
(4.3.2) (Blocking an attempt to movelefttheread-write Main Results
headwhenpointing to thecellof indexi)
The main resultsof this papercan be summedup in
A +-- time(T), time(W), succ(T, W), symb(X), thefollowingthreeresults.Ourfirstproposition
imme-
state(S), exinstr( S, X, l, W), rcwt(1, T), -~A. diatelyfollowsfromourconstruction.
(4.4) (Movingthe read-write head right).
rwct(Y, W) +-- time(T), time(W), succ(T, Theorem 1 There is a polynomial q so that for ev-
symb(X), cell(Y), cell(Z), succ( ery machine M, polynomial p, and an input a, the
exinstr( S, X, r, W), rwct( Z, size of the extensional database edbM,p,~ is equal to
q(IMI, I~l,P(lal).
(4.5) (Leaving the read-write head where it is).
rwct(Y, W) +-- time(T), time(W), succ(T, Wewill prove that for any nondeterministic Turing
symb( X ), cell(Y), ezinstr( S, X, A, W), rwct(Y, Machine M, runtime polynomial p(x), and input a of
length n, that the stable models of edbM,p,~t.J PTru en-
5. Our next set of clauses ensures that in a stable model,
the read-write head is over exactly one cell at time t. code the sequences of tapes of length p(n) which occur
in the steps of an accepting computation of Mstarting
(5.1) A ~- time(T), cell(Y), cell(Y1), on a and that any such sequence of steps can be used
neq(Y, Y1), rwct(Y, T), rwct(Y 1, T), -~A. to produce a stable model of edbM.p,~ U PT~u.
(5.2) rwa(Y,T) ~- time(T), cell(Y), ~otherrwa(Y,T). Theorem 2 The mapping of Turing machines to
(5.3) otherrwct(Y, T) e- time(T), cell(Y), ceU(Y1), DATALOG "~ programs defined by M ~ eclbM,p,~, t9
neq(Y, Y1), rwct(Y1, T). Prra has the property that there is a 1-1 polynomial
time correspondence between the set of stable models of
6. This group consists of a single clause. That clause
edbM,p,~ U PT~ and the set computations of M of the
ensures that in a stable model, the read-write head
ends in state f = qp+l at time t = p(n).) length p(n) ending in the state f
A ~- lasttime(T), state(X), neq(X, f), rwst(X, Corollary 1 A search S problem can be solved by
~ program consisting of all means of a uniform logic program if and only if S is
We call the DATALOG an NP-search problem.
clauses in groups (1)-(6), Turing program, PTrg.
Wecan also prove that similar results hold for default
Extensional database - coding of the logic programs without function symbols with respect
to nondeterministic Turing machines with an oracle for
machine, input and the run-time 3-SAT. It follows that a search problem S can be solved
Wewill define now the extensional database extM,p,a. by means of a uniform default logic program if and only
Given initial input a = al ... an and runtime p(n), we if S is in ~,.
let I(~,p(n)) consist of the following set of facts.
Metalnterpreters for logic programs
1. Basic descriptive facts
Wewill now discuss metainterpreters, i.e. programs
(a) state(ql) e- for i = 0,...,p + 1. that process programs. Our goal is to build a single
(b) symb(al) e- for i = 1,...,r + 1. DATALOG-"program P that given a coding edbQ of
(c) delta(s, z, sl, xl, d) +-- for every pair (s, z) and ev- a propositional logic program Q, the stable models of
ery triple (sl,xl,d) E 6(s,x). P t9 edb0 codes the stable models of Q. Such program
is analogous to the classical ’vanilla metainterpreter’ of
(d) nogood(s,x) for every pair (s,x) such that
(Bowen & Kowalski 1982).
6(s, x)= 0. In this paper, we will describe a metalnterpreter for
(e) suce(i, i + 1) +-- for 0 < i < p(n). the class 0-2 programs as described in the introduction.
(f) neq(a,b) ~- for alla,b E {0,...,p(n)} with a ~ A propositional program P is a 0-Z program if for every
(g)time(i) e- for0 < i < p(n). clause C of P has either no positive literal in the body,
or exactly 2 positive literals in the body. Blair proved
(h) lasttime(p(n) 1) that 0-2 programs semirepresent all propositional pro-
(i) cell(i) +-- for 1 <_i < p(n). grams. (See (Marek & Truszczyfiski 1993), Ch. 5,
O) syct(ai, i, O) for i = 1,..., n and syct(B,i, O) +-- the discussion of semirepresentability). This result is
for i = n + 1,...,p(n). implicit in (Blair & al. 1999). Specifically we have the
following.
(k)action(l), action(r), action(A).
2. Beginning state of the Read-Write Head Theorem 1 (Blair)There is a linear-lime com-
rwst(qo,O) +-- (recall q0 = s is the start state.) putable function f that assigns to each propositional
program P a 0-2 program f(P) and such that there is
3. rwet(1,0) ~. This is initial read-write head cell con- one-to-one projection from the family of stable models
dition. of f(P) to the family of stable models of

129
To putBlair’sresultin properperspective, we note I. Generating
thecandidate
fora model
thatthereis a morerestrictive classof programs with
(a) in(A) e- atom(A),-~out(A)
an evenstronger property. Namely,calla programP
purelynegative if theclausesof P haveno positive (b) out(A) ~- atom(A),-.in(A)
literalsin the body.Dung and Kanchanasut (Dung 2. Computing Geffond-Lifschitz reduet
& Kanchanasut 1989)provedthateverypropositional
program is representable by a purelynegative program. (a) unusable(C) ~- clause(C), atom(A),
neg( A, C),in(A)
However,the purelynegativeprogramof Dung and
Kanchanasut can not be computedin polynomial time (b) usable(C) e- clause(C),-,unusable(C)
fromtheoriginal program. Thusthecostof thistype 3. Classifying clauses
of moreextensive preprocessing wouldbe prohibitive.
We shallnow construct our metainterpreter Metal (a) nempty(C) ~ clause(C), atom(A),first(A,
thatcomputes stablemodelsof 0-2propositional pro- (b) empty(C) ~- clause(C), "~nempty(C)
grams.To thisendwe needa datastructure thatex- 4. Computation process
presses thegiven0-2program Q. Theextensional pred-
icatesthatoccurin theextensional database edbQare (a) computed(A) e- clause(C), empty(C), usable(C),
asfollows: head(A, C)
1. atom(.) forlisting atoms, (b) computed(A) ¢-- clause(C),first(A1,
second(A2, C), computed(A1), computed(A2),
2.clause(.) forlisting clauses,
head(A, C)
3. head(., .)forspecifying theheadofa clause,
5. Constraints
4. neg(., .)forspecifying thatan atomoccurs negatively
in thebodyof a clause, (a) f e- atom(A), in(A),-,computed(A),-~f
5.first(., .)forspecifying thatanatomisthefirst ofthe (b) f +- atom(A), out(A), computed(A),-.f
twopositive atomsoccurring in thebodyof a clause, Wenow have the following result
and
Theorem 3 For every propositional 0-2 program Q,
6. second(., .) forspecifying thatan atomis thesec- there is a one-to-one correspondencebetween set of sta-
ondof twopositive atomsoccurring in thebodyof a ble models of Q and the set of stable models of Metal U
clause. edbQ. Moreover, we can recover a stable model of Q
Nextwe listtheintentional predicates thatalsooccur from its corresponding stable model of Metal t2 edbQ in
in Metal. linear time.
1. nempty(.) forspecifying thatthereareatomsoccur- Thus, in order to compute stable models of a proposi-
ringpositively in thebodyof a clause. tional program P, first process P using Proposition 1,
2. empty(.) forspecifying thatthereareno atomsoc- getting a program Q. Next, apply Proposition 3, get
curring positively in thebodyof a clause. a stable model of Metal U edb0 and project it twice.
First to get a stable model of Q and then of P.
3. in(.)forspecifying theatomswhichoccurin thesta- Wenote that the metainterpreter Metal does dis-
ble modelof theinputprogram. tinguish between the stable and supported semantics.
4. out(.) forspecifying theatomswhichdo notoccurin That is, the supported models of Metal U edbQ do
thestablemodelof theinputprogram. not necessarily determine stable models of Q. Fi-
5. unusable(.), forspecifying theclauses do notoccur nally, we note that by using techniques similar to
in theGelfond-Lifschitz reduct relative tothestable those used to construct our program P~, we can
model. write another metainterpreter Meta2 that does not re-
quire a particular form for the input propositional pro-
6. usable(.) forspecifying theclauses thatoccurin the gram. This requires a more complicated construction
Gelfond-Lifschitz reduct relative to thestable model. where we directly simulate the iterations of the opera-
7. computed(.) for specifying the atoms which are com- tor TGzu(Q) in the computation of a stable model
puted to be in the stable model. from it Gelfond-Lifschitz reduet GLM(Q). Wecan not
8. f a propositional atoms used to enforce constraints. supply details here due to lack of space. However, we
will provide such details in the full version of the paper.
The extensional database edbQ for a propositional pro-
gram Q consists of the atoms atom(a) for all atoms a
occurring in Q, the atoms clause(c) for all clauses c References
in Q, the atoms head(a, c) for the head a of clause c, K.R.AptLogicProgramming.in Handbook
of Theoretical
the atoms first(a, c) and second(b, c) where a, b are first Computer
Science,pp.475-574.
Elsevier,
1990.
and the second atom in the body of c, respectively. We K.R.AptandH.A.Blair. Arithmetical
classification
of
denote this collection of atoms edbq. perfect
modelsofstratifiedprograms.
Fundamenta
InJor-
Wenowdescribe the metainterpreter itself. maticae,
12:1-17,
1990.

130
K. Apt, H.A. Blair, and A. Walker. Towards a theory of J. Jaffar and M.J. Maher. Constraint logic programming:
declarative knowledge. In J. Minker, editor, Foundations of A survey. Journal o]Logic Programming, 19(20):503-581,
deductive databases and logic programming, pages 89-142, 1994.
Los Altos, CA, 1988. Morgan Kanfmann. V. Lifschitz. Action languages, answer sets and planning.
K.R. Apt and D. Pedreechi. Reasoning about termination The Logic Programming Paradigm, pp. 357-373. Series
of pure Prolog program.q. Information and Computation Artificial Intelligence, Springer-Verlag, 1999.
106:109-157, 1994. V. Lifschitz. Answer set planning. In Logic program-
K.R. Apt and A. Pellegrini. On the occur-check free pure ming and nonmonotonic reasoning, volume 1730 of Lec-
Prolog progr~mR~A CMToplas 16:687-726, 1994. ture Notes in Computer Science, pages 373-374. Springer-
S. Abiteboul, R. Hull, and V. Vianu. Foundations of Verlag, 1999.
Databases. Addison-Wesley Publishing Company, 1995. W. Marek, A. Nerode, and J. B. Remmel. The stable mod-
H.A. Blair, W. Marek, and J. Schlipf. The expressiveness els of predicate logic program.q. Journal of Logic Program-
of locally stratified programs. Annals of Mathematics and ming, 21(3):129-154, 1994.
Artificial Intelligence, 15:209-229, 1995. W. Marek and M. Truszczyfiski. Autoepistemic logic. Jour-
H.A. Blair, F. Dnshin, D.W. Jackel, A.3. Rivera and M. nal of the ACM, 38:588-619, 1991.
Sezgin, Continuous Models of Computation for Logic Pro- W. Marek and M. Truszczydski. Nonmonotonic Logic
gramA: Importing Continuous Mathematics into Logic Pro- - Conte.zt-Dependent Reasoning. Series Artificial Intelli-
gramming’s Algorithmic Foundations, The Logic Program- gence, Springer-Verlag, 1993.
ming Paradigm, pp. 231-255, Series Artificial Intelligence,
W. Marek and M. Trnszczyfiski. Stable Models and an Al-
Springer-Verlag, 1999. ternative Logic Programming Paradigm. The Logic Pro-
K.A. Bowen and tLA. Kowalski Amalgamating language grammingParadigm, pp. 375-398. Series Artificial Intelli-
and metaianguage in Logic Programming. In: Logic Pro- gence, Springer-Verlag, 1999.
gramming, pp. 153-172, Academic Press, 1982.
K. Marriott and P.J. Stuckey. Programming with Con-
M. Cadoli and L. Palipoli. Circumscribing dataiog: expres- straints: An Introduction. MIT Press, Cambridge, MA,
sive power and complexity. Theoretical Computer Science, 1998.
193:215-244, 1998. I. Niemel~. Logic program-q with stable model semantics
D. Cenzer and J.B. RemmelFI° Classes in Mathematics. In: as a constraint programming paradigm. In Proceedings of
Handbook of Recursive Mathematics pp. 623-821, Elsevier the Workshop on Computational Aspects of Nonmonotonic
1999. Reasoning, pages 72-79, 1998.
P. Cholewi6ski, W. Marek, A. Mikitiuk, and I. Niemel~ and P. Simons. Efficient implementation of the
M. Truszczyfiski. Programmingwith default logic. Artifi- well-founded and stable model semantics. In Proceedings
cial Intelligence 112:105-146, 1999. of JICSLP-96. MIT Press, 1996.
A. Colmerauer, H. Kanoui, tL Pasero, and P. Roussel. Un T. Przymusi6ski. On the declarative semantics of deduc-
syst~me de communication homme-machine en franqais. tive databases and logic programs. In Foundations of de-
Technical report, University of MarseUle, 1973. ductive databases and logic programming, pages 193-216,
S. Cook. The complexity of theorem-proving procedures. Los Altos, CA, 1988. Morgan Kaufmann.
Proceedings of Third Annual A CMSymposium on Theory T. Przymusinski. The Well-Founded Semantics Coincides
of Computing pp. 151-158. 1971. With The Three-Valued Stable Semantics, Fundamenta
P.M. Dung and K. Kanchanasut, On the generalized predi- Informaticae, 13:445-464, 1990.
cate completion of non-Horn programs, In: Logic program- P. Rao, I.V. Ramskrishnan, K. Sagonas, T. Swift, D. S.
ming, Proceedings of the North American Conference, pp. Warren, and J. Freire. XSB: A system for efficiently
587-603, MIT Press, 1989. computing well-founded semantics. In Proceedings of LP-
East, D., and Truszczy~ki, M. 2000. Dataiog with con- NMR’97, pages 430-440, Lecture Notes in Computer Sci-
straints. In Proceedings of the Seoenteenth National Con- ence, 1265, Springer-Verlag, 1997.
ference on Artificial Intelligence (AAAI-£O00), 163-168, J. Scldipf. The expressive powers of the logic programming
2000. semantics. Journal of the Computer Systems and Science,
T. Eiter, N. Leone, C. Mateis, G. Pfeifer, and F. Scarcello. 51:64-86, 1995.
The KR System dlv: Progress Report, Comparisons, and
T. Soininen and I. Niemel~. Developing a declarative rule
Benchmarks. In Proceedings Si~-th International Confer-
language for applications in product configuration. In Pro-
ence on Principles of Kno~oledge Representation and Rea-
ceedings of the First International Wor~hopin Practical
soning (KR-gS), pages 406-417, 1998.
Aspects of Declarative Languages, pages 305--319. Springer-
A. Ferry, Topological Characterizations for Logic Program- Verlag, 1999.
ming Semantics, Ph.D. Dissertation, University of Michi-
.I.D. Ullman. Principles of Database and Knowledge*Base
gan, 1994. Systems. Computer Science Press, Rockville, MD,1988.
M.R. Garey and D.S. Johnson. Computers and intractabil-
A. Van Gelder, K.A. Ross, and J.S. Schlipf. Unfounded
ity; a guide to the theory of NP-completeness. W.H. Free-
sets and well-founded semantics for general logic programs.
man, 1979.
Journal of the ACM,38:620-650, 1991.
M. Gelfond and V. Lifschitz. The stable semantics for logic
L. Wall, T. Christiansen, and J. Orwant. Programming
programs. In Proceedings of the 5th International Sympo-
Perl, Third edition, O’Reilly, 2000.
sium on Logic Programming, pages 1070-1080, Cambridge,
MA, 1988. MIT Press.

131

You might also like