---
title: 'SharpASP-SR: Exact Counting for Disjunctive ASP'
url: https://www.emergentmind.com/topics/sharpasp-sr
type: topic
---

# SharpASP-SR: Exact Counting for Disjunctive ASP

SharpASP-SR is an exact counter for disjunctive answer set programs that computes the number of answer sets $|AS(P)|$ by a subtractive reduction to projected propositional model counting. It was introduced as a framework for making counting in disjunctive ASP practically feasible without relying on loop-formula-style encodings that can become exponentially large. Its central technical idea is an alternative characterization of answer sets in which non-stability can be witnessed by unjustified loop atoms only; this makes it possible to construct polynomial-size intermediate formulas and to exploit recent projected model counting technology effectively [2507.11655].

## 1. Problem domain and formal setting

SharpASP-SR operates on finite propositional disjunctive logic programs. In this setting, a rule has the form
$$
a_1 \vee \ldots a_k \leftarrow b_1, \ldots, b_m, \textsf{not } c_1, \ldots, \textsf{not } c_n
$$
and a program is disjunctive if some rule has at least two head atoms. The task is exact counting of answer sets, not satisfiability checking and not bounded enumeration. For an interpretation $M \subseteq at(P)$, the semantic difficulty is that modelhood is insufficient: $M$ must satisfy the program and also be minimal with respect to the Gelfond–Lifschitz reduct
$$
P^M = \{Head(r) \leftarrow Body(r)^+ \mid r \in P,\; Body(r)^- \cap M = \emptyset\}.
$$
Thus $M$ is an answer set iff
$$
M \models P \quad\text{and}\quad \not\exists M' \subset M \text{ such that } M' \models P^M.
$$
This minimality condition is the source of the main counting difficulty [2507.11655].

The framework is explicitly situated beyond the normal-program case. Counting answer sets of normal programs is stated to be in $\#P$ and $\#P$-complete, whereas counting answer sets of disjunctive programs lies in $\# \cdot \mathrm{coNP}$. The decision analogue exhibits the same increase in difficulty: answer-set existence for normal programs is NP-complete, while answer-set existence for disjunctive programs is $\Sigma_2^p$-complete. SharpASP-SR is designed for this harder regime and is motivated by applications in probabilistic reasoning, network reliability, answer set navigation, and trap-space counting [2507.11655].

The framework also positions itself against three unsatisfactory baseline routes. Translating disjunctive ASP to normal ASP incurs exponential overhead unless the polynomial hierarchy collapses. Clark completion plus loop formulas is valid in principle but can become practically huge on cyclic programs. Reduction to QBF counting is theoretically possible, but current QBF counting scales much worse in practice than propositional projected counting. SharpASP-SR therefore targets projected model counting as a better computational match for the complexity of the problem [2507.11655].

## 2. Semantic basis: completion, loops, and unjustified atoms

The semantic core of SharpASP-SR combines Clark completion with a loop-sensitive characterization of stability. The completion $Comp(P)$ is defined as the conjunction of three classes of formulas: unit clauses $\neg a$ for atoms with no defining head rule; implications from each rule body to the disjunctive head; and, for each atom $a$ with head occurrences $r_1,\dots,r_k$, implications of the form
$$
a \longrightarrow \bigvee_{i \in [1,k]}
\left(
\bigwedge_{\ell \in Body(r_i)} \ell
\;\wedge\;
\bigwedge_{x \in Head(r_i)\setminus\{a\}} \neg x
\right).
$$
Every answer set satisfies $Comp(P)$, but not every model of $Comp(P)$ is an answer set [2507.11655].

The positive dependency graph $DG(P)$ has one vertex per atom and an edge from $y$ to $x$ if there is a rule $r$ with $y \in Head(r)$ and $x \in Body(r)^+$. A set $L \subseteq at(P)$ is a loop if it is strongly connected in $DG(P)$ using only atoms in $L$. Atoms belonging to some loop are called loop atoms, and the set of all such atoms is denoted $LA(P)$. These loop atoms are the only atoms that need to be copied in the SharpASP-SR reduction [2507.11655].

The crucial semantic step is the restriction of non-stability witnesses to cyclic structure. For a model $M \models P$, an atom $x \in M$ is justified in $M$ if every reduct-model $M' \models P^M$ with $M' \subseteq M$ still contains $x$. The framework proves that under Clark completion, if a completion-model is not stable, then some loop atom in it is not justified. This is formalized through a satisfiability test in which non-loop atoms fixed true in $M$ are held true, false atoms are held false, and at least one true loop atom is allowed to flip:
$$
P^{M} \wedge \bigwedge_{x \in \tau_M^-} \neg x
\wedge \bigwedge_{x \in \tau_M^+ \wedge x \not \in LA(P)} x
\wedge \bigvee_{x \in \tau_M^+ \wedge x \in LA(P)} \neg x.
$$
The significance of this restriction is structural rather than merely semantic: it makes it possible to encode the minimality test without duplicating the whole program [2507.11655].

## 3. Copy construction and subtractive reduction

To avoid constructing the reduct explicitly inside the counting reduction, SharpASP-SR introduces a copy construction over loop atoms. For each loop atom $x \in LA(P)$, a fresh copy variable is introduced. The resulting $Copy(P)$ contains two kinds of implications. First, for every loop atom,
$$
x' \longrightarrow x.
$$
Second, for every rule
$$
r = a_1 \vee \ldots a_k \leftarrow b_1,\ldots,b_m,\textsf{not }c_1,\ldots,\textsf{not }c_n
$$
with $Head(r)\cap LA(P)\neq\emptyset$, the construction includes
$$
{b_1} \wedge \ldots \wedge {b_m} \wedge \neg c_1 \wedge \ldots \wedge \neg c_n
\longrightarrow
{a_1} \vee \ldots \vee {a_k},
$$
where ${x}=x'$ if $x \in LA(P)$ and ${x}=x$ otherwise. The framework proves that this copy-based check is equivalent to the reduct-based justification test on completion-models [2507.11655].

This yields the alternative characterization used by the counter. For every interpretation $M \subseteq at(P)$ such that $\tau_M \models Comp(P)$,
$$
M \in AS(P) \quad\text{iff}\quad Copy(P)_{|\tau_M} \wedge \bigvee_{x \in \tau_M^+ \wedge x \in LA(P)} \neg x' \;\text{ is UNSAT.}
$$
Answer sets are therefore exactly the completion-models that admit no witness showing that a true loop atom can be made unjustified while preserving the copy constraints [2507.11655].

