Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about."— Presentation transcript:

1 1 Knowledge Representation and Reasoning

2 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about the world can be represented What kinds of reasoning can be done with that knowledge. What kinds of reasoning can be done with that knowledge. Two different systems that are commonly used to represent knowledge: Two different systems that are commonly used to represent knowledge: Propositional calculus Propositional calculus Predicate calculus Predicate calculus

3 3 Propositional Calculus In propositional calculus, features of the world are represented by propositions, features of the world are represented by propositions, relationships between features (constraints) are represented by connectives. relationships between features (constraints) are represented by connectives.Example: LECTURE_BORING  TIME_LATE ! SLEEP

4 4 Propositional Calculus You see that the language of propositional calculus can be used to represent aspects of the world. When there are a language, as defined by a syntax, a language, as defined by a syntax, inference rules for manipulating sentences in that language, and inference rules for manipulating sentences in that language, and semantics for associating elements of the language with elements of the world, semantics for associating elements of the language with elements of the world, then we have a system called logic.

5 5 Logic When we have too many states, we want a convenient way of dealing with sets of states.When we have too many states, we want a convenient way of dealing with sets of states. The sentence “It’s raining” stands for all the states of the world in which it is raining.The sentence “It’s raining” stands for all the states of the world in which it is raining. Logic provides a way of manipulating big collections of sets by manipulating short descriptions instead.Logic provides a way of manipulating big collections of sets by manipulating short descriptions instead.

6 6 What is a logic? A formal language: Syntax – what expressions are legalSyntax – what expressions are legal Semantics – what legal expressions meanSemantics – what legal expressions mean Proof system – a way of manipulating syntactic expressions to get other syntactic expressions (which will tell us something new)Proof system – a way of manipulating syntactic expressions to get other syntactic expressions (which will tell us something new)

7 7 Propositional Logic Atoms: The atoms T and F and all strings that begin with a capital letter, for instance, P, Q, LECTURE_BORING, and so on. Connectives:  “or”  “or”  “and”  “and” ! “implies” or “if-then” ! “implies” or “if-then” $ “equivalence” $ “equivalence”  “not”  “not”

8 8 Propositional Logic Syntax of well-formed formulas (wffs): Any atom is a wff. Any atom is a wff. If  1 and  2 are wffs, so are If  1 and  2 are wffs, so are  1   2 (conjunction)  1   2 (disjunction)  1 !  2 (implication)  1 $  2 (double implication)  1 $  2 (double implication)  1 (negation) There are no other wffs. There are no other wffs.

9 9 Propositional Logic Atoms and negated atoms are called literals. Atoms and negated atoms are called literals. In  1 !  2,  1 is called the antecedent, and  2 is called the consequent of the implication. In  1 !  2,  1 is called the antecedent, and  2 is called the consequent of the implication. Examples of wffs (sentences): Examples of wffs (sentences): (P  Q) !  P P !  P P  P ! P (P ! Q) ! (  Q !  P)  P  P

10 10 Precedence : Æ Ç ! $ highest lowest A Ç B Æ C A Ç (B Æ C) A Æ B ! C Ç D (A Æ B) ! (C Ç D) A ! B Ç C $ D (A ! (B Ç C)) $ 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)

11 11 Rules of Inference We use rules of inference to generate new wffs from existing ones. One important rule is called modus ponens or the law of detachment. It is based on the tautology (P  (P ! Q)) ! Q. We write it in the following way: P P ! Q _____  Q The two hypotheses P and P ! Q are written in a column, and the conclusion below a bar, where  means “therefore”.

12 12 Rules of Inference P______  P  Q Addition P  Q P  Q_____  P Simplification P Q______  P  Q Conjunction  Q  Q P ! Q P ! Q_____   P Modus tollens P ! Q P ! Q Q ! R Q ! R_______  P ! R Hypothetical syllogism P  Q P  Q  P  P_____  Q Disjunctive syllogism

13 13 Predicate Calculus Proposition’s are simple but weak, so it is a better idea to use predicates instead of propositions. This leads us to predicate calculus. Predicate calculus has symbols called object constants, object constants, relation constants, and relation constants, and function constants function constants These symbols will be used to refer to objects in the world and to propositions about the world.

14 14 Syntax 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

15 15 Syntax of First-Order Logic in BNF     | $ Connective   |  |  |  | $ Quantifier   |  Constant  A | X 1 | John | … Variable  a | v | x | … Predicate  Before | HasColor | Raining | … Function  MotherOf | LegOf | …

16 16Components Object constants: Strings of alphanumeric characters beginning with either a capital letter or a numeral. Examples: XY, George, 154, H1B Function constants: Strings of alphanumeric characters beginning with a lowercase letter and (sometimes) superscripted by their “arity”: Examples: fatherOf 1, distanceBetween 2

17 17Components Relation constants: Strings of alphanumeric characters beginning with a capital letter and (sometimes) superscripted by their “arity”: Examples: BeatsUp 2, Tired 1 Other symbols: Propositional connectives , , !, $, and , delimiters (, ), [, ].

18 18 Terms An object constant is a term.An object constant is a term. A function constant of arity n, followed by n terms in parentheses and separated by commas, is a term.A function constant of arity n, followed by n terms in parentheses and separated by commas, is a term. Examples: fatherOf(George), times(3, minus(5, 2))

19 19WffsAtoms: A relation constant of arity n followed by n terms in parentheses and separated by commas is an atom. An atom is a wff.A relation constant of arity n followed by n terms in parentheses and separated by commas is an atom. An atom is a wff. Examples: Tired(John), OlderThan(Hans, Peter)Examples: Tired(John), OlderThan(Hans, Peter) Propositional wffs: Any expression formed out of predicate-calculus wffs in the same way that the propositional calculus forms wffs out of other wffs is a propositional wff.Any expression formed out of predicate-calculus wffs in the same way that the propositional calculus forms wffs out of other wffs is a propositional wff. Example: OlderThan(John, Peter)  OlderThan(Peter, Jennifer)Example: OlderThan(John, Peter)  OlderThan(Peter, Jennifer)

20 20Quantification Introducing the universal quantifier  and the existential quantifier  facilitates the translation of world knowledge into predicate calculus. Examples: Paul hates all professors who fail him.  x(Professor(x)  Fails(x, Paul) ! Hates(Paul, x)) There is at least one intelligent Sharif professor.  x(SharifProf(x)  Intelligent(x))

21 21 Rules of Inference  x P(x)  x P(x)__________  P(c) if c  U Universal instantiation P(c) for an arbitrary c  U ___________________   x P(x) Universal generalization  x P(x)  x P(x)______________________  P(c) for some element c  U Existential instantiation P(c) for some element c  U ____________________   x P(x) Existential generalization

22 22 Quantifiers Properties of quantifiers: –  x  y is the same as  y  x –  x  y is the same as  y  x – note:  x  y can be written as  x  y likewise with  Example? –  x  y Likes(x,y) is active voice: Everyone likes everyone. Everyone likes everyone. –  y  x Likes(x,y) is passive voice: Everyone is liked by everyone. Everyone is liked by everyone.

23 23 Quantifiers Properties of quantifiers: –  x  y is not the same as  y  x –  x  y is not the same as  y  x Example? –  x  y Likes(x,y) is active voice: Everyone likes someone. Everyone likes someone. –  y  x Likes(x,y) is passive voice: Someone is liked by everyone. Someone is liked by everyone.

24 24 Quantifiers Properties of quantifiers: –  x P(x) is the same as  x  P(x) –  x P(x) is the same as  x  P(x) Example? –  x Likes(x,IceCream) Everyone likes ice cream. Everyone likes ice cream. –  x  Likes(x,IceCream) No one doesn't like ice cream. It's a double negative! It's a double negative!

25 25 Quantifiers Properties of quantifiers: –  x P(x) when negated is  x  P(x) –  x P(x) when negated is  x  P(x) Example? –  x Likes(x,IceCream) Everyone likes ice cream. Everyone likes ice cream. –  x  Likes(x,IceCream) Someone doesn't like ice cream. Someone doesn't like ice cream. –This is from the application of de Morgan's law to the fully instantiated sentence.

26 26 Basics A free variable is a variable that isn't bound by a quantifier. –  y Likes(x,y) x is free, y is bound x is free, y is bound A well-formed formula is a sentence where all variables are quantified.

27 27 Summary Term: Constant, variable, or Function(term 1, …, term n ) denotes an object in the world Ground Term has no variables Atom: Predicate(term 1, …, term n ), term 1 = term 2 is smallest expression assigned a truth value Sentence: atom, quantified sentence with variables or complex sentence using connectives is assigned a truth value Well-Formed Formula (wff): sentence where all variables are quantified

28 28 An example of E.I. 1.  x(Bottle(x,T1)  Upturned(x, T2)) 2.  x  y(Upturned(x, y)  Empty(x, y)) 3.  x(Full(x, T1) & Empty(x, T2)  Wet(Floor)) 4.  x (Bottle(x, T1) & Full(x, T1)) T1T2 b1b2b3 b1b2b3

29 29 An example of E.I. 5. Bottle(b1, T1) & Full(b1, T1))- EI assumption 6.Bottle(b1, T1)- &, 5 7.Full(b1, T1)- &, 5 8.Upturned (b1, T2)- , 1, - , 6 9.Empty(b1, T2)- , 2, - , 7 10.Full(b1, T1) & Empty (b1, T2)+ &, 7, 9 11.Wet(Floor) - , 3, - , 10 Wet(Floor)- EI conclusion


Download ppt "1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about."

Similar presentations


Ads by Google