artificial intelligence knowledge representation problem

61
Artificial Intelligence Knowledge Representation Problem

Upload: cuthbert-wilson

Post on 14-Dec-2015

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Artificial Intelligence Knowledge Representation Problem

Artificial Intelligence

Knowledge Representation Problem

Page 2: Artificial Intelligence Knowledge Representation Problem

Knowledge bases

Knowledge base = set of sentences in a formal language

Page 3: Artificial Intelligence Knowledge Representation Problem

Stages of Knowledge Use Acquisition

structure of facts integration of old & new knowledge

Retrieval (recall) roles of linking and chunking means of improving recall efficiency

Page 4: Artificial Intelligence Knowledge Representation Problem

Representation

Set of syntactic and semantic conventions which make it possible to describe things

Syntax specific symbols allowed and rules allowed

Semantics how meaning is associated with symbol

arrangements allowed by syntax

Page 5: Artificial Intelligence Knowledge Representation Problem

Knowledge Representation Schemas

Logic based representation – first order predicate logic, Prolog

Procedural representation – rules, production system

Network representation – semantic networks, conceptual graphs

Structural representation – scripts, frames, objects

Page 6: Artificial Intelligence Knowledge Representation Problem

Conceptual Graphs each concept has got its type and an instance

general concept – a concept with a wildcard instance

specific concept – a concept with a concrete instance

there exsists a hierarchy of types subtype:

concept w is specialisation of concept v iftype(v)>type(w) or instance(w)::type(v)

dog:Emma browncolour

dog:*X browncolour

animal

dog cat

Page 7: Artificial Intelligence Knowledge Representation Problem

Types of Knowledge Objects

both physical & concepts Events

usually involve time maybe cause & effect relationships

Performance how to do things

META Knowledge knowledge about how to use knowledge

Page 8: Artificial Intelligence Knowledge Representation Problem

Proposition logic

Page 9: Artificial Intelligence Knowledge Representation Problem

Basic connectives and truth tables

statements (propositions): declarative sentences that areeither true or false--but not both.

Eg. Ahmed Hassan wrote Gone with the Wind. 2+3=5.

not statements:

What a beautiful morning!Get up and do your exercises.

Page 10: Artificial Intelligence Knowledge Representation Problem

Fundamentals of Logic

"The number x is an integer."

is not a statement because its truth value cannot be determined until a numerical value is assigned for x.

Page 11: Artificial Intelligence Knowledge Representation Problem

Propositional logic Logical constants: true, false Propositional symbols: P, Q, S, ... (atomic

sentences) Sentences are combined by connectives:

...and [conjunction] ...or [disjunction] ...implies [implication / conditional] ..is equivalent [biconditional] ...not [negation]

Literal: atomic sentence or negated atomic sentence

Page 12: Artificial Intelligence Knowledge Representation Problem

Truth Tables

p q p q p q p q p qp q

0 0 0 0 0 1 1

0 1 0 1 1 1 0

1 0 0 1 1 0 0

1 1 1 1 0 1 1

Page 13: Artificial Intelligence Knowledge Representation Problem

Examples of PL sentences P means “It is hot.” Q means “It is humid.” R means “It is raining.” (P Q) R

“If it is hot and humid, then it is raining” Q P

“If it is humid, then it is hot” A better way:

Hot = “It is hot”

Humid = “It is humid”

Raining = “It is raining”

Page 14: Artificial Intelligence Knowledge Representation Problem

Example

s: Aya goes out for a walk.t: The moon is out.u: It is snowing.

( )t u s : If the moon is out and it is not snowing, thenAya goes out for a walk.

If it is snowing and the moon is not out, then Aya will not go out for a walk. ( )u t s

Page 15: Artificial Intelligence Knowledge Representation Problem

Logical Equivalence

0011

0101

1100

1101

1101

p q p p q p q

s s1 2

Page 16: Artificial Intelligence Knowledge Representation Problem

Logical equivalence

Two sentences are logically equivalent} iff true in same models: α ≡ ß iff α╞ β and β╞ α

Page 17: Artificial Intelligence Knowledge Representation Problem

L3 17

Tables of Logical Equivalences

Identity lawsLike adding 0

Domination lawsLike multiplying by 0

Idempotent lawsDelete redundancies

Double negation“I don’t like you, not”

Commutativity Like “x+y = y+x”

AssociativityLike “(x+y)+z = y+(x+z)”

DistributivityLike “(x+y)z = xz+yz”

De Morgan

Page 18: Artificial Intelligence Knowledge Representation Problem

Tables of Logical Equivalences

Excluded middle Negating creates opposite Definition of implication in

terms of Not and Or

Page 19: Artificial Intelligence Knowledge Representation Problem

Fundamentals of Logic

