title: what is code in prolog can find two person who has same generation?
body: <p>I need a code in prolog.</p>
  
  <p>Assume we defined some persons in family tree.</p>
  
  <p>How can I write a function that get two persons name and process if they have same generation and who is their same ancestor?</p>
  
  <pre><code>parent(chester,irvin).
  parent(chester,clarence).
  parent(chester,mildred).
  parent(irvin,ron).
  parent(irvin,ken).
  parent(clarence,shirley).
  parent(clarence,sharon).
  parent(clarence,charlie).
  parent(mildred,mary).
  
  
  male(chester).
  female(mildred).
  male(irvin).
  female(shirley).
  male(clarence).
  female(sharon).
  male(ron).
  female(mary).
  male(ken).
  male(charlie).
  
  
  
  father(X,Y) :- parent(X,Y), male(X).
  
  mother(X,Y) :- parent(X,Y), female(X).
  
  grandparent(X,Y) :- parent(X,Z), parent(Z,Y).
  
  paternalgrandfather(X,Y) :- father(X,Z), father(Z,Y).
  
  sibling(X,Y) :- parent(Z,X), parent(Z,Y).
  
  brothers(X,Y) :- sibling(X,Y),male(X),male(Y), \+ (X=Y).
  
  samegeneration(x,y) :- HERE I DONT KNOW WHAT TO DO
  </code></pre>