KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x))...

57
KRR3: Inference in First-order logic 2 Yannick Pencol´ e [email protected] 16 Mar 2005

Transcript of KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x))...

Page 1: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

KRR3: Inference in First-order logic 2

Yannick [email protected]

16 Mar 2005

Page 2: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Outline

1 Backward chaining

2 Resolution

Page 3: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Substitution and Composition

Definition

Given p a sentence and θ1, θ2 two substitutions, the composition of θ1 and θ2

is the substitution θ = COMPOSE(θ1, θ2) such that:

SUBST(θ, p) = SUBST(θ1, SUBST(θ2, p)) = SUBST(θ2, SUBST(θ1, p))

Example

Sentence p is P(y) ∧ Q(x) ⇒ R(z)Consider θ1 = {y/Toto, z/Titi}, θ2 = {x/Tata}SUBST(θ1, p) = P(Toto) ∧ Q(x) ⇒ R(Titi)SUBST(θ2, p) = P(y) ∧ Q(Tata) ⇒ R(z)SUBST(COMPOSE(θ1, θ2), p) = P(Toto) ∧ Q(Tata) ⇒ R(Titi)

Page 4: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: main idea

Definition

Given a definite clause p1 ∧ · · · ∧ pn ⇒ c, c is called the Head.p1 ∧ · · · ∧ pn is called the Body.

BC Idea

Goal-driven algorithm.1 Unification of the goal with the head of a rule2 Propagation of the substitution to the body. Every premise

of the body is a new goal3 Apply BC recursively on the new goals...

Based on a depth-first search (DFS).

Page 5: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: algorithm

Page 6: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

GoodTeacher(Yannick)

{ x / Yannick }

Page 7: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

S1

Person(Yannick)

S5

GoodTeacher(Yannick)

{ x / Yannick }

{ }

Page 8: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

S1

Person(Yannick)

S5

GoodTeacher(Yannick)

GoodLecturesFOL(y)

{ x / Yannick }

{ }

Page 9: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

S1

Person(Yannick)

S5

S7

S2

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

{ x / Yannick }

{ }

{ y / M1 }

Page 10: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

S1

Person(Yannick)

S5

S7

S2

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

Gives(Yannick,M1,People)

{ x / Yannick }

{ }

{ y / M1 }

{ z / People }compose

Page 11: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

S1

Person(Yannick)

S5

S7

S2

GoodLecturesLogic(M1)

S2

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

Gives(Yannick,M1,People)

{ x / Yannick }

{ }

{ y / M1 }

{ z / People }compose

{ }

Page 12: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

S1

Person(Yannick)

S5

S7

S2

GoodLecturesLogic(M1) Have(People,M1)

S2

S3

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

S2

Gives(Yannick,M1,People)

{ x / Yannick }

{ }

{ y / M1 }

{ z / People }compose

{ }{ }

Page 13: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

Students(People)

S1

Person(Yannick)

S5

S7

S2

GoodLecturesLogic(M1) Have(People,M1)

S2

S3

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

S2

Gives(Yannick,M1,People)

{ x / Yannick }

{ }

{ y / M1 }

{ z / People }compose compose

{ }{ }

Page 14: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

Study(People, ANU)

Students(People)

S4

S6

S1

Person(Yannick)

S5

S7

S2

GoodLecturesLogic(M1) Have(People,M1)

S2

S3

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

S2

Gives(Yannick,M1,People)

{ x / Yannick }

{ }

{ y / M1 }

{ z / People }compose compose

{ }{ }{ }

Page 15: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Backward chaining: DFS-tree

Example

Study(People, ANU)

Students(People)

S4

S6

S1

Person(Yannick)

S5

S7

S2

GoodLecturesLogic(M1) Have(People,M1)

S2

S3

GoodTeacher(Yannick)

GoodLecturesFOL(y)

GoodLecturesLogic(M1)

S2

Gives(Yannick,M1,People)

{ x / Yannick }

{ }

{ y / M1 }

