Presentation is loading. Please wait.

Presentation is loading. Please wait.

WFSX programming Prolog programming style, but with the WFSX semantics Requires: –A new proof procedure (different from SLDNF), complying with WFS, and.

Similar presentations


Presentation on theme: "WFSX programming Prolog programming style, but with the WFSX semantics Requires: –A new proof procedure (different from SLDNF), complying with WFS, and."— Presentation transcript:

1 WFSX programming Prolog programming style, but with the WFSX semantics Requires: –A new proof procedure (different from SLDNF), complying with WFS, and with explicit negation –The corresponding Prolog-like implementation: XSB-Prolog

2 SLX: Proof procedure for WFSX SLX (SL with eXplicit negation) is a top-down procedure for WFSX Is similar to SLDNF –Nodes are either successful or failed –Resolution with program rules and resolution of default literals by failure of their complements are as in SLDNF In SLX, failure doesn’t mean falsity. It simply means non-verity (i.e. false or undefined)

3 Success and failure A finite tree is successful if its root is successful, and failed if its root is failed The status of a node is determined by: –A leaf labeled with an objective literal is failed –A leaf with true is successful –An intermediate node is successful if all its children are successful, and failed otherwise (i.e. at least one of its children is failed)

4 Negation as Failure? As in SLS, to solve infinite positive recursion, infinite trees are (by definition) failed Can a NAF rule be used? YES True of not A succeeds if true-or-undefined of A fails True-or-undefined of not A succeeds if true of A fails This is the basis of SLX. It defines: –T-Trees for proving truth –TU-Trees for proving truth or undefinedness

5 T and TU-trees They differ in that literals involved in recursion through negation, and so undefined in WFSXp, are failed in T-Trees and successful in TU-Trees a  not b b  not a … b not a TU b not a TU a not b T a T X X X X

6 Explicit negation in SLX ¬-literals are treated as atoms To impose coherence, the semi-normal program is used in TU-trees a  not b b  not a ¬a b not a X a not b not ¬a ¬a¬a true X b not a ¬a¬a true … X X a not b not ¬a X

7 Explicit negation in SLX (2) In TU-trees: L also fails if ¬L succeeds true I.e. if not ¬L fail as true-or-undefined c  not c b  not c ¬b a  b not a X ¬b¬b true c not c ¬a¬a b not ¬b a not ¬a X X X c not c c c c … X X X X X X

8 T and TU-trees definition D T-Trees (resp TU-trees) are AND-trees labeled by literals, constructed top-down from the root by expanding nodes with the rules Nodes labeled with objective literal A If there are no rules for A, the node is a leaf Otherwise, non-deterministically select a rule for A A  L 1,…,L m, not L m+1,…, not L n In a T-tree the children of A are L 1,…,L m, not L m+1,…, not L n In a TU-tree A has, additionally, the child not ¬A Nodes labeled with default literals are leafs

9 Success and Failure D All infinite trees are failed. A finite tree is successful if its root is successful and failed if its root is failed. The status of nodes is determined by: A leaf node labeled with true is successful A leaf node labeled with an objective literal is failed A leaf node of a T-tree (resp. TU) labeled with not A is successful if all TU- trees (resp. T) with root A (subsidiary tree) are failed; and failed otherwise An intermediate node is successful if all its children are successful; and failed otherwise After applying these rules, some nodes may remain undetermined (recursion through not). Undetermined nodes in T-trees (resp.TU) are by definition failed (resp. successful)

10 Properties of SLX SLX is sound and (theoretically) complete wrt WFSX. If there is no explicit negation, SLX is sound and (theoretically) complete wrt WFS. See [AP96] for the definition of a refutation procedure based on the AND-trees characterization, and for all proofs and details

11 Infinite trees example s  not p, not q, not r p  not s, q, not r q  r, not p r  p, not q WFM is {s, not p, not q, not r} not pnot qnot r s X p q not s r not q not r r not p p q not snot r r not p p not q X X q r not p p not q q not snot r

12 Negative recursion example q  not p(0), not s p(N)  not p(s(N)) s  true WFM = {s, not q} … not q p(0) not p(1) not p(0) q not s X X p(1) not p(2) p(2) not p(3) X X X X s true not p(0) … p(1) not p(2) p(0) not p(1) X X X p(2) not p(3)

13 Guaranteeing termination The method is not effective, because of loops To guarantee termination in ground programs: Local ancestors of node n are literals in the path from n to the root, exclusive of n Global ancestors are assigned to trees: the root tree has no global ancestors the global ancestors of T, a subsidiary tree of leaf n of T’, are the global ancestors of T’ plus the local ancestors of n global ancestors are divided into those occurring in T-trees and those occurring in TU-trees

14 Pruning rules For cyclic positive recursion: Rule 1 If the label of a node belongs to its local ancestors, then the node is marked failed, and its children are ignored For recursion through negation: Rule 2 If a literal L in a T-tree occurs in its global T-ancestors then it is marked failed and its children are ignored

15 Rule 2Rule 1 Pruning rules (2) L L L L …

16 Other sound rules Rule 3 If a literal L in a T-tree occurs in its global TU-ancestors then it is marked failed, and its children are ignored Rule 4 If a literal L in a TU-tree occurs in its global T-ancestors then it is marked successful, and its children are ignored Rule 5 If a literal L in a TU-tree occurs in its global TU-ancestors then it is marked successful, and its children are ignored

