ML-KULeuven / problog

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

subquery/2 and /3 always use the ProbabilitySemiring #40

Open VincentDerk opened 4 years ago

VincentDerk commented 4 years ago

In subquery/2 (and /3), the semiring is not passed on to the sub evaluation. This means custom semirings or the HALSemiring (continuous vars) do not yet work properly.

Example for dcproblog_develop branch:

b~beta(0.5,1).
c :- b > 1.
event :- subquery(c, Prob), writeln(Prob).
query(event).
shuvrobiswas commented 4 years ago

Hey guys, any update on this?

pedrozudo commented 4 years ago

Hi,

Yeah sorry, last couple of weeks have been super hectic. We briefly looked at it and could not come up with a quick and general fix. I'll be working on improving support continuous random variables over the next weeks. I hope I can get around fixing this issue, too.

shuvrobiswas commented 4 years ago

Hey guys, any timeline on this issue and/or any way I can help?

Created a simple covid19 example (with just plain problog, no continuous variables):

image

VincentDerk commented 4 years ago

Unfortunately I have been swamped with other things, hard to tell when I can look into this again. I don't know whether @pedrozudo found time?

From what I remember, the problem was the current design structure where the engine had no knowledge of the semiring. We could not just pass on a semiring to the engine because the semiring might be based on the results from the engine (for example in the implementation for continuous variables).

I was opting for a user defined function to create a semiring given an engine but I believe there was another reason that made me change my mind. Something to do with how the implementation in the continuous case is done with a Solver and was not necessarily following the procedure in subquery.

Regarding the comment in your example, 0::fever(X) :- healthy(X). adds a reason for fever(X) to become true (even though it will not change the results as you attached a probability of 0). \+ fever(X) :- healthy(X). says that it is impossible to have a fever when you are healthy. It overrides any other rule that could have otherwised caused fever while being healthy.

shuvrobiswas commented 4 years ago

Thanks for the update @VincentDerk and agreed re the fever/healthy comment :+1: