% ReCodEx declarations
male(liam). 
male(noah). 
male(oliver). 
male(william).
male(elijah). 
male(james). 
male(ben).

female(olivia). 
female(emma). 
female(ava).
female(sophia). 
female(isabella). 
female(evelyn).

parent(liam, oliver).
parent(olivia, oliver).

parent(liam, emma).
parent(olivia, emma).

parent(noah, william).
parent(olivia, william).

parent(william, evelyn).

parent(oliver, ava).
parent(ava, james).
parent(james, isabella).

parent(emma, elijah).
parent(elijah, sophia).
parent(sophia, ben).

% custom definitions

% great_grandmother
great_grandmother(G, D) :-
    parent(X, D), % rodič dítěte
    parent(Y, X), % rodič rodiče (babička dítěte)
    parent(G, Y), % rodič rodiče rodiče (prababička dítěte)
    female(G). % vyžaduje ženu jako babičku


% siblings (one parent required)
sibling(X, Y) :- 
    parent(R, X), 
    parent(R, Y), 
    X \= Y.

% full siblings (both parents required)
full_sibling(X, Y) :-
    parent(O, X),
    parent(M, X),
    parent(O, Y),
    parent(M, Y),
    O \= M,
    X \= Y,
    % tohle by se nelíbilo LGBT community
    male(O),
    female(M).
    % konec LGBT neplechy

first_cousin(X, Y) :-
    parent(S1, X),
    parent(S2, Y),
    full_sibling(S1, S2),
    S1 \= S2,
    X \= Y.

second_cousin(X, Y) :-
    parent(P1, X),
    parent(P2, Y),
    first_cousin(P1, P2).

nth_cousin(X, Y) :- first_cousin(X, Y).
nth_cousin(X, Y) :- second_cousin(X, Y).
nth_cousin(X, Y) :-
    parent(P1, X),
    parent(P2, Y),
    nth_cousin(P1, P2).