#
On the Semantics of Hybrid ASP Systems Based on `Clingo`

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

`clingo`’s theory-reasoning framework precise. This provides us with a formal framework in which we can elaborate upon the formal properties of existing hybridizations of

`clingo`, such as

`clingcon`,

`clingo`[dl], and

`clingo`[lp].

## 1. Introduction

`clingo`[3].

`clingo`or

`dlvhex`[15] leave the choice of the specific theory largely open. For instance,

`clingo`merely requires fixing the interaction between theories and their theory atoms. As attractive as this generality may be from an implementation point of view, it complicates the development of generic semantics that are meaningful to existing systems. Not to mention that in ASP, the integration of theories takes place in a non-monotonic context.

`clingcon`,

`clingo`[dl], and

`clingo`[lp], can be accommodated as instances of this general framework.

## 2. Background

`clingo`, these theory atoms are expressions preceded by ‘&’, but their internal syntax is not predetermined: it can be defined by the user to build new extensions. As an example, the system

`clingcon`extends the input language of

`clingo`with linear equations, represented as theory atoms of the form

`<=`,

`=`,

`!=`,

`<`,

`>`,

`>=`. As we said above, we may have two different theory atoms, such as $\&\mathtt{sum}\left\{x\right\}>0$ and $\&\mathtt{sum}\left\{\mathtt{x}\right\}>=1$, actually representing the same condition (as a linear equation).

`clingcon`, whose theory atoms correspond to linear integer equations. We refer to logic programs augmented by such theory atoms as

`clingcon`-programs.

`clingo`[16], used for several extensions such as the addition of difference constraints in

`clingo`[dl], of linear equations over integers in

`clingcon`, and over reals in

`clingo`[lp]. In all these systems, we can see the role of the corresponding external theory as a kind of “certification authority” that sanctions regular stable models whose theory atoms are in accord with their underlying constraints. To this end, we envisage a two-step process: (1) generate regular stable models and (2) select the ones passing the theory certification. In step (1), we ignore the distinction between atoms in $\mathcal{A}$ and $\mathcal{T}$ and plainly apply the stable model semantics [2]. More precisely, a set $X\subseteq \mathcal{A}\cup \mathcal{T}$ of atoms is a model of a $\mathcal{T}$-logic program P over $\langle \mathcal{A},\mathcal{T}\rangle $, if, for every rule $r\in P$ such that ${\mathit{B}\left(r\right)}^{+}\subseteq X$ and ${\mathit{B}\left(r\right)}^{-}\cap X=\varnothing $, we have $\mathit{h}\left(r\right)\in X$. In the case of an integrity constraint with $h\left(r\right)=\perp $, note that ⊥ does not belong to $X\subseteq \mathcal{A}\cup \mathcal{T}$. The stable models of P are defined via the reduct of P relative to a set X of atoms, viz.

`clingcon`-program containing both atoms $\&\mathtt{sum}\{x;2\ast y\}>9$ and $\&\mathtt{sum}\{2\ast x;4\ast y\}<=6$. This stable model would not pass theory certification since no values for integer variables x and y can satisfy both corresponding linear equations, viz. $x+2y>9$ and $2x+4y\le 6$ (note that the latter is equivalent to $x+2y\le 3$).

`clingo`’s semantics for $\mathcal{T}$-logic programs as follows [16]: Informally speaking, a $\mathfrak{T}$-solution S is a subset $S\subseteq \mathcal{T}$ of theory atoms whose associated constraints are “sanctioned” by abstract theory $\mathfrak{T}$; this is made precise in Section 3. A set $X\subseteq \mathcal{A}\cup \mathcal{T}$ of atoms is a $\mathfrak{T}$-stable model of a $\mathcal{T}$-logic program P over $\langle \mathcal{A},\mathcal{T},\mathcal{E}\rangle $, if there is some $\mathfrak{T}$-solution S such that X is a stable model of the logic program

`clingcon`-program ${P}_{(4/5)}$:

## 3. Transformation-Based Semantics Revisited

`clingo`that allows for formal elaborations of $\mathcal{T}$-logic programs. To this end, we introduce the concept of an abstract theory $\mathfrak{T}$, which is our key instrument for establishing more fine-grained formal foundations. With it, we revisit the transformation-based approach and give a formal account of $\mathfrak{T}$-solutions.

#### 3.1. Abstract Theories

- inconsistent, if both $\mathtt{s}\in S$ and $\stackrel{\u23dc}{\mathtt{s}}\in S$ for some atom $\mathtt{s}$, (consistent otherwise)
- $\mathcal{Z}$-complete for some subset $\mathcal{Z}\subseteq \mathcal{T}$, if for all $\mathtt{s}\in \mathcal{Z}$, either $\mathtt{s}\in S$ or $\stackrel{\u23dc}{\mathtt{s}}\in S$, and
- closed, if $\mathtt{s}\in S$ implies $\stackrel{\u23dc}{\mathtt{s}}\in S$.

`clingcon`programs, where

