Inference in First Order Logic Inference in First Order Logic Course: CS40002 Course: CS40002 Instructor: Dr. Pallab Dasgupta Pallab Dasgupta Instructor: Dr. Department of Computer Science & Engineering Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Kharagpur Indian Institute of Technology
Inference rules Inference rules � Universal elimination: Universal elimination: � � ∀ ∀ x Likes( x, x Likes( x, IceCream IceCream ) ) with the substitution with the substitution � {x / Einstein} gives us gives us Likes( Einstein, Likes( Einstein, IceCream IceCream ) ) {x / Einstein} � The substitution has to be done by a ground term The substitution has to be done by a ground term � � Existential elimination: Existential elimination: � ∃ x Likes( x, From ∃ � From x Likes( x, IceCream IceCream ) ) we may infer we may infer � Likes( Man, IceCream IceCream ) ) as long as Man does not as long as Man does not Likes( Man, appear elsewhere in the Knowledge base appear elsewhere in the Knowledge base � Existential introduction: Existential introduction: � � From From Likes( Likes( Monalisa Monalisa, , IceCream IceCream ) ) we can infer we can infer � ∃ x Likes( x, ∃ x Likes( x, IceCream IceCream ) ) CSE, IIT Kharagpur Kharagpur CSE, IIT 2
Reasoning in first- -order logic order logic Reasoning in first � The law says that it is a crime for a Gaul The law says that it is a crime for a Gaul � to sell potion formulas to hostile nations. to sell potion formulas to hostile nations. � The country Rome, an enemy of Gaul, The country Rome, an enemy of Gaul, � has acquired some potion formulas, and has acquired some potion formulas, and all of its formulas were sold to it by Druid all of its formulas were sold to it by Druid Traitorix. . Traitorix � Traitorix Traitorix is a Gaul. is a Gaul. � � Is Is Traitorix Traitorix a criminal? a criminal? � CSE, IIT Kharagpur Kharagpur CSE, IIT 3
Generalized Modus Ponens Ponens Generalized Modus � For atomic sentences p For atomic sentences p i , p i ’, and q, where i , p i ’, and q, where � θ such that there is a substitution θ such that there is a substitution θ , p θ , p for all i: SUBST( θ ) = SUBST( θ ), for all i: , p i ’) = SUBST( , p i SUBST( i ’ i ), ′ ′ ′ p , p ,..., p , ( p ∧ p ∧ ... ∧ p ⇒ q ) 1 2 n 1 2 n θ SUBST ( , q ) CSE, IIT Kharagpur Kharagpur CSE, IIT 4
Unification Unification θ ,p) = SUBST( θ ,q) where SUBST( θ ,p) = SUBST( θ θ where SUBST( ,q) UNIFY(p,q) = θ UNIFY(p,q) = Examples: Examples: UNIFY( Knows(Erdos Erdos, x),Knows( , x),Knows(Erdos Erdos, , Godel Godel)) )) UNIFY( Knows( = {x / Godel Godel} } = {x / UNIFY( Knows(Erdos Erdos, x), Knows(y, , x), Knows(y,Godel Godel)) )) UNIFY( Knows( = {x/Godel Godel, y/ , y/Erdos Erdos} } = {x/ CSE, IIT Kharagpur Kharagpur CSE, IIT 5
Unification Unification θ ,p) = SUBST( θ ,q) where SUBST( θ ,p) = SUBST( θ θ where SUBST( ,q) UNIFY(p,q) = θ UNIFY(p,q) = Examples: Examples: UNIFY( Knows(Erdos Erdos, x), Knows(y, Father(y))) , x), Knows(y, Father(y))) UNIFY( Knows( = { y/Erdos Erdos, x/Father( , x/Father(Erdos Erdos) } ) } = { y/ UNIFY( Knows(Erdos Erdos, x), Knows(x, , x), Knows(x, Godel Godel)) = F )) = F UNIFY( Knows( We require the most general unifier We require the most general unifier CSE, IIT Kharagpur Kharagpur CSE, IIT 6
Reasoning with Horn Logic Reasoning with Horn Logic � We can convert Horn sentences to a We can convert Horn sentences to a � canonical form and then use generalized canonical form and then use generalized Modus Ponens Ponens with unification. with unification. Modus � We We skolemize skolemize existential formulas and existential formulas and � remove the universal ones remove the universal ones � This gives us a conjunction of clauses, that This gives us a conjunction of clauses, that � are inserted in the KB are inserted in the KB � Modus Modus Ponens Ponens help us in inferring new help us in inferring new � clauses clauses � Forward and backward chaining Forward and backward chaining � CSE, IIT Kharagpur Kharagpur CSE, IIT 7
Completeness issues Completeness issues � Reasoning with Modus Reasoning with Modus Ponens Ponens is incomplete is incomplete � � Consider the example Consider the example – – � ∀ x P(x) ⇒ Q(x) ∀ x ¬ P(x) ⇒ R(x) ∀ x P(x) ⇒ ∀ x ¬ P(x) ⇒ Q(x) R(x) ∀ x Q(x) ⇒ S(x) ∀ x R(x) ⇒ S(x) ∀ x Q(x) ⇒ ∀ x R(x) ⇒ S(x) S(x) � We should be able to conclude S(A) We should be able to conclude S(A) � ∀ x ¬ P(x) ⇒ R(x) cannot The problem is that ∀ x ¬ P(x) ⇒ � The problem is that R(x) cannot � be converted to Horn form, and thus cannot be converted to Horn form, and thus cannot be used by Modus Ponens Ponens be used by Modus CSE, IIT Kharagpur Kharagpur CSE, IIT 8
Godel’s Completeness Theorem Completeness Theorem Godel’s � For first For first- -order logic, any sentence that is order logic, any sentence that is � entailed by another set of sentences can be entailed by another set of sentences can be proved from that set proved from that set � Godel Godel did not suggest a proof procedure did not suggest a proof procedure � � In 1965 Robinson published his resolution In 1965 Robinson published his resolution � algorithm algorithm � Entailment in first Entailment in first- -order logic is semi order logic is semi- -decidable, decidable, � that is, we can show that sentences follow from that is, we can show that sentences follow from premises if they do, but we cannot always show if premises if they do, but we cannot always show if they do not. they do not. CSE, IIT Kharagpur Kharagpur CSE, IIT 9
The validity problem of first- -order logic order logic The validity problem of first � [Church] [Church] The validity problem of the first The validity problem of the first- - � order predicate calculus is partially solvable. order predicate calculus is partially solvable. � Consider the following formula: Consider the following formula: � n [ ∧ p ( f ( a ), g ( a )) i i i = 1 n ∧ ∀ x ∀ y [ p ( x , y ) ⇒ ∧ p ( f ( x ), g ( x ))]] i i i = 1 ⇒ ∃ z p ( z , z ) CSE, IIT Kharagpur Kharagpur CSE, IIT 10
Resolution Resolution � Generalized Resolution Rule: Generalized Resolution Rule: � θ , ) = θ For atoms p i , q q i , r r i , s s i , where Unify(p p j , q q k , For atoms p i , i , i , i , where Unify( j , k ) = we have: we have: p ∧ ... p ... ∧ p ⇒ r ∨ ... r 1 j n 1 1 n 2 s ∧ ... ∧ s ⇒ q ∨ ... q ... ∨ q 1 n 3 1 k n 4 SUBST ( θ , p ∧ ... p ∧ p ... ∧ p ∧ s ∧ ... s 1 j − 1 j + 1 n 1 1 n 3 ⇒ r ∨ ... r ∨ ... q ∨ q ∨ ... ∨ q ) 1 n 2 k − 1 k + 1 n 4 CSE, IIT Kharagpur Kharagpur CSE, IIT 11
Our earlier example Our earlier example P(w) ⇒ Q(w) Q(y) ⇒ S(y) {y / w} P(w) ⇒ S(w) True ⇒ P(x) ∨ R(x) {w / x} True ⇒ S(x) ∨ R(x) R(z) ⇒ S(z) {x/A, z/A} True ⇒ S(A) CSE, IIT Kharagpur Kharagpur CSE, IIT 12
Conversion to Normal Form Conversion to Normal Form � A formula is said to be in clause form if it is of A formula is said to be in clause form if it is of � the form: the form: ∀ x ∀ x … ∀ ∀ x ∧ C ∧ … … ∧ ∧ C ∀ 1 ∀ 1 ∧ 2 ∧ x 1 x 2 x n [C 1 C 2 C k ] 2 … n [C k ] � All first All first- -order logic formulas can be converted order logic formulas can be converted � to clause form to clause form � We shall demonstrate the conversion on the We shall demonstrate the conversion on the � formula: formula: ∀ x {p(x) ⇒ ∃ ∃ z { ¬∀ y [q(x,y) ⇒ p(f(x ∀ x {p(x) ⇒ z { ¬∀ y [q(x,y) ⇒ p(f(x 1 ))] 1 ))] ∧ ∀ ∀ y [q(x,y) ⇒ p(x)] }} ∧ y [q(x,y) ⇒ p(x)] }} CSE, IIT Kharagpur Kharagpur CSE, IIT 13
Conversion to Normal Form Conversion to Normal Form � Step1: Step1: Take the existential closure and Take the existential closure and � eliminate redundant quantifiers. quantifiers. This This eliminate redundant ∃ x ∃ z, so: introduces ∃ and eliminates ∃ x 1 z, so: introduces 1 and eliminates ∀ x {p(x) ⇒ ∃ ∃ z ¬∀ y [q(x,y) ⇒ p(f( ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ z { p(f(x x 1 ))] 1 ))] ∧ ∀ ∀ y [q(x,y) ⇒ p(x)] }} ∧ y [q(x,y) ⇒ p(x)] }} ∃ x ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ p(f(x ∃ 1 ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ x 1 p(f(x 1 ))] 1 ))] ∧ ∀ ∀ y [q(x,y) ⇒ p(x)] }} ∧ y [q(x,y) ⇒ p(x)] }} CSE, IIT Kharagpur Kharagpur CSE, IIT 14
Conversion to Normal Form Conversion to Normal Form � Step 2: Step 2: Rename any variable that is Rename any variable that is � quantified more than once. y has been y has been quantified more than once. quantified twice, so: quantified twice, so: ∃ x ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ p(f(x ∃ 1 ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ x 1 p(f(x 1 ))] 1 ))] ∧ ∀ ∀ y [q(x,y) ⇒ p(x)] }} ∧ y [q(x,y) ⇒ p(x)] }} ∃ x ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ p(f(x ∃ 1 ∀ x {p(x) ⇒ { ¬∀ y [q(x,y) ⇒ x 1 p(f(x 1 ))] 1 ))] ∧ ∀ ∀ z [q(x,z) ⇒ p(x)] ∧ z [q(x,z) ⇒ p(x)] }} }} CSE, IIT Kharagpur Kharagpur CSE, IIT 15
Recommend
More recommend