The counting method is then expressed as a subtractive reduction. The overcounting formula is
$$
\Phi = Comp(P),
$$
and the surplus formula is
$$
\Psi(at(P), CV', CV^*) = Comp(P) \wedge Copy'(P) \wedge Copy^*(P) \wedge \bigwedge_{x \in LA(P)} (x' \longrightarrow x^*) \wedge \bigvee_{x \in LA(P)} (\neg x' \wedge x^*).
$$
The projected variables are
$$
X = CV' \cup CV^*.
$$
The quantity $\#\Phi$ counts all completion-models, while $\#\exists X \Psi$ counts exactly those completion-models that have a witness of non-stability. The main theorem is
$$
|AS(P)| = \#\Phi - \#\exists X \Psi.
$$
Both $\Phi$ and $\Psi$ are stated to be computable in polynomial time in $|P|$. This polynomial-size guarantee is one of the defining properties of SharpASP-SR [2507.11655].

## 4. Computational workflow and implementation

Operationally, the framework proceeds in a fixed sequence. It first constructs Clark completion as the overcount. It then computes the set of loop atoms $LA(P)$ from the positive dependency graph. For each loop atom it introduces two fresh copy layers, forming $CV'$ and $CV^*$, and builds two corresponding copy programs $Copy'(P)$ and $Copy^*(P)$. These are assembled into the projected-counting formula $\Psi$, whose purpose is to witness that a completion-model is not an answer set. Two counting calls are then required: an exact propositional model count of $\Phi = Comp(P)$ and a projected model count of $\Psi$ under projection over the copy variables [2507.11655].

The implementation leverages existing projected model counters, most notably GANAK. Appendix experiments also tested D4 and GPMC, and GANAK was reported as the best backend among those tried in this framework. The method is explicitly backend-oriented: its practical success depends on the ability to offload both exact propositional counting and projected counting to mature propositional technology [2507.11655].

The reduction has a tight structural dependence on cyclicity. Only loop atoms are duplicated, not all atoms, and only rules relevant to loop heads contribute to the copy program. This is the mechanism by which the framework avoids the exponential blow-up associated with loop formulas and whole-program duplication. A plausible implication is that the framework is especially well aligned with instances where cyclic structure is selective rather than pervasive [2507.11655].

## 5. Empirical behavior and hybrid counting

The reported experimental study uses 1125 non-tight disjunctive ASP instances drawn from 2QBF, strategic companies, preferred extensions of abstract argumentation, pc configuration, minimal diagnosis, minimal trap spaces, and additional hard random disjunctive programs generated using ART2017. The runs used AMD EPYC 7713 processors, one core per benchmark, a timeout of 5000 seconds, and an 8 GB memory limit. The main baselines were clingo v5.7.1, DynASP v2.0, and Wasp v2 [2507.11655].

The overall results reported in Table 1 are as follows.

| System | Solved | PAR2 |
|---|---:|---:|
| clingo | 708 | 4118 |
| DynASP | 89 | 9212 |
| Wasp | 432 | 6204 |
| SharpASP-SR | 825 | 2939 |

These numbers make SharpASP-SR the best-performing standalone system in the reported comparison by both solved instances and PAR2. The paper also emphasizes that the method is particularly strong when the number of answer sets is very large: clingo times out on nearly all instances with about $2^{30}$ or more answer sets, Wasp on nearly all instances with about $2^{24}$ or more, whereas SharpASP-SR can handle instances with up to about $2^{127}$ answer sets [2507.11655].

The paper also develops a hybrid counter based on the observed complementarity between enumeration and symbolic counting. The strategy is to run clingo enumeration first up to a threshold of $10^4$ answer sets and then switch to SharpASP-SR if that threshold is exceeded. The hybrid outperforms all compared combinations.

| Hybrid system | Solved | PAR2 |
|---|---:|---:|
| clingo | 708 | 4118 |
| clingo($\le 10^4$) + DynASP | 377 | 4790 |
| clingo($\le 10^4$) + Wasp | 442 | 4404 |
| clingo($\le 10^4$) + SharpASP-SR | 918 | 1600 |

A key caveat is that performance degrades with the number of loop atoms. When instances are partitioned by $|LA(P)|$, SharpASP-SR solves 386 of 399 instances in the range $[1,100]$, 398 of 519 in $[101,1000]$, and only 41 of 207 when $|LA(P)|>1000$. The reported bottleneck is therefore not simply “many answer sets,” but rather highly cyclic structure as measured by loop atoms [2507.11655].

## 6. Relation to sharpASP and main limitations

A closely related predecessor is sharpASP, an exact ASP counting framework for normal logic programs. That earlier framework introduced an alternative definition of answer sets based on satisfying Clark completion and a separate copy formula, introduced copy variables only for loop atoms, and adapted deterministic splitting, component decomposition, and component caching from propositional model counting. It did not, however, explicitly define a variant named SharpASP-SR [2312.11936]. A plausible implication is that SharpASP-SR inherits the compact-encoding orientation of sharpASP while extending the counting architecture to disjunctive programs through subtractive reduction and projected counting rather than the earlier direct normal-program formulation [2312.11936].

SharpASP-SR’s limitations are stated explicitly. Its performance deteriorates when $|LA(P)|$ is large, since the copy machinery and projected counting instance become harder on very cyclic programs. The method also depends strongly on the quality of the projected model counting backend. Its completion-based design counts models of $Comp(P)$ and then subtracts the surplus, so practical efficiency depends on both parts of the reduction being manageable for the backend. Finally, some theoretically related approaches could not be compared empirically because they either target normal programs only or have no implementation [2507.11655].

The framework’s place in the ASP-counting landscape is therefore specific. It is not an enumeration method, not a QBF-based method, and not a loop-formula compiler in the usual sense. Its defining identity is the formula
$$
|AS(P)| = \#Comp(P) - \#\exists (CV' \cup CV^*)\,\Psi,
$$
together with the semantic observation that non-stability in completion-models can be witnessed through unjustified loop atoms only. Within the reported evaluation, that combination yields the best standalone performance on disjunctive benchmarks and the best overall performance when integrated into a hybrid with bounded enumeration [2507.11655].

Source: https://www.emergentmind.com/topics/sharpasp-sr