{ z / People }compose compose

{ }{ }{ }

Answer = { x / Yannick, y / M1, z / People }

Page 16: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Properties of BC

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

Incomplete due to infinite loops (DFS). To fix that, we have tocheck the current goal against every goal in the stack.

Inefficient due to repeated subgoals. To fix that we must use acache of previous results (memoization)

So what? If BC is not so good, why do we talk about it? Well, itis widely used and with good optimisations it works! (linearalgorithm): PROLOG

Page 17: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Outline

1 Backward chaining

2 Resolution

Page 18: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example

Everyone who loves all animals is loved by someone. Anyonewho kills an animal is loved by no one. Jack loves all animals.Either Jack or Curiosity killed the cat, who is named Tuna.

Did Curiosity kill the cat?

Page 19: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

Page 20: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

Page 21: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

Page 22: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

Page 23: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

Page 24: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

Page 25: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Page 26: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Page 27: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Tuna is a cat

Page 28: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Tuna is a cat

Cat(Tuna)

Page 29: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Tuna is a cat

Cat(Tuna)

A cat is an animal

Page 30: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Tuna is a cat

Cat(Tuna)

A cat is an animal

∀x Cat(x) ⇒ Animal(x)

Page 31: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Tuna is a cat

Cat(Tuna)

A cat is an animal

∀x Cat(x) ⇒ Animal(x)

Question: Did Curiosity kill the cat?

Page 32: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Another Knowledge base

Example“Everyone who loves all animals is loved by someone.”

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

“Anyone who kills an animal is loved by no one..”

∀x [∃yAnimal(y) ∧ Kills(x , y)] ⇒ [∀z ¬Loves(z, x)]

“Jack loves all animals”

∀x Animal(x) ⇒ Loves(Jack , x)

“Either Jack or Curiosity killed the cat, who is named Tuna”

Kills(Jack , Tuna) ∨ Kills(Curiosity , Tuna)

Tuna is a cat

Cat(Tuna)

A cat is an animal

∀x Cat(x) ⇒ Animal(x)

Question: Did Curiosity kill the cat?

Kills(Curiosity , Tuna)

Page 33: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conjunctive Normal Form for FOL

Conjuntive Normal Form

A sentence in a Conjunctive Normal Form is a conjunction ofclauses, each clause is a disjunction of literals.

Property

Every sentence in FOL (without equality) is logically equivalentto a FOL-CNF sentence.

Example

“Everyone who loves all animals is loved by someone”∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

has the following CNF[Animal(F (x)) ∨ Loves(G(x), x)] ∧ [¬Loves(x , F (x)) ∨ Loves(G(x), x)].

Page 34: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF

Method1 Elimination of implications

A ⇒ B ≡ ¬A ∨ B

2 Move ¬ inwards3 Standardize variables4 Skolemisation5 Drop the universal quantifiers6 Distribute ∨ over ∧

Page 35: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Move ¬ inwards and variable standardization

Rules for negated quantifiers

¬∀x p ≡ ∃x ¬p

¬∃x p ≡ ∀x ¬p

Variable standardization

(∀x P(x)) ∨ (∃x Q(x))

x is used twice but it does not represent the same thing (twodiffrent scopes). To avoid confusion, we rename:

(∀x P(x)) ∨ (∃y Q(y))

Page 36: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Skolemization

Definition

Skolemisation is the process of removing existential quantifiersby elimination.

Simple case = Existential Instanciation

Complex case = Use of Skolem functions

Example

Simple case: ∃x P(x)Using EI, we have: P(A)

Complex case: ∀x [∃y P(x , y)]Using EI, we have: ∀x P(x , A) wrongUse of a Skolem function F (x): ∀x P(x , F (x))(y in is the scope of x)

Page 37: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

Page 38: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

Page 39: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]

Page 40: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]∀x [∃y ¬¬Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)] (DeMorgan)

Page 41: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]∀x [∃y ¬¬Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)] (DeMorgan)∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)](double negation)