- $\mathcal{T}$ is the set of all expressions of form (1),
- $\mathit{Sat}$ is the set of all subsets $S\subseteq \mathcal{T}$ of expressions of form (1) for which there exists an assignment of integer values to their variables that satisfies all the linear equations in S with their usual meaning, and
- the complement function is defined such as $\stackrel{\u23dc}{\&\mathtt{sum}\{\cdots \}\prec c}$ is $\&\mathtt{sum}\{\cdots \}\stackrel{\u23dc}{\prec}c$ with $\stackrel{\u23dc}{\prec}$ defined according to the following table:

≺ | <= | = | != | < | > | >= |

$\stackrel{\u23dc}{\prec}$ | > | != | = | >= | <= | < |

`clingo`[dl]-programs, we introduce abstract theory $\mathfrak{D}$ capturing difference constraints over integers, which is a subset of the already seen abstract theory $\mathfrak{L}$ where theory atoms have the fixed form $\&\mathtt{sum}\{1\ast x;(-1)\ast y\}<=\phantom{\rule{0.166667em}{0ex}}k$ but are rewritten instead as:

**Definition**

**1**(Abstract Entailment)

**.**

#### 3.2. Stable Models of Logic Programs with Abstract Theories

**Definition**

**2**($\langle \mathfrak{T},\mathcal{E}\rangle $-solution)

**.**

**Proposition**

**1.**

- 1.
- ${\mathit{Comp}}_{\mathcal{E}}\left(S\right)$ is $\mathcal{E}$-complete and is also a$\langle \mathfrak{T},\mathcal{E}\rangle $-solution.
- 2.
- If S is $\mathcal{E}$-complete, then S is $\mathfrak{T}$-satisfiable.

**Proposition**

**2.**

`clingcon`-program consisting of rules (4) and (5) with abstract theory $\mathfrak{L}$, the already seen theory atoms $\mathcal{T}=\{{\mathtt{s}}_{1},{\mathtt{s}}_{2},{\mathtt{s}}_{3},{\mathtt{s}}_{4}\}$, and the closed subset of external atoms $\mathcal{E}=\{{\mathtt{s}}_{1},{\mathtt{s}}_{3}\}$. This program has two $\langle \mathfrak{L},\mathcal{E}\rangle $-stable models:

**Proposition**

**3.**

## 4. Structured Theories and Answer Sets

`clingo`5 [16]. The strength of this semantic is two-fold. First, it provides an effective way to develop algorithms that connect answer set solvers with abstract theories. Second, it is very general as it puts very few requirements on the abstract theories it can be applied to. This applies to constraint answer set solvers based on

`clingo`, such as the mentioned

`clingo`[dl],

`clingcon`and

`clingo`[lp].

`clingcon`, typing the command:

