Third edition of Artificial Intelligence: foundations of computational agents, Cambridge University Press, 2023 is now available (including the full text).
13.5 Implementing Knowledge-Based Systems
It may be useful for an agent to be able to represent its own reasoning. Such reasoning about an agent's own representations is called reflection. Explicitly representing its own reasoning enables the agent to reason more flexibly so that the designer can craft the most appropriate language for each application.
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 can 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 12. 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.