examples for the new programs

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2017 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
rzf 2007-11-15 12:38:55 +00:00
parent 83b4c2cdac
commit 8fb01d6607
26 changed files with 281 additions and 49 deletions

View File

@ -1 +1,9 @@
universe(['Coin'],[coin1,coin2]).
mode(heads(coin)).
mode(tails(coin)).
mode(toss(coin)).
mode(fair(coin)).
mode(biased(coin)).
type(coin,[coin1,coin2]).

View File

@ -1,13 +0,0 @@
/*
s([a],P).
Variables: [(1,[]),(2,[]),(3,[])]
P = 0.226 ?
*/
a:0.1.
b:0.3;c:0.6.
a:0.2:- \+ b.

View File

@ -1,12 +0,0 @@
/*
s([a],P).
Variables: [(1,[]),(2,[]),(3,[])]
P = 0.1719 ? ;
*/
a:0.1:-p(X).
p(1):0.9.
p(2):0.9.

View File

@ -1,21 +0,0 @@
/*
s([a(X)],P).
Variables: [(1,[]),(5,[]),(2,[]),(6,[])]
P = 0.2775
X = 1 ? ;
Variables: [(3,[]),(5,[]),(4,[]),(6,[])]
P = 0.36
X = 2 ? ;
*/
a(1):0.3:-p(1).
a(1):0.3:-p(2).
a(2):0.4:-p(1).
a(2):0.4:-p(2).
p(1):0.5.
p(2):0.5.

6
cplint/examples/ex.uni Normal file
View File

@ -0,0 +1,6 @@
mode(a).
mode(b).
mode(c).

View File

@ -0,0 +1,9 @@
universe(['X'],[1,2]).
mode(a).
mode(p(int)).
type(int,[1,2]).

View File

@ -0,0 +1,6 @@
mode(a(int)).
mode(p(int)).
type(int,[1,2]).

27
cplint/examples/hiv.cpl Normal file
View File

@ -0,0 +1,27 @@
/*
?- s([hiv(a)],P).
P = 0.154 ?
yes
?- s([hiv(b)],P).
P = 0.154 ?
yes
?- s([hiv(b),hiv(a)],P).
P = 0.118 ?
yes
?- s([\+ hiv(b),\+ hiv(a)],P).
P = 0.81 ?
yes
?- s([ hiv(b),\+ hiv(a)],P).
P = 0.036 ?
yes
?- s([\+ hiv(b),hiv(a)],P).
P = 0.036 ?
yes
*/
(hiv(a) : 0.1).
(hiv(b) : 0.1).
(hiv(a) : 0.6) :- hiv(b).
(hiv(b) : 0.6) :- hiv(a).
hiv(a) :- hiv(a).
hiv(b) :- hiv(b).

4
cplint/examples/hiv.uni Normal file
View File

@ -0,0 +1,4 @@
mode(hiv(person)).
type(person,[a,b]).

View File

@ -0,0 +1,15 @@
/*
?- s([p],P).
P = 0.5 ?
yes
?- s([q],P).
P = 0.5 ?
yes
?- s([p,q],P).
P = 0 ?
yes
*/
p : 0.5;q : 0.5:- r.
r :- \+ p.
r :- \+ q.

View File

@ -0,0 +1,7 @@
mode(p).
mode(r).
mode(q).

26
cplint/examples/light.cpl Normal file
View File

@ -0,0 +1,26 @@
/*
?- p(light).
yes
?- s([push,replace],P).
P = 0.5 ?
yes
?- s([push,light],P).
P = 0.5 ?
yes
?- s([push,light,replace],P).
P = 0 ?
yes
?- s([light,replace],P).
P = 0 ?
yes
?- s([light],P).
P = 0.5 ?
yes
?- s([replace],P).
P = 0.5 ?
yes
*/
push.
light : 0.5 :- push.
replace :- \+ light.

View File

@ -0,0 +1,4 @@
mode(push).
mode(light).
mode(replace).

View File

@ -0,0 +1,13 @@
mode(mother(person,person)).
mode(father(person,person)).
mode(cg(person,chr,allele)).
type(person,[s,m,f,mm,fm,mf,ff]).
type(chr,[1,2]).
type(allele,[p,w]).
universe(['X'],[s,m,f]).
universe(['A','B'],[p,w]).

View File

