KNOWLEDGE REPRESENTATION Class 3 INFSY 565
Knowledge Representation INTRODUCTION OVERVIEW TYPES OF KNOWLEDGE KNOWLEDGE REPRESENTATION TECHNIQUES Object-Attribute-Value Triplets Rules Semantic Networks Frames Logic SUMMARY ON KNOWLEDGE REPRESENTATION
Introduction Will look at techniques for encoding knowledge in an expert system An expert system must encode knowledge, not data Knowledge is represented in some symbolic form Knowledge must be able to be manipulated by the expert system No one technique is suited for every application
Overview Knowledge - Understanding of a subject area Domain - A well-focused subject area Knowledge Representation - The method used to encode knowledge in an expert system’s knowledge base KNOWLEDGE IS POWER
Knowledge in AI Cognitive psychologists have formed a number of theories to explain how humans solve problems Theories have uncovered: Types of knowledge humans commonly use How humans mentally organize this knowledge How humans use it efficiently to solve a problem Researchers in AI have used the results to develop techniques to best represent these different knowledge types in the computer A knowledge engineers’ responsibility is to choose the knowledge representation technique best suited for the given application
Approaches to Knowledge Representation A good system for the representation of knowledge should possess The following properties: 1. Representational Adequacy - the ability to represent all of the kinds of knowledge that are needed in that domain. 2. Inferential Adequacy - the ability to manipulate the representational structures in such a way as to derive new structures corresponding to new knowledge inferred from old 3. Inferential Efficiency - the ability to incorporate into the know- ledge structure additional information 4. Acquisitional Efficiency - the ability to acquire new information easily
Types of Knowledge 1. Procedural Knowledge - describes how a problem is solved provides direction on how to do something Ex: rules, strategies, agendas and procedures 2. Declarative Knowledge - describes what is known about a problem includes simple statements that are asserted to be true or false includes a list of statements that more fully describe some concept 3. Meta-Knowledge - describes knowledge about knowledge used to pick other knowledge best suited for solving a problem experts use to enhance the efficiency of problem solving by directing their reasoning into the most promising areas
Types of Knowledge - cont. 4. Heuristic Knowledge - describes a rule-of-thumb that guides the reasoning process. represents the knowledge compiled by an expert through the experience of solving past problems experts will take fundamental knowledge and compile it into simple heuristics to aid problem solving 5. Structural Knowledge - describes knowledge structures describes the expert’s overall mental model of the problem concepts, sub-concepts, and objects are typical examples
Summary of Knowledge Types Types of Knowledge Rules; Strategies Agendas; Procedures Concepts; Objects Facts Knowledge about the other types of knowledge and how to use them Rules of Thumb Rule Sets; Concept Relationships Concept to Object Relationships Procedural Knowledge Declarative Knowledge Meta-Knowledge Heuristic Knowledge Structural Knowledge
Knowledge Representation Techniques Five most common Techniques: Object-attribute-value triplets Rules Semantic Networks Frames Logic Each technique emphasizes certain information about a problem while ignoring other information Each technique has advantages and disadvantages for capturing efficiently the different types of knowledge Choosing the correct representation for a given application supports effective problem solving
Facts All cognitive theories of human knowledge organization use facts as basic building blocks A fact is a form of declarative knowledge that provides some understanding of an event or problem In expert systems, facts are used to help describe parts of frames semantic networks, or rules DEFINITION: A proposition (i.e. fact) is a statement that is either true or false
Object-Attribute-Value Triplets (O-A-V Triplets) In an expert system we assert into the working memory the Boolean truth statement (TRUE OR FALSE), and use this assertion in processing other knowledge Simple proposition: It is raining Fact is also used to assert a particular property value of some object “The ball is red” assigns the value “red” to the ball’s color This is known as an object-attribute-value (O-A-V) triplet
O-A-V Triplets Cont. O-A-V triplets divides a given statement into three distinct parts: Object Attribute Attribute Value Consider: “The chair’s color is brown” Can represent as an O-A-V triplet as follows: Object = “chair” Attribute = “color” Value = “brown”
O-A-V Triplets Cont. For most problems addressed by an expert system, objects have more than one important feature: 1 Foot Diameter Ball Color Red Weight 1 Pound Object Attribute Value Object with multiple attributes
Single-Valued and Multi-Valued Facts If only one answer makes sense, the O-A-V is single-valued: Expert System Question: Please tell me if the barometric (object) pressure (attribute) is Falling (attribute values) Steady Rising A: Falling If multiple values make sense then the O-A-V is multi-valued: Q: Please select the level of your education (attribute) High School (attribute values) College Graduate School A: High School note: object “person” is implied
MYCIN An Example
Rules Facts allow the system to understand the state of the world System must have additional knowledge for it to work intelligently with the facts Most expert systems use rules to provide additional knowledge DEFINITION: Rule - A knowledge structure that relates some known information to other information that can be concluded or inferred to be known
Rules Cont. A rule is a form of procedural knowledge It associates given information to some action Action may be the assertion of new information or some procedure to perform A rule describes how to solve a problem
Structure of a Rule The rules structure logically connects one or more antecedents also called premises contained in the IF part, to one or more consequents also called conclusions contained in the THEN part. IF The ball’s color is red THEN I like the ball If the balls color is red then we can infer that I like the ball
Structure of a Rule - Cont. A rule can have multiple premises joined with AND statements (conjunctions), OR statements (disjunctions), or a combination of both. Its conclusion can contain a single statement or a combination joined with an AND. The rule can also contain an ELSE statement, that is inferred to be TRUE if one or more of its premises are FALSE
Rule Example IF Today’s time is after 10am AND Today is a weekday AND I am at home OR My boss called and said that I am late for work THEN I am late for work ELSE I am not late for work RECOMMENDATION: Avoid the use of the OR operator and ELSE statements
Avoid ORs and ELSEs Rule 1: IF A = X Rule 2: IF A = X OR B = Y THEN D = XX THEN D = XX ELSE D = YY should be rewritten as: should be rewritten as: Rule 1a: IF A = X Rule 2a: IF A = X THEN D = XX THEN D = XX Rule 1b: IF B = Y Rule 2b: IF A NOT = X THEN D = XX THEN D = YY Why: Easier to follow the inference process. Easier to debug. Clearer presentation Validation of such rules more difficult Not all expert system shells allow ORs or ELSEs. .
Examples of Bad Rules IF (engine_type==”Jet”) IF(Wing_Position==”Low” Is B747 IF(engine_type==”High”) IF(Bulges==”None”) IS C5A IF(Bulges==”Aft Wing”) IS C141 IF(engine_type==”Prop”)
Example 2 IF Item Type is Tool THEN put on Peg Board ELSE IF Item Type is Toy THEN IF Toy Type is Indoor THEN put in Box in Back ELSE put Along Wall IF Item Type is Supply THEN IF Size is Small THEN put in Drawer ELSE put Under Bench IF Item Type is Miscellaneous THEN IF Need Again is No THEN put in Trash ELSE put in Box in Back
Example 3 If weight is less than 10 lbs and is not a tool Then put on top shelf Else if it is for yard work Then put in shed Else hang above tool bench
Working Memory Expert systems employing rules are called rule-based System matches the IF portion of the rules with facts contained in the working memory When a match is confirmed, the rule fires and its THEN statements are added to the working memory The new statements added to the working memory can also cause other rules to fire
The Inference Engine Knowledge Base IF ball’s color is Red THEN I like the ball If I like the ball THEN I will buy the ball Step 3 Working Memory Q: Ball’s color? A: Red Step 1 Ball’s color is red I like the ball I will buy the ball Step 2 Step 4 Step 5
Executing a Procedure Simple calculation: IF the area of the square is needed THEN AREA = LENGTH*WIDTH Procedural Program to call an external routine: IF The design requires a new box AND NUMBER = Number of items to pack AND SIZE = Size of item THEN CALL COMPUTE_BOX_VOLUME AND SEND NUMBER, SIZE AND RETURN VOLUME
Other examples of Procedures SPREADSHEET: IF January sales needed THEN OPEN SALES AND JANUARY_SALES = B7 DATABASE: IF There is a plant emergency AND NAME = Smith THEN OPEN TELEPHONE AND FIND NAME, NAME-FIELD AND TELEPHONE = TELEPHONE-FIELD
Variable Rules In some applications, you will need to perform the same operation on a set of similar objects. Ex: IF John Smith is an employee AND John Smith’s age is greater than 65 THEN John Smith can retire Rule checks if John Smith is an employee of the company and is over 65 before concluding he can retire. What if you wanted the system to perform the same check for other individuals?
Pattern-Matching Most shells offer pattern-matching that include variables that you can use to match similar problem statements. IF ?X is EMPLOYEE AND ?X AGE > 65 THEN ?X can retire Rule scans working memory looking for matches, if matches are found, the rule concludes that the person can retire
Advantages to Using Variables Designer only has to write one rule for many employees Designer only has to change one rule to make a variable change instead of many Offers an efficient way to process information Can directly capture general directions obtained from an expert
Meta-Rules DEFINITION: Meta-knowledge - Knowledge about the use and control of domain knowledge DEFINITION: Meta-rule - A rule that describes how other rules should be used
Meta Rules Cont. A meta-rule establishes strategies for the use of domain specific rules, instead of concluding new information Meta-rules provide direction to the expert system during the session Ex: IF The car will not start AND The electrical system is operating normally THEN Use rules concerning the fuel system
Semantic Networks DEFINITION: Semantic Network - A method of knowledge representation using a graph made up of nodes and arcs where the nodes represent objects and the arcs the relationships between the objects Wings IS-A (Canary, Bird) HAS Canary IS-A Bird TRAVEL Semantic network of a bird Fly
Expanding the Network You can add a new object node by 1) a similar object, 2) a more specific object, or (3) a more general object. Wings Air HAS BREATHE Canary IS-A IS-A Bird IS-A Animal Tweety IS-A TRAVEL Penguin Fly TRAVEL Walk
Inheritance Nodes added to a semantic network automatically inherit information from the network “Tweety” breathes air because it is an “Animal” Inheritance eases the task of coding knowledge To support, objects must be organized into classes; classes must be arranged in a generalization hierarchy BREATHE (Tweety, Air) Air BREATHE Canary IS-A IS-A Bird IS-A Animal Tweety
Inheritable Knowledge Fielder .262 .106 Three-Finger- Brown Pee-Wee- Reese Brooklyn- Dodgers Chicago- Cubs Baseball Player Adult- Male Person Right 5-10 6-1 .252 Pitcher team instance Batting-average isa height bats handed Equal isa shows class inclusion; instance shows class membership
Fault Detection System: An Expert System Example
Frames DEFINITION: Frame - A data structure for representing stereotypical knowledge of some concept Minsky (first proposed frames) describes a frame as follows: “When one encounters a new situation (or makes a substantial change in one’s view of a problem) one selects from memory a structure called a “frame.” This is a remembered framework to be adapted to fit reality by changing details as necessary.”
Structure of a Frame The basic structure of a frame is similar to many forms such as a “report card” ISA(OBJECT1, OBJECT2) REPORT CARD GENERAL FRAME STRUCTURE Student Name: Frame Name: Object1 Address: Class: Object2 Course Grades Property1 Chemistry Properties: Value1 Property2 Value2 Math English Property3 Value3 ... ... ...
Class Frame A class frame represents the general characteristics of some set of common objects. Frame Name: Properties: Bird Color Unknown Eats Worms No._Wings 2 Flies True Hungry Unknown Activity Unknown
Instance Frame Instance Frame describes a specific instance of a class frame. The frame inherits both properties and property values from the class. Frame Name: Class: Properties: Tweety Bird Color Yellow Eats Worms No._Wings 1 Flies False Hungry Unknown Activity Unknown Cage Lives
Hierarchical Structure You can create complex frame structures organizing by different levels of abstraction. Each level inherits from the previous level. Birds Sparrows Robins Canaries Bird1 Bird2 Bird3 Bird5 Bird4
Facets Provide you with additional control over property values Can define a constraint on a property value - i.e. Limit a numeric property value to some set range limit a string value to one of a few possible values restrict the type of data that can be stored in a property value, i.e. string, numeric, or boolean Can instruct a property how to obtain its value or what to do if its value changes IF-NEEDED facets IF-CHANGED facets
Methods A method is a procedure that executes whenever a property value is needed. Property value can be obtained through a series of computations, or from an external database or spreadsheet Method is typically written in the procedural language of the chosen shell and attached to the property’s IF-NEEDED facet
Example 1. Assume property value “Flies” in the “Tweety” frame is “Unknown”. 2. You want the system to determine if tweety can fly. Method: IF Tweety has less than two wings THEN Tweety can’t fly IF Tweety has two wings THEN Tweety can fly To implement method, we need the property value of “No._Wings” from the “Tweety” frame.
Example Con’t Shells differ but one example is Frame:Property Using the code on the previous “Tweety frame, we have Tweety:No._Wings = 1 Now we need to assert a value of True or False to the “Flies” property depending on Tweety’s wing count.
Example Con’t Frame:Property = Value IF Tweety:No._Wings < 2 THEN Tweety:Flies = False IF Tweety:No._Wings = 2 THEN Tweety:Flies = True This method is attached to the IF-NEEDED facet of property “Flies” of the frame “Tweety”
Logic in a computer One most often linked to intelligent systems are Logic is the oldest form of knowledge representation in a computer One most often linked to intelligent systems are propositional logic and predicate calculus Techniques use symbols to represent knowledge Operators applied to the symbols produce logical reasoning
Predicate Logic Class Handout