lesson 9 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Lesson 9 PowerPoint Presentation

Lesson 9

162 Views Download Presentation
Download Presentation

Lesson 9

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Lesson 9 Resolution method (continuing, examples)

  2. Verifying an argument: (Anybody) who knows Paul and Mary is sorry for Mary. x ( [Z(x, P)  Z(x, M)]  L(x, M) ) Some are not sorry for Mary, though they know her. x [L(x, M)  Z(x, M)] ––––––––––––––––––––––––––––––– Somebody knows Mary, but does not know Paul. x [Z(x, M) Z(x, P)] • x [Z(x, P) Z(x, M)  L(x, M)] implication elimination (1. assumption) • L(a, M)  Z(a, M) „Scolemising“ (2. assumption) • y [Z(y, M)  Z(y, P)] negation of conclusion (and renaming x) Clauses: 1. Z(x, P) Z(x, M)  L(x, M) 2. L(a, M) (2. assumption is a conjunction: 3. Z(a, M) two clauses arise!) 4. Z(y, M)  Z(y, P) 5. Z(a, P) Z(a, M) resolution 1., 2., substitutiona/x 6. Z(a, P) resolution 3., 5. 7. Z(a, M) resolution 4., 6., substitution a/y 8. resolution 3., 7. • We obtained an empty clause, i.e., the negated conclusion contradicts the premises; thus the non-negated original conclusion logically follows from the premises. • The argument is valid.

  3. Remark: Compare the proof of this argument with the semantic proof (lesson 6, slides 22, 23) • We demonstrate the truth-conditions of the premises first; the predicates Z and L are interpreted as the relations ZU and LU, respectively: • ZU = {…, i1,m,  i1,k, i2,m, i2,k,…,,m,… } 1. premise 2. premise • LU = {…, i1,m, ...., i2,m,…........., ,m,… } and so on, by the method of an indirect proof

  4. Indirect proof of the validity of an argument • We make use of the following equivalence valid for closedformulas: P1,...,Pn |= Z iff |= (P1... Pn)  Z • Moreover |= (P1... Pn)  Z iff the negated formula is a contradiction: (P1... PnZ) • Hence, the argument is valid iff the negated conclusion Z contradicts the conjunction of premises. Indeed, compare with the definition of the validity of an argument: • P1,...,Pn |= Z iff Z is true in every model of the set of premises P1,...,Pn iff • Z is true in no model of the set of premises.

  5. Proofs of the validity: • Prove, that the following statement • „If there is a philosopher who disagrees with all the philosophers, then he disagrees with himself as well“ • is logically true. • We analyse this sentence in following way:(”intended” interpretation is over the set of individuals, P  subset of philosophers, Q  relation: the couples of individuals where the first member disagrees with the second) • We prove the logical validity of the formula: • x {[P(x) y (P(y)  Q(x,y))]  Q(x,x)} • First, negate the formula and transform it into clausul form: • xy {P(x)  [P(y)  Q(x,y)] Q(x,x)}. • The set of clauses:1. P(x) 2. P(y)  Q(x,y)3. Q(x,x) the substitution {y/x} is the most general unifier: 4. Q(x,x) resolution 1. and 2.5. resolution 3. and 4.

  6. Proofs of the validity: • Prove the logical validity of following statement: • „There is somebody such that if he\sheisa genius, then everybody is a genius“. • Formula: x[G(x) x G(x)](mind the brackets!) • We prove, that the negated formulais a contradiction: • x [G(x)x G(x)], renaming variables gives: • x [G(x)y G(y)], step 6: [x G(x)y G(y)]and by Scolemizing we have: • x [G(x) G(a)]. • G(x) • G(a) • resolution 1. and 2., substitution a/x We obtained an empty clause,i.e., the negated formula is a contradiction;so the original formula is a tautology.

  7. Every member of the management is an obligation owner or a shareholder. • No member of the management is an obligation owner and also a shareholder. • Every obligation owner is a member of the management. –––––––––––––––––––––––––––––––––––––––––––––––– 4. No obligation owner is a shareholder. • x[V(x)  (O(x)  A(x))] • x [V(x) (O(x)  A(x))] • x [O(x)  V(x)] • ––––––––––––––––––––– • x [O(x) A(x)] Clauses: 1. V(x) O(x) A(x) 1. premise 2. V(y) O(y) A(y) 2. premise 3. O(z) V(z) 3. premise 4. O(k) negated conclusion 5. A(k) (after Scolemization) 6. O(y) A(y) resolution 2., 3., substitution z/y 7. A(k) resolution 4., 6., substitutiony/k 8. resolution 5., 7. Notethat we do not use the first clause in the proof sequence. So conclusion is a consequent of the second and the third premise (the first one is superfluous for inferingthe conclusion).

  8. Everybody who likes George will collaborate with Michael. Michael is a friend of nobody who is a friend of Luke. Peter will collaborate only with the friends of Charles. –––––––––––––––––––––––––––––––––––––––––––––– If Charles is a friend of Luke, then Peter does not like George. • x[L(x, G)  C(x, M)] • x [F(x, L) F(M, x)] • x [C(P, x) F(x, Cr) • –––––––––––––––––––– • F(Cr, L) L(P, G) Clauses: 1. L(x, G)  C(x, M) 1. premise 2. F(y, L) F(M, y) 2. premise 3. C(P, z) F(z, Cr) 3. premise 4. F(Cr, L) negated 5. L(P, G) conclusion 6. F(M, Cr) resolution 4., 2., substitution y/Cr 7. C(P, M) resolution 3., 6., substitution z/M 8. L(P, G) resolution 1., 7., substitution x/P 9. resolution 5., 8.

  9. What are the logical consequences of premises? Variant of the preceding example. Premises do not contain existential statement. Everybody who likes George will collaborate with Michael. Michael is a friend of nobody who is a friend of Luke. Peter will collaborate only with the friends of Charles. Charles is a friend of Luke. –––––––––––––––––––––––––––––––––––––––––––––– ??? Clauses: 1. L(x, G)  C(x, M) 1. premise 2. F(y, L) F(M, y) 2. premise 3. C(P, z) F(z, Cr) 3. premise 4. F(Cr, L) 4. premise 5. F(M, Cr)inference, resolution 2,4, y/Cr 6. L(P, G) F(M, Cr) inference, resolution 1,3, x/P, z/M 7. L(P, G)inference, resolution 5,6 8. C(P, M)inference, resolution 3,5, z/M

  10. Indirect proof of the validity of an argument All men like football and beer. Xaver likes only those who like football and beer. There is somebody who likes football but does not like beer. Anybody who is not a man is a woman.(we must not omit tacit premises) ––––––––––––––––––––––––––––––––––––– Some women are not liked by Xaver. x[M(x)  (R(x,f)  R(x,p))] 1. premise x[R(Xa,x)  (R(x,f)  R(x,p))] 2. premise x [R(x,f) R(x,p)] 3. premise x [M(x)  Z(x)] 4. premise  x [Z(x) R(Xa,x)] negated conclusion

  11. Indirect proof of the argument Clauses: 1. M(x)  R(x,f) first 2. M(x)  R(x,p) premise 3. R(Xa,y)  R(y,f) second 4. R(Xa,y)  R(y,p) premise 5. R(k,f) third premise 6. R(k,p) after Scolemization: x/k 7. M(z)  Z(z) 4. premise 8. Z(u)  R(Xa,u) negated conclusion ––––––––––––––––––– 9. R(Xa,k) resolution 4., 6. (y/k) 10. Z(k) resolution 8., 9. (u/k) 11. M(k) resolution 7., 10. (z/k) 12. R(k,p) resolution 2., 11. (x/k) 13. resolution 6., 12. We have found out again that the negated conclusion contradictsthe premises, so that the argument is valid. Do you knowwhich premiseswere not necessary for inferring the conclusion?

  12. Proof by the resolution method If a number is even then its second power is even . |= If a number is even then its fourth power is even . y[P(y) Pf(y)] |=x [P(x) P(f(f(x)))] – negate it: x [P(x) P(f(f(x)))] – Scolemise: [P(a) P(f(f(a)))] – write down the clauses: • P(y) Pf(y) premise • P(a) negated • P(f(f(a))) conclusion • P(f(a)) resolution 1-2, substitutiony/a • P(f(f(a))) resolution 1-4, substitutiony/f(a) • resolution3-5, contradiction The argument is valid.

  13. Mathematical induction P(a),y [P(y)  Pf(y)] |x P(x) Is the derived formula a logicall consequence of the premises? In other words, is the mathematical-induction rule correct, i.e., does it preserve truth? Clauses: • P(a) • P(y)  P(f(y)) • P(f(a)) inference 2.1., subst. y/a • P(f(f(a))) inference 2.3., subst. y/f(a) • P(f(f(f(a)))) inference 2.4., subst. y/f(f(a)) • and so on, ad infinitum. We cannot prove it by the indirect proof as well, because the negated conclusion is (after scolemising): P(b) and the terms b, a, f(a), f(f(a)),… are not unifiable. We never prove that x P(x) – the case of the actual infinity. We can only reach the potential infinity… potentially we can go ad infinitum; but not really.

  14. Verifying the consistence • There is a barber who shaves just all those who do not shave themselves. • Does this barber shave himself? x y[H(y,y)H(x,y)]|=? H(x,x) • In Lesson 7 we have seen that the premise is a contradiction; so such a barber does not exist. We prove it by the resolution method. We add the negated conclusion to the premise and write down the clauses. x y[H(y,y)H(x,y)]|=? H(x,x) • H(y,y)  H(a,y) H(a,a) substitution y/a • H(y,y) H(a,y) H(a,a) substitution y/a • H(x,x) • resolution 1., 2., substitution y/a We don´t need the third clause (negated conclusion) in order to infer the contradiction.So the premise is contradictory. Such a barber does not exist.

  15. Note: • Robinson‘s algorithm of the general resolution and unification operates also on particular literals of a clause. For instance, from the clauses 1. P(x,y) Q(a,f(y))  P(x,a)  Q(y,x)  P(f(a),a) Q(a,f(a)) 2. P(f(z),z) P(v,a) P(f(a),a) we derive the resolventQ(a,f(a)), after the unificationx/f(a), y/a, z/a, v/f(a), because the first clause is unified intoP(f(a),a) Q(a,f(a)) and the second intoP(f(a),a).

  16. Note: Pay attention to equivalences • Formula A  B is not contradictory, it is satisfiable • Formula A  A is contradictory Clauses ad a) • A  B • A  B nowin each step we can generate the resolvent by the resolution of onlyone pair ofliterals, so no empty clause is derived: 3. B  B 4. A  A Clauses ad b) • A  A  A • A  A  A • 1. and 2. resolve into the empty clause

  17. Checking the consistence • Mr X changed his job and got a more qualified one (K). • Mr X knows the wage-payment system very well (M). • If Mr X changed his job for the more qualified one, then it is right to discuss his case (P). • If is it right to discuss his case, then he should not be a member of the commission (C). • If he knows the wage-payment system very well, then he should be a member of the commission. What are the logical consequences? We checkthe consistence of the set of statements first. K  M  (K  P)  (P  C)  (M  C) • K • M • K  P • P  C • M  C • P resolution 1, 3 • C resolution 4, 6 • C resolution 2, 5 • contradiction resolution 7, 8 The given set of statements is contradictory; so anything follows.

  18. Checking the validness of a formula |=? x [P(x) yx (Q(x,y) z R(a,x,y))] z [(P(b)  Q(f(z), z))  R(a, f(b), z)] We transform the antecedent to the clause form : • By the method of Skolem algorithm • We transform it to the prenex form at first and then we scolemise it.

  19. Checking the validness of a formula vs step 6 Antecedent –transformation to the clause form, procedure a) x [P(x) yx (Q(x,y) z R(a,x,y))] Steps 2., 5. Renaming variable x and eliminatingz: x [P(x) yu (Q(u,y)  R(a,u,y))] Step 3. Elimination of the implication: x[P(x) yu (Q(u,y)  R(a,u,y))] Step 6. Moving the quantifier x to the left: x P(x) yu (Q(u,y)  R(a,u,y)) Step 7. Skolemization (i.e., substitutingg(y) for the varible u:the symbol f is used in the conclusion, so we have to use a new one): x P(x) y (Q(g(y), y)  R(a, g(y), y)) Step 8. moving the quantifier to the left: SK1: xy[P(x)  (Q(g(y), y)  R(a, g(y), y))].

  20. Checking the validness of a formula vs step 6 Antecedent – transformation to the clause form, procedure b) without step 6 x [P(x) yx (Q(x,y) z R(a,x,y))] Steps 2,5: Renaming variable x and eliminatingz: x [P(x) yu (Q(u,y)  R(a,u,y))] Step 3. Elimination of the implication: x[P(x) yu (Q(u,y)  R(a,u,y))] Step 7. Skolemization (i.e., substitutingg(x,y), for the varible u, because the variable u is at the scope ofx): x[P(x) y (Q(g(x,y), y)  R(a, g(x,y), y)) Step 8. removing the quantifier to the left: SK2: xy[P(x)  (Q(g(x,y), y)  R(a, g(x,y), y))].

  21. Checking the validness of a formula vs step 6 The negated conclusion (is in the clausal form already): z [(P(b) Q(f(z), z)) R(a, f(b), z)]. We attempt to prove a contradiction with SK1 (clausal form of the antecedent) We write the clauses down, procedure a): • P(x) premise • Q(g(y), y)  R(a, g(y), y) premise • P(b) Q(f(z), z) negated conclusion • R(a, f(b), z) negated conclusion • Q(f(z), z) resolution 1., 3., substitution x / b • ??? We cannot derive any more resolvents, because terms g(y) a f(z), or g(y) and f(b) are not unifiable. The Formula is not a tautology.

  22. Checking the validness of a formula vs step 6 We are not able to prove the contradiction with SK2 (procedure b) with the negated conclusion either : • P(x) • Q(g(x,y), y)  R(a, g(x,y), y) • P(b) Q(f(z), z) • R(a, f(b), z) • Q(f(z), z) resolution 1., 3., substitution x / b However, we can‘t procede further, because the terms g(x,y) and f(z), possibly g(x,y) and f(b), are not unifiable. Conclusion: The Formulais not a tautology.

  23. Exercise, a puzzle • Tom, Peter and John are members of a sport club. Every member of the club is a skier or a climber. No climber likes raining. All skiers like snow. Peter does not like what Tom likes, and does like what Tom does not like. Tom likes snow and raining. • Question: Is there in the club a sportsman who is a climber but not a skier? • Solution:Knowledge base (+ query 11): • SC(t) • SC(p) • SC(j) • x [ SC(x)  (SKI(x)  CLIMB(x)) ] • x [ CLIMB(x) LIKE(x,r) ] • x [ SKI(x)  LIKE(x,s)] • x [LIKE(t,x) LIKE(p,x)] • x [LIKE(t,x)  LIKE(p,x)] • LIKE(t,s) • LIKE(t,r) • ? x [SC(x)  CLIMB(x) SKI(x)]

  24. Exercise, a puzzle Knowledge base (in Clausal form + negated query 11): • SC(t) sport-club(tom). • SC(p) sport-club(peter). • SC(j) sport-club(john). • SC(y)  SKI(y)  CLIMB(y) each club member is a skier or a climber • CLIMB(z) LIKE(z,r) each climber does not like raining • SKI(v)  LIKE(v,s) each skier does not like snowing • LIKE(t,x1) LIKE(p,x1) Tom and Peter have opposite • LIKE(t,x2)  LIKE(p,x2) tastes • LIKE(t,s) like(tom, snow). • LIKE(t,r) like(tom, raining). • SC(x) CLIMB(x)  SKI(x) Query Proof by resolution that 1-11 is inconsistent. In other words, we are looking for an instantiation of the variable x, that leads to a contradiction. • LIKE(p,s) res.: 9, 7 by substituting s for x1 • SKI(p) res.: 12, 6 by substituting p for v • SC(p)  CLIMB(p) res.: 13, 4 by substituting p for y • CLIMB(p) res.: 14, 2 • Resolution 11 + 2 + 13 + 15 by substituting p for x. (Obviously, the solution is p = Peter)

  25. Checking the validness of an argument Situation: A couple of friends met a priest A, who said: „The first man whom I confessed was a murder“. After a while Mr B came, looked at the priest and said: „I was the first man whom the priest A confessed“. Question: Did the priest offend against the confessional secrecy? Řešení: x [(x = f(A))  V(x)] B = f(A) ??? (Intended interpretation: Let f be a function that assigns to the priest the only man confessed by the priest as the first one) Clauses: 1. (x = f(A))  M(x) 1. premise 2. B = f(A) 2. premise 3. M(B) inference: resolution (B is a murder) 1.,2., substitution x/B Solution: The priest offended against the confessional secrecy.

  26. Prolog foundations (the logic) • Method of („pure“) logic programming is a special case of the general resolution method. Compared to the general resolution method, it has the following restrictions: • it works just with Horn‘s clauses (they have one positive literal at most), • it uses thelinear strategy of generating resolventstogether with the process of „backtracking“

  27. Prolog foundations (the logic) • In logic programming we use the following terminology: • Notation: P:- Q1, Q2,..,Qn.(is equivalent to: Q1 Q2 …  Qn P, or to (Q1 Q2 …  Qn) P ) conditional statement (rule) • Notation P. unconditional statement (fact) • Notation?- Q1, Q2,..,Qn.(is equivalent to: Q1 Q2 …  Qn)targets /target clauses, queries/ • Notation, YES: contradiction /an emptyclause/

  28. Prolog foundations (the logic) • Logic program is a sequence of conditionalstatements(rules) and unconditional statements(facts). Target clause set queries that the program tries to reply. • Note: Commands are understood as being declared by stating the rules and facts. So logic programs aredeclarative(not imperative). We only specify ”whatis to be done” and do not determine ”in which way to do it”.

  29. Prolog foundations (the logic) Example: • All students are younger than Peter‘s mother. Charles and Mary are students. Who is younger than Peter‘s mother? • Notation in PL1: x [St(x)  Mlx,matka(p)], St(k), St(m) |= ? • Program in Prolog (Notice: variables - capitals, constants - small letters): younger(X,mother(peter)):- student(X). rule student(charles). fact student(mary). fact ?- younger(Y, mother(peter)).Query, target goal The interpreter performs unification and resolution following the linear strategy driven by target: • Target ?- younger(Y, mother(peter)) is unificated with younger (X,mother(peter)), Y=X; • New target is generated: ?- student(Y) • This target is unificated with the 2. fact in the database: success with Y=charles • It‘ll figure out the reply YES, Y = charles ; We can enter semicolon ‘;’ which means that we are asking„Who next?“. It envokesbacktracking,i.e., the process of returningto the last target and attempting to execute it again: ?- student(Y).Now the interpreter cannot use the 2. clause again (it remembers the place that has been used already) but it can use 3. clause: e) It‘ll figure out the reply YES, Y = Mary ; NO

  30. Prolog foundations (the logic) As stated above, logic programs aredeclarative (not imperative). We specify ”whatis to be done” and do not determine ”in which wayit is to be done”. The interpreter findsthe way how to reply the queries, i.e., it deduces which are the logical consequences of the specified knowledge base and which values have to be substitutiated for variablesby unification (answers). However,the restriction to Horn clauses can cause troubles. See the example of a puzzle (slides 19, 20) Try to formulate this puzzle in Prolog! Summary of the restrictions: • one positive literal at most (no disjunction in the consequent), • we are not able to specify negative facts directly. Negation as failure of inferring!