1 Computation with Logic as Operator Elimination
We pursue an approach to computation with logic emerging from three theses:
Like the standard logic operators, secondorder operators can be defined semantically, by specifying the requirements on an interpretation to be a model of a formula whose principal functor is the operator, depending only on semantic properties of the argument formulas. Neither control structure imposed over formulas (e.g. Prolog), nor formula transformations depending on a particular syntactic shape (e.g. Clark’s completion) are involved. Compared to classical firstorder formulas, the secondorder operators give additional expressive power. Circumscription is a prominent knowledge representation technique that can be expressed with secondorder operators, in particular predicate quantifiers [1].
Elimination is a way to computationally process secondorder operators, for example Boolean quantifiers with respect to propositional logic: The input is a formula which may contain the operator, for example a quantified Boolean formula such as . The output is a formula that is equivalent to the input, but in which the operator does not occur, such as, with respect to the formula above, the propositional formula
. Let us assume that the method used to eliminate the Boolean quantifiers returns formulas in which not just the quantifiers but also the quantified propositional variables do not occur. This syntactic condition is usually met by elimination procedures. Our method then subsumes a variety of tasks: Computation of uniform interpolants, QBF and SAT solving, as well as computation of certain forms of abductive explanations, of propositional circumscription, and of stable models, as will be outlined below.
If results of elimination are formulas characterized just up to semantics, they may contain redundancies and be in a shape that is difficult to comprehend. Thus, they should be subjected to simplification and canonization procedures before passed to humans or machine clients. The output format depends on the application problem: What is a CNF of the formula? Are certain facts consequences of the formula? What are the models of the formula? What are its minimal models? What are its 3valued models with respect to some encoding into 2valued logics? Corresponding answers can be computed on the basis of normal form representations of the elimination outputs: CNFs, DNFs, and full DNFs. Of course, transformation into such normal forms might by itself be an expensive task. Secondorder operators allow to counter this by specifying a small set of application relevant symbols that should be included in the output (e.g. by Boolean quantification upon the irrelevant atoms).
2 Features of the System
ToyElim^{1}^{1}1http://cs.christophwernhard.com/provers/toyelim/, under GNU Public License. is a prototype system developed to investigate operator elimination from a pragmatic point of view with small applications. For simplicity, it is based on propositional logic, although its characteristic features should transfer to firstorder logic. It supports a set of secondorder operators that have been semantically defined in [11, 14, 13].
Formula Syntax.
As the system is implemented in Prolog, formulas are represented by Prolog terms, the standard connectives corresponding to true/0, false/0, ~/1, ,/2, ;/2, >/2, </2, <>/2. Propositional atoms are represented by Prolog atoms or compound ground terms. The system supports propositional expansion with respect to finite domains of formulas containing firstorder quantifiers.
Forgetting.
Existential Boolean quantification can be expressed as forgetting [11, 4] in formula about atom , written , represented by forg([p], ) in system syntax, where is the system representation of . To get an intuition of forgetting, consider the equivalence , where () denotes with all occurrences of replaced by (). Rewriting with this equivalence constitutes a naive method for eliminating the forgetting operator. The formula can be said to express the same as about all other atoms than , but nothing about .
Elimination and Pretty Printing of Formulas.
The central operation of the ToyElim system, elimination of secondorder operators, is performed by the predicate elim(F,G), with input formula and output formula . For example, define as extension of kb1/1 a formula (after [3]) as follows:
kb1(((shoes_are_wet < grass_is_wet), 
(grass_is_wet < rained_last_night), 
(grass_is_wet < sprinkler_was_on))). 
(1)
After consulting this, we can execute the following query on the Prolog toplevel:
? kb1(F), elim(forg([grass_is_wet], F), G), ppr(G). 
(2)
This results in binding G to the output of eliminating the forgetting about grass_is_wet. The predicate ppr/1 is one of several provided predicates for converting formulas into application adequate shapes. It prints its argument as CNF with clauses written as reverse implications:
((shoes_are_wet < rained_last_night), 
(shoes_are_wet < sprinkler_was_on)). 
(3)
Scopes.
So far, the first argument of forgetting has been a singleton set. More generally, it can be an arbitrary set of atoms, corresponding to nested existential quantification. Even more generally, also polarity can be considered: Forgetting can, for example, be applied only to those occurrences of an atom which have negative polarity in a NNF formula. This can be expressed by literals with explicitly written sign in the first argument of the forgetting operator. Forgetting about an atom is equivalent to nested forgetting about the positive and the negative literal with that atom. In accord with this observation, we technically consider the first argument of forgetting always as a set of literals, and regard an unsigned atom there as a shorthand representing both of its literals. For example, [+grass_is_wet, shoes_are_wet] is a shorthand for [+grass_is_wet, +shoes_are_wet, shoes_are_wet]. Not just forgetting, but, as shown below, also other secondorder operators have a set of literals as parameter. Hence, we refer to a set of literals in this context by a special name, as scope.
Projection.
In many applications it is useful to make explicit not the scope that is ‘‘forgotten’’ about, but what is preserved. The projection [11] of formula onto scope , which can be defined for scopes and formulas as , where denotes the set of all literals, serves this purpose. Vice versa, forgetting could be defined in terms of projection: The call to elim/2 in the query (2) can equivalently be expressed with projection instead of forgetting by
elim(proj([shoes_are_wet, rained_last_night, sprinkler_was_on], F). 
(4)
User Defined Logic Operators – An Example of Abduction.
ToyElim allows the user to specify macros for use in the input formulas of elim/2. The following example extends the system by a logic operator gwsc for a variant of the weakest necessary condition [8], characterized in terms of projection:
: define_elim_macro(gwsc(S, F, G), ~proj(complements(S), (F, ~G))). 
(5)
Here complements(S) specifies the set of the literal complements of the members of the scope specified by S. The term gwsc(S, F, G) is the system syntax for , the globally weakest sufficient condition of formula on scope within formula , which satisfies the following: A formula is equivalent to if and only if it holds that (1.) ; (2.) ; (3.) For all formulas such that and it holds that . With the gwsc operator certain abductive tasks [3] can be expressed. The following query, for example, yields abductive explanations for shoes_are_wet in terms of rained_last_night, sprinkler_was_on with respect to the knowledge base (2):
? kb1(F), 
elim(gwsc([rained_last_night, sprinkler_was_on], F, shoes_are_wet), 
G), 
ppm(G). 
(6)
The predicate ppm/1 serves, like ppr/1, to convert formulas to application adequate shape. It writes a DNF of its input, in list notation, and simplified such that it does not contain tautologies and subsumed clauses. In the example the output has two clauses, each representing an alternate explanation:
[[rained_last_night],[sprinkler_was_on]]. 
(7)
ScopeDetermined Circumscription.
A further secondorder operator supported by ToyElim is scopedetermined circumscription [14]. The corresponding functor circ has, like proj and forg, a scope specifier and a formula as arguments. It allows to express parallel predicate circumscription with varied predicates [5] (only propositional, since the system is based on propositional logic). The scope specifier controls the effect of circumscription: Atoms that occur just in a positive literal in the scope are minimized; symmetrically, atoms that occur just negatively are maximized; atoms that occur in both polarities are fixed; and atoms that do not at all occur in the scope are allowed to vary. For example, the scope specifier, [+abnormal, bird], a shorthand for [+abnormal, +bird, bird], expresses that abnormal is minimized, bird is fixed, and all other predicates are varied.
Predicate Groups and Systematic Renaming.
Semantics for knowledge representation sometimes involve what might be described as handling different occurrences of a predicate differently  for example depending on whether it is subject to negation as failure. If such semantics are to be modeled with classical logic, then these occurrences can be identified by using distinguished predicates, which are equated with the original ones when required. To this end, ToyElim supports the handling of predicate groups: The idea is that each predicate actually is represented by several corresponding predicates , where the superscripted index is called predicate group. In the system syntax, the predicate group of an atom is represented within its main functor: If the group is larger than , the main functor is suffixed by the group number; if it is , the main functor does not end in a number. For example and are represented by p(a) and p1(a), respectively. In scope specifiers, a number is used as shorthand for the set of all literals whose atom is from the indicated group, and a number in a sign functor for the set of those literals which have that sign and whose atom is from the indicated group. For example, [+(0), 1] denotes the union of the set of all positive literals whose atom is from group 0 and of the set of all literals whose atom is from group 1. Systematic renaming of all atoms in a formula that have a specific group to their correspondents from another group can be expressed in terms of forgetting [13]. The ToyElim system provides the secondorder operator rename for this. For example, rename([10], ) is equivalent to after eliminating secondorder operators, followed by replacing all atoms from group 1 with their correspondents from group 0.
An Example of Modeling a Logic Programming Semantics.
Scopedetermined circumscription and predicate groups can be used to express the characterization of the stable models semantics in terms of circumscription [7] (described also in [6, 13]). Consider the following knowledge base:
kb2(((shoes_are_wet < grass_is_wet), 
(grass_is_wet < sprinkler_was_on, ~sprinkler_was_abnormal1), 
sprinkler_was_on)). 
(8)
Group 1 is used here to indicate atoms that are subject to negation as failure: All atoms in (2) are from group 0, except for sprinkler_was_abnormal1, which is from 1. The user defined operator stable renders the stable models semantics:
: define_elim_macro(stable(F), rename([10], circ([+(0),1], F))). 
(9)
The following query then yields the stable models:
: kb2(F), elim(stable((F)), G), ppm(G). 
(10)
The result is displayed with ppm/1, as in query (2). It shows here a DNF with a single clause, representing a single model. The positive members of the clause constitute the answer set
[[grass_is_wet, shoes_are_wet, ~sprinkler_was_abnormal, sprinkler_was_on]]. 
(11)
If it is only of interest whether shoes_are_wet is a consequence of the knowledge base under stable models semantics, projection can be applied to obtain a smaller result. The query
: kb2(F), elim(proj([shoes_are_wet], stable(F)), G), ppm(G). 
(12)
will effect that the DNF [[shoes_are_wet]] is printed.
3 Implementation
The ToyElim system is implemented in SWIProlog and can invoke external systems such as SAT and QBF solvers. It runs embedded in the Prolog environment, allowing for example to pass intermediate results between its components through Prolog variables, as exemplified by the queries shown above.
The implementation of the core predicate elim/2 maintains a formula which is gradually rewritten until it contains no more secondorder operators. It is initialized with the input formula, preprocessed such that only two primitively supported secondorder operators remain: forgetting and renaming. It then proceeds in a loop where alternately equivalence preserving simplifying rewritings are applied, and a subformula is picked and handed over for elimination to a specialized procedure. The simplifying rewritings include distribution of forgetting over subformulas and elimination steps that can be performed with low cost [12]. Rewriting of subformulas with the Shannon expansion enables lowcost elimination steps. It is performed at this stage if the expansion, combined with lowcost elimination steps and simplifications, does not lead to an increase of the formula size. The subformula for handing over to a specialized method is picked with the following priority: First, an application of forgetting upon the whole signature of a propositional argument, which can be reduced by a SAT solver to either or , is searched. Second, a subformula that can be reduced analogously by a QBF solver, and finally a subformula which properly requires elimination of forgetting. For the latter, ToyElim schedules a portfolio of different methods, where currently two algorithmic approaches are supported: Resolvent generation (SCAN, DavisPutnam method) and rewriting of subformulas with the Shannon expansion [10, 12]. Recent SAT preprocessors partially perform variable elimination by resolvent generation. Coprocessor [9] is such a preprocessor that is configurable such that it can be invoked by ToyElim for the purpose of performing the elimination of forgetting.
4 Conclusion
We have seen a prototype system for computation with logic as elimination of secondorder operators. The system helped to concretize requirements on the user interface and on processing methods of systems which are entailed by that approach. In the long run, such a system should be based on more expressive logics than propositional logic. ToyElim is just a first pragmatic attempt, taking advantage of recent advances in SAT solving. A major difference in a firstorder setting is that computations of elimination tasks then inherently do not terminate for all inputs.
A general system should for special subtasks not behave worse than systems specialized for these. This can be achieved by identifying such subtasks, or by general methods that implicitly operate like the specialized ones. ToyElim identifies SAT and QBF subtasks. It is a challenge to extend this range, for example, such that the encoded stable model computation would be performed efficiently. The system picks in each round a single subtask that is passed to a specialized solver. We plan to experiment with a more flexible regime, where different subtasks are alternately tried with increasing timeouts.
Research on the improvement of elimination methods includes further consideration of techniques from SAT preprocessors, investigation of tableau and DPLLlike techniques [12, 2], and, in the context of firstorder logic, the so called direct methods [1]. In addition, it seems worth to investigate further types of output: incremental construction, like enumeration of model representations, and representations of proofs.
The approach of computation with logic by elimination leads to a system that provides a uniform user interface covering many tasks, like satisfiability checking, computation of abductive explanations and computation of models for various logic programming semantics. Variants of established concepts can be easily expressed on a clean semantic basis and made operational. The approach supports the coexistence of different knowledge representation techniques in a single system, backed by a single classical semantic framework. This seems a necessary precondition for logic libraries that accumulate knowledge independently of some particular application.
References
 [1] D. M. Gabbay, R. A. Schmidt, and A. Szałas. SecondOrder Quantifier Elimination: Foundations, Computational Aspects and Applications. College Publications, 2008.
 [2] J. Huang and A. Darwiche. DPLL with a trace: From SAT to knowledge compilation. In IJCAI05, pages 156162. Morgan Kaufmann, 2005.
 [3] A. C. Kakas, R. A. Kowalski, and F. Toni. Abductive logic programming. Journal of Logic and Computation, 2(6):719770, 1993.

[4]
J. Lang, P. Liberatore, and P. Marquis.
Propositional independence  formulavariable independence and
forgetting.
Journal of Artificial Intelligence Research
, 18:391443, 2003.  [5] V. Lifschitz. Circumscription. In D. M. Gabbay, C. J. Hogger, and J. A. Robinson, editors, Handbook of Logic in Artificial Intelligence and Logic Programming, volume 3, pages 298352. Oxford University Press, 1994.
 [6] V. Lifschitz. Twelve definitions of a stable model. In ICLP 2008, volume 5366 of LNCS, pages 3751. Springer, 2008.
 [7] F. Lin. A Study of Nonmonotonic Reasoning. PhD thesis, Stanford University, 1991.
 [8] F. Lin. On strongest necessary and weakest sufficient conditions. Artificial Intelligence, 128:143159, 2001.
 [9] N. Manthey. Coprocessor  a standalone SAT preprocessor. In WLP 2011, 2011. (This volume).
 [10] N. V. Murray and E. Rosenthal. Tableaux, path dissolution and decomposable negation normal form for knowledge compilation. In TABLEAUX 2003, volume 2796 of LNAI, pages 165180. Springer, 2003.
 [11] C. Wernhard. Literal projection for firstorder logic. In JELIA 08, volume 5293 of LNAI, pages 389402. Springer, 2008.
 [12] C. Wernhard. Tableaux for projection computation and knowledge compilation. In TABLEAUX 2009, volume 5607 of LNAI, pages 325340. Springer, 2009.
 [13] C. Wernhard. Circumscription and projection as primitives of logic programming. In Tech. Comm. of the ICLP 2010, volume 7 of LIPIcs, pages 202211, 2010.
 [14] C. Wernhard. Literal projection and circumscription. In FTP’09, volume 556 of CEUR Workshop Proceedings, pages 6074. CEURWS.org, 2010.
Comments
There are no comments yet.