1 / 53

Logic seminar 5

Logic seminar 5. The resolution principle 12.12.2005. Slobodan Petrović. The resolution principle. Herbrand’s procedure has one major drawback: It requires the generation of sets S 1 ’, S 2 ’,… of ground instances of clauses. For most cases, this sequence grows exponentially. Example:

Download Presentation

Logic seminar 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logic seminar 5 The resolution principle 12.12.2005. Slobodan Petrović

  2. The resolution principle • Herbrand’s procedure has one major drawback: • It requires the generation of sets S1’, S2’,… of ground instances of clauses. • For most cases, this sequence grows exponentially. • Example: • S={P(x,g(x),y,h(x,y),z,k(x,y,z)), P(u,v,e(v),w,f(v,w),x)}

  3. The resolution principle • Example (cont.): • H0={a} • H1={a,g(a),h(a,a),k(a,a,a),e(a),f(a,a)} • … • The earliest set that is unsatisfiable is S5’. • S5’ has the order of 10256 elements. • It is impossible even to store S5’ in a computer.

  4. The resolution principle • In order to avoid the generation of sets of ground instances of clauses, the resolution principle was introduced by Robinson in 1965. • The resolution principle can be applied directly to any set S of clauses (not necessarily ground clauses) to test the unsatisfiability of S.

  5. The resolution principle • The essential idea of the resolution principle: • To check whether S contains the empty clause □. • If S contains □, then S is unsatisfiable. • If S does not contain □, then it should be checked whether □ can be derived from S. • By Herbrand’s theorem, checking for the presence of □ is equivalent to counting the number of nodes of a closed semantic tree for S.

  6. The resolution principle • S is unsatisfiable if and only if there is a finite closed semantic tree T for S. • S contains □ if and only if T consists of only one node – the root node. • If S does not contain □, then T must contain more than one node. • If we can reduce the number of nodes in T to one, □ may be forced to appear.

  7. The resolution principle • We can view the resolution principle as an inference rule that can be used to generate new clauses for S. • If we put these new clauses into S, some nodes of the original T can be forced to become failure nodes. • Thus the number of nodes in T can be reduced and the empty clause □ will be eventually derived.

  8. The resolution principle • The resolution principle for the propositional logic • The resolution principle is essentially an extension of the one-literal rule (Davis and Putnam). • Example. The clauses: C1: P C2: PQ. • Using the one-literal rule, from C1 and C2 we can obtain a clause: C3: Q

  9. The resolution principle • The one-literal rule requires the examination whether there is a complementary pair of a literal (in this example P) in C1 and a literal (in this example P) in C2. • Then the complementary pair is deleted from C1 and C2 to obtain C3.

  10. The resolution principle • By extending the one-literal rule and applying it to any pair of clauses (not necessarily unit clauses) we get the resolution principle: • For any two clauses C1 and C2, if there is a literal L1 in C1 that is complementary to a literal L2 in C2, then delete L1 and L2 from C1 and C2, respectively, and construct the disjunction of the remaining clauses. • The constructed clause is a resolvent of C1 and C2.

  11. The resolution principle • Example. The clauses: C1: PR C2: PQ. • Clause C1 has the literal P, which is complementary to P in C2. • By deleting P and P from C1 and C2, respectively, and constructing the disjunction of the remaining clauses R and Q, we obtain a resolvent: RQ.

  12. The resolution principle • Example. The clauses: C1: PQR C2: QS. • The resolvent of C1 and C2 is PRS. • Example. The clauses: C1: PQ C2: PR • Since there is no literal in C1 that is complementary to any literal in C2, there is no resolvent of C1 and C2.

  13. The resolution principle • Theorem: • Given two clauses C1 and C2, a resolvent C of C1 and C2 is a logical consequence of C1 and C2. • If we have two unit clauses, then the resolvent of them, if there is one, is the empty clause □. • If a set S of clauses is unsatisfiable, we can use the resolution principle to generate □ from S.

  14. The resolution principle • Definition: • Given a set S of clauses, a (resolution) deduction of C from S is a finite sequence C1, C2,…, Ck of clauses such that each Ci either is a clause in S or a resolvent of clauses preceding Ci, and Ck=C. • A deduction of □ from S is called a refutation, or a proof of S. • A clause C can be deduced or derived from S if there is a deduction of C from S.

  15. The resolution principle • Example. Given a set S of clauses: (1) PQ (2) Q (3) P • From (1) and (2), we can obtain a resolvent (4) P. • From (3) and (4), we can obtain a resolvent (5) □. • Since □ is derived from S by resolution, □ is a logical consequence of S. Hence S is unsatisfiable.

  16. The resolution principle • Example. Given a set S of clauses: (1) PQ (2) PQ (3) PQ (4) PQ • We generate the following resolvents: (5) Q (from (1) and (2)) (6) Q (from (3) and (4)) (7) □ (from (5) and (6)). • Since □ is derived, S is unsatisfiable.

  17. The resolution principle • Example (cont.) • The deduction can be represented by a tree – deduction tree.

  18. The resolution principle • Substitution and unification • The most important part of applying the resolution principle – finding a literal in a clause that is complementary to a literal in another clause. • For clauses containing no variables, this is very simple. • For clauses containing variables, it is more complicated.

  19. The resolution principle • Example. Consider the clauses: C1: P(x)Q(x) C2: P(f(x))R(x). • There is no literal in C1 that is complementary to any literal in C2. • However, if we substitute f(a) for x in C1 and a for x in C2, we obtain: C1’: P(f(a))Q(f(a)) C2’: P(f(a))R(a).

  20. The resolution principle • Example (cont.) • C1’and C2’are ground instances of C1 and C2, respectively. • P(f(a)) and P(f(a)) are complementary to each other. • Therefore, from C1’ and C2’ we can obtain a resolvent C3’: Q(f(a))R(a).

  21. The resolution principle • Example (cont.) • More generally, if we substitute f(x) for x in C1, we obtain: C1*: P(f(x))Q(f(x)) • C1* is an instance of C1. • The literal P(f(x)) in C1* is complementary to the literal P(f(x)) in C2. • The resolvent from C1* and C2 is C3: Q(f(x))R(x).

  22. The resolution principle • Example (cont.) • C3’ is an instance of C3. • By substituting appropriate terms for the variables in C1 and C2, we can generate new clauses from C1 and C2. • The clause C3 is the most general clause in the sense that all other clauses that can be generated by this process are instances of C3. • C3 is also called a resolvent of C1 and C2.

  23. The resolution principle • Definition • A substitution is a finite set of the form {t1/v1,…,tn/vn}, where every vi is a variable, every ti is a term different from vi, and no two elements in the set have the same variable after the stroke symbol. • When t1,…,tn are ground terms, the substitution is called a ground substitution. • The substitution that consists of no elements is called the empty substitution (denoted by ).

  24. The resolution principle • Example {f(z)/x,y/z} {a/x,g(y)/y,f(g(b))/z} are substitutions. • Definition • Let ={t1/v1,…,tn/vn} be a substitution and E be an expression. • Then E is an expression obtained from E by replacing simultaneously each occurrence of the variable vi, 1in, in E by the term ti. • E is called an instance of E.

  25. The resolution principle • Example. Let ={a/x,f(b)/y,c/z} and E=P(x,y,z}. • Then E=P(a,f(b),c).

  26. The resolution principle • Definition • Let ={t1/x1,…,tn/xn} and ={u1/y1,…,um/ym} be two substitutions. • Then the composition◦ of  and  is a substitution that is obtained from the set {t1/x1,…,tn/xn,u1/y1,…,um/ym} by deleting any element tj/xj for which tj=xj, and any element ui/yi such that yi is among {x1,x2,…,xn}.

  27. The resolution principle • Example. Let ={t1/x1,t2/x2}={f(y)/x,z/y} ={u1/y1,u2/y2,u3/y3}={a/x,b/y,y/z} • Then {t1/x1,t2/x2,u1/y1,u2/y2,u3/y3}={f(b)/x,y/y,a/x,b/y,y/z}. • Since t2=x2, t2/x2, i.e. y/y should be deleted from the set. • Since y1 and y2 are among {x1,x2}, u1/y1 and u2/y2, i.e. a/x and b/y should also be deleted. Thus: ◦={f(b)/x,y/z}.

  28. The resolution principle • The composition of substitutions is associative. • The empty substitution  is both a left and a right identity. • That is (◦)◦= ◦(◦) ◦=◦ for all , , and .

  29. The resolution principle • In the resolution proof procedure, in order to identify a complementary pair of literals, very often we have to unify two or more expressions. • We have to find a substitution that can make several expressions identical. • This process is called unification of expressions.

  30. The resolution principle • Definition • A substitution  is called a unifier for a set {E1,…,Ek} if and only if E1=E2=…=Ek. • The set {E1,…,Ek} is said to be unifiable if there is a unifier for it. • Definition • A unifier  for a set {E1,…,Ek} of expressions is a most general unifier if and only if for each unifier  for the set there is a substitution  such that =◦.

  31. The resolution principle • Example • The set {P(a,y),P(x,f(b))} is unifiable since the substitution ={a/x,f(b)/y} is a unifier for the set.

  32. The resolution principle • Unification algorithm • We have to find the most general unifier for a finite unifiable set of nonempty expressions – by means of a unification algorithm. • When the given set is not unifiable, the algorithm has also to detect that fact. • Example • Given P(a) and P(x), we have to find the disagreement between these two expressions, and then try to eliminate it.

  33. The resolution principle • Example (cont.) • For P(a) and P(x), the disagreement is {a,x}. • Since x is a variable, x can be replaced by a, and thus the disagreement can be eliminated. • Definition • The disagreement set of a nonempty set W of expressions is obtained by locating the first symbol (counting from the left) at which not all the expressions in W have exactly the same symbol, and then extracting from each expression in W the subexpression that begins with the symbol occupying that position. • The set of these respective subexpressions is the disagreement set of W.

  34. The resolution principle • Example W={P(x,f(y,z)),P(x,a),P(x,g(h(k(x))))} • The first symbol position at which not all atoms in W are exactly the same is the fifth, since they all have the first four symbols P(x, in common. • Thus the disagreement set consists of the respective subexpressions (underlined terms) that begin in symbol position number five. • It is the set {f(y,z),a,g(h(k(x)))}.

  35. The resolution principle • Unification algorithm (1) Set k=0, Wk=W, and k=. (2) If Wk is a singleton, stop; k is the most general unifier for W. Otherwise, find the disagreement set Dk of Wk. (3) If there exist elements vk and tk in Dk such that vk is a variable that does not occur in tk, go to Step 4. Otherwise, stop; W is not unifiable. (4) Let k+1=k◦{tk/vk} and Wk+1=Wk{tk/vk}. (Note that Wk+1=Wk+1.) (5) Set k=k+1 and go to Step 2.

  36. The resolution principle • Example • Find the most general unifier for W={P(a,x,f(g(y))),P(z,f(z),f(u))}. (1) 0= and W0=W. Since W0 is not a singleton, 0 is not the most general unifier for W. (2) The disagreement set D0={a,z}. In D0, there is a variable v0=z that does not occur in t0=a. (3) 1=0◦{t0/v0}=◦{a/z}={a/z}; W1=W0{t0/v0}={P(a,x,f(g(y))),P(z,f(z),f(u))}{a/z}={P(a,x,f(g(y))),P(a,f(a),f(u))}.

  37. The resolution principle • Example (cont.) (4) W1 is not a singleton, hence we find the disagreement set D1 of W1: D1={x,f(a)}. (5) From D1, we find that v1=x and t1=f(a). (6) 2=1◦{t1/v1}={a/z}◦{f(a)/x}={a/z,f(a)/x}; W2=W1{t1/v1}= ={P(a,x,f(g(y))),P(a,f(a),f(u))}{f(a)/x}= ={P(a,f(a),f(g(y))),P(a,f(a),f(u))}. (7) W2 is not a singleton, hence we find the disagreement D2 of W2: D2={g(y),u}. From D2, we find that v2=u and t2=g(y).

  38. The resolution principle • Example (cont.) (8) 3=2◦{t2/v2}={a/z,f(a)/x}◦{g(y)/u}= ={a/z,f(a)/x,g(y)/u}; W3=W2{t2/v2}= ={P(a,f(a),f(g(y))),P(a,f(a),f(u))}{g(y)/u}= ={P(a,f(a),f(g(y))),P(a,f(a),f(g(y)))}= ={P(a,f(a),f(g(y)))} (9) W3 is a singleton, hence 3={a/z,f(a)/x,g(y)/u} is the most general unifier for W.

  39. The resolution principle • Example. Determine whether or not the set W={Q(f(a),g(x)),Q(y,y)} is unifiable. (1) 0=, W0=W. (2) W0 is not a singleton, hence we find the disagreement set D0 of W0: D0={f(a),y}. From D0, we know that v0=y and t0=f(a). (3) 1=0◦{t0/v0}=◦{f(a)/y}={f(a)/y}; W1=W0{t0/v0}={Q(f(a),g(x)),Q(y,y)}{f(a)/y}= ={Q(f(a),g(x)),Q(f(a),f(a))}.

  40. The resolution principle • Example (cont.) (4) W1 is not a singleton, hence we find the disagreement set D1 of W1: D1={g(x),f(a)}. (5) No element of D1 is a variable. Hence the unification algorithm is terminated and we conclude that W is not unifiable. • Theorem • If W is a finite nonempty unifiable set of expressions, the unification algorithm will always terminate at Step 2, and the last k is the most general unifier for W.

  41. The resolution principle • The resolution principle for the first-order logic • Definition • If two or more literals (with the same sign) of a clause C have the most general unifier , then C is called a factor of C. • If C is a unit clause, it is called a unit factor of C.

  42. The resolution principle • Example. C=P(x)P(f(y))Q(x) • The first and the second literals have the most general unifier ={f(y)/x}. • Hence C=P(f(y))Q(f(y)) is a factor of C. • Definition • Let C1 and C2 be two clauses (called parent clauses) with no variables in common. • Let L1 and L2 be two literals in C1 and C2, respectively.

  43. The resolution principle • Definition (cont.) • If L1 and L2 have the most general unifier , then the clause (C1-L1)(C2-L2) is called a binary resolvent of C1 and C2. • The literals L1 and L2 are called the literals resolved upon.

  44. The resolution principle • Example. • Let C1=P(x)Q(x) and C2=P(a)R(x). • Since x appears in both C1 and C2, we rename the variable in C2 and let C2=P(a)R(y). • We choose L1=P(x) and L2=P(a). • Since L2=P(a), L1 and L2 have the most general unifier ={a/x}. (C1-L1)(C2-L2)= =({P(a),Q(a)}-{P(a)})({P(a),R(y)}-{P(a)})= ={Q(a)}{R(y)}={Q(a),R(y)}=Q(a)R(y). • Thus Q(a)R(y) is a binary resolvent of C1 and C2. P(x) and P(a) are the literals resolved upon.

  45. The resolution principle • Definition • A resolvent of (parent) clauses C1 and C2 is one of the following binary resolvents: • a binary resolvent of C1 and C2, • a binary resolvent of C1 and a factor of C2, • a binary resolvent of a factor of C1 and C2, • a binary resolvent of a factor of C1 and a factor of C2.

  46. The resolution principle • Example • Let C1=P(x)P(f(y))R(g(y)) and C2=P(f(g(a)))Q(b). • A factor of C1 is C1’=P(f(y))R(g(y)). • A binary resolvent of C1’ and C2 is R(g(g(a)))Q(b). • Therefore, R(g(g(a)))Q(b) is a resolvent of C1 and C2.

  47. The resolution principle • Example • Show that alternate interior angles formed by a diagonal of a trapezoid are equal. • We first axiomatize the theorem. • Let T(x,y,u,v) mean that xyuv is a trapezoid with upper-left vertex x, upper-right vertex y, lower-right vertex u, and lower-left vertex v. • Let P(x,y,u,v) mean that the line segment xy is parallel to the line segment uv. • Let E(x,y,z,u,v,w) mean that the angle xyz is equal to the angle uvw.

  48. The resolution principle • Example (cont.) • Then the axioms are the following: • A1: (x)(y)(u)(v)[T(x,y,u,v)P(x,y,u,v)] (definition of a trapezoid) • A2: (x)(y)(u)(v)[P(x,y,u,v)E(x,y,v,u,v,y)] (alternate interior angles of parallel lines are equal) • A3: T(a,b,c,d).

  49. The resolution principle • Example (cont.) • From these axioms, we should be able to conclude that E(a,b,d,c,d,b) is true, i.e. A1A2A3E(a,b,d,c,d,b) is a valid formula. • Since we want to prove this by refutation, we negate the conclusion and prove that A1A2A3E(a,b,d,c,d,b) is unsatisfiable.

  50. The resolution principle • Example (cont.) • The standard form of the formula: S={T(x,y,u,v)P(x,y,u,v), P(x,y,u,v)E(x,y,v,u,v,y), T(a,b,c,d),E(a,b,d,c,d,b)}. • The standard form S is a set of four clauses.

More Related