potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
601 stars 79 forks source link

Projection not working correctly with multiple program parts #362

Closed rkaminsk closed 2 years ago

rkaminsk commented 2 years ago

The following program fails to derive atom c.

#program a.
p.
#program b.
r :- q(_), p.
%r :- q(X), p.

#script(lua)

clingo = require("clingo")

function main(ctl)
    ctl:ground({{'a', {}}})
    ctl:solve()

    bck = ctl:backend()
    atm = bck:add_atom(clingo.Function('q', {clingo.Number(0)}))
    bck:add_rule{{atm}}
    bck:close()
    ctl:ground({{'b', {}}})
    ctl:solve()
end

#end.