% 節? male(namihei). male(masuo). male(katuo). male(tara). /* male(X). X = namihei ; X = masuo ; X = katuo ; X = tara. */ female(fune). female(sazae). female(wakame). /* female(X). X = fune ; X = sazae ; X = wakame. */ father_of(namihei, sazae). father_of(namihei, katuo). father_of(namihei, wakame). father_of(masuo, tara). /* father_of(X, Y). X = namihei, Y = sazae ; X = namihei, Y = katuo ; X = namihei, Y = wakame ; X = masuo, Y = tara. */ mother_of(fune, sazae). mother_of(fune, katuo). mother_of(fune, wakame). mother_of(sazae, tara). /* mother_of(X, Y). X = fune, Y = sazae ; X = fune, Y = katuo ; X = fune, Y = wakame ; X = sazae, Y = tara. */ % XはYの親である % XがYの父親であるか、XがYの母親である parent_of(X, Y) :- father_of(X, Y). parent_of(X, Y) :- mother_of(X, Y). /* parent_of(X, sazae). X = namihei ; X = fune ; false. parent_of(X, Y). X = namihei, Y = sazae ; X = namihei, Y = katuo ; X = namihei, Y = wakame ; X = masuo, Y = tara ; X = fune, Y = sazae ; X = fune, Y = katuo ; X = fune, Y = wakame ; X = sazae, Y = tara. */ % XはYの息子である % YはXの親であり、かつXは男性である suns_of(X, Y) :- parent_of(Y, X), male(X). /* suns_of(X, sazae). X = tara. suns_of(X, fune). X = katuo ; false. */ % XはYの娘である % YはXの親であり、かつXは女性である daughter_of(X, Y) :- parent_of(Y, X), female(X). /* daughter_of(X, Y). X = sazae, Y = namihei ; X = wakame, Y = namihei ; X = sazae, Y = fune ; X = wakame, Y = fune ; false. */ % XはYの祖父である % ZはYの親であり、XはZの父である grandfather_of(X, Y) :- parent_of(Z, Y), father_of(X, Z). /* grandfather_of(X, Y). X = namihei, Y = tara ; false. */ /* grandfather_of(X, Y). X = namihei, Y = tara */ % XはYの祖母である % ZはYの親であり、XはZの母 grandmother_of(X, Y) :- parent_of(Z, Y), mother_of(X, Z). /* grandmother_of(X, Y). X = fune, Y = tara */ |
0 件のコメント:
コメントを投稿