Download presentation
Presentation is loading. Please wait.
Published byMyron Williams Modified over 9 years ago
1
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. 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.pP 4.¬ rP 5.q1, 3, R 6.r2, 5, R 7. [] 4, 6, R QED. 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.
2
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 ¬ FP 8.¬ A ¬ C3, 6, R 9.¬ B ¬ F4, 7, R 10.¬ B ¬ B5, 9, R 11.¬ A ¬ A2, 8, R 12.B1, 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
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
4 Clausal Forms A clause is a disjunction of literals. (Recall a literal is an atom or its negation.) A clausal form 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. 1. Construct the prenex CNF for the wff. 2. Replace all occurrences of each free variable by a new constant. 3. 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 x 1... x n, then replace x W(x) by W(ƒ(x 1, …, x n )) for a new function symbol ƒ.
5
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. x B(x, ƒ(x)). 3. x y C(x, y, g(x, y)). 4. x D(x, ƒ(x), g(x)). Example/Quiz. Find a clausal form for the wff y x p(x, y) z (q(x) r(z)). Solution: Put the wff in prenex CNF. y x p(x, y) z (q(w) r(z))(renamed) ¬ y x p(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
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. = {x/y, y/ƒ(z)} and = {y/ƒ(a), z/b} are substitutions. Applying a Substitution to an Expression or a Set of Expressions If is a substitution and E is an expression, then E denotes the expression obtained from E by simultaneously applying the bindings in to E. Example. If = {x/y, y/ƒ(z)}, then p(x, y, z) = p(x, y, z){x/y, y/ƒ(z)} = p(y, ƒ(z), z). If S is a set of expressions, then S is the set of expresisons obtained from S by applying to each expression of S. Example. If = {x/y, y/ƒ(z)} and S = {p(x, y), q(y, g(z))}, then S = {p(x, y) , q(y, g(z)) }= {p(y, ƒ(z)), q(ƒ(z), g(z))}.
7
7 Composing Substitutions If and are two substitutions, then the composition is applied to an expression E by E( ) = (E ) . We can calculate by 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 = {x/y, y/ƒ(z)} and = {y/ƒ(a), z/b}. Since the numerator variables are x, y, and z, we calculate p(x, y, z)( ) = (p(x, y, z) ) = p(y, ƒ(z), z)) = p(ƒ(a), ƒ(b), b). So = {x/ƒ(a), y/ƒ(b), z/b}. We can also calculate by the following procedure, where = {x i /t i } and = {y i /s i }. 1. Construct {x i /(t i }. 2. Delete any x i /x i from Step 1. 3. Delete y i /s i from if y i is a numerator of . is the union of the substitutions from Steps 2 and 3. Example. Let = {x/y, y/ƒ(z)} and = {y/ƒ(a), z/b}. Calculate . Step 1. Construct {x/y , y/ƒ(z) } = {x/ƒ(a), y/ƒ(b)}. Step 2. No deletions. So no changes from Step 1. Step 3. Delete y/ƒ(a) from (because y is a numerator of ) to obtain {z/b}. Step 4. The union of sets from Steps 2 and 3 give = {x/ƒ(a), y/ƒ(b), z/b}. Properties of Composition = and = = where = {}.
8
8 A unifier of a set S of expressions is a substitution such that S 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 of S such that any other unifier of S can be written as = for some substitution . 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} for some substitution . But {x/c, y/c, z/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
9 Unification Algorithms Robinson: For a finite set S of atoms find whether S has an mgu. 1. k := 0; 0 := ; go to Step 2. 2. If S k is a singleton then stop with mgu k Otherwise construct D k (set of terms in leftmost position of disagreement); go to Step 3. 3. If D k has a variable v and a term t such that v does not occur in t then k+1 := k {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; 0 := . 2. S 0 = S = {p(x, h(x, g(y)), y), p(x, h(a, z), b)} is not a singleton; D 0 = {x, a}. 3. 1 := 0 {x/a} = {x/a}; k := 1. 2. S 1 = {p(a, h(a, g(y)), y), p(a, h(a, z), b)} is not a singleton; D 1 = {g(y), z}. 3. 2 := 1 {z/g(y)} = {x/a, z/g(y)}; k := 2. 2. S 2 = {p(a, h(a, g(y)), y), p(a, h(a, g(y)), b)} is not a singleton; D 2 = {y, b}. 3. 3 := 2 {y/b} = {x/a, z/g(b), y/b}; k := 3. 2. S 3 = {p(a, h(a, g(b)), b)} is a singleton; stop with mgu 3 = {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 D 0 = {x, ƒ(x))} x occurs in ƒ(x).
10
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 ƒ(s 1, …, s n ) = ƒ(t 1, …, t n ) with equations s 1 = t 1, …, s n = t n. 2. If ƒ(s 1, …, s n ) = g(t 1, …, t m ) 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 {x i = t i } to mgu {x i /t i }. 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
11 Resolution Rule (R) Given the following two clauses. L 1 … L k C and ¬ M 1 … ¬ M n D, where L i and M i 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. is the mgu of {L 1, …, L k, M 1, …, M n }. 3. N = L 1 , where {L 1, …, L k, M 1, …, M n } = {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 L 1 L 2 C and ¬ M 1 D. The two clauses have distinct sets of variables. The set of atoms {p(a, y), p(a, z), p(w, ƒ(b))} has mgu = {w/a, y/ƒ(b), z/ƒ(b)}. Notice that {p(a, y), p(a, z), p(w, ƒ(b))} = {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
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.