1 Introduction
Answer set programming (ASP) is nowadays a wellestablished and successful programming paradigm based on answer set semantics [Gelfond and Lifschitz (1988), Marek and Truszczyński (1999)], with applications in many areas (cf., e.g., [Baral (2003), Truszczyński (2007), Gelfond (2007)] and the references therein). Nevertheless, as noted in [Gebser et al. (2009), Bonatti et al. (2008)], few attempts to construct a goaloriented proof procedure exist, though there is a renewal of interest, as attested, e.g., by the recent work presented in [Marple and Gupta (2014)]. This is due to the very nature of the answer set semantics, where a program may admit none or several answer sets, and where the semantics enjoys no locality, or, better, no Relevance in the sense of [Dix (1995)]: no subset of the given program can in general be identified, from where the decision of atom (intended as a goal, or query) belonging or not to some answer set can be drawn. An incremental construction of approximations of answer sets is proposed in [Gebser et al. (2009)] to provide a ground for local computations and topdown query answering. A sound and complete proof procedure is also provided. The approach of [Bonatti et al. (2008)] is in the spirit of “traditional” SLDresolution [Lloyd (1993)], and can be used with nonground queries and with nonground, possibly infinite, programs. Soundness and completeness results are proven for large classes of programs. Another way to address the queryanswering problem is discussed in [Lin and You (2002)]. This work describes a canonical rewriting system that turns out to be sound and complete under the partial stable model semantics. In principle, as the authors observe, the inference procedure could be completed to implement queryanswering w.r.t. stable model semantics by circumventing the lack of Relevance. A substantially different approach to ASP computation is proposed in [Gebser and Schaub (2006)] where the authors define a tableaubased framework for ASP. The main aim consists in providing a formal framework for characterizing inference operations and strategies in ASPsolvers. The approach is not based on queryoriented topdown evaluation, indeed, each branch in a tableau potentially corresponds to a computation of an answer set. However, one might foresee the possibility of exploiting such a tableau system to check answer set existence subject to query satisfaction.
A relevant issue concerning goaloriented answersetbased computation is related to sequences of queries. Assume that one would be able to pose a query receiving an answer “yes”, to signify that is entailed by some answer set of the given program . Possibly, one might intend subsequent queries to be answered in the same context, i.e. a subsequent query might ask whether some of the answer sets entailing also entails . This might go on until the user explicitly “resets” the context. Such an issue, though reasonable in practical applications, has been hardly addressed up to now, due to the semantic difficulties that we have mentioned. A viable approach to these problems takes inspiration from the research on RASP (Resourcebased ASP), which is a recent extension of ASP, obtained by explicitly introducing the notion of resource [Costantini and Formisano (2010)]. A RASP and linearlogic modeling of default negation as understood under the answer set semantics has been introduced in [Costantini and Formisano (2013)]. This led to the definition of an extension to the answer set semantics, called Resourcebased Answer Set Semantics (RAS). The name of the new semantics comes from the fact that in the linearlogic formulation every literal (including negative ones) is considered as a resource that is “consumed” (and hence it becomes no more available) once used in a proof. This extension finds an alternative equivalent definition in a variation of the autoepistemic logic characterization of answer set semantics discussed in [Marek and Truszczyński (1993)].
We refer the reader to [Costantini and Formisano (2015)] for a discussion of the new semantics from several points of view, and to the Appendix for a summary of its formal definition. Under resourcebased answer set semantics there are no inconsistent programs, i.e., every program admits (resourcebased) answer set. Consider for instance the program
. Under the answer set semantics, this program is inconsistent (has no answer sets) because it consists of a unique odd cycle and no supported models exists. If we extend the program to
then the resulting program has the answer set : in fact, the first rule is overridden by the second rule which allows to be derived. Under the resourcebased answer set semantics the first rule is ignored in the first place: in fact, has a unique resourcebased answer set which is the empty set. Intuitively, this results from interpreting default negation as “I assume that is false” or, in autoepistemic terms [Marek and Truszczyński (1991a), Marek and Truszczyński (1991b)] “I believe that I don’t believe ”. So, since deriving accounts to denying the assumption of , such a derivation is disallowed as it would be contradictory. It is not considered to be inconsistent because default negation is not negation in classical logic: in fact, the attempt of deriving from in classical logic leads to an inconsistency, while contradicting one’s own assumption is (in our view) simply meaningless, so a rule such as the one in is plainly ignored. Assume now to further enlarge the program, by obtaining . There are again no answer sets, because by combining the last two rules a contradiction on is determined, though indirectly. In resourcebased answer set semantics there is still the answer set , as the indirect contradiction is ignored: having assumed makes unprovable.In standard ASP, a constraint such as where the s are literals is implemented by translating it into the rule with fresh atom. This is because, in order to make the contradiction on harmless, one of the s must be false: otherwise, no answer set exists. Under resourcebased answer set semantics such a transposition no longer works. Thus, constraints related to a given program are not seen as part of the program: rather, they must be defined separately and associated to the program. Since resourcebased answer sets always exist, constraints will possibly exclude (aposteriori) some of them. Thus, constraints act as a filter on resourcebased answer sets, leaving those which are admissible with respect to given constraints.
In this paper we discuss a topdown proof procedure for the new semantics. The proposed procedure, beyond queryanswering, also provides contextualization, via a form of tabling; i.e., a table is associated with the given program, and initialized prior to posing queries. Such table contains information useful for both the next and the subsequent queries. Under this procedure, (where we us assume with no loss of generality that is an atom), succeeds whenever there exists some resourcebased answer set where . Contextualization implies that given a sequence of queries, for instance , both queries succeed if there exists some resourcebased answer set where : this at the condition of evaluating on the program table as left by (analogously for longer sequences). In case the table is reset, subsequent queries will be evaluated independently of previous ones. Success of must then be validated with respect to constraints; this issue is only introduced here, and will be treated in a future paper.
Differently from [Gebser et al. (2009)], the proposed procedure does not require incremental answer set construction when answering a query and is not based on preliminary program analysis as done in [Marple and Gupta (2014)]. Rather, it exploits the fact that resourcebased answer set semantics enjoys the property of Relevance [Dix (1995)] (whereas answer set semantics does not). This guarantees that the truth value of an atom can be established on the basis of the subprogram it depends upon, and thus allows for topdown computation starting from a query. For previous sample programs and , query succeeds, while fails. W.r.t. the topdown procedure proposed in [Bonatti et al. (2008)], we do not aim at managing function symbols (and thus programs with infinite grounding), so concerning this aspect our work is more limited.
As answer set semantics and resourcebased answer set semantics extend the wellfounded semantics [Van Gelder et al. (1991)], we take as a starting point XSBresolution [Swift and Warren (2012), Chen and Warren (1993)], an efficient, fully described and implemented procedure which is correct and complete w.r.t. the wellfounded semantics. In particular, we define RASXSBresolution and discuss its properties; we prove correctness and completeness for every program (under the new semantics). We do not provide the full implementation details that we defer to a next step; in fact, this would imply suitably extending and reworking all operative aspects related to XSB. Thus, practical issues such as efficiency and optimization are not dealt with in the present paper and are rather deferred to future work of actual specification of an implementation. The proposed procedure is intended as a proofofconcept rather than as an implementation guideline.
RASXSB resolution can be used for answer set programming under the software engineering discipline of dividing the program into a consistent “base” level and a “top” level including constraints. Therefore, even to readers not particularly interested in the new semantics, the paper proposes a full topdown queryanswering procedure for ASP, though applicable under such (reasonable) limitation.
In summary, RASXSBResolution:

can be used for (credulous) topdown queryanswering on logic programs under the resourcebased answer set semantics and possibly under the answer set semantics, given the condition that constraints are defined separately from the “main” program;

it is meant for the socalled “credulous reasoning” in the sense that given, say, query (where is an atom), it determines whether there exists any (resourcebased) answer set such that ;

it provides “contextual” queryanswering, i.e. it is possible to pose subsequent queries, say and, if they all succeed, this means that there exists some (resourcebased) answer set such that ; this extends to the case when only some of them succeed, where successful atoms are all in and unsuccessful ones are not;

does not require either preliminary program analysis or incremental answerset construction, and does not impose any kind of limitation over the class of resourcebased answer set programs which are considered (for answer set programs, there is the abovementioned limitation on constraints).
This paper is organized as follows. After a presentation of resourcebased answer set semantics in Section 2, we present the proposed queryanswering procedure in Section 3, and conclude in Section 4. In the rest of the paper, we refer to the standard definitions concerning propositional general logic programs and ASP [Lloyd (1993), Apt and Bol (1994), Gelfond (2007)]. If not differently specified, we will implicitly refer to the ground version of a program . We do not consider “classical negation”, double negation , disjunctive programs, or the various useful programming constructs, such as aggregates, added over time to the basic ASP paradigm [Simons et al. (2002), Costantini and Formisano (2011), Faber et al. (2011)].
2 Background on Resourcebased ASP
The denomination “resourcebased” answer set semantics (RAS) stems from the linear logic formulation of ASP (proposed in [Costantini and Formisano (2013), Costantini and Formisano (2015)]), which constituted the original inspiration for the new semantics. In this perspective, the negation of some atom is considered to be a resource of unary amount, where:

is consumed whenever it is used in a proof, thus preventing to be proved, for retaining consistency;

becomes no longer available whenever is proved.
Consider for instance the following wellknown sample answer set program consisting of a ternary odd cycle and concerning someone who wonders where to spend her vacation:
In ASP, such program is inconsistent. Under the new semantics, there are the following three resourcebased answer sets: , , and . Take for instance the first one, . In order to derive the conclusion the first rule can be used; in doing so, the premise is consumed, thus disabling the possibility of proving , which thus becomes false; is false as well, since it depends from a false premise.
We refer the reader to [Costantini and Formisano (2015)] for a detailed discussion about logical foundations, motivations, properties, and complexity, and for examples of use. We provide therein characterizations of RAS in terms of linear logic, as a variation of the answer set semantics, and in terms of autoepistemic logic. Here we just recall that, due to the ability to cope with odd cycles, under RAS it is always possible to assign a truth value to all atoms: every program in fact admits at least one (possibly empty) resourcebased answer set. A more significant example is the following (where, albeit in this paper we focus on the case of ground programs, for the sake of conciseness we make use of variables, as customary done to denote collections of ground literals/rules). The program models a recommender agent, which provides a user with indication to where it is possible to spend the evening, and how the user should dress for such an occasion. The system is also able to take user preferences into account.
The resourcebased answer set program which constitutes the core of the system is the following. There are two ternary cycles. The first one specifies that a person can be dressed either formally or normally or in an eccentric way. In addition, only oldfashioned persons dress formally, and only persons with a young mind dress in an eccentric way. Later on, it is stated by two even cycles that any person can be oldfashioned or youngminded, independently of the age that, by the second odd cycle, can be young, middle, or old. The two even cycles interact, so that only one option can be taken. Then, it is stated that one is admitted to an elegant restaurant if (s)he is formally dressed, and to a disco if (s)he is dressed in an eccentric way. To spend the evening either in an elegant restaurant or in a disco one must be admitted. Going out in this context means either going to an elegant restaurant (for middleaged or old people) or to the disco for young people, or sightseeing for anyone.
The above program, if considered as an answer set program, has a (unique) empty resourcebased answer set, as there are no facts (in particular there are no facts for the predicate to provide values for the placeholder ).
Now assume that the above program is incorporated into an interface system which interacts with a user, say George, who wants to go out and wishes to be made aware of his options. The system may thus add the fact to the program. While, in ASP the program would become inconsistent, in RASP the system would, without any more information, advise George to go sightseeing. This is, in fact, the only advice that can be extracted from the unique resourcebased answer set of the resulting program. If the system might obtain or elicit George’s age, the options would be many more, according to the hypotheses about him being oldfashioned or youngminded. Moreover, for each option (except sightseeing) the system would be able to extract the required dress code. George might want to express a preference, e.g., going to the disco. Then the system might add to the program the rule
and state the constraint that “forces” the preference to be satisfied, thus making George aware of the hypotheses and conditions under which he might actually go to the disco. Namely, they correspond to the unique resourcebased answer set where George is young, youngminded and dresses in an eccentric way.
However, in resourcebased answer set semantics constraints cannot be modeled (as done in ASP) as “syntactic sugar”, in terms of unary odd cycles involving fresh atoms. Hence, they have to be modeled explicitly. Without loss of generality, we assume, from now on, the following simplification concerning constraints. Each constraint , where each is a literal, can be rephrased as simple constraint , where is a fresh atom, plus rule to be added to the given program . So, occurs in the set of all the atoms of .
Definition 2.1
Let be a program and be a set of constraints, each in the form .

