# prolog תרגיל 1

```
?- student(X,history).
X = nili ;
X = ran.

?- student(nili,X).
X = history ;
X = prolog.

?- student(nili,X),student(dani,X).
X = prolog ;

?- student(_,matimatics).
true

?- student(yosi,_).
false.

?- student(X,prolog),student(X,matimatics).
X = dani ;
X = ran ;

parent(nati,tali).
parent(nati,avigail).
parent(maayan,tali).
parent(maayan,avigail).
married(nati,maayan).
married(maayan,nati).
male(nati).
female(avigail).
female(tali).
female(maayan).

father(X) :- parent(X,Y), male(X).     % x is father if he is a parent of someone and he is a male
mother(X) :- parent(X,Y), female(X).   % x is mother if he is a parent of someone and he is a female
son(X) :- parent(Y,X), male(X).        % x is son if X is male and X has a parent
doughter(X) :- parent(Y,X), female(X).   % x is doughter if X is a female and X has a parent
parents(X,Y) :- parent(X,Z), parent(Y,Z).   %X,Y are parents if both(X,Y) are parent of Z
grandfather(X) :- parent(X,Y), parent(Y,Z), male(X).   %x is grandfather if is parent of Y and Y parent of Z and X male
grandmother(X) :- parent(X,Y), parent(Y,Z), female(X).   %x is grandmother if is parent of Y and Y parent of Z and X female
grandson(X) :- parent(Y,X), parent(Z,Y), male(X).   % X is grandson if Y parent of X and Z parent of Y and X male
grandoughter(X) :- parent(Y,X), parent(Z,Y), female(X).   % X is grandoughter if Y parent of X and Z parent of Y and X female
brothers(X,Y) :- parent(Z,X), parent(Z,Y), parent(W,X), parent(W,Y).  % X,Y brothers if they are parent of  Z
uncle(X) :- brothers(Y,X), parent(Y,Z), male(X).    % X is uncle if X brother he is a parent and x is male
cousin(X) :- parent(Z,X), brothers(Z,W), parent(W,V), male(X).   % X is cousin if parent of X has a brother Y and Y is a parent and x is male
brotherinlow(X) :- brothers(X,Y), married(Y,Z), male(X).   % X is brotherinlow if x brother is marrid to someone and x is male
niece(X) :- parent(Y,X), brothers(Z,Y), female(X).    % X is niece ix parent has a brother and x female

left_of(bicycle, camera).
left_of(pencil, clock).
left_of(pencil, botherfly).
left_of(pencil, fish).
left_of(clock, botherfly).
left_of(botherfly, fish).
left_of(botherfly, fish).
above(bicycle, pencil).
above(camera, botherfly).

right_of(X,Y) :- left_of(Y, X).
below(X, Y):- above(Y,X).
```