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

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

Jul 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: First-Order Logic · First-Order Logic Chapter 8 Examples [04PBT 04PFT 04PLT 04PNT 04PRT] Genap 2011-2012 [dks0638]

First-Order Logic

Chapter 8Examples

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

Genap 2011-2012

[dks0638]

Page 2: First-Order Logic · First-Order Logic Chapter 8 Examples [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, …

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

Syntax of FOL

• Constants KingJohn, 2, UofA,...

• Predicates Brother, >,...

• Functions Sqrt, LeftLegOf,...

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

• Connectives , , , , • Equality =

• Quantifiers ,

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

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!

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

Example Knowledge Base contd.

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

6

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

7

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

8

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

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

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

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

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

11

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

12

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

13

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

14

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

15

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

16

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

17

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

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

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

19

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

21

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

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.

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

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!

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

Resolution in Propositional Logic

24

P Q R (2) R

P Q P (1)

T Q (4) Q

T T (5)

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

Prove fido will die!

1. All dogs are animal.

2. Fido is a dog.

3. All animals will die.

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

Resolution proof for the “dead dog” problem.

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

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!

Page 28: First-Order Logic · First-Order Logic Chapter 8 Examples [04PBT 04PFT 04PLT 04PNT 04PRT] Genap 2011-2012 [dks0638]
Page 29: First-Order Logic · First-Order Logic Chapter 8 Examples [04PBT 04PFT 04PLT 04PNT 04PRT] Genap 2011-2012 [dks0638]
Page 30: First-Order Logic · First-Order Logic Chapter 8 Examples [04PBT 04PFT 04PLT 04PNT 04PRT] Genap 2011-2012 [dks0638]
Page 31: First-Order Logic · First-Order Logic Chapter 8 Examples [04PBT 04PFT 04PLT 04PNT 04PRT] Genap 2011-2012 [dks0638]

One resolution refutation for the “happy student” problem.

[1] [6]

[5]

[3]

[5]

[7]

[10]

[9]

[9]

[8]

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

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?

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

[1]

[3][2]

[4]

[6][5]

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

Resolution proof for the “exciting life” problem.

[6] [5]

[1]

[2]

[4]

[3]

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

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

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

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

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

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