Logical Reasoning 1 2 3 First Order Predicate

  • Slides: 14
Download presentation
Logical Reasoning 1. 2. 3. First Order Predicate Logic as a Language Resolution a)

Logical Reasoning 1. 2. 3. First Order Predicate Logic as a Language Resolution a) For Propositional Calculus b) For First Order Predicate Calculus c) Unification Resolution and PROLOG very short! Textbook’s Perspective: knowledge based systems; giving a somewhat comprehensive introduction to logic; cover 7, [9], [[10]] 6368 Perspective: Using FOPL to make statements about the world; use computers to prove theorems and for question-answering. Ch. Eick: FOPL, Resolution and PROLOG

Using Resolution for Propositional Calculus o o Makes a proof by contradiction Works with

Using Resolution for Propositional Calculus o o Makes a proof by contradiction Works with clauses --- knowledge is represented as a conjunct of disjuncts (conjunctive normal form) Does not use modus ponens; uses the inference rule of resolution (m, n 0): A 1 v…v An v C; B 1 v…v Bm v ~C _______________ A 1 v…v An v B 1 v…v Bm Steps of a resolution proof: 1. Convert assumption into clauses 2. Convert negated conclusion into clauses 3. Determine if the empty clause can � be derived from the clauses generated in steps 1 and 2. o Yes: theorem is proven o 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: A 1, …, An |-

Proof by Contradiction • Assume you want to prove: A 1, …, An |- B then the truth of this statement is verified as follows: – We assume that A 1, . . , An is true – We assume that ~B is true – We show that it can never be the case that A 1, . . , 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 |-

Resolution for Propositional Calculus Example: P v (Q R), Q S, P Q |- R S Clauses: (1) P v Q Pv. 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 (2) Ch. Eick: FOPL, Resolution and PROLOG

Key Ideas --Resolution for FOPL § § All-quantifiers are replaced by match variables Existential

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 (q denotes a substitution): § P v R, ~R’ v S, R and R’ unify, unify(R, R’)=q § q(P) v q(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

Ch. Eick: FOPL, Resolution and PROLOG

Ch. Eick: FOPL, Resolution and PROLOG

PROLOG and Resolution grandchild(X, Z): -child(X, Y), child(Y, Z) **PROLOG Rule*** 2. Asserted facts:

PROLOG and Resolution 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” 1. 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 Continued ~child($x, $y) v ~child($y, $z) v grandchild($x, $z) rule 2. ~grandchild($u,

PROLOG Example Continued ~child($x, $y) v ~child($y, $z) v grandchild($x, $z) rule 2. ~grandchild($u, Fred) “negated conclusion/query” 3. child(Pete, John) fact 4. child(Sally, John) fact 5. child(John, Fred) fact 6. child(Tom, Fred) fact 7. ~child($u, $y) v ~child ($y, Fred) using 1, 2 8. ~child($u, John) using 5, 7 9. � for (($u Pete)) using 3, 8 First answer! 10. � for (($u Sally)) using 4, 8 Second answer! 11. ~child($u, Tom) using 6, 7 1. No more empty clauses are found; therefore the PROLOG system returns two answers: Pete and Sally Ch. Eick: FOPL, Resolution and PROLOG

Example Sentences Every vegetarian is intelligent. 2. Every NBA-player owns at least one house

Example Sentences Every vegetarian is intelligent. 2. Every NBA-player owns at least one house in Texas. 3. There at least 2 giraffes in the Houston-Zoo. 1. Ch. Eick: FOPL, Resolution and PROLOG

Example Sentences in FOPL Every vegetarian is intelligent. Vx (vegetarian(x) intelligent(x)) Every NBA-player owns

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 at least 2 giraffes in the Houston-Zoo. ]g 1]g 2 (giraffe(g 1) ^ giraffe(g 2) ^ not(g 1=g 2)) ^ lives(g 1, HOU_Zoo) ^ lives(g 2, HOU_Zoo) )) Ch. Eick: FOPL, Resolution and PROLOG

Answers Sept. 23, 2004 English FOPL Exam (1) (2) (3) (4) (5) (6) frog(Fred)

Answers Sept. 23, 2004 English FOPL Exam (1) (2) (3) (4) (5) (6) frog(Fred) ^ green(Fred) x (student(x) ^ (not(take(x, AGR 2320) v not(take(x, AGR 2388)) x y z ((person(x) ^ person(y) ^ has-ssn(x, z) ^ has-ssn(y, z)) x=y) x ((red(x) ^ car(x)) dangerous(x)) x y(brother(x, Fred) ^ brother(y, Fred) ^ not(x=y)) ^ ~ s sister(s, Fred) a b c((ontop(a, b) ^ ontop(b, c)) ontop(a, c)) same s not(sister(s, Fred)) Ch. Eick: FOPL, Resolution and PROLOG

FOPL as a Language Solutions Answers to the Un-graded Quiz (1) (2) (3) (4)

FOPL as a Language Solutions Answers to the Un-graded Quiz (1) (2) (3) (4) (5) (6) frog(Fred) ^ green(Fred) Vx (red(x) ^ car(x) dangerous(x)) Vx. Vy. Vz (person(x) ^ person(y) ^ has-ssn(x, z) ^ hasssn(y, z) x=y) ]x (student(x) ^ registered(x, COSC 6367) ^ Vy (registered(y, COSC 6367) ^ not (x=y) send-mail(x, y))) Vm (man(m) ^ white(m) not (jump-high(m)) ) Not possible; no quantifier for “most”! Ch. Eick: FOPL, Resolution and PROLOG

Answers February 26, 2009 English FOPL Exam (1) (2) (3) (4) m w (man(m)

Answers February 26, 2009 English FOPL Exam (1) (2) (3) (4) m w (man(m) (woman(w) ^ loves(m, w))) x (student(x) ^ (not(take(x, COSC 6340) ^ not(take(x, COSC 6351)) x y z ((person(x) ^ person(y) ^ has-ssn(x, z) ^ hasssn(y, z)) x=y) x (takes(x, COSC 6368) ^ e s g 1 g 2(((exam(e, COSC 6368, s, g 1) ^ (exam(e, COSC 6368, x, g 2)) ^ not(e=s)) g 2>g 1)) No answer (“most” is a fuzzy quantifier) for (5)!! Remark: Exam(name, course, student, grade) is a predicate that captions the grades of students in courses for a particlar semester; e. g. exam(Mt, COSC 6368, Fred, 3. 0) Ch. Eick: FOPL, Resolution and PROLOG