A compound statement is called a tautology(T0) if it is true for all truth value assignments for its component statements. If a compound statement is false for all such assignments, then it is called a contradiction(F0).

p p q

p p q

( )

( )

: tautology

: contradiction

Page 20: Artificial Intelligence Knowledge Representation Problem

Propositional Logic - 2 more defn…A tautology is a proposition that’s always TRUE.

A contradiction is a proposition that’s always FALSE.

p p p p p p

T F

F T

T

T

F

F

Page 21: Artificial Intelligence Knowledge Representation Problem

21

Tautology example

Demonstrate that

[¬p (p q )]q

is a tautology in two ways:

1. Using a truth table – show that [¬p (p q )]q is always true

2. Using a proof (will get to this later).

Page 22: Artificial Intelligence Knowledge Representation Problem

Tautology by truth tablep q ¬p p q ¬p (p q ) [¬p (p q )]q

T T

T F

F T

F F

Page 23: Artificial Intelligence Knowledge Representation Problem

Tautology by truth tablep q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F

T F F

F T T

F F T

Page 24: Artificial Intelligence Knowledge Representation Problem

Tautology by truth tablep q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F T

T F F T

F T T T

F F T F

Page 25: Artificial Intelligence Knowledge Representation Problem

Tautology by truth tablep q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F T F

T F F T F

F T T T T

F F T F F

Page 26: Artificial Intelligence Knowledge Representation Problem

Tautology by truth tablep q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F T F T

T F F T F T

F T T T T T

F F T F F T

Page 27: Artificial Intelligence Knowledge Representation Problem

Derivational Proof TechniquesEG: consider the compound proposition

(p p ) ((sr)t) ) (qr )

Q: Why is this a tautology?

Page 28: Artificial Intelligence Knowledge Representation Problem

L3 28

Derivational Proof TechniquesA: Part of it is a tautology (p p ) and the

disjunction of True with any other compound proposition is still True:

(p p ) ((sr)t )) (qr ) T ((sr)t )) (qr ) TDerivational techniques formalize the

intuition of this example.

Page 29: Artificial Intelligence Knowledge Representation Problem

L3 29

Tautology by proof[¬p (p q )]q

Page 30: Artificial Intelligence Knowledge Representation Problem

L3 30

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

Page 31: Artificial Intelligence Knowledge Representation Problem

L3 31

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE

Page 32: Artificial Intelligence Knowledge Representation Problem

L3 32

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

Page 33: Artificial Intelligence Knowledge Representation Problem

L3 33

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

Page 34: Artificial Intelligence Knowledge Representation Problem

L3 34

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

[¬(¬p) ¬q ] q DeMorgan

Page 35: Artificial Intelligence Knowledge Representation Problem

L3 35

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

[¬(¬p) ¬q ] q DeMorgan

[p ¬q ] q Double Negation

Page 36: Artificial Intelligence Knowledge Representation Problem

L3 36

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

[¬(¬p) ¬q ] q DeMorgan

[p ¬q ] q Double Negation

p [¬q q ] Associative

Page 37: Artificial Intelligence Knowledge Representation Problem

L3 37

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

[¬(¬p) ¬q ] q DeMorgan

[p ¬q ] q Double Negation

p [¬q q ] Associative

p [q ¬q ] Commutative

Page 38: Artificial Intelligence Knowledge Representation Problem

L3 38

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

[¬(¬p) ¬q ] q DeMorgan

[p ¬q ] q Double Negation

p [¬q q ] Associative

p [q ¬q ] Commutative p T ULE

Page 39: Artificial Intelligence Knowledge Representation Problem

L3 39

Tautology by proof[¬p (p q )]q

[(¬p p)(¬p q)]q Distributive

[ F (¬p q)]q ULE [¬p q ]q Identity

¬ [¬p q ] q ULE

[¬(¬p) ¬q ] q DeMorgan

[p ¬q ] q Double Negation

p [¬q q ] Associative

p [q ¬q ] Commutative p T ULE T Domination

Page 40: Artificial Intelligence Knowledge Representation Problem

Examples1. “I don’t study well and fail” is logically

equivalent to “If I study well, then I don’t fail”

2. Write a C program that represents the compound proposition (pq)r

Page 41: Artificial Intelligence Knowledge Representation Problem

Use truth table to find - P Q P R P -Q R P R - Q A B -C D E F

Page 42: Artificial Intelligence Knowledge Representation Problem

Limitations of propositional logic So far we studied propositional logic

Some English statements are hard to model in propositional logic:

“If your roommate is wet because of rain, your roommate must not be carrying any umbrella”

Pathetic attempt at modeling this:

