---
title: 'ASP-FZN: CASP Solver via FlatZinc'
url: https://www.emergentmind.com/topics/asp-fzn
type: topic
---

# ASP-FZN: CASP Solver via FlatZinc

Searching arXiv for the specified paper to ground the article in the current record.
ASP-FZN is a translation-based solver for Constraint Answer Set Programming (CASP) that extends Answer Set Programming (ASP) with linear constraints and translates CASP programs into the solver-independent FlatZinc language, thereby enabling the use of several Constraint Programming and Integer Programming backend solvers [2507.22774]. In the formulation presented by Eiter et al., the system combines ASP grounding through gringo’s theory interface with a FlatZinc compilation pipeline and backend solving via MiniZinc, while supporting a rich language of linear constraints, some common global constraints, and optimization over both ASP atoms and linear terms [2507.22774].

## 1. Formal CASP framework

A CASP program $P$ in ASP-FZN extends ordinary ground ASP by three classes of constructs: domain constraints of the form $v \in [l,u]$ for a linear integer variable $v$; linear constraints of the form $a \leftrightarrow w_1 \cdot v_1 + \cdots + w_n \cdot v_n \circ g$, where $a$ is a Boolean atom, the $v_i$ are integer variables, $w_i,g \in \mathbb{Z}$, and $\circ \in \{<,>,=,\neq,\le,\ge\}$; and global constraints represented as theory atoms via gringo’s interface, namely `alldifferent`, `disjoint`, and `cumulative` [2507.22774].

Semantically, ASP-FZN uses an extended interpretation $\mathcal{I}=(I,\delta)$, where $I \subseteq \mathrm{Atoms}$ assigns truth values to propositional atoms and $\delta(v)$ assigns integers to CASP variables. The semantics requires that every domain constraint $v \in [l,u]$ holds, that each linear constraint $a \leftrightarrow \sum_i w_i \delta(v_i) \circ g$ satisfies the stated equivalence between atom membership and arithmetic truth, and that $I$ is an answer set of the propositional part $\hat{P}$ obtained by treating each linear constraint as a theory atom [2507.22774]. When minimization statements are present, either in the form `min a₁:w₁, …, aₖ:wₖ` or `min v₁·w₁+⋯+vₙ·wₙ`, ASP-FZN selects an extended interpretation minimizing the corresponding weighted sum [2507.22774].

This design places ASP-FZN within the CASP line of work in which stable-model reasoning over propositional structure is coupled to numeric feasibility over integer variables. A plausible implication is that the formal split between $I$ and $\delta$ is central to the translation architecture, because it permits propositional supportedness and ranking conditions to be expressed alongside reified arithmetic constraints in FlatZinc.

## 2. Translation into FlatZinc

ASP-FZN first uses gringo’s theory interface to ground a program into ASPIF with theory atoms for linear and global constraints, and then applies the translation
$$
\mathrm{Tr}(P) = \mathrm{TrRk}(P) \cup \bigcup_{r \in P}\mathrm{TrRule}(r) \cup \mathrm{TrSupp}(P)
$$
into a low-level FlatZinc model [2507.22774]. The translation therefore combines ranking constraints, per-rule encodings, and supportedness constraints in a single target representation.

The ranking component $\mathrm{TrRk}(P)$ introduces, for each atom $a$ in a non-trivial SCC, an integer variable $\ell_a \in [1 \ldots |\mathrm{SCC}(a)|+1]$ and enforces
$$
\ell_a \le |\mathrm{SCC}(a)| \leftrightarrow a \tag{5}
$$
so that $\ell_a=|\mathrm{SCC}(a)|+1$ exactly when $a=\mathrm{false}$ [2507.22774]. For each positive dependency $(a \to b)$ in the SCC, a Boolean $\mathrm{dep}_{a,b}$ is added together with
$$
\ell_a-\ell_b \ge 1 \leftrightarrow \mathrm{dep}_{a,b}. \tag{6}
$$
To guarantee that rankings are strict and gap-free, ASP-FZN further introduces auxiliary atoms $y_{a,b}$ and $\mathrm{gap}_{a,b}$ via
$$
\ell_a-\ell_b \ge 2 \leftrightarrow y_{a,b}, \qquad a \land b \land y_{a,b} \leftrightarrow \mathrm{gap}_{a,b}. \tag{7}
$$

The body translation distinguishes several rule classes. For a constraint rule with normal body, ASP-FZN emits the clausal FlatZinc constraint
$$
\bigvee_{b\in B^+(r)} \neg b \;\;\vee\;\; \bigvee_{b\in B^-(r)} b. \tag{8}
$$
For a weighted-body constraint
$$
l \le \{b_1:w_1,\ldots,b_k:w_k,\neg b_{k+1}:w_{k+1},\ldots,\neg b_n:w_n\},
$$
the translation uses the pseudo-Boolean constraint
$$
\sum_{b\in B^+(r)}w_b \cdot b + \sum_{b\in B^-(r)}w_b \cdot b \le l-1. \tag{9}
$$
When the rule has a nonempty head, an auxiliary Boolean $\mathrm{bd}_r$ is introduced. In the tight case, ASP-FZN applies Clark completion through
$$
\left(\bigwedge_{b\in B^+} b \land \bigwedge_{b\in B^-}\neg b \right)\leftrightarrow \mathrm{bd}_r \tag{10}
$$
or, for weighted bodies,
$$
\left(\sum_{b\in B^+}w_b\cdot b + \sum_{b\in B^-}w_b\cdot b \ge l\right)\leftrightarrow \mathrm{bd}_r. \tag{11}
$$
In the non-tight case, the translation refines $\mathrm{bd}_r$ into internal and external support booleans and combines them with ranking-based conditions through formulas (12)–(14), including an auxiliary $\mathrm{aux}_r^a$, the disjunctive condition $\mathrm{ext}_r^a \vee \mathrm{aux}_r^a \vee \neg \mathrm{int}_r^a$, and the definition $\mathrm{bd}_r^a \leftrightarrow (\mathrm{ext}_r^a \vee \mathrm{int}_r^a)$ [2507.22774].

For heads, ASP-FZN introduces support atoms $\mathrm{sp}_r^a$ for each $a \in H(r)$. In normal, disjunctive, or choice heads, it uses
$$
\mathrm{sp}_r^a \leftrightarrow \mathrm{bd}_r \tag{15}
$$
when the head is singleton or $a$ is locally tight, and
$$
\mathrm{bd}_r \land \bigwedge_{b\in H(r)\setminus\{a\}}\neg b \leftrightarrow \mathrm{sp}_r^a \tag{16}
$$
for disjunctions [2507.22774]. It also imposes the rule-satisfaction condition
$$
\bigvee_{a\in H(r)} a \;\;\vee\;\; \neg \mathrm{bd}_r. \tag{17}
$$
Finally, supportedness is enforced globally by
$$
\left(\bigvee_{r:a\in H(r)} \mathrm{sp}_r^a\right) \vee \neg a. \tag{18}
$$

The paper states that Theorems 4.6–4.8 prove that, for head-cycle-free $P$, the models of $\mathrm{Tr}(P)$ correspond one-to-one to the CASP answer sets of $P$ under this reified, ranking, and completion embedding [2507.22774]. This establishes the translation not merely as an implementation device but as a semantic reduction.

## 3. Supported language and encodings

ASP-FZN’s input language, exposed via gringo theory syntax, supports integer variables and domain constraints through `&dom{l..u}=v`; linear constraints through `&sum{…}=g` or the relations `≤, ≥, ≠, <, >`; minimization on ASP atoms with `#minimize{…}`; minimization on linear sums with `&minimize{…}`; and the global constraints `&distinct{v₁,…,vₙ}`, `&disjoint{start(J)@dur(J)}`, and `&cumulative{(s,l,r)} ≤ G` [2507.22774].

These constructs are compiled into FlatZinc via reified primitives. Each `&sum` is expanded into reified linear constraints as in formulas (9)–(11). Each `&distinct` becomes a sequence of pairwise inequality constraints $\forall i<j: v_i \neq v_j$. Each `&disjoint` is flattened into the FlatZinc global propagator `constraint disjoint(...)`, and each `&cumulative` into `cumulative(...)` [2507.22774]. Minimization objectives over atoms and variables are collected into a single FlatZinc objective by summing weak-constraint weights and linear terms.

The following table summarizes the language features explicitly listed in the source.

| Construct | Input form | FlatZinc-oriented encoding |
|---|---|---|
| Domain constraint | `&dom{l..u}=v` | Integer variable with domain |
| Linear constraint | `&sum{…}=g`, `≤, ≥, ≠, <, >` | Reified linear constraints |
| Atom minimization | `#minimize{…}` | Single summed objective |
| Linear minimization | `&minimize{…}` | Single summed objective |
| Distinctness | `&distinct{v₁,…,vₙ}` | Pairwise inequalities |
| Disjointness | `&disjoint{start(J)@dur(J)}` | `constraint disjoint(...)` |
| Cumulative resource bound | `&cumulative{(s,l,r)} ≤ G` | `cumulative(...)` |

A notable aspect of the language support is that some global constraints are preserved at the FlatZinc level rather than decomposed entirely into primitive linear constraints. This suggests that ASP-FZN is designed to leverage backend propagators where available, while still expressing propositional ASP structure through a uniform reified encoding.

## 4. Architecture and backend integration

ASP-FZN is implemented in Rust and consists of three stages: grounding from non-ground files to ASPIF plus theory atoms via gringo; translation from ASPIF plus theory atoms to FlatZinc via $\mathrm{Tr}(P)$; and solving from FlatZinc through MiniZinc to a chosen backend solver [2507.22774]. Supported backends include CP-SAT from OR-Tools, Chuffed as a lazy-clause-generation CP solver, and Gurobi as a MIP backend [2507.22774].

By default, ASP-FZN invokes MiniZinc 2.9.2 to drive the selected solver, with solver identifiers such as `--solver-id cp-sat`, `org.chuffed.chuffed`, and `gurobi` [2507.22774]. The system supports both strict and non-strict ranking. Strict ranking enforces a one-to-one mapping, whereas non-strict ranking may collapse multiple rankings to one flat solution [2507.22774]. Minimization is handled through the FlatZinc objective, and output can take the form of enumeration of all answer sets or optimization search [2507.22774].

This architecture is solver-independent at the FlatZinc interface, but not solver-agnostic in performance terms. The availability of CP, lazy-clause-generation CP, and MIP backends implies that ASP-FZN can expose the same translated model to substantially different solving paradigms. A plausible implication is that the quality of the translation, particularly the amount of auxiliary structure induced by rankings and supportedness, strongly influences which backend performs best.

## 5. Empirical performance

The evaluation reported for ASP-FZN has two parts: plain ASP benchmarks from recent ASP competitions and several CASP problems from the literature [2507.22774]. For plain ASP, the benchmark set consists of 31 domains and 772 instances, and the comparison includes ASP-FZN with CP-SAT, Chuffed, and Gurobi backends against clingo 5.7.1 and DLV 2.1.0 on decision and optimization variants [2507.22774]. The reported aggregate measures are `Score₁ = fraction of instances solved (×100)`, `Score₂ = fraction where solver ties best known`, and `PAR10 = average runtime with 10× penalty for timeouts` [2507.22774].

| Solver | Score₁ | Score₂ | PAR10 |
|---|---:|---:|---:|
| clingo (1 thread) | 1890.4 | 1992.1 | 147786.8 |
| asp-fzn(cp-sat, strict) | 1840.0 | 1888.3 | 153738.5 |
| asp-fzn(cp-sat, non-strict) | 1871.7 | 1978.3 | 149807.9 |
| asp-fzn(chuffed, non-strict) | 812.4 | 812.4 | 275942.3 |
| asp-fzn(gurobi, non-strict) | 1265.0 | 1290.0 | 222057.8 |
| DLV | 1524.4 | 1604.4 | 191445.8 |

In single-threaded mode, the paper states that CP-SAT-backed ASP-FZN is competitive with clingo and only approximately 1.4% worse in PAR10, while non-strict ranking improves performance over strict ranking [2507.22774]. On 8 threads, clingo still leads, but ASP-FZN with CP-SAT narrows the gap [2507.22774].

