ML-KULeuven / problog

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

Negative cycle detected. #106

Closed romanilin325 closed 10 months ago

romanilin325 commented 1 year 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 1 year 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 1 year 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 1 year 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 1 year ago

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