Browsing by Subject "Lambda Prolog"
Now showing 1 - 1 of 1
- Results Per Page
- Sort Options
Item An implementation of the language lambda Prolog organized around higher-order pattern unification.(2009-10) Qi, XiaochuThe automation of meta-theoretic aspects of formal systems typically requires the treatment of syntactically complex objects. Thus, programs must be represented and manipulated by program development systems, mathematical expressions by computer-based algebraic systems, and logic formulas and proofs by automatic proof systems and proof assistants. The notion of bound variables plays an important role in the structures of such syntactic objects, and should therefore be reflected in their representations and properly accounted for in their manipulation. The λ-calculus was designed specifically to treat binding in a logically precise way and the terms of such a calculus turn out to be an especially suitable representational device for the application tasks of interest. Moreover, the equality relation associated with these terms and the accompanying notion of higher-order unification leads to a convenient means for analyzing and decomposing these representations in a way that respects the binding structure inherent in the formal objects. This thesis concerns the language λProlog that has been designed to provide support for the kinds of meta-programming tasks discussed above. In its essence, λProlog is a logic programming language that builds on a conventional language like Prolog by using typed λ-terms instead of first-order terms as data structures, by using higher-order unification rather than first-order unification to manipulate these data structures and by including new devices for restricting the scopes of names and of code and thereby providing the basis for realizing recursion over binding constructs. These features make λProlog a convenient programming vehicle in the domain of interest. However, they also raise significant implementation questions that must be addressed adequately if the language is to be an effective tool in these contexts. It is this task that is undertaken in this thesis. An efficient implementation of λProlog can potentially exploit the processing structure that has been previously designed for realizing Prolog. In this context, the main new issue to be treated becomes that of higher order unification. This computation has characteristics that make it difficult to embed it effectively within a low-level implementation: higher-order unification is in general undecidable, it does not admit a notion of most general unifiers and a branching search is involved in the task of looking for unifiers. However, a sub-class of this computation that is referred to as L λ or higher-order pattern unification has been discovered that is substantially better behaved: in particular, for this class, unification is decidable, most general unifiers exist and a deterministic unification procedure can be provided. This class is also interesting from a programming point-of-view: most natural computations carried out using λProlog fall within it. Finally, a treatment of full higher-order unification within the context of λProlog can be realized by solving only higher-order pattern unification problems at intermediate stages, delaying any branching and possibly costly search to the end of the computation. This thesis examines the use of the strategy described above in providing an implementation of λProlog. In particular, it develops a new virtual machine and compilation based scheme for the language by embedding a higher-order pattern unification algorithm due to Nadathur and Linnell within the well-known Warren Abstract Machine model for Prolog. In executing this idea, it exposes and treats various auxiliary issues such as the low-level representation of λ-terms, the implementation of reduction on such terms, the optimized processing of types in computation and the representation of unification problems whose solution must be deferred till a later point in computation. Another important component of this thesis is the development of an actual implementation of λProlog --called Teyjus Version 2 --that is based on the conceptual design that is presented. This system contains an emulator for the virtual machine that is written in the C language for efficiency and a compiler that is written in the OCaml language so as to enhance readability and extensibility. This mix of languages within one system raises interesting software issues that are handled. Portability across architectures for the emulator is also treated by developing a modular mapping from term representation to actual machine structures. A final contribution of the thesis is an assessment of the efficacy of the various design ideas through experiments carried out with the assistance of the system.