Classic provides a number of extra-logical features, including multiple
knowledge bases, forward-chaining rules, procedural extensions to the
description logic in the form of test functions and computed rules, and
hooks that allow programs to be informed of the actions that Classic
performs.
In the CI commands are given to NeoClassic over a character stream, and
responses are given back on another character stream. The syntax for the
CI allows two ways of grouping a function with its arguments. Parentheses
may be placed around the arguments only or parentheses may be placed around
the function name as well as the arguments. Most examples are shown using
the second syntax. Many CI functions can take an arbitrary number of
arguments that are grouped into a set or list.
In the GUI concepts, roles, rules, and individuals can be created in
several ways: a file can be specified and read in; CI commands can be
entered; or a dialog box that guides the creation of a concept, role, rule,
or individual can be used. Concepts, roles, rules, and individuals can be
viewed and changes can be made to them and explanation can be performed on
them.
The API to NeoClassic exposes the object-oriented implementation of
NeoClassic, but in a way that does not (easily) allow subverting the
semantics of NeoClassic objects. There is some functionality that only
makes sense using the API, and thus does not show up in the CI.
where <input file> is the name of a file containing character interface
commands. After reading these files, if any, this version of neoclassic
will prompt for more input from the standard input.
When the user is running NeoClassic from a unix system it can be run as
a server by adding in a "-s" followed by an optional number of seconds after
which it should time out, if there is no response. The filename, if there is
one, is always the last argument. The default amount of time that the server
will wait for a response from the client is 500 seconds. Let us say that
a user wants to run NeoClassic as a server that waits only 30 seconds for
a response from the client and read in the file "test.classic".
The user would call it like this:
The easiest way to run NeoClassic under Windows 95 or Windows NT is to
double click on the executable file. Once the window for NeoClassic is up
files can be read by using the files menu.
Using NeoClassic as part of a larger C++ program is only slightly more
complicated. To compile a C++ program that uses NeoClassic, put the
NeoClassic directory in the include path, and include the file NeoClassic.H
in each file that uses NeoClassic classes. To link a C++ program that uses
NeoClassic, add the library libneoclassic.a to the libraries of the
program. The C++ program is responsible for starting NeoClassic by calling
the function NeoEnvironment::init and for cleaning up after all use of
NeoClassic is done by calling NeoEnvironment::cleanup. To process
NeoClassic character interface commands, use the function
NeoEnvironment::readFile.
NeoClassic allows the creation of a collection of (named) knowledge bases.
Each knowledge base has a collection of (named) roles, (named) concepts,
(named) individuals, and (named) rules.
The allowable operations on knowledge bases are:
NeoClassic is not quite a complete reasoner. There is one kind of
reasoning by cases that it does not perform.
Descriptions in NeoClassic are likewise either host descriptions or classic
descriptions. As expected, host individuals can only satisfy host
descriptions and classic individuals can only satisfy classic descriptions.
Most descriptions exist in a particular knowledge base, and cannot refer to
descriptions from other knowledge bases. Similarly, concepts, individuals,
and rules must use descriptions that are valid for their knowledge base.
The details of descriptions are contained elsewhere.
The operations on the collection of knowledge bases are:
Similarly, if an operation in NeoClassic would result in the creation of an
incoherent concept, that concept is not added to the knowledge base.
Instead the operation returns a special value, which can be used to find
and explain the source of the potential incoherency.
Explanations report only the last (important) inference made in any chain
of inferences. To see an entire chain of inferences a series of
explanations must be requested, manually or automatically. There will
eventually be mechanisms for controlling what is and what is not important.
The classes Role, Concept, Rule, and ClassicIndividual share functionality
having to do with their similar position in knowledge bases. They each
have a name and a knowledge base they belong to. They also have two kinds
of modifiable data, a comment string and an arbitrary piece of information,
that are not managed by NeoClassic. This common functionality is provided by a
mechanism that is not visible to the user.
When a knowledge base is created, it contains only the definitions of the
built in NeoClassic concepts. These are:
The roles, concepts, rules, and classic individuals in a knowledge base can
be retrieved by name.
There are also operations to initialize the collection of knowledge bases,
to reinitialize it, and clean it up by destroying all the knowledge bases
in the collection. The newly initialized or reinitialized collection
contains a single fresh knowledge base, which is the current knowledge
base.
NeoClassic divides descriptions into concepts and constructed descriptions.
Concepts are defined in a particular knowledge base in terms of a
description and primitive information. Constructed descriptions are formed
by one of the description constructors.
NeoClassic also divides descriptions into thing descriptions, classic
descriptions, host descriptions, and incoherent descriptions. The
collection of objects represented by a classic description must come only
from the classic objects of the model, and the collection of objects
represented by a host description must come only from the host objects of
the model. The host objects of a model are strings, integers, and floats.
The classic objects of a model are all the other objects in the model.
Thing descriptions represent the union of all classic objects and host
objects; incoherent descriptions structurally represent the empty set.
(Note that it is possible to have classic descriptions and host
descriptions that represent the empty set.)
Currently roles are atomic entities, but a role hierarchy will be added in
a future release.
The representation of a host concept is precisely the representation of its
definition. The representation of a classic concept is a subset of the
representation of the description in its definition. If the classic
concept is not primitive then its representation is precisely the
representation of this description. If it is primitive then the
representation must also be disjoint from selected other primitive
concepts.
The consequent of a rule can be specified as a description, as a function
from classic individuals to descriptions, or as a function from classic
individuals and roles to sets of individuals. In the first case the
consequent of the rule is the description provided, in the second case it
is the description returned when the function is run, and in the third case
the description is a fills description created from the role and the set of
individuals.
A classic individual is a formal object that represents a classic object in
a model. Classic Individuals are created in knowledge bases, and
information can be added to them and removed from them. This information
is either in the form of a description or a role closing. Adding a
description means that the classic individual is required to satisfy the
description. Adding a role closing means that the only fillers for the
role on the individual are the ones currently known.
Classic Individuals that belong to a knowledge base must be consistent, as
knowledge bases are consistent. However, operations that would have
resulted in an inconsistent knowledge base return inconsistent individuals
to encode the inconsistent relevant state that would have resulted if the
operation was performed.
A host individual is both a formal object that represents a host object in
a model and a data structure in C++. Host individuals are thus either
strings, integers, or reals. They exist in all knowledge bases and, of
course, cannot be changed.
In the character interface commands are given to NeoClassic over a
character stream, and responses are given back on another character stream.
Many character interface functions accept a set as a last argument. This
can either be entered as a sequence of arguments, each of which become
an element of the set, like
The C++ application programming interface to NeoClassic exposes the
object-oriented implementation of NeoClassic, but in a way that does not
(easily) allow subverting the semantics of NeoClassic objects. There is
some functionality that only makes sense using the application programming
interface and thus does not show up in the character interface, and vice
versa.
Many of the character interface function names are provided solely for
compatability with C-Classic. Such names are marked with
``©''. A few
character interface function names are provided as shorthand, and should
not be used except when typing directly into the character interface. Such
function names are marked with ``£''.
The application programming interface does not print error messages.
Exceptional conditions are signalled through return values. Some functions
return null objects, which indicate some sort of non-knowledge exceptional
condition, such as trying to create a concept when the name is already in
use for another concept in the knowledge base. Knowledge exceptional
conditions are those that would result in an illegal state of affairs in a
knowledge base (including creating an incoherent concept in the knowledge
base, making the knowledge base inconsistent, etc.) are signalled by
returning an incoherent or inconsistent object. Exceptional return values
are prominently indicated below. Note that passing a null object into
another function may generate abnormal behavior, including dumping core.
The character interface does print messages. In particular it checks for
exceptional returns and prints a message explaining the exceptional return.
The character interface also does not continue evaluating a form if a
sub-form produced a null object.
Most of the C++ classes provided by NeoClassic are organized under the
class NeoPtrObject.
There are ``null objects'' possible under NeoPtrObject, i.e.,
objects that do not point to any data. A null object can be
checked for in the usual way (by comparison with 0). Functions
that can return such null objects are prominently indicated.
[NULL return] If the object does not actually belong to the
subclass, a null object is returned.
In the Character Interface, more-general classes are conditionally coerced
into more-specific classes. For example, if a function requires a
ClassicDescription, but its argument produces a Description, the Character
Interface will check to see if the result of evaluating the argument is
actually a ClassicDescription, and will use it if so. If the result is not
a ClassicDescription, the Character Interface will report an error.
In the Character Interface, Symbols can be coerced into ClassicTestGenerate,
HostTestGenerate, ComputedDescriptionGenerate, and ComputedFillersGenerate by
looking the symbol up in tables. These tables are populated as a
side-effect of creating objects in ClassicTestGenerate, HostTestGenerate,
ComputedDescriptionGenerate, and ComputedFillersGenerate.
Every knowledge base starts out with several pre-defined concepts.
Knowledge bases only really exist as members of this collection.
Whenever a knowledge base is removed from the collection, all
information is removed from it. The knowledge base should not be
modified or accessed thereafter.
[NULL return] If there is no current knowledge base, return a null
knowledge base.
[NULL return] If there is no knowledge base with this name, then
don't change the current knowledge base and return a null knowledge
base.
[NULL return] If a knowledge base with that name already exists,
then return a null knowledge base.
[NULL return] If there is no knowledge base with the name, return a
null knowledge base.
It is impossible to make the knowledge base collection empty with
this function, as another knowledge base will be created in this case.
It is impossible to make the knowledge base collection empty with
this function, as another knowledge base will be created in this case.
[NULL return] If there is no such role, return a null role.
[NULL return] If there is no such concept, return a null concept.
[NULL return] If there is no such classic concept, return a null
classic concept.
[NULL return] If there is no such rule, return a null rule.
[NULL return] If there is no such classic individual, return a null
classic individual.
[NULL return] If there already is a role with that name, return a
null role.
[NULL return] If there already is a concept with that name, return
a null classic concept.
[INCOHERENT return] If the concept is incoherent, do not add it to
the knowledge base.
[NULL return] If there already is a concept with that name, return
a null host concept.
[INCOHERENT return] If the concept is incoherent, do not add it to
the knowledge base.
[NULL return] If there already is a rule with that name, return a
null rule.
[INCONSISTENT return] If running the rule on instances of the
antecedent results in an inconsistent knowledge base, do not change
the knowledge base. In this case return an inconsistent rule that
contains the relevant state of the knowledge base that would have
resulted if the rule had been added.
[NULL return] If there already is a classic individual with that
name, return a null classic individual.
[INCONSISTENT return] If adding the classic individual makes the
knowledge base inconsistent, do not change the knowledge base. In
this case return an inconsistent classic individual that contains
the relevant state of the knowledge base that would have resulted
if the classic individual had been added.
[NULL return] If such a role, concept, classic concept, host
concept, rule, or classic individual does not exist; return a null
role, concept, classic concept, host concept, rule, or classic
individual, as appropriate.
[NULL return] If the object does not belong to a knowledge base, a
null knowledge base is returned. This should only happen for
incoherent or inconsistent objects or objects that have been
``destroyed'' by being removed from their knowledge base or by
having their knowledge base destroyed.
Classic individuals represent classic objects in a domain.
[INCONSISTENT return] If any of these operations would make the
knowledge base inconsistent, the operation is not performed. Instead
an inconsistent classic individual is returned. This classic
individual contains the relevant inconsistent state of the knowledge
base that would have resulted from performing the operation.
Note: Most of these classes are actually template instantiations,
but this implementation detail does not affect their use.
User Functions are C++ functions that are called at appropriate places
within NeoClassic, and are used to extend the functionality of
NeoClassic. There are two kinds of user functions: test functions, which
extend descriptions; and rule functions, which extend rules.
Each kind of user function is actually a subclass of ClassicTestDetail,
HostTestDetail, ComputedDescriptionDetail, or ComputedFillersDetail.
Creating a user function involves calling the create member function of a
subclass of ClassicTestGenerate, HostTestGenerate,
ComputedDescriptionGenerate, or ComputedFillersGenerate. The creation
function takes a collection of parameters, which are stored in the new
instance of a subclass of ClassicTestDetail, HostTestDetail,
ComputedDescriptionDetail, or ComputedFillersDetail. Running the user
function involves calling the run member function of this new instance.
This member function can access the information retained in the instance.
The different user functions have different behavior, based on where the
object they are embedded in is placed in NeoClassic.
ClassicTestDetail and HostTestDetail are placed in descriptions created
by testC and testH, respectively. Their run functions are responsible
for determinining whether a classic or host individual is known to belong
to the test description, in which case the function returns testTrue;
whether the individual is known not to belong to the description, in
which case it returns testFalse; or whether the individual is neither
known to belong nor not known to belong, in which case it returns
testMaybe. Once a ClassicTestDetail or HostTestDetail is placed in a
description, it is no longer directly accessible but its data can be
retrieved in the application programming interface via the ClassicTest
and HostTest classes that are returned from the toldTests and
derivedTests functions.
The character interface creates user functions by means of tables that map
symbols into user function prototype. These prototypes are instances of
the ...Generate classes, and are responsible for checking if the
parameters supplied are appropriate, for creating new user functions, and
for generating usage messages.
There are four built-in user functions that can be used in the
character interface without doing any C++ programming. They are all
HostTestGenerate functions that are used to create host test
descriptions.
Most of the work of defining kinds of user functions is done by macros
and templates. The only function that has to be written by users is the
run function.
Consider this example:
The macro also creates a prototype object that is an instance of (a
subclass of) ClassicTestGenerate. The prototype ensures that a creation
of an AtLeastTest via a call to testC has two parameters, and that the
first one can be converted into an unsigned int and that the second one
can be converted into a Role. The create function of the prototype
converts the parameters to the correct type, if necessary, and determines
which knowledge base, if any, the description will belong to. Then the
create function calls a constructor for AtLeastTest that stores the name,
knowledge base, and parameters in the new instance. Finally the create
function returns the new instance of AtLeastTest. The usage function of
the prototype print an appropriate string.
The macro provides a number of member functions for the AtLeast class.
The == member operator that the name and all the parameters are the same.
The print member function prints the name and the parameters. The getKB
and getName member functions return the stored knowledge base and name.
The run member function has to be supplied by the user, as above. This
run member function takes a classic individual and two pointers to sets,
and returns a TestVal, as do all ClassicTestFun1ctions. The run member
function here checks to see if there are enough fillers for the role
parameter on the individual. It ignores the set pointers, which are used
to communicate dependencies, as it does not produce any dependencies.
The following macros are defined for creating user functions. Each
create data members, argi, for each parameter. Note that ComputedFillers
has an implicit first parameter, which is a role. The meaning of the
suffix on the macros is the number of parameters, followed by L if a list
of the trailing parameters is wanted.
The run functions have the following signature
Underlying the above macros are the following member functions for the
...Generate and ...Detail classes.
On the ...Generate side there is:
There is a fifth kind of ``unusual'' return from NeoClassic that is not
really an error. This return value is an incoherent description. There
is nothing wrong with creating an incoherent description unless that
description is used as the definition of a concept or individual, so this
return does not by itself signal an error.
Illegal calls to NeoClassic functions generally result in null returns.
Illegal calls to NeoClassic include:
To incorporate your hooks into NeoClassic, create a file with the hook
functions you require. Assign pointers to these functions to the
appropriate members of the class Hook. You have to assign values for all
the members of the class Hook given below; unused hooks can be set to 0.
There are two different kinds of changes that can be monitored, requests
to add or remove information from the knowledge base and deductions made
in response to these requests. The former kinds of changes may be
rejected by NeoClassic because they would make the knowledge base
inconsistent or create an incoherent concept. Therefore, there are
several hooks for each such change. The latter kinds of changes just
happen, but it is possible for several deductions to be made in response
to a request, an inconsistency discovered, and then the changes undone.
Hooks that signal the creations of objects in a knowledge base have as
arguments the knowledge base in which the request is being made, the name
of the new object, and the creation arguments. Hooks that signal the end
of such requests have as argument the new object, which is an error
object for failed requests.
The functions in the character interface are described in the interface
documentation.
The syntax for the CI allows two ways of grouping a function with its
arguments. Parentheses may be placed around the arguments only or
parentheses may be placed around the function name as well as the
arguments. Many CI functions can take an arbitrary number of arguments
that are grouped into a set or list.
A character interface function is compatible with a list of arguments if
the arguments can be converted into the types of objects that the function
wants. If the function has a Set or List as its last argument, a Set or
List is made from the sequence of trailing actual arguments.
Variables are replaced by their values before evaluation starts.
Other conversions are also performed, including
Symbols are conditionally converted into NeoPtrObject, Role, Concept,
ClassicConcept, HostConcept, or Rule, by looking them up in the current
knowledge base. KBSymbols are conditionally converted into NeoPtrObject,
Role, Concept, ClassicConcept, HostConcept, or Rule, by looking them up in
their knowledge base. Symbols are conditionally converted into
ClassicTestDetail, HostTestDetail, ComputedDescriptionDetail, or
ComputedFillersDetail by looking the symbol up in the appropriate table.
In addition, the fills and oneOf functions will automatically create
ClassicIndividuals if given a symbol for which no classic individual
exists.
Operations that are member functions of KnowledgeBase work on the current
knowledge base in the character interface, so no knowledge base
``argument'' is required.
Variables can be set and retrieved. The values of the last three forms
that produced values are available as the values of the variables $, $$,
and $$$.
Parsing errors indicate a problem with parsing the input. Forms that have
parsing errors are not evaluated. As soon as a parse error is detected the
rest of the input line is discarded. Parsing errors include:
Evaluator errors indicate a problem with evaluating a form. As soon as an
evaluator error occurs, the evaluation of the entire form is aborted.
Evaluator errors include:
User functions do their own compatability checking, initiated by the
evaluator. If the user function is not compatible with the supplied
parameters this is considered an evaluator error.
NeoClassic errors indicate some problem within NeoClassic. These are not
necessarily real errors, but instead may indicate some sort of exceptional
condition in a NeoClassic knowledge base.
NeoClassic errors include:
2/ What is NeoClassic?
NeoClassic is an implementation of Classic in C++. NeoClassic heavily uses
C++ object-oriented programming. NeoClassic currently provides two
low-level interfaces, a character-based interface (CI) and an application
program interface (API).
There was a graphical user
interface (GUI), but it is no longer working. All
interfaces can exercise the full knowledge representation capabilities of
NeoClassic.
3/ Running NeoClassic
The easiest way to run neoclassic is to execute a version of neoclassic
that reads from the standard input into the character interface and writes
to the standard output from the character interface. This version of
neoclassic is generally available via the command
4/ Knowledge Level Overview of NeoClassic
This overview ignores the exact syntax (and semantics) of NeoClassic, in
favor of providing a general idea of what NeoClassic can do. A passing
familiarity with description logics is required.
NeoClassic immediately computes the consequences of all information added
to a knowledge base. If an attempt is made to define an incoherent concept
(i.e., a concept that could never have any instances) then the attempt is
rejected. If an attempt is made to change a knowledge base in a way that
would make the knowledge base inconsistent then that attempt is rejected.
In both the above cases information is returned indicating why the attempt
was invalid.
5/ The Knowledge Language of NeoClassic
Individuals in a NeoClassic knowledge base are either host individuals or
classic individuals. Host individuals come from C++ and can be either
integers, floats, or strings. Classic individuals are created by NeoClassic
and represent anything desired.
6/ The Collection of Knowledge Bases
NeoClassic maintains a collection of named knowledge bases. One of these
knowledge bases is the current knowledge base. This knowledge base is used
in the character interface and when looking up symbols.
7/ Incoherency and Inconsistency Reporting in NeoClassic
If an operation in NeoClassic would result in an inconsistent knowledge
base that operation is not performed. Instead the operation returns a
special value, which encodes the relevant portion of the knowledge base and
can be used to find and explain the source of the potential inconsistency.
This result can be used to explain why the operation would have resulted in
an inconsistent knowledge base.
8/ Explanation Facilities in NeoClassic
NeoClassic can explain anything that is has inferred about any concept or
individual. It can explain why one description does/does not subsume
another, why an individual does/does not satisfy a description, why a
particular fact is/is not known about an individual or concept, and why a
rule did/did not fire. NeoClassic can even explain the inferences that
would have resulted in an inconsistent knowledge base.
9/ Hooks in NeoClassic
NeoClassic provides a facility that allows functions from outside NeoClassic
to be run in response to particular activities performed by NeoClassic.
These activities include the creation of roles, concepts, rules, and
individuals; the addition of information to or the retraction of
information from an individual; the firing of rules; the transfer of
information from one individual to another; and the discovery of a new
individual that satisfies a concept. This facility can be used to build
user interfaces that maintain an up-to-date view of a NeoClassic knowledge
base.
10/ Features to be Added in the Future
NeoClassic Conceptual Building Blocks
NeoClassic is a sophisticated knowledge representation system that allows
close program direct but safe access to its data structures. To
effectively access these data structures from a program requires a
knowledge of how they are organized.
1/ NeoPtrObject and named objects
Many NeoClassic objects belong to the NeoPtrObject class. This class is
actually a class of smart pointers that implement automatic storage
management, currently be means of reference counting. There are
type-checking operations provided for each subclass of NeoPtrObject to
allow discrimination between the various subclasses of NeoPtrObject. There
are also conditional downcasting operations provided for each subclass of
NeoPtrObject.
2/ Knowledge Bases
A knowledge base in NeoClassic contains a collection of consistent
information. This information is stored in the form of roles, concepts,
rules, and classic individuals. Each knowledge base also has a name.
A knowledge base continually computes the consequences of all information
it contains. Any operation that would result in an inconsistent knowledge
base is rejected. Part of this information is a classification and
instantiation taxonomy of concepts and classic individuals.
3/ The Knowledge Base Collection
NeoClassic also maintains a collection of named knowledge bases. In the
normal course of events every knowledge base is in this collection of
knowledge bases. There are operations to add a named knowledge base to
this collection, to remove a knowledge base from this collection, and to
find a knowledge base in this collection given a name. One of the
knowledge bases in this collection is the current knowledge base. There
are operations to return the current knowledge base and to make a knowledge
base be the current knowledge base. The current knowledge base is used in
several operations, including when coercing a symbol to a role, concept,
rule, or classic individual.
4/ Descriptions
A description in NeoClassic is a formal object that represents a collection
of the objects of a model or interpretation. Objects that are in the
collection are said to satisfy the description. A description is said to
subsume another description if for every model the collection it represents
is a superset of the collection the other description represents. A
description is said to be incoherent if the collection it represents is
empty in all models.
5/ Roles
A role in NeoClassic is a formal object that represents a relation from the
classic domain of a model to the entire domain. Roles are created in
knowledge bases. Roles can be tagged as attributes, i.e., a role whose
relation is a (partial) function.
6/ Concepts
A concept in NeoClassic is a formal object that represents a collection of
objects of a model. Concepts are defined in a knowledge base. Concepts
are divided into thing concepts, whose definition is a thing description;
classic concepts, whose definition is a classic description plus some
primitive information; and host concepts, whose definition is a host
description. Definitions of concepts must refer only to concepts that have
already been defined in the knowledge base.
7/ Rules
A rule in NeoClassic is a formal object that represents a mapping between
the representation of its antecedent and the representation of its
consequent. A rule requires that all classic individuals in the knowledge
base that belong to its antecedent also belong to its consequent. Rules
are created in knowledge bases.
8/ Individuals
Individuals in NeoClassic are either Classic Individuals or Host Individuals.
NeoClassic Interface Functionality
NeoClassic currently provides three low-level interfaces, a character-based
interface (CI), a graphical user interface (GUI), and a C++ application
program interface (API). All three interfaces can exercise the full
knowledge representation capabilities of NeoClassic. This document
includes information on all the user-callable NeoClassic functions, giving
both their C++ signature and their syntax in the character interface.
or as a single argument, which becomes the set itself, like
In the descriptions below, functions like this are written as follows
1/ Interface-Visible Classes Provided or Used by NeoClassic
NeoClassic provides or uses a number of C++ classes that are visible in the
two interfaces. In the following list of classes
means Sub is a child class of each of the Supers.
NeoPtrObject
KnowledgeBase : NeoPtrObject
Description : NeoPtrObject
ThingDescription: Description
ClassicDescription : Description
HostDescription : Description
Construct : Description
ThingConstruct: Construct, ThingDescription
ClassicConstruct : Construct, ClassicDescription
HostConstruct : Construct, HostDescription
IncoherentConstruct : Construct
Role : NeoPtrObject
Concept : Description
ThingConcept : Concept, ThingDescription
ClassicConcept : Concept, ClassicDescription
HostConcept : Concept, HostDescription
Rule : NeoPtrObject
ClassicIndividual : NeoPtrObject
The following C++ classes or enumerations provided or used by NeoClassic
are not (seen to be) subclasses of NeoPtrObject.
String
Symbol
Boolean { false, true }
HostType { negativeInfinity, positiveInfinity,
integerType, floatType, stringType }
TestVal { testFalse, testMaybe, testTrue }
KBSymbol
NeoSet<T>
IndividualSet
ClassicOneOf
HostOneOf
MinOrMax
HostIndividual
IntOrFloat
Primitive
RuleConsequent
ClassicDescriptionConsequent : RuleConsequent
ComputedDescription : RuleConsequent
ComputedFillers : RuleConsequent
ClassicTestGenerate
HostTestGenerate
ComputedDescriptionGenerate
ComputedFillersGenerate
ClassicTestDetail
HostTestDetail
ComputedDescriptionDetail
ComputedFillersDetail
ClassicTest
HostTest
NeoObject
Descriptions of some of the classes above are given here. Descriptions of
the other classes are given later in this document.
NeoClassic provides conditional coercion of String, Symbol, and char* into
Role, Concept, ClassicConcept, HostConcept, Rule, and ClassicIndividual by
look-up in the current knowledge base. If there is no object of the
correct type in the current knowledge base, a null object is returned.
2/ Knowledge Bases
Concept Name Definition
Thing Description::and()
ClassicThing Description::and(NeoSet<ClassicDescription>())
HostThing Description::and(NeoSet<HostDescription>())
Number Description::testH(numberp)
Integer Description::and(Number,testH(integerp))
Float Description::and(Number,testH(floatp))
String Description::testH(stringp)
a) Managing the Collection of Knowledge Bases
There is a single collection of all knowledge bases, maintained as a
map from symbols to knowledge bases. There is also a current knowledge
base, which is one of the knowledge bases in this collection. The
collection of knowledge bases is initialized to contain a single
knowledge base, which is the current knowledge base, when
NeoEnvironment::init is called.
b) Retrieving built-in concepts
The built-in concepts can be retrieved using these functions. They can
also be retrieved by name.
c) Retrieving Information by Name
The information in a knowledge base is maintained in maps from
symbols to several different kinds of information. There is one map
for roles, one for concepts, one for rules, and one for classic
individuals.
The character interface versions uses the current knowledge base.
The character interface versions use the current knowledge base.
The character interface versions use the current knowledge base.
The character interface versions use the current knowledge base.
The character interface versions use the current knowledge base.
The character interface versions use the current knowledge base.
d) Creating Objects in a Knowledge Base
One way to add information to a knowledge base is to add a new role,
concept, rule, or classic individual to the knowledge base.
The character interface versions use the current knowledge base.
The define-primitive version sets the primitive argument to true.
The character interface versions use the current knowledge base.
The character interface versions use the current knowledge base.
The character interface versions use the current knowledge base.
e) Writing a Knowledge Base to a file
3/ Descriptions
a) Subclasses of Descriptions
b) Creating Constructed Descriptions
Constructed Descriptions (Constructs) are created by means of various
functions, one for each of the constructors defined in the description
logic underlying NeoClassic.
c) Queries
d) Told Retrievals
The following functions retrieve various information that was TOLD about
the description. In several cases there are two versions of a function,
one that returns a set of the told information and one that returns this
told information combined into one piece.
e) Derived Retrievals
The following functions retrieve various information that was DERIVED
about the description, that is a combination of the told information plus
any information that could be inferred.
4/ Named Objects
The classes Role, Concept, Rule, and ClassicIndividual share
functionality having to do with their position in a knowledge base.
For various reasons there is no C++ class for named objects.
5/ Roles
6/ Concepts
a) Primitives
b) Simple Retrievals
c) Taxonomy Retrievals
*NOTE*: This function may construct and return a large set.
7/ Rules
Rules represent simple forward-chaining rules that run only on named
classic individuals in a domain.
a) Simple Retrievals
b) Queries
c) Rule Consequents
8/ Classic Individuals
a) Simple Retrievals
b) Adding and Removing Information from Classic Individuals
Another way of modifying the information in a knowledge base is by
adding and removing information from the classic individuals in the
knowledge base.
c) Queries
d) Taxonomy Retrieval
e) Told Retrievals
The following functions retrieve various information that was TOLD
about the individual. In several cases there are two versions of
a function, one that returns a set of the told information and one
that returns this told information combined into one piece.
f) Derived Retrievals
The following functions retrieve various information that was
DERIVED about the individual, that is a combination of the told
information plus any information that could be inferred.
9/ Host Individuals and related classes
The class HostIndividual is used to represent host programming elements of
the domain. The classes MinOrMax and IntOrFloat are used internally by
NeoClassic, but are also visible in the C++ application programming
interface. All three classes share a common implementation, so they are
discussed together here.
10/ User Functions
ComputedDescriptionDetail and ComputedFillersDetail are placed in the
consequent of rules. They are responsible for determining the
description to be added to a classic individual as a result of running
the rule. The run function for ComputedDescriptionDetail returns this
classic description directly, whereas the run function for
ComputedFillersDetail returns an IndividualSet that is added to the
fillers of a role on the individual. This role is the role that was
specified as the first parameter for the ComputedFillersDetail.
Character Interface Name Description
numberp is a host individual a number?
integerp is a host individual an integer?
floatp is a host individual a float?
stringp is a host individual a string?
ClassicTestFunction2(AtLeastTest,atLeast,unsigned int,Role);
TestVal AtLeastTest::run(const ClassicIndividual& ind,
Set<ClassicIndividual> *,
Set<ClassicIndividual> *) const {
ClassicIndividualDescription def = ind.getDefinition();
unsigned int indmin = def.derivedAtLeast(arg2);
unsigned int indmax = def.derivedAtMost(arg2);
if (indmin >= arg1) {
return testTrue;
} else if (indmax < arg1) {
return testFalse;
} else {
return testMaybe;
}
}
The macro ClassicTestFunction2 creates a subclass of ClassicTestDetail,
AtLeastTest. This subclass has a data member called arg1 with type
unsigned int and a data member called arg2 with type Role.
The above macros both declare and define the user function. To be able
to refer to the user function in more than one file, there are
declaration and definition versions of the above macros. The declaration
versions have the above names suffixed with Declare; the definition
versions are suffixed with Define.
virtual TestVal
ClassicTestDetail::run(const ClassicIndividual& ind,
Set<ClassicIndividual>* pdeps,
Set<ClassicIndividual>* ndeps) const
virtual TestVal
HostTestDetail::run(const HostIndividual& ind) const
virtual ClassicDescription
ComputedDescriptionDetail::run(const ClassicIndividual& ind) const
virtual IndividualSet
ComputedFillersDetail::run(const ClassicIndividual& ind) const
These run functions have a number of severe descriptions placed on them.
First, they must not modify the knowledge base. Second, the test
functions must be monotonic---that is, if they return testTrue or
testMaybe they must return the same result in a knowledge base with more
information. Third, the rule functions must be constant---that is, they
must return the same answer in a knowledge base with more information.
Fourth, if adding information to some other classic individual could
cause an answer returned from a classic test function, then that
individual must be added to the pdeps argument, provided that that
argument is non-null; if removing information from some other classic
individual could cause an answer returned from a classic test function,
then that individual must be added to the ndeps argument, provided that
that argument is non-null.
11/ Errors
There are four kinds of errors in NeoClassic. The first two kinds of
errors are specific to the character interface, and encompass anything
that can go wrong there. (See the documentation on the character
interface for more on these kinds of errors.) The third kind of error is
illegal calls to NeoClassic functions, such as trying to return the role
that has a particular name when there is no such role. The fourth kind
of error is an actual knowledge error, such as trying to add information
to a classic individual that makes the knowledge base inconsistent.
Knowledge errors result in returned objects that are incoherent or
inconsistent. The requested operation is not performed, i.e., the
knowledge base is not changed. Explanation can be used to determine why
the object is incoherent or inconsistent. Calls that produce knowledge
errors include:
LI> ClassicIndividual KnowledgeBase::createIndividual
12/ Explanation
Explanation is in the process of being implemented. Documentation will
be provided when explanation is complete.
13/ Hooks
Hooks are designed to allow a User Interface, or some other program, to
monitor the changes to a NeoClassic knowledge base. They allow user
functions to be run in response to knowledge base changes. Hooks are
implemented as a collection of function pointers, to reduce overhead, as
data members of the class Hook, to reduce namespace pollution.
a) User Request Hooks
The hooks that monitor most requests come in threes, one that signals the
start of the request, that is when the request is started to be
performed; and two that monitor the end of the request, one that signals
successful request and one that signals failed requests. Some requests
never fail and so have only two hooks; some happen indivisibly and so
only have one hook. Requests that are rejected for name-space reasons,
such as trying to create a concept with a name that is already in use in
the knowledge base, do not cause any hook to be called.
b) Deduction Hooks
The hooks that monitor deductions are called when the deductions are
made, i. e., when NeoClassic is in the middle of processing a request.
This means that the knowledge base is in an unsual state---some
deductions will be made and others will not. Therefore these hook
functions have to be particularly careful. In particular, such a hook
function should not change the knowledge base in ANY way. Any violation
of this requirement is likely to result in malformed knowledge bases,
core dumps, or infinite loops. Accessing the knowledge base is allowed,
but the exact current state of the knowledge base will be seen, so there
may be inconsistent individuals in the knowledge base, etc., etc.
Further, the points at which the hook functions are called and the
arguments passed have been chosen to minimize the impact on NeoClassic.
14/ Environmental Concerns
The class NeoEnvironment, which has only static members, contains several
functions relating to the environment of NeoClassic. These functions are
only available through the API, as they must be performed outside of the
character interface, or have analogues inside the character interface.
15/ Future Functionality
The following functionality will be supported in future releases of
NeoClassic:
Character Interface
The NeoClassic Character Interface is a simple interface that allows access
to the capabilities of NeoClassic without having to write C++ code. The
character interface reads commands from a stream, evaluates these commands,
and (optionally) prints the results obtained.
1/ Input Syntax
The character interface inputs a sequence of forms, in the following grammar:
Form ::= LispModeForm | CModeForm
LispModeForm ::= (Symbol LispModeArg*)
LispModeArg ::= Variable | Boolean | Int | Float |
String | Symbol | KBSymbol |
LispModeForm
CModeForm ::= Symbol ( CModeArg* )
CModeArg ::= Variable | Boolean | Int | Float |
String | Symbol | KBSymbol |
CModeForm
Boolean ::= `true' | `false'
Int ::= [`+'|`-']Digit+
Float ::= [Int]`.'Digit*
String ::= `"'Char*`"'
variable ::= `$'char*
Symbol ::= Alpha AlphaDigit*
KBSymbol ::= Symbol`:'Symbol
Alpha ::= `a'|`b'|`c'|...|`z'|`A'|`B'|`C'|...|`Z'|`?'|...
AlphaDigit ::= Alpha | `0' | ... | `9'
Abmiguities are resolved by taking the first alternative. (That is, the
argument `$A' is a Variable, not a Symbol; and the argument `true' is a
Boolean, not a Symbol.)
2/ Evaluation
A form is evaluated by first evaluating its arguments. Then all character
interface functions for the first symbol in the form that are compatible
with the actual arguments in the form are found. If there is exactly one,
it is executed on these arguments.
3/ Special Functionality
In the character interface, more-general classes are conditionally coerced
into more-specific classes. For example, if a function requires a
ClassicDescription, but its argument produces a Description, the Character
Interface will check to see if the result of evaluating the argument is
actually a ClassicDescription, and will coerce it if so. If the result is
not a ClassicDescription, the character interface will report an error.
4/ Printing
The different types of objects in the character interface and their printed
representation are as follows:
Type Printed Representation
int sequence of numerals
float sequence of numerals and .
Boolean false or true
String sequence of characters
Symbol sequence of characters
KBSymbol two sequences of characters separated by :
NeoSet<TYPE> elements enclosed in { and }
IndividualSet elements enclosed in { and }
ClassicOneOf <Universe> or elements enclosed in { and }
HostOneOf <Universe> or elements enclosed in { and }
MinOrMax +INF, -INF, or as int or float
HostIndividual as int or float or String
IntOrFloat as int or float
Primitive false, true, or set of symbols
RuleConsequent form that is equivalent to the consequent
ClassicTestGenerate name of the generator
HostTestGenerate name of the generator
ComputedDescriptionGenerate name of the generator
ComputedFillersGenerate name of the generator
KnowledgeBase name of the knowledge base
Description form that is equivalent to the description
Role (primary) name of the role
Concept (primary) name of the concept
Rule (primary) name of the rule
ClassicIndividual (primary) name of the classic individual
Further, if a Concept is incoherent, or a Rule or ClassicIndividual is
inconsistent, the inference that caused the incoherency or inconsistency is
shown when the object is printed as the result of evaluation.
5/ Errors
Parsing and evaluating errors are signalled by printing an error message on
the standard error. If input is from a file, this message includes the
file name and line number where the error was detected
A non-existant NeoPtrObject return generally indicates some sort of problem
having to do with the name space of a knowledge base, such as trying to
look up a non-existent concept or trying to create a role with a name that
is already used for another role. An incoherent NeoPtrObject return
indicates some operation that would have created an incoherent concept.
An inconsistent NeoPtrObject return indicates some operation that would
have made a knowledge base inconsistent. In both these two latter cases
the operation is not performed. See the documentation on individual
NeoClassic operations for more information on NeoClassic errors.
6/ Special Functions
7/ Testing Functions
The following functions are used for testing the correct behavior of
NeoClassic, and should not be used in normal code.