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

Julia front-end for ProbLog through PyCall #46

Open femtomc opened 3 years ago

femtomc commented 3 years ago

Hello! My name is McCoy - I work on probabilistic programming in Julia.

I'd like to write a small front-end which can access the ProbLog Python API through Julia. There's a number of Julia packages which I will use to do this, the most prominent is PyCall.jl which I think will provide most of the interlinking.

This work will occur at Problox.jl.

I'd just like to keep this issue open, so that I may ask questions as I proceed.

Also, if there's a lower level C API which ProbLog offers, I'd like to read up on that as well if that's available somewhere. I know the knowledge compilation occurs in C - but I was unsure about the rest of the system.

femtomc commented 3 years ago

I have an initial version working with a simple coin flip example now. I'm sure questions may arise as I try to use some of the more advanced concepts.

VincentDerk commented 3 years ago

Hi,

Great to hear you managed to get an initial working version so fast!

In terms of things that aren't done in Python,

femtomc commented 3 years ago

Is the investigation into other backends motivated by performance questions?

I was curious about this. I'm hoping to attempt to hook this system up to a trace-based system (like Gen.jl) which means inference in the combined model might involved repeated sampling, and then querying.

Thanks for responding so quickly!

Last question: is there a notion of "noisy And"? I don't think this really makes sense, but I'm really asking about the joint query. Initially I thought a statement like:

smokes(X) :- friend(X,Y), influences(Y,X), smokes(Y).

was sort of like a CPD, but I think from my reading that this is really a sort of disjunction. Is that correct?

VincentDerk commented 3 years ago

Is the investigation into other backends motivated by performance questions?

Yes. In theory the knowledge compilation should be the most expensive step. In practice, we found that for some problems the engine (grounding) takes a lot of time. This has already been alleviated a bit in the develop branch but still, a Prolog engine in C might yield even more improvements.

Last question

I'm afraid I don't fully understand your question. The rule smokes(X) :- friend(X,Y), influences(Y,X), smokes(Y). means that anytime the body holds (conjunction), the head is true.

Personally, I like to reason over these programs as a combination of rules that can make something true. A weighted model counting perspective can also help. Consider the following program:

0.5::smokes(bob).
0.2::smokes(ann).
smokes(X) :- friend(X,Y), smokes(Y).
friend(bob,ann).
friend(ann,bob).
query(smokes(ann)).

smokes(ann) is either true because of the second rule (0.2) or because of the third and first rule (0.5). query(smokes(ann)) = 0.2 + (1-0.2) * 0.5

Hope that helps.

femtomc commented 3 years ago

@VincentDerk That helps tremendously. Thank you.