1 Introduction
Answer Set Programming (ASP) (Marek and Truszczyński Reference Marek and Truszczyński1999) has emerged as a powerful declarative problem-solving paradigm with applications across diverse application domains. These include decision support systems (Nogueira et al. Reference Nogueira, Balduccini, Gelfond, Watson and Barry2001), systems biology (Gebser et al. Reference Gebser, Schaub, Thiele, Usadel and Veber2008), and diagnosis and repair (Leone and Ricca Reference Leone and Ricca2015). In the ASP paradigm, domain knowledge and queries are expressed through rules defined over propositional atoms, collectively forming an ASP program. Solutions manifest as answer sets – assignments to these atoms that satisfy program rules according to ASP semantics. Our work focuses on the fundamental challenge of answer set counting #ASP: determining the total number of valid answer sets for a given ASP program.
Answer set counting shares conceptual similarities with propositional model counting (#SAT), in which we count satisfying assignments of Boolean formulas (Valiant Reference Valiant1979). While #SAT is #
$\mathsf{P}$
-complete (Valiant Reference Valiant1979), its practical significance has driven substantial research, yielding practically efficient propositional model counters that combine strong theoretical guarantees with impressive empirical performance. This, in turn, has motivated research in counting techniques beyond propositional logic. Specifically, there has been growing interest in answer set counting, spurred by applications in probabilistic reasoning (Lee et al. Reference Lee, Talsania and Wang2017), network reliability analysis (Kabir and Meel Reference Kabir and Meel2023), answer set navigation (Rusovac et al. Reference Rusovac, Hecher, Gebser, Gaggl and Fichte2024), system biology (Kabir et al. Reference Kabir, Trinh, Pastva and Meel2025), and others (Kabir and Meel Reference Kabir and Meel2024, Reference Kabir and Meel2025).
Early approaches to answer set counting relied primarily on exhaustive enumeration (Gebser et al. Reference Gebser, Kaufmann and Schaub2012). Recent methods have made significant progress by leveraging #SAT techniques (Janhunen Reference Janhunen2006; Janhunen and Niemelä Reference Janhunen and Niemelä2011; Aziz et al. Reference Aziz, Chu, Muise and Stuckey2015b; Eiter et al. Reference Eiter, Hecher and Kiesel2024; Kabir et al. Reference Kabir, Chakraborty and Meel2024; Fichte et al. Reference Fichte, Gaggl, Hecher and Rusovac2024). Complementing these approaches, dynamic programming on tree decompositions has shown promise for programs with bounded treewidth (Fichte et al. Reference Fichte, Hecher, Morak and Woltran2017; Fichte and Hecher Reference Fichte and Hecher2019). Most existing answer set counters focus on normal logic programs – a restricted class of ASP. Research on counters for the more expressive class of disjunctive logic programs (Eiter and Gottlob Reference Eiter and Gottlob1995) has received relatively less attention over the years. Our work attempts to bridge this gap by focusing on practically efficient counters for disjunctive logic programs. Complexity theoretic arguments show that barring a collapse of the polynomial hierarchy, translation from disjunctive to normal programs must incur exponential overhead (Eiter et al. Reference Eiter, Fink, Tompits and Woltran2004; Zhou Reference Zhou2014). Consequently, counters optimized for normal programs cannot efficiently handle disjunctive programs, unless the programs themselves have special properties (Fichte and Szeider Reference Fichte and Szeider2015; Ji et al. Reference Ji, Wan, Wang, Wang, Zhang and Xu2016; Ben-Eliyahu-Zohary et al. Reference Ben-Eliyahu-Zohary, Angiulli, Fassetti and Palopoli2017). While loop formula-based translation (Lee and Lifschitz Reference Lee and Lifschitz2003) enables counting in theory, the exponential overhead becomes practically prohibitive for programs with many cyclic atom relationships (Lifschitz and Razborov Reference Lifschitz and Razborov2006). Similarly, although disjunctive answer set counting can be reduced to QBF counting in principle (Egly et al. Reference Egly, Eiter, Tompits and Woltran2000), this doesn’t yield a practically scalable counter since QBF model counting still does not scale as well in practice as propositional model counting (Shukla et al. Reference Shukla, Möhle, Kauers and Seidl2022; Capelli et al. Reference Capelli, Lagniez, Plank and Seidl2024). This leads to our central research question: Can we develop a practical answer set counter for disjunctive logic programs that can scale effectively to handle large answer set counts?
Our work provides an affirmative answer to this question through several key contributions. We present the design, implementation, and extensive evaluation of a novel counter for disjunctive programs, employing subtractive reduction (Durand et al. Reference Durand, Hermann and Kolaitis2005) to projected propositional model counting (Aziz et al. Reference Aziz, Chu, Muise and Stuckey2015a), while maintaining polynomial formula size growth. The approach first computes an over-approximation of the answer set count and then subtracts the surplus computed using projected counting. This yields a #
$\mathsf{NP}$
algorithm that leverages recent advances in projected propositional counting (Sharma et al. Reference Sharma, Roy, Soos and Meel2019). This approach is theoretically justified: answer set counting for normal programs is in #
$\mathsf{P}$
(Janhunen and Niemelä Reference Janhunen and Niemelä2011; Eiter et al. Reference Eiter, Hecher and Kiesel2021), while for disjunctive programs, it lies in #
$\cdot$
co-
$\mathsf{NP}$
(Fichte et al. Reference Fichte, Hecher, Morak and Woltran2017). Since #
$\cdot$
co-
$\mathsf{NP}$
= #
$\cdot$
$\mathsf{P}$
$^{\mathsf{NP}} =$
#
$\mathsf{NP}$
(Hemaspaandra and Vollmer Reference Hemaspaandra and Vollmer1995; Durand et al. Reference Durand, Hermann and Kolaitis2005), our reduction is complexity-theoretically sound and yields a practical counting algorithm.
While subtractive reduction for answer set counting has been proposed earlier (Hecher and Kiesel Reference Hecher and Kiesel2023), our work makes several novel contributions beyond the theoretical framework. We develop a complete implementation with careful algorithm design choices and provide comprehensive empirical evaluation across diverse benchmarks. A detailed comparison with the prior approach is presented in Section 5.
Our counter,
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
, employs an alternative definition of answer sets for disjunctive programs, extending earlier work on normal programs (Kabir et al. Reference Kabir, Chakraborty and Meel2024). This definition enables the use of off-the-shelf projected model counters without exponential formula growth. Extensive experiments on standard benchmarks demonstrate that
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
significantly outperforms existing counters on instances with large answer set counts. This motivates our development of a hybrid counter combining enumeration and
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
to consistently exceed state-of-the-art performance.
The remainder of the paper is organized as follows. Section 2 covers essential background. Section 3 reviews prior work. Section 4 presents our alternative answer set definition for disjunctive programs. Section 5 details our counting technique
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
. Section 6 provides experimental results, and Section 7 concludes the paper with future research directions.
2 Preliminaries
We now introduce some notations and preliminaries needed in subsequent sections.
2.1 Propositional satisfiability
A propositional variable
$v$
takes value from the domain
$\{0, 1\}$
(
$\{\textit {false}, \textit {true}\}$
resp.). A literal
$\ell$
is either a variable or its negation.
A clause
$C$
is a disjunction (
$\vee$
) of literals. For clarity, we often represent a clause as a set of literals, implicitly meaning that all literals in the set are disjoined in the clause. A unit clause is a clause with a single literal. The constraint represented by a clause
$C \equiv (\neg {x_1} \vee \ldots \vee \neg {x_k} \vee x_{k+1} \vee \ldots \vee x_{k+m})$
can be expressed as a logical implication as follows:
$(x_1 \wedge \ldots \wedge x_k) \longrightarrow (x_{k+1} \vee \ldots \vee x_{k+m})$
, where the conjunction of literals
$x_1 \wedge \ldots \wedge x_k$
is known as the antecedent and the disjunction of literals is known as the consequent. If
$k = 0$
, the antecedent of the implication is
$\textit {true}$
, and if
$m = 0$
, the consequent is
$\textit {false}$
.
A formula
$\phi$
is said to be in conjunctive normal form (CNF) if it is a conjunction (
$\wedge$
) of clauses. For convenience of exposition, a CNF formula is often represented as a set of clauses, implicitly meaning that all clauses in the set are conjoined in the formula. We denote the set of variables of a propositional formula
$\phi$
as
$\mathsf{Var}(\phi )$
.
An assignment over a set
$X$
of propositional variables is a mapping
$\tau : X \rightarrow \{0,1\}$
. For a variable
$x \in X$
, we define
$\tau (\neg {x}) = 1 - \tau (x)$
. An assignment
$\tau$
over
$\mathsf{Var}(\phi )$
is called a model of
$\phi$
, represented as
$\tau \models \phi$
, if
$\phi$
evaluates to true under the assignment
$\tau$
, as per the semantics of propositional logic. A formula
$\phi$
is said to be SAT (resp. UNSAT) if there exists a model (resp. no model) of
$\phi$
. Given an assignment
$\tau$
, we use the notation
$\tau ^{+}$
(resp.
$\tau ^{-}$
) to denote the set of variables that are assigned
$1$
or true (resp.
$0$
or false).
Given a CNF formula
$\phi$
(as a set of clauses) and an assignment
$\tau : X \rightarrow \{0,1\}$
, where
$X \subseteq \mathsf{Var}(\phi )$
, the unit propagation of
$\tau$
on
$\phi$
, denoted
${\phi }\!\mid _{\tau }$
, is another CNF formula obtained by applying the following steps recursively: (a) remove each clause
$C$
from
$\phi$
that contains a literal
$\ell$
s.t.
$\tau (\ell ) = 1$
; (b) remove from each clause
$C$
in
$\phi$
all literals
$\ell$
s.t. either
$\tau (\ell ) = 0$
or there exists a unit clause
$\{\neg \ell \}$
, that is, a clause with a single literal
$\neg \ell$
; and (c) apply the above steps recursively to the resulting CNF formula until there are no further syntactic changes to the formula. As a special case, the unit propagation of an empty formula is the empty formula. It is not hard to show that unit propagation of
$\tau$
on
$\phi$
always terminates or reaches fixed point. We say that
$\tau$
unit propagates to literal
$\ell$
in
$\phi$
, if
$\{\ell \}$
is a unit clause in
${\phi }\!\mid _{\tau }$
, that is, if
$\{\ell \} \in {\phi }\!\mid _{\tau }$
.
Given a propositional formula
$\phi$
, we use
$\#\phi$
to denote the count of models of
$\phi$
. If
$X \subseteq \mathsf{Var}(\phi )$
is a set of variables, then
$\#\exists X \phi$
denotes the count of models of
$\phi$
after disregarding assignments to the variables in
$X$
. In other words, two different models of
$\phi$
that differ only in the assignment of variables in
$X$
are counted as one in
$\#\exists X \phi$
.
2.2 Answer set programming
An answer set program
$P$
consists of a set of rules, where each rule is structured as follows:

where
$a_1, \ldots , a_k, b_1, \ldots , b_m, c_1, \ldots , c_n$
are propositional variables or atoms, and
$k,m,n$
are non-negative integers. The notations
$P$
and
$\mathsf{at}(P)$
refer to the rules and atoms of the program
$P$
, respectively. In rule
$r$
above, the operator “not” denotes default negation (Clark Reference Clark1978). For each such rule
$r$
, we use the following notation: the set of atoms
$\{a_1, \ldots , a_k\}$
constitutes the head of
$r$
, denoted by
$\mathsf{Head}(r)$
, the set of atoms
$\{b_1, \ldots , b_m\}$
is referred to as the positive body atoms of
$r$
, denoted by
$\mathsf{Body}(r)^+$
, and the set of atoms
$\{c_1, \ldots , c_n\}$
is referred to as the negative body atoms of
$r$
, denoted by
$\mathsf{Body}(r)^-$
. We use
$\mathsf{Body}(r)$
to denote the set of literals
$\{b_1, \ldots , b_m, \neg {c_1}, \ldots , \neg {c_n}\}$
. For notational convenience, we sometimes use
$\bot$
on the left (resp.
$\top$
on the right) of
$\leftarrow$
in a rule
$r$
to denote that
$\mathsf{Head}(r)$
(resp.
$\mathsf{Body}(r)$
) is empty. A program
$P$
is called a disjunctive logic program if
$\exists r \in P$
such that
$|\mathsf{Head}(r)| \geq 2$
(Ben-Eliyahu and Dechter Reference Ben-Eliyahu and Dechter1994); otherwise, it is a normal logic program. Our focus in this paper is on disjunctive logic programs.
Following standard ASP semantics, an interpretation
$M$
over the atoms
$\mathsf{at}(P)$
specifies which atoms are present in
$M$
, or equivalently assigned true in
$M$
. Specifically, atom
$a$
is true in
$M$
if and only if
$a \in M$
. An interpretation
$M$
satisfies a rule
$r$
, denoted by
$M \models r$
, if and only if
$(\mathsf{Head}(r) \cup \mathsf{Body}(r)^{-}) \cap M \neq \emptyset$
or
$\mathsf{Body}(r)^{+} \setminus M \neq \emptyset$
. An interpretation
$M$
is a model (though not necessarily an answer set) of
$P$
, denoted by
$M \models P$
, if
$M$
satisfies every rule in
$P$
, that is,
$\forall _{r \in P} M \models r$
. The Gelfond–Lifschitz (GL) reduct of a program
$P$
with respect to an interpretation
$M$
is defined as
$P^M = \{\mathsf{Head}(r) \leftarrow \mathsf{Body}(r)^+ \mid r \in P, \mathsf{Body}(r)^- \cap M = \emptyset \}$
(Gelfond and Lifschitz Reference Gelfond and Lifschitz1991). An interpretation
$M$
is an answer set of
$P$
if
$M \models P$
and
$\not \exists M^\prime \subset M$
such that
$M^\prime \models P^M$
. In general, an ASP
$P$
may have multiple answer sets. The notation
$\mathsf{AS}(P)$
denotes the set of all answer sets of
$P$
.
2.3 Clark completion
The Clark Completion (Lee and Lifschitz Reference Lee and Lifschitz2003) translates an ASP program
$P$
to a propositional formula
$\mathsf{Comp}(P)$
. The formula
$\mathsf{Comp}(P)$
is defined as the conjunction of the following propositional implications:
-
1. (group
$1$ ) for each atom
$a \in \mathsf{at}(P)$ s.t.
$\not \exists r \in P$ and
$a \in \mathsf{Head}(r)$ , add a unit clause
$\neg {a}$ to
$\mathsf{Comp}(P)$
-
2. (group
$2$ ) for each rule
$r \in P$ , add the following implication to
$\mathsf{Comp}(P)$ :
\begin{equation*} \bigwedge _{\ell \in \mathsf{Body}(r)} \ell \longrightarrow \bigvee _{x \in \mathsf{Head}(r)} x \end{equation*}
-
3. (group
$3$ ) for each atom
$a \in \mathsf{at}(P)$ occuring in the head of at least one of the rules of
$P$ , let
$r_1, \ldots , r_k$ be precisely all rules containing
$a$ in the head, and add the following implication to
$\mathsf{Comp}(P)$ :
\begin{equation*} a \longrightarrow \bigvee _{i \in [1,k]} (\bigwedge _{\ell \in \mathsf{Body}(r_i)} \ell \,\wedge \, \bigwedge _{x \in \mathsf{Head}(r_i) \setminus \{a\}} \neg {x}) \end{equation*}
It is known that every answer set of
$P$
satisfies
$\mathsf{Comp}(P)$
, although the converse is not necessarily true (Lee and Lifschitz Reference Lee and Lifschitz2003).
Given a program
$P$
, we define the positive dependency graph
$\mathsf{DG}(P)$
of
$P$
as follows. Each atom
$x \in \mathsf{at}(P)$
corresponds to a vertex in
$\mathsf{DG}(P)$
. For
$x, y \in \mathsf{at}(P)$
, there is an edge from
$y$
to
$x$
in
$\mathsf{DG}(P)$
if there exists a rule
$r \in P$
such that
$x \in \mathsf{Body}(r)^+$
and
$y \in \mathsf{Head}(r)$
(Kanchanasut and Stuckey Reference Kanchanasut and Stuckey1992). A set of atoms
$L \subseteq \mathsf{at}(P)$
forms a loop in
$P$
if, for every
$x, y \in L$
, there is a path from
$x$
to
$y$
in
$\mathsf{DG}(P)$
, and all atoms (equivalently, nodes) on the path belong to
$L$
. An atom
$x$
is called a loop atom of
$P$
if there is a loop
$L$
in
$\mathsf{DG}(P)$
such that
$x \in L$
. We use the notation
$\mathsf{LA}(P)$
to denote the set of all loop atoms of the program
$P$
. If there is no loop in
$P$
, we call the program tight; otherwise, it is said to be non-tight (Fages Reference Fages1994).
Example 1.
Consider the program
$P = \{r_1: p_0 \vee p_1 \leftarrow \top ; \text{ }r_2: q_0 \vee q_1 \leftarrow \top ; \text{ }r_3: q_0 \leftarrow w; \text{ }r_4: q_1 \leftarrow w;\text{ } r_5: w \leftarrow p_0; \text{ }r_6: w \leftarrow p_1, q_1; \text{ }r_7: \bot \leftarrow \mathsf{not }\text{ }w;\}$
.
The group 2 clauses in
$\mathsf{Comp}(P)$
are:
$\{(p_0 \vee p_1), (q_0 \vee q_1), (\neg {w} \vee q_0), (\neg {w} \vee q_1), (\neg {p_0} \vee w), (\neg {p_1} \vee \neg {q_1} \vee w), (w)\}$
; and the group 3 clauses are:
$\{(p_0 \longrightarrow \neg {p_1}), (p_1 \longrightarrow \neg {p_0}), (q_0 \longrightarrow (\neg {q_1} \vee w)), (q_1 \longrightarrow (\neg {q_0} \vee w)), (w \longrightarrow (p_0 \vee (p_1 \wedge q_1)))\}$
.
Since each atom occurs in at least one rule’s head, there are no group 1 clauses. Thus,
$\mathsf{Comp}(P)$
consists of only group 2 and group 3 clauses. In this program, the set of loop atoms is
$\{q_1, w\}$
.
2.4 Subtractive reduction
Borrowing notation from Durand et al. (Reference Durand, Hermann and Kolaitis2005), suppose
$\Sigma$
and
$\Gamma$
are alphabets, and
$Q_1, Q_2 \subseteq \Sigma ^* \times \Gamma ^*$
are binary relations such that for each
$x \in \Sigma ^*$
, the sets
$Q_1(x) = \{y \in \Gamma ^* \mid Q_1(x,y)\}$
and
$Q_2(x) = \{y \in \Gamma ^* \mid Q_2(x,y)\}$
are finite. Let
$\#Q_1$
and
$\#Q_2$
denote counting problems that require us to find
$|Q_1(x)|$
and
$|Q_2(x)|$
, respectively, for a given
$x \in \Sigma ^*$
. We say that
$\#Q_1$
strongly reduces to
$\#Q_2$
via a subtractive reduction, if there exist polynomial-time computable functions
$f$
and
$g$
such that for every string
$x \in \Sigma ^*$
, the following hold: (a)
$Q_2(g(x)) \subseteq Q_2(f(x))$
, and (b)
$|Q_1(x)| = |Q_2(f(x))| - |Q_2(g(x))|$
. As we will see in Section 5, in our context,
$\#Q_1$
is the answer set counting problem for disjunctive logic programs, and
$\#Q_2$
is the projected model counting problem for propositional formulas.
3 Related Work
Answer set counting exhibits distinct complexity characteristics across different classes of logic programs. For normal logic programs, the problem is #P-complete (Valiant Reference Valiant1979), while for disjunctive logic programs, it rises to #
$\cdot$
$\mathsf{co}$
-
$\mathsf{NP}$
(Fichte et al. Reference Fichte, Hecher, Morak and Woltran2017). This complexity gap between normal and disjunctive programs highlights that answer set counting for disjunctive logic programs is likely harder than that for normal logic programs, under standard complexity theoretic assumptions.
This complexity distinction is also reflected in the corresponding decision problems as well. While determining the existence of an answer set for normal logic programs is
$\mathsf{NP}$
-complete (Marek and Truszczyński Reference Marek and Truszczyński1991), the same problem for disjunctive logic programs is
$\Sigma _{2}^{p}$
-complete (Eiter and Gottlob Reference Eiter and Gottlob1995). This fundamental difference in complexity has important implications for translations between program classes. Specifically, a polynomial-time translation from disjunctive to normal logic programs that preserves the count of answer sets does exist unless the polynomial hierarchy collapses (Janhunen et al. Reference Janhunen, Niemelä, Seipel, Simons and You2006; Zhou Reference Zhou2014; Ji et al. Reference Ji, Wan, Wang, Wang, Zhang and Xu2016).
Much of the early research on answer set counting focused on normal logic programs (Aziz et al. Reference Aziz, Chu, Muise and Stuckey2015b; Eiter et al. Reference Eiter, Hecher and Kiesel2021, Reference Eiter, Hecher and Kiesel2024; Kabir et al. Reference Kabir, Chakraborty and Meel2024). The methodologies for counting answer sets have evolved significantly over time. Initial approaches relied primarily on enumerations (Gebser et al. Reference Gebser, Kaufmann and Schaub2012). More recent methods have adopted advanced algorithmic techniques, particularly tree decomposition and dynamic programming. Fichte et al. (Reference Fichte, Hecher, Morak and Woltran2017) developed DynASP, an exact answer set counter optimized for instances with small treewidth. Kabir et al. (Reference Kabir, Everardo, Shukla, Hecher, Fichte and Meel2022) explored a different direction with ApproxASP, which implements an approximate counter providing
$(\varepsilon ,\delta )$
-guarantees, with the adaptation of hashing-based techniques.
Subtraction-based techniques have emerged as promising approaches for various counting problems, for example, MUS counting (Bendík and Meel Reference Bendík and Meel2021). In the context of answer set counting, subtraction-based methods were introduced in Hecher and Kiesel (Reference Hecher and Kiesel2023) and Fichte et al. (Reference Fichte, Gaggl, Hecher and Rusovac2024). These methods employ a two-phase strategy: initially overcounts the answer set count, subsequently subtracts the surplus to obtain the exact count. Hecher and Kiesel (Reference Hecher and Kiesel2023) developed a method utilizing projected model counting over propositional formulas with projection sets. A detailed comparison of our work with their approach is provided at the end of Section 5. In a different direction, Fichte et al. (Reference Fichte, Gaggl, Hecher and Rusovac2024) proposed iascar, specifically tailored for normal programs. Their approach iteratively refines the overcount count by enforcing external support for each loop and applying the inclusion-exclusion principle. The key distinction of iascar lies in its comprehensive consideration of external supports for all cycles in the counting process.
4 An Alternative Definition of Answer Sets
In this section, we present an alternative definition of answer sets for disjunctive logic programs, that generalizes the work of Kabir et al. (Reference Kabir, Chakraborty and Meel2024) for normal logic programs. Before presenting the alternative definition of answer sets, we provide a definition of justification, which is crucial to understand our technical contribution.
4.1 Checking Justification in ASP
Intuitively, justification refers to a structured explanation for why a literal (atom or its negation) is true or false in a given answer set (Pontelli et al. Reference Pontelli, Son and Elkhatib2009; Fandinno and Schulz Reference Fandinno and Schulz2019). Recall that the classical definition of answer sets requires that each true atom in an interpretation, that also appears at the head of a rule, must be justified (Gelfond and Lifschitz Reference Gelfond and Lifschitz1988; Lifschitz Reference Lifschitz2010). More precisely, given an interpretation
$M$
s.t.
$M \models P$
, ASP solvers check whether some of the atoms in
$M$
can be set to false, while satisfying the reduct program
$P^{M}$
(Lierler Reference Lierler2005). We use the notation
$\tau _{M}$
to denote the assignment of propositional variables corresponding to the interpretation
$M$
. Furthermore, we say that
$x \in \tau _M^+$
(resp.
$\tau _M^-$
) iff
$\tau _M(x) = 1$
(resp.
$0$
).
While the existing literature typically formulates justification using rule-based or graph-based explanations (Fandinno and Schulz Reference Fandinno and Schulz2019), we propose a model-theoretic definition from the reduct
$P^M$
, for each interpretation
$M \models P$
. An atom
$x \in M$
is justified in
$M$
if for every
$M^\prime \models P^M$
such that
$M^\prime \subseteq M$
, it holds that
$x \in M^\prime$
. In other words, removing
$x$
from
$M$
violates the satisfaction of
$P^M$
. The definition is compatible with the standard characterization of answer sets, since
$M$
is an answer set, when no
$M^\prime \subsetneq M$
exists such that
$M^\prime \models P^M$
; that is, each atom
$x \in M$
is justified. Conversely, an atom
$x \in M$
is not justified in
$M$
if there exists a proper subset
$M^\prime \subset M$
such that
$M^\prime \models P^M$
and
$x \not \in M^\prime$
. This notion of justification also aligns with how SAT-based ASP solvers perform minimality checks (Lierler Reference Lierler2005) – such solvers encode
$P^M$
as a set of implications (see definition of
$P^M$
in Section 2) and check the satisfiability of the formula:
$P^M \wedge \bigwedge _{x \in \tau _M^{-}} \neg x \wedge \bigvee _{x \in \tau _M^{+}} \neg x$
.
Proposition 1.
For a program
$P$
and each interpretation
$M$
such that
$M \models P$
, if the formula
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigvee _{x \in \tau _{M}^{+}} \neg {x}$
is satisfiable, then some atoms in
$M$
are not justified.
The proposition holds by definition. In the above formula, the term
$\bigwedge _{x \in \tau _{M}^{-}} \neg {x}$
encodes the fact that variables assigned false in
$M$
need no justification. On the other hand, the term
$\bigvee _{x \in \tau _{M}^{+}} \neg {x}$
verifies whether any of the variables assigned true in
$M$
is not justified.
Example 1 (continued).
Consider the following two interpretations over
$\mathsf{at}(P)$
:
-
•
$M_1 = \{p_0, w, q_0, q_1\}$ : Clearly,
$\tau _{M_1} = \{p_0, w, q_0, q_1, \neg {p_1}\}$ . As no strict subset of
$M_1$ satisfies
$P^{M_1}$ , each atom of
$M_1$ is justified.
-
•
$M_2 = \{p_1, w, q_0, q_1\}$ : Here,
$\tau _{M_2} = \{p_1, w, q_0, q_1, \neg {p_0}\}$ . Note that
$\tau _{M_2} \models \mathsf{Comp}(P)$ . The program
$P^{M_2}$ includes all rules of
$P$ except rule
$r_7$ . There is an interpretation
$\{p_1, q_0\} \subset M_2$ that satisfies
$P^{M_2}$ . It indicates that atoms
$q_1$ and
$w$ are not justified in
$M_2$ .
We now show that under the Clark completion of a program, or when
$\tau _{M} \models \mathsf{Comp}(P)$
, then it suffices to check justification of only loop atoms of
$P$
in the interpretation
$M$
. Note that the ASP counter, sharpASP (Kabir et al. Reference Kabir, Chakraborty and Meel2024), also checks justifications for loop atoms in the context of normal logic programs. Our contribution lies in proving the sufficiency of checking justifications for loop atoms even in the context of disjunctive logic programs – a non-trivial generalization. Specifically, we establish that when
$\tau _{M} \models \mathsf{Comp}(P)$
, if some atoms in
$M$
are not justified, then there must also be some loop atoms in
$M$
that is not justified. To verify justifications for only loop atoms, we check the satisfiability of the formula:
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$
.
Proposition 2.
For each
$M \subseteq \mathsf{at}(P)$
such that
$M \models P$
, if the formula
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$
is satisfiable, then some of the loop atoms in
$M$
are not justified; otherwise, each loop atom in
$M$
is justified.
Proof.
Since
$\tau _M \models \mathsf{Comp}(P)$
, it implies that
$\tau _M \models P^{M}$
. Thus, the formula
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x$
is satisfiable.
If
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$
is satisfiable, then there are some loop atoms from
$\tau _{M}^{+} \cup \mathsf{LA}(P)$
that can be set to false, while satisfying the formula
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x$
. It indicates that some of the loop atoms of
$M$
are not justified; otherwise, each loop atom of
$M$
is justified.
In this above formula, the term
$\bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x$
ensures that we are not concerned with justifications for non-loop atoms. On the other hand, the term
$\bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$
specifically verifies whether any of the loop atoms assigned to true in
$M$
is not justified.
For every interpretation
$M \models P$
, checking justification of all loop atoms of
$M$
suffices to check justification all atoms of
$M$
. The following lemma formalizes our claim:
Lemma 1.
For a given program
$P$
and each interpretation
$M \subseteq \mathsf{at}(P)$
such that
$\tau _{M} \models \mathsf{Comp}(P)$
, if
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigvee _{x \in \tau _{M}^{+}} \neg {x}$
is SAT then
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$
is also SAT.
Proof.
For notational clarity, let
$A$
and
$B$
denote the formulas
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigvee _{x \in \tau _{M}^{+}} \neg {x}$
and
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$
, respectively.
We use proof by contradiction. Suppose, if possible,
$A$
is SAT but
$B$
is UNSAT. Given that
$A$
is SAT, we know that some atoms are not justified in
$M$
(Proposition1). Similarly, since
$B$
is UNSAT, we know that all loop atoms are justified in
$M$
(Proposition2). Therefore, there must be a non-loop atom, say
$x_1$
, that is not justified in
$M$
. Since
$x_1 \in M$
and
$\tau _{M} \models \mathsf{Comp}(P)$
, according to group
$3$
implications in the definition of Clark completion, there exists a rule
$r_1 \in P$
such that
$\mathsf{Body}(r_1) \wedge \bigwedge _{x \in \mathsf{Head}(r_1) \setminus \{x_1\}} \neg {x}$
is true under
$\tau _{M}$
. It follows that there exists an atom
$x_2 \in \mathsf{Body}(r_1)^+$
that is not justified; otherwise, the atom
$x_1$
would have no other option but be justified. Now, we can repeat the same argument we presented above for
$x_1$
, but in the context of the non-justified atom
$x_2$
in
$M$
. By continuing this argument, we obtain a sequence of not justified atoms
$\{x_1, x_2, \ldots \}$
, such that the underlying set is a subset of
$M$
. There are two possible cases to consider: either (i) the sequence
$\{x_i\}$
is unbounded, or (ii) for some
$i \lt j$
,
$x_i = x_j$
. Case (i) contradicts the finiteness of
$\mathsf{at}(P)$
. Case (ii) implies that some loop atoms are not justified – a contradiction of our premise!
Example 1 (continued).
Consider the following two interpretations over
$\mathsf{at}(P)$
:
-
•
$M_1 = \{p_0, w, q_0, q_1\}$ : Clearly,
$\tau _{M_1} = \{p_0, w, q_0, q_1, \neg {p_1}\}$ . Note that
$M_1 \in \mathsf{AS}(P)$ , as no strict subset of
$M_1$ satisfies
$P^{M_1}$ .
-
•
$M_2 = \{p_1, w, q_0, q_1\}$ : Here,
$\tau _{M_2} = \{p_1, w, q_0, q_1, \neg {p_0}\}$ . While
$\tau _{M_2} \models \mathsf{Comp}(P)$ , it can be shown that
$M_2 \not \in \mathsf{AS}(P)$ . The program
$P^{M_2}$ includes all rules of
$P$ except rule
$r_7$ . There is an interpretation
$\{p_1, q_0\} \subset M_2$ that satisfies
$P^{M_2}$ . This means that the atoms
$q_1$ and
$w$ in
$M_2$ are not justified. Note that both
$q_1$ and
$w$ are loop atoms in program
$P$ .
4.2
$\mathsf{Copy}(P)$
for disjunctive logic programs
Toward establishing an alternative definition of answer sets for disjunctive logic programs, we now generalize the copy operation used in Kabir et al. (Reference Kabir, Chakraborty and Meel2024) in the context of normal logic programs. Given an ASP program
$P$
, for each loop atom
$x \in \mathsf{LA}(P)$
, we introduce a fresh variable
${x}^{\prime }$
such that
${x}^{\prime } \not \in \mathsf{at}(P)$
. We refer to
${x}^{\prime }$
as the copy variable of
$x$
. Similar to Kabir et al. (Reference Kabir, Chakraborty and Meel2024) and Kabir (Reference Kabir2024), the operator
$\mathsf{Copy}(P)$
returns the following set of implicitly conjoined implications.
-
1. (type
$1$ ) for each loop atom
$x \in \mathsf{LA}(P)$ , the implication
${x}^{\prime } \longrightarrow x$ is included in
$\mathsf{Copy}(P)$ .
-
2. (type
$2$ ) for each rule
$r = a_1 \vee \ldots \vee a_k \leftarrow b_1, \ldots , b_m, \textsf {not } c_1, \ldots , \textsf {not } c_n \in P$ such that
$\{a_1, \ldots a_k\} \cap \mathsf{LA}(P) \neq \emptyset$ , the implication
$\psi (b_1) \wedge \ldots \wedge \psi (b_m) \wedge \neg {c_1} \wedge \ldots \wedge \neg {c_n} \longrightarrow \psi (a_1) \vee \ldots \vee \psi (a_k)$ is included in
$\mathsf{Copy}(P)$ , where
$\psi (x)$ is a function defined as follows:
$\psi (x) = \begin{cases} {x}^{\prime } & \text{if } x \in \mathsf{LA}(P)\\ x & \text{otherwise}\\ \end{cases}$
-
3. No other implication is included in
$\mathsf{Copy}(P)$ .
Note that we do not introduce any type 2 implication for a rule
$r$
if
$\mathsf{Head}(r) \cap \mathsf{LA}(P) = \emptyset$
. In a type 2 implication, each loop atom in the head and each positive body atom is replaced by its corresponding copy variable. As a special case, if the program
$P$
is tight then
$\mathsf{Copy}(P) = \emptyset$
.
Example 1(continued).
For the given program
$P$
, we have
$\mathsf{LA}(P) = \{q_1, w\}$
. Therefore,
$\mathsf{Copy}(P)$
introduces two fresh copy variables
${q_1}^{\prime }$
and
${w}^{\prime }$
, and adds the the following implications:
$\{{q_1}^{\prime } \longrightarrow q_1, {w}^{\prime } \longrightarrow w, q_0 \vee {q_1}^{\prime }, {w}^{\prime } \longrightarrow {q_1}^{\prime }, p_0 \longrightarrow {w}^{\prime }, p_1 \wedge {q_1}^{\prime } \longrightarrow {w}^{\prime }\}$
.
We now demonstrate an important relationship between
$P^{M}$
and
${\mathsf{Copy}(P)}\!\mid _{\tau _M}$
, for a given interpretation
$M$
. Specifically, we show that we can use
${\mathsf{Copy}(P)}\!\mid _{\tau _M}$
, instead of
$P^M$
, to check the justification of loop atoms in
$M$
. While sharpASP also utilizes a similar idea for normal programs, the following lemma (Lemma2) formalizes this important relationship in the context of the more general class of disjunctive logic programs.
Lemma 2.
For a given program
$P$
and each interpretation
$M \subseteq \mathsf{at}(P)$
such that
$\tau _{M} \models \mathsf{Comp}(P)$
,
-
1. the formula
${\mathsf{Copy}(P)}\!\mid _{\tau _M} \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {{x}^{\prime }}$ is SAT if and only if
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigwedge _{x \in \tau _{M}^{+} \wedge x \not \in \mathsf{LA}(P)} x \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {x}$ is SAT
-
2. the formula
${\mathsf{Copy}(P)}\!\mid _{\tau _M} \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {{x}^{\prime }}$ is SAT if and only if
$P^{M} \wedge \bigwedge _{x \in \tau _{M}^{-}} \neg {x} \wedge \bigvee _{x \in \tau _{M}^{+}} \neg {x}$ is SAT
The proof is deferred to the extended version of the paper.Footnote 1
We now integrate Clark’s completion, the copy operation introduced above, and the core idea from Lemma2 to propose an alternative definition of answer sets.
Lemma 3.
For a given program
$P$
and each interpretation
$M \subseteq \mathsf{at}(P)$
such that
$\tau _{M} \models \mathsf{Comp}(P)$
,
$M \in \mathsf{AS}(P)$
if and only if the formula
${\mathsf{Copy}(P)}\!\mid _{\tau _M} \wedge \bigvee _{x \in \tau _{M}^{+} \wedge x \in \mathsf{LA}(P)} \neg {{x}^{\prime }}$
is UNSAT.
The proof follows directly from the correctness of Lemma2 and from the definition of answer sets based on the GL reduct
$P^M$
(see Section 2).
Example 1(continued).
Consider two interpretations
$M_1, M_2 \subseteq \mathsf{at}(P)$
:
-
•
$M_1 = \{p_0, w, q_0, q_1\}$ , where
$\tau _{M_1} = \{p_0, w, q_0, q_1, \neg {p_1}\}$ . Note that
$M_1 \in \mathsf{AS}(P)$ and we can verify that
${\mathsf{Copy}(P)}\!\mid _{\tau _{M_1}} \wedge (\neg {{q_1}^{\prime }} \vee \neg {{w}^{\prime }})$ is UNSAT.
-
•
$M_2 = \{p_1, w, q_0, q_1\}$ , where
$\tau _{M_2} = \{p_1, w, q_0, q_1, \neg {p_0}\}$ . Here,
$M_2 \not \in \mathsf{AS}(P)$ . While
$\tau _{M_2} \models \mathsf{Comp}(P)$ , we can see that
${\mathsf{Copy}(P)}\!\mid _{\tau _{M_2}} \wedge (\neg {{q_1}^{\prime }} \vee \neg {{w}^{\prime }})$ is SAT.
Our alternative definition of answer sets, formalized in Lemma3, implies that the complexity of checking answer sets for disjunctive logic programs is in
$\mathsf{co}$
-
$\mathsf{NP}$
. In contrast, the definition in Kabir et al. (Reference Kabir, Chakraborty and Meel2024), which applies only to normal logic programs, allows answer set checking for this restricted class of programs to be accomplished in polynomial time. Note that the
$\mathsf{Copy}(P)$
has similarities with formulas introduced in Fichte and Szeider (Reference Fichte and Szeider2015) and Hecher and Kiesel (Reference Hecher and Kiesel2023) for
$\mathsf{co}$
-
$\mathsf{NP}$
checks.
In the following section, we utilize the definition in Lemma3 to count of models of
$\mathsf{Comp}(P)$
that are not answer sets of
$P$
. This approach allows us to determine the number of answer sets of
$P$
via subtractive reduction.
5 Answer Set Counting:
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
We now introduce a subtractive reduction-based technique for counting the answer sets of disjunctive logic programs. This approach reduces answer set counting to projected model counting for propositional formulas. Note that projected model counting for propositional formulas is known to be in #
$\mathsf{NP}$
(Aziz et al. Reference Aziz, Chu, Muise and Stuckey2015a); hence reducing answer set counting (a #
$\cdot$
co
$\mathsf{NP}$
-complete problem) to projected model counting makes sense.Footnote
2
In contrast, answer set counting of normal logic programs is in #P, and is therefore easier.

Fig. 1. The high-level architecture of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
for a program
$P$
.
At a high level, the proposed subtractive reduction approach is illustrated in Figure 1. For a given ASP program
$P$
, we overcount the answer sets of
$P$
by considering the satisfying assignment of an appropriately constructed propositional formula
$\phi _1$
(Overcount). The value
$\#\phi _1$
counts all answer sets of
$P$
, but also includes some interpretations that are not answer sets of
$P$
. To account for this surplus, we introduce another Boolean formula
$\phi _2$
and a projection set
$\mathcal{X}$
such that
$\#\exists \mathcal{X} \phi _2$
counts the surplus from the overcount of answer sets (Surplus). To correctly count the surplus, we employ the alternative answer set definition outlined in Lemma3. Finally, the count of answer sets of
$P$
is determined by
$\#\phi _1 - \#\exists \mathcal{X}\phi _2$
.
5.1 Counting overcount (
$\boldsymbol\phi _{\textbf{1}}$
)
Given a program
$P$
, the count of models of
$\mathsf{Comp}(P)$
provides an overcount of the count of answer sets of
$P$
. In the case of tight programs, the count of answer sets is equivalent to the count of models of
$\mathsf{Comp}(P)$
(Lee and Lifschitz Reference Lee and Lifschitz2003). However, for non-tight programs, the count of models of
$\mathsf{Comp}(P)$
overcounts
$|\mathsf{AS}(P)|$
. Therefore, we use

5.2 Counting surplus (
$\boldsymbol\phi _{\textbf{2}}$
)
To count the surplus, we utilize the alternative answer set definition presented in Lemma3. We use a propositional formula
$\phi _2$
, in which for each loop atom
$x$
, there are two fresh copy variables:
${x}^{\prime }$
and
$x^{\star }$
. We introduce two sets of copy operations of
$P$
, namely,
${\mathsf{Copy}(P)}^{\prime }$
and
$\mathsf{Copy}(P)^{\star }$
, where for each loop atom
$x$
, the corresponding copy variables are denoted as
${x}^{\prime }$
and
$x^{\star }$
, respectively. We use the notations
${{\mathsf{CV}}}^{\prime }$
and
${\mathsf{CV}}^{\star }$
to refer to the copy variables of
${\mathsf{Copy}(P)}^{\prime }$
and
$\mathsf{Copy}(P)^{\star }$
, respectively; that is,
${{\mathsf{CV}}}^{\prime } = \{{x}^{\prime }|x \in \mathsf{LA}(P)\}$
and
${\mathsf{CV}}^{\star } = \{x^{\star }|x \in \mathsf{LA}(P)\}$
. To compute the surplus, we define the formula
$\phi _2(\mathsf{at}(P), {{\mathsf{CV}}}^{\prime }, {\mathsf{CV}}^{\star })$
as follows:

Lemma 4.
The number of models of
$\mathsf{Comp}(P)$
that are not answer sets of
$P$
can be computed as
$\#\exists {{\mathsf{CV}}}^{\prime }, {\mathsf{CV}}^{\star }\text{ }\phi _2(\mathsf{at}(P), {{\mathsf{CV}}}^{\prime }, {\mathsf{CV}}^{\star })$
, where the formula
$\phi _2$
is defined in Equation (3).
Proof.
From the definition of
$\phi _2$
(Equation (3)), we know that for every model
$\sigma \models \phi _2$
, the assignment to
${{\mathsf{CV}}}^{\prime }$
and
${\mathsf{CV}}^{\star }$
is such that
$\forall x \in \mathsf{LA}(P), \sigma ({x}^{\prime }) \leq \sigma (x^{\star })$
and
$\exists x \in \mathsf{LA}(P), \sigma ({x}^{\prime }) \lt \sigma (x^{\star })$
.Footnote
3
Let
$M$
be the corresponding interpretation over
$\mathsf{at}(P)$
of the satisfying assignment
$\sigma$
. Since
$\sigma \models \phi _2$
,
$\tau _M \models \mathsf{Comp}(P)$
and some of the copy variables
${x}^{\prime } \in {{\mathsf{CV}}}^{\prime }$
can be set to false where
$\sigma (x) = \textit {true}$
, while after setting the copy variables
${x}^{\prime }$
to false, the formula
$\mathsf{Copy}(P)_{|\tau _M}$
is still satisfied. According to Lemma3, we can conclude that
$M \not \in \mathsf{AS}(P)$
. As a result,
$\#\exists {{\mathsf{CV}}}^{\prime }, {\mathsf{CV}}^{\star }\text{ }\phi _2(\mathsf{at}(P), {{\mathsf{CV}}}^{\prime }, {\mathsf{CV}}^{\star })$
counts all interpretations that are not answer sets of
$P$
.
Theorem 1.
For a given program
$P$
, the number of answer sets:
$|\mathsf{AS}(P)| = \#\phi _1 - \#\exists \mathcal{X}\phi _2$
, where
$\mathcal{X} = {CV}^{\prime } \cup CV^{\star }$
, and
$\phi _1$
and
$\phi _2$
are defined in Equations (2) and (3). Furthermore, both
$\phi _1$
and
$\phi _2$
can be computed in time polynomial in
$|P|$
.
The proof is deferred to the extended version of the paper.
Now recall to subtractive reduction definition (ref. Section 2), for a given ASP program
$P$
,
$f(P)$
computes the formula
$\phi _1$
, and
$g(P)$
computes the formula
$\exists \mathsf{CV}',\mathsf{CV}^*\phi _2$
.
We refer to the answer set counting technique based on Theorem1 as
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
. While
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
shares similarities with the answer set counting approach outlined in Hecher and Kiesel (Reference Hecher and Kiesel2023), there are key differences between the two techniques. First, instead of counting the number of models of Clark completion, the technique in Hecher and Kiesel (Reference Hecher and Kiesel2023) counts non-models of the Clark completion. Second, to count the surplus,
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
introduces copy variables only for loop variables, whereas the approach of Hecher and Kiesel (Reference Hecher and Kiesel2023) introduces copy (referred to as duplicate variable) variables for every variable in the program. Third,
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
focuses on generating a copy program over the cyclic components of the input program, while their approach duplicates the entire program. A key distinction is that the size of Boolean formulas introduced by Hecher and Kiesel (Reference Hecher and Kiesel2023) depends on the tree decomposition of the input program and its treewidth, assuming that the treewidth is small. However, most natural encodings that result in ASP programs are not treewidth-aware (Hecher Reference Hecher2022). Importantly, their work focused on theoretical treatment and, as such, does not address algorithmic aspects. It is worth noting that there is no accompanying implementation. Our personal communication with authors confirmed that they have not yet implemented their proposed technique.
6 Experimental Results
We developed a prototype of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
,Footnote
4
by leveraging existing projected model counters. Specifically, we employed GANAK (Sharma et al. Reference Sharma, Roy, Soos and Meel2019) as the underlying projected model counter, given its competitive performance in model counting competitions. All counters are sourced from the model counting competition
$2024$
.
6.1 Baseline and benchmarks
We evaluated
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
against state-of-the-art ASP systems capable of handling disjunctive answer set programs: (i) clingo v
$5.7.1$
(Gebser et al. Reference Gebser, Kaufmann and Schaub2012), (ii) DynASP v
$2.0$
(Fichte et al. Reference Fichte, Hecher, Morak and Woltran2017), and (iii) Wasp v
$2$
(Alviano et al. Reference Alviano, Dodaro, Leone and Ricca2015). ASP solvers clingo and Wasp count answer sets via enumeration. We were unable to baseline against existing ASP counters such as aspmc+#SAT (Eiter et al. Reference Eiter, Hecher and Kiesel2024), lp2sat+#SAT (Janhunen Reference Janhunen2006; Janhunen and Niemelä Reference Janhunen and Niemelä2011), sharpASP (Kabir et al. Reference Kabir, Chakraborty and Meel2024), and iascar (Fichte et al. Reference Fichte, Gaggl, Hecher and Rusovac2024), as these systems are designed exclusively for counting answer sets of normal logic programs. Since no implementation is available for the counting techniques outlined by Hecher and Kiesel (Reference Hecher and Kiesel2023), a comparison against their approach was not possible. We also considered ApproxASP (Kabir et al. Reference Kabir, Everardo, Shukla, Hecher, Fichte and Meel2022) for comparison purposes and the result is provided in the extended version.
Our benchmark suite comprised non-tight disjunctive logic program instances previously used to evaluate disjunctive answer set solvers. These benchmarks span diverse computational problems, including (i)
$2$
QBF (Kabir et al. Reference Kabir, Everardo, Shukla, Hecher, Fichte and Meel2022), (ii) strategic companies (Lierler Reference Lierler2005), (iii) preferred extensions of abstract argumentation (Gaggl et al. Reference Gaggl, Manthey, Ronca, Wallner and Woltran2015), (iv) pc configuration (Fichte et al. Reference Fichte, Gaggl and Rusovac2022), (v) minimal diagnosis (Gebser et al. Reference Gebser, Schaub, Thiele, Usadel and Veber2008), and (vi) minimal trap spaces (Trinh et al. Reference Trinh, Benhamou, Pastva and Soliman2024). The benchmarks were sourced from abstract argumentation competitions, ASP competitions (Gebser et al. Reference Gebser, Maratea and Ricca2020) and from Kabir et al. (Reference Kabir, Everardo, Shukla, Hecher, Fichte and Meel2022) and Trinh et al. (Reference Trinh, Benhamou, Pastva and Soliman2024). Following recent work on disjunctive logic programs (Alviano et al. Reference Alviano, Amendola, Dodaro, Leone, Maratea and Ricca2019), we generated additional non-tight disjunctive answer set programs using the generator implemented by Amendola et al. (Reference Amendola, Ricca and Truszczynski2017). The complete benchmark set comprises
$1125$
instances.
6.2 Environmental settings
All experiments were conducted on a computing cluster equipped with AMD EPYC
$7713$
processors. Each benchmark instance was allocated one core, with runtime and memory limits set to
$5000$
seconds and
$8$
GB, respectively, for all tools, which is consistent with prior works on model counting and answer set counting.
6.1.1 Experimental results
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
demonstrated significant performance improvement across the benchmark suite, as evidenced in Table 1. For comparative analysis, we present both the number of solved instances and PAR
$2$
scores (Balyo et al. Reference Balyo, Heule and Järvisalo2017), for each tool.
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
achieved the highest solution count while maintaining the lowest PAR
$2$
score, indicating superior scalability compared to existing systems capable of counting answer sets of disjunctive logic programs. The comparative performance of different counters is shown in a cactus plot in Figure 2.
Table 1.
The performance of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
vis-a-vis existing disjunctive answer set counters, based on
$1125$
instances


Fig. 2. The runtime performance of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
vis-a-vis other ASP counters.
Given clingo’s superior performance on instances with few answer sets, we developed a hybrid counter integrating the strengths of clingo’s enumeration and other counting techniques, following the experimental evaluation of Kabir et al. (Reference Kabir, Chakraborty and Meel2024). This hybrid approach first employs clingo enumeration (maximum
$10^4$
answer sets) and switches to alternative counting techniques if needed. Within our benchmark instances, a noticeable shift was observed on clingo’s runtime performance when the number of answer sets exceeds
$10^4$
. As shown in Table 2, the hybrid counter based on
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
significantly outperforms baseline approaches.
The cactus plot in Figure 2 illustrates the runtime performance of the four tools, where a point
$(x,y)$
indicates that a tool can count
$x$
instances within
$y$
seconds. The plot shows
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
’s clear performance advantage over state-of-the-art answer set counters for disjunctive logic programs.
Since clingo and Wasp employ enumeration-based techniques, their performance is inherently constrained by the answer set count. Our analysis revealed that clingo (resp. Wasp) timed out on nearly all instances with approximately
$2^{30}$
(resp.
$2^{24}$
) or more answer sets, while
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
can count instances upto
$2^{127}$
answer sets. However, the performance of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
is primarily influenced by the hardness of the projected model counting, which is related to the cyclicity of the program. The cyclicity of a program is quantified using the measure
$|\mathsf{LA}(P)|$
.
Table 2.
The performance comparison of hybrid counters, based on
$1125$
instances. The hybrid counters correspond to last
$3$
columns that employ clingo enumeration followed by ASP counters. The clingo (
$2$
nd column) refers to clingo enumeration for
$5000$
seconds

To analyze
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
’s performance relative to
$|\mathsf{LA}(P)|$
, we compared different ASP counters across varying ranges of loop atoms. The results in the Table 3 indicate that while
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
performs exceptionally well on instances with fewer loop atoms, its performance deteriorates significantly for instances with a higher number of loop atoms (e.g., those with
$|\mathsf{LA}(P)| \gt 1000$
), leading to a decrease in the solved instances count.
Table 3. The performance comparison of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
(SA) vis-a-vis existing disjunctive answer set counters across instances with varying numbers of loop atoms. The second column (
$\sum$
) indicates the number of instances within each range of
$|\mathsf{LA}(P)|$

To further analyze the performance of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
, we compare the number of answer sets for each instance solved by different ASP counters. Since both clingo and Wasp count using enumeration, clingo and Wasp can handle instances with up to
$2^{30}$
and
$2^{24}$
answer sets (roughly), respectively, whereas
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
is capable of counting instances having
$2^{127}$
answer sets. Due to its use of projected model counting,
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
demonstrates superior scalability on instances with a large number of answer sets.
Further experimental evaluation of
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
are provided in the extended version.
7 Conclusion
In this paper, we introduced
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
, a novel answer set counter based on subtractive reduction. By leveraging an alternative definition of answer sets,
$\mathsf{sharpASP}$
-
$\mathcal{SR}$
achieves significant performance improvements over baseline approaches, owing to its ability to rely on the scalability of state-of-the-art projected model counting techniques. Our experimental results demonstrate the effectiveness and efficiency of our approach across a range of benchmarks.
The use of subtractive reductions for empirical efficiency opens up potential avenues for future work. In particular, an interesting direction would be to categorize problems that can be reduced to #SAT via subtractive methods, which would allow us to utilize existing #SAT model counters.