# [

###### Abstract

Fuzzy answer set programming (FASP) combines two declarative frameworks, answer set programming and fuzzy logic, in order to model reasoning by default over imprecise information. Several connectives are available to combine different expressions; in particular the Gödel and Łukasiewicz fuzzy connectives are usually considered, due to their properties. Although the Gödel conjunction can be easily eliminated from rule heads, we show through complexity arguments that such a simplification is infeasible in general for all other connectives. The paper analyzes a translation of FASP programs into satisfiability modulo theories (SMT), which in general produces quantified formulas because of the minimality of the semantics. Structural properties of many FASP programs allow to eliminate the quantification, or to sensibly reduce the number of quantified variables. Indeed, integrality constraints can replace recursive rules commonly used to force Boolean interpretations, and completion subformulas can guarantee minimality for acyclic programs with atomic heads. Moreover, head cycle free rules can be replaced by shifted subprograms, whose structure depends on the eliminated head connective, so that ordered completion may replace the minimality check if also Łukasiewicz disjunction in rule bodies is acyclic. The paper also presents and evaluates a prototype system implementing these translations.

Theory and Practice of Logic Programming]
Fuzzy Answer Set Computation via Satisfiability Modulo Theories
M. Alviano and R. Peñaloza]
MARIO ALVIANO

University of Calabria, Italy
and RAFAEL PEÑALOZA

