Seminar on Unification Ground Resolution The substitution rule
Seminar on Unification
Ground Resolution The substitution rule allows us to derive instances of a clause by ‘filling in’ the values of variables, one of the key steps in the kind of derivation we carried out in Chapter 1. The other key step is to combine two clauses that have a matching literal, to derive a new clause. We consider first the special case used there, in which both the clauses are ground. It is called the rule of ground resolution: From two ground clauses P : − Q 1, . . . , Qj, . . . , Qn and Q : − R 1, . . . , Rm such that Q = Qj , derive the clause P : − Q 1, . . . , Qj− 1, R 1, . . . , Rm, Qj+1, . . . , Qn obtained by taking a copy of the first clause and replacing Qj with the body of the second clause. We call the clause that is derived in this rule the ground resolvent of the first two clauses on Qj. 12/22/2021 2
Incompleteness of the generalized modus ponens inference rule Backward chaining Generalized Modus Ponens Forward chaining x x P(x) => Q(x) Cannot be converted to Horn Q(x) => S(x) R(x) => S(x) Want to conclude S(A) is true if Q(A) or R(A) is true, and one of those must be true because either P(A) or P(A) Incomplete: there are entailed sentences that the procedure cannot infer. 12/22/2021 3
Generalized Modus Ponens in Horn FOL • Generalized Modus Ponens (GMP) is complete for KBs containing only Horn clauses – A Horn clause is a sentence of the form: (Ax) (P 1(x) ^ P 2(x) ^. . . ^ Pn(x)) => Q(x) where there are 0 or more Pi's, and the Pi's and Q are positive (i. e. , un-negated) literals – Horn clauses represent a subset of the set of sentences representable in FOL. For example, P(a) v Q(a) is a sentence in FOL but is not a Horn clause. – Natural deduction using GMP is complete for KBs containing only Horn clauses. Proofs start with the given axioms/premises in KB, deriving new sentences using GMP until the goal/query sentence is derived. This defines a forward chaining inference procedure because it moves "forward" from the KB to the goal. 12/22/2021 4
Example of forward chaining Example: KB = All cats like fish, cats eat everything they like, and Ziggy is a cat. In FOL, KB = • 1. 2. 3. • (Ax) cat(x) => likes(x, Fish) (Ax)(Ay) (cat(x) ^ likes(x, y)) => eats(x, y) cat(Ziggy) Goal query: Does Ziggy eat fish? Data-driven Proof: 1. Use GMP with (1) and (3) to derive: 4. likes(Ziggy, 2. Use GMP with (3), (4) and (2) to derive eats(Ziggy, 3. So, Yes, Ziggy eats fish. 12/22/2021 Fish) 5
Backward chaining • Backward-chaining deduction using GMP is complete for KBs containing only Horn clauses. Proofs start with the goal query, find implications that would allow you to prove it, and then prove each of the antecedents in the implication, continuing to work "backwards" until we get to the axioms, which we know are true. Example: Does Ziggy eat fish? To prove eats(Ziggy, Fish), first see if this is known from one of the axioms directly. Here it is not known, so see if there is a Horn clause that has the consequent (i. e. , right-hand side) of the implication matching the goal. Proof: Goal Driven 1. Goal matches RHS of Horn clause (2), so try and prove new sub-goals cat(Ziggy) and likes(Ziggy, Fish) that correspond to the LHS of (2) 2. cat(Ziggy) matches axiom (3), so we've "solved" that sub-goal 3. likes(Ziggy, Fish) matches the RHS of (1), so try and prove cat(Ziggy) 4. cat(Ziggy) matches (as it did earlier) axiom (3), so we've solved this sub-goal 5. There are no unsolved sub-goals, so we're done. Yes, Ziggy eats fish. • • 12/22/2021 6
Resolution Procedure (aka Resolution Refutation Procedure) • Resolution procedure is a sound and complete inference procedure for FOL (BFS is complete for Horn, DFS may go into infinite loops) • Resolution procedure uses a single rule of inference: the Resolution Rule (RR), which is a generalization of the same rule used in PL • Resolution Rule for PL: From sentence P 1 v P 2 v. . . v Pn and sentence ~P 1 v Q 2 v. . . v Qm derive resolvent sentence: P 2 v. . . v Pn v Q 2 v. . . v Qm – Examples • From P and ~P v Q, derive Q (Modus Ponens) • From (~P v Q) and (~Q v R), derive ~P v R • From P and ~P, derive False • From (P v Q) and (~P v ~Q), derive True 12/22/2021 7
Resolution Procedure… • Resolution Rule for FOL: – Given sentence P 1 v. . . v Pn – and sentence Q 1 v. . . v Qm • where each Pi and Qi is a literal, i. e. , a positive or negated predicate symbol with its terms, – if Pj and ~Qk unify with substitution list Theta, – then derive the resolvent sentence: subst(Theta, P 1 v. . . v Pj-1 v Pj+1 v. . . v Pn v Q 1 v. . . Qk-1 v Qk+1 v. . . v Qm) • Example – From clause P(x, f(a)) v P(x, f(y)) v Q(y) – and clause ~P(z, f(a)) v ~Q(z), – derive resolvent clause P(z, f(y)) v Q(y) v ~Q(z) using Theta = {x/z} 12/22/2021 8
Unification • Unification is a "pattern matching" procedure that takes two atomic sentences, called literals, as input, and returns "failure" if they do not match and a substitution list, Theta, if they do match. – That is, unify(p, q) = Theta means subst(Theta, p) subst(Theta, q) for two atomic sentences p and q. – Theta is called the most general unifier (mgu) = • All variables in the given two literals are implicitly universally quantified • To make literals match, replace (universallyquantified) variables by terms 12/22/2021 9
Unification Algorithm procedure unify(p, q, theta) Scan p and q left-to-right and find the first corresponding terms where p and q "disagree" ; where p and q not equal If there is no disagreement, return theta ; success Let r and s be the terms in p and q, respectively, where disagreement first occurs If variable(r) then theta = union(theta, {r/s}) unify(subst(theta, p), subst(theta, q), theta) else if variable(s) then theta = union(theta, {s/r}) unify(subst(theta, p), subst(theta, q), theta) else return "failure" end 12/22/2021 10
Unification… • Examples Literal 1 Literal 2 Literal 3 parents(x, father(x), mother(Bill)) parents(Bill, father(Bill), y) {x/Bill, y/mother(Bill)} parents(x, father(x), mother(Bill)) parents(Bill, father(y), z) {x/Bill, y/Bill, z/mother(Bill)} parents(x, father(x), mother(Jane)) parents(Bill, father(y), mother(y)) Failure 12/22/2021 11
Unification… • Unify is a linear time algorithm that returns the most general unifier (mgu), i. e. , a shortest length substitution list that makes the two literals match. – (In general, there is not a unique minimum length substitution list, but unify returns one of them. ) • A variable can never be replaced by a term containing that variable. For example, x/f(x) is illegal. This "occurs check" should be done in the above pseudocode before making the recursive calls. 12/22/2021 12
Resolution procedure as search • Resolution procedure can be thought of as the bottom-up construction of a search tree, where the leaves are the clauses produced by KB and the negation of the goal. When a pair of clauses generates a new resolvent clause, add a new node to the tree with arcs directed from the resolvent to the two parent clauses. The resolution procedure succeeds when a node containing the False clause is produced, becoming the root node of the tree. • A strategy is complete if its use guarantees that the empty clause (i. e. , false) can be derived whenever it is entailed 12/22/2021 13
Some strategies for controlling resolution's search • Breadth-First – Level 0 clauses are those from the original axioms and the negation of the goal. Level k clauses are the resolvents computed from two clauses, one of which must be from level k-1 and the other from any earlier level. – Compute all level 1 clauses possible, then all possible level 2 clauses, etc. – Complete, but very inefficient. • Set-of-Support – At least one parent clause must be from the negation of the goal or one of the "descendents" of such a goal clause (i. e. , derived from a goal clause) – Complete (assuming all possible set-of-support clauses are derived) • Unit Resolution – At least one parent clause must be a "unit clause, " (clause containing a single literal) – Not complete in general, but complete for Horn clause KBs • Input Resolution – At least one parent from the original KB (axioms and the negation of the goal) – Not complete in general, but complete for Horn clause KBs • Linear Resolution – P and Q can be resolved together if either P is in the original KB or if P is an ancestor of Q in the proof tree – Complete 12/22/2021 14
12/22/2021 15
12/22/2021 16
12/22/2021 17
12/22/2021 18
12/22/2021 19
12/22/2021 20
- Slides: 20