i had quick question error got. new prolog please excuse me if simple fix.
here trying do:
consider database created in question 1. in implementing following rules, can add additional rules make implementation easier.
2.1 add following set of rules extend family relations among members: (1) parent_of, (2) sibling_of, (3) uncle_of, (4) uncleoraunt_of, (5) spouse_of, , (6) descendant_of
2.2 add @ least 10 facts database. these new facts should show consistent relationship among family members , must ensure (1) no conflict facts,(2) no redundant information, (3) each rule defined in question 2.1 can return "yes" value @ least 1 set of parameters.
2.4 add rule called fullquestions @ end of database test rules have defined in homework. include sufficient write statements, answers individual questions printed. make sure compound question can terminate (will not cause "dead loop"). include output comments.
here got far:
/* database family. consists of facts , rules. */ /* facts */ /* female(ella). female(jodi). female(sonya). /* male(arnold). */ male(chris). /* male(louis). male(mark). */ father_of(x,y) :- parent_of(x,y), is_male(x). father_of(arnold, chris). /* arnold father of chris */ father_of(louis, mark). father_of(mark, arnold). mother_of(x,y) :- parent_of(x,y), is_female(x). mother_of(ella, sonya). mother_of(jodi, mark). child(x, y) :- parent_of(y, x). parent_of(x, y) :- child(y, x). parent_of(jodi, ella). parent_of(jodi, mark). parent_of(louis, mark). parent_of(mark, arnold). parent_of(jose, sergio). parent_of(ana, sergio). parent_of(jose, gio). parent_of(ana, gio). parent_of(joe, jose). parent_of(mary, jose). /* rules */ grandmother_of(x, z) :- mother_of(x, y), (mother_of(y, z); father_of(y, z)). is_male(x) :- father_of(x, _). is_female(x) :- mother_of(x, _). sibling_of(x, y) :- parent_of(z, x), parent_of(z, y). sister(x,y) :- siblings(x,y), is_female(x), x \= y. brother(x,y) :- siblings(x,y), is_male(x), x \= y. uncle_of(x,y) :- brother(x,z), mother_of(z,y). uncle_of(x,y) :- brother(x,z), father_of(z,y). uncleoraunt_of(x, y) :- brother(x,z), mother_of(z,y). uncleoraunt_of(x, y) :- brother(x,z), father_of(z,y). uncleoraunt_of(x, y) :- sister(x,z), father_of(z,y). uncleoraunt_of(x, y) :- sister(x,z), mother_of(z,y). spouse_of(x,y) :- child(p, x), child(p, y). ancestor( x , y ) :- parent_of( x , y ). ancestor( x , y ) :- parent_of( x , z ) , ancestor( z , y ). descendant_of(x, y) :- ancestor(y, x). familyquestions :- grandmother_of(x, arnold), write('the grandmother of arnold '), write(x), nl, father_of(y, mark), write(y), write(' father of mark'), nl, nl.
however, when try compile multiple errors:
/tmp/gplcexlkpg.o: in function `predicate(sister/2)':
(.text+0x7b3): undefined reference `predicate(siblings/2)'
/tmp/gplcexlkpg.o: in function `predicate(brother/2)':
(.text+0x843): undefined reference `predicate(siblings/2)'
collect2: error: ld returned 1 exit status
compilation failed
the "warning: discontiguous predicate parent_of/2 - clause ignored error" pops because there separation of parent_of/2 predicate. try parent_of(x, y) :- child(y, x).
right under parent_of(mary, jose).
like this:
father_of(x,y) :- parent_of(x,y), is_male(x). father_of(arnold, chris). /* arnold father of chris */ father_of(louis, mark). father_of(mark, arnold). mother_of(x,y) :- parent_of(x,y), is_female(x). mother_of(ella, sonya). mother_of(jodi, mark). parent_of(x, y) :- child(y, x). parent_of(jodi, ella). parent_of(jodi, mark). parent_of(louis, mark). parent_of(mark, arnold). parent_of(jose, sergio). parent_of(ana, sergio). parent_of(jose, gio). parent_of(ana, gio). parent_of(joe, jose). parent_of(mary, jose).
etc..
i dont remember exact syntax sure ";" (or) should work:
uncleoraunt_of(x, y) :- (brother(x,z), mother(z,y)); (brother(x,z), father(z,y)); (sister(x,z), father(z,y)); (sister(x,z), mother(z,y)).
give try , let me know. way can fix fatal error rewriting to
uncleoraunt_of(x, y) :-brother(x,z), mother(z,y). uncleoraunt_of(x, y) :-brother(x,z), father(z,y). uncleoraunt_of(x, y) :-sister(x,z), father(z,y). uncleoraunt_of(x, y) :-sister(x,z), mother(z,y).
hope made things clear , im right.
....................................................