ML-KULeuven / problog

ProbLog is a Probabilistic Logic Programming Language for logic programs with probabilities.
https://dtai.cs.kuleuven.be/problog/
297 stars 34 forks source link

Negative cycle detected. #106

Closed romanilin325 closed 5 months ago

romanilin325 commented 7 months ago

Hello all, I am new to problog. I keep getting NegativeCycle: Negative cycle detected but the error does not allow to trace to a particular statement in the problog program. Is there a way to get better debug information? What is the meaning of this error?

wannesm commented 7 months ago

Can you share the full message? The NegativeCycle error (or Exception if you are using Python) should also print a line number and position.

For example, when entering the following program in our online tool:

0.5::a :- \+b.
0.5::b :- a.

query(a).
query(b).

The result is: NegativeCycle: Negative cycle detected at 1:11., which is the location where the negation is being used and a and b are a cycle through negation (and that is a paradoxical expression).

romanilin325 commented 7 months ago

Thank you, yes there is line number in the error message! However, I cannot figure out what other statements in the program create the cycle. Is there any way to print the whole cycle?

romanilin325 commented 7 months ago

In addition, when I use --combine option, something like

problog --combine file1.pl file2.pl The error message does not even have the line number, it just says NegativeCycle: Negative cycle detected.

rmanhaeve commented 7 months ago

There is no way currently to print out the exact cycle. Could you perhaps show the program that is causing the issue?