Prolog is deeply unsuited for work, use Clingo instead.<p>Try this on <a href="https://swish.swi-prolog.org/" rel="nofollow">https://swish.swi-prolog.org/</a>.<p>on(a,b).
on(b,c).
above(X,Y) :- on(X,Y).
above(X,Y) :- on(X,Z), above(Z,Y).<p>Query above(a,c)<p>Ok, true - it works! no probs.<p>now try<p>on(a,b).
on(b,c).
above(X,Y) :- above(X,Z), on(Z,Y).
above(X,Y) :- on(X,Y).<p>and query... and it explodes.<p>So - this kind of bug is very hard to find and extremely easy to introduce.<p>The good news is that answer set programming is not prone to it. So instead of prolog use Clingo !<p><a href="https://potassco.org/clingo/" rel="nofollow">https://potassco.org/clingo/</a>