1 knowledge representation and reasoning. 2 knowledge representation & reasoning how knowledge...

29
1 Knowledge Representation Knowledge Representation and Reasoning and Reasoning

Upload: irene-powell

Post on 22-Dec-2015

256 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

1

Knowledge RepresentationKnowledge Representation

and Reasoningand Reasoning

Page 2: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

2

Knowledge Representation & ReasoningKnowledge Representation & Reasoning

• How knowledge about the world can be representedHow knowledge about the world can be represented

• What kinds of reasoning can be done with that What kinds of reasoning can be done with that knowledge.knowledge.

• Two different systems that are commonly used to Two different systems that are commonly used to represent knowledge:represent knowledge:

• Propositional calculusPropositional calculus

• Predicate calculusPredicate calculus

Page 3: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

3

Propositional CalculusPropositional Calculus

In propositional calculus, In propositional calculus,

• features of the world are represented by features of the world are represented by propositionspropositions,,

• relationships between features (constraints) relationships between features (constraints) are are represented by represented by connectivesconnectives..

Example:Example:

LECTURE_BORING LECTURE_BORING TIME_LATE TIME_LATE !! SLEEP SLEEP

Page 4: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

4

Propositional CalculusPropositional Calculus

You see that the language of propositional calculus You see that the language of propositional calculus can be used to represent aspects of the world.can be used to represent aspects of the world.

When there areWhen there are

• a a languagelanguage, as defined by a syntax,, as defined by a syntax,

• inference rulesinference rules for manipulating sentences in that for manipulating sentences in that language, and language, and

• semanticssemantics for associating elements of the for associating elements of the language with elements of the world, language with elements of the world,

then we have a system called then we have a system called logiclogic..

Page 5: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

5

LogicLogic• When we have too many states, we want a When we have too many states, we want a

convenient way of dealing with sets of convenient way of dealing with sets of states.states.

• The sentence “It’s raining” stands for all the The sentence “It’s raining” stands for all the states of the world in which it is raining.states of the world in which it is raining.

• Logic provides a way of manipulating big Logic provides a way of manipulating big collections of sets by manipulating short collections of sets by manipulating short descriptions instead.descriptions instead.

Page 6: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

6

What is a logic?What is a logic?

A formal language:A formal language:• Syntax – what expressions are legalSyntax – what expressions are legal

• Semantics – what legal expressions Semantics – what legal expressions meanmean

• Proof system – a way of manipulating Proof system – a way of manipulating syntactic expressions to get other syntactic expressions to get other syntactic expressions (which will tell syntactic expressions (which will tell us something new)us something new)

Page 7: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

7

Propositional LogicPropositional Logic

Atoms:Atoms:

The atoms T and F and all strings that begin with a The atoms T and F and all strings that begin with a capital letter, for instance, P, Q, LECTURE_BORING, capital letter, for instance, P, Q, LECTURE_BORING, and so on.and so on.

Connectives:Connectives:

• “ “or”or”

• “ “and”and”

• !! “implies” or “if-then” “implies” or “if-then”

• $ “$ “equivalence”equivalence”

• “ “not”not”

Page 8: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

8

Propositional LogicPropositional Logic

Syntax of well-formed formulas (wffs):Syntax of well-formed formulas (wffs):• Any atom is a wff.Any atom is a wff.

• If If 11 and and 22 are wffs, so are are wffs, so are

11 22 (conjunction) (conjunction)

11 22 (disjunction) (disjunction)

11 !! 22 (implication) (implication)

11 $$ 2 2 (double implication)(double implication)

11 (negation) (negation)

• There are no other wffs.There are no other wffs.

Page 9: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

9

Propositional LogicPropositional Logic• Atoms and negated atoms are called Atoms and negated atoms are called literalsliterals..

• In In 1 1 !! 22 , , 11 is called the is called the antecedentantecedent, and , and

22 is called the is called the consequentconsequent of the implication. of the implication.

• Examples of wffs (sentences):Examples of wffs (sentences):