Page 42: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]∀x [∃y ¬¬Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)] (DeMorgan)∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)](double negation)

3 Standardize variables:∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃z Loves(z, x)]

Page 43: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]∀x [∃y ¬¬Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)] (DeMorgan)∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)](double negation)

3 Standardize variables:∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃z Loves(z, x)]

4 Skolemization: ∀x [Animal(F (x))∧¬Loves(x , F (x))]∨ [Loves(G(x), x)]

Page 44: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]∀x [∃y ¬¬Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)] (DeMorgan)∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)](double negation)

3 Standardize variables:∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃z Loves(z, x)]

4 Skolemization: ∀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)]

Page 45: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Conversion to CNF: example

Example

∀x [∀y Animal(y) ⇒ Loves(x , y)] ⇒ [∃y Loves(y , x)]

1 Eliminate implications:∀x [¬∀y ¬Animal(y) ∨ Loves(x , y)] ∨ [∃y Loves(y , x)]

2 Move ¬ inwards

∀x [∃y ¬(¬Animal(y) ∨ Loves(x , y))] ∨ [∃y Loves(y , x)]∀x [∃y ¬¬Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)] (DeMorgan)∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃y Loves(y , x)](double negation)

3 Standardize variables:∀x [∃y Animal(y) ∧ ¬Loves(x , y)] ∨ [∃z Loves(z, x)]

4 Skolemization: ∀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 46: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution: inference rule

Rule

`1 ∨ · · · ∨ `i ∨ · · · ∨ `k , `′1 ∨ · · · ∨ `′j ∨ · · · ∨ `′n

SUBST(θ, `1 ∨ · · · ∨ `i−1 ∨ `i+1 ∨ · · · ∨ `k ∨ `′1 ∨ · · · ∨ `′j−1 ∨ `′j+1 ∨ · · · ∨ `′n)

with θ a substitution such that UNIFY( `i ,¬ `′j ) = θ

Example

[Animal(F (x)) ∨ Loves(G(x), x)] [¬Loves(u, v) ∨ ¬Kills(u, v)]

Page 47: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution: inference rule

Rule

`1 ∨ · · · ∨ `i ∨ · · · ∨ `k , `′1 ∨ · · · ∨ `′j ∨ · · · ∨ `′n

SUBST(θ, `1 ∨ · · · ∨ `i−1 ∨ `i+1 ∨ · · · ∨ `k ∨ `′1 ∨ · · · ∨ `′j−1 ∨ `′j+1 ∨ · · · ∨ `′n)

with θ a substitution such that UNIFY( `i ,¬ `′j ) = θ

Example

[Animal(F (x)) ∨ Loves(G(x), x) ] [ ¬Loves(u, v) ∨ ¬Kills(u, v)]

Page 48: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution: inference rule

Rule

`1 ∨ · · · ∨ `i ∨ · · · ∨ `k , `′1 ∨ · · · ∨ `′j ∨ · · · ∨ `′n

SUBST(θ, `1 ∨ · · · ∨ `i−1 ∨ `i+1 ∨ · · · ∨ `k ∨ `′1 ∨ · · · ∨ `′j−1 ∨ `′j+1 ∨ · · · ∨ `′n)

with θ a substitution such that UNIFY( `i ,¬ `′j ) = θ

Example

[Animal(F (x)) ∨ Loves(G(x), x) ] [ ¬Loves(u, v) ∨ ¬Kills(u, v)]

SUBST(θ, Animal(F (x)) ∨ ¬Kills(u, v))

Page 49: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution: inference rule

Rule

`1 ∨ · · · ∨ `i ∨ · · · ∨ `k , `′1 ∨ · · · ∨ `′j ∨ · · · ∨ `′n

SUBST(θ, `1 ∨ · · · ∨ `i−1 ∨ `i+1 ∨ · · · ∨ `k ∨ `′1 ∨ · · · ∨ `′j−1 ∨ `′j+1 ∨ · · · ∨ `′n)

