Answer Set Programming, or ASP for short, has become a popular and sophisticated approachto declarative problem solving. Its popularity is due to its attractive modeling-grounding-solvingworkflow that provides an easy approach to problem solving, even for laypersons outside computerscience. However, in contrast to ASP’s ease of use, the high degree of sophistication ofthe underlying technology makes it even hard for ASP experts to put ideas into practice wheneverthis involves modifying ASP’s machinery. For addressing this issue, this tutorial aims atenabling users to build their own ASP-based systems. More precisely, we show how the ASPsystem clingo can be used for extending ASP and for implementing customized special-purposesystems. To this end, we propose two alternatives. We begin with a traditional AI technique andshow how metaprogramming can be used for extending ASP. This is a rather light approachthat relies on clingo’s reification feature to use ASP itself for expressing new functionalities. Thesecond part of this tutorial uses traditional programming (in Python) for manipulating clingovia its application programming interface. This approach allows for changing and controllingthe entire model-ground-solve workflow of ASP. Central to this is clingo’s new Applicationclass that allows us to draw on clingo’s infrastructure by customizing processes similar to theone in clingo. For instance, we may apply manipulations to programs’ abstract syntax trees,control various forms of multi-shot solving, and set up theory propagators for foreign inferences.A cross-sectional structure, spanning meta as well as application programming, is clingo’s intermediateformat, aspif, that specifies the interface among the underlying grounder and solver.We illustrate the aforementioned concepts and techniques throughout this tutorial by means ofexamples and several nontrivial case studies. In particular, we show how clingo can be extendedby difference constraints and how guess-and-check programming can be implemented with bothmeta and application programming.
展开▼