A resourcebased answer set for is admissible w.r.t. if for all where .

The program is called “admissible” w.r.t. if it has an admissible answer w.r.t. .
It is useful for what follows to evaluate RAS with respect to general properties of semantics of logic programs introduced in [Dix (1995)], that we recall below (see the mentioned article for the details). A semantic for logic programs is intended as a function which associates a logic program with a set of sets of atoms, which constitute the intended meaning.
Definition 2.2
Given any semantics and a ground program , Relevance states that for all literals it holds that .
Relevance implies that the truth value of any literal under that semantics in a given program, is determined solely by the subprogram consisting of the relevant rules. The answer set semantics does not enjoy Relevance [Dix (1995)]. This is one reason for the lack of goaloriented proof procedures. Instead, it is easy to see that resourcebased answer set semantics enjoys Relevance.
Resourcebased answer set semantics, like most semantics for logic programs with negation, enjoys Reduction, which simply assures that the atoms not occurring in the heads of a program are always assigned truth value false.
Another important property is Modularity, defined in [Dix (1995)] as follows (where the reduct of program w.r.t. set of atoms ):
Definition 2.3
Given any semantics , a ground program let where for every atom occurring in , . We say that SEM enjoys Modularity if it holds that .
If Modularity holds, then the semantics can be always computed by splitting a program in its subprograms (w.r.t. relevant rules). Intuitively, in the above definition, the semantics of , which is selfcontained, is first computed. Then, the semantics of the whole program can be determined by reducing w.r.t. . We can state (as a consequence of Relevance and of Proposition A.3 in the Appendix) that resourcebased answer set semantics enjoys Modularity.
Proposition 2.1
Given a ground program let , where for every atom occurring in , . A set of atoms is a resourcebased answer set of iff there exists a resourcebased answer set of such that is a resourcebased answer set of .
Modularity also impacts on constraint checking, i.e. on the check of admissibility of resourcebased answer sets. Considering, in fact, a set of constraints , , each in the form , and letting for each , from Proposition 2.1 it follows that, if a resourcebased answer set of is admissible (in terms of Definition 2.1) w.r.t. , then any resourcebased answer set of such that is also admissible w.r.t. . In particular, can be identified in relation to a certain query:
Definition 2.4
Given a program , a constraint associated to is relevant for query if .
3 A Topdown Proof Procedure for RAS
As it is wellknown, the answer set semantics extends the wellfounded semantics (wfs) [Van Gelder et al. (1991)] that provides a unique threevalued model , where atoms in are true, those in are false, and all the others are undefined. In fact, the answer set semantics assigns, for consistent programs truth values to the undefined atoms. However the program can be inconsistent because of odd cyclic dependencies. The improvement of resourcebased answer set semantics over the answer set semantics relies exactly on its ability to deal with odd cycles that the answer set semantics interprets as inconsistencies. So, in any reasonable potential queryanswering device for ASP, a query to an ASP program may be reasonably expected to succeed or fail if belongs to or , respectively. Such a procedure will then be characterized according to how to provide an answer when is undefined under the wfs.
An additional problem with answer set semantics is that query might locally succeed, but still, for the lack of Relevance, the overall program may not have answer sets. In resourcebased answer set semantics instead, every program has one or more resourcebased answer set: each of them taken singularly is then admissible or not w.r.t. the integrity constraints. This allows one to perform constraint checking upon success of query .
We will now define the foundations of a topdown proof procedure for resourcebased answer set semantics, which we call RASXSBresolution. The procedure has to deal with atoms involved in negative circularities, that must be assigned a truth value according to some resourcebased answer set. We build upon XSBresolution, for which an ample literature exists, from the seminal work in [Chen and Warren (1993)] to the most recent work in [Swift and Warren (2012)] where many useful references can also be found. For lack of space XSBresolution is not described here. XSB in its basic version, XOLDTNFresolution [Chen and Warren (1993)] is shortly described in the Appendix. We take for granted basic notions concerning proof procedures for logic programming, such as for instance backtracking. For the relevant definitions we refer to [Lloyd (1993)]. Some notions are however required here for the understanding of what follows. In particular, it is necessary to illustrate detection of cycles on negation.
Definition 3.1 (XSB Negative Cycles Detection)

Each call to atom has an associated set of negative literals, called the negative context for , so the call takes the form .

Whenever a negative literal is selected during the evaluation of some , there are two possibilities: (i) : this will lead to the call ; (ii) , then there is a possible negative loop, and is called a possibly looping negative literal.

For the initial call of any atom , is set to empty.
In order to assume that a literal is a looping negative literal, that in XSB assumes truth value undefined, the evaluation of must however be completed, i.e. the search space must have been fully explored without finding conditions for success or failure.
Like in XSB, for each program a table records useful information about proofs. As a small extension w.r.t. XSBResolution, we record in not only successes, but also failures. XSBresolution is, for Datalog programs, correct and complete w.r.t. the wfs. Thus, it is useful to state the following definition.
Definition 3.2
Given a program and an atom , we say that

definitely succeeds iff it succeeds via XSB (or, equivalently, XOLDTNF) resolution, and thus is recorded in with truth value true. For simplicity, we assume occurs in .

definitely fails iff it fails via XSB (or, equivalently, XOLDTNF) resolution, and thus is recorded in with truth value false. For simplicity, we assume occurs in .
To represent the notion of negation as a resource, we initialize the program table prior to posing queries and we manage the table during a proof so as to state that:

the negation of any atom which is not a fact is available unless this atom has been proved;

the negation of an atom which has been proved becomes unavailable;

the negation of an atom which cannot be proved is always available.
Definition 3.3 (Table Initialization in RASXSBresolution)
Given a program and an associated table , Initialization of is performed by inserting, for each atom occurring as the conclusion of some rule in , a fact (where is a fresh atom).
The meaning of is that the negation of has not been proved. If is present in the table, then can possibly succeed. Success of “absorbs” and prevents from success. Failure of or success of “absorbs” as well, but is asserted. will in fact evolve during a proof into subsequent states, as specified below.
Definition 3.4 (Table Update in RASXSBresolution)
Given a program and an associated table , referring to the definition of RASXSBresolution (cf. Definition 3.5 below), the table update is performed as follows.

Upon success of subgoal , is removed from and is added to .

Upon failure of subgoal , is removed from and is added to .

Upon success of subgoal , is removed from and is added to . However:

if succeeds by case 3.b, then such modification is permanent;

if succeeds either by case 3.c or by case 3.d, then in case of failure of the parent subgoal the modification is retracted, i.e. is restored in and is removed from .

We refer the reader to the examples provided below for a clarification of the tableupdate mechanism. In the following, without loss of generality we can assume that a query is of the form , where is an atom. Success or failure of this query is established as follows. Like in XSBresolution, we assume that the call to query implicitly corresponds to the call where is the negative context of , which is initialized to and treated as stated in Definition 3.1.
Definition 3.5 (Success and failure in RASXSBresolution)
Given a program and its associated table , notions of success and failure and of modifications to are extended as follows with respect to XSBresolution.

Atom succeeds iff is present in , and one of the following conditions holds.

definitely succeeds (which includes the case where is present in ).

There exists in either fact or a rule of the form , , such that neither nor occur in the body and every literal , , succeeds.


Atom fails iff one of the following conditions holds.

is not present in .

definitely fails.

There is no rule of the form , , such that every literal succeeds.


Literal succeeds if one of the following is the case:

is present in .

fails.

is allowed to succeed.

is forced to failure.


Literal fails if succeeds.

is allowed to succeed whenever the call results, whatever sequence of derivation steps is attempted, in the call . I.e., the derivation of incurs through layers of negation again into .

is forced to failure when the call always results in the call , whatever sequence of derivation steps is attempted. I.e., the derivation of incurs in directly.
From the above extension of the notions of success and failure we obtain RASXSBresolution as an extended XSBresolution. Actually, in the definition we exploit XSB (or, more precisely, XOLDTNF), as a “plugin” for definite success and failure, and we add cases which manage subgoals with answer undefined under XSB. This is not exactly ideal from an implementation point of view. In future work, we intend to proceed to a much more effective integration of XSB with the new aspects that we have introduced, and to consider efficiency and optimization issues that are presently neglected.
Notice that the distinction between RASXSBresolution and XSBresolution is determined by cases 3.c and 3.d of Definition 3.5, which manage literals involved in negative cycles. The notions of allowance to succeed (case 5) and of forcing to failure (case 6) are crucial. Let us illustrate the various cases via simple examples:

Case 3.c deals with literals depending negatively upon themselves through other negations. Such literals can be assumed as hypotheses. Consider, for example, the program Query succeeds by assuming , which is correct w.r.t. (resourcebased) answer set . If, however, the program is then, the same query fails upon definite failure of , so the hypothesis must be retracted. This is, in fact, stated in the specification of table update (Definition 3.4).

