april 3rd, 1998tapd'98. paris 2-3 april, 1998.1 tabling abduction josé alferes and luís moniz...

22
April 3rd, 199 8 TAPD'98. Paris 2-3 Apri l, 1998. 1 Tabling Abduction Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa Portugal Portugal

Upload: isabel-wilcox

Post on 29-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998. 1

Tabling AbductionTabling Abduction

José Alferes and Luís Moniz PereiraUniv. Évora and CENTRIA

CENTRIA Univ. Nova Lisboa

Portugal Portugal

Page 2: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.2

Abductive proceduresAbductive procedures

One of the main issues in abductive procedures is:

– How to collect abduced literals to prove a goal?

i.e.– Which consistent set of abducibles, if

added as facts, prove the goal

Page 3: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.3

In XSB-PrologIn XSB-Prolog

When a tabled goal G succeeds its table may contains suspended goals due to loops over negation - The residue of G

This residue can be accessed by predicate get_residual/2

Page 4: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.4

Naïve approachNaïve approach

Table abducible predicates Force calls to them to suspend every time Produce an abductive solution as a residue of the

top-goal

In general the naïve approach does not work.

We generalize the naïve approach to implement an abductive procedure based on tabling in XSB-Prolog

Page 5: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.5

SummarySummary

Review of XSB residue

Naïve approach

Dealing with default negation

Dealing with loops

Further topics

Page 6: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.6

Tabling negationTabling negation

– Whenever there are loops over negation, two tabled calls may depend on each other so that neither of which can be completed

Literals involved in such loops are delayed

If, in the end, some calls are not completely evaluated, they’ll have an associated list of delays - the residue

We assume some knowledge of SLG resolut.We assume some knowledge of SLG resolut.

Page 7: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.7

Delayed literalsDelayed literals

For tabled literals, answers are rules with delayed literals in the body

:- table r/0, s/0, p/1.

p(X) :- tnot(r). r :- tnot(s).

p(X) :- a(X). a(a). s :- tnot(r).

The answers are:

p(X) :- tnot(r). r :- tnot(s).

p(a). a(a). s :- tnot(r).

Page 8: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.8

Combinatorial explosionCombinatorial explosion

To avoid combinatorial explosion, delayed literals in the body are not propagated over tabled literals

Tabled literals act as place holders for propagating delays

:- table r/0, s/0, p/1, q/0.

p(X) :- q. r :- tnot(s).

q :- tnot(r). s :- tnot(r).

Page 9: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.9

Residual programResidual program

get_residual(Goal,Res)– Returns in Res the body of an answer

rule for Goal

– It does not produce the residue itself

– It only accesses the already built

residue

Page 10: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.10

Naïve approachNaïve approach

Table abductive literals

q pp a, bp c

Abd = {a,b,c}

q :- p.

p :- abd(a), abd(b).

p :- abd(c).

abd(X) :- tnot(abd(X)).

:- table abd/1, q/0.

abd_sol(q,Ab) :-

q,fail;

get_residual(q,Ab).

Make sure that they are suspended

Guarantee that the table is complete before calling get_residual

Obtain the abductive solutions via the residue

Table the top-goal

Translate abducible L into abd(L)

Page 11: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.11

Naïve approach exampleNaïve approach example

q :- p.

p :- abd(a), abd(b).

p :- abd(c).

abd(X) :- tnot(abd(X)).

:- table abd/1, q/0.

abd_sol(q,Ab) :- q,fail; get_residual(q,Ab).

?- abd_sol(q,Ab).

Ab = [abd(a),abd(b)];

Ab = [abd(c)];

no.

Page 12: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.12

ProblemsProblems

If the program has default negation, the failure mechanism makes it impossible to pass arguments (abductions) to the top-goal– Other problems arise: abducing falsity;

consistency checking;...

If other predicates are tabled, the residue may come in terms of those (and not of the abducibles).– Tabling of others is needed because of loops

Page 13: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.13

Negation ExampleNegation Example

q a, tnot p.

p a,b. p c.The desired abd. solution is:

{a, not b, not c}

With the naïve approach (with not tabled): [abd(p), tnot(p)].

• How to pass abductions up through negation?

• Generate rules for negation and replace negative call by (positive) calls to these rules

• Rules for negatives form a dual program (c.f. [PAA91])

Page 14: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.14

Dual (ground) programDual (ground) program

Turn all rules for a predicate A into one (by using disjunction in bodies)

The rule for not_A is obtained by interchanging, in the rule for A, conjunction and disjunction, plus positive and negative literals

a b, not ca d, not e

a b, not c ; d, not e

not_a (not_b; c) , (not_d; e)

Page 15: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.15

Dual exampleDual example

q :- abd(a), not_p.

p :- abd(a), abd(b).

p :- abd(c).

abd(X) :- tnot(abd(X)).

:- table abd/1, q/0.

abd_sol(q,Ab) :- q,fail; get_residual(q,Ab).

?- abd_sol(q,Ab).

Ab = [abd(a),abd(not_a),abd(not_c)];

