family tree - parent_of prolog -


i new prolog , have advice.

i have facts:

male(tom). male(james). male(john). female(elly). female(joanne). female(evonne). brother(john,tom). brother(john,joanne). sister(elly,joanne). parent_of(evonne,john). parent_of(james,john). 

is possible define parent_of rule without using sister , brother?

at first should have parent_of facts core of parental relation. can expand relation attaching 1 of facts child or parent. need use siblings/2 rule if want attach child, or couples/2 rule if want attach parent.

 %if want attach child 'siblings' relation parent_of_rule(x, y) :-         parent_of(x, z),         siblings(z, y). 
 %if want attach parrent 'couples' relation parent_of_rule(x, y) :-         parent_of(z, y),         couples(x, z). 

i don't think it's possible have parent_of_rule rule without use of third party relation.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -