プログラム断片(2008/05/28)
for VisualWorks 7.6 with Jun780, Prologインタプリタのマニュアル(PDF)
JunPrologInterpreter open
apple.
tomato.
orange.
?- apple.
?- orange.
?- banana.
 |
?- apple.
yes
?- orange.
yes
?- banana.
no
|
|
fruit :- apple.
fruit :- orange.
jam :- fruit, sugar.
?- listing.
 |
?- listing.
apple.
fruit :-
apple.
fruit :-
orange.
jam :-
fruit,
sugar.
orange.
tomato.
yes
|
|
?- jam.
sugar.
?- jam.
 |
?- jam.
no
?- jam.
yes
|
|
?- remove.
?- listing.
 |
?- remove.
yes
?- listing.
yes
|
|
?- clear.
 |
yes
|
|
?- remove.
human(socrates).
human(platon).
human(aristotle).
mortal(X) :- human(X).
?- clear.
?- listing.
?- mortal(socrates).
?- mortal(aoki).
human(aoki).
?- mortal(aoki).
 |
yes
?- listing.
human(socrates).
human(platon).
human(aristotle).
mortal(X) :-
human(X).
yes
?- mortal(socrates).
yes
?- mortal(aoki).
no
?- mortal(aoki).
yes
|
|
?- remove.
human(socrates).
human(platon).
human(aristotle).
human(aoki).
mortal(X) :- human(X).
?- clear.
?- listing.
?- mortal(X).
 |
yes
?- listing.
human(socrates).
human(platon).
human(aristotle).
human(aoki).
mortal(X) :-
human(X).
yes
?- mortal(X).
X = socrates ;
X = platon ;
X = aristotle ;
X = aoki ;
no
|
|
?- remove.
likes(john, apple).
likes(john, wine).
likes(mary, wine).
likes(mary, john).
?- clear.
?- listing.
?- likes(john, X).
?- likes(X, john).
?- likes(john, X), likes(mary, X).
 |
yes
?- listing.
likes(john,apple).
likes(john,wine).
likes(mary,wine).
likes(mary,john).
yes
?- likes(john,X).
X = apple ;
X = wine ;
no
?- likes(X,john).
X = mary ;
no
?- likes(john,X), likes(mary,X).
X = wine ;
no
|
|
?- remove.
on(hen, cat).
on(cat, dog).
on(dog, donkey).
above(X, Y) :- on(X, Y).
above(X, Y) :- on(X, Z), above(Z, Y).
?- clear.
?- listing.
?- above(hen, X).
?- above(X, donkey).
?- above(X, Y).

 |
yes
?- listing.
above(X,Y) :-
on(X,Y).
above(X,Y) :-
on(X,Z),
above(Z,Y).
on(hen,cat).
on(cat,dog).
on(dog,donkey).
yes
?- above(hen,X).
X = cat ;
X = dog ;
X = donkey ;
no
?- above(X,donkey).
X = dog ;
X = hen ;
X = cat ;
no
?- above(X,Y).
X = hen ,
Y = cat ;
X = cat ,
Y = dog ;
X = dog ,
Y = donkey ;
X = hen ,
Y = dog ;
X = hen ,
Y = donkey ;
X = cat ,
Y = donkey ;
no
|
|
?- remove.
?- clear.
?- listing.
?- is(X, F(3, 4)).
 |
yes
?- listing.
yes
?- is(X,F(3,4)).
F = + ,
X = 7 ;
F = - ,
X = -1 ;
F = * ,
X = 12 ;
F = / ,
X = (3/4) ;
F = F1 ,
X = F1(3,4) ;
no
|
|
?- remove.
likes(john, apple).
likes(john, wine).
likes(john, mary).
likes(mary, wine).
likes(mary, john).
lovers(X, Y) :- 作成して.
?- clear.
?- listing.
?- lovers(X, Y).
 |
yes
?- listing.
likes(john,apple).
likes(john,wine).
likes(john,mary).
likes(mary,wine).
likes(mary,john).
lovers(X,Y) :- 作成して.
yes
?- lovers(X,Y).
X = john ,
Y = mary ;
X = mary ,
Y = john ;
no
|
|
for VisualWorks 7.6 with Jun780, Prologインタプリタのマニュアル(PDF)
Updated: 2015/11/08 (Created: 2008/05/28)
