Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Appendix A - Examples 172<br />
The Identification Algorithm<br />
The previous sections have described a small section of the animal kingdom,<br />
including the inter-relationships of different species (the frame hierarchy) and<br />
some of their characteristics (default values).<br />
The following KSL program can be used to identify a particular species<br />
within the example. Note, though, that the algorithm itself is not specific to<br />
the example, but could equally be used for identifying classes within any<br />
taxonomy.action run(Frame,PosAttribs,NegAttribs)<br />
do [ isa_frame( Frame, _ ) or isa_instance(Frame,_)<br />
]<br />
and for every PosAttr-PosVal is included in<br />
PosAttribs<br />
do check [ the PosAttr of Frame includes PosVal<br />
or the PosAttr of Frame is equal to PosVal<br />
]<br />
end for<br />
and for every NegAttr-NegVal is included in<br />
NegAttribs<br />
do check [ the NegAttr of Frame does not<br />
include<br />
NegVal and the<br />
NegAttr of Frame is not equal to<br />
NegVal<br />
]<br />
end for .<br />
Given a set of positive clues and a set of negative clues, the algorithm will<br />
identify any class which has each of the positive attributes but none of the<br />
negative attributes.<br />
isa_frame/2 and lookup/3 are built-in <strong>flex</strong> predicates for retrieving the<br />
names of frames and for looking up values of frame attributes, respectively.<br />
The lookup/3 procedure will automatically take into account any<br />
inheritance through the frame hierarchy.<br />
Some Example Questions<br />
Using the identification algorithm above we can ask, for example, the<br />
following two questions :<br />
• Which type of animal eats meat ?<br />
• Which type of animal lives on land, is medium in size but does not eat<br />
meat ?<br />
<strong>flex</strong> toolkit