Knowledge Representation (II) Paolo Turrini Department of - - PowerPoint PPT Presentation

knowledge representation ii
SMART_READER_LITE
LIVE PREVIEW

Knowledge Representation (II) Paolo Turrini Department of - - PowerPoint PPT Presentation

Intro to AI Knowledge Representation (II) Paolo Turrini Department of Computing, Imperial College London Introduction to Artificial Intelligence Paolo Turrini Intro to AI Intro to AI The main reference Stuart Russell and Peter Norvig


slide-1
SLIDE 1

Intro to AI

Knowledge Representation (II)

Paolo Turrini

Department of Computing, Imperial College London

Introduction to Artificial Intelligence

Paolo Turrini Intro to AI

slide-2
SLIDE 2

Intro to AI

The main reference

Stuart Russell and Peter Norvig Artificial Intelligence: a modern approach Chapter 9

Paolo Turrini Intro to AI

slide-3
SLIDE 3

Intro to AI

Today’s class

Start with a knowledge base and try to prove something interesting Various methods for doing so, with different computational properties

Paolo Turrini Intro to AI

slide-4
SLIDE 4

Intro to AI

Artificial Intelligence and Law

The formalization of legislation and the development of computer systems to assist with legal problem solving provide a rich domain for developing and testing artificial-intelligence technology. Marek Sergot, Fariba Sadri, Robert Kowalski, (and others) The British Nationality Act as a logic program Communications of the ACM, 1986

Paolo Turrini Intro to AI

slide-5
SLIDE 5

Intro to AI

An informal knowledge base

The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy

  • f America, has some missiles, and all of its missiles were

sold to it by Colonel West, who is American.

Paolo Turrini Intro to AI

slide-6
SLIDE 6

Intro to AI

An informal knowledge base

The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy

  • f America, has some missiles, and all of its missiles were

sold to it by Colonel West, who is American. Prove that Colonel West is a criminal

Paolo Turrini Intro to AI

slide-7
SLIDE 7

Intro to AI

Example knowledge base contd.

. . . it is a crime for an American to sell weapons to hostile nations:

Paolo Turrini Intro to AI

slide-8
SLIDE 8

Intro to AI

Example knowledge base contd.

. . . it is a crime for an American to sell weapons to hostile nations: American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x)

Paolo Turrini Intro to AI

slide-9
SLIDE 9

Intro to AI

Example knowledge base contd.

. . . it is a crime for an American to sell weapons to hostile nations: American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) Nono . . . has some missiles

Paolo Turrini Intro to AI

slide-10
SLIDE 10

Intro to AI

Example knowledge base contd.

. . . it is a crime for an American to sell weapons to hostile nations: American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) Nono . . . has some missiles Owns(Nono, M1) and Missile(M1)

Paolo Turrini Intro to AI

slide-11
SLIDE 11

Intro to AI

Example knowledge base contd.

. . . it is a crime for an American to sell weapons to hostile nations: American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) Nono . . . has some missiles Owns(Nono, M1) and Missile(M1) . . . all of its missiles were sold to it by Colonel West

Paolo Turrini Intro to AI

slide-12
SLIDE 12

Intro to AI

Example knowledge base contd.

. . . it is a crime for an American to sell weapons to hostile nations: American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) Nono . . . has some missiles Owns(Nono, M1) and Missile(M1) . . . all of its missiles were sold to it by Colonel West ∀ x Missile(x) ∧ Owns(Nono, x) ⇒ Sells(West, x, Nono)

Paolo Turrini Intro to AI

slide-13
SLIDE 13

Intro to AI

Example knowledge base contd.

Missiles are weapons:

Paolo Turrini Intro to AI

slide-14
SLIDE 14

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x)

Paolo Turrini Intro to AI

slide-15
SLIDE 15

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x) An enemy of America ”counts as” hostile:

Paolo Turrini Intro to AI

slide-16
SLIDE 16

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x) An enemy of America ”counts as” hostile: Enemy(x, America) ⇒ Hostile(x)

Paolo Turrini Intro to AI

