Presentation is loading. Please wait.

Presentation is loading. Please wait.

Resolution. An example 1.John is a lawyer. 2.Lawyers are rich. 3.Rich people have big houses. 4.Big houses are a lot of work. We would like to conclude.

Similar presentations


Presentation on theme: "Resolution. An example 1.John is a lawyer. 2.Lawyers are rich. 3.Rich people have big houses. 4.Big houses are a lot of work. We would like to conclude."— Presentation transcript:

1 Resolution

2 An example 1.John is a lawyer. 2.Lawyers are rich. 3.Rich people have big houses. 4.Big houses are a lot of work. We would like to conclude that John’s house is a lot of work. Natural languages are ambiguous so we can have different axiomatizations.

3 Axiomatization 1 1.lawyer(john) 2.  x lawyer(x)  rich(x) 3.  x rich(x)   y house(x,y) 4.  x,y rich(x)  house(x,y)  big(y) 5.  x,y ( house(x,y)  big(y)  work(y) ) 3 and 4, say that rich people do have at least one house and all their houses are big. Conclusion we want to show: house(john, jhouse)  work(john, jhouse) Or, do we want to conclude that John has at least one house that needs a lot of work? I.e.  y house(john,y)  work(y)

4 Axiomatization 2 1.lawyer(john) 2.  x lawyer(x)  rich(x) 3.  x rich(x)   y house(x,y)  big(y) 4.  x,y ( house(x,y)  big(y)  work(y) ) Now, 3 says that rich people have at least one house which is big. Conclusion we want to show: house(john, jhouse)  work(john, jhouse) Well, this is not anymore a conclusion we can or want to derive! So, now we want to conclude that John has at least one house that needs a lot of work? I.e.  y house(john,y)  work(y)

5 Let’s fix axiomatization 1… 1.lawyer(john) 2.  x lawyer(x)  rich(x) 3.  x rich(x)   y house(x,y) 4.  x,y rich(x)  house(x,y)  big(y) 5.  x,y ( house(x,y)  big(y)  work(y) ) Conclusion we want to show: John has at least one house that needs a lot of work. I.e.  y house(john,y)  work(y) Think about sentence 3. It says that every rich person x, has a house; which house? The one that belongs to him, I.e. let’s name it: houseof(x). Now, 3 can be rewritten as  x rich(x)  house(x, houseof(x)) This is called skolemization.

6 Universal quantifiers Since universal quantifiers appear so often, it is common simply to omit them, using the convention that any variable not associated with a quantifier is implicitly universally quantified. So, the premises become: 1.lawyer(john) 2.lawyer(x)  rich(x) 3.rich(x)  house(x, houseof(x)) 4.rich(x)  house(x,y)  big(y) 5.house(x,y)  big(y)  work(y)

7 Clausal Form A literal is either an atomic sentence or a negation of an atomic sentence. A clausal sentence is either a literal or a disjunction of literals. A clause is a set of literals. {p(a)} {  p(a)} {p(a), q(b)} The empty clause {} is unsatisfiable. Before applying resolution we want to convert the sentences into clausal form.

8 Inseado Implications Out:  1  2  1  2  1  2  1  2  1  2  (  1  2 )  (  1  2 ) Negations In:   (  1  2 )  1  2  (  1  2 )  1  2 . .  . . 

9 Inseado (continued) Standardize variables (I.e. renaming)  x.p(x)  x.q(x)  x.p(x)  y.q(y) The scope of quantifiers determines the scope of variables. So, in order to avoid name conflicts we rename the variables. Existentials Out  x.p(x)  p(a)  xy.(p(x)  z.q(x, y, z))  xy.(p(x)  q(x, y, f (x, y))) This is called skolemization. Recall example with lawyers. When the existentially quantified variable is not in the scope of any universally quantified variable, we just replace it with an object constant (name doesn’t matter). See first case.

10 Inseado (concluded) Alls Out  x.( p(x)  q(x, y, f (x, y)))  p(x)  q(x, y, f (x, y)) Distribution  1  (  2  3)  (  1  2)  (  1  3) (  1  2)  3  (  1  3)  (  2  3) Operators out  1 ...  n  1...  n  1 ...  n  {  1,...,  n}

11 Example 1.{lawyer(john)} 2.  x (lawyer(x)  rich(x)) 3.  x (rich(x)   y house(x,y)) 4.  x,y (rich(x)  house(x,y)  big(y)) 5.  x,y ( house(x,y)  big(y)  work(y) )  x (lawyer(x)  rich(x)) I  x (  lawyer(x)  rich(x)) N  x (  lawyer(x)  rich(x)) S  x (  lawyer(x)  rich(x)) E  x (  lawyer(x)  rich(x)) A  lawyer(x)  rich(x) D  lawyer(x)  rich(x) O{  lawyer(x), rich(x)}  x (rich(x)   y house(x,y)) I  x (  rich(x)   y house(x,y)) N  x (  rich(x)   y house(x,y)) S  x (  rich(x)   y house(x,y)) E  x (  rich(x)  house(x,houseof(x)) A  rich(x)  house(x,houseof(x)) D  rich(x)  house(x,houseof(x)) O{  rich(x), house(x,houseof(x))}  x,y (rich(x)  house(x,y)  big(y)) I  x,y (  (rich(x)  house(x,y))  big(y)) N  x,y (  rich(x)   house(x,y)  big(y)) S  x,y (  rich(x)   house(x,y)  big(y)) E  x,y (  rich(x)   house(x,y)  big(y)) A  rich(x)   house(x,y)  big(y) D  rich(x)   house(x,y)  big(y) O{  rich(x),  house(x,y), big(y)}

12 Example (continued)  x,y ( house(x,y)  big(y)  work(y) ) I  x,y (  (house(x,y)  big(y))  work(y) ) N  x,y (  house(x,y)   big(y)  work(y) ) S  x,y (  house(x,y)   big(y)  work(y) ) E  x,y (  house(x,y)   big(y)  work(y) ) A  house(x,y)   big(y)  work(y) D  house(x,y)   big(y)  work(y) O{  house(x,y),  big(y), work(y)} Negated conclusion:  y (house(john,y)  work(y)) I  y (house(john,y)  work(y)) N  y (  house(john,y)   work(y)) S  y (  house(john,y)   work(y)) E  y (  house(john,y)   work(y)) A  house(john,y)   work(y) D  house(john,y)   work(y) O{  house(john,y),  work(y)}

13 Example (concluded) Here are all the clauses we got through INSEADO from the premises and the negated conclusion. {lawyer(john)} {  lawyer(x 1 ), rich(x 1 )} {  rich(x 2 ), house(x 2,houseof(x 2 ))} {  rich(x 3 ),  house(x 3,y 1 ), big(y 1 )} {  house(x 4,y 2 ),  big(y 2 ), work(y 2 )} {  house(john,y 3 ),  work(y 3 )} Note: We rename the variables, in order to not have variable name clashes between clauses.

14 Resolution Propositional resolution was: {  1,..., ,...,  m } {  1,..., ,...,  n } {  1,...,  m,  1,...,  n } Similarly, relational resolution is: {  1,..., ,...,  m } {  1,..., ,...,  n } {  1,...,  m,  1,...,  n }  where  mgu( ,  ) mgu( ,  ): Most General Unifier Example. { p(a, y),r(y)} {  p(x,b)} {r(y)}{x  a, y  b} {r(b)} We are unifying (or making the same) p(a, y) with p(x,b). So, what we should do? Make x  a and y  b. The set {x  a, y  b}, which is a mapping from variables to constants is called a unifier.

15 Unification Unification is the process of determining whether two expressions can be made identical by the appropriate substitutions for their variables. A substitution is a finite mapping of variables to terms. We write substitutions as sets of replacement rules, e.g.: {x  a,y  f (b),z  v} In each rule, the variable to which the arrow is pointing to is to be replaced by the term from which the arrow is pointing. In this case, x is to be replaced by a, y is to be replaced by f(b), and z is to be replaced by v. The variables being replaced constitute the domain of the substitution, and the terms replacing them constitute the range. In the example above: domain is {x, y, z}, and range is {a, b, v}. The variables in the domain are called bound. The terms in the range are called variable bindings.

16 A substitution is pure when all replacement terms in the range are free of the variables in the domain of the substitution. Otherwise, the substitution is impure. The substitution shown above is pure whereas the one shown below is impure. {x  a,y  f (b),z  x} The result of applying a substitution  to an expression  is the expression  obtained from the original expression by replacing every occurrence of every variable in the domain of the substitution by the term with which it is associated. Examples: q(x, y) {x  a, y  f (b), z  v}  q(a, f (b)) q(x, x) {x  a, y  f (b), z  v}  q(a,a) q(x,w) {x  a, y  f (b), z  v}  q(a,w) q(z,v) {x  a, y  f (b), z  v}  q(v,v)

17 If no bound variable of a pure substitution  occurs in another pure substitution , then we can compose  with , obtaining so a new substitution  which is also pure. We do the composition by applying  at the bindings of , and then adding remaining bindings from . E.g. {w  g(x,y)} {x  a, y  b, z  c} = {w  g(a,b), x  a, y  b, z  c} A set of expressions {  1, …,  n } is unifiable if and only if there is a substitution  that makes the expressions identical; I.e.  1  = …=  n   is said to be a unifer for the set. E.g. {x  a, y  b, z  c} unifies the expressions p(a,y,z) and p(x,b,z): p(a,y,z) {x  a, y  b, z  c} = p(a,b,c) = P(x,b,z) {x  a, y  b, z  c} The above is not the only unifier. We can say for z, z  w or z  c. Well, the z  w is more “general” than z  c, because w is variable, which can bounded later to any other variable or constant, while c as constant can’t be bounded to anything at all.

18 Formally: We say that a substitution  is more general than a unifier  if there exists a substitution  such that  = . A most general unifier (mgu)  has the property that any other unifier  can be obtained from  by some substitution:  = . The mgu is unique up to variable renaming. Example. p(x,y) and p(a,v) are unifiable because they have a unifier, e.g. {xa,yb,vb}{xa,yb,vb} The results of applying this substitution to the two expressions are: p(x, y) {x  a, y  b,v  b}  p(a,b) p(a,v) {x  a,y  b,v  b}  p(a,b) We could have substituted c or d or f(c) or f(w) for y and v. In fact, we can unify the expressions without changing v at all by simply replacing y by v. So, the substitution {x  a,y  v} is more general than {x  a,y  f(c),v  f(c)} since there is a substitution {v  f(c)} that, when applied to the former, gives the latter: {x  a,y  v} {v  f (c)}  {x  a, y  f (c),v  f (c)}

19 Mgu (x,y) { if (x==y) return {}; if (Variable(x)) return MguVar(x,y); if (Variable(y)) return MguVar(y,x); if (Constant(x) || Constant(y)) exit(“Non unifiable”); if (Length(x) != Length(y)) exit(“Non unifiable”);; i = 0; g = {}; while (TRUE) { if (i==Length(x)) return g; s = Mgu (Part(x,i), Part(y,i)); g = Compose(g,s); x = Substitute(x,g); y = Substitute(y,g); i = i + 1; } } MguVar (x,y) { if (x occurs in y) exit(“Non unifiable”); return {x  y}; } Well, this is for the computer…In doing examples by hand, we can easily find the mgu by looking. Variable(x) returns TRUE is x is variable. Length(x) for x e.g. x=F(A,G(y)) returns the number of arguments, I.e. 2. Part(i) returns the i-th part. E.g. Part(F(A,G(y)), 0) = F Part(F(A,G(y)), 1) = A Part(F(A,G(y)), 2) = G(y) Compose(g,s) is self- explanatory. Substitute(x,g) is self- explanatory. Recursive procedure for the mgu of two expressions(starting with a relation or function)

20 Unification example E1: p(x, g(y,y), x) with E2: p(g(a,z), v, v) p==p -- part 0 Now try to unify x with g(a,z) -- part 1 x  g(a,z) Now apply this substitution to both E1 and E2 E1: p(g(a,z), g(y,y), g(a,z)) E2: p(g(a,z), v, v) Now try to unify g(y,y) with v -- part 2 v  g(y,y) Now apply this substitution to both E1 and E2 E1: p(g(a,z), g(y,y), g(a,z)) E2: p(g(a,z), g(y,y), g(y,y)) Now try to unify g(a,z) with g(y,y) -- part 3 Recursively, we find y  a and z  a. Finally, {x  g(a,a), y  a, z  a, v  g(a,a)} E1: p(g(a,a), g(a,a), g(a,a)) E2: p(g(a,a), g(a,a), g(a,a))

21 Example. 1.{p(a,b)}  2.{  p(x,y), q(x,y)}  3.{  q(z,w), r(z)}  4.{  r(v)}  5.{q(a,b)}1,2 6.{  q(v,w)}3,4 7.{}5,6 When the {} conclusion is derived we have a contradiction. It is useful in proving things by refutation, I.e. assuming that what we want to prove is not true… There are other possible conclusions that can be derived from the same premises. In the following graph there are the possible conclusions. {p(a,b)} {  p(x,y), q(x,y)}{  q(z,w), r(z)} {  r(v)} {q(a,b)} {  p(z,w), r(z)} {  q(v,w)} {r(a)} {} {  p(v,w)}

22 1.{p(a,b)}  2.{  p(x,y), q(x,y)}  3.{  q(z,w), r(z)}  4.{  r(v)}  5.{q(a,b)}1,2 6.{  p(z,w), r(z)}2,3 7.{  q(v,w)}3,4 8.{r(a)}3,5 9.{r(a)}1,6 10.{  p(v,w)}4,6 11.{  p(v,w)}2,7 12.{}1,10 We keep two pointers (the slow and the fast); On each step we compare the sentences under the pointers. If we can resolve, we add the new derived sentence at the end of the list. At the start of the inference we initialize slow and fast at the top of the list. As long as the two pointers point to different positions, we leave the slow where it is and advance the fast. When they meet, we move the fast at the top of the list and we move the slow one position down the list.

23 Lawyer’s example 1.{lawyer(john)} 2.{  lawyer(x 1 ), rich(x 1 )} 3.{  rich(x 2 ), house(x 2,houseof(x 2 ))} 4.{  rich(x 3 ),  house(x 3,y 1 ), big(y 1 )} 5.{  house(x 4,y 2 ),  big(y 2 ), work(y 2 )} 6.{  house(john,y 3 ),  work(y 3 )} 7.{rich(john)}1,2 mgu = {x1  john} 8.{  lawyer(x 2 ), house(x 2,houseof(x 2 ))}2,3 mgu = {x1  x2} 9.{  lawyer(x 2 ),  house(x 3,y 1 ), big(y 1 )}2,4 10.{  rich(x 3 ), big(houseof(x 3 ))}3,4 11.{  rich(x 2 ),  big(houseof(x 2 )), work(houseof(x 2 ))}3,5 12.{…}4,5 13.{…}3,6 14.{…}5,6 … you can continue with the two finger method…but it’s too long.

24 Lawyer’s example in short… 1.{lawyer(john)} 2.{  lawyer(x 1 ), rich(x 1 )} 3.{  rich(x 2 ), house(x 2,houseof(x 2 ))} 4.{  rich(x 3 ),  house(x 3,y 1 ), big(y 1 )} 5.{  house(x 4,y 2 ),  big(y 2 ), work(y 2 )} 6.{  house(john,y 3 ),  work(y 3 )} 7.{rich(john)}1,2 8.{  rich(john),  work(houseof(john))}3,6 9.{  work(houseof(john))}7,8 10.{house(john,houseof(john))}3,7 11.{  house(john,y 1 ), big(y 1 )}4,7 12.{big(houseof(john))}10,11 13.{  house(x 4, houseof(john)), work(houseof(john))}5,12 14.{work(houseof(john))} 10,13 15.{}9,14

25 Curiosity and the cat Everyone who loves all animals is loved by someone. Anyone who kills an animal is loved by no one. Jack loves all animals. Either Jack or Curiosity killed the cat, who is named Tuna. Did Curiosity kill the cat? 1.  x [  y animal(y)  loves(x,y)]  [  y loves(y,x)] 2.  x [  y animal(y)  kills(x,y)]  [  z  loves(z,x)] 3.  y animal(y)  loves(jack,y) 4.kills(jack,tuna)  kills(curiosity,tuna) 5.  x cat(x)  animal(x) 6.  kills(curiosity,tuna)negated goal

26 Curiosity – Inseado (1)  x [  y (animal(y)  loves(x,y))]  [  y loves(y,x)] I  x  [  y (  animal(y)  loves(x,y))]  [  y loves(y,x)] N  x [  y  (  animal(y)  loves(x,y))]  [  y loves(y,x)]  x [  y (animal(y)   loves(x,y))]  [  y loves(y,x)] S  x [  y (animal(y)   loves(x,y))]  [  z loves(z,x)] E  x [animal(f(x))   loves(x,f(x))]  [loves(g(x),x)] A [animal(f(x))   loves(x,f(x))]  [loves(g(x),x)] D [animal(f(x))  loves(g(x),x) ]  [  loves(x,f(x))  loves(g(x),x)] O{animal(f(x)), loves(g(x),x)} {  loves(x,f(x)), loves(g(x),x)}

27 Curiosity – Inseado (2)  x [  y animal(y)  kills(x,y)]  [  z  loves(z,x)] I  x  [  y animal(y)  kills(x,y)]  [  z  loves(z,x)] N  x [  y  animal(y)   kills(x,y)]  [  z  loves(z,x)] S  x [  y  animal(y)   kills(x,y)]  [  z  loves(z,x)] E  x [  y  animal(y)   kills(x,y)]  [  z  loves(z,x)] A  animal(y)   kills(x,y)   loves(z,x) D  animal(y)   kills(x,y)   loves(z,x) O{  animal(y),  kills(x,y),  loves(z,x)}

28 Curiosity – Inseado (3-5)  y animal(y)  loves(jack,y) INSE  y  animal(y)  loves(jack,y) AD  animal(y)  loves(jack,y) O{  animal(y), loves(jack,y)} kills(jack,tuna)  kills(curiosity,tuna) INSEADO{kills(jack,tuna), kills(curiosity,tuna)}  x cat(x)  animal(x) INSE  x  cat(x)  animal(x) AD  cat(x)  animal(x) O{  cat(x), animal(x)}

29 Clausal Curiosity 1.{animal(f(x 1 )), loves(g(x 1 ),x 1 )} 2.{  loves(x 2,f(x 2 )), loves(g(x 2 ),x 2 )} 3.{  animal(y 1 ),  kills(x 3,y 1 ),  loves(z,x 3 )} 4.{  animal(y 2 ), loves(jack,y 2 )} 5.{kills(jack,tuna), kills(curiosity,tuna)} 6.{  cat(x 4 ), animal(x 4 )} 7.  kills(curiosity,tuna) Note: We rename the variables, in order to not have variable name clashes between clauses.

30


Download ppt "Resolution. An example 1.John is a lawyer. 2.Lawyers are rich. 3.Rich people have big houses. 4.Big houses are a lot of work. We would like to conclude."

Similar presentations


Ads by Google