CS 342 Lecture -*- Outline -*- * Resolution (logical basis for Prolog) see section 8.6 of Kamin interpreter tries to verify the goal statement (or prove false) through a proof procedure. proof procedure = inference system + search strategy inference is resolution + selection of leftmost term (SL resolution) resolution derives a new goal from goal and a pattern ** Example (for use below) ------------- ;facts (infer (scientist sue)) ;1 (infer (scientist ron)) ;2 (infer (spanish sue)) ;3 (infer (american ron)) ;4 ;rule (infer (logician X) from (scientist X)) ;5 ;goal (infer? (logician Y) (american Y) (print Y)) ; (is there) some Y is both a logician and an american? --------------- ** resolution theorem proving *** rule of inference (resolution) R or P, (not P or Q) --------------------- R or Q use CNF to remove implications (see page 392ff.) skolemize (drop universal quantification) leaves set of disjunctions (clauses) e.g. rule 5 for all X: (logician X) if (scientist X) CNF form is for all X: (logician X) or not(scientist X) skolemized: (logician X) or not(scientist X) truth table for implication A ==> B, i.e., B if A, same as (B or not A) A\B true false true t f false t t *** the resolution rule (mechanical) (theorem 8.6) suppose clause A contains some term s, clause B contains negation of term t, s and t are unifiable by some subst sigma, then resolvent of A and B is generated by 1. combining the clauses to form A or B 2. removing s and t (from the resulting term) 3. applying substitution sigma to result e.g., resolvent of: not (scientist sue) with (scientist sue) formed by combining: not (scientist sue) or (scientist sue), then deleting matching parts: *poof!* ([] in Kamin) e.g., resolvent of: not (logician Y) or not (american Y) with: (logician X1) or not (scientist X1) unifying substitution s(Y) = U0, s(X1) = U0 is: not american(U0) or not scientist(U0). *** to ask a question Q, resolve (not Q) against set of clauses, if reach a contradiction (empty clause) shows that original goal was true goal: exists Y, (logician Y) and (american Y) denial of goal: for all Y, not(logician Y) or not(american Y) *** practical questions in using resolution (and Prolog's answers) what clause to resolve? (goal or descendent) what disjunct in goal to resolve? (leftmost = linear) what clause to resolve against? (from original set, top-down) what subsitution to use? (most general) search strategy breadth-first - sure to find solution (complete) depth first - less storage for backtracking (Prolog) *** SL resolution (**draw following tree as you go**) not (logician Y) or not (american Y) | X1 = U0 | Y = U0 | | not scientist(U0) or not american(U0) | | U0 = sue | | U0 = ron | | not american(sue) not american(ron) | | fails! succeeds (answer the query (infer? (locician Y) (american Y)) 0. denial of query: not (logician Y) or not (american Y) 1. select not (logician Y), unifies with lhs of 5, with Y = U0, X = U0, get new goal list: not( scientist U0) or not (american U0) 2. select (scientist U0), unifies with 1 by U0 = sue, get new goal list: not (american sue) 3. (american sue) does not unify with any lhs, so proof fails 4. backtrack to last selection, (2), can unify (scientist U0) with U0 = ron, get new goal list: not (american ron) 5. (american ron) unifies with rule 4, new goal list empty. means denial of goal was inconsistent substitution was Y=U0=ron ** Why Horn clauses? (omit) lhs of rules is always positive e.g., A if B and C ==> A or not B or not C not every statement in predicate logic can be stated this way. ** Top-down vs. bottom up control *** top-down control (backward chaining) as in Prolog goal directed, start with goal as in resolution algorithm only works well when there is a small set of possible answers *** bottom up control (forward chaining) as in OPS5 hard to know what goals to generate ** Depth-first search vs breadth-first search. *draw trees* breadth-first search strategy guaranteed to find refutation if possible may require exponential amount of space (hence time) to track *mimics parallel search! depth-first may not find refutation on another branch requires less space if succeeds. makes order of clauses tried very important example: (infer p from p q) (infer p) (infer q) Prolog goes into infinite loop on goal (infer? p) breadth first search finds answer.