Case 3.d deals with literals depending negatively upon themselves directly. Such literals can be assumed as hypotheses. Consider, for example, the program . Query succeeds because the attempt to prove comes across (through ), and thus is forced to failure. This is correct w.r.t. resourcebased answer set . Notice that for atoms involved in negative cycles the positivecycle detection is relaxed, as some atom in the cycle will either fail or been forced to failure. If however the program is then, the same query fails upon definite failure of , so the hypothesis must be retracted. This is in fact stated in the specification of table update (Definition 3.4).
We provide below a highlevel definition of the overall proof procedure (overlooking implementation details), which resembles plain SLDresolution.
Definition 3.6 (A naive RASXSBresolution)
Given a program , let assume as input the data structure used by the proof procedure for tabling purposes, i.e. the table associated with the program. Given a query , the list of current subgoals is initially set to . If in the construction of a prooftree for a literal is selected in the list of current subgoals , we have that: if succeeds then we take as proved and proceed to prove after the related updates to the program table. Otherwise, we have to backtrack to the previous list of subgoals.
Conditions for success and failure are those specified in Definition 3.5. Success and failure determine the modifications to specified in Definition 3.4. Backtracking does not involve restoring previous contents of , as subgoals which have been proved can be usefully employed as lemmas. In fact, the table is updated only when the entire search space for a subgoal has been explored. The only exception concerns negative subgoals which correspond to literals involved in cycles: in fact, they are to considered as hypotheses that could later be retracted.
For instance, consider the program
and query . Let us assume clauses are selected in the order. So, the first clause for is selected, and is initially allowed to succeed (though involved in a negative cycle with ). However, upon failure of subgoal with consequent backtracking to the second rule for , lemma must be retracted from the table: this in fact enables to be allowed to succeed, so determining success of the query.
Definition 3.7
Given a program and its associated table , a free query is a query which is posed on when the table has just been initialized. A contextual query is a query which is posed on leaving the associated table in the state determined by former queries.
Success of query means (as proved in Theorem 3.1 below) that there exist resourcebased answer sets that contain . The final content of specifies literals that hold in these sets (including ). Precisely, the state of characterizes a set resourcebased answer sets of , such that for all , and for every atom , implies and implies . Backtracking on accounts to asking whether there are other different resourcebased answer sets containing , and implies making different assumptions about cycles by retracting literals which had been assumed to succeed. Instead, posing a subsequent query without resetting the contents of , which constitutes a context, accounts to asking whether some of the answer sets in also contain . Posing such a contextual query, the resulting table reduces previouslyidentified resourcebased answer sets to a possibly smaller set whose elements include both and (see Theorem 3.2 below). Contextual queries and sequences of contextual queries are formally defined below.
Definition 3.8 (Query sequence)
Given a program and queries , …, performed one after the other, assume that is initialized only before posing . Then, is a free query where each , is a contextual query, evaluated w.r.t. the previous ones.
To show the application of RASXSBresolution to single queries and to a query sequence, let us consider the
sample following program , which includes virtually all cases of potential success
and failure.
The wellfounded model of this program is while
the resourcebased answer sets are and .
Initially, includes for every atom occurring in some rule head: ,,,,,,,,. Below we illustrate some derivations. We assume that applicable rules are considered from first () to last () as they are ordered in the program, and literals in rule bodies from left to right.
Let us first illustrate the proof of query . Each additional layer of indicates nested derivation of whenever literal is encountered. In the comment, we refer to cases of RASXSBresolution as specified in Definition 3.5. Let us first consider query .
Subgoal is treated as follows.
Subgoal gives now rise to the following derivation.
Assuming now to go on to query the same context, i.e. without reinitializing , query quickly fails by case 2.a since . Query succeeds immediately by case 1.a as . We can see that the context we are within corresponds to resourcebased answer set . Notice that, if resetting the context, would instead succeed as by case 1.b as can be allowed to succeed by case 3.c. Finally, a derivation for is obtained as follows:
Then, at the upper level, and succeed by case 1.b, and . Notice that forcing to failure determines to succeed, and consequently allows to succeed (where is undefined under the wfs). The derivation of involves the tricky case of a positive dependency through negation.
3.1 Properties of RASXSBresolution
Properties of resourcebased answer set semantics are strictly related to properties of RASXSBresolution. In fact, thanks to Relevance we have soundness and completeness, and Modularity allows for contextual query and locality in constraintchecking. Such properties are summarized in the following Theorems (whose proofs can be found in Appendix).
Theorem 3.1
RASXSBresolution is correct and complete w.r.t. resourcebased answer set semantics, in the sense that, given a program , a query succeeds under RASXSBresolution with an initialized iff there exists resourcebased answer set for where .
Theorem 3.2
RASXSBresolution is contextually correct and complete w.r.t. resource Answer Set semantics, in the sense that, given a program and a query sequence , …, , , where (i.e. the s are atoms occurring in ), we have that, for and , the queries , …, succeed while , …, fail under RASXSBresolution, iff there exists resourcebased answer set for where and .
This result extends immediately to queries including negative literals such as , . We say that a query sequence contextually succeeds if each of the involved queries succeeds in the context (table) left by all former ones.
We defer a discussion of constraint checking to a future paper. Notice only that, given an admissible program and a constraint (where is an atom), success of the query in a certain context (given by ) means that this constraint is fulfilled in the admissible resourcebased answer sets selected by that context. If the context where is executed results from a query , this implies by Theorem 3.2 that is fulfilled at least one admissible resourcebased answer set including . So, in admissible programs one should identify and check (a posteriori) constraints that are relevant to the query according to Definition 2.4.
4 Concluding Remarks
A relevant question about RASXSBresolution is whether it might be applicable to nonground queries and programs. By resorting to standard unification, nonground queries on ground programs can be easily managed. In future work we intend however to extend the procedure to nonground programs without requiring preliminary program grounding. This should be made possible by the tabling mechanism, which stores ground positive and negative intermediate results, and by Relevance and Modularity of resourcebased answer set semantics.
An important issue is whether RASXSBresolution might be extended to plain ASP. Unfortunately, ASP programs may have a quite complicated structure: the effort of [Gebser et al. (2009)] has been, in fact, that of performing a layerbased computation upon some conditions. Many answer set programs concerning real applications are however already expressed with constraints at the top layer, as required by our approach.
A comparison with existing proof procedures can be only partial, as these procedures cope with any answer set program, with its involved internal structure. So, overall our procedure imposes less ’a priori’ conditions and has a simple definition, but this is obtained by means of a strong preliminary assumption about constraints. However, as the expressive power and complexity remain the same, our approach might constitute a way of simplifying implementation aspects without significant losses in “practical” expressivity.
We intend to investigate an integration of RASXSBresolution with principles and techniques introduced in [Bonatti et al. (2008)], so as to further enlarge its applicability to what they call finitary programs, which are a large class of nonground programs with function symbols. In fact, this approach allows programmers to make use of popular recursive definitions which are common in Prolog, and makes ASP technology even more competitive with respect to other stateoftheart techniques.
In summary, we have proposed the theoretical foundations of a proof procedure related to a reasonable extension of answer set programming. The procedure has been obtained by taking as a basis XSBresolution and its tabling features. Future work includes a precise design of a RASXSBresolution implementation. Our objective is to realize an efficient inference engine, that should then be checked and experimented on (suitable versions of) wellestablished benchmarks (see, e.g., [Calimeri et al. (2016)]). We intend in this sense to seek an integration with XSB, and with wellestablished ASPrelated systems (cf. the discussion in [Giunchiglia et al. (2008)]), already used for the implementation of the procedure proposed in [Bonatti et al. (2008)].
Acknowledgments
The authors wish to thank the anonymous reviewers for their insightful comments.
References
 Apt and Bol (1994) Apt, K. R. and Bol, R. N. 1994. Logic programming and negation: A survey. J. Log. Prog. 19/20, 9–71.
 Baral (2003) Baral, C. 2003. Knowledge representation, reasoning and declarative problem solving. Cambridge University Press, New York, NY, USA.
 Bonatti et al. (2008) Bonatti, P. A., Pontelli, E., and Son, T. C. 2008. Credulous resolution for answer set programming. In Proc. of AAAI 2008, D. Fox and C. P. Gomes, Eds. AAAI Press, Chicago, USA, 418–423.
 Calimeri et al. (2016) Calimeri, F., Gebser, M., Maratea, M., and Ricca, F. 2016. Design and results of the fifth answer set programming competition. Artif. Intell. 231, 151–181.
 Chen and Warren (1993) Chen, W. and Warren, D. S. 1993. A goaloriented approach to computing the wellfounded semantics. J. Log. Prog. 17, 2/3&4, 279–300.
 Chen and Warren (1996) Chen, W. and Warren, D. S. 1996. Tabled evaluation with delaying for general logic programs. J. ACM 43, 1, 20–74.
 Costantini (1995) Costantini, S. 1995. Contributions to the stable model semantics of logic programs with negation. Theoretical Computer Science 149, 2, 231–255.
 Costantini (2006) Costantini, S. 2006. On the existence of stable models of nonstratified logic programs. TPLP 6, 12, 169–212.
 Costantini and Formisano (2010) Costantini, S. and Formisano, A. 2010. Answer set programming with resources. J. of Logic and Computation 20, 2, 533–571.
 Costantini and Formisano (2011) Costantini, S. and Formisano, A. 2011. Weight constraints with preferences in ASP. In Proc. of LPNMR’11. LNCS, vol. 6645. Springer, Vancouver, Canada, 229–235.
 Costantini and Formisano (2013) Costantini, S. and Formisano, A. 2013. RASP and ASP as a fragment of linear logic. J. of Applied NonClassical Logics 23, 12, 49–74.
 Costantini and Formisano (2014) Costantini, S. and Formisano, A. 2014. Query answering in resourcebased answer set semantics. In Proc. of the 29th Italian Conference on Computational Logic. CEUR, Torino, Italy. Also appeared in the 7th Workshop on Answer Set Programming and Other Computing Paradigms ASPOCP 2014.
 Costantini and Formisano (2015) Costantini, S. and Formisano, A. 2015. Negation as a resource: a novel view on answer set semantics. Fundam. Inform. 140, 34, 279–305.
 Dix (1995) Dix, J. 1995. A classification theory of semantics of normal logic programs III. Fundam. Inform. 22, 3, 227–255 and 257–288.
 Faber et al. (2011) Faber, W., Leone, N., and Pfeifer, G. 2011. Semantics and complexity of recursive aggregates in answer set programming. Artificial Intelligence 175, 1, 278–298.
 Gebser et al. (2009) Gebser, M., Gharib, M., Mercer, R. E., and Schaub, T. 2009. Monotonic answer set programming. J. Log. Comput. 19, 4, 539–564.
 Gebser and Schaub (2006) Gebser, M. and Schaub, T. 2006. Tableau calculi for answer set programming. In Proc. of ICLP 2006, S. Etalle and M. Truszczyński, Eds. LNCS, vol. 4079. Springer, Seattle, USA, 11–25.
 Gelfond (2007) Gelfond, M. 2007. Answer sets. In Handbook of Knowledge Representation. Chapter 7. Elsevier, Amsterdam, The Netherlands, 285–316.
 Gelfond and Lifschitz (1988) Gelfond, M. and Lifschitz, V. 1988. The stable model semantics for logic programming. In Proc. of the 5th Intl. Conf. and Symposium on Logic Programming, R. Kowalski and K. Bowen, Eds. MIT Press, Seattle, USA, 1070–1080.
 Gelfond and Lifschitz (1991) Gelfond, M. and Lifschitz, V. 1991. Classical negation in logic programs and disjunctive databases. New Generation Computing 9, 365–385.
 Giunchiglia et al. (2008) Giunchiglia, E., Leone, N., and Maratea, M. 2008. On the relation among answer set solvers. Ann. Math. Artif. Intell. 53, 14, 169–204.
 Lifschitz and Turner (1994) Lifschitz, V. and Turner, H. 1994. Splitting a logic program. In Proc. of ICLP’94, Intl. Conference on Logic Programming. MIT Press, Santa Marherita Ligure, Italy, 23–37.
 Lin and You (2002) Lin, F. and You, J. 2002. Abduction in logic programming: A new definition and an abductive procedure based on rewriting. Artificial Intelligence 140, 1/2, 175–205.
 Lloyd (1993) Lloyd, J. W. 1993. Foundations of Logic Programming, 2nd ed. Springer, New York, USA.
 Marek and Truszczyński (1991a) Marek, V. W. and Truszczyński, M. 1991a. Autoepistemic logic. J. of the ACM 38, 3, 587–618.
 Marek and Truszczyński (1991b) Marek, V. W. and Truszczyński, M. 1991b. Computing intersection of autoepistemic expansions. In Proc. LPNMR 1991. MIT Press, Washington, D.C., USA, 35–70.
 Marek and Truszczyński (1993) Marek, V. W. and Truszczyński, M. 1993. Reflective autoepistemic logic and logic programming. In Proc. of LPNMR 1993, A.Nerode and L.M.Pereira, Eds. The MIT Press, Lisbon, Portugal, 115–131.
 Marek and Truszczyński (1999) Marek, V. W. and Truszczyński, M. 1999. Stable logic programming  an alternative logic programming paradigm. Springer, Berlin, Heidelberg, 375–398.
 Marple and Gupta (2014) Marple, K. and Gupta, G. 2014. Dynamic consistency checking in goaldirected answer set programming. TPLP 14, 45, 415–427.
 Przymusinski (1989) Przymusinski, T. C. 1989. Every logic program has a natural stratification and an iterated least fixed point model. In Proc. of the Eighth ACM SIGACTSIGMODSIGART Symposium on Principles of Database Systems, A. Silberschatz, Ed. ACM Press, Philadelphia, USA, 11–21.
 Ross (1992) Ross, K. A. 1992. A procedural semantics for wellfounded negation in logic programs. J. Log. Prog. 13, 1, 1–22.
 Simons et al. (2002) Simons, P., Niemelä, I., and Soininen, T. 2002. Extending and implementing the stable model semantics. Artificial Intelligence 138, 12, 181–234.
 Swift and Warren (2012) Swift, T. and Warren, D. S. 2012. XSB: Extending prolog with tabled logic programming. TPLP 12, 12, 157–187.
 Tamaki and Sato (1986) Tamaki, H. and Sato, T. 1986. OLD resolution with tabulation. In Proc. ICLP 1986, E. Y. Shapiro, Ed. LNCS, vol. 225. Springer, London, UK, 84–98.
 Truszczyński (2007) Truszczyński, M. 2007. Logic programming for knowledge representation. In Logic Programming, 23rd Intl. Conference, ICLP 2007, V. Dahl and I. Niemelä, Eds. Springer, Porto, Portugal, 76–88.
 Van Gelder et al. (1991) Van Gelder, A., Ross, K. A., and Schlipf, J. S. 1991. The wellfounded semantics for general logic programs. J. ACM 38, 3, 620–650.
