Abstract:
A method of controlling the operation of a computer database system. The method of the invention is particularly adapted for use in processing a query in a computer system which has an inference engine, query processing means, and a set of object theories and metatheories. The method includes providing a system theory to define coupling relationships between the object theories and metatheories, selecting an object theory and associated metatheories according to the system theory in dependence on parameters of a query to be processed, and processing the query by the theories so chosen. The coupling relationship may be an interpreter, an assimilator or an attribute metatheory.

Description:
CROSS REFERENCE TO RELATED APPLICATION 
     This is a Continuation in Part application of copending application Ser. No. 07/247,451 filed Sep. 6, 1988, abandoned. 
    
    
     The present invention relates to the organization of theory-based systems and, more particularly, to the organization of a logic programming system or knowledge representation and management system based on logic programming, which incorporates a provability interface to multiple modules, databases or theories. 
     The basic terms such as theory, metatheory, assimilation, and provability used in this specification follow the usage of D. A. Bowen and R. A. Kowalski, &#34;Amalgamating Language and Metalanguage in Logic Programming&#34;, pages 153-182 of Logic Programming, edited by K. L. Clark and S. A. Ternlund, Academic Press, New York, 1982 and also K. A. Bowen and T. Weinberg, &#34;A Meta-level Extension of Prolog&#34;, pages 48-53 or 1985 Symposium on Logic Programming, Boston, IEEE. It is to be understood that the term &#34;theory&#34; as used herein encompasses equivalent concepts such as logic databases, modules and worlds (the latter term being one used by H. Kauffmann and A. Grumbach in &#34;Representing and Manipulation Knowledge within Worlds&#34;, at pages 61-73 of Proc First Int Conf on Expert Database Systems, Edited by L. Kershberg, 1986). 
     The present specification also assumes a basic knowledge of logic programming such as that possessed by any skilled worker in the field. In particular, some knowledge of the logic programming language Prolog is assumed. For a basic text, refer to &#34;Programming in Prolog&#34;, W. F. Clocksin and C. S. Mellish, Springer-Verlag, 1984). Another very useful reference is the paper by R. A. Kowalski entitled `Problems and Promises of Computational Logic` published as part of the Computational Logic Symposium Proceedings, Brussels, November 1990 and edited by J. W. Lloyd. The basic concepts of a knowledge-base management system are also assumed (see Proc First Int Conf on Expert Database Systems, cited above). 
     Rather than having a homogeneous knowledge base, in practice, some kind of partitioning of the facts and rules of a knowledge base system is often desirable for various reasons some examples of which are: 
     modularization of knowledge can reflect the conceptual structuring of a problem, 
     it permits the existence of mutually inconsistent theories: 
     a partition of the knowledge base can be treated as an `object` for purposes of metaprogramming--specialized inference control and specialized assimilation control can be particularized to certain partitions. Those partitions can be subjected to more than one regime of control; 
     it is the primary mechanism through which scale is controlled. Partitions are not affected by the growth of other partitions as they might be with flat knowledge bases; theories become a code module structure (theories can be reused in more than one application); 
     the partitioning of knowledge in theories enables different theories to be realized in foreign systems where desirable. For example one theory which appears to be a large set of ground structureless facts might in reality be stored in a relational database and managed by a relational database management system. 
     The simplest form of partitioning is to divide the system into entirely independent theories. However, this effectively results in a number of entirely independent modules, which is of very little use. A more useful form of partitioning involves modularising the knowledge base into distinct subsystems, but preserving some form of coupling between those subsystems. 
     Two main types of partitioning are possible. 
     If the functionality of a theory is considered in detail, it will be realized that several reasonably distinct areas of functionality can be distinguished. These functionalities can be partitioned out from the basic theory as metatheories; theories which are concerned with the basic theory as an object or operand. 
     One function of the basic theory is the inbuilt reasoning or interpretation function, but in some circumstances it may be desirable to provide an additional and more elaborate interpreter function. If it is desired to be able to update the theory, then assimilator means are required with the functionality for ensuring the updates do not introduce inconsistency. Further, the updating may involve checking against factual data to ensure, for example, that various values are within appropriate ranges, and the range information may be regarded as attribute information distinct from the functionality of assimilation, requiring an attribute function. 
     Thus it may be desirable to have a number of metatheories, performing different specialized functions, associated with a given theory. The present system provides for three types of metatheory--interpreter, assimilator and attribute metatheories. 
     The use of such metatheories and the sharing of metatheories between object theories is known e.g. from the Bowen and Weinberg paper mentioned in the introduction of this application. 
     Another type of partitioning is the partitioning of the basic or main theory into different subject matters, giving a set of theories, all on the same &#34;level&#34;, which we can conveniently describe as object theories. 
     Although these two types of partitioning are logically distinct, it is advantageous to use them in combination. This permits the sharing of a single metatheory by several object theories, whereas partitioning of object theories alone would require the same metatheory statements and rules to appear in several object theories. 
     FIG. 1 of the accompanying drawings illustrates known types of partitioning by showing a fragment of a hypothetical system containing a variety of different theories and the relationships between them. The principal forms of relationship are illustrated in this example, which gives the flavour of a relational database application. 
     The theory-metatheory relationships are of three different kinds, of a theory with its interpreter, assimilator, and attribute metatheories; these are indicated by the different types of line indicated as I, As, and At respectively. 
     Three object theories 20 to 22--an employment theory 20, a parts theory 21, and a suppliers theory 22--are together equivalent to a typical database of primarily factual data. The employment theory 20 is primarily a collection of facts concerning various people; it includes their employment details and also various simple relationships between them (such as spouse and parent-child relationships). The parts theory 21 is primarily a collection of facts about parts and components for a factory and the suppliers theory 22 is primarily a collection of facts about the suppliers of various raw materials for the factory. 
     The parts theory 21 and the suppliers theory 22 are both inherently factlike and so each can have an interpreter which takes account of this and performs fact look-up instead of full theorem proving. These two theories therefore have a common interpreter 26. In the same way, they have a common assimilator 27, which ensures that the individual theories remain semantically consistent. This therefore illustrates two of the three types of theory-metatheory relationship and a metatheory being used by two different object theories. 
     The employment theory 20 has an interpreter theory 23, an assimilator theory 24 and an attribute theory 25. The employment theory may include certain rules in addition to factual statements, so its interpreter 23 must incorporate a full theorem prover. The assimilator theory 24 is a specialized assimilator which ensures that any new data added to the employment theory does not violate any specified constraints. 
     One type of constraint concerns the nature of the data being added; for instance, it must be consistent with a group of data, such as employee grade data, that is allowed in that theory. The allowed groups of data are defined in the attribute theory 25, which contains all the metadata about the employment theory. Thus to perform this check, the assimilator needs to reference (prove a result) in the attribute theory. Thus the metatheory level need not be flat; a metatheory can be manipulated by a further metalevel which is a &#34;metametatheory&#34; to the original object theory and simultaneously a metatheory to the original metatheory. 
     In addition to the three fact-like theories 20 to 22, there is a genealogy object theory 28, which is primarily composed of a set of rules defining complex genealogical relationships, such as ancestorhood and cousinhood and many of which are therefore recursive. This theory has a special interpreter theory 29, which is designed to deal efficiently with recursive rules and so restrict the types of inference explosion that can otherwise arise with such rules. The genealogy theory itself draws on the simple personal relationship information contained in the employment theory 20. This is a further type of theory-to-theory relationship, between two object theories. 
     Returning to the employment theory 20, its assimilator theory 24 also takes account of a further type of constraint pertaining to the &#34;meaning&#34; of the data, for instance whether a new employee&#39;s relationship that is being added is consistent with the theory and with the knowledge about relationships held in the genealogy theory. This will involve the assimilator requiring results to be proved in the genealogy theory. 
     The present invention is concerned with an architecture for organising theories in a theory-based system. The prior art only addresses the issue of theory reference in terms of references to one theory within another. The issue of the overall organisation of theories in a theory-based system is not addressed at all. 
     According to the present invention there is provided, in a system comprising a plurality of object theories and metatheories having coupling relationships between them, an inference engine, and query processing means, the method of processing queries comprising: providing a system theory which defines the coupling relationships between the theories, processing the query by the system theory to choose an object theory and associated metatheories in dependence on the parameters of the query and processing of the query by the theories so chosen. The present invention thus provides a new system arhitecture for a theory-based system and one which gives rise to substantial technical advantages as will be explained. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 depicts known types of partitioning. 
     FIG. 2 shows the main components of a system according to the present invention. 
     FIG. 3 depicts the updating of a theory having a name TN according to the teachings of the invention. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     A system theory provides an organisation of the theories it contains. Since it is itself a theory it can participate in higher level organisations of system theories. This higher level organisation therefore contains many system theories which may be an evolution of one system theory or an organisation of several evolutions of unconnected system theories. This higher level organisation could itself be described by a theory and so could participate in even higher level organisations and so on. 
     A system theory can be regarded as an architecture which supports the storage, retrieval and updating of knowledge modularised into separate theories. Each theory in the system is associated with three other theories. All three are metatheories with respect to that theory, which correspondingly is an object theory with respect to those metatheories. First, there is an interpreter metatheory, which defines a provability relationship for the object theory, supporting query satisfaction as theorem proving. The interpreter controls inference within the object theory, supporting explicit, domain-specific characterizations of the object theory clauses where available. Second, there is an assimilator metatheory, which extends the logical update primitives provided by the underlying knowledge base management system to enforce syntactic and semantic constraints (both local and global) on updates of the object theory. Third, there is an attribute metatheory which expresses characteristics of the object theory clauses, such as type constraints, used by interpreters and assimilators to control inference and updating. 
     The partitioning of this theory-specific metaknowledge allows interpreters and assimilators to be shared amongst several different object theories. 
     An interpreter theory may for example incorporate means for backtracking through a succession of theories having an inheritance relationship. One form of inheritance is merely theory selection, where a goal is proved in one member of a set of theories with an inheritance relationship. A more elaborate form of inheritance can readily be incorporated in a theory&#39;s interpreter, such that when the interpreter tries to satisfy a goal in a named theory and fails, it does not back-track to the previous goal; instead, it queries the system to find the name of a theory from which the current theory inherits and tries to satisfy the current goal in the ancestral theory. This elaboration allows each individual subgoal to be tried in each theory, instead of only the overall goal. 
     The primary use of attribute theories is to allow particular theory-dependent information to be abstracted out of interpreters and assimilators. This enables the interpreters and assimilators to be made relatively independent of particular theories and hence to be applicable to more than one object theory. 
     All assimilation proceeds via a standard interface, like the standard query interface, update(System,TheoryName,Updates,NewSystem,NewTheory). In a similar manner to interpretation, each assimilator must understand and be able to translate into, the representation of the theory it is updating. An update is specified as a list of actions--all actions are eventually reduced to primitive declarative add and delete operations on the theory being updated. The simplest form of assimilator simply carries out such additions and deletions. A more elaborate assimilator will carry out some form of checking for consistency either clause by clause as they are added (with provision for ignoring unavoidably inconsistent states of the theory during updating) or on the theory as fully updated; in either case, there is provision for backtracking and restoration of the original state of the theory in the event of an attempted illegal update. As with interpreter theories, the abstraction of consistency checking from a theory into an assimilator theory makes it more likely that an assimilator theory will be applicable to more than one theory. The system theory itself also has its own assimilator. A typical task for the system assimilator might be to check that when a new theory is being added to the system, all of its nominated metatheories also belong to the system. 
     Since interpreters and assimilators are themselves theories, they also may be associated with metatheories. An interpreter theory (object theory) will in turn require another interpreter theory (metatheory) to control inference within the first interpreter theory. Likewise assimilator theories and attribute theories will require interpreter theories. Conversely, interpreter and assimilator theories may also require attribute theories and so on. However, only one or two levels of interpretation will be used in practice, for reasons of efficiency. This apparent infinite regress is terminated by special built-in interpreter and assimilation theories. 
     In the architecture of the invention a knowledge base is represented by a special type of theory, the system theory, but one which is distinguished only by its role. The system theory is a declarative statement of all theories in the system and the relationships between them. The system theory describes the relationship between the name of a theory, the theory itself and the names of its metatheories. In defining this relationship, the full power of Horn clause logic can be brought to bear. For example, a named object theory can have many interpreters and a particular interpreter may be used on many object theories. The system ability to represent many-to-many relationships between theories and their metatheories and allows reasoning within the system about which metatheory is appropriate for a particular task. 
     In the preferred arrangement, the system theory statement are preferably five-place clauses, with one place for a theory name and the other four places corresponding respectively to an object theory, an interpreter metatheory, an assimilator metatheory and an attribute metatheory therefor. 
     
         ______________________________________An example of theform of statements in the system theory is shown below:TheoryName        Theory  Interpreter                         Assimilator                                 Attribute______________________________________&#34;theory&#34;  (calc,   T.sub.1,                   prologInt,                           prologAss,                                   none)&#34;theory&#34;  (calc,   T.sub.1,                   calcInt prologAss,                                   none)&#34;theory&#34;  (calcInt,           T.sub.2,                   prologInt,                           prologAss,                                   none)&#34;theory&#34;  (calcInt,           T.sub.2,                   prologInt,                           calcAss,                                   none)&#34;theory&#34;  (calcAss,           T.sub.3,                   prologInt,                           prologAss,                                   none)&#34;theory&#34;  (system, T.sub.4,                   prologInt,                           prolog Ass,                                   none)______________________________________ 
    
     In each of the five place statements in the system theory, the first place is filled by a theory name. The second item in each of the &#34;theory&#34; statements is the object theory named in the first item. In this embodiment, the second place is filled by the theory itself, not just an address where the theory can be found. The third, fourth and fifth items are the names of the relevant interpreter, assimilator and attribute theories respectively. Where the interpreter, assimilator or attribute theory is not the basic interpreter, assimilator or attribute theory (prolog-Int, prologAss, none respectively--the built-in attribute theory is called `none` which names the empty theory), an entry for that metatheory also appears as a statement in the system theory. This enables the appropriate metatheory to be accessed. The system therefore supports arbitrary levels of interpretation to be introduced in handling a query--an interpreter is found by querying the system (that is, the system theory), and then this interpreter is interpreted by another interpreter found by querying the system and so on. 
     Such a sequence of metatheories must of course terminate eventually. This achieved by defining a built-in set of metatheories, &#34;prologInt&#34;, &#34;prologAss&#34; and &#34;none&#34; and ensuring that every sequence of metatheories terminates in the appropriate built-in metatheory. A sequence can of course call one or more of the built-in metatheories directly. 
     The system theory contains other statements governing the resolution of theory names. For example, there could be two five-place statements in the system theory which have the same theory names (although the object theories will be different) and further statements in the system theory for resolving the theory names. For example, there could be two entries for a theory named &#34;tax&#34;, each having the same set of three named metatheories, although one of the tax theories is for 1989 calculations and the other for 1990  calculations. The system theory will have other statements permitting inferencing about which tax theory to select on the basis of the parameters given in the query. Instead, or as well, information in the system attribute theory may be used for resolving theory names eg. information such as who wrote a theory and when. 
     The system theory also contains rules governing how metatheories are selected. For example, the `calc` theory may be for calculating the prime factors of a given number and the system theory may contain a rule specifying that when the given number is greater than a certain threshold the calcInt interpreter should be used, otherwise the prologInt interpreter should be used. 
     The present system thus provides a new and improved technique for resolving theory names and for defining metatheories for each theory allowing the selection among a plurality of theories in dependence on circumstances defined by the particular query. 
     The system theory contains a statement for every theory in the system and therefore contains an entry for itself (shown as the last statement above). FIG. 4 depicts the way in which the system theory references the theories in the system. 
     An example of a system theory is appended as Appendix A. Each five-place statement begins with &#34;theory&#34; and each actual object theory is prefaced by a hash symbol. 
     FIG. 2 shows the main components of a system 35 according to the present invention. 
     Hardware 40 may comprise a model from the 300, 400 or 800 series of the Hewlett-Packard HP9000 family of computers, an HP3000, 900 series or an IBM-AT compatible PC; operating system software 42 such as the UNIX operating system, the MPE/XL operating system or the OS/2 operating system, depending on the platform used; interpreter software 44 comprising a Prolog interpreter; a knowledge base management system (KBMS) 46 according to the present invention comprising a knowledge base 48; query interface software 50 for translating input queries into a form which can be processed by the system 35. The query interface software 50 may comprise a query interface theory which can convert a standard database query language into an appropriate form for querying any of the other theories in the system. 
     The KBMS 46 comprises at least one system theory defining a knowledge base 48. It is possible for the KBMS to contain a plurality of independent system theories and/or theories which are independent of the or each system theory. 
     Whenever a query is made in a named theory, that theory must be located via the system theory. This is achieved by querying the system, by means of a predictate interface which is standard for all theories. This interface operates in the underlying knowledge base management system (KBMS) 46 and takes a theory name and a set of goals: prove(System,TheoryName,Goals). The system theory is consulted to resolve the name of the theory and the name of its interpreter. If there is more than one interpreter for the named theory, then inference within the system is used to choose between them. The KBMS then attempts to prove that the interpreter can solve the goals (if an interpreter is required for the interpreter, recursion occurs until the built-in interpreter is reached). The use of interpreters specific to individual theories can increase the efficiency of proving goals, since the proof techniques can be matched to the specific domains of the various theories, using appropriate syntactic and semantic constraints in inference control. 
     The implementation of a system written in Prolog will not be described in detail since this forms part of the knowledge of the average skilled person in the field of logic programming. However, an outline will be given. 
     A prolog system can essentially be implemented using a simple stack model. The whole nature of theorem-proving using the Prolog depth-first, left-to-right, backtracking form of resolution lends itself to being realized using a stack at the centre of the implemented system. A step of inference proceeds through four basic steps: goal selection, where the next goal from the set of outstanding goals to be satisfied is selected--in Prolog this is simply the goal at the top of the goal stack; clause selection, where a clause is selected from the relevant procedure in the relevant part of the knowledge base--this clause must have a head that is (or potentially is) unifiable with the goal selected; unification, where the goal selected and head of the clause selected are unified; combination of subgoals, where all the goals in the body of the clause selected are pushed onto the top of the goal stack. 
     Thus it would appear that a single stack is sufficient to implement a Prolog system--a control stack where the set of outstanding goals to be satisfied in the computation are kept, and where the requirements of the system treat this purely as a LIFO (last-in, first-out) stack. However, on inspection it transpires that a second stack is necessary to retain terms which are bound to variables and would be popped off the control stack if the one-stack model were used. The second stack, the copy stack, is therefore introduced to act as the store for any such terms which would otherwise be lost. A third stack is also necessary to ensure that state can be faithfully restored on the copy stack during backtracking. 
     A fuller explanation of these stacks, and Prolog implementation in general, may be found in &#34;Implementing Persistent Prolog&#34;, Coulomb, RM, Ellis Hardwood 1990, ISMB 0-13-453531-6. 
     In accordance with the present invention, for all incoming queries, theory names are resolved and the appropriate metatheories are selected using the system theory before the query is processed. 
     Since the invention is used in implementing a flexible query (provability) and assimilation (updating) interface to a logic programming system (KBMS), the invention can be implemented by means of a Prolog program fragment implementing this facility. Such a program with statements in first-order logic thus forms a detailed embodiment of the invention. (The implementation of theories within Prolog is straightforward and not described here). 
     The following description is in the form of a particular predicate theory (the system theory) which relates theory names to theories to interpreter names, assimilator names and attribute names. The system theory contains, interalia, a 5-place predicate &#34;theory&#34; relating a theory name TheoryName with a theory Theory, an interpreter theory name IntName, an assimilator theory name AssName and an attribute theory name AttrName. 
     A formal definition in first-order logic of the meaning of &#34;prove&#34; and &#34;update&#34; is as follows. Clauses defining the conditions under which particular associations apply are represented within the system theory. The system theory is used during the first stage of query and update handling and specified in the third (prove) and fifth (update) predicates. 
     
         ______________________________________prove (System, system, Goals):- interpretTheory                     (Clause 1)(System, Goals).prove (System, prologInt, interpret (TheoryName,                     (Clause 2)Theory AttrName, Goals):-interpretTheory (Theory, Goals).prove(System, TheoryName, Goals):-                     (Clause 3)prove(System, system, theory(TheoryName, Theory, IntName,AssName, AttrName).prove(System, Intname, interpret(TheoryName, Theory,AttrName, Goals).update(System, TheoryName, Clauses, NewSystem, NewTheory):-prove(System, system, theory(TheoryName, Theory, IntName,AssName, AttrName))prove(System, AssName, assimilate(System, Theory, AttrName,Clauses, NewTheory), updateSystem(System, TheoryName, Theory, New Theory, NewSystem).______________________________________ 
    
     The meaning of these predicates, variables and functions is as follows: 
     1) &#34;prove(System,TheoryName,Goals)&#34; is true if the goal (or query) &#34;Goals&#34; is provable in the theory named &#34;TheoryName&#34;, where the system theory &#34;System&#34; defines the naming relationships (i.e. which name names which theory, interpreter, assimilator, attributes). In the case given, the clauses restrict the system theory&#39;s interpreter to being Prolog--like (the built-in interpreter). 
     2) &#34;update(System,TheoryName,Clauses,NewSystem,NewTheory) is true if the clauses &#34;Clauses&#34; are added to the theory named &#34;TheoryName&#34; in the system theory &#34;System&#34; to produce the new theory &#34;NewTheory&#34; and the new version of the system containing &#34;NewTheory&#34;, &#34;NewSystem&#34;. &#34;NewSystem&#34; is created from &#34;System&#34; in such a way that &#34;TheoryName&#34; now names the new theory. 
     3) &#34;IntName&#34;, &#34;AssName&#34; and &#34;AttrName&#34; represent the names of a theory&#39;s interpreter, assimilator and attributes (see above) respectively. 
     4) &#34;interpret(TheoryName,Theory,AttrName,Goals)&#34; is true if the compound goal &#34;Goals&#34; is provable in the theory &#34;Theory&#34; having name &#34;TheoryName&#34; and an attribute theory named &#34;AttrName&#34;. 
     5) &#34;assimilate(System,TheoryName,Theory,AttrName,Clauses, NewTheory)&#34; is true if the clauses &#34;Clauses&#34; can be added to the theory &#34;Theory&#34; to yield a new theory &#34;NewTheory&#34; given &#34;AttrName&#34; and the system theory &#34;System&#34;. 
     6) &#34;interpretTheory(TheoryName,Goals)&#34; is true if the goal &#34;Goals&#34; is provable using the Prolog-like proof procedure. 
     7) &#34;updateSystem(System,TheoryName,Theory,NewTheory, NewSystem)&#34; is true if the system theory &#34;NewSystem&#34; differs from the system theory &#34;System&#34; by having the theory &#34;NewTheory&#34; associated with the theory name &#34;TheoryName&#34; instead of the theory &#34;OldTheory&#34;. 
     A specific example of the operation follows. We suppose that we want to find the 8th term of the Fibonacci series, using a function &#34;fib&#34; by which we have defined the series. 
     
         ______________________________________The system theory comprises the following statements:______________________________________theory (system, Theory,             &lt;- system(Theory) &amp; trueprologint, prologAss, none)theory (fib, theory-a80f8,             &lt;- trueprologint, prologAss, none)theory (lemma, theory-a8510,             &lt;- trueprologint, prologAss, none)theory (fibbattr, theory-a8638,             &lt;- trueprologint, prologAss, none)theory (fibl, theory-a8734,             &lt;- truelemma, prologAss, fibattr)theory (myprove, theory-a8bd8,             &lt;- trueprologint, prologAss, none)theory (myprove, theory-a8bd8,prologint, prologAss, none)             &lt;- true______________________________________Reference numbers for the relevant theories appear in the secondplaces in each statement for the purpose of this description, inactuality the whole Theory term resides in those positions.______________________________________The query is:prove (System, fib, fib(8, N))______________________________________The steps in the prove process are shown below:______________________________________clause 3 (call): prove(theory-a8f84, fib, fib(8, N))                          C1clause 1 (call): prove(theory-a8f84, system, theory(fib,                          C2Theory, IntName, AssName, AttrName))clause 1 (call): interpretTheory(theory-a8f84, theory(fib,                          C3Theory, IntName, AssName, AttrName))clause 1 (exit): interpretTheory(theory-a8f84, theory(fib,                          E3theory-a80f8, prologint, prologAss, none))clause 1 (exit): prove(theory-a8f84, system, theory(fib,                          E2theory-a80f8, prologint, prologAss, none))clause 2 (call): prove(theory-a8f84, prologint, interpret(fib,                          C4theory-a80f8, none, fib(8, N))clause 1 (call): interpretTheory(theory-a80f8, fib(8, N))                          C5clause 1 (exit): interpretTheory(theory-a80f8, fib(8, 34))                          E5clause 2 (exit): prove(theory-a8f84, prologint, interpret(fib,                          E4theory-a80f8, none, fib(8, 34))clause 3 (exit): prove(theory-a8f84, fib, fib(8, 34))                          E1______________________________________ 
    
     On the left hand side is indicated the relevant clause of the &#34;prove&#34; predicate and whether the clause is being called or exited (i.e. with the relevant variables instantiated). The nesting of the calls is indicated on the right hand side where C indicates call and E indicates exit. 
     In the first call, the &#34;prove&#34; predicate is invoked. In the second call, &#34;prove&#34; is used to look for the theory which is needed to deal with the function &#34;fib&#34;, together with the appropriate metatheories. To achieve this, a third call has to be made to satisfy &#34;interpretTheory&#34;. This third call returns the theory for &#34;fib&#34; and the appropriate metatheories and these are returned in the exit from the second call. The fourth call attempts to satisfy the Fibonacci function itself. This involves the fifth call, which reaches the Fibonacci theory (identified by fib) and returns the answer to the fourth call, which then makes the final return with that answer. The answer is declared in the answer to the first call. 
     In terms of the formal definitions given above, the second call proves the first subgoal of clause 3 and the third call proves the first clause, the fourth call proves the third clause of subgoal 2 and the fifth call proves the second clause of that subgoal. 
     In another example, suppose we wish to update the theory fib by including the fact that the first negatively-indexed Fibonacci number is zero. 
     
         ______________________________________The system theory comprises the following statements:______________________________________theory(system, Theory, prologInt,               &lt;- system(Theory) &amp; trueprologAss, none)theory(fib, theory-aa12c, prologInt,               &lt;- trueprologAss, none)theory(lemma, theory-a86bc,               &lt;- trueprologInt, prologAss, none)theory(fibattr, theory-a87e4,               &lt;- trueprologInt, prologAss, none)theory(fibl, theory-a88e0, lemma,               &lt;- trueprologAss, fibattr)theory(myprove, theory-a8d84,               &lt;- trueprologInt, prologAss, none)theory(prologAss, theory-a94d8,               &lt;- trueprologInt, prologAss, none)nil______________________________________The steps in the &#34;update&#34; process are shown below:______________________________________clause 1 (call): myupdate(theory-a96ac, fib, assert(fib(-1,                          C1),nil, S7, NT)clause 1 (call): prove(theory-a96ac, system, theory(fib,                          C2eory,IntName, AssName, AttrName))clause 1 (call): interprettheory(theory-a96ac, theory(fib,                          C3Theory, IntName, AssName, AttrName))clause 1 (exit): interpretTheory(theory-a96ac, theory(fib,                          E3theory-a82a4, prologInt, prologAss, none))clause 1 (exit): prove(theory-a96ac, system, theory(fib,                          E2theory-a82a4, prologInt, prologAss, none))clause 3 (call): prove(theory-a96ac, prologAss, assimilate                          C4(theory-a96ac, theory-a82a4, none, assert(fib(-1, 0)),nil, NT))clause 1 (call): prove(theory-a96ac, system, theory(prologAss,                          C5Theory, IntName,, AssName, AttrName))clause 1 (call): interpretTheory(theory-a96ac,                          C6theory(prologAss, Theory, IntName, AssName, AttrName))clause 1 (exit): interpretTheory(theory-a96ac,                          E6theory(prologAss, theory-a94d8, prologInt, prologAss, none))clause 1 (exit): prove(theory-a96ac, system, theory(prologAss,                          E5theory-a94d8, prologInt, prologAss, none)clause 2 (call): prove(theory-a96ac, prologInt,                          C7interpret(prologAss, theory-a94d8, none,assimilate(theory-a96ac, theory-a82a4, none,assert(fib(-1, 0)), nil, NT))clause 1 (exit): interpretTheory(theory-a94d8,                          E8assimilate(theory-a96ac, theory-a82a4, none,assert(fib(-1,0)), nil, theory-aa12c))clause 2 (exit): prove(theory-a96ac, prologInt,                          E7interpret(prologAss, theory-a94d8, none, assimilate(theory-a96ac, theory-a82a4, none, assert(fib-1, 0)), nil,theory-aa12c))clause 3 (exit): prove(theory-a96ac, prologAss,                          E4assimilate(theory-a96ac, theory-a82a4, none,assert(fib(-1, 0)), nil, theory-aa12c))clause 1 (call): updateSystem(theory-a96ac, fib, theory-a82a4,                          C9theory-aa12c, S7)clause 1 (exit): updateSystem(theory-a96ac, fib, theory-a82a4,                          E9theory-aa12c, theory-aa1f4)clause 1 (exit): myupdate(theory-a96ac, fib, assert(fib(-1,                          E1),nil, theory-aa1f4, theory-aa12c)______________________________________ 
    
     Again on the left hand side is indicated the relevant clause of the &#34;prove&#34; or &#34;update&#34; predicate (the &#34;update&#34; predicate has only one clause) as appropriate and whether the clause is being called or returned. Again the nesting of the calls is shown on the right hand side. 
     The overall goal to be satisfied is attempting to add the clause fib(-1,0) to the procedure fib/2 in the theory named &#34;fib&#34; in the system theory represented by the descriptor &#34;theory --  a92ec&#34;. 
     The succession of &#34;calls&#34; and &#34;exits&#34; achieve this satisfaction by the following process: 
     1) clause 1 of the &#34;update&#34; predicate is invoked (there is only one clause in this procedure). 
     2) clause 1 of the &#34;prove&#34; predicate is invoked in an attempt to locate the theory named &#34;fib&#34; in system theory &#34;theory --  a92ec&#34;. 
     3) a subgoal (interpretTheory) of that clause of &#34;prove&#34; is invoked which exits with its Theory, IntName, AssName, AttrName variables all instantiated to the required terms. 
     4) clause 1 of the &#34;prove&#34; predicate exits successfully. 
     5) now that the assimilator of &#34;fib&#34; is known (prologAss) it is invoked via a call to &#34;prove&#34; to achieve the required update. 
     6) this causes the third clause of &#34;prove&#34; to be invoked in an attempt to find the theory associated with then name &#34;prologAss&#34; and then to attempt satisfaction of the required update. This clause of &#34;prove&#34; has two subgoals which attempt to perform these two tasks. 
     7) the first subgoal invokes &#34;prove&#34; to locate &#34;prologAss&#34;, which in turn invokes &#34;interpretTheory&#34;. &#34;prologAss&#34; is successfully found as well as the name of its interpreter. 
     8) &#34;prove&#34; is further invoked to attempt a satisfaction of the update (assimilation) by proving using &#34;prologAss&#34;&#39;s interpreter (prologInt) that the assimilation is satisfiable. 
     9) this causes the system theory to be searched again for the theory corresponding to the name &#34;prologInt&#34;. 
     10) this is a special case of &#34;prove&#34; since &#34;prologInt&#34; is the built-in interpreter. This case is trapped by the second clause of &#34;prove&#34;. 
     11) the assimilation is successfully completed (the exit of clause 3 of &#34;prove&#34;). 
     12) the final stage is to update the system theory &#34;theory --  a92ec&#34; the one in which all the dereferencing of names has occurred. &#34;updateSystem&#34; is invoked which causes variable S7 to be bound to the updated system theory &#34;theory --  a9d6c&#34;. 
     The result of this satisfaction is that if &#34;fib&#34; is dereferenced in the first system theory &#34;theory --  a92ec&#34;, then the clause &#34;fib(-1,0)&#34; is not part of the procedure fib/2. If it is dereferenced in &#34;theory --  a9d6c&#34; then fib(-1,0) is part of fib/2. 
     The present system extends the declarative Prolog style, as used in individual theories, to the incorporation of an organisation of theory-to-theory relationships. This is in contrast to the prior systems, in which theory-to-theory relationships are implemented in a manner which is more implicit. Each of these types of relationship can be a many-to-many relationship. For example, a given theory can have more than one interpreter. (if this is the case it is necessary to perform inference within the system each time this theory is invoked to determine which interpreter is appropriate at this time--probably on the basis of the goal that has to be proved.) All these relationships are dynamic. Successive versions of a system theory can have existing relationships updated and new relationships added. The relationships do not need to be specified in the system theory as facts; they can equally well be specified in rules of arbitrary complexity. The only fixed relationship is that the system theory&#39;s interpreter is the built-in interpreter. 
     For each theory, the system theory holds a relationship statement between that theory and other theories associated with it; that is, all relationships between theories are explicitly represented in the form of a set of logical statements by the system theory. It is convenient for the relationship statement to define various distinct forms of association or relationship, so that the types of relationship of a theory to other theories are automatically determined; in other words, there are distinct types of relationship between a theory and an interpreter theory, an assimilator theory and an attribute theory. It will however be realised that differences between the various types of relationship are only defined by the structure of the system itself to the extent that each type of relationship has a specific place (first, second, etc) in the relationship statement. The choice of which place is used to give a relationship with an interpreter theory, which with an assimilator theory and which with an attribute theory is arbitrary and to a large extent a matter of interpretation, though of course the choice, once made, must be the same for all theories. 
     As we have seen, the ability to query the system as a theory enables selection of particular entities (such as an interpreter) on the basis of information contained in the query. It also readily supports arbitrary levels of interpretation to be introduced in handling a query--an interpreter is found by querying the system (that is, the system theory), and then this interpreter might be interpreted by another interpreter found by querying the system. 
     The present invention also has advantages concerning the updating of theories. All operations on theories, including updating, are declarative and hence free of side-effects. Every update to a named theory produces a new theory. Since both are part of the system theory, a new system will also result. Hence access to all versions of all theories is potentially possible. The update model used in the present system is completely declarative. This means that any update to (addition to or subtraction from) a theory results in a new theory. Both the new version and the previous version are accessible as long as references to both still exist. This can be achieved with very little overhead cost in time and space by arranging for versions of a theory to share all common data. 
     FIG. 3 depicts the updating of a theory named TN and can be summarised: 
     Update (S 1 , TN, Updates, S 2 , T 2 ) 
     The corresponding statements in the system theories named S1 and S2 are shown below: 
     theory (system, System 1, I, AS, AT) 
     theory (TN, (T 1 ), I, AS, AT) 
     theory(system, System 2, I, AS, AT) 
     theory (TN, (T 2 ) I, AS) 
     The manner in which the relationships between the various theories are held in the present system allows the relationships between the theories and the population of the theories to change with time. For example, it may be desired to investigate the effects of various changes of exchange rate. To this end, a financial theory (not shown) may be constructed which defines the manner in which discounts are determined. A series of queries may be directed to this financial theory and these may cause the setting up of a series of distinct discount theories (not shown), one for each possible exchange rate being considered. The system theory operates to keep track of these different discount theories, which are of course mutually inconsistent. (A simpler example is when a theory is updated; the system then includes the old theory and the new (updated) one). The system then exists in a considerable number of distinct versions, corresponding to the different possible exchange rates being considered or to successive periods of time and the appropriate version has to be selected for any particular query 
     It will be appreciated that the present invention has been described with reference to a particular embodiment in which the system theory has clauses of a five-place predicate defining the organisation of theories in the system. It is possible for different theory organisations to be defined by the system theory in which the system theory has n-place statements defining theory relationships where n is greater than or equal to three i.e. places for the theory name, the theory itself and at least one metatheory. 
     
                                           APPENDIX A__________________________________________________________________________fib.pl loading . . .fib.pl loaded.lemma.pl loading . . .lemma. pl loaded.fibattr loading . . .fibattr loaded.fib.pl loading . . .fib.pl loaded.myprove loading. . .myprove loaded.prologAss.pl loading . . .prologAss.pl loaded.The System Theorytheory(system, Theory, prologInt, prologAss, none) &lt;-system(theory) &amp; true.theory(fib, #fib(0, 1) &lt;- true.fib(1, 1) &lt;- true.fib(N, M3) &lt;-N &gt; 1 &amp;M is N - 1 &amp;M1 is N - 2 &amp;fib(M, FM) &amp;fib(M1, FM1) &amp;M3 is FM + FM1 &amp; true.nil, prologInt, prologAss, none) &lt;- true.theory(lemma, #interpret(TheoryName, Theory, AttrName, Goals) &lt;-call(Theory, Goals) &amp; true.nil, prologInt, prologAss, none) &lt;- true.theory(fibattr, #uniqueSoln(fib(X, .sub.-)) &lt;-ground(X) &amp;! &amp; true.nil, prologInt, prologAss, none) &lt;- true.theory(fibl, #fib(0, 1) &lt;- true.fib(1, 1) &lt;- true.fib(N, M3) &lt;-N &gt; 1 &amp;M is N - 1 &amp;M1 is N - 2 &amp;fib(M, FM) &amp;fib(M1, FM1) &amp;M3 is FM + FM1 &amp; true.nil, lemma, prologAss, fibatttr) &lt;- true.theory(myprove, #myupdate(System, TheoryName, Clauses, NewSystem,NewTheory) &lt;-write(&#39;clause 1 (call): &#39;) &amp;write(update(System, TheoryName, Clauses, NewSystem, NewTheory)) &amp;nl &amp;myprove(System, system, theory(TheoryName, Theory, IntName, AssName,AttrName)) &amp;myprove(System, AssName, assimilate(System, Theory, AttrName, Clauses,NewTheory)) &amp;updatesSystem(System, TheoryName, Theory, NewTheory, NewSystem) &amp;write(&#39;clause 1 (exit): &#39;) &amp;write(update(System, TheoryName, Clauses, NewSystem, NewTheory)) &amp;nl &amp; true.updateSystem(System, TheoryName, Theory, NewTheory, NewSystem) &lt;-write(&#39;clause 1 (call): &#39;) &amp;write(updateSystem(System, TheoryName, Theory, NewTheory, NewSystem)) &amp;nl &amp;update(system, replace(theory(TheoryName, Theory, IntName, AssName,AttrName) &lt;- true,theory(TheoryName, NewTheory, IntName, AssName, AttrName) &lt;- true) . nil,System, NewSystemwrite(&#39;clause 1 (exit): &#39;) &amp;write(updateSystem(System, TheoryName, Theory, NewTheory, NewSystem)) &amp;nl &amp; true.interpretTheory(T, G) &lt;-write(&#39;clause 1 (call): &#39;) &amp;write(interpretTheory(T, G)) &amp;nl &amp;call(T, G) &amp;write(&#39;clause 1(exit): &#39;) &amp;write(interpretTheory(T, G)) &amp;nl &amp; true.myprove(System, system, Goals) &lt;-write(&#39;clause 1 (call): &#39; ) &amp;write(prove(System, system, Goals)) &amp;nl &amp;interpretTheory(System, Goals) &amp;write(&#39;clause 1 (exit): &#39;) &amp;write(prove(System, system, Goals)) &amp;nl &amp; true.myprove(System, prologint, interpret(TheoryName, Theory, AttrName,Goals)) &lt;-write(&#39;clause 2 (call): &#39;) &amp;write(prove(System, prologInt, interpret(TheoryName, Theory, AttrName,Goals))) &amp;nl &amp;interpretTheory(Theory, Goals) &amp;write(&#39;clause 2 (exit): &#39;) &amp;write(prove(System, prologInt, interpret(TheoryName, Theory, AttrName,Goals))) &amp;nl &amp; true.myprove(System, TheoryName, Golas) &lt;-write(&#39;clause 3 (call): &#39;) &amp;write(prove(System, TheoryName, Goals)) &amp;nl &amp;myprove(System, system, theory(TheoryName, Theory, IntName, AssName,AttrName)) &amp;myprove(System, IntName, interpret(TheoryName, Theory, AttrName, Goals))write(&#39;clause 3 (exit): &#39;) &amp;write(prove(System, TheoryName, Goals)) &amp;nl &amp; true.nil, prologInt, prologAss, none) &lt;- true.theory(prologAss, #assimilate(.sub.-, T, .sub.-, nil, T) &lt;- true.assimilate(S, T, .sub.-, assert(C) . Rest, NT) &lt;-normalize(C, NC) &amp;assertz(T, T1, NC) &amp;assimilate(S, T1, .sub.-, Rest, NT) &amp; true.assimilate(S, T, .sub.-, retract(C) . Rest, NT) &lt;-normalize(C, NC) &amp;retract(T, T1, NC) &amp;assimilate(S, T1, .sub.-, Rest, NT) &amp; true.nilprologInt, prologAss, none) &lt;- true.SUCCESSINTERPRET TIME: 640 msINFERENCE STEPS: 243__________________________________________________________________________