A Functional Approach to Finding Answer Sets

A Functional Approach to Finding Answer Sets

A Functional Approach to Finding Answer Sets Bryant Nelson, Josh Archer, and Nelson Rushton Texas Tech Dept. of Computer Science (bryant.nelson | josh.archer | nelson.rushton) @ ttu.edu Texas Tech University Department of Computer Science Box 43104 Lubbock, TX 79409-3104 we have been convinced of Hughes’ hypothesis. We set out to further test this Submitted to FCS 2013 hypothesis by encoding an Answer Set Solver in SequenceL. We hypothesize that Keywords: Functional Programming, a functional language would allow the Answer Set Prolog, Logic Programming programmer to implement an Answer Set Solver more quickly than a procedural Abstract: A naive answer set solver was language, and that the resulting program implemented in the functional programming would be more readable and language SequenceL, and its performance understandable. compared to mainstream solvers on a set of standard benchmark problems. Finding answer sets is an NP-Complete Implementation was very rapid (25 person problem, and over the last few decades a hours) and the resulting program only 400 few solvers have been developed that lines of code. Nonetheless, the algorithm tackle this problem. The current juggernauts was tractable and obtained parallel in this area are the DLV, CLASP, and speedups. Performance, though not SMODELS solvers, all of which are very pathologically poor, was considerably efficient. The problem would seem to benefit slower (around 20x) than that of mainstream from a parallelized solver, yet CLASP only solvers (CLASP, Smodels, and DLV) on all has a branch (CLASPar) dedicated to this, but one benchmark problem. and DLV has been “experimenting” with parallelization in their grounder [DLVPar]. 1. Introduction Moreover, all of the competitive solvers are written in C/C++ and span over hundreds of In his 1990 paper “Why Functional large files. Programming Matters”, John Hughes argues that functional programming allows SequenceL is a high-abstraction, auto- for an improvement in productivity due to parallelizing, functional language. It is auto- improved modularity. Through the encoding parallelizing in the sense that programs, of the solutions to many non-trivial problems written in a high-level, declarative language without concern for command execution, preliminary research, never been applied to are then compiled into optimized multicore this problem. Upon initial observations it C++. This abstraction frees the programmer was obvious that a simple answer set from the burden of manually implementing a solving algorithm could be easily expressed parallel solution and allows them to focus on declaratively. It was also apparent that this solving the problem at hand. declarative implementation would also be considerably easier to read than a SequenceL also appears to be very easy to procedural implementation. read, even to those who have never programmed in SequenceL. By easy to read The methods of programming declaratively we mean that given a sufficient level of effectively involve envisioning what a understanding of the language’s syntax, the solution to a problem looks like, formally relationship between the syntax and specifying this solution, and directly semantics of statements is obvious enough . implementing it. Therefore, if a solution to a The designers of SequenceL had simplicity problem (especially one that is in mind when developing the groundwork for computationally substantial) is already the language. They aimed to accomplish stated precisely, then encoding the this by the “ruthless pursuit of utmost declarative attempt at said solution appears simplicity” with respect to the language’s to be easier than doing so procedurally. It complexity. appeared that this was the case with the algorithm chosen for finding answer sets: SequenceL was chosen as the the algorithm [Gelfond 2013] was proven, implementation language in order to, in stated at least partially as definitions rather addition to the above, explore the effect of than algorithms, and modular enough to suit auto-parallelizations on a naturally a vision for a functionally written program. parallelizable problem. Even before work began to write this solver, We hypothesized that a naïve functional around the time we had looked at enough ASP Solver could be developed more existing procedural solutions to intelligently quickly, and be more readable than a speak about them, we had the hypothesis procedural implementation of the same. We that a declarative solver would be easier to also hypothesized that automatic read when compared to the existing ones. parallelizations would allow the solver to From the use of SequenceL to solve other perform within an acceptable range of time common problems, and by observing the requirements for some problems. massive size of the CLASP code, it was apparent that SequenceL implementation would exemplify the readability of a 2. Motivation declarative approach. The problem of finding answer sets of non- Our literature survey revealed not a lot of disjunctive Answer Set Programs is an area work has been done on parallelization of that has had substantial research over the Answer Set Program solving. The only past few decades. The declarative parallel solver found was CLASPAR, programming paradigm had, based on created by the same people behind CLASP. This solver used a master-slave based solver . Future work is planned for exploring approach where the master would a system which intelligently grounds atoms determine which sub-processes the slaves as needed, as opposed to grounding would handle in a very procedural way. It everything as most solvers currently do. was apparent that a great deal more thought went into the parallelization of the After exploring the other two options, it was algorithm than the solution itself. decided to use the simplest algorithm possible, short of brute force guessing and All of these points led to experimenting with checking, which was the algorithm found in implementing an Answer Set Program [Gelfond 2013]. This algorithm is completely solving algorithm in SequenceL, an auto- naive -- that is, it does nothing but find the parallelizing high-level declarative answer set of a grounded Answer Set programming language. Programs with zero heuristics and with nothing more than the direct definition of Answer Set Programs. This algorithm had a 3. Methods proof of correctness, and was readily available for encoding. Algorithm Selection The choice of algorithm was based on the Algorithm Implementation criteria of simplicity, verifiability, and The algorithm chosen is both sound and availability. An initial attempt was made to complete with respect to the domain, but look at the algorithm that the current non- parts of it were presented in different ways. parallel version of CLASP encoded; this Moreover, there were two major methods was done in an effort to create the best with which the pieces were described: “apples-to-apples” comparison with a top effective definitions and sequential solver. However, after a moderate amount algorithms . of effort the actual algorithm could not be found and it was impossible to easily A sequential algorithm is one that lists a decipher what it was from just looking at the sequence of instructions that need to be available source code. This was due to two executed in order to compute the desired major issues; the first was the sheer size of result; this is the description of most the program [insert actual size of the one commercial implementations. An effective we got], and the second was the fact that, in definition is a mathematical definition that general, it is difficult to discern the algorithm implicitly embodies an algorithm for from procedurally written code. computing the function it defines. For example; if we define as the Initially, the idea of going with the DLV route largest integer which is a divisor of m and a of solving answer sets was considered, but divisor of n, then this definition is not it was decided against because that would effective. On the other hand if is involve creating a grounder and integrating defined as the largest integer in the closed it with the solver. It was decided that the interval [1, m] which is a divisor of m and a grounding would be done by GRINGO. divisor of n, then the definition is effective Once again, this was chosen to create an because the search has been limited to a “apples-to-apples” comparison with the finite space A SequenceL program is essentially a set of effective definitions. In the following example are two function specifications; the first ( Least ) is defined algorithmically, whereas the second ( IsAnswerSet ) is specified mostly by definitions. If the specification can be mathematically proven to be correct, then the SequenceL code is as well by default. Effective Definition vs. Algorithm The following is an illustration of the difference between the definitional and Again, Least was specified algorithmically, algorithmic styles mentioned above; the and as such there was a bit of translation Reduct is a well-known and integral concept needed in order to encode this correctly in for finding answer sets of programs, and it is SequenceL. The effort needed in showing defined with what appears to be a very correctness of the encoded Least lies not in procedural mindset. checking whether the translated description entails the SequenceL code (because this is obvious ), but rather ensuring that the translation of the algorithmic description into a definition is correct. It is easy to see that this Reduct is computed by performing these steps as specified, and in sequential order. This does not affect the nature of the result yielded; but it is stated procedurally. Compare this with the following equivalent specification: The ease with which the function IsAnswerSet was written was indispensable in the creation of this solver. As mentioned above, the actual translation from the specification into a definition is the bulk of the work; here that is already done and therefore the SequenceL encoding this is obviously correct. Here, the Reduct clearly is something, namely the items satisfying (1) .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us