1 / 12

Automatic Reasoning: Resolution for Propositional and First-Order Logic

Learn about the resolution rule and its application in proving unsatisfiability and tautologies in propositional and first-order logic.

mreddick
Download Presentation

Automatic Reasoning: Resolution for Propositional and First-Order Logic

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. Section 9.1 Automatic Reasoning Recall that a wff W is valid iff ¬ W is unsatisfiable. Resolution is an inference rule used to prove unsatisfiability in a “mechanical” way. Resolution for Propositional Logic The resolution rule for propositions is shown to the right, where A and B are disjunctions of literals. Notation:A – p denotes A with all occurrences of p removed and B – ¬ p denotes B with all occurrences of ¬ p removed. Notation: We denote false by a box []. In applying resolution, we assume A B  B  A and A []  A. If A and B are false, then the rule is simplified as shown. To prove a wff is valid: negate the wff and convert it to CNF; write down the fundamental disjunctions as premises; use resolution to find a false statement. Example. Prove (pq)  (qr)  (pr) is a tautology. Solution. Negate the wff and transform it into CNF: (¬ pq)  (¬ qr) p ¬ r. Now write down the fundamental disjunctions as premises to start the proof. 1. ¬ pq P 2. ¬ qr P 3. p P 4. ¬ r P 5. q 1, 3, R 6. r 2, 5, R 7. []4, 6, R QED.

  2. Example/Quiz. Use resolution to prove that the following wff (an application of constructive dilemma) is a tautology. (AB)  (AC  D)  (BE  F)  (C  D)  (E  F). Solution. Negate the wff and transform the result into CNF. (AB)  (¬ AC ) (¬ AD)  (¬ BE) (¬ BF) (¬ C  ¬ D)  (¬ E  ¬ F). 1. AB P 2. ¬ AC P 3. ¬ AD P 4. ¬ BE P 5. ¬ BF P 6. ¬ C  ¬ D P 7. ¬ E  ¬ F P 8. ¬ A ¬ C 3, 6, R 9. ¬ B ¬ F 4, 7, R 10. ¬ B ¬ B 5, 9, R 11. ¬ A ¬ A 2, 8, R 12. B 1, 11, R 13. [] 10, 12, R QED. Question. Are there proofs that use less than 13 steps. Answer: Probably not since each of the 7 premises must be used. Why?

  3. Resolution for First-Order Logic Example (to Show the Idea). Suppose some proof contains the following two lines, where we assume that the wffs (called clauses) are universally closed. 1. p(a, x) q(x, y, a) P 2. ¬ p(x, b) r(x, y, b) P To apply resolution to the wffs on lines 1 and 2 several actions need to be taken: Change the names so the clauses have distinct variable names. In this case, we’ll keep line 1 as it is and change the names on line 2. 3. ¬ p(v, b) r(v, w, b) P Unify (i.e., match) p(a, x) on line 1 and p(v, b) on line 3 to get a substitution (i.e., a set of bindings) = {v/a, x/b}. Apply  to clauses on lines 1 and 3. p(a, b) q(b, y, a) ¬ p(a, b) r(a, w, b) Apply resolution to the transformed wffs. 4. q(b, y, a) r(a, w, b)1, 3, R, = {v/a, x/b} So we need to discuss three things for first-order resolution. The clausal form of wffs Unification of atoms The inference rule.

  4. Clausal Forms A clause is a disjunction of literals. (Recall a literal is an atom or its negation.) A clausalform is the universal closure of a conjunction of clauses. Notation. A clausal form is also represented as a set of its clauses. Example. The clausal form x y(p(x)  (q(x, y)  ¬ r(x))  (¬ p(x) s(y))) Is represented by the set {p(x), q(x, y)  ¬ r(x), ¬ p(x) s(y)}. Not every wff is equivalent to a clausal form. For example, the wff x p(x) is not equivalent to a clausal form. But we have the following result of Skolem, which is sufficient for resolution. Skolem’s Algorithm Every wff can be associated with a clausal form in which the two are either both satisfiable or both unsatisfiable. Construct the prenex CNF for the wff. Replace all occurrences of each free variable by a new constant. Eliminate the existential quantifiers by Skolem’s Rule: A. If x W(x) is not inside the scope of a universal quantifier, then replace x W(x) by W(c) for a new constant c. B. If x W(x) is inside the scope of x1 ...xn, then replace x W(x) by W(ƒ(x1, …, xn)) for a new function symbol ƒ.

  5. Quiz. Find a clausal form for each wff. 1. x A(x). 2. x y B(x, y). 3. x y z C(x, y, z). 4. x y z D(x, y, z). Answers. 1. A(c). 2. xB(x, ƒ(x)). 3. x yC(x, y, g(x, y)). 4. xD(x, ƒ(x), g(x)). Example/Quiz. Find a clausal form for the wff y xp(x, y)  z (q(x)  r(z)). Solution: Put the wff in prenex CNF. y xp(x, y)  z (q(w)  r(z)) (renamed)  ¬ y xp(x, y)  z (q(w)  r(z)) (removed )  y x ¬ p(x, y)  z (q(w)  r(z)) (moved ¬ inside)  y (x ¬ p(x, y)  z (q(w)  r(z))) (moved y outside)  y x z (¬ p(x, y) (q(w)  r(z))) (moved x and z outside)  y x z ((¬ p(x, y)  q(w))  (¬ p(x, y)  r(z))) (constructed CNF) (replace free variable w by constant c) y x z ((¬ p(x, y)  q(c))  (¬ p(x, y)  r(z))) Apply Skolem’s Rule to eliminate x and z. y ((¬ p(ƒ(y), y)  q(c))  (¬ p(ƒ(y), y)  r(g(y))). So there are two clauses in the clausal form, which can be denoted by the set {¬ p(ƒ(y), y)  q(c), ¬ p(ƒ(y), y)  r(g(y)}.

  6. Substitutions and Unification A binding of a variable x to a term t is denoted x/t and it means replace x by t. Applying a Binding to an Expression If x/t is a binding and E is an expression, then E(x/t) denotes the expression obtained from E by replacing all free occurrences of x with t. Examples. p(x, y, z)(x/y) = p(y, y, z) p(x, y, z)(y/ƒ(z)) = p(x, ƒ(z), z) A substitution is a finite set of bindings with distinct numerators. (Use lowercase greek letters for substitutions.) Example. q = {x/y, y/ƒ(z)} and s = {y/ƒ(a), z/b} are substitutions. Applying a Substitution to an Expression or a Set of Expressions If q is a substitution and E is an expression, then Eq denotes the expression obtained from E by simultaneously applying the bindings in q to E. Example. If q = {x/y, y/ƒ(z)}, then p(x, y, z)q = p(x, y, z){x/y, y/ƒ(z)} = p(y, ƒ(z), z). If S is a set of expressions, then Sq is the set of expresisons obtained from S by applying q to each expression of S. Example. If q = {x/y, y/ƒ(z)} and S = {p(x, y), q(y, g(z))}, then Sq = {p(x, y)q, q(y, g(z))q}= {p(y, ƒ(z)), q(ƒ(z), g(z))}.

  7. Composing Substitutions If q and s are two substitutions, then the compositionqs is applied to an expression E by E(qs) = (Eq)s. We can calculate qsby applying it to an atom that contains all the numerator variables of the two substitutions. Then collect the bindings that result from the application. Example. Let q = {x/y, y/ƒ(z)} and s = {y/ƒ(a), z/b}. Since the numerator variables are x, y, and z, we calculate p(x, y, z)(qs) = (p(x, y, z)q)s = p(y, ƒ(z), z))s = p(ƒ(a), ƒ(b), b). So qs = {x/ƒ(a),y/ƒ(b), z/b}. We can also calculate qs by the following procedure, where q = {xi/ti} and s = {yi/si}. Construct {xi/(tis)}. Delete any xi/xifrom Step 1. Delete yi/si from s if yi is a numerator of q. 4. qs is the union of the substitutions from Steps 2 and 3. Example. Let q = {x/y, y/ƒ(z)} and s = {y/ƒ(a), z/b}. Calculate qs. Step 1. Construct {x/ys, y/ƒ(z)s} = {x/ƒ(a), y/ƒ(b)}. Step 2. No deletions. So no changes from Step 1. Step 3. Delete y/ƒ(a) from s (because y is a numerator of q) to obtain {z/b}. Step 4. The union of sets from Steps 2 and 3 give qs = {x/ƒ(a), y/ƒ(b), z/b}. Properties of Composition q(sg) = (qs)g and qe =eq =q where e ={}.

  8. A unifier of a set S of expressions is a substitution q such that Sq is a singleton set. Example. {x/a} is a unifier of {p(x), p(a)} because {p(x), p(a)}{x/a} = {p(a)}. Example/Quiz. What are some unifiers of S = {p(x, a), p(y, z)}? Answer: Since a is a constant, any unifier must include the binding z/a. A unifier might also include x/y or y/x. So two unifiers of S are {x/y, z/a} and {y/x, z/a} because S{x/y, z/a} = {p(y, a)} and S{y/x, z/a} = {p(x, a)}. Notice also that {x/t, y/t, z/a} is a unifier of S for any term t because S{x/t, y/t, z/a} = {p(t, a)}. A most general unifier (mgu) of a set S of expressions is a unifier of q of S such that any other unifier s of S can be written as s =qa for some substitution a. Example. Let S = {p(x, a), p(y, z)} from the preceding example. The unifiers of S are {x/y, z/a} and {y/x, z/a} and {x/t, y/t, z/a} for any term t. The unifier {x/y, z/a} is an mgu for S because {y/x, z/a} = {x/y, z/a}{y/x} and {x/t, y/t, z/a} = {x/y, z/a}{y/t}. Quiz. Continue the example and show that, {y/x, z/a} is an mgu of S. Proof: {x/y, z/a} = {y/x, z/a}{x/y} and {x/t, y/t, z/a} = {y/x, z/a}{x/t}. QED. Quiz. Continue the example and show for a constant c that {x/c, y/c, z/a} is not an mgu of S. Proof: Assume, BWOC, that {x/c, y/c, z/a} is an mgu. Then {x/y, z/a} = {x/c, y/c, z/a}a for some substitution a. But {x/c, y/c, z/a}a contains the subset {x/c, y/c, z/a}, so it can’t equal {x/y, z/a}. This contradiction tells us that {x/c, y/c, z/a} is not an mgu. QED.

  9. Unification Algorithms Robinson: For a finite set S of atoms find whether S has an mgu. 1. k := 0; q0:= e; go to Step 2. 2. If Sqk is a singleton then stop with mgu qk Otherwise construct Dk (set of terms in leftmost position of disagreement); go to Step 3. 3. If Dk has a variable v and a term t such that v does not occur in t then qk+1 := qk{v/t}; k := k + 1; go to Step 2. Otherwise stop (S is not unifiable). Example. Trace the algorithm for S = {p(x, h(x, g(y)), y), p(x, h(a, z), b)}. 1. k := 0; q0:= e. 2. Sq0 = Se = {p(x, h(x, g(y)), y), p(x, h(a, z), b)} is not a singleton; D0 = {x, a}. 3. q1 := q0{x/a} = {x/a}; k := 1. 2. Sq1 = {p(a, h(a, g(y)), y), p(a, h(a, z), b)} is not a singleton; D1 = {g(y), z}. 3. q2 := q1{z/g(y)} = {x/a, z/g(y)}; k := 2. 2. Sq2 = {p(a, h(a, g(y)), y), p(a, h(a, g(y)), b)} is not a singleton; D2 = {y, b}. 3. q3 := q2{y/b} = {x/a, z/g(b), y/b}; k := 3. 2. Sq3 = {p(a, h(a, g(b)), b)} is a singleton; stop with mgu q3 = {x/a, z/g(b), y/b}. Quiz. Apply the algorithm to S = {p(x), p(ƒ(x))}. Answer. S is not unifiable because in the set D0 = {x, ƒ(x))} xoccurs in ƒ(x).

  10. Martelli-Montanari: To see whether two atoms A and B have an mgu, form the set {A = B} and apply the following rules repeatedly in any order. (ƒ and g are either function or predicate symbols.) 1.Replaceƒ(s1, …, sn) = ƒ(t1, …, tn)with equations s1 = t1, …, sn = tn. 2. If ƒ(s1, …, sn) = g(t1, …, tm)with ƒ ≠ g or m ≠ n, then stop with failure. 3. Delete x = x. 4. Replace t = x, where t is not a variable, with x = t. 5. If x = t and x does not occur in t, apply {x/t} to the other equations that contain x. 6. If x = t and t is not a variable and x occurs in t, then stop with failure. If there is no failure and the rules cannot be applied, then transform {xi = ti} to mgu {xi/ti}. Example. Trace the algorithm for A = p(x, h(x, g(y)), y) and B = p(x, h(a, z), b). {p(x, h(x, g(y)), y) = p(x, h(a, z), b)} ({A = B}) {x = x, h(x, g(y)) = h(a, z), y = b} (Rule 1) {h(x, g(y)) = h(a, z), y = b} (Rule 3) {x = a, g(y) = z, y = b} (Rule 1) {x = a, z = g(y), y = b} (Rule 4) {x = a, z = g(b), y = b} (Rule 5) Done. The mgu is {x/a, z/g(b), y/b}. Quiz. Apply the algorithm to the two atoms p(x, x) and p(y, ƒ(y)). Solution: {p(x, x) = p(y, ƒ(y))} and Rule 1 gives {x = y, x = ƒ(y)}. Apply Rule 5 to get {x = y, y = ƒ(y)}. Apply Rule 6 to get failure.

  11. Resolution Rule (R) Given the following two clauses. L1 … Lk  C and ¬ M1 …  ¬ Mn  D, where Li and Mi are atoms and C and D are disjunctions of other literals. Assume also that 1. The clauses have distinct sets of variable names (rename if necessary). 2. q is the mgu of {L1, …, Lk, M1, …, Mn}. 3. N = L1q, where {L1, …, Lk, M1, …, Mn}q = {N}. Then we have: Example. Given the two clauses in the following proof segment k. p(a, y)p(a, z)q(x, y, z)P k + 1. ¬ p(w, ƒ(b))r(w, v, g(w))  ¬ p(a, ƒ(b)) P These two clauses have the form L1L2 C and¬ M1 D. The two clauses have distinct sets of variables. The set of atoms {p(a, y), p(a, z), p(w, ƒ(b))} has mgu q = {w/a, y/ƒ(b), z/ƒ(b)}. Notice that {p(a, y), p(a, z), p(w, ƒ(b))}q = {p(a, ƒ(b))}. So the resolution rule can be applied to the two clauses to obtain the resolvant: k + 2. q(x, ƒ(b), ƒ(b)) r(a, v, g(a))k, k + 1, R, {w/a, y/ƒ(b), z/ƒ(b)}.

  12. To prove a wff is valid: negate the wff and convert it to clausal form; write down the clauses as premises; use resolution to find a false statement. Example/Quiz. Use resolution to prove the following wff is valid. x (y p(x, y)  z q(x, z) y (p(x, y) q(x, y))). Solution: Negate the wff: ¬ x (y p(x, y)  z q(x, z) y (p(x, y) q(x, y))). Convert it to clausal form: ¬ x (y p(x, y)  z q(x, z) w (p(x, w) q(x, w))) (renamed variables) x ((y p(x, y)  z q(x, z)) w (¬ p(x, w)  ¬ q(x, w))) (removed  and moved ¬ right) xw ((y p(x, y)  z q(x, z)) ¬ p(x, w)  ¬ q(x, w)) (moved w left) xw y z ((p(x, y)  q(x, z)) ¬ p(x, w)  ¬ q(x, w)) (moved y andz left) xy z ((p(x, y)  q(x, z)) ¬ p(x, ƒ(x))  ¬ q(x, ƒ(x))) (removed w by Skolem) So the set of clauses is {p(x, y)  q(x, z), ¬ p(x, ƒ(x)), ¬ q(x, ƒ(x)))}. Now do a resolution proof by making each the three clauses a premise (rename to get distinct variable names). 1. p(x, y)  q(x, z) P 2. ¬ p(u, ƒ(u)) P 3. ¬ q(w, ƒ(w)) P 4. q(u, z) 1, 2, R, {x/u, y/ƒ(u)} 5. [] 3, 4, R, {w/u, z/ ƒ(u)} QED.

More Related