slide-17
SLIDE 17

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x) An enemy of America ”counts as” hostile: Enemy(x, America) ⇒ Hostile(x) West, who is American.

Paolo Turrini Intro to AI

slide-18
SLIDE 18

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x) An enemy of America ”counts as” hostile: Enemy(x, America) ⇒ Hostile(x) West, who is American. American(West)

Paolo Turrini Intro to AI

slide-19
SLIDE 19

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x) An enemy of America ”counts as” hostile: Enemy(x, America) ⇒ Hostile(x) West, who is American. American(West) The country Nono, an enemy of America . . .

Paolo Turrini Intro to AI

slide-20
SLIDE 20

Intro to AI

Example knowledge base contd.

Missiles are weapons: Missile(x) ⇒ Weapon(x) An enemy of America ”counts as” hostile: Enemy(x, America) ⇒ Hostile(x) West, who is American. American(West) The country Nono, an enemy of America . . . Enemy(Nono, America)

Paolo Turrini Intro to AI

slide-21
SLIDE 21

Intro to AI

Forward chaining proof

Paolo Turrini Intro to AI

slide-22
SLIDE 22

Intro to AI

Forward chaining proof

Paolo Turrini Intro to AI

slide-23
SLIDE 23

Intro to AI

Forward chaining proof

Paolo Turrini Intro to AI

slide-24
SLIDE 24

Intro to AI

Footage from Tuesday

Paolo Turrini Intro to AI

slide-25
SLIDE 25

Intro to AI

GMP: recall...

Definite clause: disjunction of literals, exactly one of which positive e.g., (p1 ∧ p2 ∧ . . . ∧ pn ⇒ q)

p1′, p2′, . . . , pn′, (p1 ∧ p2 ∧ . . . ∧ pn ⇒ q) qθ where pi ′θ = piθ for all i

Assuming all variables are universally quantified...

p1′ is King(Joffrey) p1 is King(x) p2′ is Greedy(y) p2 is Greedy(x) θ is {x/Joffrey, y/Joffrey} q is Evil(x) qθ is Evil(Joffrey)

Paolo Turrini Intro to AI

slide-26
SLIDE 26

Intro to AI

Forward chaining algorithm

Paolo Turrini Intro to AI

function FOL-FC-Ask(KB,α) returns a substitution or false inputs: KB, the knowledge base, a set of definite clauses α, the (atomic) query local variables: new, the new sentences inferred at each iteration repeat until new is empty new ← { } for each sentence r in KB do ( p1 ∧ . . . ∧ pn ⇒ q) ← Standardize-Apart(r) for each θ such that (p1 ∧ . . . ∧ pn)θ = (p′

1 ∧ . . . ∧ p′ n)θ

for some p′

1, . . . , p′ n in KB do

q′ ← qθ if q′ does not already unify in KB or new then add q′ to new φ ← Unify(q′,α) if φ is not fail then return φ add new to KB return false

slide-27
SLIDE 27

Intro to AI

First iteration

On the first iteration... American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x)

Paolo Turrini Intro to AI

slide-28
SLIDE 28

Intro to AI

First iteration

On the first iteration... American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) has unsatisfied premises

Paolo Turrini Intro to AI

slide-29
SLIDE 29

Intro to AI

First iteration

∀ x Missile(x) ∧ Owns(Nono, x) ⇒ Sells(West, x, Nono)

Paolo Turrini Intro to AI

slide-30
SLIDE 30

Intro to AI

First iteration

∀ x Missile(x) ∧ Owns(Nono, x) ⇒ Sells(West, x, Nono) is satisfied with {x/M1} and Sells(West, M1, Nono) is added

Paolo Turrini Intro to AI

slide-31
SLIDE 31

Intro to AI

First iteration

Missile(x) ⇒ Weapon(x)

Paolo Turrini Intro to AI

slide-32
SLIDE 32

Intro to AI

First iteration

Missile(x) ⇒ Weapon(x) is satisfied with {x/M1} and Weapon(M1) is added

Paolo Turrini Intro to AI

slide-33
SLIDE 33

Intro to AI

First iteration

