0 evaluări0% au considerat acest document util (0 voturi)

44 vizualizări62 paginiARTIFICIAL INTELLIGENCE

Jan 17, 2016

© © All Rights Reserved

PPTX, PDF, TXT sau citiți online pe Scribd

ARTIFICIAL INTELLIGENCE

© All Rights Reserved

0 evaluări0% au considerat acest document util (0 voturi)

44 vizualizări62 paginiARTIFICIAL INTELLIGENCE

© All Rights Reserved

Sunteți pe pagina 1din 62

&

INFERENCE IN FIRST ORDER LOGIC

By

Predicate Logic

C.PABITHA., AP

1/17/16

Propositional Logic

Propositional logic isnt powerful enough as a

an exam they either pass or fail.

Find Pits in Wumpus world

Bx,y (Px,y+1 Px,y-1 Px+1,y Px-1,y) (Breeze next to Pit)

16 rules

Find Wumpus

Sx,y (Wx,y+1 Wx,y-1 Wx+1,y Wx-1,y) (stench next to Wumpus) 16 rules

At least one Wumpus in world

W1,1 W1,2 W4,4 (at least 1 Wumpus) 1 rule

At most one Wumpus

W1,1 W1,2 (155 RULES)

Predicate Logic

1/17/16

More expressive logic than propositional

Constants are objects: john, apples

likes(john, apples)

Functions transform objects:

likes(john, fruit_of(apple_tree))

Variables represent any object: likes(X, apples)

True for all objects (Universal):

X. likes(X, apples)

Exists at least one object (Existential): X. likes(X, apples)

First-order logic

Whereas propositional logic assumes the world

contains facts,

first-order logic (like natural language) assumes

the world contains

games, wars,

Functions: father of, best friend, one more than,

plus,

Predicate Logic

1/17/16

Constants King, John, 2, NUS,...

Predicates Brother, >,...

Functions

Variables

Connectives

Equality

Quantifiers

Predicate Logic

Sqrt( ), LeftLegOf,...

x, y, a, b,...

, , , ,

,

1/17/16

Terms

Term = logical expression that refers to an object.

There are 2 kinds of terms:

function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc

Pat_Grandfather(x) = father(father(x))

7

Predicate Logic

1/17/16

Atomic Sentences

Atomic sentences state facts using terms and predicate symbols

P(x,y) interpreted as x is P of y

Examples:

LargerThan(2,3) is false.

Brother_of(Mary,Pete) is false.

Married(Father(Richard), Mother(John)) could be true or false

Note: Functions do not state facts and form no sentence:

Brother(Pete) refers to John (his brother) and is neither true nor false.

Brother_of(Pete,Brother(Pete)) is True.

Binary relation

Predicate Logic

Function

1/17/16

Complex Sentences