@ -0,0 +1,30 @@
/*
this file can not be used with s.pl: it generates too many programs
s([cg(s,1,p)],P).
P = 0.75 ?
s([cg(s,1,w)],P).
P = 0.25 ?
s([cg(s,2,p)],P).
P = 0.25 ?
s([cg(s,2,w)],P).
P = 0.75 ?
s([cg(f,2,w)],P).
P = 0.5
s([cg(s,2,w)],P).
P = 0.75
*/
mother(m,s).
father(f,s).
cg(m,1,p).
cg(m,2,w).
cg(f,1,p).
cg(f,2,p).
cg(X,1,A):0.5 ; cg(X,1,B):0.5 :- mother(Y,X),cg(Y,1,A) , cg(Y,2,B).
cg(X,2,A):0.5 ; cg(X,2,B):0.5 :- father(Y,X),cg(Y,1,A) , cg(Y,2,B).

View File

@ -0,0 +1,13 @@
mode(mother(person,person)).
mode(father(person,person)).
mode(cg(person,chr,allele)).
type(person,[s,m,f]).
type(chr,[1,2]).
type(allele,[p,w]).
universe(['X'],[s]).
universe(['A','B'],[p,w]).

View File

@ -1,3 +1,18 @@
universe(['Stu'],[s0]).
universe(['Key'],[r0,r1]).
universe(['Cou'],[c16,c10]).
type(stu,[s0]).
type(reg,[r0,r1]).
type(cou,[c16,c10]).
type(gr,[1,4]).
type(dif,[h,l]).
type(ran,[h,l]).
mode(registration(reg,cou,stu)).
mode(registration_grade(reg,gr)).
mode(registration_course(reg,cou)).
mode(registration_student(reg,stu)).
mode(course_difficulty(cou,dif)).
mode(student_ranking(stu,ran)).

View File

@ -2,3 +2,28 @@ universe(['S'],[jane_doe]).
universe(['P'],[gump]).
universe(['Reg'],[5639,5640]).
universe(['C'],[phil101]).
type(prof,[gump]).
type(stu,[jane_doe]).
type(abi,[l,h]).
type(int,[h,l]).
type(reg,[5639,5640]).
type(cou,[phil101]).
type(gr,[1,2]).
type(sat,[1,2]).
type(dif,[h,l]).
type(rat,[h,l]).
mode(professor(prof)).
mode(professor_teach_ab(prof,abi)
mode(student(stu)).
mode(student_int(stu,int)).
mode(registr(reg)).
mode(registr_cou(reg,cou)).
mode(registr_stu(reg,stu)).
mode(registr_gr(reg,gr)).
mode(registr_sat(reg,sat)).
mode(course(cou)).
mode(course_prof(cou,prof)).
mode(course_dif(cou,dif)).
mode(course_rat(cou,rat)).

View File

@ -1,3 +1,9 @@
universe(['X'],[1,2]).
universe(['X1'],[0,1]).
mode(on(time,face)).
type(time,[0,1,2]).
type(face,[1,2,3]).
universe(['X'],[0,1,2]).
universe(['X1'],[0,1,2]).
universe(['Y'],[1,2,3]).

View File

@ -0,0 +1,21 @@
/*
no
?- s([throws(mary),throws(john),break],P).
P = 0.46 ?
yes
?- s([throws(mary),throws(john),\+break],P).
P = 0.04 ?
yes
?- s([\+ throws(mary),throws(john),break],P).
P = 0.3 ?
yes
?- s([\+ throws(mary),throws(john),\+ break],P).
P = 0.2 ?
yes
?-
*/
break : 0.8 :- throws(mary).
break : 0.6 :- throws(john).
throws(mary) : 0.5.
throws(john).

View File

@ -0,0 +1,6 @@
type(person,[mary,john]).
mode(break).
mode(throws(person)).

View File

@ -0,0 +1,13 @@
/*
?- s([death],P).
P = 0.305555555555556 ?
yes
?-
*/
death : 1/6 :- pull_trigger(left_gun).
death : 1/6 :- pull_trigger(right_gun).
pull_trigger(left_gun).
pull_trigger(right_gun).

View File

@ -0,0 +1,4 @@
mode(death).
mode(pull_trigger(gun)).
type(gun,[left_gun,right_gun]).

View File

@ -17,5 +17,5 @@ on(0,1):0.5;on(0,2):0.5.
on(X,1):0.5;on(X,2):0.5:-
X1 is X-1,X1>=0,
on(X1,_),
on(X1,Y),
\+ on(X1,2).

14
cplint/examples/win.cpl Normal file
View File

@ -0,0 +1,14 @@
/*
?- s([win(white)],P).
P = 0.5 ?
yes
?- s([win(black)],P).
P = 0.5 ?
yes
?- s([win(black),win(white)],P).
P = 0 ?
*/
win(white) :- \+ win(black).
win(black):- \+ win(white).
win(white) : 0.5 ; win(black) : 0.5.

6
cplint/examples/win.uni Normal file
View File

@ -0,0 +1,6 @@
mode(win(player)).
type(player,[white,black]).