1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

18
1/19 Inference in first- order logic Chapter 9- Part2 Modified by Vali Derhami

Transcript of 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

Page 1: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

1/19

Inference in first-order logic

Chapter 9- Part2

Modified by Vali Derhami

Page 2: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

2/19

Backward chaining algorithm

SUBST(COMPOSE(θ1, θ2), p) = SUBST(θ2, SUBST(θ1, p))به جایگزینها از یک هر کارگیری به تاثیر معادل جایگزینی ترکیب

است نوبت

Page 3: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

3/19

Backward chaining example

Page 4: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

4/19

Backward chaining example

Page 5: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

5/19

Backward chaining example

Page 6: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

6/19

Backward chaining example

Page 7: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

7/19

Backward chaining example

Page 8: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

8/19

Backward chaining example

Page 9: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

9/19

Backward chaining example

Page 10: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

10/19

Backward chaining example

Page 11: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

11/19

Properties of backward chaining

• Depth-first recursive proof search: space is linear in size of proof

• Incomplete due to infinite loops (even for Datalog) fix by checking current goal against every goal on stack

• Inefficient due to repeated subgoals (both success and failure) fix using caching of previous results (extra space)

تکرار( هنگام در نگهداری، تولید حین در فرعی هدفهای جوابهای( استفاده انها از فرعی هدفهای

• Widely used for logic programming

Page 12: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

12/19

Logic programming: Prolog• Algorithm = Logic + Control• Basis: backward chaining with Horn clauses • Uses uppercase letters for variables and lowercase for constants.• Clauses are written with the head preceding the body; ": -" is used

for left- implication, commas separate literals in the body, and ‘.’ for end of a sentence.

• Widely used in Europe, Japan

• Program = set of clauses = head :- literal1, … literaln.

criminal(X) :- american(X), weapon(Y), sells(X,Y,Z), hostile(Z).

• Depth-first, left-to-right backward chaining• Built-in predicates for arithmetic etc., e.g., X is Y*Z+3

Page 13: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

14/19

Resolution: brief summary• Full first-order version:

l1 ··· lk, m1 ··· mn

(l1 ··· li-1 li+1 ··· lk m1 ··· mj-1 mj+1 ··· mn)θwhere Unify(li, mj) = θ.

• The two clauses are assumed to be standardized apart so that they share no variables.

• For example:Rich(x) Unhappy(x) Rich(Ken)

Unhappy(Ken)with θ = {x/Ken}

• Apply resolution steps to CNF(KB α); complete for FOL

••

Page 14: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

15/19

Conversion to CNF

• Everyone who loves all animals is loved by someone:x [y Animal(y) Loves(x,y)] [y Loves(y,x)]

1. Eliminate biconditionals and implicationsx [y Animal(y) Loves(x,y)] [y Loves(y,x)]

2. Move inwards: x p ≡ x p, x p ≡ x px [y (Animal(y) Loves(x,y))] [y Loves(y,x)] x [y Animal(y) Loves(x,y)] [y Loves(y,x)] x [y Animal(y) Loves(x,y)] [y Loves(y,x)]

Page 15: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

16/19

Conversion to CNF contd.3. Standardize variables: each quantifier should use a different one

x [y Animal(y) Loves(x,y)] [z Loves(z,x)]4. Skolemize: a more general form of existential instantiation.

Each existential variable is replaced by a Skolem function of the enclosing universally quantified variables:

x [Animal(F(x)) Loves(x,F(x))] Loves(G(x),x)

5. Drop universal quantifiers: [Animal(F(x)) Loves(x,F(x))] Loves(G(x),x)

6. Distribute over : [Animal(F(x)) Loves(G(x),x)] [Loves(x,F(x)) Loves(G(x),x)]

–»

––

Page 16: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

17/19

Resolution proof: definite clausesR1: American(x) Weapon(y) Sells(x,y,z) Hostile(z) Criminal(x)R2: Missile(x1) Owns(Nono,x1) Sells(West,x1,Nono)R3: Missile(x2) Weapon(x2)R4: Enemy(x3,America) Hostile(x3)Owns(Nono,M1) Missile(M1)American(West)Enemy(Nono,America)

Page 17: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

18/19

Resolution proof: definite clauses

R1: American(x) Weapon(y) Sells(x,y,z) Hostile(z) Criminal(x)R2: Missile(x1) Owns(Nono,x1) Sells(West,x1,Nono)R3: Missile(x2) Weapon(x2)R4: Enemy(x3,America) Hostile(x3)Owns(Nono,M1) Missile(M1)American(West)Enemy(Nono,America)

Page 18: 1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.

19/19

فصل • تستی 18، 9، 4: 9تمارین سواالت و