1 / 95

CptS 440 / 540 Artificial Intelligence

CptS 440 / 540 Artificial Intelligence. Knowledge Representation. Knowledge Representation. Knowledge Representation. When we use search to solve a problem we must Capture the knowledge needed to formalize the problem Apply a search technique to solve problem

clara
Download Presentation

CptS 440 / 540 Artificial Intelligence

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. CptS 440 / 540Artificial Intelligence Knowledge Representation

  2. Knowledge Representation

  3. Knowledge Representation • When we use search to solve a problem we must • Capture the knowledge needed to formalize the problem • Apply a search technique to solve problem • Execute the problem solution

  4. Role of KR • The first step is the role of “knowledge representation” in AI. • Formally, • The intended role of knowledge representation in artificial intelligence is to reduce problems of intelligent action to search problems. • A good description, developed within the conventions of a good KR, is an open door to problem solving • A bad description, using a bad representation, is a brick wall preventing problem solving

  5. A Knowledge-Based Agent • We previously talked about applications of search but not about methods of formalizing the problem. • Now we look at extended capabilities to general logical reasoning. • Here is one knowledge representation: logical expressions. • A knowledge-based agent must be able to • Represent states, actions, etc. • Incorporate new percepts • Update internal representations of the world • Deduce hidden properties about the world • Deduce appropriate actions • We will • Describe properties of languages to use for logical reasoning • Describe techniques for deducing new information from current information • Apply search to deduce (or learn) specifically needed information

  6. The Wumpus World Environment

  7. Percepts

  8. WW Agent Description • Performance measure • gold +1000, death -1000 • -1 per step, -10 for using arrow • Environment • Squares adjacent to wumpus are smelly • Squares adjacent to pit are breezy • Glitter iff gold is in same square • Shooting kills wumpus if agent facing it • Shooting uses up only arrow • Grabbing picks up gold if in same square • Releasing drops gold in same square • Actuators • Left turn, right turn, forward, grab, release, shoot • Sensors • Breeze, glitter, smell, bump, scream

  9. WW Environment Properties • Observable? • Partial • Deterministic? • Yes • Episodic? • Sequential • Static? • Yes (for now), wumpus and pits do not move • Discrete? • Yes • Single agent? • Multi (wumpus, eventually other agents)

  10. Sample Run

  11. Sample Run

  12. Sample Run

  13. Sample Run

  14. Sample Run

  15. Sample Run

  16. Sample Run

  17. Sample Run

  18. Sample Run • Now we look at • How to represent facts / beliefs • “There is a pit in (2,2) or (3,1)” • How to make inferences • “No breeze in (1,2), so pit in (3,1)”

  19. Representation, Reasoning and Logic • Sentence: Individual piece of knowledge - English sentence forms one piece of knowledge in English language - Statement in C forms one piece of knowledge in C programming language • Syntax: Form used to represent sentences - Syntax of C indicates legal combinations of symbols - a = 2 + 3; is legal - a = + 2 3 is not legal - Syntax alone does not indicate meaning • Semantics: Mapping from sentences to facts in the world - They define the truth of a sentence in a “possible world”- Add the values of 2 and 3, store them in the memory location indicated by variable a • In the language of arithmetic: x + 2 >= y is a sentence x2 + y > is not a sentence x + 2 >= y is true in all worlds where the number x + 2 is no less than the number y x + 2 >= y is true in a world where x = 7, y = 1 x + 2 >= y is false in a world where x = 0, y = 6

  20. Entailment • There can exist a relationship between items in the language • Sentences “entail” sentences (representation level) • Facts “follow” from facts (real world) • Entail / Follow mean the new item is true if the old items are true • A collection of sentences, or knowledge base (KB), entail a sentence • KB |= sentence • KB entails the sentence iff the sentence is true in all worlds where the KB is true Entails Sentences Sentence Semantics Semantics Representation World Follows Facts Fact

  21. Entailment Examples • KB • The Giants won • The Reds won • Entails • Either the Giants won or the Reds won • KB • To get a perfect score your program must be turned in today • I always get perfect scores • Entails • I turned in my program today • KB • CookLectures -> TodayIsTuesday v TodayIsThursday • - TodayIsThursday • TodayIsSaturday -> SleepLate • Rainy -> GrassIsWet • CookLectures v TodayIsSaturday • - SleepLate • Which of these are correct entailments? • - Sleeplate • GrassIsWet • - SleepLate v GrassIsWet • TodayIsTuesday • True

  22. Models • Logicians frequently use models, which are formally structured worlds with respect to which truth can be evaluated. These are our “possible worlds”. • M is a model of a sentence s if s is true in M. • M(s) is the set of all models of s. • KB entails s (KB |= s) if and only if M(KB) is a subset of M(s) • For example, KB = Giants won and Reds won, s = Giants won

  23. Entailment in the Wumpus World • Situation after detecting nothing in [1,1], moving right, breeze in [2,1] • Consider possible models for the situation (the region around the visited squares) assuming only pits, no wumpi • 3 Boolean choices, so there are 8 possible models

  24. Wumpus Models

  25. Wumpus Models KB = wumpus world rules + observations

  26. Wumpus Models KB = wumpus world rules + observations Possible conclusion: alpha1 = “[1,2] is safe” KB |= alpha1, proved by model checking

  27. Wumpus Models KB = wumpus world rules + observations alpha2 = “[2,2] is safe”, KB |= alpha2

  28. Inference • Use two different ways: • Generate new sentences that are entailed by KB • Determine whether or not sentence is entailed by KB • A sound inference procedure generates only entailed sentences • Modus ponens is sound • Abduction is not sound • Logic gone bad

  29. Definitions • A complete inference procedure can generate all entailed sentences from the knowledge base. • The meaning of a sentence is a mapping onto the world (a model). • This mapping is an interpretation (interpretation of Lisp code). • A sentence is valid (necessarily true, tautology) iff true under all possible interpretations. • A V -A • A could be: • Stench at [1,1] • Today is Monday • 2+3=5 • These statements are not valid. • A ^ -A • A V B • The last statement is satisfiable, meaning there exists at least one interpretation that makes the statement true. The previous statement is unsatisfiable.

  30. Logics • Logics are formal languages for representing information such that conclusions can be drawn • Logics are characterized by their “primitives” commitments • Ontological commitment: What exists? Facts? Objects? Time? Beliefs? • Epistemological commitment: What are the states of knowledge?

  31. Examples • Propositional logic • Simple logic • Symbols represent entire facts • Boolean connectives (&, v, ->, <=>, ~) • Propositions (symbols, facts) are either TRUE or FALSE • First-order logic • Extend propositional logic to include variables, quantifiers, functions, objects

  32. Propositional Logic • Proposition symbols P, Q, etc., are sentences • The true/false value of propositions and combinations of propositions can be calculated using a truth table • If P and S are sentences, then so are –P, P^Q, PvQ, P->Q, P<->Q • An interpretation I consists of an assignment of truth values to all proposition symbols I(S) • An interpretation is a logician's word for what is often called a “possible world” • Given 3 proposition symbols P, Q, and R, there are 8 interpretations • Given n proposition symbols, there are 2n interpretations • To determine the truth of a complex statement for I, we can • Substitute I's truth value for every symbol • Use truth tables to reduce the statement to a single truth value • End result is a single truth value, either True or False

  33. Propositional Logic • For propositional logic, a row in the truth table is one interpretation • A logic is monotonic as long as entailed sentences are preserved as more knowledge is added

  34. Rules of Inference for Propositional Logic • Modus ponens • And introduction • Or introduction • And elimination • Double-negation elimination • Unit resolution • Resolution • All men are mortal (Man -> Mortal) • Socrates is a man (Man) • ----------------------------------------------- • Socrates is mortal (Mortal) • Today is Tuesday or Thursday • Today is not Thursday • --------------------------------------- • Today is Tuesday • Today is Tuesday or Thursday • Today is not Thursday or tomorrow is Friday • ---------------------------------------------------------- • Today is Tuesday or tomorrow is Friday

  35. Normal Forms • Other approaches to inference use syntactic operations on sentences, often expressed in standardized forms • Conjunctive Normal Form (CNF) conjunction of disjunctions of literals (conjunction of clauses)For example, (A v –B) ^ (B v –C v –D) • Disjunctive Normal Form (DNF) disjunction of conjunctions of literals (disjunction of terms)For example, (A ^ B) v (A ^ -C) v (A ^ -D) v (-B ^ -C) v (-B ^ -D) • Horn Form (restricted) conjunction of Horn clauses (clauses with <= 1 positive literal) For example, (A v –B) ^ (B v –C v –D)Often written as a set of implications: B -> A and (C ^ D) -> B

  36. Proof methods • Model checking • Truth table enumeration (sound and complete for propositional logic) • Show that all interpretations in which the left hand side of the rule is true, the right hand side is also true • Application of inference rules • Sound generation of new sentences from old Proof = a sequence of inference rule applications Can use inference rules as operators in a standard search algorithm

  37. Wumpus World KB • Vocabulary • Let Pi,j be true if there is a pit in [i,j] • Let Bi,j be true if there is a breeze in [i,j] • Sentences • -P1,1 • -B1,1 • B2,1 • “Pits cause breezes in adjacent squres” • B1,1 <-> P1,2 v P2,1 • B2,1 <-> P1,1 v P2,2 v P3,1

  38. An Agent for the Wumpus World • Imagine we are at a stage in the game where we have had some experience • What is in our knowledge base? • What can we deduce about the world? • Example: Finding the wumpus • If we are in [1,1] and know • -S11 • S12 • S21 • -S11 -> -W11 & -W12 & -W21 • S12 -> W11 v W12 v W13 v W22 • S21 -> W11 v W21 v W31 v W22 • What can we conclude?

  39. Limitations of Propositional Logic • Propositional logic cannot express general-purpose knowledge succinctly • We need 32 sentences to describe the relationship between wumpi and stenches • We would need another 32 sentences for pits and breezes • We would need at least 64 sentences to describe the effects of actions • How would we express the fact that there is only one wumpus? • Difficult to identify specific individuals (Mary, among 3) • Generalizations, patterns, regularities difficult to represent (all triangles have 3 sides)

  40. First-Order Predicate Calculus • Propositional Logic uses only propositions (symbols representing facts), only possible values are True and False • First-Order Logic includes: • Objects: peoples, numbers, places, ideas (atoms) • Relations: relationships between objects (predicates, T/F value) • Example: father(fred, mary) • Properties: properties of atoms (predicates, T/F value) Example: red(ball) • Functions: father-of(mary), next(3), (any value in range) • Constant: function with no parameters, MARY

  41. FOPC Models

  42. Example • Express “Socrates is a man” in • Propositional logic • MANSOCRATES - single proposition representing entire idea • First-Order Predicate Calculus • Man(SOCRATES) - predicate representing property of constant SOCRATES

  43. FOPC Syntax • Constant symbols (Capitalized, Functions with no arguments) Interpretation must map to exactly one object in the world • Predicates (can take arguments, True/False) Interpretation maps to relationship or property T/F value • Function (can take arguments) Maps to exactly one object in the world

  44. Definitions • TermAnything that identifies an object Function(args) Constant - function with 0 args • Atomic sentence Predicate with term arguments Enemies(WilyCoyote, RoadRunner) Married(FatherOf(Alex), MotherOf(Alex)) • Literalsatomic sentences and negated atomic sentences • Connectives (&), (v), (->), (<=>), (~) if connected by , conjunction (components are conjuncts) if connected by , disjunction (components are disjuncts) • QuantifiersUniversal Quantifier Existential Quantifier

  45. Universal Quantifiers • How do we express “All unicorns speak English” in Propositional Logic? • We would need to specify a proposition for each unicorn • is used to express facts and relationships that we know to be true for all members of a group (objects in the world) • A variable is used in the place of an object x Unicorn(x) -> SpeakEnglish(x) The domain of x is the world The scope of x is the statement following (sometimes in []) • Same as specifying • Unicorn(Uni1) -> SpeakEnglish(Uni1) & • Unicorn(Uni2) -> SpeakEnglish(Uni2) & • Unicorn(Uni3) -> SpeakEnglish(Uni3) & • ... • Unicorn(Table1) -> Table(Table1) & • ... • One statement for each object in the world • We will leave variables lower case (sometimes ?x) Notice that x ranges over all objects, not just unicorns. • A term with no variables is a ground term

  46. Existential Quantifier • This makes a statement about some object (not named) • x [Bunny(x) ^ EatsCarrots(x)] • This means there exists some object in the world (at least one) for which the statement is true. Same as disjunction over all objects in the world. • (Bunny(Bun1) & EatsCarrots(Bun1)) v • (Bunny(Bun2) & EatsCarrots(Bun2)) v • (Bunny(Bun3) & EatsCarrots(Bun3)) v • ... • (Bunny(Table1) & EatsCarrots(Table1)) v • ... • What about x Unicorn(x) -> SpeakEnglish(x)? • Means implication applies to at least one object in the universe

  47. DeMorgan Rules • Example:

  48. Other Properties • (X->Y) <-> -XvY • Can prove with truth table • Not true: • (X->Y) <-> (Y->X) • This is a type of inference that is not sound (abduction)

  49. Examples • All men are mortal

  50. Examples • All men are mortal • x [Man(x) -> Mortal(x)]

More Related