17 Pruning examples a  not b b  not a ¬a b not a X a not b not ¬a ¬a¬a true X c  not c b  not c ¬b a  b not a X ¬b¬b true c not c ¬a¬a b not ¬b a not ¬a X X X X X Rule 3 b Rule 2 X

18 Non-ground case The characterization and pruning rules apply to allowed non-ground programs, with ground queries It is well known that pruning rules do not generalize to general programs with variables: p(X)  p(Y) p(a) p(X) p(Y) What to do? p(Z) If “fail”, the answers are incomplete If “proceed” then loop

19 Tabling To guarantee termination in non-ground programs, instead of ancestors and pruning rules, tabulation mechanisms are required –when there is a possible loop, suspend the literal and try alternative solutions –when a solution is found, store it in a table –resume suspended nodes with new solutions in the table –apply an algorithm to determine completion of the process, i.e. when no more solutions exist, and fail the corresponding suspended nodes

20 Tabling example SLX is also implemented with tabulation mechanisms It uses XSB-Prolog tabling implementation SLX with tabling is available with XSB-Prolog from Version 2.0 onwards Try it at: p(X)  p(Y) p(a) p(X) p(Y) 1) suspend X = a 2) resume Y = a X = _ Table for p(X)

21 Tabling (cont.) If a solution is already stored in a table, and the predicate is called again, then: –there is no need to compute the solution again –simply pick it from the table! This increases efficiency. Sometimes by one order of magnitude.

22 A methodology for KR WFSXp provides mechanisms for representing usual KR problems: –logic language –non-monotonic mechanisms for defaults –forms of explicitly representing negation –paraconsistency handling –ways of dealing with undefinedness In what follows, we propose a methodology for representing (incomplete) knowledge of taxonomies with default rules using WFSXp

23 Representation method (1) Definite rules If A then B: –B  A penguins are birds: bird(X)  penguin(X) Default rules Normally if A then B: –B  A, rule_name, not ¬ B rule_name  not ¬ rule_name birds normally fly:fly(X)  bird(X), bf(X), not ¬fly(X) bf(X)  not ¬bf(X)

24 Representation method (2) Exception to default rules Under conditions COND do not apply rule RULE: –¬ RULE  COND Penguins are an exception to the birds-fly rule ¬bf(X)  penguin(X) Preference rules Under conditions COND prefer rule RULE + to RULE - : –¬ RULE -  COND, RULE + for penguins, prefer the penguins-don’t-fly to the birds-fly rule: ¬bf(X)  penguin(X), pdf(X)

25 Representation method (3) Hypotethical rules “If A then B” may or not apply: –B  A, rule_name, not ¬ B rule_name  not ¬ rule_name ¬ rule_name  not rule_name quakers might be pacifists: pacifist(X)  quaker(X), qp(X), not ¬pacifist(X) qp(X)  not ¬qp(X) ¬qp(X)  not qp(X) For a quaker, there is a PSM with pacifist, another with not pacifist. In the WFM pacifist is undefined

26 Taxonomy example Mammal are animal Bats are mammals Birds are animal Penguins are birds Dead animals are animals Normally animals don’t fly Normally bats fly Normally birds fly Normally penguins don’t fly Normally dead animals don’t fly The taxonomy: Pluto is a mammal Joe is a penguin Tweety is a bird Dracula is a dead bat The elements: Dead bats don’t fly though bats do Dead birds don’t fly though birds do Dracula is an exception to the above In general, more specific information is preferred The preferences:

27 The taxonomy flies animal bird penguin mammal bat dead animal plutotweetydraculajoe Definite rules Default rules Negated default rules

28 Taxonomy representation Taxonomy animal(X)  mammal(X) mammal(X)  bat(X) animal(X)  bird(X) bird(X)  penguin(X) deadAn(X)  dead(X) Default rules ¬flies(X)  animal(X), adf(X), not flies(X) adf(X)  not ¬adf(X) flies(X)  bat(X), btf(X), not ¬flies(X) btf(X)  not ¬btf(X) flies(X)  bird(X), bf(X), not ¬flies(X) bf(X)  not ¬bf(X) ¬flies(X)  penguin(X), pdf(X), not flies(X) pdf(X)  not ¬pdf(X) ¬flies(X)  deadAn(X), ddf(X), not flies(X) ddf(X)  not ¬ddf(X) Facts mammal(pluto). bird(tweety). deadAn(dracula). penguin(joe). bat(dracula). Explicit preferences ¬btf(X)  deadAn(X), bat(X), r1(X) r1(X)  not ¬r1(X) ¬btf(X)  deadAn(X), bird(X), r2(X) r2(X)  not ¬r2(X) ¬r1(dracula) ¬r2(dracula) Implicit preferences ¬adf(X)  bat(X), btf(X) ¬adf(X)  bird(X), bf(X) ¬bf(X)  penguin(X), pdf(X)

29 Taxonomy results Joedraculaplutotweety deadAnnot  batnot  penguin  not mammalnot  bird  not  animal  adf  ¬  ¬ btf  ¬  bf¬  pdf  ddf  ¬  r1  ¬  r2  ¬  flies¬  ¬ 


Download ppt "WFSX programming Prolog programming style, but with the WFSX semantics Requires: –A new proof procedure (different from SLDNF), complying with WFS, and."

Similar presentations


Ads by Google