HAL Id: hal-02452472
https://hal.archives-ouvertes.fr/hal-02452472
Submitted on 23 Jan 2020
HAL is a multi-disciplinary open access
archive for the deposit and dissemination of
sci-entific research documents, whether they are
pub-lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.
L’archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d’enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.
Gelfond-Zhang aggregates as propositional formulas
Pedro Cabalar, Jorge Fandinno, Torsten Schaub, Sebastian Schellhorn
To cite this version:
Pedro Cabalar, Jorge Fandinno, Torsten Schaub, Sebastian Schellhorn.
Gelfond-Zhang
ag-gregates as propositional formulas.
Artificial Intelligence, Elsevier, 2019, 274, pp.26-43.
OATAO is an open access repository that collects the work of Toulouse
researchers and makes it freely available over the web where possible
Any correspondence concerning this service should be sent
to the repository administrator: tech-oatao@listes-diff.inp-toulouse.fr
This is an author’s version published in: http://oatao.univ-toulouse.fr/24791
To cite this version:
Cabalar, Pedro and Fandinno, Jorge and Schaub, Torsten
and Schellhorn, Sebastian Gelfond-Zhang aggregates as
propositional formulas. (2019) Artificial Intelligence, 274.
26-43. ISSN 0004-3702
Official URL:
http://dx.doi.org/10.1016/j.artint.2018.10.007
Gelfond-Zhang aggregates as propositional formulas
*
Pedro Cabalar
a,*, 1•
Jorge
Fandinno
a,
d,
2•
Torsten Schaub
b,
c,*,
3.
4 3,
Sebastian Schellhorn
b,
• Universiry ofCorunna, Spainb Universiry of Potsdam, Gennany
c /NRJA, Rennes. France
d /RIT, Université de Toulouse, CNRS, Toulouse, France
Keywords:
Aggregares
Answer Set Programming
1. Introduction
ABSTRACT
Answer Set Programming (ASP) has become a popular and widespread paradigm for
practical Knowledge Representation thanks to its expressiveness and the available enhance
ments of its input language. One of such enhancements is the use of aggregates, for
which different semantic proposais have been made. In this paper, we show that any
ASP aggregate interpreted under Gelfond and Zhang's (GZ) semantics c.an be replaced
( under strong equivalence) by a propositional formula. Restricted to the original GZ
syntax, the resulting formula is reducible to a disjunction of conjunctions of literais
but the formulation is still applicable even when the syntax is extended to allow for
arbitrary formulas (including nested aggregates) in the condition. Once GZ-aggregates are
represented as formulas, we establish a formai comparison ( in terms of the logic of Here
and-There) to Ferraris' (F) aggregates, which are defined by a different formula translation
involving nested implications. ln particular, we prove that if we replace an F-aggregate
by a GZ-aggregate in a rule head, we do not (ose answer sets (although more can be
gained). This extends the previously known result that the opposite happens in rule bodies,
i.e., replacing a GZ-aggregate by an F-aggregate in the body may yield more answer sets.
Finally, we characterize a class of aggregates for which GZ- and F-semantics coïncide.
Knowledge Representation and Reasoning (KRR) has constitute
done of the central areas of Artificial Intelligence since its
very beginning an
d, in parti
cular, logic-based approa
ches have attracte
dmost of the interest in the literature. Although
"' This is an extended version of a conference paper at the 14th International Conference on logic Programming and Nonmonotonic Reasoning. Espoo, Finland, July 3-6, 2017, where it received a best technical paper award.* Corresponding authors.
E-mail addresses: cabalar@udc.es (P. Cabalar), jorge.fandino@udc.es, jorge.fandinno@irit.fr U- Fandinno), torsten@cs.uni-potsdam.de (T. Schaub), seschell@cs.uni-potsdam.de (S. Schellhorn).
1 Panially supponed by grants GPC-ED431B 2016/035 and 2016-2019 ED431G/01 (Xunta de Galicia, Spain), and TIN 2013-42149-P, TIN 2017-84453-P (MINECO, Spain).
2 Funded by the Centre International de Mathématiques et Informatique de Toulouse through contract ANR-11-LABEX-0040-0MI within the program ANR-11-IDEX-0002-02.
3 This work was panially funded by DFG gram SCHA 550/9.
4 Affiliated with the School of Computing Science at Simon Fraser University, Canada, and the lnstirute for Integrated and Intelligent Systems at Griffith University, Australia.
classicallogiccopeswithmanyoftheusualdesiderataforKRRsuchassimplicity,clearsemanticsorwell-knowninference methodsandtheirassociatedcomplexity,itwas soondetectedtofall shortforpracticalpurposes indifferentaspects.For instance, one crucialfeature in manyKRR scenarios, evenin extremelysimple ones, is the need todraw conclusions in absenceofinformation,somethingimpossibleinclassicallogicduetoitsmonotonicinferencerelation.Asaresult,sincethe introductionofthethreewell-knownapproaches,circumscription [1],defaultlogic [2] and modalnon-monotonic logics [3] in thehistorical specialissueofthe ArtificialIntelligence journalin1980, Non-MonotonicReasoning(NMR)hascentered great partofthediscussioninKRR.
Nowadays,AnswerSetProgramming (ASP [4])hasbecomeanestablishedproblem-solvingparadigmandaprimecandidate forpracticalKRR.Thereasonsforthissuccessaremanifold.Themostobviousoneistheavailabilityofeffectivesolvers [5,6] and a growing list of covered application domains [7]. A probably equally important reason is its declarative semantics, havingbeengeneralized fromtheoriginal stablemodels [8] of normallogicprogramsup toarbitraryfirst-order [9,10] and infinitary [11] formulas.SeverallogicalcharacterizationsofASPhavebeenobtained,amongwhichEquilibriumLogic [12] and its monotonic basis, the intermediate logic of Here-and-There (HT), are arguablythe most prominentones. These general-izations haveallowedustounderstandASPasagenerallogicalframeworkforNMR.Finally,athirdrelevantcauseofASP’s success lies in its flexible specification language [13],offering constructs especially useful forpractical KRR. Some of its distinctiveconstructsareaggregates, allowingforoperationsonsets ofelementssuchascountingthenumberofinstances forwhicha formula holds,oraddingall theinteger valuesforsome predicateargument.Tounderstandtheutility ofthis kindofconstraintsthinkaboutrepresentinginfirst-orderlogic, forinstance,that predicate p issatisfiedbyatleastn
=
3 differentindividuals.Atypicalformalizationwouldlooklike:∃
x∃
y∃
z(
p(
x)
∧
p(
y)
∧
p(
z)
∧
x=
y∧
y=
z∧
x=
z)
This pattern becomes obviously cumbersome when increasing the number n of individuals, as the number of required inequalities combinatorially explodes.Moreover, the formulaabove cannot be constructed ifn is an arbitraryparameter whose value isnot known beforehand.On theother hand, thissamemeaning can be simply capturedby a naturalASP aggregateoftheform
count
{
X:
p(
X)
}
≥
n.Unfortunately, there is no clear agreement on the expected behavior of aggregates in ASP, and several alternative seman-tics have been defined [14–19], among which perhaps Ferraris’ [17] and Faber et al.’s [18] are the two more consolidatedonesduetotheirrespectiveimplementationsintheASPsolvers
clingo
[5] andDLV
[6].Althoughthesetwo approachesmaydifferwhentheaggregatesareinthescopeofdefaultnegation,theycoincidefortherestofcases(likeall theexam-plesinthispaper),evenwhenaggregatesareinvolvedinrecursivedefinitions.Ferraris’(F-)aggregatesadditionally showaremarkable feature: theycan be expressed as propositional formulasin the logic of HT, something that greatly simplifiestheirformaltreatment.Toillustratethis,letusexplorethesimplerule:p
(
a)
← count{
X:
p(
X)
} ≥
n,
(1)where p
(
a)
recursivelydependsonthenumberofatomsoftheform p(
X)
.Supposefirstthatn=
1.Sincethedomainonly containsa,count
{
X:
p(
X)
} ≥
1 is trueiff p(
a)
holds.ThisiscapturedinFerraris’translationof (1) for n=
1 thatamounts to p(
a)
←
p(
a)
,a tautology whoseonlystable modelis∅
.Supposenow thatn=
0. Then,the aggregateisconsidered as tautologicaland theHT-translation of(1) corresponds to p(
a)
←
whoseunique stable modelis{
p(
a)
}
. Finally,asone moreelaboration,assumen=
1 andsupposeweaddthefactp(
b)
.Then,(1) becomestheformula p(
a)
←
p(
a)
∨
p(
b)
that, togetherwithfact p(
b)
,isHT-equivalentto:p
(
b).
p(
a)
←
p(
a).
p(
a)
←
p(
b).
(2) Thisresultsintheuniquestablemodel{
p(
a),
p(
b)
}
.Recently, GelfondandZhang [19] (GZ)proposed a morerestrictive interpretationofrecursive aggregatesthat imposes the so-called ViciousCirclePrinciple, namely, “noobjectorpropertycanbeintroducedbythedefinitionreferringtothetotality ofobjectssatisfyingthisproperty.” According to thisprinciple, ifwe havea program whose onlydefinition for p
(
a)
is (1), we mayleave p(
a)
false,butwe cannot be forcedtoderive its truth,since itdependson aset ofatoms{
X:
p(
X)
}
that includesp(
a)
itself.Inthisway,ifn=
1,theGZ-stablemodelfor(1) isalso∅
,asthereisnoneedtoassume p(
a)
.However, ifwe have n=
0, we cannot leave p(
a)
false anymore (the rule wouldhavea true body anda false head) and, atthe same time, p(
a)
cannot become truebecause it dependsona vicious circle. Something similar happensforn=
1 when addingfact p(
b)
.Asshownin [20],GZ-programsarestrongerthanF-programs inthesense that,whenthey representthe sameproblem,anyGZ-stablemodelisalsoan F-stablemodel,buttheoppositemaynothold(aswesawintheexamples above).Withoutenteringadiscussionofwhichsemanticsismoreintuitiveorsuitableforpracticalpurposes,oneobjective disadvantageofGZ-aggregatesisthattheylackedalogicalrepresentationsofar;theywereexclusivelydefinedintermsof areduct,somethingthatmadetheirformalanalysismorelimitedandthecomparisontoF-aggregatesmorecumbersome.Inthispaper,weshowthat,infact,itisalsopossibletounderstandaGZ-aggregate asapropositionalformula,classically equivalent tothe F-aggregate translation,butwitha differentmeaning in HT.Forinstance,theGZ-translation for (1) with
n
=
1 coincideswiththeF-encoding p(
a)
←
p(
a)
,butifwechangeton=
0 wegettheformulap(
a)
←
p(
a)
∨ ¬
p(
a)
whose antecedentisvalidinclassicallogic,butnotin HT.Infact,thewholeformulaisHT-equivalenttotheprogram:p
(
a)
←
p(
a).
p(
a)
← ¬
p(
a).
This makesit nowobviousthat thereisnostablemodel.Similarly, whenwe addfact p
(
b)
andn=
1,theGZ-translation eventuallyleadstothepropositionalprogram:p
(
b).
p
(
a)
← ¬
p(
a)
∧
p(
b).
p
(
a)
←
p(
a)
∧ ¬
p(
b).
p
(
a)
←
p(
a)
∧
p(
b).
(3) Again, it is classically equivalent to the F-translation(2), but quite different in logic programming, where the left rules enforcethenon-existenceofstable models.Therestofthepaperisorganizedasfollows.Inthenext section,we reviewsomebasicdefinitionsthatwillbeneeded through the paper.In Section 3,we presenta generalization ofFerraris’reductthat covers GZ-aggregatesandshow that the latter canbe replaced, under strongequivalence, by a propositional formula. InSection 4, we show that, ingeneral, GZ-aggregatesarestrongerthanF-aggregatesinHTand,asaresult,characterize the effectofreplacingsomeoccurrenceof a GZ-aggregateby acorrespondingF-aggregate. Wealsoidentifyafamilyofaggregatesinwhichbothsemantics coincide. InSection5,weliftthefragmentinwhichbothsemanticscoincidetotheirfirst-orderlanguages:
A
log andgringo
[21]. Finally,Section6concludesthepaper.2. Background
We beginby introducing some basic definitionsused inthe restof thepaper. Let
L
be some syntactic language and assume we have adefinition ofstablemodel foranytheory⊆
L
inthat syntax. Moreover, letSM()
denote thestable models of.Twotheories
,
arestronglyequivalent,written
≡
s,iffSM
(
∪ )
=
SM(
∪ )
foranytheory.We will providea strongerdefinitionof
≡
s forexpressions inL
.Let(
ϕ
)
denotesometheorywithadistinguishedoccurrence ofasubformulaϕ
andlet(ψ)
be theresultofreplacingthatoccurrenceϕ
byψ
in(
ϕ
)
.Twoexpressionsϕ
, ψ
∈
L
are said to be stronglyequivalent,also writtenϕ
≡
sψ
, when(
ϕ
)
≡
s(ψ)
foran arbitrary5(
ϕ
)
⊆
L
. We alsorecall next some basicdefinitions andresultsrelatedtothe logicofHere-and-There (HT). LetAt be aset ofgroundatomscalledthe propositionalsignature.Apropositionalformulaϕ
isdefinedusingthegrammar:ϕ
::= ⊥ |
a|
ϕ
∧
ϕ
|
ϕ
∨
ϕ
|
ϕ
→
ϕ
for any a∈
At.
We use Greek letters
ϕ
andψ
andtheir variants to stand forpropositional formulas. We define the derived operators¬
ϕ
def= (
ϕ
→ ⊥)
,ϕ
↔ ψ
def= (
ϕ
→ ψ)
∧ (ψ →
ϕ
)
anddef
= ¬⊥
.Aclassicalinterpretation T isasetofatomsT
⊆
At.Wewrite|=
cltostandbothforclassicalsatisfactionandentailment, and≡
clrepresentsclassicalequivalence.AnHT-interpretation isapairH,
TofsetsofatomsH⊆
T⊆
At.Definition1(HT-satisfaction).An interpretation
H,
T satisfies a formulaϕ
, written H,
T|=
ϕ
, if any of the following recursiveconditionsholds:•
H,
T|= ⊥
•
H,
T|=
p iff p∈
H,
for any atom p•
H,
T|=
ϕ1
∧
ϕ2
iff H,
T|=
ϕ1
andH,
T|=
ϕ2
•
H,
T|=
ϕ1
∨
ϕ2
iff H,
T|=
ϕ1
orH,
T|=
ϕ2
•
H,
T|=
ϕ1
→
ϕ2
iff both:(i) T
|=cl
ϕ1
→
ϕ2
and(ii)
H,
T|=
ϕ1
orH,
T|=
ϕ2
2
Itisnotdifficulttoseethat
T,
T|=
ϕ
iffT|=
clϕ
.A(propositional)theory isasetofpropositionalformulas.An interpre-tationH,
Tisamodel ofatheorywhenH
,
T|=
ϕ
forallϕ
∈
.Atheoryentails aformula
ϕ
,written|=
ϕ
,when allmodelsofsatisfy
ϕ
.Twotheories,
are(HT)-equivalent,written
≡
,iftheysharethesamesetofmodels. Definition2(Equilibrium/stablemodel).AtotalinterpretationT,
Tisanequilibriummodel ofaformulaϕ
iffT,
T|=
ϕ
and thereisno H⊂
T suchthatH,
T|=
ϕ
.Ifso,wesaythat T isastablemodel ofϕ
.2
5 Notethat,forarbitrarylanguagesandsemantics,thisdefinitionisstrongerthanusual,asitrefersto
any subformula replacement and
notjust conjunc-tionsofformulas,asusual.Forinstance,ϕ≡sψalsoimplies{ϕ⊗α}≡s{ψ ⊗α}foranybinaryoperator⊗inourlanguage.WhenLisalogicallanguage and≡samountstoequivalenceinHT(oranylogicwithsubstitutionofequivalents)thedistinctionbecomesirrelevant.Proposition1.ThefollowingaregeneralpropertiesofHT: i) if
H,
T|=
ϕ
thenT,
T|=
ϕ
(i.e.,T|=
clϕ
) ii) H,
T|= ¬
ϕ
iffT|=
cl¬
ϕ
.2
Definition3(Ferraris’reduct).Thereductofaformula
ϕ
withrespecttoaninterpretationT ,writtenϕ
T,isdefinedas:ϕ
T def=
⎧
⎨
⎩
⊥
if T|=cl
ϕ
a ifϕ
is some atom a∈
Tϕ
T1
⊗
ϕ
2T if T|=cl
ϕ
andϕ
= (
ϕ
1⊗
ϕ
2)
for some⊗ ∈ {∧, ∨, →}
2
Thatis,ϕ
T istheresultofreplacingby⊥
eachmaximalsubformulaψ
ofϕ
s.t. T|=
cl
ψ
.Proposition2(Lemma 1in [22]).ForanypairofinterpretationsH
⊆
T andanyϕ
:H|=
clϕ
TiffH,
T|=
ϕ
.2
Asiswell-known, strongequivalenceforpropositionalformulascorresponds toHT-equivalence [23],that is,
ϕ
≡
sψ
iffϕ
≡ ψ
inthatlanguage.ThefollowingresultfollowsfromCorollary 3in [24].Proposition3.If
ϕ
|= ψ
andϕ
≡
clψ
,thenSM(
ϕ
)
⊇
SM(ψ)
.2
Inother words,if
ϕ
isstrongerthanψ
inHT(andso,inclassical logictoo),butthey furtherhappento beclassically equivalent,thenϕ
isweakerwithrespecttostablemodels.Asanexample,notethat(
p∨
q)
|= (¬
p→
q)
.Astheyare clas-sically equivalent,SM(
p∨
q)
⊇
SM(
¬
p→
q)
whichisnotsuch astrongresult. However,since HT-entailment ismonotonic withrespecttoconjunction,itfollowsthat(
p∨
q)
∧
γ
|= (¬
p→
q)
∧
γ
alsoholdsforanyγ
,andthus,ifwereplacea dis-junctiverule(
p∨
q)
by(
¬
p→
q)
inanyprogramwemaylosesomestablemodels,buttheremainingarestillapplicableto(
p∨
q)
.Wecangeneralizethisbehaviornotonlyonconjunctions,butalsotocoverthereplacementofanysubformulaϕ
. We saythat an occurrenceϕ
ofa formulaispositive in a theory(
ϕ
)
ifthenumberof implicationsin(
ϕ
)
containing occurrenceϕ
intheantecedentiseven.Itiscallednegative otherwise.Proposition4.Let
ϕ
andψ
betwoformulassatisfyingϕ
|= ψ
andϕ
≡
clψ
.Then: i) SM((
ϕ
))
⊇
SM((ψ))
foranytheory(
ϕ
)
whereoccurrenceϕ
ispositive; ii) SM((
ϕ
))
⊆
SM((ψ))
foranytheory(
ϕ
)
whereoccurrenceϕ
isnegative.2
Backtotheexample,notethat
(
p∨
q)
occurspositivelyin(
p∨
q)
∧
γ
andso,(
¬
p→
q)
∧
γ
hasasubsetofstablemodels. Ontheotherhand,itoccursnegativelyin(
p∨
q)
→
γ
,andso,(
¬
p→
q)
→
γ
hasasupersetofstablemodels.3. Aggregatesasformulas
Todealwithaggregates,weconsiderasimplifiedfirst-order6 signature
=
C, A, P
formedbythreepairwisedisjoint setsrespectivelycalledconstants,aggregatesymbols andpredicatesymbols.Anarithmeticterm isacombinationofnumerical constants, variablesandarithmetic operatorsbuiltinthe usualway.A term iseithera constantc∈
C
,a variable X or an arithmetic term.We usethevector overlinetorepresenttuplesof terms,suchast,andwrite|
t|
tostandforthe tuple’s arity. As usual, a predicateatom isan expression ofthe form p(
t)
wheret isa tuple ofterms; an arithmeticatom is an expressionoftheformt≺
twitht andt arithmetictermsand≺∈ {=, =, ≤, ≥, <, >}
anarithmeticrelation.Aregularatom iseitherapredicateatomoranarithmeticatom.An(aggregate)formulaϕ
isrecursivelydefinedbythefollowinggrammar:ϕ
::= ⊥ |
a|
f{
X:
ϕ
} ≺
t|
f{
c:
ϕ
, . . . ,
c:
ϕ
} ≺
t|
ϕ
∧
ϕ
|
ϕ
∨
ϕ
|
ϕ
→
ϕ
where a is regular atom, f
∈
A
is an aggregate symbol, X is a non-empty tuple of variables, c is a non-empty tuple ofconstants,≺∈ {=,
=,
≤,
≥,
<,
>
}
is an arithmetic relation,andt isan arithmetic term. A (aggregate)theory isa set of aggregateformulas.Aswe cansee,we distinguishtwotypesofaggregates: f{
X:
ϕ
} ≺
t calledGZ-aggregates (or setatoms); and f{
c1:
ϕ
1, . . . ,
cm:
ϕ
m} ≺
t,with all ci of samearity, calledF-aggregates.This syntactic distinctionrespects the original syntax7 alsoturnsout tobe convenientforcomparisonpurposes,since we canassigna differentsemanticsto each type of aggregate withoutambiguity. An important observationis that,in our generallanguage, it ispossible to nest GZ and F-aggregatesin a completely arbitraryway,sinceϕ
andϕ
1,
. . . ,
ϕm
inside bracketsare aggregate formulas intheir turn.6 Anextensiontoafullfirst-orderlanguageisunderdevelopment. 7 Ferrarisactuallyusesϕ
Achieving thisgeneralization isnot surprising,onceaggregatescan beseenaspropositionalformulas.AGZ-formula (resp. F-formula) is one inwhich all its aggregatesare GZ-aggregates (resp. F-aggregates). We sometimes informally talkabout rules (resp.programs)insteadofformulas(resp.theories)whenthesyntaxcoincideswiththeusualinlogicprogramming.
The technical treatment of F-aggregates is directly extracted from [17], so the focus in this section is put on GZ-aggregates, where our contribution lies.One oftheir distinctive features is the use of variables X .
In fact, a formulaϕ
inside A=
f{
X:
ϕ
}
≺
t (calledthe condition of A) normallycontains occurrencesof X ,so weusually write itascond(
X)
. Moreover, theoccurrencesofvariables X in A aresaidtobebound to A.Avariableoccurrence X inaformulaϕ
isfree if itisnotboundtoanyGZ-aggregateinϕ
.Anatom iseitheraregularatom(predicateorarithmetic atom)oran aggregate. A (regular)literal is eithera (regular) atom a (positive literal)or its defaultnegation not a (negativeliteral). Apredicate atom p(
t)
issaid to be ground iff all its terms are constants t⊆
C
|t|; an arithmetic atom t≺
t issaid to be ground iff t and t are numbers; andan aggregate atom f{. . . } ≺
t issaid tobe ground iff itcontains no free variables8 andt is a number. We write At(C,
P)
to stand forthe set of groundatomsfor predicatesP
and constantsC
. A theory is said to be ground iff all atomsoccurring init are ground. We define thegrounding ofa formulaϕ
(
X)
withfree variables X as expected:Gr
(
ϕ
(
X))
def= {
ϕ
(
c)
|
c∈
C
| X|}
whereϕ
(
c
)
is the result ofreplacing all occurrences ofthe variables X inϕ
(
X)
by the constants in
c andevaluating all arithmetic terms.Similarly, byGr
()
def=
{Gr(
ϕ
(
X))
|
ϕ
(
X)
∈ }
we denote the groundingofanytheory.UntilSection5,we willexclusivelydealwithgroundtheories.Thisisnotalimitation,since a non-groundformula
ϕ
(
X)
insometheorycanbeunderstoodasanabbreviationofitsgroundingGr
(
ϕ
(
X))
,asusual.Given asetofformulasS,wewriteS andS tostandfortheirconjunctionanddisjunction,respectively;welet
∅ = ⊥
and∅ =
.To definethe semantics,we assume thatfor allaggregate symbols f
∈
A
andarities m≥
1,there existsa predefined associatedpartialfunctionˆ
fm:
2Cm
→ Z
that,foreachset S ofm-tuplesofconstants,eitherreturnsanumberˆ
fm(
S)
oris undefined.Thispredefinedvalueistheexpectedonefortheusualaggregatefunctionssum
,
count
,
max
, etc.Forexample, foraggregate symbolsum
andaritym=
1 the functionreturns theaggregateaddition whenthesetconsistsof(1-tuples of) integer numbers. Forinstance,sum
1(
{
7,
2,
−
4})
=
5 andsum
1(
∅)
=
0 butsum
1(
{
7,
a,
3,
b})
is undefined. For integer aggregatefunctionsofaritym>
1,weassumethattheaggregateisappliedontheleftmostelementsinthetupleswhenall ofthemareinteger,sothat,forinstance,sum
2(
{
7,
a,
2,
b,
2,
a})
=
11.Weomitthearitywhenclearfromthe context.Aclassicalinterpretation T isasetofgroundatomsT
⊆
At(
C,
P)
.Definition4.AclassicalinterpretationT satisfies aformula
ϕ
,denotedbyT|=
clϕ
,whenthefollowingrecursiveconditions hold:•
T|=cl
⊥
•
T|=cl
p(
c)
iff p(
c)
∈
T for any ground atom p(
c)
•
T|=cl
f{
X:
cond(
X)
} ≺
n iffˆ
f| X|{
c∈
C
| X||
T|=cl
cond(
c)
}
has some value k
∈ Z
and k≺
n under the usual meaning of arithmetic relation≺
•
T|=cl
f{
c1:
ϕ1
, . . . ,
cm:
ϕ
m} ≺n iffˆ
f|c1|{
ci|
T|=cl
ϕ
i}
has some value k
∈ Z
and k≺
n,
again, under its usual meaning•
T|=cl
ϕ1
∧
ϕ2
iff T|=cl
ϕ1
and T|=cl
ϕ2
•
T|=cl
ϕ1
∨
ϕ2
iff T|=cl
ϕ1
or T|=cl
ϕ2
•
T|=cl
ϕ1
→
ϕ2
iff T|=cl
ϕ1
or T|=cl
ϕ2
WesaythatT isa(classical)model ofatheory
iffT
|=
clϕ
forallϕ
∈
.2
GiveninterpretationT ,wedivideanytheoryintothetwodisjointsubsets:
+T def
= {
ϕ
∈ |
T|=cl
ϕ
}
−T def
= \
+Tthatis,theformulasin
satisfiedbyT andnotsatisfiedbyT ,respectively.Whenset
isparametrized,say
(
z)
,wewrite+T
(
z)
and−T
(
z)
insteadof(
z)
+T and(
z)
−T.Forinstance,Gr
+T(
ϕ
)
collectstheformulasfromGr
(
ϕ
)
satisfiedby T .Definition5(Reduct).Wewilldefinethereduct ofaGZ-aggregateformula A
=
f{
X:
cond(
X)
} ≺
n withrespecttoaclassical interpretation T ,denotedasAT,inthefollowingway:AT def
=
⊥
if T|=
clAGr
+T(
cond(
X))
T
otherwiseThereductofanF-aggregate B
=
f{
c1:
ϕ
1, . . . ,
cm:
ϕ
m} ≺
n istheformula: BT def=
⊥
if T|=cl
Bf
{
c1:
ϕ
1T, . . . ,
cm:
ϕ
m} ≺T n otherwiseThereductofanyotherformulaisjustasinDefinition3.Thereductofatheoryisthesetofreductsofitsformulas.
2
Definition6(Stablemodel).Aclassicalinterpretation T isastablemodel ofatheoryiffT isa
⊆
-minimalmodelofT.
2
Note that,when restricted toF-formulas, Definition 3exactly matches thereduct definitionfor aggregate theoriesby Ferraris [17].Ontheotherhand,whenrestrictedtoGZ-formulas,itgeneralizes thereductdefinitionbyGelfond–Zhang [19] allowingarbitraryformulasincond
(
X)
,includingnestedaggregates.Forthisreason,inoursetting,thereductisrecursively appliedto(
Gr
+T(
cond(
X)))
T.Intheoriginalcase [19],cond(
X)
wasaconjunctionofatoms,butitisstraightforwardtosee that,then,(
Gr
+T(
cond(
X)))
T=
Gr
+T(
cond(
X))
.Tosumup,theabovedefinitionsofstablemodelandreductcorrespond totheoriginalonesforFerraris [17] andGelfond–Zhang [19] whenrestrictedtotheirrespectivesyntacticfragments. Proposition5.Stablemodelsareclassicalmodels.2
Example1.Let P1 be the program consistingof fact p
(
b)
and rule (1) with n=
1, and let A1 be the GZ-aggregate in that rule.We showthat P1 hasnostablemodels. Givengroundatoms p(
a)
and p(
b)
,the onlymodelofthe programis T= {
p(
a),
p(
b)
}
,since p(
b)
isfixedasafact,andso, A1 mustbetrue,so (1) entails p(
a)
too.Since T|=
clA1,thereduct becomes AT1
=
p(
a)
∧
p(
b)
,andso, P1T containstherules p(
b)
andp(
a)
←
p(
a)
∧
p(
b)
,theirleastmodelbeing{
p(
b)
}
,soT isnotstable.Asanotherexampleoftheaggregatereduct,ifwetookT= ∅
,then T|=
clA1and AT1= ⊥
.2
Example2.AsanexampleofnestedGZ-aggregates,consider:
A2
= count
X
: sum{
Y:
owns(
X,
Y)
} ≥
10≥
2andimaginethatowns
(
X,
Y)
meansthat X ownssomeitemY whosecostisalsoY .Accordingly, A2 checkswhetherthere are2 ormorepersons X thatownitemsforatotalcostofatleast10.Supposewehavetheinterpretation:T
= {
owns(
a,
6),
owns(
a,
8),
owns(
b,
2),
owns(
b,
3),
owns(
c,
12)
}
Then A2 holdsinT sincebotha andc havetotalvaluesgreaterthan10:14 fora and 12 forc.Therefore, AT2 corresponds to
(
Gr
+T(sum
{
Y:
owns(
X,
Y)
}
≥
10))
T.Aftergroundingfreevariable X ,weobtain:(sum
{
Y:
owns(
a,
Y)
} ≥
10∧ sum{
Y:
owns(
c,
Y)
} ≥
10)
TNotethatb doesnotoccur,sinceitstotalsumislowerthan10 inT .Ifwe applyagainthereducttotheconjunctsabove, weeventuallyobtaintheconjunction:owns
(
a,
6)
∧
owns(
a,
8)
∧
owns(
c,
12)
.2
Proposition6.Givenformulas
ϕ
andψ
,thefollowingconditionshold: i) H|=
clϕ
TimpliesT|=
clϕ
,andii) T
|=
clϕ
TiffT|=
clϕ
foranypairofinterpretationsH
⊆
T .Furthermore,thefollowingconditionalsoholdsiii) ifH
|=
clϕ
TiffH|=
clψ
TforallinterpretationsH⊆
T ,thenϕ
andψ
arestronglyequivalent,ϕ
≡
sψ
.2
Proposition 6 generalizes results from [17] to our extended language combiningGZ andF-aggregates. Inparticular, item iii) provides a sufficient condition for strong equivalence that, in the case of propositional formulas, amounts to HT-equivalence.
Wenow movetoconsiderpropositional translationsofaggregates.As saidintheintroduction,anyF-aggregatecan be understoodasapropositionalformula.TakeanyF-aggregateB
=
f{
c1:
ϕ
1,
. . . ,
cm:
ϕ
m}
≺
n whereallformulasin{
ϕ
1,
. . . ,
ϕm
}
arepropositional–moreover,letuscallconds (theconditions)tothissetofformulas.By[
B]
,wedenotethepropositional formula:[
B]
def=
T:T|=clBconds+T
→
conds−T (4) ThefollowingresultdirectlyfollowsfromProposition 12in [17].
Proposition7.ForanyF-aggregate B withpropositionalconditions,wehaveB
≡
s[
B]
.2
GivenanF-formula
ϕ
,wecandefineits(stronglyequivalent)propositionaltranslation[
ϕ
]
astheresultofthe exhaus-tivereplacementofnon-nestedaggregatesB by[
B]
untilallaggregatesareeventuallyremoved.Our main contribution is to provide an analogouspropositional encoding for GZ-aggregates. To this aim, we extend translation
tobealso applicabletoanyGZ-aggregate A
=
f{
X:
cond(
X)
} ≺
n withapropositional condition cond(
X)
,so that[
A]
correspondstothepropositionalformula:[
A]
def=
T:T|=clAGr
+T(
cond(
X))
∧ ¬
Gr
−T(
cond(
X))
(5)Proposition8.ForanyGZ-aggregateA withapropositionalcondition,wehaveA
≡
s[
A]
.2
Thisresultallowsustodefine, foranyarbitrary aggregateformula
ϕ
,its(strongly equivalent)propositionaltranslation[
ϕ
]
,againbyexhaustivereplacementofnon-nestedaggregates(nowofanykind)C bytheirpropositionalformulas[
C]
. Foranytheory,its(stronglyequivalent)propositionaltranslationisdefinedas
[]
def= { [
ϕ
]
|
ϕ
∈ }
.Example3.Takeagaintheaggregate A1 inthebodyofrule (1) withn
=
1 andassumewehaveconstantsa,
b.Theclassical modelsof A1are{
p(
a)
}
,{
p(
b)
}
and{
p(
a),
p(
b)
}
,sincesomeatom p(
X)
musthold.Asaresult:[
A1] =
p(
a)
∧¬
p(
b)
∨
p(
b)
∧¬
p(
a)
∨
p(
a)
∧
p(
b)
and[
(1)]
amountstothelastthreerulesin (3).2
Example4.TakeGZ-aggregate A3
= count{
X:
p(
X)
}
=
1 andassumewehaveconstantsC = {
a,
b,
c}
.Theclassicalmodels of A3 are{
p(
a)
}
,{
p(
b)
}
and{
p(
c)
}
.Accordingly:[
A3] =
p(
a)
∧ ¬(
p(
b)
∨
p(
c))
∨
p(
b)
∧ ¬(
p(
a)
∨
p(
c))
∨
p(
c)
∧ ¬(
p(
a)
∨
p(
b))
≡
p(
a)
∧ ¬
p(
b)
∧ ¬
p(
c)
∨
p(
b)
∧ ¬
p(
a)
∧ ¬
p(
c)
∨
p(
c)
∧ ¬
p(
a)
∧ ¬
p(
b)
Theorem1(Mainresult).Anyaggregatetheory
isstronglyequivalenttoitspropositionaltranslation
[]
,thatis,≡
s[]
.2
4. RelationtoFerrarisaggregates
In this section, we study the relation between GZ and F-aggregates. One first observation is that GZ-aggregates are first-orderstructureswithquantifiedvariables, whileF-aggregatesallow setsofpropositional expressions.Encodinga GZ-aggregate asanF-aggregateiseasy:wecanjustgroundthevariables.Theother direction,however,isnotalwayspossible, sincethesetofconditionsintheF-aggregatemaynothavearegularrepresentationintermsofvariablesubstitutions.Given aGZ-aggregate A
=
f{
X:
cond(
X)
}
≺
n wedefineitscorrespondingF-aggregateF
[
A]
:F
[
A]
def=
f{
c:
cond(
c)
|
cond(
c)
∈ Gr(
cond(
X))
} ≺
n (6)Thiscorrespondenceisanalogoustotheprocessofinstantiation usedin [18] togroundaggregateswithvariables.Itiseasy tocheckthat A and
F
[
A]
areclassicallyequivalent.ThiscanbecheckedusingsatisfactionfromDefinition4orclassicallogic fortheirpropositionalrepresentations[
A]
≡
cl[F[
A]]
.Moreover,itcanbeobservedthatthesetwologicalrepresentations aresomehowdual.Indeed,[F[
A]]
eventuallyamountsto:[F[
A]] ≡
T:T|=clAGr
+T(
cond(
X))
→
Gr
−T(
cond(
X))
(7)which is a conjunction of formulas like
α
→ β
for countermodels of A, whereas[
A]
, formula (5), is a disjunction of formulas likeα
∧ ¬β
formodels of A.Anotherinteresting consequenceoftheclassicalequivalenceof A andF
[
A]
isthat, duetoProposition1-ii),wecansafelyreplaceonebyanotherwhennegated.Inotherwords:Proposition9.Let
ϕ
beaformulawithsomeoccurrenceofaGZ-aggregateA andletψ
betheresultofreplacingA byitscorresponding F-aggregateF
[
A]
inϕ
.Then,wehavethat¬
ϕ
≡ ¬ψ
.2
However,aswesawintheintroductionexamples,replacingsome GZ-aggregate A byitsF-aggregateversion
F
[
A]
may changetheprogramsemantics.Still,thestablemodelsobtainedaftersuch replacementarenotarbitrary.Aswe said, [20] provedthat iftheGZ-aggregate A occursinapositive rulebody,thenthereplacementby theF-aggregateF
[
A]
preserves thestablemodels,butmayyieldmore.Next,wegeneralize thisresulttoaggregatetheorieswithoutnestedGZ-aggregates. Tothisaim,wemakeuseofthefollowingpropositionassertingthat,indeed,[
A]
isstrongerthan[F[
A]]
inHT. Proposition10.ForanyGZ-aggregateA,[
A]
|= [F[
A]]
.2
Theorem2.ForanyoccurrenceA ofaGZ-aggregatewithoutnestedaggregates: i) SM
((
A))
⊇
SM((F
[
A]))
foranytheory(
A)
whereoccurrenceA ispositive; ii) SM((
A))
⊆
SM((F
[
A]))
foranytheory(
A)
whereoccurrenceA isnegative.2
Proof. From[
A]
≡
cl[F[
A]]
andProposition10wedirectlyapplyProposition4.2
In particular,this meansthat if we replacea (non-nested)GZ-aggregate A by itsF-version
F
[
A]
in the positive head ofsome rule,we still get stablemodels ofthe original program,but perhapsnot all of them.Theorem 2 is notdirectly applicable to theories with nestedaggregates because applyingoperator[
·
]
produces a new formulain which nested aggregatesmayoccurbothpositivelyandnegatively.Itis wellknownthat GZandF-semantics donotagreeeven inthecaseofmonotonicaggregatesasillustratedby the exampleintheintroduction.Nevertheless,weidentifynextamorerestrictedfamilyofaggregatesforwhichbothsemantics coincide.
Proposition11.AnyGZ-aggregateA ofthefollowingtypessatisfiesA
≡
sF
[
A]
: i) A= (count{
X:
cond(
X)
} =
n)
ii) A
= (sum{
X,
Y:
cond(
X,
Y)
∧
X>
0} =
n)
iii) A
= (sum{
X,
Y:
cond(
X,
Y)
∧
X<
0} =
n)
.2
Note that the resultii (resp. iii) of Proposition 11 does not apply if the condition X
>
0 (resp. X<
0) is dropped. For instance,theprogramconsistingoftherulep
(
0)
← sum{
X:
p(
X)
} =
0 (8)hasauniquestablemodel
{
p(
0)
}
underFerraris’semanticbutnostablemodelunderGZ’s one. 5. RelationbetweenA
log andclingoaggregatesInthissection,werestrictourselvestothesyntaxoflogicprogrammingandlifttherelationbetweenGZandF-aggregates totheirrespectivefirstorderlanguages,studyingasyntacticfragmentinwhichthesemanticsof
A
log [19] andgringo
[21] coincide.We alsoshowthat everyA
log programwhoseaggregatesare allofcount
typecan be easilyrewrittento this fragment ina human friendlyway. Thesame applies toprogram that also containsum
aggregatesprovided that 0 does notoccurasaconstantintheprogram.ItisworthmentioningthatacompilationforGZ-aggregatesintoF-aggregateshas alreadybeendescribedintheliterature [25].Thiscompilationhastheadvantageofcoveringprogramscontaininganykind ofaggregates.Ontheotherhand,itmakesusesofnewauxiliaryatomsthatobscurethesemanticsoftheprogram.Inthis sense,thiscompilationisbettersuitedforautomatictranslationwhileourrewriting,thoughlessgeneral,preserveshuman readability.An
A
log rule isanexpressionoftheform:Head
←
Pos∧
Neg∧
Agg (9)whereHead isadisjunctionofatoms,Pos isaconjunctionofregularatoms,Neg isaconjunctionofnegativeregularliterals, andAgg isaconjunctionofGZ-aggregates.An
A
log program isasetofA
log rules.Recallthat,inthissection,wenolonger assume that atomsor programs are ground. Note that everyA
log program isalso a program inthe syntax ofgringo
, though their semantic may differ. We also recall the notion of globalvariable from [21]: a variable is said to be global in a rule ofthe form of (9) iff it occursin any literal in Pos or Neg or in anyterm t of anyaggregate atom inAgg of the form f{
X:
cond(
X)
} ≺
t.An instance of arule isobtained byreplacing all globalvariables by constants. Thegringo
every aggregate atom A by
F
[
A]
. Asetofatoms T isagringo
stablemodelofaprogramiffitisa stablemodelof
Gr
gringo()
.Notethatnotionsofglobalandfreevariablesdonotcoincide:anoccurrenceofavariablemaybebothglobalandbound. Thisimpliesthat the
A
log andgringo
grounding ofaprogram maybedifferentand, asa result,the same programmayhavedifferentstablemodels.Toillustratethisfact,considerthefollowingexamplefrom [19]:Example5.LetP2consistingofthefollowingrules
r
← count{
X:
p(
X)
} ≥
2∧
q(
X)
(10)p
(
a)
p
(
b)
q
(
a)
Variable X isbothglobalin (10) andboundin
count
{
X:
p(
X)
}
≥
2.Asaresult,theA
log groundingof P2 isobtainedby replacingrule (10) byrulesr
← count{
X:
p(
X)
} ≥
2∧
q(
a)
r
← count{
X:
p(
X)
} ≥
2∧
q(
b)
Ontheotherhand,itsclingogroundingisobtainedbyreplacingthesameruleby
r
← count{
a:
p(
a)
} ≥
2∧
q(
a)
r
← count{
b:
p(
b)
} ≥
2∧
q(
b)
Both programshaveauniquestablemodel,butadifferentone:
{
p(
a),
p(
b),
q(
a),
r}
fortheformerand{
p(
a),
p(
b),
q(
a)
}
for thelatter.2
We saythat an aggregate atom isclosed [26] iff no globalvariableoccursinit. Wesay thata rule (resp.program)is closed if allits aggregateatomsare closed.Then,fromProposition11,we immediatelygetthefollowingresultforclosed programs:
Proposition12.Let
beaclosedlogicprogramwhereallaggregateatomsareoftheform
count
{
X:
cond(
X)
}
=
t.Then,thestable modelofwithrespectto
A
log andgringo
coincide.2
An interesting property of
A
log isthat we can rewrite anylogic program asan equivalent closedprogram where all aggregateconditionsareequalities.Definition7.Givenalogicprogram
,bytr1
()
wedenotetheresultofreplacingi) everyoccurrenceofaglobalvariablethatisalsoboundtosomeaggregate A byasamenewfreshvariablenotoccurring anywhereelse,and
ii) everyaggregate f
{
X:
cond(
X,
Y)
}
≺
t with≺
differentfrom=
,by theformula f{
X:
cond(
X,
Y)
}
=
Z∧
Z≺
t with Z alsoanewfreshvariablenotoccurringanywhereelse.2
Proposition13.Givenalogicprogram
,the
A
log stablemodelsofandtr1
()
coincide.2
From Proposition12and Proposition13itimmediatelyfollowsthatwecanrewriteany
A
log programwhereall aggre-gatesareofthetypecount
intoanequivalentoneinwhichitsstablemodelscoincidewiththegringo
stablemodels.Theorem3.Givenalogicprogram
whereallaggregateatomsareoftheform
count
{
X:
cond(
X)
}
=
t,thentheA
log stablemodels ofcoincidewiththe
gringo
stablemodelsoftr1()
.2
Example6(Ex.5continued).Asmentionedabove, P2isaprogramwhosestablemodelsaredifferentaccordingto
A
log andgringo
semantics.Ontheotherhand,wehavethattr1(
P2)
isr
← count{
Y:
p(
Y)
} =
Z∧
Z≥
2∧
q(
X)
(11)p
(
a)
p
(
b)
whoseuniquestablemodelis
{
p(
a),
p(
b),
q,
r}
accordingtobothsemantics.Recallthatthisisthe unique stablemodelof P2 accordingtoA
log.As afurtherexample,let P3 bethelogicprogramconsistingofrule (1) withn=
1.Recallfromthe introductionthat P3 hasa unique stablemodel{
p(
a)
}
accordingto Ferraris semanticswhile itdoesnot have anystable modelsemantics accordingto Gelfond andZhangsemantics. Notethat, since thisprogram isground,gringo
andA
log semanticsrespectivelycoincidewithFerrarisandGelfondandZhangsemanticsasdescribedinSection3.Furthermore,we havethattr1(
P3)
isp
(
a)
← count{
X:
p(
X)
} =
Z∧
Z≥
0 whichhasnostablemodelunderbothsemantics.2
Notethat,ingeneral,therewritingtr1
(
·)
isnotsafeforotherkindsofaggregateswithanassociatedfunction f forwhich thereexistsets S and Swith S⊂
S suchthat f(
S)
=
f(
S)
.Forinstance,thesumoftheemptysetandtheset{
1,
−
1}
is inbothcases0 and,asaresult,wehavethatprogramsinvolvingsumoverthesetwosetswillhavedifferentstablemodels. Example7.Let P4 bethelogicprogramconsistingofthefollowingrules:p
(
1)
← sum{
X:
p(
X)
} =
0 (12)p
(
1)
←
p(
−
1)
p
(
−
1)
←
p(
1)
It iseasy tocheck that tr1
(
P4)
=
P4,butthisprogram hasno stablemodelundertheA
log semanticsandhasa unique stablemodel{
p(
1),
p(
−
1)
}
underthegringo
semantics.2
6. Conclusions
Wehaveprovideda(strongequivalencepreserving)translationfromlogicprogramswithGZ-aggregatestopropositional theoriesinEquilibriumLogic.Onceweunderstandaggregatesaspropositionalformulas,itisstraightforwardto extendthe syntax toarbitrary nesting ofaggregates(bothGZ andF-aggregates)plus propositional connectives,something we called aggregatetheories.Wehaveprovidedtwo alternativesemanticsforthesetheories:onebasedonadirect,combined exten-sionof GZand F-reducts,andtheother on a translationtopropositional formulas. Thepropositional formulatranslation has helpedus tocharacterize the effect (withrespect to the obtainedstable models)of replacing a GZ-aggregate by its correspondingF-aggregate.Moreover,wehavebeenabletoprovethatbothaggregateshavethesamebehavior inthescope ofnegation.Finally,we identifieda classofaggregatesinwhich theGZandF-semantics coincide.Itisworth to mention thatapropositional formula9 equivalent toSonandPontelliaggregateswasalsogivenin [16].Weexpect thatthecurrent propositional formulatranslationswill opennewpossibilities to exploreformal propertiesandpotential implementations ofbothGZandF-aggregates, possiblyextendingtheideaof [20] toourgeneralaggregatetheories.Finally,anextension of thecurrentapproachtoafullfirst-orderlanguagewithpartial,evaluablefunctions(asthosein [27])wasdevelopedin [28]. Thisallowstreatingaggregatesasordinaryfirst-ordertermsandcombinethemwitharbitrarypredicates,notjustarithmetic relations.
Appendix A. Proofs
ProofofProposition4. First,notethat
ϕ
≡
clψ
implies(
ϕ
)
≡
cl(ψ)
duetosubstitutionofequivalentsinclassicallogic, regardlesswhetherϕ
occurspositivelyornegativelyin(
ϕ
)
.Ontheother hand,HTsatisfiestheDeductionTheorem,i.e.,ϕ
|= ψ
iffϕ
→ ψ
isvalidand,fromthelatter,wecanderivethefollowingintuitionisticconsequences:(
ϕ
∧
γ
)
→ (ψ ∧
γ
)
(
ϕ
∨
γ
)
→ (ψ ∨
γ
)
(
γ
→
ϕ
)
→ (
γ
→ ψ)
(ψ
→
γ
)
→ (
ϕ
→
γ
)
whicharealsoconsequencesintheintermediatelogicofHT.Asaresult,if