(P (P Q) Q) !! PP

P P !! P P

P P P P !! P P

(P (P !! Q) Q) !! ( (Q Q !! P)P)

PP

Page 10: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

10

PrecedencePrecedence::

ÆÆ

ÇÇ

!!

$$

highest

lowest

A A ÇÇ B B ÆÆ C C A A ÇÇ (B (B ÆÆ C) C)

A A ÆÆ B B !! C C ÇÇ D D (A (A ÆÆ B) B) !! (C (C ÇÇ D) D)

A A !! B B ÇÇ C C $$ D D (A (A !! (B (B ÇÇ C)) C)) $$ D D

• Precedence rules enable “shorthand” form of sentences, but formally only the fully parenthesized form is legal.

• Syntactically ambiguous forms allowed in shorthand only when semantically equivalent: A Æ B Æ C is equivalent to (A Æ B) Æ C and A Æ (B Æ C)

Page 11: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

11

Rules of InferenceRules of Inference

We use We use rules of inferencerules of inference to generate new wffs to generate new wffs from existing ones.from existing ones.

One important rule is called One important rule is called modus ponensmodus ponens or the or the law of detachmentlaw of detachment. It is based on the tautology . It is based on the tautology (P (P (P (P !! Q)) Q)) !! Q. We write it in the following way: Q. We write it in the following way:

PPP P !! Q Q__________ QQ

The two The two hypotheseshypotheses P and P P and P !! Q are Q are written in a column, and the written in a column, and the conclusionconclusionbelow a bar, where below a bar, where means “therefore”. means “therefore”.

Page 12: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

12

Rules of InferenceRules of Inference

PP____________ PPQQ AdditionAddition

PPQQ__________ PP

SimplificationSimplification

PP QQ____________ PPQQ

ConjunctionConjunction

QQ P P !! Q Q __________ PP

Modus tollensModus tollens

P P !! Q Q Q Q !! R R ______________ P P ! ! R R

Hypothetical Hypothetical syllogismsyllogism

PPQQ PP__________ Q Q

Disjunctive Disjunctive syllogismsyllogism

Page 13: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

13

Predicate CalculusPredicate Calculus

Proposition’s are simple but weak, so it is a better Proposition’s are simple but weak, so it is a better idea to use idea to use predicatespredicates instead of propositions. instead of propositions.

This leads us to This leads us to predicate calculuspredicate calculus..

Predicate calculus has Predicate calculus has symbolssymbols called called • object constants,object constants,• relation constants, andrelation constants, and• function constantsfunction constants

These symbols will be used to refer to These symbols will be used to refer to objectsobjects in the in the world and to world and to propositionspropositions about the world. about the world.

Page 14: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

14

Syntax of First-Order Logic in BNFSyntax of First-Order Logic in BNF

Sentence AtomicSentence | Sentence Connective Sentence | Quantifier Variable,… Sentence | Sentence | (Sentence)

AtomicSentence Predicate(Term,…) | Term= Term

Term Function(Term,…) | Constant | Variable

Page 15: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

15

Syntax of First-Order Logic in BNFSyntax of First-Order Logic in BNF

Connective | | | | | $$ Quantifier | Constant A | X1 | John | … Variable a | v | x | … Predicate Before | HasColor | Raining | … Function MotherOf | LegOf | …

Page 16: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

16

ComponentsComponents

Object constants:Object constants:

Strings of alphanumeric characters beginning with Strings of alphanumeric characters beginning with either a capital letter or a numeral.either a capital letter or a numeral.

Examples:Examples: XY, George, 154, H1B XY, George, 154, H1B

Function constants:Function constants:

Strings of alphanumeric characters beginning with a Strings of alphanumeric characters beginning with a lowercase letter and (sometimes) superscripted by lowercase letter and (sometimes) superscripted by their “arity”:their “arity”:

Examples:Examples: fatherOf fatherOf11, distanceBetween, distanceBetween22

Page 17: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

17

ComponentsComponents

Relation constants:Relation constants:

Strings of alphanumeric characters beginning with a Strings of alphanumeric characters beginning with a capital letter and (sometimes) superscripted by their capital letter and (sometimes) superscripted by their “arity”:“arity”:

Examples:Examples: BeatsUp BeatsUp22, Tired, Tired11

Other symbols:Other symbols:

Propositional connectives Propositional connectives , , , , !!, , $$ , and , and , delimiters , delimiters (, ), [, ]. (, ), [, ].

Page 18: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

18

TermsTerms

• An object constant is a term.An object constant is a term.• A function constant of arity n, followed by n terms in A function constant of arity n, followed by n terms in

parentheses and separated by commas, is a term.parentheses and separated by commas, is a term.

Examples:Examples: fatherOf(George), times(3, minus(5, 2)) fatherOf(George), times(3, minus(5, 2))

Page 19: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

19

WffsWffsAtoms: Atoms: • A relation constant of arity n followed by n terms in A relation constant of arity n followed by n terms in

parentheses and separated by commas is an atom.parentheses and separated by commas is an atom.An atom is a wff.An atom is a wff.

• Examples:Examples: Tired(John), OlderThan(Hans, Peter) Tired(John), OlderThan(Hans, Peter)

Propositional wffs:Propositional wffs:• Any expression formed out of predicate-calculus Any expression formed out of predicate-calculus

wffs in the same way that the propositional calculus wffs in the same way that the propositional calculus forms wffs out of other wffs is a propositional wff.forms wffs out of other wffs is a propositional wff.

• Example:Example: OlderThan(John, Peter) OlderThan(John, Peter) OlderThan(Peter, Jennifer) OlderThan(Peter, Jennifer)

Page 20: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

20

QuantificationQuantification

Introducing the Introducing the universal quantifier universal quantifier and the and the existential existential quantifier quantifier facilitates the translation of world knowledge into facilitates the translation of world knowledge into predicate calculus.predicate calculus.

Examples:Examples:

Paul hates all professors who fail him.Paul hates all professors who fail him.

x(Professor(x) x(Professor(x) Fails(x, Paul) Fails(x, Paul) !! Hates(Paul, x)) Hates(Paul, x))

There is at least one intelligent Sharif professor.There is at least one intelligent Sharif professor.

x(SharifProf(x) x(SharifProf(x) Intelligent(x)) Intelligent(x))

Page 21: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

21

Rules of InferenceRules of Inference

x P(x)x P(x)____________________

P(c) if cP(c) if cUU

Universal Universal instantiationinstantiation

P(c) for an arbitrary cP(c) for an arbitrary cUU______________________________________

x P(x)x P(x)

Universal Universal generalizationgeneralization

x P(x)x P(x)____________________________________________

P(c) for some element cP(c) for some element cUU

Existential Existential instantiationinstantiation

P(c) for some element cP(c) for some element cUU________________________________________

x P(x) x P(x)

Existential Existential generalizationgeneralization

Page 22: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

22

QuantifiersQuantifiers

Properties of quantifiers:Properties of quantifiers:– xxy y is the same asis the same as yyxx– xxy y is the same asis the same as yyxx– note: note: xxy y can be written as can be written as xxy y likewise with likewise with

Example?Example?– xxy Likes(x,y)y Likes(x,y) is is activeactive voice voice::

Everyone likes everyone.Everyone likes everyone.– yyx Likes(x,y)x Likes(x,y) is is passivepassive voice voice::

Everyone is liked by everyone.Everyone is liked by everyone.

Page 23: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

23

QuantifiersQuantifiers

Properties of quantifiers:Properties of quantifiers:– xxy y is not the same asis not the same as yyxx– xxy y is not the same asis not the same as yyxx

Example?Example?– xxy Likes(x,y)y Likes(x,y) is is active voiceactive voice::

Everyone likes someone.Everyone likes someone.– yyx Likes(x,y)x Likes(x,y) is is passive voicepassive voice::

Someone is liked by everyone.Someone is liked by everyone.

