potassco / potassco/constraint-handler
Twice the amount of variables needed
@AbdallahS is already working on this.
Since Apr 22, 2026.
- Dominant language
- Python
- Stars
- 3
- Forks
- 0
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 20
Description
For the well known example:
#const int_domain_size = 10000.
variable_declare(assign_x, x, fromFacts).
variable_domain(x, val(int, 1..int_domain_size)).
in direct.lp you have the rules:
_se_value(variable(X),V) :- direct_query(variable(X)), _se_assign(NAME,variable(X),E2), _se_value(E2,V), usc_active(NAME).
this is the reason we have double the variables, as it grounds to:
_se_value(variable(x),val(int,10000)):-_se_assign(_label_anonymous,variable(x),val(int,10000)),direct_query(variable(x)).
_se_value(variable(x),val(int,9999)):-_se_assign(_label_anonymous,variable(x),val(int,9999)),direct_query(variable(x)).
_se_value(variable(x),val(int,9998)):-_se_assign(_label_anonymous,variable(x),val(int,9998)),direct_query(variable(x)).
...
we have 2 literals in the body, 1 literal in the head, that means that clasp probably introduces a variable for the whole body.
Is this rule correct like this? And more interesting, what means direct_query(variable(X)). This is a dynamic predicate and can't be optimized away, and is produced by the rule:
direct_query(X) :- _se_assign(NAME,X,E).
which produces
direct_query(variable(x)):-_se_assign(_label_anonymous,variable(x),val(int,9998)).
direct_query(variable(x)):-_se_assign(_label_anonymous,variable(x),val(int,9999)).
direct_query(variable(x)):-_se_assign(_label_anonymous,variable(x),val(int,10000)).
...
Non of this is detected as deterministic. I'm not sure what the semantics of direct_query is, but maybe we could so something to define it "deterministically".
In short: I think this is the reason why we have twice the amount of predicates we need, but I do not know what is going on there because of the lack of my semantic knowledge
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.