1 / 56

Introduction

Introduction. What is knowledge? Try to define it. The study of knowledge is a called epistemology. Knowledge can be further defined as Procedural knowledge Knowing how to do something (eg knowing how to start a car.) Declarative knowledge Knowing that something is true or false

ziv
Télécharger la présentation

Introduction

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. Introduction • What is knowledge? Try to define it. • The study of knowledge is a called epistemology. • Knowledge can be further defined as • Procedural knowledge • Knowing how to do something (eg knowing how to start a car.) • Declarative knowledge • Knowing that something is true or false • Tacit knowledge • eg I know how to put the key in the ignition but do I know how my hand/arm/muscles/tendons/nerves all corordinated? Artificial Intelligence

  2. Fire-Engine Symbol Structure Symbols Red (Fire-Engine) Red Introduction • AI suggests that intelligent behaviour can be achieved through the manipulation of symbol structures • You could use this knowledge to infer new facts. • Galway has a new fire-engine. • It must be red! • We represents facts (on the computer) using data structures and we write program code to reason with them. Artificial Intelligence

  3. Knowledge Representation Languages • High level knowledge representation languages have been developed to make knowledge representation easier • We’ll look at a few of these • Semantic nets • Frames • Predicate logic • Rules Artificial Intelligence

  4. First though…Requirements for a knowledge representation language • It must allow you represent adequately complex facts in a clear and precise yet natural way, and in a way that easily allows you to deduce new facts from your existing knowledge. • adequately complex facts • Known as - Representational adequacy • A level of detail that will produce the results we require and no more • if a simple representation language will be adequate then use a simple language! • dislikes (everybody, sprouts) Artificial Intelligence

  5. Requirements for Knowledge Representation Languages • clear and precise • Known as - Well defined syntax and semantics • no room for confusion and no ambiguities. • Syntax defines the allowable structures which describe how to make sentences • “Dislikes – everybody – sprouts” is not allowed • Semantics defines what it means • “dislikes (everybody, sprouts)” means everybody dislikes sprouts not sprouts dislike everybody. • Natural • Language must not be overly complex and difficult to interpret. • deduce new facts • Known as - Inferential adequacy • The language must support inference. Artificial Intelligence

  6. The main contenders • Broadly speaking there are three main approaches to knowledge representation in AI. • SEMANTIC NETS/FRAMES • Easy to use and relatively natural. • LOGIC • Arguably the most important. With a well defined syntax and semantics. Allows inference but can be difficult to translate the real world into logic. Has difficulties with time, uncertainty and beliefs. • RULES(If fire Then shout help) • Condition-action rules or Production Rules(specifying what to do under certain conditions) within a rule-based system. Artificial Intelligence

  7. Semantic Nets/Frames Artificial Intelligence

  8. Semantic Networks A simple class hierarchy • Allows you to represent classes (or categories) of objects and relationship between objects and to draw simple inferences based on this knowledge. • The net is made up of nodes and arcs/links connecting the nodes. • The links express relationships. Without relationships knowledge is simply a collection of unrelated facts. – with them other knowledge can be inferred. (nellie has a head!) • The nodes express physical objects, concepts or situations. Conclude: Clyde and Nellie both have heads Artificial Intelligence

  9. Semantic Networks • Originally used to represent the meaning of English words • The links represent the relationships . • The most important relations are; • known as a A-KIND-OF (AKO) relationship • known as a IS-A relationship • Other relations also allowed • To represent properties of objects and categories of objects. • Semantic networks normally allow efficient inheritance-based inferences using special purpose algorithms. • Semantic nets in maths are labelled, directed graphs. • Sometimes known as associative nets (i.e. nodes are associated or related to other nodes) Artificial Intelligence

  10. Semantic Networks • Have a Go ! --- Class Problems • Represent each of the following useful pieces of knowledge as a semantic net. • (a) “Floyd is a small hippo who lives in Dublin zoo. Like all hippos he eats grass and likes swimming” • (b) “The aorta is a particular kind of artery which has a diameter of 2.5cm. An artery is a kind of blood vessel. An artery always has a muscular wall, and generally has a diameter of 0.4cm. A vein is a kind of blood vessel, but has a fibrous wall. Blood vessels all have tubular form and contain blood.” Artificial Intelligence

  11. (a) (b) Artificial Intelligence

  12. Semantic Networks • To try and properly define the semantics of a semantic network (what it means) set theory is often employed. • Semantic networks allows us to represent knowledge about objects and relationships between objects in an intuitive way. •  However the sort of inferences that can be supported is fairly restrictive (just inheritance of properties). • Also the lack of any standards for link names is problematic. • A semantic net cannot define knowledge as well as logic can. •  There is no way to encode heuristic knowledge (rules of thumb) into semantic nets. • It remains a good choice as a knowledge representation language for some AI problems – particularly for showing binary relationships. Artificial Intelligence

  13. Frames • Frames are a variant of semantic networks • popular way to represent facts in an expert system. • The difference is basically in the level of detail of a node. • In semantic nets the node has a name. • Properties of a node are shown using other nodes and some sort of relationship linking them. • In a frame the node itself has a structure. • This means that the node can contain values or indeed other frames. • Semantic nets (generally) represent knowledge about a broad area. • Frames represent (related) knowledge about a narrow subject • A frame would be a good choice for describing something such as a car – a computer etc. Artificial Intelligence

  14. A slot value may also be a frame Property and Slot terminology is interchangeable Frames • A frame is basically a group of slots (sometimes called properties) and slot values or fillers) that define a stereotypical object. Artificial Intelligence

  15. Frames • Some of the terminology from frames has been adopted by Oject Orientated technology. • It is straight forward to translate between semantic networks and frame based representaion. • Class and Instance Nodes ---- Objects • Links ---- Slots • Node at end of Link --- Slot value Artificial Intelligence

  16. Semantic Net and Frame Artificial Intelligence

  17. Defaults and Multiple Inheritance • Objects inherit the default property value unless they have an individual property value that conflicts with the inherited one. • Multiple inheritance is difficult and often results in conflicts. • Nellie could be a circus-animal who has been specially “engineered” to be white. Nellie then is a subclass of Elephant and Circus-animal. • Colour? The value for Elephant or for Circus-animal? • The system must provide for these conflicts – such that it will return the right value for colour (white) and the right value for size (large). Artificial Intelligence

  18. Practical Frames • The slots and slot values can be frames. • The slot values could also be procedures, executed when the value for the slot is required. • [The system is then described as having a procedural rather that decalarative semantics] • Implementation of a simple frame system could be carried out with the following algorithm [Note the recursion]; • What is the slot value for object “O’s” slot P. • value(O, P) • If slot name P exits for object O then • Return slot value of P • Else if object O has slot called “subclass” or “instance”. • Then return “Super”, the value of this slot • Find value(Super, P) and return this value. • Else Fail. Artificial Intelligence

  19. Frames and Semantic Nets Summary • Frames and semantic networks provide a clear and simple way of representing properties of objects and categories of objects. A basic inference is available through inheritance. • It does not cope will with • Negation ( not A) • Disjunction (A or B) • Quantification (for all A and some B) Artificial Intelligence

  20. Frames • Go on try it. • Represent the following as frames; • (a) “Hippos live in Africa. Hippos are generally quite large. Floyd is a small hippo who lives in Dublin zoo. Like all hippos he eats grass and likes swimming” • (b) “The aorta is a particular kind of artery which has a diameter of 2.5cm. An artery is a kind of blood vessel. An artery always has a muscular wall, and generally has a diameter of 0.4cm. A vein is a kind of blood vessel, but has a fibrous wall. Blood vessels all have tubular form and contain blood.” Artificial Intelligence

  21. Frames (b) Blood-vessel form tubular contains blood (a) Hippo likes swimming eats grass *lives Africa *size large Artery ako Blood-vessel wall muscular *Diameter 0.4cm Aorta is-a Artery Diameter 2.5cm Vein Ako Blood-vessel Wall fiborous Floyd is-a Hippo lives Dublin Zoo size small Artificial Intelligence

  22. Logic Artificial Intelligence

  23. Logic • Most important knowledge representation language is arguably (predicate) logic. • It allows us to represent fairly complex facts about the world, • To derive new facts in such a way that guarantees that if the initial facts were true then so are the conclusions. • The term “reasoning”, “inference” and “deduction” are generally used to cover any process by which conclusions are reached. • Logic is a formal system which may be described in terms of its syntax, sematics and its proof theory. • First we will look at the simpler propositional logic (sometimes called boolean logic) and then the more useful predicate logic Artificial Intelligence

  24. Propositional Logic • Syntax • Symbols (P, Q, R, S, T ….) are used to represent facts about the world. • “Paul is tall” represented by “P” • “Paul likes rugby” represented by “R” • These simple facts are called atomic propositions. • You can build more complex sentences by combining atomic propositions with logical connectives • Paul is tall AND Paul likes rugby ( PR) • Paul is tall OR Paul likes rugby (P R) • Paul doesn’t like rugby (R) • If Paul is tall then Paul likes rugby ( P  R) • If Paul is tall then Paul likes rugby and vice versa ( P R) Note- The symbol TallPaul could also have been used Artificial Intelligence

  25. Premise or antecedant Conclusion or consequence Propositional Logic - Syntax • Implications () are sometimes called conditionals or rules or if-then statements. • Equivalence () is often called bi-conditional • A sentence can be formed by combining simlper sentences with one of the five logical connectives. • P Q • (P Q) • The logical constants True and False are sentences by themselves • A propositional symbol such as P or Q is also a sentence. • Wrapping parentheses around a sentence yields a sentence eg (PQ). Artificial Intelligence

  26. Propositional Logic - Semantics • The semantics of propositional logic allow us to state precisely what sentences like “P (PQ)” mean. • It is defined in terms of what is true in the world. If we know P and Q are tue then semantic of the language will tell us if sentences like “P (PQ)” are true. • We can determine the truth or falsity of sentences like these using truth tables. If we have the assertion “raining V sunny” and the truth value of the assertion is true. Working backwards from the truth value of the sentence towards the constituent parts gives us the meaning of the sentence. Given the precise semantic of “V” we see that this means that it can be raining and it can be sunny when the sentence is true– without this precise semantics we may not have interpreted this correctly. Artificial Intelligence

  27. Propositional Logic - Semantics The truth table for And and OR and Not are in close accord with our intutition of English words. In some ways the the implication connective () is the most important and the most confusing. Confusing because it does not fit our intutive understanding of “P imples Q” ( or “If P Then Q”). There does not have to be any relation or causation between P and Q. The following sentence is a true sentence of propositinal logic – althought its strange “English” sentence. ( 5 is an odd number)  (Tokoyo is the capital of Japan) Also an implication is true whenever its antecedant (P) is false! (5 is an even number)  (Spiddal is bigger then Rome) Is true regardless of whether Spiddal is indeed bigger than Rome. Think of P  Q as meaning “If P is true then I am claiming that Q is true. Otherwise I make no claims”. Artificial Intelligence

  28. Propositional Logic – Validity and Inference • Truth tables can not only be used to define the connectives but also to test for valid sentences. • We make a row for each of the possibe combinations of truth values for the proposition symbols in the sentence. For each row we calculate the truth value of the entire sentence. If the sentence is true in every row then the sentence is valid. Consider ((PH)H)  P Artificial Intelligence

  29. Propositional Logic – Proof Theory • The process by which the soundness of an inference (such as ((PH)H)  P ) is established through truth tables can be extended to entire classes of of inference. There are certain patterns of inference that occur over and over again – the soundness of this pattern can be shown for once and for all and captured in an inference rule which is universally valid. • Once a rule is built then it can be used to make inferences without going throught the tedious process of building truth tables. • There are many rules of inference here are two. Modus Ponens If AB is True and A is true then B is necessarily true. If its raining then Paul puts on his coat. Its raining out then Paul has his coat on. Given this Infer this Resolution (somewhat like Prolog) Since B cannot be both true and false, then A or C is true Given “sunnyV raining, raining V carryumbrella” we can conclude “sunny V carrycumbrella” Artificial Intelligence

  30. Predicate Logic • Syntax • One problem with propositional logic is that it is not possible to write general statements. • Paul likes everything • Predicate calculus allows general statements • Sentences in predicate calculus are built up from atomic sentences. This allows facts to expressed as a predicate name and some arguments. • likes(paul, rugby) • So rather than having a single proposition “P” to store the fact that “paul likes rugby” we have a predicate logic sentence “likes(paul, rugby)” where we can ‘get at’ the individual entities ‘paul’ and ‘rugby’ Artificial Intelligence

  31. Predicate logic - Syntax • The arguments in an atomic sentence may be any term, such as; • Constant symbols [lowercase such as “paul”] • Variable symbols [Uppercase such as “X”] • Function expressions [such as father(paul) which are composed of a functor followed by arguments, which themselves can be any term] • Sentences can be constructed by combining atomic sentences with logical connectives. • likes(paul, rugby)  likes(paul, soccer) • likes(paul, movies) likes(paul, students) • Sentences can also be formed using the quantifiers (existential quantifier - there exists) and (universal quantifier - for all). [Note: All variables should be quantified] • X(likes(paul,X)  contact_sport(X)) ie There exists a contact sport paul likes •  X  Y (person(X)  likes(X,Y)) ie Everyone like something Atomic sentences likes(paul, rugby) likes(paul, X) friends(father(paul), jim) Artificial Intelligence

  32. Predicate Logic - Semantics • The semantics of predicate logic is defined in terms of the truth values of sentences (like propositional logic). Like propositional logic we can use the truth table to find the truth value of sentences involving logical connectives from the truth value of each part of the sentence. • However we also need to deal with predicates, arguments and quantifiers. For simplicity assume that you can assign a truth value to a sentence like likes(paul, rugby) • The meaning of  can be defined in terms of whether some sentence is true for all objects in the domain of interest.  X S means that for all X in a domain, S is true. • X likes(X, movies) could be verified if we could go to the domain under consideration (such as this class) and verify that likes(joe, movies), likes(jim, movies) etc. • The meaning of  could also be defined in terms of whether some sentences are true for at least one of the objects in the domain of interest. • So if likes(jim, movies) was the only sentence we could show to be true then; • X likes(X, movies) would be false •  X likes(X, movies) would be true. Artificial Intelligence

  33. Predicate Logic • Inference rules in predicate logic are similar to those in propositional logic. • Modus Ponens and Resolution still apply but in a slightly modified format to deal with variables and quantifiers. • All this said the aveage AI programmer doesn’t have to know predicate logic semantics or proof procedures. • However they should know how to represent things in predicate logic and what predicate logic expressions mean. Artificial Intelligence

  34. Predicate Logic • Examples of English sentences converted to predicate logic • John loves Mary • Use the verb as the prediate and the nouns as arguments • loves(john, mary) • Mary is tall • Make a one argument predicate • tall(mary) • If the car is moving then wear the seat belt • Generally translate If X then Y into X  Y • moving(car)  wear(seat_belt) • If Paul is hungry then he eats fruit • Hungry(paul)  eats(paul, fruit) • All Students study • X student(X)  study(X) • These is something small and slimey on the floor • X ((small(X)  slimey(X)  onfloor(X)) Artificial Intelligence

  35. Prolog program Predicate Logic father(jim, fred). father(joe, jim). grandfather(X,Y) :- father (X,Z), father(Z,Y). father(jim, fred) father(joe, jim) XYZ((father (X,Z)  father(Z,Y))  grandfather(X,Y) Logic and Prolog • The most widely used logic programming language is Prolog. It is based on predicate logic. • Each statement in a Prolog program corresponds to a sentence in predicate logic. • The notations are different however and Prolog will only allow a horn clause [only one fact allowed on the right hand side of an implication sign]. This allows a simpler and more efficient goal directed proof procedure to be executed by Prolog. • The Prolog system views your (Prolog) computer program as a set of statements in logic. You then ask the system to prove a statement given the statements in your program. If Prolog was asked “grandfather(joe, fred)” it would repsond “true”. Artificial Intelligence

  36. Logic • Logic is not only used as a knowledge representation language but also; • To communicate AI theories within the AI community • As a basic of AI programming languages • To give the meaning of natural language sentences in a natural language understanding system. • To define the semantics of other simpler representation languages (such as frames). Artificial Intelligence

  37. Logic Summary • Predicate logic is a powerful way to represent and reason with knowledge. • Negation, disjunction and quantification are easily represented using logic (which is not true for frames) • Available proof procedures and inference rules means that a very wide range of inferences are possible (contrast this with frames where only simple inheritance based inference is possible) • Logic has a problem in dealing with uncertainty, defaults and beliefs. Where new logic has been developed to deal with these issues the logic can become overly complex. Artificial Intelligence

  38. Logic - Questions • Give it a go. • Convert the following to the language of predicate logic. • Every apply is either green or yellow • No apple is blue • If an apple is green then its tasty • Every man likes a tasty apple • Some people like garlic • Fido is a doberman and a good dog. • All basketball players are tall Artificial Intelligence

  39. Logic - Questions Convert the following to the language of predicate logic. • Every apply is either green or yellow • No apple is blue • If an apple is green then its tasty • Every man likes a tasty apple • Some people like garlic • Fido is a doberman and a good dog. • All basketball players are tall Artificial Intelligence

  40. Rule Based Systems Artificial Intelligence

  41. Rule-Based Systems • Instead of representing knowledge in a relatively declaratively, static way (as a set of things that are true) rule based systems represent knowledge as a set of rules for different situations that • tell you what to do • or what you can conclude Control Scheme (Intepreter – controls application of rules) Condition action rules IF alarm_beeps THEN ADD smoky IF hot AND smoky THEN ADD fire Database of facts (normally representing things that are true) alarm-beeps hot Note: IF-THEN rule based systems are independent chunks of knowledge, to be invoked, as required, by the interpreter. In C or Java they are treated as a sequence of instructions. They are like implications in logic, alarm_beeps  smoky . Artificial Intelligence

  42. Rule-Based Systems • The interpreter can use one of the following methodologies (reasoning mechanims) to connect a problem with a solution. This is called inference. • Forward chaining (CLIPS and Jess) • Start with some initial facts and the interpreter keeps using rules to draw new conclusions (or take certain actions) given those facts. • Useful when you know facts but don’t know what conclusions can be drawn (or what likely conclusions can be drawn) • “The ground is wet. What might be happening”?… • Backward chaining (PROLOG) • You start with some hypothesis (or goal) you are trying to prove and keep looking for rules that allow you to conclude that hypothesis – possibly setting new subgoals to prove as youi go along. • Focus on a hypothesis. • “Should I wear a raincoat” • Chaining gets it name from chaining inferences (modus ponens) together to form a chain of inference. • elephant(X)  mammal(X) • mammal(X)  animal(X) Artificial Intelligence

  43. Forward and Backward chaining Artificial Intelligence

  44. Forward Chaining and Backward Chaining comparison Artificial Intelligence

  45. Forward chaining rule-based systems • Facts are held in working memory which is being continually updated as rules are invoked. • Rules represent possible actions to take when specified facts occur in the working memory. • The interpreter controls the application of the rules. Artificial Intelligence

  46. Forward chaining rule-based systems • The interpreters cycle of activity is sometimes known as the recognize-act cycle. • Fire a rule • Which rules conditions (IF parts) hold given the current state of working memory. (Match phase) • Select a rule (Conflict resolution phase) • Perform action in conclusion of rule (THEN part) which may modify working memory (Act phase) • New working memory results • Repeat (until no rule fires or Halt encountered) Artificial Intelligence

  47. Forwad chaining rule-based systemsExample Artificial Intelligence

  48. Forwad chaining rule-based systemsExample Artificial Intelligence

  49. Forwad chaining rule-based systemsExample The example illustrates that the order in which rules fire depends on what is in working memory, and not on the sequence of the rules. A problem arises when more that one rule can fire based on what is in working memory. F1: alarm R1: If alarm THEN fight_fire F2: evacuate R2: If alarm THEN evacuate It is very important which rule is chosen to fire when there is a choice! Artificial Intelligence

  50. Forward chaining • Conflict resolution strategy • A forward chaining system will have some conflict resolution strategy to decide which rule to fire. Common strategies are; • Prefer to fire rules that involve facts that have been recently added to working memory • Prefer to fire rules that have more specific conditions. (eg IF a AND b AND c THEN d instead of IF a THEN z). • Allow the user to prioritize rules. • Fire all applicable rules at once. • Reason maintenance • Some sophisticated techniques have been developed to to update working memory to remove facts whose justification for being there has become invalidated. (The facts that caused the rule to fire to add this fact no longer hold => no justification for this fact to be in the working memory). • Pattern matching • If we have more complex fact, temperature(kitchen, hot) and we want to match it aginst a general rule, IF temperature(R, hot) THEN alarm, then we will employ pattern matching (matching the pattern temperature(kitchen, hot) against IF temperature(R, hot) THEN alarm) which will greatly increase the flexability of our rules. Depth First (CLIPS default) Breadth First Artificial Intelligence

More Related