`echo ″a :- &sum{ x; y } = 4. \``&sum{ y; z } = 2 :- a.″ | clingcon --heuristic=Berkmin`

`Answer: 1`

`a`

`Assignment:`

`x=4 y=0 z=2`

`Answer: 2`

`a`

`Assignment:`

`x=3 y=1 z=1`

`...`

`clingcon`enumerates it one by one, if asked for more solutions.

#### 4.1. Structured and Compositional Theories

**Definition**

**3**(Structure)

**.**

- 1.
- $\mathcal{X}$ is a set of variables,
- 2.
- $\mathcal{D}$ is a set of domain elements,
- 3.
- $\mathit{vars}:\mathcal{T}\to {2}^{\mathcal{X}}$ is a function giving the set of variables contained in a theory atom such that $\mathit{vars}\left(\mathtt{s}\right)=\mathit{vars}\left(\stackrel{\u23dc}{\mathtt{s}}\right)$ for all theory atoms $\mathtt{s}\in \mathcal{T}$,
- 4.
- $\mathcal{V}=\{v\mid v:\mathcal{X}\to \mathcal{D}\}$ is the set of all valuations over $\mathcal{X}$ and $\mathcal{D}$, and
- 5.
- $\u301a\phantom{\rule{0.166667em}{0ex}}\xb7\phantom{\rule{0.166667em}{0ex}}\u301b:\mathcal{T}\to {2}^{\mathcal{V}}$ is a function mapping theory atoms to sets of valuations such that$$v\in \u301a\phantom{\rule{0.166667em}{0ex}}\mathtt{s}\phantom{\rule{0.166667em}{0ex}}\u301b\phantom{\rule{4.pt}{0ex}}\mathrm{iff}\phantom{\rule{4.pt}{0ex}}w\in \u301a\phantom{\rule{0.166667em}{0ex}}\mathtt{s}\phantom{\rule{0.166667em}{0ex}}\u301b$$for all theory atoms $\mathtt{s}\in \mathcal{T}$ and every pair of valuations $v,w$ agreeing on the value of all variables $\mathit{vars}\left(\mathtt{s}\right)$ occurring in $\mathtt{s}$.

- ${\mathcal{X}}_{\mathfrak{L}}$ is an infinite set of integer variables,
- ${\mathcal{D}}_{\mathfrak{L}}=\mathbb{Z}$,
- ${\mathit{vars}}_{\mathfrak{L}}(\&\mathtt{sum}\{{k}_{1}\ast {x}_{1};\cdots ;{k}_{n}\ast {x}_{n}\}\prec {k}_{0})=\{{x}_{1},\cdots ,{x}_{n}\}$, and
- $\u301a\phantom{\rule{0.166667em}{0ex}}\&\mathtt{sum}\{{k}_{1}\ast {x}_{1};\cdots ;{k}_{n}\ast {x}_{n}\}\prec {k}_{0}\phantom{\rule{0.166667em}{0ex}}{\u301b}_{\mathfrak{L}}=$$$\{v\in {\mathcal{V}}_{\mathfrak{L}}\phantom{\rule{0.277778em}{0ex}}\mid \phantom{\rule{0.277778em}{0ex}}\{{k}_{1},v\left({x}_{1}\right),\cdots {k}_{n},v\left({x}_{n}\right)\}\subseteq \mathbb{Z}\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}{\sum}_{1\le i\le n}{k}_{i}\ast v\left({x}_{i}\right)\prec {k}_{0}\}.$$

**Proposition**

**4.**

**Definition**

**4**(Compositional entailment)

**.**

**Proposition**

**5.**

**Proposition**

**6.**

#### 4.2. Answer Sets of Logic Programs with Compositional Theories

`clingo`5.

**Definition**

**5**(Answer Set)

**.**

`clingcon`corresponds to the $\langle \mathfrak{L},\mathcal{E}\rangle $-answer set $({Y}_{1},{v}_{11})$ where ${Y}_{1}=\left\{a\right\}$ is a set of regular atoms and ${v}_{11}$ is the valuation $\{x=4,\phantom{\rule{0.166667em}{0ex}}y=0,\phantom{\rule{0.166667em}{0ex}}z=2\}$. Recall that the theory atoms in ${X}_{1}$ are ${\mathtt{s}}_{1}$ and ${\mathtt{s}}_{2}$, and note that ${v}_{11}$ satisfies both. Similarly, the second answer set printed by

`clingcon`corresponds to the $\langle \mathfrak{L},\mathcal{E}\rangle $-answer set $({Y}_{1},{v}_{12})$ where ${v}_{12}$ is the valuation $\{x=3,\phantom{\rule{0.166667em}{0ex}}y=1,\phantom{\rule{0.166667em}{0ex}}z=1\}$. As stated in (7), the other stable model of the program was ${X}_{2}=\left\{{\mathtt{s}}_{3}\right\}=\{\&\mathtt{sum}\{x;y\}\phantom{\rule{0.166667em}{0ex}}!=\phantom{\rule{0.166667em}{0ex}}4\}$. The answer sets for this stable model have the form $(\varnothing ,v)$ where v is assignments for the subset of variables $\{x,y\}$ occurring in ${\mathtt{s}}_{3}$, so that $v\left(x\right)+v\left(y\right)\ne 4$, such as, for instance, $\{x=0,y=0\}$ or $\{x=3,y=2\}$, to put a pair of examples. Note that the value of z in these cases is irrelevant.

`clingo`[dl] and its answer sets.

`clingo`[dl] are the following:

`Answer: 1`

`Answer: 2`

`dl(x,0) dl(y,2) a`

`clingo`[dl] selects a particular one for output, which we further discuss in Section 5.

**Proposition**

**7.**

- $b\in Y$ for regular atoms $b\in \mathcal{A}$;
- $v\in {\u301a\phantom{\rule{0.166667em}{0ex}}b\phantom{\rule{0.166667em}{0ex}}\u301b|}_{\phantom{\rule{-1.0pt}{0ex}}\mathit{domain}\left(v\right)}$ for theory atoms $b\in \mathcal{T}$.

**Proposition**

**8.**

## 5. Answer Set Solving Modulo Linear Equations

`clingo`extensions with linear equations. At first, we use the structured theory $\mathfrak{L}$ of linear equations to describe the semantics of

`clingcon`. Then, we introduce structured theories $\mathfrak{D}$ and $\mathfrak{R}$ to analogously capture

`clingo`[dl] and

`clingo`[lp]. This allows us to compare the systems and their features.

#### 5.1. `clingcon`

`clingcon`, all theory atoms are external, that is $\mathcal{E}=\mathcal{T}$, and may indistinctly occur in the head or in the body. As we already mentioned, one interesting feature of

`clingcon`is that it does not only show the $\langle \mathfrak{L},\mathcal{E}\rangle $-stable models but also allows for enumerating all $\langle \mathfrak{L},\mathcal{E}\rangle $-answer sets for those stable models.

`clingcon`. To interpret this program in our notation, we consider “

`.`” to be the separation between the rules of the program, “

`:-`” is the implication ←, “

`not`” is the negation ¬, and the choice rule

`eligible`is an abbreviation for the rule

`eligible`$\leftarrow \neg \neg $

`eligible`. The program contains one propositional variable,

`eligible`, signifying whether one is

`eligible`for a tax deduction, and three integer variables tax, deduction, and overall that are used in theory atoms and represent taxes before deduction, possible tax deduction, and the overall taxes to pay, respectively. Lines 1 and 2 describe the domain of the integer variables tax and deduction via theory atoms that state that tax is greater or equal to zero and smaller or equal to two, and deduction is greater or equal to zero and at most, the value of tax. Line 3 allows propositional atoms

`eligible`to be freely chosen. Overall, Lines 1 to 3 describe the solution space with six overall combinations of values for the integer variables that are doubled by the possible truth values of

`eligible`to a total of twelve combinations. In practice, these values would, of course, be subject to more complex computations. Lines 5 and 6 then calculate the value of the integer variable overall. The former, by subtracting the value of deduction from tax if

`eligible`, is true, and the latter sets overall equal to tax if

`eligible`is false.

Listing 1: clingcon-program calculating taxes |

`clingcon`-program has four $\langle \mathfrak{L},\mathcal{E}\rangle $-stable models:

`{&sum{tax}>=0, &sum{tax}<=2,``&sum{deduction}>=0, &sum{deduction}<=tax,``&sum{tax;-deduction}=overall, &sum{tax}!=overall, eligible}`

`{&sum{tax}>=0, &sum{tax}<=2,``&sum{deduction}>=0, &sum{deduction}<=tax,``&sum{tax;-deduction}=overall, &sum{tax}=overall, eligible}`

`{&sum{tax}>=0, &sum{tax}<=2,``&sum{deduction}>=0, &sum{deduction}<=tax,``&sum{tax}=overall, &sum{tax;-deduction}!=overall}`

`{&sum{tax}>=0, &sum{tax}<=2,``&sum{deduction}>=0, &sum{deduction}<=tax,``&sum{tax}=overall, &sum{tax;-deduction}=overall\}`

`deduction`can be zero, so whether we are eligible or not, we may have

`tax=tax`−

`deduction=overall`. These four $\langle \mathfrak{L},\mathcal{E}\rangle $-stable models yield the following twelve answer sets:

- &
`sum{tax`; -`deduction}`<=`overall`:-`eligible.` - &
`sum{tax`; -`deduction}`>=`overall`:-`eligible`.

`{...,&sum{tax;-deduction}<=overall, eligible``&sum{tax;-deduction}>=overall, &sum{tax}!=overall}`

`{...,&sum{tax;-deduction}<=overall, eligible``&sum{tax;-deduction}>=overall, &sum{tax}=overall}`

`{...,&sum{tax;-deduction}<overall,``&sum{tax;-deduction}<=overall, &sum{tax}=overall}`

`{...,&sum{tax;-deduction}>=overall,``&sum{tax;-deduction}<=overall, &sum{tax}=overall}`

`&sum{tax;-deduction}=overall}`by atoms

`&sum{tax;-deduction}<=overall}`and

`&sum{tax;-deduction}>=overall}`. That is, the syntactic changes in the program are carried to the $\langle \mathfrak{L},\mathcal{E}\rangle $-stable mode but not to the $\langle \mathfrak{L},\mathcal{E}\rangle $-answer sets.

`clingcon`are external, we can always apply Proposition 3 to constrain atoms in the head and shift them to the body. As an example, we can safely replace Line 5 in Listing 1 with the following constraint and retain the same stable models:

`:- not &sum{tax; -deduction} = overall, eligible.`

#### 5.2. `clingo`[dl]

`clingo`[dl] system that uses the theory $\mathfrak{D}$ in which theory atoms have the form $\&\mathtt{diff}\{\mathit{x}-\mathit{y}\}\phantom{\rule{4pt}{0ex}}<=\phantom{\rule{4pt}{0ex}}\mathit{k}$, as introduced in (6). As with $\mathfrak{L}$, the abstract theory $\mathfrak{D}$ also has a complete complement operation. However, while in linear constraints, the complementary atom would be obtained by just switching the ordering relation from ‘$<=$’ to ‘>’, in the case of $\mathfrak{D}$, the resulting construct $\&\mathtt{diff}\{x-y\}>k$ is not exactly in the format of a difference constraint, where we must always use the ‘$<=$’ relation. Fortunately, as we deal with integer numbers, we can reformulate the complement simply as $\&\mathtt{diff}\{\mathit{y}-\mathit{x}\}\phantom{\rule{4pt}{0ex}}<=\phantom{\rule{4pt}{0ex}}-\mathit{k}-\mathit{1}$. For example, the complement of $\&\mathtt{diff}\{\mathit{x}-\mathit{y}\}\phantom{\rule{4pt}{0ex}}<=\phantom{\rule{4pt}{0ex}}\mathit{5}$ would be $\&\mathtt{diff}\{\mathit{y}-\mathit{x}\}\phantom{\rule{4pt}{0ex}}<=\phantom{\rule{4pt}{0ex}}-\mathit{6}$.

`clingo`[dl], the set of external atoms $\mathcal{E}$ consists of all body atoms: atoms that do not occur in rule bodies are founded. One difference with respect to

`clingcon`is that, in this case, we do have a one-to-one correspondence between the $\mathfrak{D}$-solutions and the $\langle \mathfrak{D},\mathcal{E}\rangle $-stable models of a

`clingo`[dl]-logic program P. Another important difference is that, for a given stable model,

`clingo`[dl] does not enumerate all possible $\langle \mathfrak{D},\mathcal{E}\rangle $-answer sets but only provides one of them. This answer set corresponds to the case where all integer variables are assigned a non-negative integer with the minimal possible value. That is,

`clingo`[dl]-answer sets are a selection among the $\langle \mathfrak{D},\mathcal{E}\rangle $-answer sets of the program. Formally, to characterize this minimal answer set, we start defining a partial order ${\le}_{\mathtt{dl}}$ between two $\langle \mathfrak{D},\mathcal{E}\rangle $-answer sets $(Y,v)$ and $({Y}^{\prime},{v}^{\prime})$ as follows:

**Definition**

**6**(

`clingo`[dl]-answer set)

**.**

`clingo`[dl]-answer setof P if$(Y,v)$is${<}_{\mathtt{dl}}$-minimal among the$\langle \mathfrak{D},\mathcal{E}\rangle $-answer sets of P that do not assign a negative value to any variable.

`clingo`[dl]-program that just consists of the fact

`clingo`[dl]-answer sets do not admit negative numbers, we must further pick $x\ge 0$, leaving the possible answer sets shown in Figure 1, where each pair of numbers $(c,d)$ represents the valuation $x=c$, $y=d$. The arrows show the ${<}_{\mathtt{dl}}$ relations among them. In this case, there exists a unique

`clingo`[dl]-answer set corresponding to the valuation $x=0,y=2$.

#### 5.3. `clingo`[lp]

`clingo`[lp]. In this case, the abstract theory $\mathfrak{R}$ is about linear equations over reals. It is identical to $\mathfrak{L}$ but structured by $({\mathcal{X}}_{\mathfrak{R}},{\mathcal{D}}_{\mathfrak{R}},{\mathit{vars}}_{\mathfrak{L}},\u301a\phantom{\rule{0.166667em}{0ex}}\xb7\phantom{\rule{0.166667em}{0ex}}{\u301b}_{\mathfrak{L}})$ where ${\mathcal{X}}_{\mathfrak{R}}$ is an infinite set of real variables and the domain ${\mathcal{D}}_{\mathfrak{R}}$ is the set of real numbers $\mathbb{R}$. Previous versions of

`clingo`[lp] treated either all theory atoms as external, $\mathcal{E}=\mathcal{T}$, or founded, $\mathcal{E}=\varnothing $. Since it imposes no restriction on the occurrence of linear equation atoms; the counter-intuitive behavior identified in [14] may emerge. The current version behaves like

`clingo`[dl] and treats body atoms as external and head atoms as founded. Another commonality with

`clingo`[dl] is a selection among the $\langle \mathfrak{R},\mathcal{E}\rangle $-answer sets that are printed. In the case of

`clingo`[lp], the selection is configurable by the user via a directive with a linear term:

**Definition**

**7**(

`clingo`[lp]-answer set)

**.**

`clingo`[lp]-answer set ofP if$(Y,v)$is${<}_{\mathtt{lp}}$-minimal among the$\langle \mathfrak{R},\mathcal{E}\rangle $-answer sets of P.

`clingo`[lp] only outputs the answer set where $\mathtt{x}=0$.

## 6. Discussion and Related Work

#### 6.1. Black Box Orientation

`clingcon`-programs.

`dingo`[20],

`mingo`[21], and

`ezsmt`[22]. As happens with

`clingo`[dl], system

`dingo`[20] deals with ASP modulo difference logic but is actually based on a translation into SMT. In

`dingo`, theory atoms are not external (they need to be derived), but they do not completely fit into our category of defined either, in the sense that SMT variables cannot be undefined. System

`ezsmt`[22] is also based on a translation into SMT but accepts linear and non-linear constraints over mixed real and integer variables, whereas

`mingo`[21] translates ASP modulo mixed-integer linear programming (MILP) to plain MILP. In these two systems, all theory atoms are external and may only appear in the body.

`ezcsp`[19], where all theory atoms are defined and may only occur in the head, deviating from the standard CASP definition.

#### 6.2. White Box Orientation

## 7. Summary

`clingo`with different forms of linear equations. To this end, we extended logic programs with very general abstract theories without any predefined syntax. To characterize the interplay between theory atoms and their corresponding constraints, we extended the semantics of such programs and distinguished between defined and external theory atoms. Defined theory atoms have to be derived by the logic program for the represented constraint to take effect, while external theory atoms can be seen as oracles for which no justification inside the logic program is needed. A further refinement of abstract theories to structured ones allowed us to distinguish variables inside theory atoms and to assign values to them, leading to a denotation-based semantic. Moreover, this allows us to refine our extended concept of stable models with witnesses provided by assignments for theory variables. We then used the resulting concept of answer sets to characterize the semantic foundations of

`clingo`’s hybrid extensions. Finally, we analyzed commonalities and differences to existing approaches of extending logic programs with external non-Boolean theories. These can be separated into black-box and white-box orientations, where in the former, the logic program is largely unaware of the intricacies of the external theory, while in the latter, the external theory is integrated into the logic programming syntax and semantics. The approach in this paper follows a black-box orientation, as the syntax of abstract and structured theories is completely left open and stable models are merely sanctioned by the external theory.

## Author Contributions

## Funding

## Data Availability Statement

## Conflicts of Interest

## Appendix A. Examples of Abstract Theories

**Example**

**A1**(Equilibrium logic)

**.**

**Example**

**A2**(Kleene’s three-valued logic)

**.**

- ${f}_{v}(\perp )\stackrel{\mathrm{def}}{=}0$, ${f}_{v}(\top )\stackrel{\mathrm{def}}{=}1$
- ${f}_{v}\left(x\right)\stackrel{\mathrm{def}}{=}v\left(x\right)$ for atoms $x\in {\mathcal{X}}_{pr}$
- ${f}_{v}(\phi \wedge \psi )\stackrel{\mathrm{def}}{=}min({f}_{v}\left(\phi \right),{f}_{v}\left(\psi \right))$
- ${f}_{v}(\phi \vee \psi )\stackrel{\mathrm{def}}{=}max({f}_{v}\left(\phi \right),{f}_{v}\left(\psi \right))$
- ${f}_{v}(\neg \phi )\stackrel{\mathrm{def}}{=}1-{f}_{v}\left(\phi \right)$
- ${f}_{v}(\phi \to \psi )\stackrel{\mathrm{def}}{=}{f}_{v}(\neg \phi \vee \psi )$

**Example**

**A3.**

**Example**

**A4**(ukasiewicz Fuzzy logic)

**.**

- ${f}_{v}(\perp )\stackrel{\mathrm{def}}{=}0$, ${f}_{v}(\top )\stackrel{\mathrm{def}}{=}1$
- ${f}_{v}\left(x\right)\stackrel{\mathrm{def}}{=}v\left(x\right)$ for atoms $x\in {\mathcal{X}}_{pr}$
- ${f}_{v}(\phi \wedge \psi )\stackrel{\mathrm{def}}{=}min({f}_{v}\left(\phi \right),{f}_{v}\left(\psi \right))$
- ${f}_{v}(\phi \vee \psi )\stackrel{\mathrm{def}}{=}max({f}_{v}\left(\phi \right),{f}_{v}\left(\psi \right))$
- ${f}_{v}(\neg \phi )\stackrel{\mathrm{def}}{=}1-{f}_{v}\left(\phi \right)$
- ${f}_{v}(\phi \to \psi )\stackrel{\mathrm{def}}{=}min(1,1-{f}_{v}\left(\phi \right)+{f}_{v}\left(\psi \right))$

**Example**

**A5**(Description Logic $\mathcal{ALC}$)

**.**

## Appendix B. Proofs of Results

**Proof**

**of**

**Proposition**

**1**.

**Proof**

**of**

**Proposition**

**2**.

**Lemma**

**A1.**

**Proof.**

**Proof**

**of**

**Proposition**

**3**.

**Proof**

**of**

**Proposition**

**4**.

**Proof**

**of**

**Proposition**

**5**.

**Proof**

**of**

**Proposition**

**6**.

**Proof**

**of**

**Proposition**

**7**.

**Proof**

**of**

**Proposition**

**8**.

## References

- Lifschitz, V. Thirteen Definitions of a Stable Model. In Fields of Logic and Computation, Essays Dedicated to Yuri Gurevich on the Occasion of His 70th Birthday; Lecture Notes in Computer Science; Blass, A., Dershowitz, N., Reisig, W., Eds.; Springer: Berlin, Germany, 2010; Volume 6300, pp. 488–503. [Google Scholar] [CrossRef] [Green Version]
- Gelfond, M.; Lifschitz, V. The Stable Model Semantics for Logic Programming. In Proceedings of the Fifth International Conference and Symposium of Logic Programming (ICLP’88), Seattle, WA, USA, 15–19 August 1988; Kowalski, R., Bowen, K., Eds.; MIT Press: Cambridge, MA, USA, 1988; pp. 1070–1080. [Google Scholar] [CrossRef]
- Gebser, M.; Harrison, A.; Kaminski, R.; Lifschitz, V.; Schaub, T. Abstract Gringo. Theory Pract. Log. Program.
**2015**, 15, 449–463. [Google Scholar] [CrossRef] [Green Version] - Falkner, A.; Friedrich, G.; Schekotihin, K.; Taupe, R.; Teppan, E. Industrial Applications of Answer Set Programming. Künstliche Intell.
**2018**, 32, 165–176. [Google Scholar] [CrossRef] [Green Version] - Lierler, Y. Relating constraint answer set programming languages and algorithms. Artif. Intell.
**2014**, 207, 1–22. [Google Scholar] [CrossRef] - Kaminski, R.; Schaub, T.; Wanko, P. A Tutorial on Hybrid Answer Set Solving with clingo. In Proceedings of the Thirteenth International Summer School of the Reasoning Web, London, UK, 7–11 July 2017; Lecture Notes in Computer Science. Ianni, G., Lembo, D., Bertossi, L., Faber, W., Glimm, B., Gottlob, G., Staab, S., Eds.; Springer: Berlin, Germany, 2017; Volume 10370, pp. 167–203. [Google Scholar] [CrossRef]
- Barrett, C.; Sebastiani, R.; Seshia, S.; Tinelli, C. Satisfiability Modulo Theories. In Handbook of Satisfiability; Frontiers in Artificial Intelligence and Applications; Chapter 26; Biere, A., Heule, M., van Maaren, H., Walsh, T., Eds.; IOS Press: Amsterdam, The Netherlands, 2009; Volume 185, pp. 825–885. [Google Scholar] [CrossRef]
- Elkabani, I.; Pontelli, E.; Son, T. Smodels with CLP and Its Applications: A Simple and Effective Approach to Aggregates in ASP. In Proceedings of the Twentieth International Conference on Logic Programming (ICLP’04), Saint-Malo, France, 6–10 September 2004; Lecture Notes in Computer Science. Demoen, B., Lifschitz, V., Eds.; Springer: Berlin, Germany, 2004; Volume 3132, pp. 73–89. [Google Scholar] [CrossRef]
- Gebser, M.; Ostrowski, M.; Schaub, T. Constraint Answer Set Solving. In Proceedings of the Twenty-Fifth International Conference on Logic Programming (ICLP’09), Pasadena, CA, USA, 14–17 July 2009; Lecture Notes in Computer Science. Hill, P., Warren, D., Eds.; Springer: Berlin, Germany, 2009; Volume 5649, pp. 235–249. [Google Scholar] [CrossRef]
- Drescher, C.; Walsh, T. A Translational Approach to Constraint Answer Set Solving. Theory Pract. Log. Program.
**2010**, 10, 465–480. [Google Scholar] [CrossRef] [Green Version] - Ostrowski, M.; Schaub, T. ASP modulo CSP: The clingcon system. Theory Pract. Log. Program.
**2012**, 12, 485–503. [Google Scholar] [CrossRef] [Green Version] - De Rosis, A.; Eiter, T.; Redl, C.; Ricca, F. Constraint Answer Set Programming Based on HEX-Programs. In Proceedings of the Eighth Workshop on Answer Set Programming and Other Computing Paradigms (ASPOCP’15), Cork, Ireland, 13 August 2015; Inclezan, D., Maratea, M., Eds.; 2015. [Google Scholar]
- Banbara, M.; Kaufmann, B.; Ostrowski, M.; Schaub, T. Clingcon: The Next Generation. Theory Pract. Log. Program.
**2017**, 17, 408–461. [Google Scholar] [CrossRef] [Green Version] - Janhunen, T.; Kaminski, R.; Ostrowski, M.; Schaub, T.; Schellhorn, S.; Wanko, P. Clingo goes Linear Constraints over Reals and Integers. Theory Pract. Log. Program.
**2017**, 17, 872–888. [Google Scholar] [CrossRef] [Green Version] - Eiter, T.; Germano, S.; Ianni, G.; Kaminski, T.; Redl, C.; Schüller, P.; Weinzierl, A. The DLVHEX System. Künstliche Intell.
**2018**, 32, 187–189. [Google Scholar] [CrossRef] - Gebser, M.; Kaminski, R.; Kaufmann, B.; Ostrowski, M.; Schaub, T.; Wanko, P. Theory Solving Made Easy with Clingo 5. In Proceedings of the Technical Communications of the Thirty-Second International Conference on Logic Programming (ICLP’16), New York, NY, USA, 16–21 October 2016; pp. 2:1–2:15. [Google Scholar]
- Pearce, D. Equilibrium logic. Ann. Math. Artif. Intell.
**2006**, 47, 3–41. [Google Scholar] [CrossRef] - Lierler, Y. Constraint Answer Set Programming: Integrational and Translational (or SMT-based) Approaches. Theory Pract. Log. Program.
**2023**, 23, 195–225. [Google Scholar] [CrossRef] - Balduccini, M.; Lierler, Y. Constraint answer set solver EZCSP and why integration schemas matter. Theory Pract. Log. Program.
**2017**, 17, 462–515. [Google Scholar] [CrossRef] [Green Version] - Janhunen, T.; Niemelä, I.; Sevalnev, M. Computing Stable Models via Reductions to Difference Logic. In Proceedings of the Tenth International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR’09), Potsdam, Germany, 14–18 September 2009; Lecture Notes in Artificial Intelligence. Erdem, E., Lin, F., Schaub, T., Eds.; Springer: Berlin, Germany, 2009; Volume 5753, pp. 142–154. [Google Scholar]
- Liu, G.; Janhunen, T.; Niemelä, I. Answer Set Programming via Mixed Integer Programming. In Proceedings of the Thirteenth International Conference on Principles of Knowledge Representation and Reasoning (KR’12), Rome, Italy, 10–14 June 2012; Brewka, G., Eiter, T., McIlraith, S., Eds.; AAAI Press: Palo Alto, CA, USA, 2012; pp. 32–42. [Google Scholar]
- Lierler, Y.; Susman, B. SMT-Based Constraint Answer Set Solver EZSMT (System Description). Comput. Sci. Fac. Proc. Present.
**2016**, 46, 1:1–1:15. [Google Scholar] - Eiter, T.; Ianni, G.; Schindlauer, R.; Tompits, H. A Uniform Integration of Higher-Order Reasoning and External Evaluations in Answer-Set Programming. In Proceedings of the Nineteenth International Joint Conference on Artificial Intelligence (IJCAI’05), Scotland, UK, 30 July–5 August 2005; Kaelbling, L., Saffiotti, A., Eds.; Morgan Kaufmann Publishers Inc.: Burlington, VT, USA, 2005; pp. 90–96. [Google Scholar]
- Brewka, G.; Eiter, T. Equilibria in Heterogeneous Nonmonotonic Multi-Context Systems. In Proceedings of the Twenty-Second National Conference on Artificial Intelligence (AAAI’07), Vancouver, BC, Canada, 22–26 July 2007; AAAI Press: Palo Alto, CA, USA, 2007; pp. 385–390. [Google Scholar]
- Cabalar, P. Functional answer set programming. Theory Pract. Log. Program.
**2011**, 11, 203–233. [Google Scholar] [CrossRef] [Green Version] - Balduccini, M.; Gelfond, M. Language ASP{f} with Arithmetic Expressions and Consistency-Restoring Rules. arXiv
**2013**, arXiv:1301.1387. [Google Scholar] - Bartholomew, M.; Lee, J. First-order stable model semantics with intensional functions. Artif. Intell.
**2019**, 273, 56–93. [Google Scholar] [CrossRef] - Cabalar, P.; Fandinno, J.; Fariñas del Cerro, L.; Pearce, D. Functional ASP with Intensional Sets: Application to Gelfond-Zhang Aggregates. Theory Pract. Log. Program.
**2018**, 18, 390–405. [Google Scholar] [CrossRef] [Green Version] - Balduccini, M. A “conservative” approach to extending answer set programming with nonherbrand functions. In Correct Reasoning: Essays on Logic-Based AI in Honour of Vladimir Lifschitz; Lecture Notes in Computer Science; Erdem, E., Lee, J., Lierler, Y., Pearce, D., Eds.; Springer: Berlin, Germany, 2012; Volume 7265, pp. 24–39. [Google Scholar]
- Bartholomew, M.; Lee, J. On the stable model semantics for intensional functions. Theory Pract. Log. Program.
**2013**, 13, 863–876. [Google Scholar] [CrossRef] [Green Version] - Balduccini, M. ASP with non-herbrand partial functions: A language and system for practical use. Theory Pract. Log. Program.
**2013**, 13, 547–561. [Google Scholar] [CrossRef] [Green Version] - Arias, J.; Carro, M.; Salatar, E.; Marple, K.; Gupta, G. Constraint Answer Set Programming without Grounding. Theory Pract. Log. Program.
**2018**, 18, 337–354. [Google Scholar] [CrossRef] [Green Version] - Eiter, T.; Kiesel, R. ASP(AC): Answer Set Programming with Algebraic Constraints. Theory Pract. Log. Program.
**2020**, 20, 895–910. [Google Scholar] [CrossRef] - Lifschitz, V.; Pearce, D.; Valverde, A. Strongly equivalent logic programs. ACM Trans. Comput. Log.
**2001**, 2, 526–541. [Google Scholar] [CrossRef]

**Figure 1.**Answer sets for (18) without negative values.

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Cabalar, P.; Fandinno, J.; Schaub, T.; Wanko, P.
On the Semantics of Hybrid ASP Systems Based on `Clingo`. *Algorithms* **2023**, *16*, 185.
https://doi.org/10.3390/a16040185

**AMA Style**

Cabalar P, Fandinno J, Schaub T, Wanko P.
On the Semantics of Hybrid ASP Systems Based on `Clingo`. *Algorithms*. 2023; 16(4):185.
https://doi.org/10.3390/a16040185

**Chicago/Turabian Style**

Cabalar, Pedro, Jorge Fandinno, Torsten Schaub, and Philipp Wanko.
2023. "On the Semantics of Hybrid ASP Systems Based on `Clingo`" *Algorithms* 16, no. 4: 185.
https://doi.org/10.3390/a16040185