Enemy(x, America) ⇒ Hostile(x)

Paolo Turrini Intro to AI

slide-34
SLIDE 34

Intro to AI

First iteration

Enemy(x, America) ⇒ Hostile(x) is satisfied with {x/Nono} and Hostile(Nono) is added

Paolo Turrini Intro to AI

slide-35
SLIDE 35

Intro to AI

First iteration

So in total we have added...

Paolo Turrini Intro to AI

slide-36
SLIDE 36

Intro to AI

First iteration

So in total we have added... Sells(West, M1, Nono)

Paolo Turrini Intro to AI

slide-37
SLIDE 37

Intro to AI

First iteration

So in total we have added... Sells(West, M1, Nono) Weapon(M1)

Paolo Turrini Intro to AI

slide-38
SLIDE 38

Intro to AI

First iteration

So in total we have added... Sells(West, M1, Nono) Weapon(M1) Hostile(Nono)

Paolo Turrini Intro to AI

slide-39
SLIDE 39

Intro to AI

Second iteration

On the second iteration...

Paolo Turrini Intro to AI

slide-40
SLIDE 40

Intro to AI

Second iteration

On the second iteration... American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x)

Paolo Turrini Intro to AI

slide-41
SLIDE 41

Intro to AI

Second iteration

On the second iteration... American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) is satisfied with {x/West, y/M1, z/Nono} and Criminal(West) is added

Paolo Turrini Intro to AI

slide-42
SLIDE 42

Intro to AI

Second iteration

On the second iteration... American(x)∧Weapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x) is satisfied with {x/West, y/M1, z/Nono} and Criminal(West) is added Yay! :)

Paolo Turrini Intro to AI

slide-43
SLIDE 43

Intro to AI

Forward chaining proof

Paolo Turrini Intro to AI

slide-44
SLIDE 44

Intro to AI

Forward chaining proof

Paolo Turrini Intro to AI

slide-45
SLIDE 45

Intro to AI

Forward chaining proof

Paolo Turrini Intro to AI

slide-46
SLIDE 46

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP)

Paolo Turrini Intro to AI

slide-47
SLIDE 47

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP) Complete for first-order (entailed!) definite clauses

Paolo Turrini Intro to AI

slide-48
SLIDE 48

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP) Complete for first-order (entailed!) definite clauses May not terminate in general if α is not entailed

Paolo Turrini Intro to AI

slide-49
SLIDE 49

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP) Complete for first-order (entailed!) definite clauses May not terminate in general if α is not entailed It’s inefficient:

Paolo Turrini Intro to AI

slide-50
SLIDE 50

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP) Complete for first-order (entailed!) definite clauses May not terminate in general if α is not entailed It’s inefficient:

but there can be improvements

Paolo Turrini Intro to AI

slide-51
SLIDE 51

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP) Complete for first-order (entailed!) definite clauses May not terminate in general if α is not entailed It’s inefficient:

but there can be improvements well... matching conjunctive premises against known facts is NP-hard

Paolo Turrini Intro to AI

slide-52
SLIDE 52

Intro to AI

Properties of forward chaining

Sound (because of soundness of GMP) Complete for first-order (entailed!) definite clauses May not terminate in general if α is not entailed It’s inefficient:

but there can be improvements well... matching conjunctive premises against known facts is NP-hard

Forward chaining is widely used in deductive databases

Paolo Turrini Intro to AI

slide-53
SLIDE 53

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-54
SLIDE 54

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-55
SLIDE 55

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-56
SLIDE 56

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-57
SLIDE 57

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-58
SLIDE 58

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-59
SLIDE 59

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-60
SLIDE 60

Intro to AI

Backward chaining algorithm

Paolo Turrini Intro to AI

function FOL-BC-Ask(KB,goals,θ) returns a set of substitutions inputs: KB, a knowledge base goals, a list of conjuncts forming a query (θ already applied) θ, the current substitution, initially the empty substitution { } local variables: answers, a set of substitutions, initially empty if goals is empty then return {θ} q′ ← First(goals)θ for each sentence r in KB where Standardize-Apart(r) = ( p1 ∧ . . . ∧ pn ⇒ q) and θ′ ← Unify(q,q′) succeeds new goals ← [ p1, . . . , pn|Rest(goals)] answers ← FOL-BC-Ask(KB,new goals,Compose(θ′,θ)) ∪ answers return answers

