Closed AbdallahS closed 5 days ago
This is indeed unfortunate. Now I should adjust gringo to not accumulate the elements twice. However, note that the aggregate is simplified before being passed to the solver. This is just not reflected in the text output.
Another issue is that the current aggregate implementation does not perform well, when we want to encode small checks in rule bodies. With the current implementation there is some redundant processing, I have been planning to ground stratified aggregates using some other implementation since a long time. I never came around to do it.
In your case (but not knowing the full context), I would try to avoid the aggregate altogether.
➜ gringo test.lp | lpconvert --text
{a(1)}.
{a(2)}.
{t}.
strange3(1) :- a(1), not t.
strange3(1) :- a(2), not t.
strange3(2) :- a(2), not t
Closing for now. This will be addressed in future clingo versions.
Given the following program
When I look at the rule for
strange3
, I expect the ground version to contain a number of rules that depend onI
, but I don't expect the number of elements in the aggregate to depend onI
. The rule forstrange4
is the blown-up version of it: for fixed valuesI=1
,J=1
,K=1
, I expect there to be a single rule with an aggregate over one element. Instead, the number of elements in the aggregate scales with the cross-product of the potential domain forI
,J
,K
(even though the concrete domain is a singleton, since these variables are fixed to1
).The output of
gringo --text
isSmall variations in the writing of the rule body that don't change the semantics let us recover an efficient grounding (see the
okay
rules).