RoommateWetBecauseOfRain => (NOT(RoommateCarryingUmbrella0) AND NOT(RoommateCarryingUmbrella1) AND NOT(RoommateCarryingUmbrella2) AND …)

Page 43: Artificial Intelligence Knowledge Representation Problem

Problems with propositional logic No notion of objects

No notion of relations among objects

RoommateCarryingUmbrella0 is instructive to us, suggesting there is an object we call Roommate,

there is an object we call Umbrella0,

there is a relationship Carrying between these two objects

Formally, none of this meaning is there Might as well have replaced RoommateCarryingUmbrella0 by

P

Page 44: Artificial Intelligence Knowledge Representation Problem

First-Order Logic

Syntax

Page 45: Artificial Intelligence Knowledge Representation Problem

Constants Constants refer to objects, functions and relationships.

Ahmed, Mona, loves, happy, Simple sentences express relationships among objects.

loves(Ahmed, Mona) They are called atoms.

Compound sentences capture relationships among relations.loves(x,y) loves(y,x)loves(x,y) loves(y,x) happy(x)

Relations can be unary as well.tall(Tomy)

Page 46: Artificial Intelligence Knowledge Representation Problem

Elements of first-order logic Objects: can give these names such as Umbrella0,

Person0, John, Earth, …

Relations: Carrying(., .), IsAnUmbrella(.)

Carrying(Person0, Umbrella0), IsUmbrella(Umbrella0)

Relations with one object = unary relations = properties

Functions: Roommate(.)

Roommate(Person0) Equality: Roommate(Person0) = Person1

Page 47: Artificial Intelligence Knowledge Representation Problem

Example with Functions

E.g. How about saying that Ahmed has a big nose?

Ahmed is an object and

nose_of (Ahmed)

is a function that constructs an object from the argument object.

Then, we can write:

big(nose_of (Ahmed))

E.g. Mona loves her dog.

loves(Mona, dog_of (Mona))

Note: We are allowed to relate sentences only.

So, we can say:

loves(Mona, dog_of (Mona)) loves(Mona, cat_of (Mona))

But not,

loves(Mona,

dog_of (Mona) cat_of (Mona))

Page 48: Artificial Intelligence Knowledge Representation Problem

First-Order Logic: , The language that we have described so far, consisting of atoms and the

connectives (,,,,,) is typically called predicate logic. To extend it to first-order logic, we need to add quantifiers. The purpose of quantifiers is to allow us to say things about sets of

objects. To say that Heba loves everything we write:

x. loves (Heba, x)We can think of as a big conjunction. For example, if there are only three objects Heba, dog, and cat, what the above asserts is:

loves (Heba, dog) loves (Heba, cat) loves (Heba, Heba) To say that Hassan loves something we write:

x. loves (Hassan, x)We can think of as a big disjunction. For example, if there are only three objects as above, then what we are asserting is:

loves (Hassan, dog) loves (Hassan, cat) loves (Hassan, Hassan)

Page 49: Artificial Intelligence Knowledge Representation Problem

First Order Predicate Logic – enriched by variables, predicates, functions quantifiers ,

friends(father(david),father(andrew)) Y friends(Y, petr) X likes(X,ice_cream) X Y Z parent(X,Y) parent(X,Z)

siblings(Y,Z)

Page 50: Artificial Intelligence Knowledge Representation Problem

Reasoning about many objects at once

Variables: x, y, z, … can refer to multiple objects New operators “for all” and “there exists”

Universal quantifier and existential quantifier

for all x: CompletelyWhite(x) => NOT(PartiallyBlack(x)) Completely white objects are never partially black

there exists x: PartiallyWhite(x) AND PartiallyBlack(x) There exists some object in the world that is partially white and

partially black

Page 51: Artificial Intelligence Knowledge Representation Problem

Practice converting English to first-order logic

“John has an umbrella” there exists y: (Has(John, y) AND IsUmbrella(y)) “Anything that has an umbrella is not wet” for all x: ((there exists y: (Has(x, y) AND

IsUmbrella(y))) => NOT(IsWet(x))) “Any person who has an umbrella is not wet” for all x: (IsPerson(x) => ((there exists y: (Has(x, y)

AND IsUmbrella(y))) => NOT(IsWet(x))))

Page 52: Artificial Intelligence Knowledge Representation Problem

More practice converting English to first-order logic

