PROLOG sorusunu çözdüm. ama eitörde yazıp çalıştırmadım. umarım doğrudur.:
Suppose the Prolog database defines relations of the form male(X), female(X), sibling(X, Y), spouse(X, Y), and parent(X, Y), which means that X is a parent of Y. Write the Prolog predicates described below.
a. niece(X, Y), which means that X is a niece of Y.
Note: your niece is your brother’s daughter, sister’s daughter, or spouse’s niece.
Niece(X,Y) :- female(X), parent(Z,X), sibling(Z,Y);
Female(X), spouse(Z,Y), niece(X,Z).
b. nephew(X, Y), which means that X is a nephew of Y.
Note: your nephew is your brother’s son, sister’s son, or spouse’s nephew.
Nephew(X,Y) :- male(X), parent(Z,X), sibling(Z,Y);
Male(X), spouse(Z,Y), nephew(X,Z).
c. uncle(X, Y), which means that X is an uncle of Y.
Note: your uncle is your father’s brother, mother’s brother, or aunt’s husband.
Uncle(X,Y) :- parent(Z,Y), sibling(X,Z), male(X);
Parent(Z,Y), sibling(Z,T), spouse(T,X), male(X).
d. aunt(X, Y), which means that X is an aunt of Y.
Note: your aunt is your father’s sister, mother’s sister, or uncle’s wife.
Aunt(X,Y) :- parent (Z,Y), sibling(X,Y), female(X);
Parent(Z,Y), sibling(T,Z), spouse(X,T), female(X);
Uncle(T,Y), spouse(T,X).
Who is Hamilton? Forza Kimi !!!!
http://www.burhanaras.net/
|