slides01-15

slides01-15 - Rule Goal Trees Nodes correspond to rules and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Rule Goal Trees Nodes correspond to rules and to subgoals of rules. Rule node: children = subgoals of the rule. Goal node: children = rules whose heads unify with the goal. Unifying substitution must be made in the rule. 3 Be careful that local variables of the rule are changed so their are no accidental equalities between local variables and variables of the parent goal. Root is goal node corresponding to a query. Arguments of goal may have constants acquired from query. Example Page 769 of PDKS-II has suggestion of in nite rule goal tree from recursive example. Here is a simple, nonrecursive example. r1: pX,Y :- qX,Z & rZ,Y r2: rA,B :- sA,B r3: rA,B :- tA,B Query: p0; W ? i.e., for what values of W is p0; W  true? p0; W  r1: p0,W :- q0,Z & rZ,W q0; Z  rZ; W  r2: rZ,W :- sZ,W r3: rZ,W :- tZ,W sZ; W  tZ; W  Passing Relations Around the Rule Goal Tree We evaluate a query by passing information around the R G tree in three ways. Queries are passed down. A query gives bindings for certain arguments of a goal. Answers are passed upward. These relations give values for the arguments of a goal. 1 Information is passed sideways, from left to right, through the subgoals of a rule. Supplementary Relations Sideways information passing is accomplished through supplementary relations." If a rule has n subgoals, there are n supplementary relations, S0 ; S1; : : :; Sn,1. The supplementary relation Si has arguments corresponding to certain variables of the rule. These variables must: 1. Have been bound before the i + 1st subgoal, by appearing either in a bound argument of the head or in the ith or earlier to the left subgoal. 2. Be used later; either the variable appears in the i + 1st or later to the right subgoal, or anywhere in the head. Example In our R G tree, the rule node labeled r1 has supplementary relations S0 and S1 . S0 has no arguments, because although the rst argument of the head is bound by the query, there are no variables bound. S1 has only Z as an argument, because Z appears in the rst subgoal, q0; Z , and is used later, in the second subgoal rZ; W . The nodes labeled r2 and r3 each have only S0 as a supplementary relation. Its argument is Z , because Z is bound by the head as we shall see and used in the rst and only subgoal. Bound Arguments and Variables Important: Goals have bound arguments; rules have bound variables. Distinction is important in many situations, e.g., function symbols, constant arguments, duplicate occurrences of variables. ATOV Match is tuple-by-tuple. Match of argument against a term an argument of a rule head must be exact; i.e., argument and term must unify. 2 If a variable is bound to two di erent constant values, match fails. Example Rule head pfX,Y,Z,W :-. First two arguments are bound by the relation Arg 2 Arg 1 f a; b c d ge First tuple: X ! a, Y ! b, Z ! c. Second tuple: no match. f X; Y  does not unify with d. Result: X a Y b Z c Example Head pX,X,Y,Z :-, with rst three arguments bound by the relation Arg 1 Arg 2 Arg 3 a a b b a b c gd c First tuple: no match; X cannot be both a and b. Second tuple: X ! a, Y ! gd. Third tuple: X ! b, Y ! c. Result: Y gd c X a b VTOA An argument must become completely bound, or it is not bound at all. Example Subgoal pfX,Y,Z,W with X , Y , and Z bound by: 3 X a d Result: Y b e Z c f g Arg 1 f a; b f d; e Arg 2 c f g  Example Subgoal pfX,Z,X,Y with X and Y bound. The rst argument is not bound, because Z is not bound. The second and third arguments are bound. Variable-binding and result relations: X a c Y b d Arg 2 Arg 3 a c b d Rule Goal Graphs Condense nodes of rule goal tree having same rule or goal with the same binding pattern. Goal Nodes Predicate + adornment." Adornment = list of b's and f 's, indicating which arguments are bound, which are free. Example: pbfb. First and third arguments of p are bound. Rule Nodes Correspond to supplementary relation. riS jT represents the point in rule r after seeing i subgoals, with variables in set S bound, those in T free. Children Children of goal node p are those rule nodes r0S jT such that 4 1. Rule r has head predicate p. 2. S is the set of variables that appear in those arguments of the head that says are bound. 3. T is the other variables of r. Children of the rule node rjS jT are: 1. The goal node of the j + 1st subgoal of r, with adornment that binds those arguments whose only variables are in S . 2. The rule node rjS jT , where S 0 = S + +1 variables appearing the in j + 1st subgoal; T 0 is the other variables. 0 0 Exceptions: no rj +1 rule node if r has only j + 1 subgoals. No goal child if j = 0 and r has no subgoals. Widgets Bound goal arguments ATOV rule rule S0 Variables bound in head Passing queries from a goal to its rule children Bound arguments Matching answers EDB goal Interrogating the database 5 rule Si,1 . Bound variables ATOV goal  Si Answers Joining the result of a goal into the supplementary relations Bound variables rule Si VTOA Bound goal arguments Querying the next subgoal Arguments of head H :- VTOA rule Sn,1 !. ATOV goal Answers Answers for the last goal are joined with the last supplementary relation and produce tuples for the head 6 rule goal Answers rule Answers from head Answers from the head of a rule are passed to the goal parent and from there to the rule parent of that goal 7 ...
View Full Document

This document was uploaded on 01/06/2012.

Ask a homework question - tutors are online