210 likes | 302 Views
Frames. • Knowledge bases can be enhanced by using principles from frame knowledge representation (similar to object orientation) • This is advantageous, as it permits large and complex knowledge bases to be "smarter" -- essentially by implementing them as object-oriented
E N D
Frames • Knowledge bases can be enhanced by using principles from frame knowledge representation (similar to object orientation) • This is advantageous, as it permits large and complex knowledge bases to be "smarter" -- essentially by implementing them as object-oriented databases. Object: formal structure which has variables which denotes its state and procedures which denote its behaviors Object-oriented programming: a style of programming where data and procedures are encapsulated into objects. They communicate by passing messages which invoke the encapsulating procedures. Slot: an attribute or property Facet: usually a value, but can be a default, constraint, description, or demon Demon: Rules or procedures activated under certain conditions, eg. when a slot value is being modified Frames: formal structure that contains an object's slots and facets
Frames Definitions (cont) • Inheritance : Frames or objects can be organized into hierarchies such that members of classes can derive (inherit) slots and values from classes above them • I will first show some code which implements three basic frame utilities: get_frame: retrieves attrobute values for a frame add_frame : adds or updates attribute values for a frame del_frame: deletes attribute values for a frame Then this frame framework will be incorporated into the Oops forward chaining system.
Frames (6.1)
Frames Data Structure p.101, 100
Frames 1. get_frame 6.2
Frames 102,103,104,105
Frames 106
Frames 2. add_frame 107,108
Frames 3. del_frame 109,110
Frames Example usage: 111,112
Comments • Having a frame-based knowledge base means that it can be modified very easily. Frames forces a structure to the KB. • Contrast this with the static KB's, for example, the first bird KB. Here, all the rules are "flat", and you can change any rule you like, which can have dire effects on the soundness of the whole KB. • A frame KB, however, is arguably less "declarative", since frame directives introduce more implmentation-specific syntax and peculiarities.
Frame integration • Oops: forward chaining expert system for furniture placement • whole system implemented with productions - some rules did system-specific operations, such as input and output - these rules were messy - the rules in general were large and complicated, since they dealt with lots of descriptive facts about furniture which weren't directly related to rules about how to place furniture • We can make this application much cleaner by: 1. Adding frames to represent items of furniture, walls, etc - these frames will contain descriptive facts 2. Adding hooks to Prolog routines to do I / O, rather than in productions 3. Use production rules exclusively for placing furniture in room.
Frame integration p. 133
Frame integration p.120
Frame integration 1. Integrating frames • incorporate frame classes (like before) and frame instances, which are previous frames, but with - class name - instance (object) name - slot-attribute value pair list - time stamp (used for enhanced forward-chaining strategies) • fancier frame format: Class - Name with [Attr-Val, Attr-Val, ... ] • typical rule: rule f11: [ table_lamp - TL with [ position-none ], end_table - ET with [ position-wall/W]] ==> [ update(table_lamp-TL with [ position-end_table/ET] )].
Frame integration 2. Prolog hooks • add production actions test { LHS } and take { RHS } which refer to Prolog routines • inference engine will call these Prolog utilities directly p.125-6
Frame integration 3. Productions • We will describe furniture items and walls with frame instances. • This permits the knowledge base to deal exclusively with rules for placing furniture in a room • furniture frames: p.121-123
Frame integration • furniture frames
Frame integration • frame demons: called by frames to do specific actions • initial data p.125
Frame integration • frame rules p. 129
Frame integration Conclusion: • As with most non-trivial software systems, a mixture of techniques can provide the clearest solution. • This Foops system is a sophisticated shell - inference uses efficiency techniques such as specificity, time stamps, ... - the frame component can be used for programming applications - hooks to general Prolog means that rules and frames are not burdened with system code - Prolog's adaptive syntax means that prettier rule formats are trivial to derive (Try doing that in any other language!)