with θ a substitution such that UNIFY( `i ,¬ `′j ) = θ

Example

[Animal(F (x)) ∨ Loves(G(x), x) ] [ ¬Loves(u, v) ∨ ¬Kills(u, v)]

SUBST(θ, Animal(F (x)) ∨ ¬Kills(u, v))

θ = {u/G(x), v/x}

Page 50: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution: inference rule

Rule

`1 ∨ · · · ∨ `i ∨ · · · ∨ `k , `′1 ∨ · · · ∨ `′j ∨ · · · ∨ `′n

SUBST(θ, `1 ∨ · · · ∨ `i−1 ∨ `i+1 ∨ · · · ∨ `k ∨ `′1 ∨ · · · ∨ `′j−1 ∨ `′j+1 ∨ · · · ∨ `′n)

with θ a substitution such that UNIFY( `i ,¬ `′j ) = θ

Example

[Animal(F (x)) ∨ Loves(G(x), x) ] [ ¬Loves(u, v) ∨ ¬Kills(u, v)]

Animal(F (x)) ∨ ¬Kills(G(x), x)

θ = {u/G(x), v/x}

Page 51: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution algorithm

Definition

Proof by contradiction: given KB, to prove α, we prove thatKB ∧ ¬α is not satisfiable.

Page 52: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Resolution: example

Resolution Proof that Curiosity has killed the cat:

¬α is ¬Kills(Curiosity , Tuna)

Use of the factoring rule to infer Loves(G(Jack), Jack)

Page 53: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Dealing with equality

Paramodulation

There are several ways to deal with t1 = t2. One of them isParamodulation:

`1 ∨ · · · ∨ `k ∨ t1 = t2, `′1 ∨ · · · ∨ `′

n[t3]SUBST(θ, `1 ∨ · · · ∨ `′

n[y ])

whereUNIFY (t1, t3) = θ

This inference rule can be used during the resolution algorithm.

Example

Father(John) = Father(Richard) Male(Father(x))

Male(Father(Richard))

θ = {x/John} = UNIFY(Father(John), Father(x))

Page 54: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Theorem provers

Unlike logic programming language, Theorem provers cover FOL (norestriction on Definite Clauses). Their algorithm is based on resolution.Theorem prover: OTTER

Optimisations

Using the resolution algorithm in a “clever” way.

Unit preference: Inference of sentences with a minimal number ofliterals (more chance to get the empty clause)

Set of support: What is the set of clauses in KB that will be useful?

Input resolution: Always using a sentence from KB or α to apply theresolution rule.

Subsumption: Elimination of sentences that are subsumed by (morespecific than) an existing sentence in the KB.

Page 55: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Completeness of resolution

Resolution can find a contradiction in S’

There is a resolution proof for the contradiction in S

Herbrand’s theorem

Some set S’ of ground instances is unsatisfiable

Any set of sentences S is representable in clausal form

Assume S is unsatisfiable, and in clausal form

Lifting lemma

Ground resolution theorem

Page 56: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

Summary

Inference in FOL

Propositionalisation: very slow

Unification techniques: much more efficientGeneralised Modus Ponens: FC and BC on Definiteclauses

FC for deductive databasesBC for logic programming

Entailement problem is semi-decidable

Generalised resolution: complete proof system (CNF)

Page 57: KRR3: Inference in First-order logic 2 - LAAS[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]. Conversion to CNF Method 1 Elimination of implications A ⇒

To Infinity and Beyond!

A dream

Using theorem proving to automatically prove everything...

A first step

To prove everything, we need to prove everything in arithmetic...

Arithmetic

Logic for arithmetic: 0, S(..), ×, +, Expt (extension of FOL, more expressive)

Godel’s incompleteness theorem

Godel said (after a proof on 30 pages):“Whatever your logic is, if your logic can express arithmetic, whatever yourKB is, I can exhibit a sentence in your logic such that the sentence is entailedby KB but there’s no way to prove it by inference thanks to your KB”

The reality

Sorry for the inconvenience...