slide-61
SLIDE 61

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-62
SLIDE 62

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-63
SLIDE 63

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-64
SLIDE 64

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-65
SLIDE 65

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-66
SLIDE 66

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-67
SLIDE 67

Intro to AI

Backward chaining example

Paolo Turrini Intro to AI

slide-68
SLIDE 68

Intro to AI

Properties of backward chaining

Depth-first recursive proof search

Paolo Turrini Intro to AI

slide-69
SLIDE 69

Intro to AI

Properties of backward chaining

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

Paolo Turrini Intro to AI

slide-70
SLIDE 70

Intro to AI

Properties of backward chaining

Depth-first recursive proof search space is linear in size of proof Incomplete due to infinite loops

Paolo Turrini Intro to AI

slide-71
SLIDE 71

Intro to AI

Properties of backward chaining

Depth-first recursive proof search space is linear in size of proof Incomplete due to infinite loops Widely used for logic programming

Paolo Turrini Intro to AI

slide-72
SLIDE 72

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

Paolo Turrini Intro to AI

slide-73
SLIDE 73

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

For example, ¬Rich(x) ∨ Unhappy(x)

Paolo Turrini Intro to AI

slide-74
SLIDE 74

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

For example, ¬Rich(x) ∨ Unhappy(x) Rich(Berlusconi)

Paolo Turrini Intro to AI

slide-75
SLIDE 75

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

For example, ¬Rich(x) ∨ Unhappy(x) Rich(Berlusconi) Unhappy(Berlusconi)

Paolo Turrini Intro to AI

slide-76
SLIDE 76

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

For example, ¬Rich(x) ∨ Unhappy(x) Rich(Berlusconi) Unhappy(Berlusconi)

Paolo Turrini Intro to AI

slide-77
SLIDE 77

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

For example, ¬Rich(x) ∨ Unhappy(x) Rich(Berlusconi) Unhappy(Berlusconi) with θ = {x/Berlusconi}

Paolo Turrini Intro to AI

slide-78
SLIDE 78

Intro to AI

Resolution

Full first-order version:

ℓ1 ∨ · · · ∨ ℓk, m1 ∨ · · · ∨ mn (ℓ1 ∨ · · · ∨ ℓi−1 ∨ ℓi+1 ∨ · · · ∨ ℓk ∨ m1 ∨ · · · ∨ mj−1 ∨ mj+1 ∨ · · · ∨ mn)θ where Unify(ℓi, ¬mj) = θ.

For example, ¬Rich(x) ∨ Unhappy(x) Rich(Berlusconi) Unhappy(Berlusconi) with θ = {x/Berlusconi} Apply resolution steps to CNF(KB ∧ ¬α)

Paolo Turrini Intro to AI

slide-79
SLIDE 79

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone:

Paolo Turrini Intro to AI

slide-80
SLIDE 80

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

Paolo Turrini Intro to AI

slide-81
SLIDE 81

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

Paolo Turrini Intro to AI

slide-82
SLIDE 82

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

