Comments (5)
Hi Jean Christophe,
cplint uses tabling, so it is not possible to draw an SLDNF tree. One should draw an SLG forest but I don't know of any tool that can do it. However, you can draw the BDD.
Best
Fabrizio
from cplint.
Thanks for the information and the suggestion.
Kind regards, JC
from cplint.
I re-opened the issue because I started considering writing code that automatically converts an LPAD to a program with CLPR constraints. For example, given the LPAD:
0.9::happy(P):-
hasFriend(P, F),
nice(F).
0.3::happy(P):-
rich(P).
hasFriend(josh, mark).
0.8::nice(mark).
rich(josh).
Automatically generate (where the X's are probabilities):
:- use_module(library(clpr)).
happy(P, X1):-
niceFriend(P, X2),
rich(P, X3),
{X1 = 0.9 * X2 + 0.3 * X3 - 0.9 * X2 * 0.3 * X3}.
niceFriend(P, X1):-
hasFriend(P, F, X2),
nice(F, X3),
{X1 = X2 * X3}.
hasFriend(josh, mark, 1).
nice(mark, 0.8).
rich(josh, 1).
One advantage could be to facilitate generating proof trees such as the following (in addition to the BDDs you suggested).
happy(josh,0.804) ⇐
niceFriend(josh,0.800) ⇐
hasFriend(josh,mark,1) ⇐ true
nice(mark,0.800) ⇐ true
{0.800=1*0.800} ⇐ true
rich(josh,1) ⇐ true
{0.804=0.900*0.800+0.300*1-0.900*0.800*0.300*1} ⇐ true
Another advantage is that it would be possible to reason bidirectionally (curtesy of CLPR), e.g. "Given that Josh is happy, that he is friends with mark who is nice, what is the probability that Josh is rich?"
And it would be cool be be able to go from a SLIPCOVER generated LPAD to a CLPR version.
On the other hand I am not sure if the semantics associated with CLPR adequately captures LPADS...
These are just some thoughts (not an issue with CPLINT per se)... I am curious about if you think that this is a good idea or not before I embark on such a project :-)
from cplint.
Hi,
the approach you propose works only if the programs satisfy the independent-and and independent-or assumption. Moreover, even in that case, it does not work if josh has more than one friend.
However, you can have a look at https://github.com/friguzzi/cplint/blob/master/prolog/pitaind.pl and modify these predicates
* orc_ind(++A:float,++B:float,--AorB:float) is det
*
* Returns A + B - A*B in AorB (or in case of independence)
*/
orc_ind(A,B,C):-
C is 1-(1-A)*(1-B).
/**
* orc_exc(++A:float,++B:float,--AorB:float) is det
*
* Returns A + B in AorB (or in case of exclusion)
*/
orc_exc(A,B,C):-
C is A+B.
/**
* onec(--One:float) is det
*
* Returns 1.0
*/
onec(1.0).
/**
* zeroc(--Zero:float) is det
*
* Returns 0.0
*/
zeroc(0.0).
/**
* andc(++A:float,++B:float,--AandB:float) is det
*
* Returns A*B in AandB (and in case of idependence). Fails if either A or B is 0.0
*/
andc(A,B,C):-
((A=0.0;B=0.0)->
%C=and(A,B)
fail
;
(A=1.0->
C=B
;
(B=1.0->
C=A
;
C is A*B
)
)
).
/**
* andcnf(++A:float,++B:float,--AandB:float) is det
*
* Returns A*B in AandB (and in case of idependence).
*/
andcnf(A,B,C):-
(A=1.0->
C=B
;
(B=1.0->
C=A
;
C is A*B
)
).
/**
* notc(++A:float,--NotA:float) is det
*
* Returns 1-A in NotA (negation)
*/
notc(A,B):-
(A=0.0->
B=1.0
;
(A=1.0->
B=0.0
;
B is 1.0-A
)
).
Replace and, or and not computations with CLPR computations and you would get what you want.
Note that this is not necessary to answer queries like "Given that Josh is happy, that he is friends with mark who is nice, what is the probability that Josh is rich?" which is a regular conditional probability query P(q|e) that you can answer computing P(q,e) and P(e), but you can answer queries such as "what probability should the fact that Josh is rich have to make the he probability of Josh being happy being tot?".
from cplint.
Aha I see. Maybe more tricky than I thought initially. Thank you for suggesting where to look in Pita!
from cplint.
Related Issues (20)
- make some prob fixed in par learning HOT 1
- Error "Exported procedure pita:randomize/2 is not defined" HOT 8
- Problems in pita.pl : yield bddem errors HOT 6
- Missing definition of add_decision_var and compute_best_strategy HOT 2
- Problems with master branch HOT 4
- Errors in examples HOT 2
- duel.pl in examples directory throws an error HOT 3
- Strange error in mc for SWI-Prolog version 8.1.14 HOT 4
- Expensive use of findall/3 HOT 2
- Redundant (and costly) use of call/1 HOT 1
- Wrong erase/1 HOT 1
- Flexible probabilities with ProbLog syntax HOT 1
- call predicates outside of lpad scope
- Negative Probability Values and Probability Bounds HOT 1
- Bug in `mc_mh_sample/4` HOT 4
- Error while getting graphical result HOT 2
- Rules with Disjunction in the Body HOT 1
- Pascal distribution HOT 4
- ?:: operator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cplint.