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

CODE WITH CIRCULARITY #115

Closed Mezzenilium closed 2 months ago

Mezzenilium commented 2 months ago

I find it hard to understand how Problog2 manages to calculate this code where there is circularity between the predicates rain and snow.

0.4::rain. 0.1::snow.

0.2::rain :- snow. 0.1::snow :- rain.

precipitation :- rain. precipitation :- snow.

melt :- rain, snow.

query(precipitation). query(melt). query(rain). query(snow).

rmanhaeve commented 2 months ago

Hi

ProbLog has cycle breaking to unroll cyclically defined rules. Here, it is first good to see that only the cyclical rules by themselves do not actually cause rain or snow to be true. If you comment out the first two lines, all query probabilities become 0.

The program you've given is equivalent to

0.4::rain_fact.
0.1::snow_fact.

rain :- rain_fact.
0.2::rain :- snow_fact.

snow :- snow_fact.
0.1::snow :- rain_fact.

precipitation :- rain.
precipitation :- snow.

melt :- rain, snow.

query(precipitation).
query(melt).
query(rain).
query(snow).

Which is acyclical.

Mezzenilium commented 2 months ago

Thank you very much. This acyclic approach simplifies the understanding of the model and eliminates the need for the iterations I explored (with possible convergence problems), making the computational process more transparent and efficient. It shows how reframing a Problog program can help clarify the underlying logic and avoid unnecessary complications associated with the need for iterations.

Le lun. 6 mai 2024 à 11:15, Robin Manhaeve @.***> a écrit :

Hi

ProbLog has cycle breaking to unroll cyclically defined rules. Here, it is first good to see that only the cyclical rules by themselves do not actually cause rain or snow to be true. If you comment out the first two lines, all query probabilities become 0.

The program you've given is equivalent to

0.4::rain_fact. 0.1::snow_fact.

rain :- rain_fact. 0.2::rain :- snow_fact.

snow :- snow_fact. 0.1::snow :- rain_fact.

precipitation :- rain. precipitation :- snow.

melt :- rain, snow.

query(precipitation). query(melt). query(rain). query(snow).

Which is acyclical.

— Reply to this email directly, view it on GitHub https://github.com/ML-KULeuven/problog/issues/115#issuecomment-2095527467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF46KYPSX6G6PDJEONQ4OT3ZA5C2BAVCNFSM6AAAAABHG7KU5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGUZDONBWG4 . You are receiving this because you authored the thread.Message ID: @.***>