Appendix A Background on ASP
We refer to the standard definitions concerning propositional general logic programs, as reported, for instance, in [Apt and Bol (1994), Lloyd (1993), Gelfond and Lifschitz (1988)]. We will sometimes reelaborate definitions and terminology (without substantial change), in a way which is functional to the discussion.
In the answer set semantics (originally named “stable model semantics”), an answer set program (or simply “program”) is a finite collection of rules of the form where is an atom, and each literal is either an atom or its default negation . The lefthand side and the righthand side of rules are called head and body, respectively. A rule can be rephrased as where can be called positive body and can be called negative body.^{2}^{2}2Observe that an answer set program can be seen as a Datalog program with negation —cf., [Lloyd (1993), Apt and Bol (1994)] for definitions about logic programming and Datalog. A rule with empty body () is called a unit rule, or fact. A rule with empty head, of the form , is a constraint, and it states that the literals cannot be simultaneously true. A positive program is a logic program including no negative literals and no constraints.
For every atom occurring in a rule of program either as positive literal or in a negative literal , we say that occurs in . Therefore, as is by definition finite it is possible to determine the set composed of all the atoms occurring in .
In the rest of the paper, whenever it is clear from the context, by “a (logic) program ” we mean an answer set program (ASP program) . As it is customary in the ASP literature, we will implicitly refer to the ground version of , which is obtained by replacing in all possible ways the variables occurring in with the constants occurring in itself, and is thus composed of ground atoms, i.e., atoms which contain no variables. We do not consider “classical negation” (cf., [Gelfond and Lifschitz (1991)]), nor we consider double negation
. We do not refer (at the moment) to the various useful programming constructs defined and added over time to the basic ASP paradigm.
A program may have several answer sets, or may have no answer set (while in many semantics for logic programming a program admits exactly one “model”, however defined). Whenever a program has no answer sets, we will say that the program is inconsistent. Correspondingly, checking for consistency means checking for the existence of answer sets.
Consistency of answer set programs is related, as it is wellknown, to the occurrence of negative cycles, (or negative “loops”) i.e. cycles through negation, and to their connections to other parts of the program (cf., e.g., [Costantini (2006)]).
To clarify this matter, some preliminary definitions are in order.
Definition A.1 (Dependency Graph)
For a ground logic program , the dependency graph is a finite directed graph whose vertices are the atoms occurring in (both in positive and negative literals). There is a positive (resp. negative) edge from vertex to vertex iff there is a rule in with as its head where occurs positively (resp. negatively) in its body, i.e. there is a positive edge if occurs as a positive literal in the body of , and a negative edge if occurs in a negative literal in the body of . We say that:

