• No results found

Discussion

DISCUSSION

Normal antecedents are antecedents that do not access the relations between frames. These antecedents usually have a LHS and a RHS separated by some comparative operator. Their truth value is found by evaluating each side of the statement andvthen applying the comparative operator.

Evaluating an expression involves retrieving values form the knowledge base or symbol-table. Functions that' return a value are called value functions. There are several value functions.

f-get returns a value form a slot, or the cardinality of a slot.

var-get returns a variable's value

num-child returns the number of children of a frame num-parents : returns the number of parents of a frame

input functions : return a user inputted value.

F-get [diagram 8.6) is a function that returns a value from a slot. This function is passed to the lisp evaluator and executed. Checking to see if an antecedent is true involves getting a value for the functions that return values and then executing the boolean function with these values. A

'

reference to a slot without a frame causes the compiler to generate code as if the slot was in the current frame. For example the lisp evaluator gets the value from (f-get

'animal 'coat) and then sees if it is equal to 'hair.

---~--~~·-----·--·

----~---There are several functions that return values namely f-get, var-get, num-chi ld, num-parents. There are many boolean functions such as equal,

>, <,

rel-get etc. The value functions all require accesses to the knowledge base.

f-get returns a slot's value it takes 2 parameters, a frame name and a slot name. Its algorithm is

1) If there is a slot of this name within this frame goto 5.

2) Inherit the slot. This involves finding the inheritance strategy in the frame's control block, and applying it. If the slot cannot be found goto 11.

3) Once the slot has been located in an ancestor frame, its exception facet is checked to see if the frame attempting to inherit it, is an exception of this slot, if it is continue the search else copy the slot to the inheriting frame. If the slot cannot be found goto 11.

4) If the inheriting frame is a generic frame then put in inherited slot else put in own slot.

5) Look at the slot's retained fact if it is 'yes and the value facet is not equal to () then goto lb.

6) If the retained facet is 'no, or the value is null, the value must be obtained using the if-needed facet. The

if-needed facet must explicitly set the slot. Execute the if-needed, if the value of the slot is not null goto 10.

7) The backward chainer proceeds by looking in the then-index of the slot to find all the rules that set this slot to a value. These rules are put. in a conflict resolution set and the frame's conflict resolution strategy is applied to them.

8) A rule is picked and tried. If it fails because one of the antecedents are false, the system will try another rule from the conflict set. The rule that sets the slots value might itself require backchaining in order to be executed.

The backward chainer uses a depth first, backward chaining strategy. It stops when the slot's value is set. If the backward chainer finds a value then goto 10.

9) The default is taken as the value. This is equivalent to making a choice about the value that we wish the slot to take. It can be a single value or a list of possible values.

10) return value

11) report error

A slot may have more than a single value. These mu.I t.i valued slots can be accessed using special multi-value functions. These- include a cardinality function that

returns a number tel 1 ing how many values the value facet holds. There is also an ordinal f-get for multi value slots that allows the user to access a particular element in the multi-valued-slot eg third element.

The compiled form of the cardinal. f-get is (f-get 'fl 'sl 'cardinal). The compiled form of the ordinal f-get is (f-get 'fl 'sl 'pos).

The third parameter is an optional one that tells f-get to return either the posth value of the slot or the number of elements in the slot.

Apart from slots returning a value, there are also variables that can return a value. A variable's name starts with a

"?" We have already mentioned one special sort of variable namely the loop variable. There are three types of variables: loop, choice and normal. The compiler can tell from the context in which they are used, what type of variable they are. The variable accesses are compiled to the var-get function which returns the value of a variable it takes 2 parameter in its compiled state [diagram 8. 7].

Var-get retrieves the. variable's value from the symbol-table.

Two other functions that return values are number of children and number of parents. These functions return the number of children or the number of parents of a frame.

These are compiled to :

(num-child frame-name) and (num-parent frame-name) respectively.

If ?x > f1.s1 -3 is compiled to :

(> (var-get 'x' 'normal) (- (f-get 'f1 's1) 3))) ::JJ~

B.7

The last type of functions that return values are the input functions. These functions are part of the knowledge base's interface to the outside world. They can communicate with a person, database or file.

8.~.~.2 Relational antecedents

An antecedent can also be of type relation which means that it refers to the relation ship between two frames. This type of function is compiled to rel-get. This is a boolean function that is the compiled form of the relation statements such as:

If Jack is the brother of Jill which is compiled to :

(rel-get 'Jill 'brother 'Jack)

It looks in the relation field in the "Jill" frame to see if there is a relation called "brother". If there is it looks to see if one of the subjects of that relation is "Jack".

If' it is, rel-get returns true, if not the system will attempt to find the value of the "brother" relation by backward chaining.

Relations are indexed to th~ clauses that use them, and the clauses that set them, these indices are the same as the slots' indices.

Related documents