Hostname: page-component-77f85d65b8-g98kq Total loading time: 0 Render date: 2026-03-29T02:48:40.806Z Has data issue: false hasContentIssue false

IASCAR: Incremental Answer Set Counting by Anytime Refinement

Published online by Cambridge University Press:  21 February 2024

JOHANNES K. FICHTE
Affiliation:
Department of Computer Science (IDA), Linköping University, Linköping, Sweden (e-mail: johannes.fichte@liu.se)
SARAH ALICE GAGGL
Affiliation:
TU Dresden, Dresden, Germany (e-mail: sarah.gaggl@tu-dresden.de)
MARKUS HECHER
Affiliation:
Massachusetts Institute of Technology, Cambridge, MA 02139, USA (e-mail: hecher@mit.edu)
DOMINIK RUSOVAC
Affiliation:
TU Dresden, Dresden, Germany (e-mail: dominik.rusovac@tu-dresden.de)
Rights & Permissions [Opens in a new window]

Abstract

Answer set programming (ASP) is a popular declarative programming paradigm with various applications. Programs can easily have many answer sets that cannot be enumerated in practice, but counting still allows quantifying solution spaces. If one counts under assumptions on literals, one obtains a tool to comprehend parts of the solution space, so-called answer set navigation. However, navigating through parts of the solution space requires counting many times, which is expensive in theory. Knowledge compilation compiles instances into representations on which counting works in polynomial time. However, these techniques exist only for conjunctive normal form (CNF) formulas, and compiling ASP programs into CNF formulas can introduce an exponential overhead. This paper introduces a technique to iteratively count answer sets under assumptions on knowledge compilations of CNFs that encode supported models. Our anytime technique uses the inclusion–exclusion principle to improve bounds by over- and undercounting systematically. In a preliminary empirical analysis, we demonstrate promising results. After compiling the input (offline phase), our approach quickly (re)counts.

Information

Type
Original Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press
Figure 0

Fig. 1. Counting graph $\mathcal{G}(\varphi \wedge \neg c)$ labeled with literals and their respective value.

Figure 1

Algorithm 1 Counting Graph Compression

Figure 2

Fig. 2. The positive dependency graph of $\Pi_2$.

Figure 3

Fig. 3. The positive dependency graph of $\Pi_3$ from Example 8.

Figure 4

Algorithm 2 Incremental Counting by Anytime Refinement

Figure 5

Fig. 4. The positive dependency graph of program $\Pi_4$ from Example 11.

Figure 6

Table 1. Comparing runtimes of different solvers when directly counting answer sets by enumeration (clingo, wasp), counting answer sets on a translation to SAT (c2d, sharpsat-td, d4), using incremental answer-set counting (iascar), or using incremental answer-set counting (iascar-d2) of depth two. iascar* and iascar-d2* refer to runs where, regardless of the timeout, a bound (anytime count) was obtained. We omit iascar-d2 due to relevance for (S1) and (S3). (S1) consists of 242 instances, (S2) of 936 instances, and (S3) of 6 instances. # refers to the number of solved instances within the timeout of 900 s. The average time of the compilation phase for solved instances comprises both sd-DNNF[s] (average time for translating into CNF and sd-DNNF compilation) and ccg[s] (average time for counting graph compression and encoding unsupported constraints). a[s] refers to the average runtime of the counting step. #AS contains the count in $\log_{10}$ notation, which equals the number of answer sets for all solvers except iascar-d2, iascar* and iascar-d2*.

Figure 7

Table 2. For selected interesting instances from the considered sets, we compare runtimes of iascar for compiling the input program to an NNF when directly counting answer sets (cnf), counting supported models (sup), converging to the answer set count (A) under assumptions with specified alternation depth (d) of several instances with varying numbers of simple cycles (#SC), compressing counting graphs (T), and supported models (#$\mathcal{S}$), sd-DNNF sizes (sd-DNNF size) and CCG sizes (CCG size). Depths marked with * indicate restricting alternation depths to the corresponding value.