For CASP benchmarks, the comparison is against clingcon 5.2.1 on three representative encodings: Parallel Machine Scheduling (PMSP, 500 instances), Test Laboratory Scheduling (TLSPS, 123 instances), and Multi-Agent Path Finding (MAPF, 547 instances) [2507.22774]. On PMSP with one thread, ASP-FZN+CP-SAT using non-strict ranking closed 40/500, was best on 166, and had PAR10 = 11051.4; clingcon closed 36/500 with PAR10 = 11147.8 [2507.22774]. On 8 threads, ASP-FZN+CP-SAT closed 54/500 and was best on 167, whereas clingcon closed 31/500 and was best on 298 by finding many good incumbents in parallel [2507.22774].

On TLSPS, ASP-FZN+CP-SAT, where strict and non-strict coincide in the reported setting, closed 55 instances, was best on 76, and had PAR10 = 6741.5; clingcon closed 7 and was best on 22 [2507.22774]. With 8 threads, clingcon leads with 77 closed, 90 best, and PAR10 = 4553.3 versus ASP-FZN+CP-SAT with 64 closed and 76 best [2507.22774]. On MAPF, ASP-FZN+CP-SAT closed 224 instances with PAR10 = 7116.6 in one thread and 233 with PAR10 = 6913.4 in 8 threads, while clingcon closed 177 with PAR10 = 8138.1 in one thread and 209 with PAR10 = 7428.2 in 8 threads [2507.22774].

The reported summary is that ASP-FZN with CP-SAT is competitive on plain ASP, outperforms clingcon on TLSPS and MAPF, especially in single-threaded PAR10, and is promising on PMSP when proving optimality, although clingcon’s multi-thread search often finds good incumbents faster [2507.22774]. This suggests that ASP-FZN’s translation overhead does not preclude strong performance even on plain ASP workloads, despite being designed for CASP.

## 6. Worked example and operational behavior

The paper presents a running example program $P_2$ consisting of the rules

```prolog
{a;b} :- c.
:- 3 ≤ #sum{1:a; 2:b}.
c :- d.
&dom{0..2}=x.
&dom{0..1}=y.
d :- &sum{x;y} != 3.
```

together with the command

```bash
asp-fzn -s cp-sat -a example.lp
```

[2507.22774]. The described execution flow is that ASP-FZN calls gringo, grounds with theory atoms, applies $\mathrm{Tr}(P_2)$, emits FlatZinc, invokes CP-SAT, and produces all extended answer sets [2507.22774]. The example outputs include
`{ d, val(y,1) }`,
`{ d, val(x,1), val(y,1) }`,
`{ c, val(x,2), val(y,1) }`,
and
`{ c,a,val(x,2),val(y,1) }`
[2507.22774].

The auxiliary predicate `val(v,V)` is introduced to enumerate $\delta(v)=V$ [2507.22774]. In operational terms, this makes the numeric component of an extended interpretation explicit in answer-set output. A plausible implication is that the output format is intended to preserve a conventional ASP-facing interface even though the underlying solving step is delegated to a FlatZinc backend.

## 7. Limitations and prospective extensions

The paper identifies several limitations. First, memory footprint can be significant: CP-SAT in particular may use large amounts of memory on big FlatZinc models, and ASP-FZN occasionally hits system limits where native ASP systems do not [2507.22774]. Second, performance degrades as disjunction and non-tightness increase, although the completion and ranking translation remains competitive in many cases and works best for head-cycle-free programs [2507.22774]. Third, the current support for global constraints is limited to `alldifferent`, `disjoint`, and `cumulative` [2507.22774].

The distinction between strict and non-strict ranking is also presented as a trade-off. Non-strict ranking yields somewhat better pruning in practice, but it breaks one-to-one correspondence when the goal is to enumerate all distinct rankings rather than just all sets $I$ [2507.22774]. This clarifies a potential misconception: non-strict ranking is not merely an implementation tweak, but a choice that affects correspondence properties at the level of translated solutions.

Several future avenues are explicitly listed: vertex elimination techniques attributed to Rankooh and Janhunen (2024) to reduce auxiliary variables; integration of local-search or hybrid MiniZinc solvers, including CP-SAT used purely heuristically; translations for alternative CASP semantics such as ASP(AC) and hybrid semantics by Cabalar et al.; and incremental and multi-shot CASP solving leveraging gringo multishot [2507.22774]. These directions indicate that ASP-FZN is situated both as a concrete solver and as a platform for exploring alternative semantic embeddings and backend combinations within CASP.

Source: https://www.emergentmind.com/topics/asp-fzn