Free University of Bozen-Bolzano, Italy
\jdateMarch 2003
2003
\pagerange[–References
\doiXXX

nswer set programming, fuzzy logic, satisfiability modulo theories.

## 1 Introduction

Answer set programming (ASP) [Gelfond and Lifschitz (1991), Niemelä (1999), Marek and Truszczyński (1999)] is a declarative language for knowledge representation, particularly suitable to model common non-monotonic tasks such as reasoning by default, abductive reasoning, and belief revision [Baral (2003), Marek and Remmel (2004), Lin and You (2002), Delgrande et al. (2008)]. If on the one hand ASP makes logic closer to the real world allowing for reasoning on incomplete knowledge, on the other hand it is unable to model imprecise information that may arise from the intrinsic limits of sensors, or the vagueness of natural language. Fuzzy answer set programming (FASP) [Nieuwenborgh et al. (2007)] overcomes this limitation by interpreting propositions with a truth degree in the real interval . Intuitively, the higher the degree assigned to a proposition, the more true it is, with and denoting totally false and totally true, respectively. The notion of fuzzy answer set, or fuzzy stable model, was recently extended to arbitrary propositional formulas [Lee and Wang (2014)]. \citeANPDBLP:conf/jelia/LeeW14 also propose an example on modeling dynamic trust in social networks, which inspired the following simplified scenario that clarifies how truth degrees increase the knowledge representation capability of ASP.

###### Example 1

A user of a social network may trust or distrust another user, and these are vague concepts that can be naturally modeled by truth degrees. These degrees may change over time. For example, if at some point has a conflict with , it is likely that her distrust on will increase and her trust on will decrease. These are non-monotonic concepts that can be naturally handled in FASP.

In practice, however, ASP offers many efficient solvers such as dlv [Alviano et al. (2010)], cmodels [Lierler and Maratea (2004)], clasp [Gebser et al. (2012)], and wasp [Alviano et al. (2013)], which is not the case for FASP. A preliminary FASP solver for programs with atomic heads and Łukasiewicz conjunction, called fasp, was presented at ICLP’13 by [Alviano and Peñaloza (2013)]. It implements approximation operators and a translation into bilevel programming [Blondeel et al. (2014)]. A more general solver, called ffasp [Mushthofa et al. (2014)], is based on a translation into ASP for computing stable models whose truth degrees are in the set , for a fixed . In general, exponentially many must be tested for checking the existene of a stable model, which is infeasible in practice. Therefore, ffasp tests by default a limited set of values. Neither fasp nor ffasp accept nesting of negation, which would allow to encode choice rules, a convenient way for guessing truth degrees without using auxiliary atoms [Lee and Wang (2014)]. Indeed, choice rules allow to check satisfiability of fuzzy propositional formulas without adding new atomic propositions. Our aim is to provide a more flexible FASP solver supporting useful patterns like choice rules.

Satisfiability modulo theories (SMT) [Barrett et al. (2009)] extends propositional logic with external background theories—e.g. real arithmetic [Ratschan (2006), Akbarpour and Paulson (2010)]—for which specialized methods provide efficient decision procedures. SMT is thus a good candidate as a target framework for computing fuzzy answer sets efficiently. This is non-trivial because the minimality condition that fuzzy stable models must satisfy makes the problem hard for the second level of the polynomial hierarchy; indeed, the translation provided in Section 4 produces quantified theories in general. However, structural properties of the program that decrease the complexity to NP can be taken into account in order to obtain more tailored translations. For example, disabling head connectives and recursive definitions yields a compact translation into fuzzy propositional logic known as completion [Janssen et al. (2012)], which in turn can be expressed in SMT (see Section 4.1). Since completion is unsound for programs with recursive definitions, the notion of ordered completion has arisen in the ASP literature [Ben-Eliyahu and Dechter (1994), Janhunen (2004), Niemelä (2008), Asuncion et al. (2012)]. In a nutshell, stable models of ASP programs with atomic heads can be recasted in terms of program reducts and fixpoint of the immediate consequence operator, where the computation of the fixpoint defines a ranking of the derived atoms. Fuzzy stable models of programs with atomic heads can also be defined in terms of reducts and fixpoint of the immediate consequence operator [Janssen et al. (2012)], although the notion of ranking can be extended to FASP only when recursive Łukasiewicz disjunction is disabled. Using these notions, ordered completion is defined for FASP programs in Section 4.2.

In ASP, completion and ordered completion are also applicable to disjunctive programs having at most one recursive atom in each rule head. Such programs, referred to as head cycle free (HCF) [Ben-Eliyahu and Dechter (1994)], are usually translated into equivalent programs with atomic heads by a so-called shift [Eiter et al. (2007)]. The same translation also works for HCF FASP programs using Łukasiewicz disjunction in rule heads. On the other hand, Łukasiewicz conjunction and Gödel disjunction require more advanced constructions (Section 3.2) which introduce recursive Łukasiewicz disjunction in rule bodies to restrict auxiliary atoms to be Boolean. Such rules are handled by integrality constraints in the theory produced by the completion, while they inhibit the application of the ordered completion. As in ASP, the shift is unsound in general for FASP programs with head cycles, and complexity arguments given in Section 3.1 prove that it is unlikely that head connectives other than Gödel conjunction can be eliminated in general.

The general translation into SMT, completion, and ordered completion are implemented in a new FASP solver called fasp2smt (http://alviano.net/software/fasp2smt/; see Section 5). fasp2smt uses gringo [Gebser et al. (2011)] to obtain a ground representation of the input program, and z3 [de Moura and Bjørner (2008)] to solve SMT instances encoding ground programs. Efficiency of fasp2smt is compared with the previously implemented solver ffasp [Mushthofa et al. (2014)], showing strengths and weaknesses of the proposed approach.

## 2 Background

We briefly recall the syntax and semantics of FASP [Nieuwenborgh et al. (2007), Lee and Wang (2014)] and SMT [Barrett et al. (2009)]. Only the notions needed for the paper are introduced; for example, we only consider real arithmetic for SMT.

### 2.1 Fuzzy Answer Set Programming

Let be a fixed set of propositional atoms. A fuzzy atom (atom for short) is either a propositional atom from , or a numeric constant in . Fuzzy expressions are defined inductively as follows: every atom is a fuzzy expression; if is a fuzzy expression then is a fuzzy expression, where denotes negation as failure; if and are fuzzy expressions, and is a connective, is a fuzzy expression. Connectives are known as the Łukasiewicz connectives, and are the Gödel connectives. A head expression is a fuzzy expression of the form , where , are atoms, and . A rule is of the form , where is a head expression, and is a fuzzy expression. A FASP program is a finite set of rules. Let denote the set of atoms used by .

A fuzzy interpretation for a FASP program is a function mapping each propositional atom of into a truth degree in . is extended to fuzzy expressions as follows: for ; ; ; ; ; and . satisfies a rule () if ; is a model of a FASP program , denoted , if for each . is a stable model of the FASP program if and there is no interpretation such that and , where the reduct is obtained from by replacing each occurrence of a fuzzy expression by the constant . Let denote the set of stable models of . A program is coherent if ; otherwise, is incoherent. Two programs are equivalent w.r.t. a crisp set , denoted , if and , where is the interpretation assigning to all , and 0 to all .

###### Example 2

Consider the scenario described in Example 1. Let be a set of users, and the timepoints of interest, for some . Let be a propositional atom expressing that trusts at time . Similarly, represents that distrusts at time , and encodes that has a conflict with at time . The social network example can be encoded by the FASP program containing the following rules, for all , , and :

The second rule above states that the trust degree of on decreases when her distrust degree on increases. A stable model of , is such that , and .

ASP programs are FASP programs such that all head connectives are , all body connectives are , and all numeric constants are or . Moreover, an ASP program implicitly contains crispifying rules of the form , for all . In ASP programs, and are usually denoted and , respectively.

### 2.2 Satisfiability Modulo Theories

Let be a signature where is a set of variables, is a set of constant symbols, is the set of binary function symbols , and is the set of binary predicate symbols . Terms and formulas over are defined inductively, where we use infix notation for all binary symbols. Constants and variables are terms. If are terms and then is a term. If are terms and then is a formula. If is a formula and are terms then is a term ( stands for if-then-else). If are formulas and then is a formula. If is a variable and is a formula then is a formula. We consider only closed formulas, i.e., formulas in which all free variables are universally quantified. For a term and integers with , we use in formulas to represent the subformula . Similarly, for terms , represents . A -theory is a set of -formulas.

A -structure is a pair , where is a mapping such that for each constant symbol , for each number , is the binary function over reals if , and the binary relation over reals if . Composed terms and formulas are interpreted as follows: for , ; equals if is true, and otherwise; for , is true if and only if ; for , equals (in propositional logic); is true if and only if is true for all , where is the formula obtained by substituting with in . is a -model of a theory , denoted , if is true for all .

###### Example 3

Let be , be a variable, and be a -theory. Any -model of maps to 0. If is added to , then any -model of maps to 0, and to real numbers in the interval .

## 3 Structure Simplification

The structure of FASP programs can be simplified through rewritings that leave at most one connective in each rule body [Mushthofa et al. (2014)]. Essentially, a rule of the form , with , is replaced by the rules , , and , with and fresh atoms. A further simplification, implicit in the translation into crisp ASP by [Mushthofa et al. (2014)], eliminates in rule heads and in rule bodies: a rule of the form , , is equivalently replaced by rules , for ; and a rule of the form is replaced by , . Moreover, a rule of the form can be equivalently replaced by the rules and , where is a fresh atom. Let be the program obtained from by applying these substitutions. {restatable}propositionPropSimp For every FASP program , it holds that , i.e., and .

DBLP:conf/ecai/MushthofaSC14 also simplify rule heads: is replaced by , , , , and , where and are fresh atoms. We do not apply these rewritings as they may inhibit other simplifications introduced in Section 3.2.

### 3.1 Hardness results

A relevant question is whether more rule connectives can be eliminated in order to further simplify the structure of FASP programs. We show that this is not possible, unless the polynomial hierarchy collapses, by adapting the usual reduction of 2-QBF satisfiability to ASP coherence testing [Eiter and Gottlob (1995)]: for , and formula , test the coherence of below

(1) | |||||

(2) | |||||

(3) |

where , and , for all . -hardness for FASP programs with in rule heads is proved by defining a FASP program comprising (1)–(3) (recall that is , and is ). This also holds if we replace with in (3). Another possibility is to replace with in (1), and add for all atoms in , showing -hardness for FASP programs with in rule heads, a result already proved by \citeNDBLP:journals/ijar/BlondeelSVC14 with a different construction.

The same result also applies to , but we need a more involved argument. Let be the program obtained from by replacing with , substituting the rule (1) with the following three rules for each :

For all interpretations , the first rule enforces . The second rule enforces whenever , i.e., whenever . Similarly, the third rule enforces whenever . Hence, one of is assigned 1, and the other 0.5. Since conjunctions are modeled by , and each conjunction contains three literals whose interpretation is either 0.5 or 1, it follows that the interpretation of the conjunction is 1 if all literals are 1, and at most 0.5 otherwise. Hence, is satisfiable if and only if is coherent.

theoremThmHard Checking coherence of FASP programs is -hard already in the following cases: (i) all connectives are ; (ii) head connectives are , and body connectives are (or ); and (iii) head connectives are , and body connectives are (or ) and .

### 3.2 Shifting heads

Theorem 3.1 shows that , , and cannot be eliminated from rule heads in general by a polytime translation, unless the polynomial hierarchy collapses. This situation is similar to the case of disjunctions in ASP programs, which cannot be eliminated either. However, head cycle free (HCF) programs admit a translation known as shift that eliminates preserving stable models [Eiter et al. (2007)]. We extend this idea to FASP connectives. The definition of HCF programs relies on the notion of dependency graph. Let denote the set of propositional atoms occurring in but not under the scope of any symbol. The dependency graph of a FASP program has vertices , and an arc if there is a rule such that , and . A (strongly connected) component of is a maximal set containing pairwise reachable vertices of . A program is acyclic if is acyclic; is HCF if there is no rule where contains two atoms from the same component of ; has non-recursive in rule bodies if whenever occurs in the body of a rule of but not under the scope of a symbol then for all and for all atoms and belong to different components of .

###### Example 4

The program is acyclic. Note that does not provide an arc to the dependency graph. Adding the rule makes the program cyclic but still HCF because and belong to two different components. If also is added, then the program is no more HCF. Finally, note that in Example 2 is acyclic.

It should now be clear why we decided not to reduce the number of head connectives in the translation defined at the beginning of this section. By removing a connective in the head of a rule of an HCF program, we might produce a program that is not HCF. Consider for example the HCF program . To reduce one of the occurrences of , we can introduce a fresh atom that stands for . However, and would belong to the same component of the resulting program .

We now define the shift of a rule for all types of head connectives. The essential idea is to move all head atoms but one to the body (hence the name shift). To preserve stable models, this has to be repeated for all head atoms, and some additional conditions might be required. For a rule of the form , the shift essentially mimics the original notion for ASP programs, and produces

(4) |

for all . Intuitively, the original rule requires any model to satisfy the condition . This is the case if and only if

i.e., if and only if (4) is satisfied, for all . The shift of rules with other connectives in the head is more elaborate. For , it produces

(5) |

for all , where is a fresh atom. The last two rules enforce whenever , and otherwise. For all , implies that the body of the first rule is interpreted as 0, and implies , where is . Since the original rule is associated with the satisfaction of , which is the case if and only if , for all , this translation preserves stable models for HCF programs.

The shift of requires an even more advanced construction. Notice first that since the program is HCF, we can order head atoms such that for every , does not reach in . Assume w.l.o.g. that one such ordering is given. Then, the shift of this rule is the program containing the rules

(6) | |||||

(7) |

for all , where each is a fresh atom. Intuitively, (7) enforces whenever , and otherwise, with the exception of which is always 1. The rule (6) enforces that whenever , and either or . In the following, let denote the program obtained by shifting all rules of .

theoremThmShift Let be FASP program. If is HCF then .

## 4 Translation into SMT

We now define a translation mapping into a -theory, where , and . The theory has two parts, and , for producing a model and checking its minimality, respectively. In more detail, is the following: for , ; for , is if , and otherwise; ; , where is ; , where stands for ; ; ; . Note that propositional atoms are mapped to constants by , and to variables by . Moreover, negated expressions are always mapped by . Define , where

(8) |

###### Example 5

Consider the program . The theory is . Let be a -structure such that and . It can be checked that . Also note that and implies .

For an interpretation of , let be the one-to-one -structure for such that , for all .

theoremThmSmt Let be a FASP program. if and only if .

### 4.1 Completion

A drawback of is that it produces quantified theories, which are usually handled by incomplete heuristics in SMT solvers [Ge and de Moura (2009)]. Structural properties of FASP programs may be exploited to obtain a more tailored translation that extends completion [Clark (1977)] to the fuzzy case. Completion is a translation into propositional theories used to compute stable models of acyclic ASP programs with atomic heads. Intuitively, the models of the completion of a program coincide with the supported models of , i.e., those models with , for each . This notion was extended to FASP programs by \citeNDBLP:journals/tplp/JanssenVSC12, with fuzzy propositional theories as target framework. We adapt it to produce -theories, for the defined before.

Let be a program with atomic heads, and . We denote by the set of rules in whose head is , and by the set of rules in whose head is a numeric constant. The completion of is the -theory:

(9) |

where , and for , , where is . Basically, yields a term interpreted as by all -structures .

###### Example 6

Since in Example 5 is acyclic, . The theory is , where is , and is .

Since and have the same constant symbols, defines a one-to-one mapping between interpretations of and -structures of . An interesting question is whether correctness can be extended to HCF programs, for example by first shifting heads. Notice that (5) and (7) introduce rules of the form through the shift of or , breaking acyclicity. However, is a common pattern to force a Boolean interpretation of , which can be encoded by integrality constraints in the theory. The same observation applies to rules of the form . Define , and let be the program obtained from by performing the following operations for each : first, occurrences of in rule bodies are replaced by , where is a fresh atom; then, a choice rule is added. The refined completion is the following:

(10) |

and the associated -structure is such that for , and equals 1 if , and 0 otherwise, for .

theoremThmComp Let be a program such that is acyclic. Then, if and only if .

Note that in the above theorem and are only required because and are defined for normal programs.

### 4.2 Ordered Completion

Stable models of recursive programs do not coincide with supported models, making completion unsound. To regain soundness, ordered completion [Ben-Eliyahu and Dechter (1994), Janhunen (2004), Niemelä (2008), Asuncion et al. (2012)] uses a notion of acyclic support. Let be an ASP program with atomic heads. is a stable model of if and only if there exists a ranking such that, for each , [Janhunen (2004)]. This holds because the reduct is also -free, and thus its unique minimal model is the least fixpoint of the immediate consequence operator , mapping interpretations to where . Since and , for all interpretations , the limit is reached in steps. For FASP programs, however, the least fixpoint of is not reached within a linear number of applications [Janssen et al. (2012)]. For example, applications are required for the program , for and [Blondeel et al. (2014)]. On the other hand, for and all interpretations , we have and . The claim can thus be extended to the fuzzy case if recursion over and is disabled.

lemmaLemRank Let be such that has atomic heads and non-recursive in rule bodies. Let be an interpretation for . The least fixpoint of is reached in steps.

Ordered completion can be defined for this class of FASP programs. Let be the least fixpoint of . The rank of in is the step at which is derived. Let be a constant symbol expressing the rank of . Define , and for , where . Also define , and for ,

The ordered completion of , denoted , is the following theory:

(11) |

###### Example 7

The -theory , is the following:

The theory is satisfied by if , , and .

The correctness of , provided that satisfies the conditions of Lemma 4.2, is proved by the following mappings: for , let be the -model for such that and is the rank of in , for all ; for such that , let be the interpretation for such that , for all .

theoremThmOcomp Let be an HCF program with non-recursive in rule bodies, and whose head connectives are . If then . Dually, if then .

The above theorem does not apply in case of recursive in rule bodies. For example, has a unique stable model assigning to , while its ordered completion is the following -theory with no -model: .

## 5 Implementation and Experiment

We implemented the translations from Section 3 in the new FASP solver fasp2smt. fasp2smt is written in python, and uses gringo [Gebser et al. (2011)] to obtain a ground representation of the input program, and z3 [de Moura and Bjørner (2008)] to solve SMT instances encoding ground programs. The output of gringo encodes a propositional program, say , that is conformant with the syntax in Section 2. The components of are computed, and the structure of the program is analyzed. If is acyclic, is built. If is HCF with non-recursive in rule bodies, and only and in rule heads, then is built. In all other cases, is built. The built theory is fed into z3, and either a stable model or the string incoherent is reported.

The performance of fasp2smt was assessed on instances of a benchmark used to evaluate the FASP solver ffasp [Mushthofa et al. (2014)]. The benchmark comprises two (synthetic) problems, the fuzzy versions of Graph Coloring and Hamiltonian Path, originally considered by \citeNDBLP:journals/tplp/AlvianoP13. In Graph Coloring edges of an input graph are associated with truth degrees, and each vertex is non-deterministically colored with a shadow of gray, i.e., truth degree 1 is distributed among the atoms and . The truth degree of each edge , say , enforces and , i.e., adjacent vertices must be colored with sufficiently different shadows of gray. Similarly, in Hamiltonian Path vertices and edges of an input graph are associated with truth degrees, and Boolean connectives are replaced by Łukasiewicz connectives in the usual ASP encoding. The truth degree of each edge , say , is non-deterministically distributed among the atoms and . Reaching a vertex from the initial vertex via an edge guarantees that is reached with truth degree . Reaching a third vertex via an edge , instead, guarantees that is reached with truth degree . In other words, the more uncertain is the selection of an edge , the more uncertain is the membership of in the selected path, which in turn implies an even more uncertain membership of any reached by an edge . In the original encodings, Łukasiewicz disjunction was used to guess (fuzzy) membership of elements in one of two sets. For example, Hamiltonian Path used a rule of the form , which was shifted and replaced by and by \citeANPDBLP:journals/tplp/AlvianoP13. In fact, in 2013 the focus was on FASP programs with atomic heads and only in rule bodies, and the shift of for these programs was implicit in the work of \citeNDBLP:journals/ijar/BlondeelSVC14. Since our focus is now on a more general setting, the original encodings were restored, even if it is clear that fasp2smt shifts such programs by itself. In fact, Graph Coloring is recognized as acyclic, and Hamiltonian Path as HCF with no in rule bodies. It turns out that fasp2smt uses completion for Graph Coloring, and ordered completion for Hamiltonian Path. The experiment was run on an Intel Xeon CPU 2.4 GHz with 16 GB of RAM. CPU and memory usage were limited to 600 seconds and 15 GB, respectively. fasp2smt and ffasp were tested with their default settings, and the performance was measured by pyrunlim (http://alviano.net/software/pyrunlim/), the tool used in the last ASP Competitions [Alviano et al. (2013), Calimeri et al. (2014)].

fasp2smt | ffasp | ffasp (shifted enc.) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|

den | inst | sol | time | mem | sol | time | mem | sol | time | mem | |

graph–col |
20 | 6 | 6 | 94.0 | 174 | 6 | 5.3 | 302 | 6 | 1.5 | 69 |

40 | 6 | 6 | 102.4 | 178 | 6 | 19.8 | 1112 | 6 | 5.3 | 181 | |

60 | 6 | 6 | 107.6 | 180 | 6 | 46.7 | 2472 | 6 | 11.8 | 342 | |

80 | 6 | 6 | 111.1 | 181 | 6 | 90.1 | 4420 | 6 | 21.0 | 550 | |

100 | 6 | 6 | 111.7 | 181 | 6 | 151.9 | 7025 | 6 | 33.6 | 812 | |

ham–path |
20 | 10 | 10 | 1.7 | 25 | 10 | 17.3 | 410 | 10 | 3.5 | 101 |

40 | 10 | 10 | 1.8 | 25 | 10 | 20.3 | 462 | 10 | 2.3 | 105 | |

60 | 10 | 10 | 2.1 | 25 | 10 | 13.2 | 481 | 10 | 2.0 | 107 | |

80 | 10 | 10 | 2.4 | 25 | 10 | 32.9 | 868 | 10 | 3.9 | 188 | |

100 | 10 | 10 | 2.1 | 25 | 10 | 69.0 | 1385 | 10 | 6.5 | 323 | |

120 | 10 | 10 | 2.0 | 25 | 10 | 125.5 | 2042 | 10 | 10.5 | 475 | |

140 | 10 | 10 | 1.9 | 25 | 10 | 176.8 | 2821 | 10 | 14.7 | 669 | |

160 | 10 | 10 | 2.2 | 25 | 9 | 139.6 | 3769 | 10 | 20.8 | 960 | |

180 | 10 | 10 | 2.4 | 26 | 8 | 203.1 | 4914 | 10 | 28.9 | 1270 |

The results are reported in Table 1. Instances are grouped according to the granularity of numeric constants, where instances with are characterized by numeric constants of the form . There are 6 instances of Graph Coloring and 10 of Hamiltonian Path in each group. All instances of Graph Coloring are coherent, while there is an average of 4 incoherent instances in each group of Hamiltonian Path. All instances are solved by fasp2smt (column sol), and the granularity of numeric constants does not really impact on execution time and memory consumption. The performance is particularly good for Hamiltonian Path, while ffasp is faster than fasp2smt in Graph Coloring for numeric constants of limited granularity. The performance of ffasp deteriorates when the granularity of numeric constants increases, and 6 timeouts are reported for the largest instances of Hamiltonian Path. Another strength of fasp2smt is the limited memory consumption compared to ffasp. If we decrease the memory limit to 3 GB, ffasp runs out of memory on 12 instances of Graph Coloring and 34 instances of Hamiltonian Path, while fasp2smt still succeeds in all instances. For the sake of completeness, manually shifted encodings were also tested. The performance of fasp2smt did not change, while ffasp improves considerably, especially regarding memory consumption. We also tested 180 instances (not reported in Table 1) of two simple problems called Stratified and Odd Cycle [Alviano and Peñaloza (2013), Mushthofa et al. (2014)], which both fasp2smt and ffasp solve in less than 1 second.

The main picture resulting from the experimental analysis is that fasp2smt is slower than ffasp in Graph Coloring, but it is faster in Hamiltonian Path. The reason for these different behaviors can be explained by the fact that all tested instances of Graph Coloring are coherent, while incoherent instances are also present among those tested for Hamiltonian Path. To confirm such an intuition, we tested the simple program . Its incoherence is proved instantaneously by fasp2smt, while ffasp requires 71.8 seconds and 446 MB of memory (8.3 seconds and 96 MB of memory if the program is manually shifted).

## 6 Conclusions

SMT proved to be a reasonable target language to compute fuzzy answer sets efficiently. In fact, when structural properties of the evaluated programs are taken into account, efficiently evaluable theories are produced by fasp2smt. This is the case for acyclic programs, for which completion can be used, as well as for HCF programs with only in rule heads and no recursive in rule bodies, for which ordered completion is proposed. Moreover, common patterns to crispify atoms, which would introduce recursive in rule bodies, are possibly replaced by integrality constraints. The performance of fasp2smt was compared with ffasp, which performs multiple calls to an ASP solver. An advantage of fasp2smt is that, contrary to ffasp, its performance is not affected by the approximation used to represent truth degrees in the input program. On the other hand, ffasp is currently faster than fasp2smt for instances having a stable model with truth degrees in , for some small , which however cannot be determined a priori. Such a does not exist for incoherent instances, and indeed in this case fasp2smt significantly overcomes ffasp. It is also important to note that in general the amount of memory required by fasp2smt is negligible compared to ffasp. Future work will evaluate the possibility to extend the approximation operators by \citeNDBLP:journals/tplp/AlvianoP13 to the broader language considered in this paper, with the aim of identifing classes of programs for which the fixpoints are reached within a linear number of applications.

## Acknowledgement

Mario Alviano was partially supported by MIUR within project “SI-LAB BA2KNOW – Business Analitycs to Know”, by Regione Calabria, POR Calabria FESR 2007-2013, within projects “ITravel PLUS” and “KnowRex”, by the National Group for Scientific Computation (GNCS-INDAM), and by Finanziamento Giovani Ricercatori UNICAL. Rafael Peñaloza was partially supported by the DFG within the Cluster of Excellence ‘cfAED;’ this work was developed while still being affiliated with TU Dresden and the Center for Advancing Electronics Dresden, Germany.

## References

- Akbarpour and Paulson (2010) Akbarpour, B. and Paulson, L. C. 2010. Metitarski: An automatic theorem prover for real-valued special functions. J. Autom. Reasoning 44, 3, 175–205.
- Alviano et al. (2013) Alviano, M., Calimeri, F., Charwat, G., Dao-Tran, M., Dodaro, C., Ianni, G., Krennwallner, T., Kronegger, M., Oetsch, J., Pfandler, A., Pührer, J., Redl, C., Ricca, F., Schneider, P., Schwengerer, M., Spendier, L. K., Wallner, J. P., and Xiao, G. 2013. The fourth answer set programming competition: Preliminary report. In LPNMR, P. Cabalar and T. C. Son, Eds. LNCS. 42–53.
- Alviano et al. (2013) Alviano, M., Dodaro, C., Faber, W., Leone, N., and Ricca, F. 2013. WASP: A native ASP solver based on constraint learning. In Logic Programming and Nonmonotonic Reasoning, 12th International Conference, LPNMR 2013, Corunna, Spain, September 15-19, 2013. Proceedings, P. Cabalar and T. C. Son, Eds. Lecture Notes in Computer Science, vol. 8148. Springer, 54–66.
- Alviano et al. (2010) Alviano, M., Faber, W., Leone, N., Perri, S., Pfeifer, G., and Terracina, G. 2010. The disjunctive datalog system DLV. In Datalog Reloaded - First International Workshop, Datalog 2010, Oxford, UK, March 16-19, 2010. Revised Selected Papers, O. de Moor, G. Gottlob, T. Furche, and A. J. Sellers, Eds. Lecture Notes in Computer Science, vol. 6702. Springer, 282–301.
- Alviano and Peñaloza (2013) Alviano, M. and Peñaloza, R. 2013. Fuzzy answer sets approximations. TPLP 13, 4-5, 753–767.
- Asuncion et al. (2012) Asuncion, V., Lin, F., Zhang, Y., and Zhou, Y. 2012. Ordered completion for first-order logic programs on finite structures. Artif. Intell. 177-179, 1–24.
- Baral (2003) Baral, C. 2003. Knowledge Representation, Reasoning and Declarative Problem Solving. Cambridge University Press.
- Barrett et al. (2009) Barrett, C. W., Sebastiani, R., Seshia, S. A., and Tinelli, C. 2009. Satisfiability modulo theories. In Handbook of Satisfiability, A. Biere, M. Heule, H. van Maaren, and T. Walsh, Eds. Frontiers in Artificial Intelligence and Applications, vol. 185. IOS Press, 825–885.
- Ben-Eliyahu and Dechter (1994) Ben-Eliyahu, R. and Dechter, R. 1994. Propositional semantics for disjunctive logic programs. Ann. Math. Artif. Intell. 12, 1-2, 53–87.
- Blondeel et al. (2014) Blondeel, M., Schockaert, S., Vermeir, D., and Cock, M. D. 2014. Complexity of fuzzy answer set programming under łukasiewicz semantics. Int. J. Approx. Reasoning 55, 9, 1971–2003.
- Calimeri et al. (2014) Calimeri, F., Gebser, M., Maratea, M., and Ricca, F. 2014. The design of the fifth answer set programming competition. CoRR abs/1405.3710.
- Clark (1977) Clark, K. L. 1977. Negation as failure. In Logic and Data Bases. 293–322.
- de Moura and Bjørner (2008) de Moura, L. M. and Bjørner, N. 2008. Z3: an efficient SMT solver. In Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings, C. R. Ramakrishnan and J. Rehof, Eds. Lecture Notes in Computer Science, vol. 4963. Springer, 337–340.
- Delgrande et al. (2008) Delgrande, J. P., Schaub, T., Tompits, H., and Woltran, S. 2008. Belief revision of logic programs under answer set semantics. In Principles of Knowledge Representation and Reasoning: Proceedings of the Eleventh International Conference, KR 2008, Sydney, Australia, September 16-19, 2008, G. Brewka and J. Lang, Eds. 411–421.
- Eiter et al. (2007) Eiter, T., Fink, M., and Woltran, S. 2007. Semantical characterizations and complexity of equivalences in answer set programming. ACM Trans. Comput. Log. 8, 3.
- Eiter and Gottlob (1995) Eiter, T. and Gottlob, G. 1995. On the computational cost of disjunctive logic programming: Propositional case. Ann. Math. Artif. Intell. 15, 3-4, 289–323.
- Ge and de Moura (2009) Ge, Y. and de Moura, L. M. 2009. Complete instantiation for quantified formulas in satisfiabiliby modulo theories. In Computer Aided Verification, 21st International Conference, CAV 2009, Grenoble, France, June 26 - July 2, 2009. Proceedings, A. Bouajjani and O. Maler, Eds. Lecture Notes in Computer Science, vol. 5643. Springer, 306–320.
- Gebser et al. (2011) Gebser, M., Kaminski, R., König, A., and Schaub, T. 2011. Advances in gringo series 3. In Logic Programming and Nonmonotonic Reasoning - 11th International Conference, LPNMR 2011, Vancouver, Canada, May 16-19, 2011. Proceedings, J. P. Delgrande and W. Faber, Eds. Lecture Notes in Computer Science, vol. 6645. Springer, 345–351.
- Gebser et al. (2012) Gebser, M., Kaufmann, B., and Schaub, T. 2012. Conflict-driven answer set solving: From theory to practice. Artif. Intell. 187, 52–89.
- Gelfond and Lifschitz (1991) Gelfond, M. and Lifschitz, V. 1991. Classical negation in logic programs and disjunctive databases. New Generation Comput. 9, 3/4, 365–386.
- Janhunen (2004) Janhunen, T. 2004. Representing normal programs with clauses. In Proceedings of the 16th Eureopean Conference on Artificial Intelligence, ECAI’2004, Valencia, Spain, August 22-27, 2004, R. L. de Mántaras and L. Saitta, Eds. IOS Press, 358–362.
- Janssen et al. (2012) Janssen, J., Schockaert, S., Vermeir, D., and Cock, M. D. 2012. Answer Set Programming for Continuous Domains - A Fuzzy Logic Approach. Atlantis Computational Intelligence Systems, vol. 5. Atlantis Press.
- Janssen et al. (2012) Janssen, J., Vermeir, D., Schockaert, S., and Cock, M. D. 2012. Reducing fuzzy answer set programming to model finding in fuzzy logics. TPLP 12, 6, 811–842.
- Lee and Wang (2014) Lee, J. and Wang, Y. 2014. Stable models of fuzzy propositional formulas. In Logics in Artificial Intelligence - 14th European Conference, JELIA 2014, Funchal, Madeira, Portugal, September 24-26, 2014. Proceedings, E. Fermé and J. Leite, Eds. Lecture Notes in Computer Science, vol. 8761. Springer, 326–339.
- Lierler and Maratea (2004) Lierler, Y. and Maratea, M. 2004. Cmodels-2: Sat-based answer set solver enhanced to non-tight programs. In Logic Programming and Nonmonotonic Reasoning, 7th International Conference, LPNMR 2004, Fort Lauderdale, FL, USA, January 6-8, 2004, Proceedings, V. Lifschitz and I. Niemelä, Eds. Lecture Notes in Computer Science, vol. 2923. Springer, 346–350.
- Lin and You (2002) Lin, F. and You, J.-H. 2002. Abduction in logic programming: A new definition and an abductive procedure based on rewriting. Artificial Intelligence 140, 1/2, 175–205.
- Marek and Remmel (2004) Marek, V. W. and Remmel, J. B. 2004. Answer set programming with default logic. In 10th International Workshop on Non-Monotonic Reasoning (NMR 2004), Whistler, Canada, June 6-8, 2004, Proceedings, J. P. Delgrande and T. Schaub, Eds. 276–284.
- Marek and Truszczyński (1999) Marek, V. W. and Truszczyński, M. 1999. Stable Models and an Alternative Logic Programming Paradigm. In The Logic Programming Paradigm – A 25-Year Perspective, K. R. Apt, V. W. Marek, M. Truszczyński, and D. S. Warren, Eds. Springer Verlag, 375–398.
- Mushthofa et al. (2014) Mushthofa, M., Schockaert, S., and Cock, M. D. 2014. A finite-valued solver for disjunctive fuzzy answer set programs. In ECAI 2014 - 21st European Conference on Artificial Intelligence, 18-22 August 2014, Prague, Czech Republic, T. Schaub, G. Friedrich, and B. O’Sullivan, Eds. Frontiers in Artificial Intelligence and Applications, vol. 263. IOS Press, 645–650.
- Niemelä (1999) Niemelä, I. 1999. Logic programs with stable model semantics as a constraint programming paradigm. Ann. Math. Artif. Intell. 25, 3-4, 241–273.
- Niemelä (2008) Niemelä, I. 2008. Stable models and difference logic. Ann. Math. Artif. Intell. 53, 1-4, 313–329.
- Nieuwenborgh et al. (2007) Nieuwenborgh, D. V., Cock, M. D., and Vermeir, D. 2007. An introduction to fuzzy answer set programming. Ann. Math. Artif. Intell. 50, 3-4, 363–388.
- Ratschan (2006) Ratschan, S. 2006. Efficient solving of quantified inequality constraints over the real numbers. ACM Trans. Comput. Log. 7, 4, 723–748.

## Appendix A Proofs

\PropSimp* {proof} Since each rule is rewritten independently, we can prove , where is some rule in . We use structural induction on . The base case, i.e., is of the form with and , is trivial because . Now, consider of the form