### Meaning of #domain declaration in answer set programming

by Forrest Sheng Bao http://fsbao.net

I just notice that a weight constraint acts oddly'' for variables declared in #domain declaration in answer set programming (ASP). My grounder and solver are lparse and smodels.

Here is a demo program:
const n=2.
step(0..n).

#domain step(S).
block(a). block(b).

#domain block(B).

1{put(X,S):block(X)}1 :- step(S), S < n . % rule 1

1{gen(B,S)}1 :- step(S), S < n .          % rule 2


I thought I should get one and only one put/2 and gen/2 literal, respectively, for each S, because the lower and upper bounds are both 1. But this is what I got:
Stable Model: put(a,0) put(a,1) gen(b,0) gen(b,1) gen(a,0) gen(a,1) step(0) step(1) step(2) block(b) block(a)

For each step S, I got exactly one put/2 literal whereas I got two gen/2 literals. Thus, I have gen(a,0), gen(b,0), gen(a,1) and gen(b,1). They are supported by Rules 1 and 2, respectively. A difference, which is the cause, between Rule 1 and Rule 2 is X is not declared in #domain declaration whereas B is.

With the help of Dr. Zhizheng Zhang, the reason was found out. Lparse manual explains the meaning of #domain a(X), "adding a(X) into the tails of all rules where X occurs." Thus, Rule 2 is actually:
1{gen(B,S)}1 :- step(S), S < n, block(B).