Rework a bit the examples

This commit is contained in:
Tiago Gomes
2013-01-07 14:59:51 +00:00
parent 91dbd60ad4
commit bafd7320a5
5 changed files with 115 additions and 88 deletions

View File

@@ -1,3 +1,8 @@
/*
Model from the paper "First-order
probabilistic inference"
*/
:- use_module(library(pfl)).
:- set_solver(hve).
@@ -11,14 +16,14 @@
%:- set_solver(lkc).
%:- set_solver(lbp).
:- multifile people/2.
:- multifile person/2.
:- multifile ev/1.
people(joe,nyc).
people(p2, nyc).
people(p3, nyc).
people(p4, nyc).
people(p5, nyc).
person(joe,nyc).
person(p2, nyc).
person(p3, nyc).
person(p4, nyc).
person(p5, nyc).
ev(descn(p2, fits)).
ev(descn(p3, fits)).
@@ -26,41 +31,41 @@ ev(descn(p4, fits)).
ev(descn(p5, fits)).
bayes city_conservativeness(C)::[high,low] ;
cons_table ;
[people(_,C)].
cons_table ;
[person(_,C)].
bayes gender(P)::[male,female] ;
gender_table ;
[people(P,_)].
gender_table ;
[person(P,_)].
bayes hair_color(P)::[dark,bright], city_conservativeness(C) ;
hair_color_table ;
[people(P,C)].
hair_color_table ;
[person(P,C)].
bayes car_color(P)::[dark,bright], hair_color(P) ;
car_color_table ;
[people(P,_)].
car_color_table ;
[person(P,_)].
bayes height(P)::[tall,short], gender(P) ;
height_table ;
[people(P,_)].
height_table ;
[person(P,_)].
bayes shoe_size(P)::[big,small], height(P) ;
shoe_size_table ;
[people(P,_)].
shoe_size_table ;
[person(P,_)].
bayes guilty(P)::[y,n] ;
guilty_table ;
[people(P,_)].
guilty_table ;
[person(P,_)].
bayes descn(P)::[fits,dont_fit], car_color(P),
hair_color(P), height(P), guilty(P) ;
descn_table ;
[people(P,_)].
hair_color(P), height(P), guilty(P) ;
descn_table ;
[person(P,_)].
bayes witness(C), descn(Joe), descn(P2) ;
witness_table ;
[people(_,C), Joe=joe, P2=p2].
witness_table ;
[person(_,C), Joe=joe, P2=p2].
cons_table(
@@ -109,20 +114,20 @@ witness_table(
runall(G, Wrapper) :-
findall(G, Wrapper, L),
execute_all(L).
findall(G, Wrapper, L),
execute_all(L).
execute_all([]).
execute_all(G.L) :-
call(G),
execute_all(L).
call(G),
execute_all(L).
is_joe_guilty(Guilty) :-
witness(nyc, t),
runall(X, ev(X)),
guilty(joe, Guilty).
witness(nyc, t),
runall(X, ev(X)),
guilty(joe, Guilty).
% ?- is_joe_guilty(Guilty).