Reasoning using First-Order Logic

Slides:



Advertisements
Similar presentations
Inference in First-Order Logic
Advertisements

Resolution Proof System for First Order Logic
First-Order Logic.
Biointelligence Lab School of Computer Sci. & Eng.
Inference Rules Universal Instantiation Existential Generalization
1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 06 : First Order Logic Resolution Prove.
Standard Logical Equivalences
Resolution.
Automated Reasoning Systems For first order Predicate Logic.
First Order Logic Resolution
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
Logic Use mathematical deduction to derive new knowledge.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
Predicate Calculus Russell and Norvig: Chapter 8,9.
Prolog IV Logic, condensed. 2 Propositional logic Propositional logic consists of: The logical values true and false ( T and F ) Propositions: “Sentences,”
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
CSE (c) S. Tanimoto, 2008 Propositional Logic
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
AI - Week 16 Logic and Reasoning in AI: Resolution Refutation Lee McCluskey, room 2/07
1 Automated Reasoning Introduction to Weak Methods in Theorem Proving 13.1The General Problem Solver and Difference Tables 13.2Resolution Theorem.
Inference and Resolution for Problem Solving
Inference in First-Order Logic
Chapter 3 Propositional Logic
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Fall 2004.
Artificial Intelligence
The Semantic Web – WEEK 8: An automatic Proof technique.. The “Layer Cake” Model – [From Rector & Horrocks Semantic Web cuurse] You are here!
Introduction to Logic for Artificial Intelligence Lecture 2 Erik Sandewall 2010.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
UIUC CS 497: Section EA Lecture #3 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Conjunctive normal form: any formula of the predicate calculus can be transformed into a conjunctive normal form. Def. A formula is said to be in conjunctive.
1 Chapter 8 Inference and Resolution for Problem Solving.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
1CS3754 Class Notes 14B, John Shieh, Figure 2.5: Further steps in the unification of (parents X (father X) (mother bill)) and (parents bill.
Unification Algorithm Input: a finite set Σ of simple expressions Output: a mgu for Σ (if Σ is unifiable) 1. Set k = 0 and  0 = . 2. If Σ  k is a singleton,
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 15 of 41 Friday 24 September.
The Law of Resolution Formal Aspects of Computer Science - Week 7 The Law of Resolution Lee McCluskey, room 2/07
Propositional Logic Predicate Logic
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.
第 1 6 章 谓词演算中的归结. 2 Outline Unification Predicate-Calculus Resolution Completeness and Soundness Converting Arbitrary wffs to Clause Form Using Resolution.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
Knowledge Repn. & Reasoning Lec. #5: First-Order Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004.
1-1 An Introduction to Logical Programming Sept
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Introduction to Logic for Artificial Intelligence Lecture 2
Propositional Logic Resolution
Horn Clauses and Unification
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Artificial Intelligence
Horn Clauses and Unification
Prolog IV Logic, condensed.
Horn Clauses and Unification
Horn Clauses and Unification
Horn Clauses and Unification
RESOLUTION.
Resolution Proof System for First Order Logic
Presentation transcript:

Reasoning using First-Order Logic

sen  sen’, sen  sen’, sen  sen’ Sentences A predicate is a sentence If sen, sen’ are sentences & x a variable, then (sen), sen, x sen, x sen, sen  sen’, sen  sen’, sen  sen’ are sentences Nothing else is a sentence

Examples of Sentences Birthday( x, y) – x celebrates birthday on date y y x Birthday (x, y) – For all dates, there exists a person who celebrates his/her Birthday on that date. That is – “everyday someone celebrates his/her Birthday”

x y Brother (x, y)  Loves (x, y) Examples (contd.) Brother( x, y) – x is y’s brother Loves (x, y) – x loves y x y Brother (x, y)  Loves (x, y) Everyone loves (all of) his/her brothers. Let m (x) represent mother of x then “everyone loves his/her mother” is x Loves (x, m (x) )

x equal (x, succ ( pred (x) ) Examples (contd.) Any number is the successor of its predecessor succ (x), pred (x), equal (x, y) x equal (x, succ ( pred (x) )

Alternative Representation The previous example can be represented succinctly as x (succ ( pred (x ) = x) Not Allowed in predicates

term = term is also a sentence FOL with Equality In FOL with equality, we are allowed to use the equality sign (=) between two functions. This is just for representational ease We modify the definition of sentence to include equality as term = term is also a sentence

Quiz Revisited x (dog(x)  bark(x)) Some dogs bark All dogs have four legs x (dog(x)  have_four_legs (x) x (dog(x)  legs (x,4) All barking dogs are irritating Do it yourself

No dogs purr ¬ x (dog(x)  purr(x)) Fathers are male parents with children x (father(x)  male(x)  has_children(x)) Students are people who are enrolled in courses Do it yourself

Inference Rules Universal Elimination x Likes (x, flower) substituting x by Shirin gives Likes (Shirin, flower) The substitution should be done by a constant term

 x Likes (x, flower)  Likes (Person, flower) Inference Rules Existential Elimination (Skolemization)  x Likes (x, flower)  Likes (Person, flower) as long as person is not in the knowledge base Existential Introduction Likes (Shahid, flower) can be written as  x Likes (x, flower)

Reasoning in FOL Consider the following problem: If a perfect square is divisible by a prime p, then it is also divisible by square of p. Every perfect square is divisible by some prime. 36 is a perfect square. Does there exist a prime q such that square of q divides 36?

Representation in FOL If a perfect square is divisible by a prime p, then it is also divisible by square of p. x,y perfect_sq (x)  prime (y)  divides (x,y)  divides (x, square (y)) Every perfect square is divisible by some prime. x y perfect_sq (x)  prime (y)  divides (x,y)

y prime (y)  divides (36,square(y)) Representation in FOL 36 is a perfect square. perfect_sq (36) Does there exist a prime q such that the square of q divides 36? y prime (y)  divides (36,square(y))

The Knowledge base x,y perfect_sq (x)  prime (y)  divides (x,y)  divides (x, square (y)) x y perfect_sq (x)  prime (y)  divides (x,y) perfect_sq (36)

Inferencing From 2 and Universal Elimination (4) y perfect_sq (36)  prime (y)  divides (36, y) From 4 and Existential Elimination (5) perfect_sq (36)  prime (P)  divides (36, P) From (1) and (5) (6) divides (36, square(P))

Inferencing (contd.) From (5) and (6) (7) prime (P)  divides (36, square(P)) From (7) and Existential Introduction y prime (y)  divides (36, square(y))

Inferencing (contd.) However, inferencing would have been easier if the knowledge base consists of the following sentences perfect_sq(36) prime(P) divides(36,P) x,y perfect_sq (x)  prime (y)  divides (x,y)  divides (x, square (y))

Horn Sentences atomic sentences perfect_sq (36) implication with a conjunction of atomic sentences on the left and a single atom on the right x,y perfect_sq (x)  prime (y)  divides (x,y)  divides (x, square (y)) No Existential Quantifier

Conversion to Horn Sentences Existential Quantifiers can be removed using Existential Elimination (Skolemization) If the existential quantifier is outside any universal quantifier, a Skolem constant is introduced. E.g. y prime (y)  prime(P), where P is a Skolem constant Otherwise a Skolem function is introduced. E.g. x y prime (y)  divides (x,y)  x prime(PD(x))  divides (x,PD(x)) , where PD(x) is a Skolem function

Conversion to Horn Sentences And-Elimination prime (P)  divides (x,P) can be written as two clauses prime (P) divides (x,P)

Substitution Substitution replaces variables with constants. SUBST ({x/49}, Perfect_sq(x)) = Perfect_sq(49) SUBST ({x/49, y/7}, Divides(x,y)) = Divides(49, 7)

Unification Unification is the Process of finding a substitution that makes two atomic sentences identical. UNIFY (Prime(7), Prime(x)) = {x/7} UNIFY (Divides(49,x), Divides (y,7)) = {y/49, x/7} UNIFY (Prime(7),Prime(17) – Impossible! UNIFY (Divides(49,x), Divides (x,7)) – Impossible!     

Inference through Resolution in First Order Predicate Logic

Resolution – A technique of Inference A sound inference mechanism Principle: Suppose x is a literal and S1 and S2 are two sets of propositional sentences represented n clausal form If we have (x V S1) AND (x V S2 ) Then we get S1 V S2 Here S1 V S2 is the resolvent, x is resolved upon

An Example If a triangle is equilateral then it is isosceles If a triangle is isosceles then two sides AB and AC are equal If AB and AC are equal then angle B and angle C are equal ABC is an equilateral triangle Angle B is equal to angle C -- Prove

Equilateral (ABC)  Isosceles (ABC) If a triangle is equilateral then it is isosceles Equilateral (ABC)  Isosceles (ABC) If a triangle is isosceles then two sides AB and AC are equal Isosceles (ABC)  Equal (AB,AC) If AB and AC are equal then angle B and angle C are equal Equal (AB,AC)  Equal (B,C) ABC is an equilateral triangle Equilateral (ABC)

1. Equilateral (ABC)  Isosceles (ABC) Clausal Form 1. Equilateral (ABC)  Isosceles (ABC)  Equilateral (ABC) V Isosceles (ABC) 2. Isosceles (ABC)  Equal (AB,AC)  Isosceles (ABC) V Equal (AB,AC) 3. Equal (AB,AC)  Equal (B,C) Equal (AB,AC)  Equal (B,C) 4. Equilateral (ABC)

Proof by refutation To prove Angle B is equal to Angle C Equal (B,C) Let us disprove Not equal (B,C) Equal (B,C) Let us try to disprove this

 Equal (AB,AC) Isosceles (ABC) Equilateral (ABC) V Isosceles (ABC) Isosceles (ABC) V Equal (AB,AC) Equal (AB,AC) V Equal (B,C) Equilateral (ABC) Equal (AB,AC) V Equal (B,C) Equal (B,C) Isosceles (ABC) V Equal (AB,AC)  Equal (AB,AC) Isosceles (ABC)

 Equal (AB,AC) V Equal (B,C) Isosceles (ABC) Equilateral (ABC) V Isosceles (ABC)  Isosceles (ABC) V Equal (AB,AC)  Equal (AB,AC) V Equal (B,C) Equilateral (ABC) Equilateral (ABC) V Isosceles (ABC) Equilateral (ABC) Equilateral (ABC) Null clause

Procedure for Resolution Convert given propositions into clausal form Convert the negation of the sentence to be proved into clausal form Combine the clauses into a set Iteratively apply resolution to the set and add the resolvent to the set Continue until no further resolvents can be obtained or a null clause is obtained

What is it for Predicate Logic

A Few Statements All people who are graduating are happy. All happy people smile. Someone is graduating. Is someone smiling? (Conclusion)

Solving the problem We intend to code the problem in predicate calculus. Use resolution refutation to solve problem Solving ≈ whether the conclusion can be answered from the given set of sentences.

Selecting the Predicates graduating (x) : x is graduating Happy (x) : x is happy Smiling (x) : x is smiling

Encoding sentences in Predicate Logic All people who are graduating are happy (x) [graduating (x)  happy (x)] All happy people smile (x) [happy (x)  smiling (x)] Someone is graduating (x) graduating (x) Is someone smiling (x) smiling (x)

Predicates (x) graduating (x)  happy (x) (x) happy (x)  smiling (x) (x) graduating (x)  (x) smiling (x) ( Negating the conclusion)

Converting to Clausal form Step 1: Eliminate  (x)  graduating (x)  happy (x) (x)  happy (x)  smiling (x) (x) graduating (x)  (x) smiling (x)

Converting to Canonical form Step 2: Reduce the scope of negation (x)  graduating (x)  happy (x) (x)  happy (x)  smiling (x) (x) graduating (x) (x)  smiling (x)

Converting to Canonical form Step 3: Standardize variables apart (x)  graduating (x)  happy (x) (y)  happy (y)  smiling (y) (z) graduating (z) (w)  smiling (w)

Converting to Canonical form Step 4: Move all quantifiers to the left (x)  graduating (x)  happy (x) (y)  happy (y)  smiling (y) (z) graduating (z) (w)  smiling (w)

Converting to Canonical form Step 5: Eliminate  ( Skolemization) (x)  graduating (x)  happy (x) (y)  happy (y)  smiling (y) graduating (name1) ( name1 is the skolemization constant) (w)  smiling (w)

Converting to Canonical form Step 6. Drop all   graduating (x)  happy (x)  happy (y)  smiling (y) graduating (name1)  smiling (w)

Converting to Canonical form Step 7. Convert to conjunct of disjuncts form Step 8. Make each conjunct a separate clause. Step 9. Standardize variables apart again. These steps do not change the set of clauses any further (in the present problem)

Resolution 4. smiling (w) 2.  happy (y)  smiling (y) {w/y} 5.  happy (w) 1.  graduating (x)  happy (x) {w/x} 6.  graduating (w) 3. graduating (name1) {name1/w} 7. Null clause

Quiz Solve the problem with resolution If a perfect square is divisible by a prime p, then it is also divisible by square of p. Every perfect square is divisible by some prime. 36 is a perfect square. Does there exist a prime q such that square of q divides 36?

Answer Extraction

Find the Package Example (Nilsson) We know that All packages in room 27 are smaller than those in room 28 Package A is either in room 27 or in room 28 Package B is in room 27 Package B is not smaller than Package A Where is Package A?

Answer extraction Suppose we wish to prove whether KB |= (u)f(u) We are probably interested in knowing the w for which f(u) holds. Add Ans(u) literal to each clause coming from the negation of the theorem to be proven; stop resolution process when there is a clause containing only Ans literal

¬P(x)  ¬ P(y)  ¬ I (x, 27)  ¬ I (y, 28)  S(x,y) 2. P(A) 3. P(B) All packages in Room 27 are smaller than those in room 28 ¬P(x)  ¬ P(y)  ¬ I (x, 27)  ¬ I (y, 28)  S(x,y) 2. P(A) 3. P(B) 4. I(A,27)  I (A,28) 5. I(B,27) 6. ¬S (B,A) In which room is A? That is, Prove (u) I (A, u)

@Anupam Basu