14 Ontologies and Knowledge-Based Systems

14.4 Implementing Knowledge-Based Systems

It is often useful for an agent to be able to represent and reason about its own reasoning in what is called reflection. Explicitly reasoning about its own representations and reasoning enables an agent to modify these for its own particular circumstances.

This section considers one use of reflection, namely, implementing light-weight tools for building new languages with features that are required for particular applications. By making it easy to implement new languages and tools, the best language for each application can be used. The language and tools can evolve as the application evolves.

A meta-interpreter for a language is an interpreter for the language written in the same language. Such an interpreter is useful because modifications allow for quick prototyping of new languages with useful features. Once the language has proven its utility, a compiler for the language may be developed to improve efficiency.

When implementing one language inside another, the language being implemented is called the base language, or sometimes the object language, and the language in which it is implemented is called the metalanguage. Expressions in the base language are said to be at the base level, and expressions in the metalanguage are at the meta-level. We first define a meta-interpreter for the definite clause language presented in Chapter 13. We then show how the base language can be modified or extended, and tools such as explanation and debugging facilities can be provided by modifying the meta-interpreter.