380 likes | 794 Views
Standard Logical Equivalences. Resolution Procedure (aka Resolution Refutation Procedure). Resolution procedure is a complete inference procedure for FOL Resolution procedure uses a single rule of inference: the Resolution Rule (RR), which is a generalization of the same rule used in PL
E N D
Resolution Procedure (aka Resolution Refutation Procedure) • Resolution procedure is a complete inference procedure for FOL • 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 P1 v P2 v ... v Pn and sentence ~P1 v Q2 v ... v Qm derive resolvent sentence: P2 v ... v Pn v Q2 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
Resolution Procedure… • Resolution Rule for FOL: • Given sentence P1 v ... v Pn • and sentence Q1 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 ~Qkunify with substitution list Theta, then derive the resolvent sentence:subst(Theta, P1 v ... v Pj-1 v Pj+1 v ... v Pn v Q1 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} • To introduce substitutions different logical expressions have to be look identical • Unification
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. • Theta is called the most general unifier (mgu)
Unification… • Examples
Unification p q Knows(John,x) Knows(John,Jane) Knows(John,x) Knows(y,OJ) Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ)
Unification p q Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ)
Unification p q Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ)
Unification p q Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}} Knows(John,x) Knows(x,OJ)
Unification p q Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}} Knows(John,x) Knows(x,OJ) {fail}
Unification • To unify Knows(John,x) and Knows(y,z), = {y/John, x/z } or = {y/John, x/John, z/John} • The first unifier is more general than the second. • There is a single most general unifier (MGU) that is unique up to renaming of variables. MGU = { y/John, x/z }
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. • 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 previous pseudo-code.
Models and Entailment • If there is an interpretation for a sentence such that the sentence is true in a particular world, that world is called a model • A sentence is entailed by a knowledge base KB if the models of the knowledge base KB are also models of the sentence KB |= • This means that every interpretation I that satisfies KB, satisfies
Resolution Procedure… • Proof by contradiction method • Given a set of axioms KBand goal sentence Q, we want to show that KB |= Q. • This means that every interpretation I that satisfies KB, satisfies Q. • But we know that any interpretation I satisfies either Q or ~Q, but not both. • Therefore if in fact KB |= Q, an interpretation that satisfies KB, satisfies Q and does not satisfy ~Q. • Hence KB union {~Q} is unsatisfiable, i.e., that it's false under all interpretations. • In other words, (KB |- Q) <=> (KB ^ ~Q |- False)
Resolution Algorithm procedure resolution-refutation(KB, Q) ;; KB is a set of consistent, true FOL sentences ;; Q is a goal sentence that we want to derive ;; return success if KB |- Q, and failure otherwise KB = union(KB, ~Q) while false not in KB do pick 2 sentences, S1 and S2, in KB that contain literals that unify (if none, return "failure“) resolvent = resolution-rule(S1, S2) KB = union(KB, resolvent) return "success"
Resolution example (using PL sentences) • From “Heads I win, tails you lose” prove that “I win” • First, define the axioms in KB: • "Heads I win, tails you lose."(Heads => IWin) or, equivalently, (~Heads v IWin)(Tails => YouLose) or, equivalently, (~Tails v YouLose) • Add some general knowledge axioms about coins, winning, and losing:(Heads v Tails)(YouLose => IWin) or, equivalently, (~YouLose v IWin)(IWin => YouLose) or, equivalently, (~IWin v YouLose) • Goal: IWin
Problems yet to be addressed • Resolution rule of inference is only applicable with sentences that are in the form P1 v P2 v ... v Pn • where each Pi is a negated or nonnegated predicate • contains functions, constants, and universally quantified variables • so can we convert every FOL sentence into this form? • Resolution strategy • How to pick which pair of sentences to resolve? • How to pick which pair of literals, one from each sentence, to unify?
Converting FOL sentences to clause form • Every FOL sentence can be converted to a logically equivalent sentence that is in a "normal form" called clause form • Steps to convert a sentence to clause form: • Eliminate all <=> connectives by replacing each instance of the form (P <=> Q) by expression ((P => Q) ^ (Q => P)) • Eliminate all => connectives by replacing each instance of the form (P => Q) by (~P v Q) • Reduce the scope of each negation symbol to a single predicate by applying equivalences such as converting • ~~P to P • ~(P v Q) to ~P ^ ~Q • ~(P ^ Q) to ~P v ~Q • ~(Ax)P to (Ex)~P • ~(Ex)P to (Ax)~P
Converting FOL sentences to clause form… • Standardize variables: rename all variables so that each quantifier has its own unique variable name. • For example, convert (Ax)P(x) to (Ay)P(y) if there is another place where variable x is already used. • Eliminate existential quantification by introducing Skolem functions. • For example, convert (Ex)P(x) to P(c) where c is a brand new constant symbol that is not used in any other sentence. c is called a Skolem constant. • More generally, if the existential quantifier is within the scope of a universal quantified variable, then introduce a Skolemfunction that depends on the universally quantified variable. • For example,(Ax)(Ey)P(x,y) is converted to (Ax)P(x, f(x)).f is called a Skolem function, and must be a brand new function name that does not occur in any other sentence in the entire KB. • Example: (Ax)(Ey)loves(x,y) is converted to (Ax)loves(x,f(x)) where in this case f(x) specifies the person that x loves. • (If we knew that everyone loved their mother, then f could stand for the mother-of function.)
Converting FOL sentences to clause form… • Remove universal quantification symbols by first moving them all to the left end and making the scope of each the entire sentence, and then just dropping the "prefix" part. E.g., convert (Ax)P(x) to P(x) • Distribute "and" over "or" to get a conjunction of disjunctions called conjunctive normal form. • convert (P ^ Q) v R to (P v R) ^ (Q v R) • convert (P v Q) v R to (P v Q v R) • Split each conjunct into a separate clause, which is just a disjunction ("or") of negated and nonnegated predicates, called literals • Standardize variables apart again so that each clause contains variable names that do not occur in any other clause
Converting FOL sentences to clause form… Examples: • Convert the sentence • (Ax)(P(x) => ((Ay)(P(y) => P(f(x,y))) ^ ~(Ay)(Q(x,y) => P(y)))) • Eliminate <=>Nothing to do here. • Eliminate =>(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ ~(Ay)(~Q(x,y) v P(y)))) • Reduce scope of negation(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Ey)(Q(x,y) ^ ~P(y))))
Converting FOL sentences to clause form… • Standardize variables(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Ez)(Q(x,z) ^ ~P(z)))) • Eliminate existential quantification(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Q(x,g(x)) ^ ~P(g(x))))) • Drop universal quantification symbols(~P(x) v ((~P(y) v P(f(x,y))) ^ (Q(x,g(x)) ^ ~P(g(x))))) • Convert to conjunction of disjunctions(~P(x) v ~P(y) v P(f(x,y))) ^ (~P(x) v Q(x,g(x))) ^ (~P(x) v ~P(g(x)))
Converting FOL sentences to clause form… • Create separate clauses • ~P(x) v ~P(y) v P(f(x,y)) • ~P(x) v Q(x,g(x)) • ~P(x) v ~P(g(x)) • Standardize variables • ~P(x) v ~P(y) v P(f(x,y)) • ~P(z) v Q(z,g(z)) • ~P(w) v ~P(g(w))
Example: Hoofers Club • Problem Statement: Tony, Shi-Kuo and Ellen belong to the Hoofers Club. Every member of the Hoofers Club is either a skier or a mountain climber or both. No mountain climber likes rain, and all skiers like snow. Ellen dislikes whatever Tony likes and likes whatever Tony dislikes. Tony likes rain and snow. • Query: Is there a member of the Hoofers Club who is a mountain climber but not a skier?
Example: Hoofers Club… • Translation into FOL Sentences • Let S(x) mean x is a skier, M(x) mean x is a mountain climber, and L(x,y) mean x likes y, where the domain of the first variable is Hoofers Club members, and the domain of the second variable is snow and rain. We can now translate the above English sentences into the following FOL wffs: • (Ax) S(x) v M(x) • ~(Ex) M(x) ^ L(x, Rain) • (Ax) S(x) => L(x, Snow) • (Ay) L(Ellen, y) <=> ~L(Tony, y) • L(Tony, Rain) • L(Tony, Snow) • Query: (Ex) M(x) ^ ~S(x) • Negation of the Query: ~(Ex) M(x) ^ ~S(x)
Example: Hoofers Club… • Conversion to Clause Form • S(x1) v M(x1) • ~M(x2) v ~L(x2, Rain) • ~S(x3) v L(x3, Snow) • ~L(Tony, x4) v ~L(Ellen, x4) • L(Tony, x5) v L(Ellen, x5) • L(Tony, Rain) • L(Tony, Snow) • Negation of the Query: ~M(x7) v S(x7)
Example: Hoofers Club… • Resolution Refutation Proof
Example: Hoofers Club… • Answer Extraction • Answer to the query: Ellen!