Files
TILO/Praktikum1.pl
2026-01-04 15:14:47 +01:00

86 lines
3.8 KiB
Prolog
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
%-----------------Daten---------------------
%maenlich m(x)
m(phillip).
m(charles).
m(william).
m(harry).
m(george).
m(louis).
m(archie).
m(andrew).
m(edward).
%weiblich w(x)
w(elizabeth).
w(diana).
w(catherine).
w(meghan).
w(charlotte).
w(sarah).
w(beatrice).
w(eugenie).
%X ist Elternteil von Y p(X,Y)
p(elizabeth, charles).
p(elizabeth, andrew).
p(elizabeth, edward).
p(phillip, charles).
p(phillip, andrew).
p(phillip, edward).
p(diana, william).
p(diana, harry).
p(charles, william).
p(charles, harry).
p(catherine, george).
p(catherine, charlotte).
p(catherine, louis).
p(william, george).
p(william, charlotte).
p(william, louis).
p(meghan, archie).
p(harry, archie).
p(sarah, beatrice).
p(sarah, eugenie).
p(andrew, beatrice).
p(andrew, eugenie).
%-----------------Regeln---------------------
%X ist Vater von Y
vater(X,Y) :- p(X,Y),m(X).
%X ist Mutter von Y
mutter(X,Y) :- p(X,Y),w(X).
%X ist Sohn von Y
sohn(X,Y) :- p(Y,X),m(X).
%X ist Tochter von Y
tochter(X,Y) :- p(Y,X),w(X).
%X ist Bruder von Y, P Vater, M Mutter
bruder(X,Y) :- p(P,X),p(P,Y),p(M,X),p(M,Y),m(X),X\=Y, M\=P.
%X ist Schwester von Y, P Vater, M Mutter
schwester(X,Y) :- p(P,X),p(P,Y),p(M,X),p(M,Y),w(X),X\=Y, M\=P.
%X ist Onkel von Y, H ist Parent von Y bzw. Bruder von X
onkel(X,Y) :- p(H,Y),bruder(X,H).
%X ist Tante von Y, H ist Parent von Y bzw. Schwester von X
tante(X,Y) :- p(H,Y),schwester(X,H).
%X ist Cousine von Y, A & B sind geschwister
cousine(X,Y) :- p(A,X),p(B,Y),A \= B,bruder(A,B), w(X).
cousine(X,Y) :- p(A,X),p(B,Y),A \= B,schwester(A,B), w(X).
%X ist Cousin von Y, A & B sind geschwister
cousin(X,Y) :- p(A,X),p(B,Y),A \= B,bruder(A,B), m(X).
cousin(X,Y) :- p(A,X),p(B,Y),A \= B,schwester(A,B), m(X).
%X ist Großvater von Y
grossvater(X,Y) :- vater(X,H),p(H,Y).
%X ist Großmutter von Y
grossmutter(X,Y) :- mutter(X,H),p(H,Y).