“John has at least two umbrellas” there exists x: (there exists y: (Has(John, x) AND

IsUmbrella(x) AND Has(John, y) AND IsUmbrella(y) AND NOT(x=y))

“John has at most two umbrellas” for all x, y, z: ((Has(John, x) AND IsUmbrella(x) AND

Has(John, y) AND IsUmbrella(y) AND Has(John, z) AND IsUmbrella(z)) => (x=y OR x=z OR y=z))

Page 53: Artificial Intelligence Knowledge Representation Problem

Even more practice converting English to first-order logic…

“Duke’s basketball team defeats any other basketball team”

for all x: ((IsBasketballTeam(x) AND NOT(x=BasketballTeamOf(Duke))) => Defeats(BasketballTeamOf(Duke), x))

“Every team defeats some other team” for all x: (IsTeam(x) => (there exists y: (IsTeam(y)

AND NOT(x=y) AND Defeats(x,y))))

Page 54: Artificial Intelligence Knowledge Representation Problem

Reverse translation• Translate the following into English.

x hesitates(x) lost(x)• He who hesitates is lost.

x business(x) like(x,Showbusiness)• There is no business like show business.

x glitters(x) gold(x)• Not everything that glitters is gold.

x t person(x) time(t) canfool(x,t)• You can fool some of the people all the time.

Page 55: Artificial Intelligence Knowledge Representation Problem

Translating English to FOLEvery gardener likes the sun.

x gardener(x) likes(x,Sun) You can fool some of the people all of the time.

x t person(x) time(t) can-fool(x,t)You can fool all of the people some of the time.

x t (person(x) time(t) can-fool(x,t))x (person(x) t (time(t) can-fool(x,t)))

All purple mushrooms are poisonous.x (mushroom(x) purple(x)) poisonous(x)

No purple mushroom is poisonous.x purple(x) mushroom(x) poisonous(x) x (mushroom(x) purple(x)) poisonous(x)

There are exactly two purple mushrooms.x y mushroom(x) purple(x) mushroom(y) purple(y) ^ (x=y) z

(mushroom(z) purple(z)) ((x=z) (y=z)) Clinton is not tall.

tall(Clinton) X is above Y iff X is on directly on top of Y or there is a pile of one or more other

objects directly on top of one another starting with X and ending with Y.x y above(x,y) ↔ (on(x,y) z (on(x,z) above(z,y)))

Equivalent

Equivalent

Page 56: Artificial Intelligence Knowledge Representation Problem

Resolution for first-order logic for all x: (NOT(Knows(John, x)) OR IsMean(x) OR

Loves(John, x)) John loves everything he knows, with the possible exception of mean

things

for all y: (Loves(Jane, y) OR Knows(y, Jane)) Jane loves everything that does not know her

What can we unify? What can we conclude?

Use the substitution: {x/Jane, y/John}

Get: IsMean(Jane) OR Loves(John, Jane) OR Loves(Jane, John)

Complete (i.e., if not satisfiable, will find a proof of this), if we can remove literals that are duplicates after unification Also need to put everything in canonical form first

Page 57: Artificial Intelligence Knowledge Representation Problem

Properties of quantifiers x y is the same as y x x y is the same as y x x y is not the same as y x

“There is a person who loves everyone in the world” “Everyone in the world is loved by at least one person”

Quantifier duality: each can be expressed using the other x Likes(x,IceCream) x Likes(x,IceCream) x Likes(x,Broccoli) x

Likes(x,Broccoli)

y x Loves(x,y) x y Loves(x,y)

Page 58: Artificial Intelligence Knowledge Representation Problem

Using FOL

Brothers are siblings x,y Brother(x,y) Sibling(x,y)

One's mother is one's female parent m,c Mother(c) = m (Female(m) Parent(m,c))

“Sibling” is symmetric x,y Sibling(x,y) Sibling(y,x)

A first cousin is a child of a parent’s sibling x,y FirstCousin(x,y) p,ps Parent(p,x) Sibling(ps,p)

Parent(ps,y)

Page 59: Artificial Intelligence Knowledge Representation Problem

An example1. Sameh is a lawyer.

2. Lawyers are rich.

3. Rich people have big houses.

4. Big houses are a lot of work. We would like to conclude that Sameh’s house is a

lot of work. Natural languages are ambiguous so we can have

different axiomatizations.

Page 60: Artificial Intelligence Knowledge Representation Problem

Axiomatization 11. lawyer(Sameh)2. x lawyer(x) rich(x)3. x rich(x) y house(x,y) 4. x,y rich(x) house(x,y) big(y)5. x,y ( house(x,y) big(y) work(y) ) 3 and 4, say that rich people do have at least one house and all

their houses are big. Conclusion we want to show:

house(Sameh, S_house) work(Sameh, S_house) Or, do we want to conclude that John has at least one house

that needs a lot of work? I.e. y house(Sameh,y) work(y)

Page 61: Artificial Intelligence Knowledge Representation Problem

Amir and the cat Everyone who loves all animals is loved by

someone. Anyone who kills an animal is loved by no

one. Mohamed loves all animals. Either Mohamed or Amir killed the cat, who

is named SoSo. Did Amir kill the cat?