Ab = [abd(a),abd(not_b), abd(not_c)];

no.

not_q :- abd(not_a); p.

not_p :- (abd(not_a); abd(not_b)),

abd(not_c).

Page 16: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.16

Checking consistencyChecking consistency

To avoid inconsistent solutions, add a call to consistent/1 after get_residual/2

abd_sol(q,Ab) :- q_cons,fail; get_residual(q_cons,Ab), consistent(Ab).

q_cons :- q, not_false.

To deal with denials include them as rules for false, and conjoin any top-goal with not_false

abd_sol(q,Ab) :- q ,fail; get_residual(q ,Ab), consistent(Ab).

Page 17: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.17

Tabling non-abduciblesTabling non-abducibles

Till now only abducibles and the top-goal are tabled

With other tabled predicates, the residue is given in terms of these, not in terms of the abducibles below

q :- p.

p :- abd(a), abd(b); abd(c).abd(X) :- tnot(abd(X)).

:- table abd/1, q/0, p/0.

abd_sol(q,Ab) :- q,fail; get_residual(q,Ab).

?- abd_sol(q,Ab).

Ab = [p];

no

Page 18: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.18

Tabling non-abduciblesTabling non-abducibles

After a call to a tabled predicate, com-plete its table, and get its residue info

(R)

abd_sol(q,Ab) :- q(_), fail ;

get_residual(q(R),RR), filter(RR,Ab).

filter/3 filters out non-abducibles, and checks consistency

q :- p, fail ; get_residual(p,R).

Pass up the info via an extra argument

Page 19: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.19

ExampleExample

p :- a, q.

p :- not t. t :- not s, c.

s :- b.

q :- not r.

r :- not q.

p :- a, q; not t.

not_p :- not_a, not_q; t.

t :- not s, c.

q :- not r. not_t :- s; not_c.

not_q :- r. s :- b.

r :- not q. not_s :- not_b

not_r :- q.

p :- abd(a), q; not t.

not_p :- abd(not_a), not_q; t.

t :- not s, abd(c).

q :- not r. not_t :- s; abd(not_c).

not_q :- r. s :- abd(b).

r :- not q. not_s :- abd(not_b).

not_r :- q.

p(RR) :- (abd(a), (q(_),fail; get_residual(q(R),RR))); not t.

not_p(RR) :- abd(not_a), (not_q(_),fail; get_res(R,RR)); t.

q(RR) :- not_r(_), fail; get_residual(not_r(R),RR).

not_q(RR) :- r(_), fail; get_residual(r(R),RR).

r(RR) :- not_q(_), fail; get_residual(not_q(R),RR).

not_r(RR) :- q(_), fail; get_residual(q(R),RR).

t :- not s, abd(c).

not_t :- s; abd(not_c).

s :- abd(b).

not_s :- abd(not_b).

:- table abd/1, p/1, not_p/1, q/1, not_q/1, r/1, not_r/1.

abd(X) :- tnot(abd(X)).

abd_sol(p,Ab) :- p(_), fail; get_residual(p(R),Ab), filter(R,RR,Ab).

abd_sol(not_p,Ab) :- not_p(_), fail; get_residual(not_p(R),Ab), filter(R,RR,Ab).

p(RR) :- (abd(a), (q(_),fail; get_residual(q(R),RR))); not t.

not_p(RR) :- abd(not_a), (not_q(_),fail; get_res(R,RR)); t.

q(RR) :- not_r(_), fail; get_residual(not_r(R),RR).

not_q(RR) :- r(_), fail; get_residual(r(R),RR).

r(RR) :- not_q(_), fail; get_residual(not_q(R),RR).

not_r(RR) :- q(_), fail; get_residual(q(R),RR).

t :- not s, abd(c). s :- abd(b).

not_t :- s; abd(not_c). not_s :- abd(not_b).

Page 20: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.20

Abductive solutionsAbductive solutions

p :- a, q.

p :- not t.

q:- not r.

r :- not q.

t :- not s, c.

s :- b

?- abd_sol(p,Ab).

Ab = [abd(b)];

Ab = [abd(not(c))];

no.

?- abd_sol(not_p,Ab).

Ab = [abd(not_a),abd(not_b),abd(c)];

no.

Page 21: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.21

One solution at a timeOne solution at a time

The L, fail; get_residual/2 construct com-putes all solutions before showing one

In the paper we explain how to avoid this, by adding an extra argument to predicates

Page 22: April 3rd, 1998TAPD'98. Paris 2-3 April, 1998.1 Tabling Abduction José Alferes and Luís Moniz Pereira Univ. Évora and CENTRIA CENTRIA Univ. Nova Lisboa

April 3rd, 1998 TAPD'98. Paris 2-3 April, 1998.22

ConclusionsConclusions

We have fostered a new method to implement abduction

The method relies on the XSB tabling mechanism

In the paper we briefly sketch:– viewing constraints as abduction and

treating them with this method;– dealing with non-ground negative goals via

constructive negation as constraints