Let's have standard notations first...
B = the guy in question
G = the girl in question, and the current girlfriend of B
P(x) is bio paternal relationship, M(x) is bio maternal relationship, P+M(x) means the confirmed bio
...
Chin, your method reminded me my long forgotten computer language called 'Prolog', which is very suitable for this kind of problem.....and I'm going to illustrate my trial here
These are predicate logic which is mentioned in
this thread.
First, I needed to tell the system some basic rules:
parent_child(X,Y) :- father_child(X,Y).
parent_child(X,Y) :- mother_child(X,Y).
sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y), X\=Y.
(1) and (2) rules tell a parent_child relation is either it's a father_child relation or mother_child relation.
(3) rule tells a sibling relation between 2 is they share a common parent and they're not the same!!! Simple...
Now I'm going to tell the system the relation of these guys....
mother_child(girlmom,girl).
gf_of(girlmom,boy).
father_child(boy,girl).
father_child(girldad,boy).
sibling(boydad,girldad).
mother_child(girlmom,boymom).
father_child(boydad,girlmom).
I hope I'm getting the above correct... To explain:
Rule (1) tells girlmom is mother of girl.
Rule (2) tells girlmom is girlfriend of boy.
etc.
Now I added in Prolog environment to see whether they're related, if you're familiar with recursion, it should be easy to understand below Rule (1), which says anything should related to himself. Others should be similar.
related(X,X).
related(X,Y) :- father_child(X,Z), related(Z,Y).
related(X,Y) :- mother_child(X,Z), related(Z,Y).
related(X,Y) :- sibling(X,Z), related(Z,Y).
and I typed
? - related(girldad,boymom).
Yes
Yes, they're related somehow....but how do I get their real relationship???
I further modified the related to
related(X,X).
related(X,Y) :- father_child(X,Z), related(Z,Y), write(X), write(' is father of '), write(Z), nl.
related(X,Y) :- mother_child(X,Z), related(Z,Y), write(X), write(' is mother of '), write(Z), nl.
related(X,Y) :- sibling(X,Z), related(Z,Y), write(X), write(' is sibling of '), write(Z), nl.
Now I really tried it again:
?- related(girldad,boymom).
girl is sibling of boymom
boy is father of girl
girldad is father of boy
If you read the above reversely, you read their relation, which implies 'girldad' is grand-dad of boymom
? I really don't know.
But I got the fun already!!!!