∀ x [¬∀ y ¬Pizza(y) ∨ Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

Paolo Turrini Intro to AI

slide-83
SLIDE 83

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

∀ x [¬∀ y ¬Pizza(y) ∨ Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

  • 2. Move ¬ inwards: ¬∀ xϕ

≡ ∃ x ¬ϕ, ¬∃ xϕ ≡ ∀ x ¬ϕ:

Paolo Turrini Intro to AI

slide-84
SLIDE 84

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

∀ x [¬∀ y ¬Pizza(y) ∨ Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

  • 2. Move ¬ inwards: ¬∀ xϕ

≡ ∃ x ¬ϕ, ¬∃ xϕ ≡ ∀ x ¬ϕ: ∀ x [∃ y ¬(¬Pizza(y) ∨ Dislikes(x, y))] ∨ [∃ y Dislikes(y, x)]

Paolo Turrini Intro to AI

slide-85
SLIDE 85

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

∀ x [¬∀ y ¬Pizza(y) ∨ Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

  • 2. Move ¬ inwards: ¬∀ xϕ

≡ ∃ x ¬ϕ, ¬∃ xϕ ≡ ∀ x ¬ϕ: ∀ x [∃ y ¬(¬Pizza(y) ∨ Dislikes(x, y))] ∨ [∃ y Dislikes(y, x)] ∀ x [∃ y ¬¬Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

Paolo Turrini Intro to AI

slide-86
SLIDE 86

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

∀ x [¬∀ y ¬Pizza(y) ∨ Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

  • 2. Move ¬ inwards: ¬∀ xϕ

≡ ∃ x ¬ϕ, ¬∃ xϕ ≡ ∀ x ¬ϕ: ∀ x [∃ y ¬(¬Pizza(y) ∨ Dislikes(x, y))] ∨ [∃ y Dislikes(y, x)] ∀ x [∃ y ¬¬Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)] ∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

Paolo Turrini Intro to AI

slide-87
SLIDE 87

Intro to AI

Conversion to CNF

Everyone who dislikes pizzas is disliked by someone: ∀ x [∀ y Pizza(y) ⇒ Dislikes(x, y)] ⇒ [∃ y Dislikes(y, x)]

  • 1. Eliminate biconditionals and implications

∀ x [¬∀ y ¬Pizza(y) ∨ Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

  • 2. Move ¬ inwards: ¬∀ xϕ

≡ ∃ x ¬ϕ, ¬∃ xϕ ≡ ∀ x ¬ϕ: ∀ x [∃ y ¬(¬Pizza(y) ∨ Dislikes(x, y))] ∨ [∃ y Dislikes(y, x)] ∀ x [∃ y ¬¬Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)] ∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ y Dislikes(y, x)]

Paolo Turrini Intro to AI

slide-88
SLIDE 88

Intro to AI

Conversion to CNF contd.

  • 3. Standardise variables: each quantifier should use a different one

Paolo Turrini Intro to AI

slide-89
SLIDE 89

Intro to AI

Conversion to CNF contd.

  • 3. Standardise variables: each quantifier should use a different one

∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ z Dislikes(z, x)]

Paolo Turrini Intro to AI

slide-90
SLIDE 90

Intro to AI

Conversion to CNF contd.

  • 3. Standardise variables: each quantifier should use a different one

∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ z Dislikes(z, x)]

  • 4. Skolemize: a more general form of existential instantiation.

Paolo Turrini Intro to AI

slide-91
SLIDE 91

Intro to AI

Conversion to CNF contd.

  • 3. Standardise variables: each quantifier should use a different one

∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ z Dislikes(z, x)]

  • 4. Skolemize: a more general form of existential instantiation.

Each existential variable is replaced by a Skolem function

Paolo Turrini Intro to AI

slide-92
SLIDE 92

Intro to AI

Conversion to CNF contd.

  • 3. Standardise variables: each quantifier should use a different one

∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ z Dislikes(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:

Paolo Turrini Intro to AI

slide-93
SLIDE 93

Intro to AI

Conversion to CNF contd.

  • 3. Standardise variables: each quantifier should use a different one

∀ x [∃ y Pizza(y) ∧ ¬Dislikes(x, y)] ∨ [∃ z Dislikes(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 [Pizza(F(x)) ∧ ¬Dislikes(x, F(x))] ∨ Dislikes(G(x), x)

Paolo Turrini Intro to AI

slide-94
SLIDE 94

Intro to AI

Conversion to CNF contd.

  • 5. Drop universal quantifiers:

[Pizza(F(x)) ∧ ¬Dislikes(x, F(x))] ∨ Dislikes(G(x), x)

Paolo Turrini Intro to AI

slide-95
SLIDE 95

Intro to AI

Conversion to CNF contd.

  • 5. Drop universal quantifiers:

[Pizza(F(x)) ∧ ¬Dislikes(x, F(x))] ∨ Dislikes(G(x), x)

  • 6. Distribute ∧ over ∨:

[Pizza(F(x)) ∨ Dislikes(G(x), x)]∧ ∧[¬Dislikes(x, F(x)) ∨ Dislikes(G(x), x)]

Paolo Turrini Intro to AI

slide-96
SLIDE 96

Intro to AI

Resolution proof: definite clauses

Paolo Turrini Intro to AI

slide-97
SLIDE 97

Intro to AI

What we have seen

Inference methods with different structure and properties Forward-chaining (deductive databases) Backward-chaining (logic programming) Resolution (full-first order logic)

Paolo Turrini Intro to AI

slide-98
SLIDE 98

Intro to AI

Coming next

Knowledge and uncertainty: what if we don’t know exactly? How to handle uncertain information:

representation reasoning

Paolo Turrini Intro to AI

slide-99
SLIDE 99

Intro to AI

Appendix: Universal Instantiation

Every instantiation of a universally quantified sentence is entailed by it: ∀ v α α({v/g}) for any variable v and ground term g

Paolo Turrini Intro to AI

slide-100
SLIDE 100

Intro to AI

Appendix: Universal Instantiation

Every instantiation of a universally quantified sentence is entailed by it: ∀ v α α({v/g}) for any variable v and ground term g E.g., ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x) yields

Paolo Turrini Intro to AI

slide-101
SLIDE 101

Intro to AI

Appendix: Universal Instantiation

Every instantiation of a universally quantified sentence is entailed by it: ∀ v α α({v/g}) for any variable v and ground term g E.g., ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x) yields

King(Joffrey) ∧ Greedy(Joffrey) ⇒ Evil(Joffrey) King(Aerys) ∧ Greedy(Aerys) ⇒ Evil(Aerys) King(Father(Joffrey)) ∧ Greedy(Father(Joffrey)) ⇒ Evil(Father(Joffrey)) . . .

Paolo Turrini Intro to AI

slide-102
SLIDE 102

Intro to AI

Appendix: Existential instantiation (EI)

For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: ∃ v α α({v/g})

Paolo Turrini Intro to AI

slide-103
SLIDE 103

Intro to AI

Appendix: Existential instantiation (EI)

For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: ∃ v α α({v/g}) E.g., ∃ x Crown(x) ∧ OnHead(x, John) yields

Paolo Turrini Intro to AI

slide-104
SLIDE 104

Intro to AI

Appendix: Existential instantiation (EI)

For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: ∃ v α α({v/g}) E.g., ∃ x Crown(x) ∧ OnHead(x, John) yields Crown(C1) ∧ OnHead(C1, John)

Paolo Turrini Intro to AI

slide-105
SLIDE 105

Intro to AI

Appendix: Existential instantiation (EI)

For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: ∃ v α α({v/g}) E.g., ∃ x Crown(x) ∧ OnHead(x, John) yields Crown(C1) ∧ OnHead(C1, John) provided C1 is a new constant symbol, called a Skolem constant

Paolo Turrini Intro to AI

slide-106
SLIDE 106

Intro to AI

Appendix: Existential instantiation contd.

UI can be applied several times to add new sentences; the new KB is logically equivalent to the old

Paolo Turrini Intro to AI

slide-107
SLIDE 107

Intro to AI

Appendix: Existential instantiation contd.

UI can be applied several times to add new sentences; the new KB is logically equivalent to the old EI can be applied once to replace the existential sentence;

Paolo Turrini Intro to AI

slide-108
SLIDE 108

Intro to AI

Appendix: Existential instantiation contd.

UI can be applied several times to add new sentences; the new KB is logically equivalent to the old EI can be applied once to replace the existential sentence; the new KB is not equivalent to the old,

Paolo Turrini Intro to AI

slide-109
SLIDE 109

Intro to AI

Appendix: Existential instantiation contd.

UI can be applied several times to add new sentences; the new KB is logically equivalent to the old EI can be applied once to replace the existential sentence; the new KB is not equivalent to the old, but is satisfiable iff the old KB was satisfiable

Paolo Turrini Intro to AI