We make complex sentences with connectives (just

property

binary

relation

function

objects

connectives

Predicate Logic

1/17/16

Universal Quantification

Allows

Can

x Person(x) => HasHead(x)

i

Note that

x King(x) Person(x) is not correct!

This would imply that all objects x are Kings and are People

x King(x) => Person(x) is the correct way to say

10

Predicate Logic

1/17/16

Existential Quantification

x means there exists an x such that.

Examples:

King(x)

Lives_in(John, Castle(x))

Integer(i) GreaterThan(i,0)

(And => is the natural connective to use with )

11

Predicate Logic

1/17/16

Typically is the main connective with

Common mistake: using as the main

connective with

12

Predicate Logic

1/17/16

Typically, is the main connective with

Common mistake: using as the main

connective with

13

Predicate Logic

1/17/16

Examples

Everyone likes McDonalds

x, likes(x, McDonalds)

Someone likes McDonalds

x, likes(x, McDonalds)

All children like McDonalds

x, child(x) likes(x, McDonalds)

Everyone likes McDonalds unless they are allergic to it

x, likes(x, McDonalds) allergic(x, McDonalds)

x, allergic (x, McDonalds) likes(x, McDonalds)

14

Predicate Logic

1/17/16

x ( Student(x) Smart(x) )

There exists a student.

x Student(x).

x ( Student(x) Smart(x) )

15

Predicate Logic

1/17/16

There is a student who is loved by every other student.

Bill is a student.

Student(Bill)

Takes(Bill, Analysis) Takes(Bill, Geometry)

Bill takes Analysis or Geometry (or both).

Bill takes Analysis and Geometry.

Bill does not take Analysis.

Takes(Bill, Analysis).

16

Predicate Logic

1/17/16

Bill has at least one sister.

x SisterOf(x,Bill)

Bill has no sister.

x SisterOf(x,Bill)

Bill has exactly one sister.

Bill has at least two sisters.

17

Predicate Logic

1/17/16

Properties of Quantifiers

x y is the same as y x

x y is the same as y x

x y Loves(x, y)

There is a person who loves everyone in the world

y x Loves(x, y)

18

Predicate Logic

1/17/16

Nesting Quantifiers

Everyone likes some kind of food

y x, food(x) likes(y, x)

x y, food(x) likes(y, x)

y x, food(x) likes(y, x)

x y, food(x) likes(y, x)

19

Predicate Logic

1/17/16

Example Domains

Kinship domain

What is a second cousin once removed, anyway?

Numbers, sets, and lists

This one is a classic. You should understand these, even if

you dont memorize them.

The Wumpus World

Note how much simpler the description is in FOL!

Whatever your domain, if the axioms correctly and

complete logical inference procedure will infer the

strongest possible description of the world, given

the available percepts

20

Predicate Logic

1/17/16

Remember:

proposition

al

logic

21

Predicate Logic

1/17/16

Reminder

Ground term: A term that does not contain a

variable.

A constant symbol

A function applies to some ground term

22

Predicate Logic

1/17/16

Proofs

23

Predicate Logic

1/17/16

Proofs

The three new inference rules for FOL (compared to propositional logic) are:

Universal Elimination (UE):

x

{x/g}

x

{x/k}

x {g/x}

24

Predicate Logic

1/17/16

Proofs

The three new inference rules for FOL (compared to propositional logic) are:

Universal Elimination (UE):

x e.g., from x Likes(x, Candy) and {x/Joe}

{x/} we can infer Likes(Joe, Candy)

x e.g., from x Kill(x, Victim) we can infer

{x/k} Kill(Murderer, Victim), if Murderer new symbol

e.g., from Likes(Joe, Candy) we can infer

x {g/x} x Likes(x, Candy)

25

Predicate Logic

1/17/16

Identify the task

26

Predicate Logic

1/17/16

The

problem instances to answers. This step is analogous to the PEAS process for designing

agents.

PEAS

PAGE

Assemble

The

work with real experts to extract what they know-a process called knowledge

acquisition

Decide

That

27

Predicate Logic

1/17/16

The knowledge engineer writes down the axioms for all the vocabulary terms. This

pins down (to the extent possible) the meaning of the terms, enabling the expert to

check the content

For a logical agent, problem instances are supplied by the sensors/ percepts

answers

Debug the knowledge base.

28

Predicate Logic

1/17/16

30

Predicate Logic

1/17/16

Every instantiation of a universally quantified sentence is

entailed by it:

v

Subst({v/g}, )

E.g., x King(x) Greedy(x) Evil(x) yields:

King(Richard) Greedy(Richard) Evil(Richard)

King(Father(John)) Greedy(Father(John)) Evil(Father(John))

.

.

.

31

Predicate Logic

1/17/16

For any sentence , variable v, and constant

the knowledge base:

v

Subst({v/k}, )

Crown(C1) OnHead(C1,John)

provided C1 is a new constant symbol, called

a Skolem constant

32

Predicate Logic

1/17/16

The law says that it is a crime for an American

Nono, an enemy America, has some missiles,

and all of its missiles were sold to it by Col.

West, who is an American.

33

it is a crime for an American to sell weapons to

hostile nations

34

it is a crime for an American to sell weapons to

hostile nations

Criminal(x)

35

it is a crime for an American to sell weapons to

hostile nations

Criminal(x)

36

it is a crime for an American to sell weapons to

hostile nations

Criminal(x)

x Owns(Nono, x) Missiles(x)

37

it is a crime for an American to sell weapons to

hostile nations

Criminal(x)

x Owns(Nono, x) Missiles(x)

all of its missiles were sold to it by Col. West

38

it is a crime for an American to sell weapons to hostile

nations

Criminal(x)

x Owns(Nono, x) Missiles(x)

Owns(Nono, M1) and Missle(M1)

x Missile(x) Owns(Nono, x) Sells( West, x, Nono)

39

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

x ,y,z American(x) Weapon(y) Sells(x,y,z) Hostile(z) Criminal(x)

Nonohas some missiles

x Owns(Nono, x) Missiles(x)

Owns(Nono, M1) and Missle(M1)

x Missle(x) Owns(Nono, x) Sells( West, x, Nono)

Missiles are weapons

Missle(x) Weapon(x)

40

An enemy of America counts as hostile

Enemy(Nono, America)

41

Unification

We can get the inference immediately if we can find a substitution such that King(x) and

Greedy(x) match King(John) and Greedy(y)

= {x/John,y/John} works

Unify(,) = if =

p q

Knows(John,x)

Knows(John,x)

Knows(John,x)

Knows(John,x)

Knows(John,Jane)

Knows(y,OJ)

Knows(y,Mother(y))

Knows(x,OJ)

{x/Jane}}

