300 likes | 575 Views
Knowledge Representation and Reasoning. Knowledge Representation & Reasoning. How knowledge about the world can be represented What kinds of reasoning can be done with that knowledge. Two different systems that are commonly used to represent knowledge: Propositional calculus
E N D
Knowledge Representation • and Reasoning
Knowledge Representation & Reasoning • How knowledge about the world can be represented • What kinds of reasoning can be done with that knowledge. • Two different systems that are commonly used to represent knowledge: • Propositional calculus • Predicate calculus
Propositional Calculus • In propositional calculus, • features of the world are represented by propositions, • relationships between features (constraints) are represented by connectives. • Example: • LECTURE_BORING TIME_LATE ! SLEEP
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, • inference rules for manipulating sentences in that language, and • semantics for associating elements of the language with elements of the world, • then we have a system called logic.
Logic • 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. • Logic provides a way of manipulating big collections of sets by manipulating short descriptions instead.
What is a logic? • A formal language: • Syntax – what expressions are legal • Semantics – what legal expressions mean • Proof system – a way of manipulating syntactic expressions to get other syntactic expressions (which will tell us something new)
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” • “and” • ! “implies” or “if-then” • $ “equivalence” • “not”
Propositional Logic • Syntax of well-formed formulas (wffs): • Any atom is a wff. • If 1 and 2 are wffs, so are • 1 2 (conjunction) • 1 2 (disjunction) • 1! 2 (implication) • 1$ 2 (double implication) • 1 (negation) • There are no other wffs.
Propositional Logic • Atoms and negated atoms are called literals. • In 1 ! 2 , 1 is called the antecedent, and 2 is called the consequent of the implication. • Examples of wffs (sentences): • (P Q) ! P • P ! P • P P ! P • (P ! Q) ! (Q ! P) P
Precedence highest lowest • 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)
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 conclusionbelow a bar, where means “therefore”.
Rules of Inference Q P ! Q _____ P Modus tollens Addition • P • ______ • PQ P ! Q Q ! R _______ P ! R PQ _____ P Hypothetical syllogism Simplification P Q ______ PQ PQ P _____ Q Conjunction Disjunctive syllogism
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, • relation constants, and • function constants • These symbols will be used to refer to objects in the world and to propositions about the world.
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
Syntax of First-Order Logic in BNF Connective | | | | $ Quantifier | Constant A | X1 | John | … Variable a | v | x | … Predicate Before | HasColor | Raining | … Function MotherOf | LegOf | …
Components • 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: fatherOf1, distanceBetween2
Components • Relation constants: • Strings of alphanumeric characters beginning with a capital letter and (sometimes) superscripted by their “arity”: • Examples: BeatsUp2, Tired1 • Other symbols: • Propositional connectives , , !, $ , and , delimiters (, ), [, ].
Terms • 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. • Examples: fatherOf(George), times(3, minus(5, 2))
Wffs • Atoms: • 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) • 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. • Example: OlderThan(John, Peter) OlderThan(Peter, Jennifer)
Quantification • 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))
Rules of Inference Universal instantiation • x P(x) • __________ • P(c) if cU P(c) for an arbitrary cU ___________________ x P(x) Universal generalization x P(x) ______________________ P(c) for some element cU Existential instantiation P(c) for some element cU ____________________ x P(x) Existential generalization
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. • "y "x Likes(x,y) is passive voice: Everyone is liked by everyone.
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. • $y "x Likes(x,y) is passive voice: Someone is liked by everyone.
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. • Ø$x ØLikes(x,IceCream) No one doesn't like ice cream. It's a double negative!
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. • $x ØLikes(x,IceCream) Someone doesn't like ice cream. • This is from the application of de Morgan's lawto the fully instantiated sentence.
Basics • A free variable is a variable thatisn't bound by a quantifier. • $y Likes(x,y) x is free, y is bound • A well-formed formula is a sentence whereall variables are quantified.
Summary • Term: Constant, variable, or Function(term1, …, termn) • denotes an object in the world • Ground Term has no variables • Atom: Predicate(term1, …, termn), term1 = term2 • 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
An example of E.I. b1 b2 b3 • x(Bottle(x,T1) Upturned(x, T2)) • xy(Upturned(x, y) Empty(x, y)) • x(Full(x, T1) & Empty(x, T2) Wet(Floor)) • x (Bottle(x, T1) & Full(x, T1)) b1 b2 b3 T1 T2
An example of E.I. • Bottle(b1, T1) & Full(b1, T1)) - EI assumption • Bottle(b1, T1) - & , 5 • Full(b1, T1) - & , 5 • Upturned (b1, T2) - , 1 , - , 6 • Empty(b1, T2) - , 2 , - , 7 • Full(b1, T1) & Empty (b1, T2) + & , 7, 9 • Wet(Floor) - , 3, - , 10 • Wet(Floor) - EI conclusion