2 00 0 A Compiler for Ordered Logic Programs ∗

This paper describes a system, called PLP, for compiling ordered logic programs into standard logic programs under the answer set semantics. In an ordered logic program, preference information is expressed at the object level by atoms of the form s ≺ t, where s and t are names of rules. An ordered logic program is transformed into a second, regular, extended logic program wherein the preferences are respected, in that the answer sets obtained in the transformed theory correspond with the preferred answer sets of the original theory. Since the result of the translation is an extended logic program, existing logic programming systems can be used as underlying reasoning engine. In particular, PLP is conceived as a front-end to the logic programming systems dlv and smodels. General Information Several approaches have been introduced in recent years undertaking the ability to express preference information within declarative knowledge representation formalisms (Baader & Hollunder 1993; Brewka 1994; Brewka 1996; Gelfond & Son 1997; Zhang & Foo 1997; Brewka & Eiter 1999). However, most of these methods treat preferences at the meta-level and require a change of the underlying semantics. For instance, incorporating explicit orderings of logic programming rules is realized by modifying the fixed-point conditions characterizing answer sets or well-founded consequences. As a result, implementations need in general fresh algorithms and cannot rely on existing systems computing the regular (unordered) formalisms. In this paper, we describe a compiler, PLP, for preferred answer sets which evades the need of new algorithms. PLP is based on an approach for expressing preference information within the framework of standard answer set semantics. The general technique is described in (Delgrande, Schaub, & Tompits 2000) and derives from a methodology for addressing preferences in default logic first proposed in (Delgrande & Schaub 1997). We begin with an ordered logic program, which is an extended logic program in which rules are named by ∗This work was partially supported by the Austrian Science Fund Project N Z29-INF. unique terms and in which preferences among rules are given by a new set of atoms of the form s ≺ t, where s and t are names. Such an ordered logic program is then transformed into a second, regular, extended logic program wherein the preferences are respected, in the sense that the answer sets obtained in the transformed theory correspond to the preferred answer sets of the original theory. The approach is sufficiently general to allow the specification of preferences among preferences, preferences holding in a particular context, and preferences holding by default. PLP has been implemented in Prolog and serves as a front-end for the logic programming systems dlv (Eiter et al. 1997) and smodels (Niemelä & Simons 1997); it has been developed under the ECLiPSe Constraint Logic Programming System and comprises roughly 300 lines of code. It runs under any operating systems for which dlv or smodels are executable, provided ECLiPSe Prolog is available. Apart from the prettyprinter, we only employ standard Prolog programming constructs. Description of the System The logic programming systems dlv and smodels represent state-of-the-art implementations of the stable model semantics (Gelfond & Lifschitz 1988), the former system also admitting strong negation and disjunctive rules. As well, several front-ends for these systems have been developed with the purpose of providing direct encodings of advanced reasoning problems, like, e.g., diagnostic reasoning or planning (Eiter et al. 1999; Eiter et al. 2000). PLP realizes a further front-end for these systems, handling ordered logic programs. The structure of PLP is divided into five files: • The actual compiler is contained in the file pref.pl (or prefx.pl, where x is the actual version number). • The file grounder.pl takes care of programs with variables and non-atomic term structures. • The file pp.pl provides a pretty-printer for the files resulting from the compilation. (This module relies on features of ECLiPSe for transforming Prolog’s variables like 4711 into more readable ones like X. This is necessary in view of processing the files with dlv and smodels.) • The files dlv.pl and smodels.pl contain code specific to the respective logic programming systems. The general function of PLP works in three stages: 1. loading the compiler (which charges also the Prolog files pp.pl, grounder.pl, dlv.pl, and smodels.pl); 2. compiling the original Prolog file (the compiler is pretty verbose and displays also intermediate versions of the compiled program); 3. call of dlv or smodels. The present version of PLP is written for the following releases of dlv and smodels: dlv : release from November 24, 1999. smodels : version 1.12, including parse-1.3. Adaptions for lparse and pparse (and thus smodels-2) are under development. The current prototype of PLP can be found at the following URL: http://www.cs. uni-potsdam.de/~torsten/plp/.