depends on if there is a path in from to ;

depends positively on if there is a path in from to containing only positive edges;

depends negatively on if there is a path in from to containing at least one negative edge.

there is an acyclic dependency of on if there is an acyclic path in from to ; such a dependency is even if the path comprises an even number of edges, is odd otherwise.
In this context we assume that depends on itself only if there exist a nonempty path in from to itself. (Note that empty paths are excluded, otherwise each would always depend positively upon itself by definition).
By saying that atom depends (positively or negatively) upon atom , we implicitly refer to the above definition.
Definition A.2 (Cycles)
A cycle in program corresponds to a circuit occurring in . We say that:

a positive cycle is a cycle including only positive edges;

a negative cycle is a cycle including at least one negative edge;

given a negative cycle , we say that is odd (or that is an odd cycle) if includes an odd number of negative edges;

given a positive cycle , we say that is even (or that is an even cycle) if includes an even number of negative edges;
When referring to positive/negative even/odd cycles we implicitly refer to the above definition.
Below is the formal specification of the answer set semantics, elaborated from [Gelfond and Lifschitz (1988)]. Preliminarily, we remind the reader that the least Herbrand model of a positive logic program can be computed by means of its immediate consequence operator , that can be defined as follows (the original definition is due to Van Emden and Kowalski). We then introduce the definition of reduct, the operator and finally the definition of answer set. Given a positive program and a set of atoms , let
The operator always has a unique least fixpoint, that for finite propositional programs is computable in a finite number of steps.
The following definition of (GL)reduct is due to Gelfond and Lifschitz.
Definition A.3
Let be a set of atoms and a program. The reduct of modulo is a new program, denoted as , obtained from by: 1. removing from all rules which contain a negative literal such that ; and by 2. removing all negative literals from the remaining rules.
Notice that for each negative literal which is removed at step 2, it holds that : otherwise, the rule where it occurs would have been removed at step 1. We can see that is a positive logic program. Answer sets are defined as follows, via the GLoperator .
Definition A.4 (The GLOperator )
Let be a set of atoms and a program. We denote with the least Herbrand model of .
Definition A.5
Let be a set of atoms and a program. is an answer set of if and only if .
Answer sets form an antichain with respect to set inclusion. The answer set semantics extends the wellfounded semantics (wfs), formally introduced in [Van Gelder et al. (1991)] and then further discussed and characterized (cf. [Apt and Bol (1994)] for a survey), that provides a unique threevalued model. The wellfounded model of program is specified by making explicit the set of true and false atoms, all the other atoms implicitly assuming the truth value “undefined”. Intuitively, according to the wfs:

The set is the set of atoms which can be derived topdown, say, like in Prolog, without incurring in cycles.

The set is the set of atoms which cannot be derived either because they are not the head of any rule, or because every possible derivation incurs in a positive cycle, or because every possible derivation incurs in some atom which in turn cannot be derived.

