Prolog Conversion to clause form Reference Artificial Intelligence

  • Slides: 13
Download presentation
Prolog Conversion to clause form Reference: Artificial Intelligence, by Elaine Rich and Kevin Knight

Prolog Conversion to clause form Reference: Artificial Intelligence, by Elaine Rich and Kevin Knight

I’m thinking of something. A. B. C. Animal Vegetable Mineral

I’m thinking of something. A. B. C. Animal Vegetable Mineral

Running example n n All Romans who know Marcus either hate Caesar or think

Running example n n All Romans who know Marcus either hate Caesar or think that anyone who hates anyone is crazy x, [ Roman(x) know(x, Marcus) ] [ hate(x, Caesar) ( y, z, hate(y, z) think. Crazy(x, y))] 3

Step 1: Eliminate implications n n n Use the fact that x y is

Step 1: Eliminate implications n n n Use the fact that x y is equivalent to x y x, [ Roman(x) know(x, Marcus) ] [ hate(x, Caesar) ( y, z, hate(y, z) think. Crazy(x, y))] x, [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( y, ( z, hate(y, z) think. Crazy(x, y))] 4

Step 2: Reduce the scope of n Reduce the scope of negation to a

Step 2: Reduce the scope of n Reduce the scope of negation to a single term, using: n n n n ( p) p (a b) x, p(x) ( a b) x, p(x) x, [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( y, ( z, hate(y, z) think. Crazy(x, y))] x, [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( y, z, hate(y, z) think. Crazy(x, y))] 5

Step 3: Standardize variables apart n n n x, P(x) x, Q(x) becomes x,

Step 3: Standardize variables apart n n n x, P(x) x, Q(x) becomes x, P(x) y, Q(y) This is just to keep the scopes of variables from getting confused Not necessary in our running example 6

Step 4: Move quantifiers n n n Move all quantifiers to the left, without

Step 4: Move quantifiers n n n Move all quantifiers to the left, without changing their relative positions x, [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( y, z, hate(y, z) think. Crazy(x, y)] x, y, z, [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( hate(y, z) think. Crazy(x, y))] 7

Step 5: Eliminate existential quantifiers n We do this by introducing Skolem functions: n

Step 5: Eliminate existential quantifiers n We do this by introducing Skolem functions: n n n If x, p(x) then just pick one; call it x’ If the existential quantifier is under control of a universal quantifier, then the picked value has to be a function of the universally quantified variable: n If x, y, p(x, y) then x, p(x, y(x)) Not necessary in our running example 8

Step 6: Drop the prefix (quantifiers) n n x, y, z, [ Roman(x) know(x,

Step 6: Drop the prefix (quantifiers) n n x, y, z, [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( hate(y, z) think. Crazy(x, y))] At this point, all the quantifiers are universal quantifiers We can just take it for granted that all variables are universally quantified [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( hate(y, z) think. Crazy(x, y))] 9

Step 7: Create a conjunction of disjuncts n [ Roman(x) know(x, Marcus) ] [hate(x,

Step 7: Create a conjunction of disjuncts n [ Roman(x) know(x, Marcus) ] [hate(x, Caesar) ( hate(y, z) think. Crazy(x, y))] becomes Roman(x) know(x, Marcus) hate(x, Caesar) hate(y, z) think. Crazy(x, y) 10

Step 8: Create separate clauses n n Every place we have an , we

Step 8: Create separate clauses n n Every place we have an , we break our expression up into separate pieces Not necessary in our running example 11

Step 9: Standardize apart n Rename variables so that no two clauses have the

Step 9: Standardize apart n Rename variables so that no two clauses have the same variable Not necessary in our running example n Final result: n Roman(x) know(x, Marcus) hate(x, Caesar) hate(y, z) think. Crazy(x, y) n That’s it! It’s a long process, but easy enough to do mechanically 12

The End 13

The End 13