If you are continuing from Part 3 in the same session, type
>>> (readFile "<topdir>/Helper/just-wines.Neo ")
or type
>>> (readFile "<topdir>/Recover/after-just-wines.Neo ") to recover state.
Otherwise, if this is a new session, type:
>>> (readFile "<topdir>/Recover/after-just-wines.Neo ") These loading operations may take a bit of time because they are adding many wine individuals to the KB.
You may want to skip down to the end of the review section if you are continuing from Part 3 in the same session.
In the first module of this assignment we covered:
In the second module of this assignment we covered:
In the third module of this assignment we covered:
In this module we will look at some other uses for rules. You
might want to briefly review the end of asg3.txt before proceeding.
Despite these limitations, we can often use rules to achieve some of
the effects of disjunctive concepts. "Dirty tricks" of this sort are
of course risky, but they can be useful. We will use an example to
illustrate the use of rules to imitate disjunctive concepts.
We know that in many cases, a concept is (implicitly) a disjunction of
its children concepts. Suppose you want to define a primitive concept
MY-FAVORITE-WINE whose only restrictions are that it must be either
a CHARDONNAY or an ITALIAN-WINE. There is no straightforward way
in NeoClassic of expressing this restriction using the constructs for
defining primitive concepts. But we can use rules to approximate the
disjunctive concept that we want in the definition, as follows.
You can think of it this way: this trick will in general provide
sufficient conditions for classifying something under
MY-FAVORITE-WINE, but it won't provide necessary conditions.
Try to implement the idea, in the following steps.
>> (readFile "
<topdir>/Helper/food-wines.Neo")
The "food-wines.Neo" knowledge base contains examples like the
following ones, which provide information about wines appropriate
for spicy-red-meat food. Do NOT enter these commands; they were
included in the file you just loaded.
Suppose we want to find out what wines go with a SPICY-RED-MEAT
food. We first create a meal course that is a SPICY-RED-MEAT.
These restrictions represent what we know about a wine, when we are
told that it is appropriate with any instance of SPICY-RED-MEAT.
Manually browse through the knowledge base for an individual wine that
meets all these restrictions, and an individual instance of
SPICY-RED-MEAT. Do you expect NeoClassic to know that the wine is
appropriate for the meat? Make your prediction now, and then query
NeoClassic for the answer. Explain why NeoClassic gives the result it does,
and test your prediction, before reading the answer.
But even the most open domains can have parts that are closed; and it
is often very useful in special cases to simulate closed-world
reasoning. The case of SPICY-RED-MEAT is a good example. It is
reasonable to expect here that we have listed all the conditions that
make a wine appropriate for a SPICY-RED-MEAT, so that a wine that
satisfies them will in fact be a good recommendation for a meal
featuring SPICY-RED-MEAT. In fact, it is hard to see how we can use
the knowledge we have put into the system to make useful meal-planning
suggestions without making some assumption of this sort.
To explore how to do this, let's return to the individual My-Meal-Food
that we created above. Remember that the role "appropriate-drink"
has only the restrictions that follow from assuming that a wine goes with
SPICY-RED-MEAT. What we need to know now is, which individual wines in
our knowledge base satisfy these restrictions. For this we can use the
function "getInstances" in the following way. (An explanation of this
function is in the NeoClassic Reference Manual in the section entitled
``Taxonomy Retrievals''. It can be found under the top level section
called "NeoClassic Interface Functionality" and in the section called
"Concepts" in there.)
First we create a concept that contains the description.
>>> (getInstances MY-WINE1)
The function "getInstances" takes a concept. The concept that we
need is found in the derivedValueRestriction for the individual,
My-Meal-Food, on its appropriate-drink role. The "getInstances"
function retrieves the wines that match this concept.
Enter the above command; NeoClassic should return the following answer to
your query:
{Mazocco-Zinfandel, Some-Wine}
Mazocco-Zinfandel is in fact the only wine in our KB that we
can recommend with a SPICY-RED-MEAT. Some-Wine was just a
variable for that wine.
You can see that techniques like this have to be used with care.
We have to recognize the closed-world constraints that went
into our recommendation: all we really know is that
Mazocco-Zinfandel is not incompatible with SPICY-RED-MEAT. We are
hoping that our constraints are complete enough so that any wine that
is not incompatible with the constraints will in fact be appropriate.
In the previous example the relationships between MEAL-FOODs and
appropriate WINEs have been expressed through rules. And in fact we
recommended a WINE as appropriate for SPICY-RED-MEAT without ever
actually filling the appropriate-drink role. (You might want to
check at this point to verify that Mazocco-Zinfandel still does not
fill the appropriate-drink role of Beef-Curry.)
To break the loop, you could:
Type: <CTRL>X<CTRL>S to save your shell to a file.
YOU ARE DONE WITH PART FOUR OF THIS ASSIGNMENT
You may go to Part 5 or go back to
the main NeoClassic Tutorial page.
REVIEW OF Part 1,
Part 2 and Part 3
MORE USES OF RULES
Definitions can help to organize knowledge, but most useful domain
information does not follow from concept definitions alone. NeoClassic
provides rules as a way to extend our knowledge of individuals, by
adding information that can't be inferred from the definitions of the
concepts under which the individuals are classified, but that will
nonetheless be expected or known. In the last module we saw how rules
can be used for this purpose.
RULES FOR CREATING PURELY DISJUNCTIVE CONCEPTS
We have seen that the "oneOf" restriction construct can be used to
define a concept as a disjunction of individual instances. The
definition of WINE-FLAVOR
in Part 1 is an example.
(createConcept
WINE-FLAVOR (and WINE-PROPERTY (oneOf Delicate Moderate Strong)))
However, there is no general way in NeoClassic to define a concept
as a disjunction of several other concepts. For instance, there is no
direct way to define a concept of DELICATE-OR-WHITE-WINE.
Disjunction is intentionally limited in NeoClassic.
This is only an approximation of true disjunction for several reasons.
For instance, if we create an individual My-Wine and tell NeoClassic
that it is a MY-FAVORITE-WINE with its region filled by Sonoma,
NeoClassic will not infer that it is a CHARDONNAY.
Moreover, if we create another individual, My-wine2, and tell NeoClassic
that it is MY-FAVORITE-WINE and a BORDEAUX-WINE, NeoClassic will not detect
the inconsistency.
To recover state here, use:
(readFile "
<topdir>/Recover/after-just-wines.Neo")
USING RULES TO CREATE "QUERY TEMPLATES"
This section introduces a use for rules that extends the type of
reasoning you might think NeoClassic is capable of doing.
The definitions and rules are in file:
``<topdir>/Helper/food-wines.Neo''.
Look at the file, if you wish, then type:
(createRule spicy-red-meat-wine-color SPICY-RED-MEAT
(all appropriate-drink (fills color Red)))
(createRule spicy-red-meat-wine-body SPICY-RED-MEAT
(all appropriate-drink (fills body Full)))
(createRule spicy-red-meat-wine-flavor SPICY-RED-MEAT
(all appropriate-drink (fills flavor Moderate)))
(createRule spicy-red-meat-wine-sugar SPICY-RED-MEAT
(all appropriate-drink (fills sugar Dry)))
Note that the rules associated with a food concept impose a number of
restrictions on any wine that fills the appropriate-drink role of an
instance of the concept. The rules concentrate on the
appropriate-drink role because we are assuming that the knowledge
base we are building would be used to give advice in selecting drinks
to go with certain foods. If we were interested in other kinds of
advice (suitability for certain sorts of diets, for instance), we
would have to modify the food concept by adding appropriate roles, and
would need to add rules constraining these roles. You'll see below
how these rules are used.
>>> (createIndividual My-Meal-Food
(and SPICY-RED-MEAT (fills appropriate-drink Some-Wine)))
Create My-Meal-Food using this definition, and use "printInfo"
to inspect it. You will notice that the role "appropriate-drink" has
restrictions associated with it, that were created by the rules for
SPICY-RED-MEAT.
>> (createConcept MY-WINE1
(derivedValueRestriction MY-MEAL-FOOD My-Meal-Food))
Then we can find the instances that satisfy this concept.
USING RULES TO BREAK CIRCULAR DEFINITIONS
The wines KB/domain doesn't really have much circularity. But suppose you
were asked to define the following concepts:
CHILD would have to be defined before PARENT and viceversa.
Try this.