Unification

We can get the inference immediately if we can find a substitution such that King(x) and

Greedy(x) match King(John) and Greedy(y)

= {x/John,y/John} works

Unify(,) = if =

p q

Knows(John,x)

Knows(John,x)

Knows(John,x)

Knows(John,x)

Knows(John,Jane) {x/Jane}}

Knows(y,OJ) {x/OJ,y/John}}

Knows(y,Mother(y))

Knows(x,OJ)

Unification

We can get the inference immediately if we can find a substitution such that King(x) and

Greedy(x) match King(John) and Greedy(y)

= {x/John,y/John} works

Unify(,) = if =

p q

Knows(John,x)

Knows(John,x)

Knows(John,x)

Knows(John,x)

Knows(John,Jane) {x/Jane}}

Knows(y,OJ) {x/OJ,y/John}}

Knows(y,Mother(y))

{y/John,x/Mother(John)}}

Knows(x,OJ)

We can get the inference immediately if we can find a substitution such

that King(x) and Greedy(x) match King(John) and Greedy(y)

= {x/John,y/John} works

Unify(,) = if =

p q

Knows(John,x)

Knows(John,x)

Knows(John,Jane)

{x/Jane}}

Knows(y,OJ) {x/OJ,y/John}}

Knows(John,x)

Knows(John,x)

Knows(y,Mother(y))

Knows(x,OJ) {fail}

{y/John,x/Mother(John)}}

Unification

Examples

UNIFY(Knows(John,x), Knows(y,Bill)) = {x/Bill, y/John}

UNIFY(Knows(John,x), Knows(y,Mother(y))= {y/John, x/Mother(John)

UNIFY(Knows(John,x), Knows(x,Elizabeth)) = fail

Last example fails because x would have to be both John and Elizabeth

We can avoid this problem by standardizing:

The two statements now read

UNIFY(Knows(John,x), Knows(z,Elizabeth))

This is solvable:

Unification

To unify Knows(John,x) and Knows(y,z)

Can use = {y/John, x/z }

Or = {y/John, x/John, z/John}

The first unifier is more general than the

second.

There is a single most general unifier

(MGU) that is unique up to renaming of

variables.

MGU = { y/John, x/z }

Unification

Unification algorithm:

side

Build up a unifier along the way

Fail if two corresponding points do not match

FORWARD CHAINING

&

BACKWARD CHAINING

49

Predicate Logic

1/17/16

Forward Chaining

Forward Chaining

Idea:

Start with atomic sentences in the KB

Apply Modus Ponens

Add new atomic sentences until no further inferences

can be made

Works well for a KB consisting of Situation

data

Backward Chaining

Idea:

the query.

Algorithm:

Algo finds every clause in the KB that unifies with the

of goals

THANK YOU

63

Predicate Logic

1/17/16

## Mult mai mult decât documente.

Descoperiți tot ce are Scribd de oferit, inclusiv cărți și cărți audio de la editori majori.

Anulați oricând.