Upload
philomena-mcgee
View
213
Download
1
Embed Size (px)
Citation preview
Ch. Eick: FOPL, Resolution and PROLOG
Logical Reasoning1. First Order Predicate Logic as a Language2. Resolution
a) For Propositional Calculusb) For First Order Predicate Calculusc) Unification
3. Resolution and PROLOG very short!
Ch. Eick: FOPL, Resolution and PROLOG
Using Resolution for Propositional Calculuso Makes a proof by contradictiono Works with clauses --- knowledge is represented as a conjunct
of disjuncts (conjunctive normal form)o Does not use modus ponens; uses the inference rule of
resolution (m,n0): A1 v…v An v C; B1v…v Bm v ~C _____________________________
A1v…v An v B1v…v Bm
o Steps of a resolution proof:1. Convert assumption into clauses2. Convert negated conclusion into clauses3. Determine if the empty clause � can be derived from the
clauses generated in steps 1 and 2.o Yes: theorem is proveno No*: theorem is not proven
*:= things are more complicated for FOPL
Ch. Eick: FOPL, Resolution and PROLOG
Proof by Contradiction• Assume you want to prove: A1,…,An |- B then the truth of
this statement is verified as follows:– We assume that A1,..,An is true– We assume that ~B is true– We show that it can never be the case that A1,..,An are
true and B is false…; that is, we look for a contraction (e.g. P and ~P are both true).
Ch. Eick: FOPL, Resolution and PROLOG
Resolution for Propositional Calculus
Example: P v (Q R), Q S, P Q |- RS
Clauses:
(1) P v Q
(2) P v R(3) ~Q v S(4) ~P v Q(5) R(6) ~S(7) ~Q using 3,6(8) ~P v S using 3,4(9) ~P using 6,8(10) Q using 1,9(11) � using 7,10
Ch. Eick: FOPL, Resolution and PROLOG
Resolution for Propositional Calculus Homework
Example:
P v Q R
RS TT U v (X Y)
~U
|-
P (X Y)
Ch. Eick: FOPL, Resolution and PROLOG
Key Ideas --- Resolution for FOPL
All-quantifiers are replaced by match variables Existential quantifiers are replaced by Skolem functions that
depend on the variables of the surrounding all-quantifiers. All match-variables in different clauses are renamed. A generalized resolution inference rule is used ( denotes a
substitution):
P v R, ~R’ v S, R and R’ unify, unify(R,R’)= (P) v (S)
Similar to resolution for prepositional calculus a proof by contradiction is conducted whose goal is to reach the empty clause (which represents a contradiction).
Ch. Eick: FOPL, Resolution and PROLOG
Ch. Eick: FOPL, Resolution and PROLOG
Ch. Eick: FOPL, Resolution and PROLOG
Assignment3: Resolution for Formulas Containing + and *
Examples: (+ 1 b) and (+ $a b) unify for (($a 1)) (+ (* a b) 5) (+ $a $b) unify for (($a (* a b)) ($b 5)) (+ a (+ $a c)) and (+ a d) do not unify; return nil (+ $a (+ a $b)) and (+ (* $b 5) (+ 5 a)) unify for (($a (+$b 5))
($b a)) (+ a b) and (+ b a) unify for ()
Properties of Multiplication:
http://www.aaamath.com/pro74b-propertiesmult.html
Properties of Addition: http://www.aaastudy.com/pro74ax2.htm
Expression Evaluation: (+ 2 (+ 5 a)) unifies (+ 7 a)
Ch. Eick: FOPL, Resolution and PROLOG
PROLOG and Resolution1. grandchild(X,Z):-child(X,Y),child(Y,Z) **PROLOG Rule***2. Asserted facts: child(pete,john), child(sally,john), child(john,fred),
child(tom,fred)3. ?-grandchild(U,fred) “Who are the grandchildren of Fred?”U=pete…U=sally… “Answers returned by the PROLOG runtime system”
How does PROLOG do it? It uses resolution as follows:In clause form (using “our” syntax): 1. ~child($x,$y) v ~child($y,$z) v grandchild($x,$z)2. ~grandchild($u,Fred) “negated conclusion”3. child(Pete,John)4. child(Sally,John) 5. child(John,Fred) 6. child(Tom,Fred)
Resolution in PROLOG: Find all substitutions to the free variables in the query expression ($u in the example) that lead to a contradiction.
Ch. Eick: FOPL, Resolution and PROLOG
PROLOG Example Continued1. ~child($x,$y) v ~child($y,$z) v grandchild($x,$z) rule2. ~grandchild($u,Fred) “negated conclusion/query”3. child(Pete,John) fact4. child(Sally,John) fact5. child(John,Fred) fact6. child(Tom,Fred) fact7. ~child($u,$y) v ~child ($y, Fred) using 1, 28. ~child($u, John) using 5,79. for (($u Pete)) using 3,8 � First answer!10. for (($u Sally)) using 4,8 � Second answer!11. ~child($u, Tom) using 6,7
No more empty clauses are found; therefore the PROLOG system returns two answers: Pete and Sally
Ch. Eick: FOPL, Resolution and PROLOG
Example Sentences
1. Every vegetarian is intelligent.
2. Every NBA-player owns at least one house in Texas.
3. There are at least 2 giraffes in the Houston-Zoo.
Ch. Eick: FOPL, Resolution and PROLOG
Example Sentences in FOPL
Every vegetarian is intelligent.
Vx (vegetarian(x) intelligent(x))Every NBA-player owns at least one house in
Texas.
Vx (nba(x) ]h(house(h) ^ owns(x,h) ^ location(h,Texas) ))
There are at least 2 giraffes in the Houston-Zoo.
]g1]g2 (giraffe(g1) ^ giraffe(g2) ^ not(g1=g2))
^ lives(g1, HOU_Zoo) ^ lives(g2, HOU_Zoo) ))
Ch. Eick: FOPL, Resolution and PROLOG
Answers Sept. 23, 2004 EnglishFOPL Exam
(1) frog(Fred) ^ green(Fred)(2) x (student(x) ^ (not(take(x,AGR2320) v
not(take(x,AGR2388))(3) xyz ((person(x) ^ person(y) ^ has-ssn(x,z) ^
has-ssn(y,z)) x=y)(4) x ((red(x) ^ car(x)) dangerous(x))(5) xy(brother(x,Fred) ^ brother(y,Fred) ^ not(x=y))
^ ~s sister(s,Fred)(6) abc((ontop(a,b) ^ ontop(b,c)) ontop(a,c))
s not(sister(s,Fred))
same
Ch. Eick: FOPL, Resolution and PROLOG
FOPL as a Language SolutionsAnswers to the Un-graded Quiz
(1) frog(Fred) ^ green(Fred)(2) Vx (red(x) ^ car(x) dangerous(x))(3) VxVyVz (person(x) ^ person(y) ^ has-ssn(x,z) ^ has-ssn(y,z)
x=y)(4) ]x (student(x) ^ registered(x,COSC6367) ^ Vy
(registered(y,COSC6367) ^ not (x=y) send-mail(x,y)))(5) Vm (man(m) ^ white(m) not (jump-high(m)) )(6) Not possible; no quantifier for “most”!