8
I have to create an uncle relationship according to the next family tree:
I already have the following code:
mãe(ana, eva).
mãe(eva, noé).
mãe(bia, raí).
mãe(bia, clô).
mãe(bia, ary).
mãe(lia, gal).
pai(ivo, eva).
pai(raí, noé).
pai(gil, raí).
pai(gil, clô).
pai(gil, ary).
pai(ary, gal).
mulher(ana).
mulher(eva).
mulher(bia).
mulher(clô).
mulher(lia).
mulher(gal).
homem(ivo).
homem(raí).
homem(noé).
homem(gil).
homem(ary).
gerou(ana, eva).
gerou(ivo, eva).
gerou(eva, noé).
gerou(raí, noé).
gerou(bia, raí).
gerou(bia, clô).
gerou(bia, ary).
gerou(gil, raí).
gerou(gil, clô).
gerou(gil, ary).
gerou(ary, gal).
gerou(lia, gal).
avô(X, Y) :- pai(X, Z), pai(Z, Y); pai(X, Z), mãe(Z, Y).
avó(X, Y) :- mãe(X, Z), mãe(Z, Y); mãe(X, Z), pai(Z, Y).
filho(X, Y) :- gerou(Y, X), homem(X).
filha(X, Y) :- gerou(Y, X), mulher(X).
/* irmãos(raí, clô).
irmãos(clô, raí).
irmãos(ary, clô).
irmãos(ary, raí).
irmãos(clô, ary).
irmãos(raí, ary). */
In the exercise I’m doing, you don’t ask me to create the sibling relationship, but I can use it to create the uncle relationship? Otherwise, what relationships should I use? Thanks and forgiveness if I haven’t expressed myself correctly.
I don’t know Prolog. About the sibling relationship is automatic, when sharing father, mother or both. If there is a brother relationship with the parent of a child, then he is an uncle
– Caputo
Well thought about the sibling relationship, could have created a rule to define it.
– Wellington Viana