-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making a Predicate/fact that depends on an inequality #92
Comments
The probables of 2 atoms cannot be compared like that. This requires a meta-query, which is offered in ProbLog through the subquery(Goal,Probability) predicate. I've included an example below, is this what you wanted to do?
|
Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
% Consider
.85::color(b1,purple); .15::color(b1,yellow).
.90::color(b2,purple); .10::color(b2,yellow).
.05::color(b3,purple); .95::color(b3,yellow).
% This computes that all balls are all the same color
same_color([],_).
same_color([Ball|Tail],Color) :- color(Ball,Color), same_color(Tail,Color).
query(same_color([b1,b2,b3],purple)). % Probability == 0.03825
query(same_color([b1,b2,b3],yellow)). % Probability == 0.01425
% How can I create a predicate majority_color(Group,Color) so that it
% compares the same-color probabailities so that
% query(majority_color([b1,b2,b3],purple)) with prob 1.0
% query(majority_color([b1,b2,b3],yellow)) with prob 0.0?
% I was trying
majority_color(G,purple) :- same_color(G,purple) > same_color(G,yellow).
majority_color(G,yellow) :- same_color(G,yellow) > same_color(G,purple).
query(majority_color([b1,b2,b3],purple)).
% but an error is reported:
% ArithmeticError: Error while evaluating '>'(same_color([b1, b2, b3],purple),same_color
% ([b1, b2, b3],yellow)): Unknown function 'same_color'/2 at 19:50.
The text was updated successfully, but these errors were encountered: