1 / 106

Chapter- 4: Knowledge Representation, Inference and Reasoning

Chapter- 4: Knowledge Representation, Inference and Reasoning. Knowledge Representation. The objective of knowledge representation is to express the knowledge about the world in a computer-tractable form Key aspects of knowledge representation languages are:

jayers
Télécharger la présentation

Chapter- 4: Knowledge Representation, Inference and Reasoning

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter- 4: Knowledge Representation, Inference and Reasoning

  2. Knowledge Representation • The objective of knowledge representation is to express the knowledge about the world in a computer-tractable form • Key aspects of knowledge representation languages are: • Syntax: describes how sentences are formed in the language. • Semantics: describes the meaning of sentences, what is it the sentence refers to in the real world. • Computational aspect: describes how sentences and objects are manipulated in concordance with semantically conventions. • A formal language is required to represent knowledge in a computer tractable form and reasoning processes are required to manipulate this knowledge to deduce non-obvious facts.

  3. Knowledge Representation using Logic • Logic is defined as a formal language for expressing knowledge and ways of reasoning. • Logic makes statements about the world which are true (or false). • Compared to natural languages (expressive but context sensitive) and programming languages (good for concrete data structures but not expressive) logic combines the advantages of natural languages and formal languages. • Logic is: • concise • unambiguous • context insensitive • expressive • effective for inferences

  4. What is logic ? A logic is defined by the following: • Syntax- describes the possible configurations that constitute sentences. • Semantics- determines what facts in the world the sentences refer to i.e. the interpretation. Each sentence makes a claim about the world. • Proof theory - set of rules for generating new sentences that are necessarily true given that the old sentences are true. The relationship between sentences is called entailment. The semantics link these sentences (representation) to facts of the world. The proof can be used to determine new facts which follow from the old. • A set of sentences – A sentence is constructed from a set of primitives according to syntax rules. • A set of interpretations – An interpretation gives a semantic to primitives. It associates primitives with values. • The valuation (meaning) function – Assigns a value (typically the truth value) to a given sentence under some interpretation. sentence × interpretation →{True , False }

  5. Knowledge representation using logic shows: • How logic can be used to form representations of the world? • How a process of inference can be used to derive new representations about the world? • How these can be used by an intelligent agent to deduce what to do.

  6. What is well-formed formula? • In mathematical, propositional and predicate logic •  well-formed formula, abbreviated WFF or wff, often simply formula, is a finite sequence of symbols from a given alphabet that is part of a formal language . A formal language can be identified with the set of formulas in the language •  Formula is a syntactic object that can be given a semantic meaning by means of an interpretation. Two key uses of formulas are in propositional logic and predicate logic.

  7. Rules for constructing Wffs • A predicate name followed by a list of variables such as P(x, y), where P is a predicate name, and x and y are variables, is called an atomic formula. Wffs are constructed using the following rules: • True and False are wffs.  • Each propositional constant (i.e. specific proposition), and each propositional variable (i.e. a variable representing propositions) are wffs. • Each atomic formula (i.e. a specific predicate with variables) is a wff. • If A, B are wffs, then so are  A, (A     B), (A  V  B)  (AB), and (A  ↔ B). • If x is a variable (representing objects of the universe of discourse), and A is a wff, then so are    x A and   x A .

  8. Propositional logic • A propositional logic is a declarative sentence which can be either true or false but not both or either. • Propositional logic is a mathematical model that allows us to reason about the truth or false of logical expression. • In propositional logic, there are atomic sentences and compound sentences (built up from atomic sentences using logical connectives)

  9. A set of connectives:

  10. 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”

  11. Propositional logic (PL) • A simple language useful for showing key ideas and definitions • User defines a set of propositional symbols, like P and Q. • User defines the semantics of each propositional symbol: • P means “It is hot” • Q means “It is humid” • R means “It is raining” • A sentence (well formed formula) is defined as follows: • A symbol is a sentence • If S is a sentence, then S is a sentence • If S is a sentence, then (S) is a sentence • If S and T are sentences, then (S  T), (S  T), (S  T), and (S ↔ T) are sentences • A sentence results from a finite number of applications of the above rules

  12. A BNF grammar of sentences in propositional logic S := <Sentence> ; <Sentence> := <AtomicSentence> | <ComplexSentence> ; <AtomicSentence> := "TRUE" | "FALSE" | "P" | "Q" | "S" ; <ComplexSentence> := "(" <Sentence> ")" | <Sentence> <Connective> <Sentence> | "NOT" <Sentence> ; <Connective> := "NOT" | "AND" | "OR" | "IMPLIES" | "EQUIVALENT" ;

  13. Some terms • The meaning or semantics of a sentence determines its interpretation. • Given the truth values of all symbols in a sentence, it can be “evaluated” to determine its truth value (True or False). • A model for a KB is a “possible world” (assignment of truth values to propositional symbols) in which each sentence in the KB is True.

  14. More terms • A valid sentence or tautology is a sentence that is True under all interpretations, no matter what the world is actually like or how the semantics are defined. Example: “It’s raining or it’s not raining.” • An inconsistent sentence or contradiction is a sentence that is False under all interpretations. The world is never like what it describes, as in “It’s raining and it’s not raining.” • P entails Q, written P |= Q, means that whenever P is True, so is Q. In other words, all models of P are also models of Q.

  15. Truth Table in Propositional Logic

  16. Inference rules • Logical inference is used to create new sentences that logically follow from a given set of predicate calculus sentences (KB). • An inference rule is sound if every sentence X produced by an inference rule operating on a KB logically follows from the KB. (That is, the inference rule does not create any contradictions) • An inference rule is complete if it is able to produce every expression that logically follows from (is entailed by) the KB. (Note the analogy to complete search algorithms.)

  17. Inference rules • Soundness is the property of only being able to prove "true" things. • Completeness is the property of being able to prove all true things. • So a given logical system is sound if and only if the inference rules of the system admit only valid formulas. Or another way, if we start with valid premises, the inference rules do not allow an invalid conclusion to be drawn. • A system is complete if and only if all valid formula can be derived from the axioms and the inference rules. So there are no valid formula that we can't prove.

  18. Sound rules of inference • Here are some examples of sound rules of inference • A rule is sound if its conclusion is true whenever the premise is true • Each can be shown to be sound using a truth table RULEPREMISE CONCLUSION Modus Ponens A, A  B B And Introduction A, B A  B And Elimination A  B A Double Negation A A Unit Resolution A  B, B A Resolution A  B, B  C A  C

  19. Proving things • A proof is a sequence of sentences, where each sentence is either a premise or a sentence derived from earlier sentences in the proof by one of the rules of inference. • The last sentence is the theorem (also called goal or query) that we want to prove. • Example for the “weather problem” given above. 1 Humid Premise “It is humid” 2 HumidHot Premise “If it is humid, it is hot” 3 Hot Modus Ponens(1,2) “It is hot” 4 (HotHumid)Rain Premise “If it’s hot & humid, it’s raining” 5 HotHumid And Introduction(1,2) “It is hot and humid” 6 Rain Modus Ponens(4,5) “It is raining”

  20. Horn Clause/Sentences • Horn clause is a logical formula of a particular rule-like form which gives it useful properties for use in logic programming. • A Horn clause is a clause (a disjunction of literals) with at most one positive literal. • A Horn clause with exactly one positive literal is a definite clause. Eg; ¬p ∨ ¬q ∨ ... ∨ ¬t ∨ u (assume that, if p and q and ... and t all holds, then also u holds) • A definite clause with no negative literals is sometimes called a fact. Eg: u (assume that u holds). • Horn clause without a positive literal is sometimes called a goal clause i.e. the empty clause consisting of no literals is a goal clause. Eg: ¬p ∨ ¬q ∨ ... ∨ ¬t (show that p and q and ... and t all holds)

  21. Entailment and derivation • Entailment: KB |= Q • Q is entailed by KB (a collection of sentences.) if and only if there is no logically possible world in which Q is false while all the premises in KB are true. • Or, stated positively, Q is entailed by KB if and only if the conclusion is true in every logically possible world in which all the premises in KB are true. • Derivation: KB |- Q • We can derive Q from KB if there is a proof consisting of a sequence of valid inference steps starting from the premises in KB and resulting in Q

  22. Two important properties for inference Soundness: If KB |- Q then KB |= Q • If Q is derived from a set of sentences KB using a given set of rules of inference, then Q is entailed by KB. • Hence, inference produces only real entailments, or any sentence that follows deductively from the premises is valid. Completeness: If KB |= Q then KB |- Q • If Q is entailed by a set of sentences KB, then Q can be derived from KB using the rules of inference. • Hence, inference produces all entailments, or all valid sentences can be proved from the premises.

  23. Entailment and derivation • If your knowledge base ‘KB’ entails ‘q’ then all interpretations (assigning ‘true’ or ‘false’ values to variables) that evaluate your knowledge to True also evaluate q to True. KB |= q. • Inference is a procedure for deriving a new sentence ‘p’ from ‘KB’ following some algorithm. KB |-p. The inference algorithm is sound if it derives only sentences that are entailed by KB. • The inference algorithm is complete if whatever can be entailed by KB can also be inferred from KB.

  24. Propositional logic is a weak language • Hard to identify “individuals” (e.g., Mary, 3) • Can’t directly talk about properties of individuals or relations between individuals (e.g., “Bill is tall”) • Generalizations, patterns, regularities can’t easily be represented (e.g., “all triangles have 3 sides”) • First-Order Logic (abbreviated FOL or FOPC) is expressive enough to concisely represent this kind of information FOL adds relations, variables, and quantifiers, e.g., • “Every elephant is gray”: x (elephant(x) → gray(x)) • “There is a white alligator”: x (alligator(X) ^ white(X))

  25. Pros and cons of propositional logic • Propositional logic is declarative -Knowledge and inference are separate  Propositional logic allows partial/disjunctive/negated information • unlike most programming languages and databases • Propositional logic is compositional: • meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2  Meaning in propositional logic is context-independent • unlike natural language, where meaning depends on context  Propositional logic has limited expressive power • unlike natural language • E.g., cannot say "pits cause breezes in adjacent squares“ • except by writing one sentence for each square

  26. Example • Consider the problem of representing the following information: • Every person is mortal. • Confucius is a person. • Confucius is mortal. • How can these sentences be represented so that we can infer the third sentence from the first two?

  27. Example II • In PL we have to create propositional symbols to stand for all or part of each sentence. For example, we might have: P = “person”; Q = “mortal”; R = “Confucius” • so the above 3 sentences are represented as: P  Q; R  P; R  Q • Although the third sentence is entailed by the first two, we needed an explicit symbol, R, to represent an individual, Confucius, who is a member of the classes “person” and “mortal” • To represent other individuals we must introduce separate symbols for each one, with some way to represent the fact that all individuals who are “people” are also “mortal”

  28. Home Work Encode the following scenario in propositional logic, and prove the conclusion: If the races are fixed or the gambling houses are crooked, then the tourist trade will decline. If the tourist trade declines then the police force will be happy. The police force is never happy.Conclusion: The races are not fixed RF= Race fixed GC= Gambling Crooked TTD= Tourist Trade Decline PF= Police Force Solution: ??

  29. Home Work • Axioms: If you work hard then you get lucky. Either you get lucky or you work hard, or both. If you get lucky then, either you are not a rogue or you work hard (but not both). You are a rogue. • Conjecture: You work hard. • Axioms: If Mary loves Pat then Mary loves Quincy. If it is Monday then Mary loves Pat or Quincy (or both). Mary does not love both Pat and Quincy. • Conjecture 1: If it is Monday then Mary loves Pat. • Conjecture 2: If it is Monday then Mary loves Quincy. • Axioms: If the car has no fuel or it has no spark, then it will not start. The car has a spark. The car will not start. • Conjecture: The car has no fuel.

  30. Predicate Logic • Predicate logic is an extension of propositional logic with more expressive power. • In propositional logic, each possible atomic fact requires a separate unique propositional symbol. • If there are n people and m locations, representing the fact that some person moved from one location to another requires (nm2) separate symbols.

  31. Predicate Logic Cont…. • Predicate logic includes a richer ontology: -objects (terms) -properties (unary predicates on terms) -relations (n-ary predicates on terms) -functions (mappings from terms to other terms) • Allows more flexible and compact representation of knowledge: Move(x, y, z) for person x moved from location y to z. • Predicate Symbols are used to denote a property of objects or a relation between objects

  32. First-Order Logic • Propositional logic assumes the world contains facts, • First-order logic (like natural language) assumes the world contains • Objects: people, houses, numbers, colors, baseball games, wars, … • Relations: red, round, prime, brother of, bigger than, part of, comes between, … • Functions: father of, best friend, one more than, plus, …

  33. Logics in General • Ontological Commitment: • What exists in the world — TRUTH • PL : facts hold or do not hold. • FOL : objects with relations between them that hold or do not hold • Epistemological Commitment: • What an agent believes about facts — BELIEF

  34. Syntax of FOL: Basic elements • Constant Symbols: • Stand for objects • e.g., KingJohn, 2, UCI,... • Predicate Symbols • Stand for relations • E.g., Brother(Richard, John), greater_than(3,2)... • Function Symbols • Stand for functions • E.g., Sqrt(3), LeftLegOf(John),...

  35. Syntax of FOL: Basic elements • Constants KingJohn, 2, UCI,... • Predicates Brother, >,... • Functions Sqrt, LeftLegOf,... • Variables x, y, a, b,... • Connectives , , , ,  • Equality = • Quantifiers , 

  36. Relations • Some relations are properties: they state some fact about a single object: Round(ball), Prime(7). • n-ary relations state facts about two or more objects: Married(John,Mary), LargerThan(3,2). • Some relations are functions: their value is another object: Plus(2,3), Father(Dan).

  37. Models for FOL: Example

  38. Terms • Term = logical expression that refers to an object. • There are 2 kinds of terms: • constant symbols: Table, Computer • function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc

  39. 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. Function Binary relation

  40. Complex Sentences • We make complex sentences with connectives (just like in propositional logic). property binary relation function objects connectives

  41. More Examples • Brother(Richard, John)  Brother(John, Richard) • King(Richard)  King(John) • King(John) =>  King(Richard) • LessThan(Plus(1,2) ,4)  GreaterThan(1,2) (Semantics are the same as in propositional logic)

  42. Variables • Person(John) is true or false because we give it a single argument ‘John’ • We can be much more flexible if we allow variables which can take on values in a domain. e.g., all persons x, all integers i, etc. • E.g., can state rules like Person(x) => HasHead(x) or Integer(i) => Integer(plus(i,1)

  43. Universal Quantification  •  means “for all” • Allows us to make statements about all objects that have certain properties • Can now state general rules:  x King(x) => Person(x) • x Person(x) => HasHead(x) • i Integer(i) => Integer(plus(i,1)) 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 this

  44. Existential Quantification  •  x means “there exists an x such that….” (at least one object x) • Allows us to make statements about some object without naming it • Examples:  x King(x)  x Lives_in(John, Castle(x)) • iInteger(i) GreaterThan(i,0) Note that  is the natural connective to use with  (And => is the natural connective to use with  )

  45. Using FOL • Brothers are siblings x,yBrother(x,y) Sibling(x,y) • One's mother is one's female parent x,yMother(x,y)(Female(x) Parent(x,y)) • “Sibling” is symmetric x,ySibling(x,y) Sibling(y,x)

  46. Combining Quantifiers  x  y Loves(x,y) • For everyone (“all x”) there is someone (“y”) who loves them • y  x Loves(x,y) - there is someone (“y”) who loves everyone Clearer with parentheses:  y (  x Loves(x,y) )

  47. Connections between Quantifiers • Asserting that all x have property P is the same as asserting that does not exist any x that don’t have the property P  x Likes(x, 271 class)   x Likes(x, 271 class) In effect: -  is a conjunction over the universe of objects -  is a disjunction over the universe of objects Thus, DeMorgan’s rules can be applied

  48. De Morgan’s Law for Quantifiers Generalized De Morgan’s Rule De Morgan’s Rule Rule is simple: if you bring a negation inside a disjunction or a conjunction, always switch between them (or and, and  or).

  49. Translating English to FOL • Every gardener likes the sun. ( x) gardener(x) => likes(x,Sun) • You can fool some of the people all of the time. ( x) (person(x) ^ ( t)(time(t) => can-fool(x,t))) • You can fool all of the people some of the time. ( 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) or, equivalently, ( x) (mushroom(x) ^ purple(x)) => ~poisonous(x)

  50. Using FOL • We want to TELL things to the KB, e.g. TELL(KB, ) TELL(KB, King(John) ) These sentences are assertions • We also want to ASK things to the KB, ASK(KB, ) these are queries or goals The KB should return the list of x’s for which Person(x) is true: {x/John,x/Richard,...}

More Related