The undefined atoms are those atoms which cannot be derived because every possible derivation incurs in a negative cycle.
Some of the classical models of (interpreted in the obvious way as a classical firstorder theory, i.e. where the comma stands for conjunction and the symbol stands for implication) can be answer sets, according to some conditions introduced in what follows.
Definition A.6
Given a nonempty set of atoms and a rule of the form , we say that is supported in iff and .
Definition A.7
Given a program and a nonempty set of atoms , we say that is supported w.r.t. (or for short supported) iff , is the head of a rule in which is supported in .
Answer sets of , if any exists, are supported minimal classical models of the program. They however enjoy a stricter property, that we introduce below (cf., Proposition A.2).
Definition A.8
Given a program and a set of atoms , an atom is consistently supported w.r.t. and iff there exists a set of rules of such that the following conditions hold (where we say that is consistently supported via ):

every rule in is supported in ;

exactly one rule in has conclusion ;

does not occur in the positive body of any rule in ;

every atom occurring in the positive body of some rule in is in turn consistently supported w.r.t. and via a set of rules .
Note that cannot occur in the negative body of any rule in either, since all such rules are supported in . is called a consistent support set for (w.r.t. and ). Moreover, by condition (ii), different support sets for may exist, each one including a different rule with head .
Definition A.9
Given a program and a set of atoms , we say that is a consistently supported set of atoms (w.r.t. ) iff , is consistently supported w.r.t. and . We say that is a maximal consistently supported set of atoms (MCS, for short) iff there does not exist such that is consistently supported w.r.t. . We say, for short, that is an MCS for .
Observe that an MCS can be empty only if it is unique, i.e, only if no nonempty consistently supported set of atoms exists. In both the answer set and the wellfounded semantics atoms involved/defined exclusively in positive cycles are assigned truth value false. However, the answer set semantics tries to assign a truth value to atoms involved in negative cycles, which are undefined under the wellfounded semantics (precisely, it succeeds in doing so if the given program is consistent). Therefore, for every answer set , . It is easy to see that:
Proposition A.1
Given the wellfounded model of program , is a consistently supported set of atoms.
Notice that is not in general an MCS, as the following proposition holds:
Proposition A.2
Any answer set of program is an MCS for .
However, maximal consistently supported sets of atoms are not necessarily answer sets.
We introduce some useful properties of answer set semantics from [Dix (1995)].
Definition A.10
The sets of atoms a single atom depends upon, directly or indirectly, positively or negatively, is defined as .
Definition A.11
Given a program and an atom , is the set of relevant rules of with respect to , i.e. the set of rules that contain an atom in their heads.
The notions introduced by Definitions A.10 and A.11 for an atom can be plainly generalized to sets of atoms. Notice that, given an atom (or a set of atoms) , is a subprogram of .
An ASP program can be seen as divided into components, some of them involving cyclic dependencies.
Definition A.12
An answer set program is cyclic if for every atom occurring in the head of some rule in , it holds that . In particular, is negatively (resp., positively) cyclic if some (resp., none) of these dependencies is negative. A program in which there is no head such that is called acyclic.
A cyclic program is not simply a program including some cycle: rather, it is a program where every atom is involved in some cycle. It is easy to see the following.

An acyclic program has a unique (possibly empty) answer set, coinciding with the set of true atoms of its wellfounded model. Acyclic programs coincide with stratified programs in a wellknown terminology [Apt and Bol (1994)]. We prefer to call them ’acyclic’ as the notion of strata is irrelevant in the present context.

A positively cyclic program has a unique empty answer set, coinciding with the set of true atoms of its wellfounded model.

Negatively cyclic programs have no answer sets and have an empty wellfounded model, in the sense that all atoms occurring in such a program are undefined under the wellfounded semantics.
In the following, unless explicitly specified by a “cyclic program” (or program component) we intend a negatively cyclic program (or program component, i.e. a subprogram of a larger program). By Definition A.12, there exist programs that are neither cyclic nor acyclic, though involving cyclic and/or acyclic fragments as subprograms, where such fragments can be either independent of or related to each other.
Definition A.13
A subprogram of a given program is selfcontained (w.r.t. ) if the set of atoms occurring (either positively or negatively) in is such that .
Notice that a subprogram is selfcontained by definition.
Definition A.14
Given two subprograms of a program , is on top of if the set of atoms occurring in the head of some rule in is such that , and the set of atoms occurring (either positively or negatively) only in the body of rules of is such that .^{3}^{3}3This notion was introduced in [Costantini (1995), Lifschitz and Turner (1994)].
Notice that, by Definition A.14, if is on top of , then is a splitting set for in the sense of [Lifschitz and Turner (1994)].
Definition A.15
A program obtained as the union of a set of cyclic or acyclic programs, none of which is on top of another one, is called a jigsaw program.
Thus any program/component, either acyclic or cyclic or jigsaw, can possibly but not necessarily be selfcontained. An entire program is selfcontained, but not necessarily jigsaw. We introduce a useful terminology for jigsaw programs which are selfcontained.
Definition A.16
Let be a program and a jigsaw subprogram of . Then, is standalone (w.r.t. ) if it is selfcontained (w.r.t. ).
In case we refer to a standalone program without mentioning the including program , we intend to be identifiable from the context.
The following property states that a program can be divided into subprograms where a standalone one can be understood as the bottom layer, which is at the basis of a “tower” where each level is a jigsaw subprogram standing on top of lower levels.
Proposition A.3
A nonempty answer set program can be seen as divided into a sequence of components, or layers, , where: , which is called the bottom of , is a standalone program; each component , for , is a jigsaw program which is on top of .
In fact, the bottom layer (that may coincide with the entire program) necessarily exists as the program is finite, and so does any upper layer. The advantage of such a decomposition is that, by the Splitting Theorem introduced in [Lifschitz and Turner (1994)], the computation of answer sets of can be divided into subsequent phases.
Proposition A.4
Consider a nonempty ASP program , divided according to Proposition A.3 into components
Comments
There are no comments yet.