First-Order Logic · First-Order Logic Chapter 8 Examples [04PBT 04PFT 04PLT 04PNT 04PRT] Genap 2011-2012 [dks0638]

Post on 20-Jul-2020

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

First-Order Logic

Chapter 8Examples

[04PBT 04PFT 04PLT 04PNT 04PRT]

Genap 2011-2012

[dks0638]

First-order logic

• Whereas propositional logic assumes the world contains facts,

• first-order logic (like natural language) assumes the world contains– Objects: people, houses, numbers, colors,

baseball games, wars, …– Relations: red, round, prime, brother of, bigger

than, part of, comes between, …– Functions: father of, best friend, one more

than, plus, …

Syntax of FOL

• Constants KingJohn, 2, UofA,...

• Predicates Brother, >,...

• Functions Sqrt, LeftLegOf,...

• Variables x, y, a, b,...

• Connectives , , , , • Equality =

• Quantifiers ,

Example Knowledge Base

The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.

Prove that Col. West is a criminal!

Example Knowledge Base contd.

6

7

8

Properties of forward chaining

9

Sound and complete for first-order definite clauses (proof similar to propositional proof)

Datalog = first-order definite clauses + no functions (e.g., crime KB)

FC terminates for Datalog in poly iterations: at most p ∙ nk literals

May not terminate in general if is not entailed

This is unavoidable: entailment with definite clauses is semidecidable

Efficiency of forward chainingSimple observation: no need to match a rule on iteration kif a premise wasn't added on iteration k - 1 match each rule whose premise contains a newly added

literal

Matching itself can be expensive

Database indexing allows O(1) retrieval of known factse.g., query Missile(x) retrieves Missile(M1)

Matching conjunctive premises against known facts is NP-hard

Forward chaining is widely used in deductive databases

11

12

13

14

15

16

17

Properties of backward chaining

18

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

Incomplete due to infinite loops

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 (without improvements!) for logic programming

19

21

Resolution refutation proofs involvesthe following steps:

1. Put the premises or axioms into clause form.

2. Add the negation of what is to be proved, in clause form, to the set of axioms.

3. Resolve these clauses together, producing new clauses that logically follow from them.

4. Produce a contradiction by generating the empty clause.

5. The substitutions used to produce the empty clause are those under which the opposite of the negated goal is true.

A Facts in Propositional Logic

23

Given Axioms Clause Form

P P (1)

(P Q) R P Q R (2)

(S T) Q S Q (3)

T Q (4)

T T (5)

Prove R!

Resolution in Propositional Logic

24

P Q R (2) R

P Q P (1)

T Q (4) Q

T T (5)

Prove fido will die!

1. All dogs are animal.

2. Fido is a dog.

3. All animals will die.

Resolution proof for the “dead dog” problem.

Lucky Student1. Anyone passing his history exams and

winning the lottery is happy.

2. Anyone who studies or is lucky can pass all his exams.

3. John did not study but he is lucky.

4. Anyone who is lucky wins the lottery.

Prove that John is happy!

One resolution refutation for the “happy student” problem.

[1] [6]

[5]

[3]

[5]

[7]

[10]

[9]

[9]

[8]

Exciting life

1. All people that are not poor and are smart are happy.

2. Those people that read are not stupid.

3. John can read and is wealthy.

4. Happy people have exiting lives.

Can anyone be found with an exciting life?

[1]

[3][2]

[4]

[6][5]

Resolution proof for the “exciting life” problem.

[6] [5]

[1]

[2]

[4]

[3]

Resolution Example1. John likes all kinds of food.

x: food(x) likes(john, x)2. Apples are food.

food(apple)3. Chicken is food.

food(chicken)4. Anything anyone eats and isn't killed by is food.

x:(y: eats(y, x) killedby(y, x)) food(x)5. Bill eats peanuts and is still alive.

A. eats(Bill, peanuts) B. alive(Bill) 6. Sue eats everything Bill eats.

x:eats(Bill, x) eats(Sue, x)7. x:y: alive(x) killedby (x,y)

35

Clause form:

1. food(x1) likes(John, x1)2. food(apples)3. food(chicken)4. eats(y4,x4) killedby(y4 , x4) food(x4)5. Eats (Bill, peanuts)6. Alive (Bill)7. eats(Bill,x7) eats(Sue,x7)8. alive(x8) killedby(x8, y8)

36

37

Resolution proof that John likes peanuts

likes (John, peanuts) (1) food(x1) likes (John, x1)

food(peanuts) (4) eats(y4,x4) killedby(y4 . x4) food(x4)

eats(y4,peanuts) killedby(y4. peanuts) (5) eats(Bill.peanuts)

killedby(Bill. peanuts) (8) alive(x8) killedby(x8 y8)

alive(Bill) (6) alive(Bill)

peanuts/x1

peanuts/x4

Bill/x8, peanuts/y8

Bill/y4

top related