WORCESTER POLYTECHNIC INSTITUTE
Computer Science Department

CS534 -- Artificial Intelligence

Wed 6:00-9:00

Prof. David C. Brown, Fuller Lab 131, (508) 831-5618, dcb@cs.wpi.edu

http://cs.wpi.edu/~dcb/courses/CS534/


PROJECT 2 - A Frame System

Write a set of routines that will build and access Frame representations of knowledge. Demonstrate that you have tested the routines, and show the system working on simple examples involving inheritance, defaults, and triggered attached actions doing inference. Attached actions can be used to activate a rule-base to do the inferencing, for example. This capability need not be demonstrated.

A frame is essentially a list of attribute/value pairs, with additional characteristics. Frames are to be organized in a hierarchy. The relationships between frames can be SUB-CONCEPT-OF (S-C-O) and INSTANCE-OF (I-O). Frames can be Generic or Individual, depending on what they represent.

For example:

where Fido is an individual and Dog and Animal are generic. That is, the frame Fido represents a single dog, whereas Dog and Animal represent classes.

The attribute/value pairs in a frame are referred to as Slots. These can be viewed as fields in a record. Each slot has a slot name (the name of the attribute), a value (if known), an optional default value, and one or two types of attached actions. These will be described in more detail below. Every individual has all the slots of the generic of which it is an instance. Both individuals and generics may have slots with values.

The operations you are to implement must include the creation (FCREATE ... ) of a new frame with its insertion into the hierarchy (Note: The user specifies where it is to go. Having the program reason it out is closer to an MS thesis.), the retrieval (FGET ... ) of a value from a slot in a frame, the insertion (FPUT ... ) of a value into a slot in a frame. Retrieval is not destructive.

You should also implement a routine that sets parameters (FSETPARAMS ... ) that determine whether and how defaults and actions are used. You may need a routine to find (FGETPARAMS ... ) the current settings of the parameters in case you want to change them temporarily.

Insertion may involve more than just putting the value into the slot. If that slot, or any slot with the same name higher in the hierarchy has an action attached that is of type IF-ADDED, then that action will be triggered and fired---i.e., executed. Only execute the first such action that is found. This approach is analogous to the most-specific-first rule selection strategy. In addition, this feature is only to be used if the appropriate parameter is set to True in the system.

Consequently, IF-ADDED actions can easily be triggered by simple situations and can be used to make simple deductions. An action could be used to start up a rule-based system, for example. The RHS actions of the rules might themselves include frame operations. For example, setting (i.e., FPUT-ing) Surgery-Done to "Yes" may trigger an action to deduce what type of surgery was done and then to store that, and the fact that drugs were given recently, in a frame.

Retrieval may involve more than just obtaining the value from the slot. First of all notice that a frame may not even contain the slot being requested, but a higher frame may have that slot with a value. For example, the fact that animals are `alive' only needs to be stored as a slot in the animal frame. Every subordinate frame can inherit that slot. It is not necessary to explicitly have Alive="Yes" as a slot in the Fido frame, for example.

In the case that there is no value for the queried attribute, an action can be "triggered". If that slot, or any slot higher in the hierarchy with the same attribute name, has an action attached that is of type IF-NEEDED, then that action will be executed. Only execute the first such action that is found. This feature is only to be used if the appropriate parameter is set in the system. The value of the FGET is the value of the IF-NEEDED action executed.

Another possible action that can occur when trying to retrieve a non-existent value is that a default value will be returned. If that slot, or any slot with the same name which is higher in the hierarchy, has a DEFAULT value attached, then that value can be returned as the value of the FGET. Notice that if during an FGET the slot doesn't exist in this frame then the only option one has is to look in the next frame higher.

Actions can be any function. They should have access to global variables that provide useful knowledge, such as, for the IF-ADDED case, the frame name, the slot name, and the value added. These variables should be automagically set by the frame operations.

It will probably be appropriate to think of both the FGET and the FPUT as recursive functions. That is, if you can't FGET it from this frame then try to FGET it from the frame above. Termination will be caused by reaching the top of the hierarchy, or by obtaining a value.

Use the parameters to control not only the whether IF-ADDED, IF-NEEDED, and DEFAULT features are activated, but also the order in which they are used. You should include the strategies {Get value, else Default, else If-Needed, else try next frame up}, and {Get value, else If-Needed, else Default, else try next frame up}. This is sometimes referred to as the "Z" strategy, as it goes across, goes up, and then goes across, just as letter Z does.

Another strategy you should implement does each one (e.g., Get value) all the way to the top of the hierarchy, before trying the next method (e.g., Get Default) all the way to the top again. This is sometimes known as the "N" strategy, as it goes up, returns to the bottom, and goes up again, just as the letter N does.


	TYPE           	generic
	NAME           	animal            
	SUB-CONCEPTS   	dog sheep professor            
	ALIVE          	yes                      

	TYPE           	generic            
	NAME           	dog            
	INSTANCES      	Fido            
	LEGS           	DEFAULT     4            
	OWNER          	IF-ADDED    check-if-kind-to-dogs            
	COAT           	IF-NEEDED   try-to-deduce-from-breed            
	BREED          	--            
	NOISE          	bark                       

	TYPE           	individual           
	NAME           	Fido            
	LEGS           	--            
	OWNER          	--            
	COAT           	--            
	BREED          	--            
	NOISE          	growl

Try an FPUT of BREED to Fido, followed by an FGET of the COAT of Fido. Try an FGET of the LEGS of Fido. Also do an FPUT of the OWNER of Fido, and an FGET of ALIVE of Fido.

You should demonstrate that your frame functions work by using some appropriate example or examples. It should show the system working with different parameter settings.

Note that I want you to implement all this functionality yourself, and not to use built-in portions of the language: e.g., no CLOS.


dcb@cs.wpi.edu / Wed Oct 1 13:36:52 EDT 2003