Page 24: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

24

QuantifiersQuantifiers

Properties of quantifiers:Properties of quantifiers:– x P(x) x P(x) is the same asis the same as x x P(x)P(x)– x P(x) x P(x) is the same asis the same as x x P(x)P(x)

Example?Example?– x Likes(x,IceCream)x Likes(x,IceCream)

Everyone likes ice cream.Everyone likes ice cream.– x x Likes(x,IceCream) Likes(x,IceCream)

No one doesn't like ice cream. No one doesn't like ice cream.

It's a double negative!It's a double negative!

Page 25: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

25

QuantifiersQuantifiers

Properties of quantifiers:Properties of quantifiers:– x P(x)x P(x) when negated iswhen negated is x x P(x)P(x)– x P(x)x P(x) when negated iswhen negated is x x P(x)P(x)

Example?Example?– x Likes(x,IceCream)x Likes(x,IceCream)

Everyone likes ice cream.Everyone likes ice cream.– x x Likes(x,IceCream)Likes(x,IceCream)

Someone doesn't like ice cream.Someone doesn't like ice cream.– This is from the application of de Morgan's lawThis is from the application of de Morgan's law

to the fully instantiated sentence.to the fully instantiated sentence.

Page 26: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

26

BasicsBasics

A A free variablefree variable is a variable that is a variable thatisn't bound by a quantifier.isn't bound by a quantifier.– y Likes(x,y)y Likes(x,y)

xx is free, is free, yy is bound is bound

A A well-formed formulawell-formed formula is a sentence where is a sentence whereall variables are quantified.all variables are quantified.

Page 27: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

27

SummarySummary

Term:Term: Constant, variable, or Function(termConstant, variable, or Function(term1, …, 1, …, termtermnn))

denotes an object in the worlddenotes an object in the world

Ground TermGround Term has no variables has no variables

Atom:Atom: Predicate(termPredicate(term1, …, 1, …, termtermnn), term), term11 = term = term22

is smallest expression assigned a truth is smallest expression assigned a truth valuevalue

Sentence:Sentence: atom, quantified sentence with variables oratom, quantified sentence with variables orcomplex sentence using connectivescomplex sentence using connectives

is assigned a truth valueis assigned a truth value

Well-Formed Formula (wff):Well-Formed Formula (wff):sentence where all variables are quantifiedsentence where all variables are quantified

Page 28: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

28

An example of E.I.An example of E.I.

1.1. x(Bottle(x,T1) x(Bottle(x,T1) Upturned(x, T2)) Upturned(x, T2))

2.2. xxy(Upturned(x, y) y(Upturned(x, y) Empty(x, y)) Empty(x, y))

3.3. x(Full(x, T1) & Empty(x, T2) x(Full(x, T1) & Empty(x, T2) Wet(Floor)) Wet(Floor))

4.4. x (Bottle(x, T1) & Full(x, T1))x (Bottle(x, T1) & Full(x, T1))

TT11

T2T2

b1b1 b2b2 b3b3b1b1 b2b2 b3b3

Page 29: 1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about

29

An example of E.I.An example of E.I.

5.5. Bottle(b1, T1) & Full(b1, T1))Bottle(b1, T1) & Full(b1, T1)) - EI assumption- EI assumption

6.6. Bottle(b1, T1)Bottle(b1, T1) - & , 5- & , 5

7.7. Full(b1, T1)Full(b1, T1) - & , 5- & , 5

8.8. Upturned (b1, T2)Upturned (b1, T2) - - , 1 , - , 1 , - , 6 , 6

9.9. Empty(b1, T2)Empty(b1, T2) - - , 2 , - , 2 , - , 7 , 7

10.10. Full(b1, T1) & Empty (b1, T2)Full(b1, T1) & Empty (b1, T2) + & , 7, 9+ & , 7, 9

11.11. Wet(Floor)Wet(Floor) - - , 3, - , 3, - , 10 , 10

Wet(Floor)Wet(Floor) - EI conclusion- EI conclusion