Stepping through an Answer-Set Program ? Johannes Oetsch, J ¨ org P¨ uhrer, and Hans Tompits Technische Universit¨ at Wien, Institut f¨ ur Informationssysteme 184/3, Favoritenstraße 9-11, A-1040 Vienna, Austria {oetsch,puehrer,tompits}@kr.tuwien.ac.at Abstract. We introduce a framework for interactive stepping through an answer- set program as a means for debugging. In procedural languages, stepping is a widespread and effective debugging strategy. The idea is to gain insight into the behaviour of a program by executing statement by statement, following the pro- gram’s control flow. Stepping has not been considered for answer-set programs so far, presumably because of their lack of a control flow. The framework we provide allows for stepwise constructing interpretations following the user’s intuition on which rule instances to become active. That is, we do not impose any ordering on the rules but give the programmer the freedom to guide the stepping process. Due to simple syntactic restrictions, each step results in a state that guarantees stability of the intermediate interpretation. We present how stepping can be started from breakpoints as in conventional programming and discuss how the approach can be used for debugging using a running example. Keywords: answer-set programming, program analysis, debugging 1 Introduction Answer-set programming (ASP) is a well-established paradigm for declarative problem solving [1], yet it is rarely used by engineers outside academia so far. Arguably, one particular obstacle preventing software engineers from using ASP is the lack of support tools for developing answer-set programs. In this paper, we introduce a framework that allows for stepping through answer-set programs. Step-by-step execution of a program is folklore in procedural programming languages, where developers can debug and investigate the behaviour of their programs in an incremental way. As answer-set programs have a genuine declarative semantics lacking any control flow, it is not obvious how stepping can be realised. Our approach makes use of a simple computation model that is based on states, which are ground rules that a user considers as active in a program. With each state, we associate the interpretation that is induced by the respective rules. This interpretation is guaranteed to be an answer set of the set of rules considered in the state. During the course of stepping, the interpretations of the subsequent states evolve towards an answer set of the overall program. Our stepping approach is interactive and incremental, letting the programmer choose which rules are added at each step. In our framework, states may ? This work was partially supported by the Austrian Science Fund (FWF) under project P21698 and by the European Commission under project IST-2009-231875 (OntoRule).