• No se han encontrado resultados

Sitio Web de la Extensión SOA

In document Tesis de Maestría en Informática (página 187-199)

Anexo A - Sitio Web de la Extensión SOA

9.2. Sitio Web de la Extensión SOA

In order to find a solution to a query, a Minimal Hypotheses semantics based top-down query-solver will need to find a Minimal Hypotheses sub-model entailing the query’s literals. The Relevance (and Brave Relevance) of the MH semantics ensures such a sub- model is extendable to a complete model. Moreover, these properties also ensure that considering only the relevant part of the program is sufficient (and necessary) to find such an answer. To accomplish this task a MH-based query solver will need to

1. Collect rules in the program relevant for the query

2. Assign the truth-value false to atoms with no rules, and to atoms in positive loops (cf. Section 11.1)

3. Assign the truth-value true to facts

4. Detect and “solve” strongly connected components of rules according to the Minimal Hypotheses principle

In previous works [194] we resorted to XSB-Prolog’s get_residual/2 predicate as a means to get the relevant rules for the query. According to the XSB Prolog’s manual “the predicate get_residual/2 unifies its first argument with a tabled subgoal and its second argument with the (possibly empty) delay list of that subgoal. The truth of the subgoal is taken to be conditional on the truth of the elements in the delay list.” The delay list is the list of literals whose truth value could not be determined to be true nor false in the WFM, i.e., their truth value is undefined in the WFM of the program. It is possible to obtain the residual clause of a solution for a query literal, and in turn the residual clauses for the literals in its body, and so on. This way we can reconstruct the complete relevant residual part of the KB for the literal — we call this a residual program or reduct for that solution to the query. This way, not only do we get just the relevant part of the KB for the literal, we also get precisely the part of those rules bodies still undefined, i.e., that are involved in Loops Over Negation. The use of the get_residual/2 predicate proved to be a useful strategy, but since not all MH models comply with the Well-Founded Model of the program (cf. Example 6.2 on page 55), we cannot use it for a MH semantics based

system implementation. Instead we must collect the relevant rules by directly accessing Prolog’s clause/2 ISO predicate. Alternatively, when a WAM-level implementation of the Layered Remainder is available in XSB by a corresponding new system predicate, e.g., get_layered_remainder/2, we could use it to construct the layered remainder part relevant for the query. We leave such task for future work.

A prototypical implementation of a MH-based query solver could resort to a Stable Models solver — e.g., Smodels [166] — to “solve” the SCCs of rules, according to the Minimal Hypotheses principle, to that effect needing to incorporate the additional func- tionality of minimal hypotheses assumption. The Smodels system [166] allows disjunctive rules, i.e., with disjunctions in the heads of rules (cf. Section 4.2), which can be added to a NLP. Such disjunctive rules could be used to allow the disjuncts to play the role of hypotheses to be assumed. Moreover, the disjuncts in Disjunctive Stable Models gener- ated by Smodels are automatically minimized (cf. Example 4.12 of [233]) thereby reifying the minimality principle of assumed hypotheses. We can use XSB-Prolog’s capabilities to accomplish items 1, 2, and 3 above; and surely a cleverly developed meta-interpreter in XSB could also be implemented to fulfil step 4, but using Smodels with its handling of Disjunctive rules could save a lot of work and debugging for this 4th step. Fortu- nately, XSB-Prolog has an inbuilt interface to Smodels which allows the programmer to accumulate rules in a clause-store that is sent to Smodels to solve.

The XASP interface [50, 52] (standing for XSB Answer Set Programming), is included in XSB-Prolog as a practical programming interface to Smodels [166], one of the best known implementations of the SMs over generalized LPs. The XASP system allows one not only to compute the models of a given NLP, but also to effectively combine 3-valued with 2-valued reasoning. Such integration permits to make use of relevance for queries. In SMs it is necessary to compute all complete models for the whole program. In the implementation framework we propose, we sidestep this issue by collecting and transforming the rules relevant for the query, and then by using XASP to send those rules to Smodels for computation of stable models of the relevant sub-program. The top- down computation, to boot, helps in partly or totally grounding the transformed relevant sub-program.

XSB’s XASP communication with Smodels enables the programmer to use a “Smodels clause store” to which several rules can be added. After adding all the original residual relevant rules, and also the newly created disjunctive rules, we add two extra rules: 1) userGoal :- Query, where Query is the query conjunct posed by the user (and userGoal is a reserved atom); and 2) :- not userGoal which prevents Smodels from producing as an answer any model where the userGoal does not hold. This clause store is then sent to Smodels which will consider only those rules when computing the models — these are obtained by asking Smodels to compute one model (and on backtracking to compute

141

others, if we so wish). The SMs obtained are Minimal Hypotheses sub-models of the original program containing only the literals relevant for the query.

As we have seen before, with MH semantics loops/SCCs are seen as kinds of dis- junctions. In this sense, a NLP might be transformable into a Disjunctive LPs where the disjuncts are the assumable hypotheses. With this approach, in order to guarantee sound and complete MH semantics based top-down querying implementation we still have to answer two questions:

1. Which atoms to be considered hypotheses and, therefore, to include in heads of disjunctive rules

2. Which literals should be in the bodies of the disjunctive rules

We do not address these questions for now, but leave them for future work along with the implementation of a fully functional MH-based KRR system.

In document Tesis de Maestría en Informática (página 187-199)