Download presentation
Presentation is loading. Please wait.
1
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University pursuant to Part VB of the Copyright Act 1968 (the Act). The material in this communication may be subject to copyright under the Act. Any further reproduction or communication of this material by you may be the subject of copyright protection under the Act. Do not remove this notice.
2
Resolution for Predicate Logic CSE2303 Formal Methods I Lecture 23
3
Overview Program Clauses Resolution for Program Clauses Well Formed Formulae (WFF) Converting WFF to Clauses Resolution for Predicate Logic
4
Program Clauses Facts A. {{A}} Rules A:- B 1,…,B n {{A, ¬B 1,…, ¬B n }} Queries –Like conclusions. –So we negate them.
5
Database parent(bob, ann). parent(bob, pat). parent(pat, jim). {{parent(bob, ann)}} {{parent(bob, pat)}} {{parent(pat, jim)}}
6
?- parent(bob, pat). Negate the query: {{¬parent(bob, pat)}} {parent(bob, pat)} {¬parent(bob, pat)}
7
?- parent(X, ann). Negate the query: {{¬parent(X, ann)}} {¬parent(bob, ann)} {¬parent(X, ann)} X/bob {parent(bob, ann)}
8
Socrates mortal(X) :- man(X). man(socrates). ?- mortal(socrates). {{mortal(X), ¬man(X)}} {{man(socrates)}} {{¬mortal(socrates)}} All men are mortal Socrates is a man. Therefore Socrates is mortal.
9
?- mortal(socrates). {mortal(socrates), ¬man(socrates)} X/socrates {mortal(X), ¬man(X)} {man(socrates)} {mortal(socrates)} {¬mortal(socrates)}
10
Natural Numbers If s(X) = X + 1 then all the natural numbers can be represented as 0, s(0), s(s(0)), s(s(s(0))),...
11
Addition For every X, Y, Z: X + 0 = X X + Y = Z X + s(Y) = s(Z)
12
Addition add(X, 0, X). {{add(X, 0, X)}} add(X, s(Y), s(Z)) :- add(X, Y, Z). {{¬add(X, Y, Z), add(X, s(Y), s(Z))}} ?- add(s(0), s(0), X). {{¬add(s(0), s(0), X)}}
13
? - add(s(0), s(0), X). {¬add(s(0), 0, Z)} {¬add(s(0), s(0), X)} {¬add(s(0), s(0), s(Z))} X /s(Z) {¬add(X, Y, Z), add(X, s(Y), s(Z))} {¬add(s(0), 0, Z), add(s(0), s(0), s(Z))} X/s(0), Y/0 {¬add(s(0), 0, s(0))} Z/s(0) {add(X, 0, X)} {add(s(0), 0, s(0) )} X/s(0)
14
Definitions A quantified sentence is called a well-formed formula (WFF) if every variable is quantified before being used. E.g. X Y (P(X,Y) Z Q(X, Z)) (WFF) X Q(Y) (not a WFF) X (P(X, Y) Y Q(X, Y)) (not a WFF)
15
Converting WFF into Clauses Eliminate and Move ¬ in as far as possible. Eliminate (Skolemize) Eliminate Put into clausal form
16
Moving ¬ ¬ X P(X) is logically equivalent to X ¬P(X) ¬ X P(X) is logically equivalent to X ¬P(X)
17
Love Example There is a girl who is loved by every boy. X (girl(X) Y(boy(Y) loves(Y,X))) Therefore every boy loves some girl. Negating this we obtain. ¬ Y(boy(Y) X (girl(X) loves(Y,X)))
18
X (girl(X) Y(boy(Y) loves(Y,X))) Eliminate X (girl(X) Y(¬boy(Y) loves(Y,X))) Eliminate girl(c) Y(¬boy(Y) loves(Y,c)) Eliminate girl(c) (¬boy(Y) loves(Y,c)) Put into clausal form {{girl(c)}, {¬boy(Y), loves(Y,c)}}
19
¬ Y(boy(Y) X (girl(X) loves(Y,X))) Eliminate ¬ Y(¬boy(Y) X (girl(X) loves(Y, X))) Move ¬ in as far as possible. Y(boy(Y) X (¬girl(X) ¬loves(Y, X))) Eliminate boy(b) X (¬girl(X) ¬loves(b, X))) Eliminate boy(b) (¬girl(X) ¬loves(b, X)) Put into clausal form {{boy(b)}, {¬girl(X), ¬loves(b, X)}}
20
Love Example There is a girl who is loved by every boy. {{girl(c)}, {¬boy(Y), loves(Y,c)}} Therefore every boy loves some girl. {{boy(b)}, {¬girl(X), ¬loves(b, X)}}
21
Proof {girl(c)} {¬loves(b,c)} {¬girl(X), ¬loves(b,X)} {¬girl(c), ¬loves(b,c)} X/c {¬boy(Y), loves(Y,c)} {¬boy(b), loves(b,c)} Y/b {boy(b)} {loves(b,c)}
22
Curiosity Example Jack owns a dog Every dog owner is an animal lover. No animal lover kills an animal. Either Jack or Curiosity killed the cat. The cat’s name is Tuna.
23
Jack owns a dog X (dog(X) owns(jack, X)) Every dog owner is an animal lover. X (( Y (dog(Y) owns(X,Y))) animalLover(X)) No animal lover kills an animal. X, Y ((animalLover(X) animal(Y)) ¬kills(X,Y)) Either Jack or Curiosity killed the cat. kills(jack, tuna) kills(curiosity, tuna) The cat’s name is Tuna. cat(tuna) All cats are animals. X cat(X) animal(X) Formulae
24
Jack owns a dog {{dog(d)}, {owns(jack, d)}} Every dog owner is an animal lover. {{¬dog(Y), ¬owns(X, Y), animalLover(X)}} No animal lover kills an animal. {{¬animalLover(X), ¬animal(Y), ¬kills(X,Y)}} Either Jack or Curiosity killed the cat. {{kills(jack, tuna), kills(curiosity, tuna)}} The cat’s name is Tuna. {{cat(tuna)}} All cats are animals. {{¬cat(X), animal(X)}} Clausal Form
25
Questions Who killed tuna? {{¬kills(X, tuna)}} Did Curiosity kill the cat? {{¬kills(curiosity, X), ¬cat(X)}}
26
Revision Know the definition of Program Clauses. Be able to do resolution for Program Clauses. Be able to do resolution for Predicate Logic.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.