
The Ontic Inference Language Carl Roger Witty * B.S., Computer Science Stanford University, 1991 Submitted to the Department of Electrical Engineering and Computer Science in Partial Fulfillment of the Requirements for the Degree of Master of Science in Electrical Engineering and Computer Science at the Massachusetts Institute of Technology June 1995 ®1995 Massachusetts Institute of Technology. All rights reserved. ;A$$A >uSETTSSTIUTE OF1EHNOLOGY Signature of Author JUL1 71995 Barmer Eng Certified by ...... David A. McAllester, Associate Professor n,1 .^ MIT Artificial Intelligence Laboratory Thesis Advisor Accepted by _, Frederic R. Morgenthaler, Chairman, Committee on Graduate Students *This material is based upon work supported under a National Science Foundation Graduate Fellowship. Any opinions, findings, conclusions or recommendations expressed in this publication are those of the author and do not necessarily reflect the views of the National Science Foundation. 1 The Ontic Inference Language by Carl Roger Witty Submitted to the Department of Electrical Engineering and Computer Science on May 12, 1995 in partial fulfillment of the requirements for the Degree of Master of Science in Electrical Engineering and Computer Science. Abstract OIL, the Ontic Inference Language, is a simple bottom-up logic programming lan- guage with equality reasoning. Although intended for use in writing proof verification systems, OIL is an interesting general-purpose programming language. In some cases, very simple OIL programs can achieve an efficiency which requires a much more com- plicated algorithm in a traditional programming language. This thesis gives a formal semantics for OIL and some new results related to its efficient implementation. The main new result is a method of transforming bottom- up logic programs with equality to bottom-up logic programs without equality. An introduction to OIL and several examples are also included. Thesis Supervisor: Dr. David A. McAllester Title: Associate Professor 2 Contents Abstract 2 Table of Contents 3 1 Introduction 5 2 An Informal Presentation of OIL 7 2.1 Some Trivial Examples ..... 2.2 Parsing................ 2.3 Arithmetic............... .. .. .. .. 7....10 2.4 Primality............... ... .. ........ 8....11 2.5 Goldbach's Conjecture ......... 13 2.6 Another Look at Primality ....... ....... 14 2.7 All-Pairs Shortest Paths ........ ...... 14 3 The OIL Programming Language 16 3.1 The Syntax of OIL ........... ....... 16 3.2 An Operational Semantics for OIL .. ........ 18 3.2.1 The Semantics of Simple OIL ........ 19 3.2.2 Equality. ........... ... ......... 21 3.2.3 Removing Equality ..... ....... 23 3.2.4 Bounds ........... .40 3.2.5 The Full OIL Language ...... .40 4 The Power of OIL 41 5 Complexity Results and Optimizations 41 5.1 Complexity for OIL Without Equality or Negated Antecedents 42 5.1.1 Binary Rule Sets ................... 42 5.1.2 The Binary Rule Transform ..... ........ 43 5.1.3 Acyclic Rules .......... ........... 44 5.2 Complexity and Optimizations with Equality ..... .... 46 5.3 Complexity and Optimizations with Negated Antecedents. 47 6 Examples 47 6.1 Binary Arithmetic ...................... 48 6.2 de Bruijn Numbers ...................... 50 6.3 Efficient Object Language .................. 52 7 External Syntax 52 8 Rulesets and Orcfuns 53 9 The Ontic Rule Compiler 60 3 10 Match Algorithms 61 11 Ideas for Further Research 63 Bibliography 64 4 1 Introduction Bottom-up logic programming has received considerable attention in recent years in the database literature because of its ability to concisely represent a wide variety of algorithms [NR91]. Algorithms well suited to such logic program representation include transitive closure, context free parsing, and shortest paths in graphs. Bottom- up interpreters for logic programs cache intermediate results. This makes them well suited for the representation of dynamic programming algorithms. It also makes bottom-up logic programming well suited for implementing inference systems. This thesis describes a method for handling equality in bottom up logic program- ming together with various source to source transformations and implementation tech- niques. Equality is a difficult issue in bottom-up logic programming both because the basic equality axioms generate an infinite number of statements and because equal- ity must be taken into account during the match phase of rule execution. Here we show that equality can be fully handled with a source to source transformation on bottom-up logic programs. The Ontic Inference Language, OIL, is a bottom-up logic programming language with equality reasoning. OIL is also, essentially, a production system like OPS5. OIL can be used as a general-purpose programming language, although the original application, writing inference rules for some kind of inference system, guides several design choices. In some cases, such as context-free parsing, very simple OIL programs can achieve an efficiency which requires a much more complicated algorithm in a traditional programming language. As the name suggests, OIL is designed for use in the Ontic proof verification system [McA]; it is a variant of the language in which Ontic's inference rules are currently written. The existing Ontic low-level inference language has a number of irregularities and special cases which make it difficult to understand and use. Also, the implementation is old, and has grown complex by accretion over the years. OIL is more general and expressive. In [NR91], Naughton and Ramakrishnan describe the Magic Templates transfor- 5 mation, which transforms a pure Prolog program (intended to be evaluated top-down) into an equivalent program which can be evaluated efficiently with bottom-up fixpoint evaluation. They also describe several program transformations which, in conjunction with the Magic Templates algorithm, yield even more efficient programs. Essentially, the transformation gains efficiency by providing full memoing. OIL programs are typ- ically written in a style similar to the results of the Magic Templates transformation; an implementation of OIL could be used as the back end of a system which used Magic Templates. In [GST90], the authors present a method for splitting up parallelizing bottom-up logic programs for distributed memory computers. The method depends on splitting the program so that parts of it execute on different processors, with minimal commu- nication between the processors. Unfortunately, their work is not directly applicable to OIL, because the only known efficient algorithm for implementing OIL depends on a shared data structure, the congruence grammar data structure. OIL is also related to existing work in production systems and logic programming. Production systems are often used to create expert systems. Essentially, a production system [New73] consists of a set of rules (sometimes known as productions; hence the name) and a database encoding the current knowledge of the system (this database is known as the working memory, and the facts in the database are called working memory elements, or WME's). The rules are of the form A 1,... , An/C, where the Ai are the antecedents and C is the conclusion. The antecedents of the rules are patterns which are matched against the WME's. A production system repeatedly finds a rule which can fire (one such that all the antecedents match WME's) and fires it (executes its conclusion). Each possible rule firing (a rule and a sequence of WME's that match the antecedents of the rule) is called an instantiation. Some production systems compute the set of all instantiations (the conflict set) and select one of them. (For instance, the instantiation chosen might be the one added to the conflict set most recently.) The conclusion of a rule may add or delete working memory elements, or it may specify other actions, such as I/O. OPS5 [For81] is one of the best-known languages for writing production systems. It 6 is often used for writing expert systems. Except for its handling of equality, OIL is a particularly simple production system. The only action allowed in the conclusion of an OIL rule is to add a fact to the database. The language of equality-free OIL can be implemented as a simple variant on an existing production system. In fact, it is possible to compile an equality-free OIL program into OPS5 such that the OPS5 program will have only a linear factor more rules firings than the OIL program; the only difficult point in the translation is ensuring fairness of the resulting OPS5 program. As with other production systems, the match process (computing the conflict set) is the performance bottleneck in OIL. Much work has been done on discovering efficient match algorithms for production systems. One of the most popular match algorithms is RETE [For82], which is used in many implementations of OPS5. Another match algorithm called TREAT [Mir90] was developed by Miranker. TREAT was designed for parallel machines, but experiments show that it is more efficient than RETE on serial architectures as well. 2 An Informal Presentation of OIL The basic operation of OIL is to take a set of facts E, a set of rules (a program) R, and a fact I, and report whether · can be deduced from E by R. Equality reasoning is built into OIL. 2.1 Some Trivial Examples Here are some examples of simple OIL programs. The simplest program is the empty program, R = 0. Suppose that R = 0 and E = 0. The only facts which can be deduced in this case are the reflexive equality facts, such as =(f(g(a)),f(g(a))). Suppose , contains the facts =(a, b) and p(a). From this, it is possible to deduce facts such as P(b) and =(f(a, b), f (b, a)). 7 Now consider a simple OIL program, which consists of a single rule: =(f(x), g(x))/ special(x). This says that for any x, if f(x) is known to be equal to g(x), then x is special. For instance, if E contains =(f(a),g(a)), then we can deduce that a is special (special(a)).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages64 Page
-
File Size-