Frames: Organizing Knowledge Networks More Compactly
Motivations • Semantic nets good for inheritance. • Networks can get big and messy. • Script technology is useful when everything happens according to the script, stereotype. • When something unexpected happens, the script becomes unstable. • AI representation technology, frame, is sometimes used instead for these more volatile situations.
Objectives • Script for family staying in a hotel • Frames • Slots • Prolog implementations
Script: Family stay in a hotel • We can attempt to write a script for a family of 7 to stay in a hotel overnight. • Roles: family, porter (door attendant), luggage handler, receptionist, room maid, housekeeper, concierge (assists guests with local info), … • Props: lobby, room, beds, bathroom, telephone, light switches, TV, … • Scenes: arrival, take care of luggage, check in, go to room, … sleep, … check out. • Script technology is useful when everything happens according to the script. • For a family with 5 kids to stay in a hotel, invariably someone is NOT going to follow the script. • When something unexpected happens, the script becomes unstable. • AI technology, frame, is sometimes used instead in these more volatile situations.
Hotel framework • Part of a frame description of a hotel room. • “Specialization of” indicates a pointer to a superclass frame slot
Slots Frames: an object has named slots with • values • procedures • links to other frames Slots • filled in as information becomes available • loosely correspond to relations in a conceptual graph Advantage: it is clearer the main object is a dog Easier to indicate hierarchies via inheritance (from animal) Accessories point to collar and bowl frames Procedural info can be attached e.g. how to calculate default values such as 4 legs. e.g. deductions based on marital status, number of children,...
Frame slots • A frame is a set of slots (similar to a set of fields in a class in OO) • The slots may contain the following information
Single bit adder with carry Addends In XOR Sum Out Carry In Carry Out AND
Frame Representation of C1 C1 Instance-Of: Circuit Input: C1-Addend1 C1-Addend2 C1-Carry-In Output: C1-Sum C1-Carry-Out Gate: X1 X2 A1 A2 O1 X1 Instance-Of: Xor-Gate Input1: X1-Input1 Input2: X1-Input2 Output: X1-Output X1-Input1 Instance-Of: Terminal Connected-To: C1-Addend1 ...
Prolog implementation frame arguments: 1. frame id 2. isa 3. list of properties 4. list of defaults frame( name(bird), isa(animal), [travel(flies),feathers], [] ). frame( name(penguin), isa(bird), [color(brown)], [travel(walks)] ). frame( name(canary), isa(bird), [color(yellow),call(sing)], [size(small)] ). frame( name(tweety), isa(canary), [], [color(white)] ). getP(Object,Prop) :- frame( name(Object), _, List_of_properties, _ ), member(Prop,List_of_properties). getP(Object,Prop) :- frame( name(Object), _, _, List_of_defaults ), member(Prop, List_of_defaults). getP(Object,Prop) :- frame( name(Object), isa(Parent), _, _ ), getP(Parent, Prop). ?- getP(canary,color(yellow)). More? Yes ?- getP(canary,color(brown)). No ?- getP(tweety,color(brown)). No ?- getP(tweety,color(yellow)). More? Yes ?- getP(tweety,Prop). Prop = color(white) ; Prop = color(yellow) ; Prop = call(sing) ; Prop = size(small) ; Prop = travel(flies) ; Prop = feathers ; No
Conclusion • AI representations: • Semantic networks • Scripts • Frames • Led to object-oriented programming philosophy, e.g., Java programming language. • Frames can organize knowledge more structurally and flexibly.