Hopefully theres got to be at least one person out there that knows a little bit about Prolog. I'll admit straight up that this is a coursework problem, but I'm stuck right at the end, and the error is so stupid, I just can't quite work it out..
Incidently, I'm using SWI-Prolog for this. The shortened version of my code is as follows.
frame(bird, subclass_of(animal), [beak, feathers]).
frame(flying_bird, subclass_of(bird),[]).
frame(canary, subclass_of(flying_bird), [colour(yellow)]).
frame(tweetie, instance_of(canary), [cage(blue),type(cage, colour)]).
This is a sample of a tree structure involving various animals. The above is all thats needed to demonstrate this really..
fask(Name, Value, Accum,[Name|Accum]):-
frame(Name,_,List),
member(Value, List),
write('Accum is: '), write(Accum).
fask(Name, Value, Accum, [Name|History]):-
frame(Name, instance_of(Sometype),_),
fask(Sometype, Value, [instance_of|Accum], History ).
fask(Name, Value, Accum, [Name|History]):-
frame(Name, subclass_of(Superclass),_),
fask(Superclass, Value,[subclass_of|Accum] ,History).
The above should then be able to be used, to find out if tweetie the canary has a beak, as its a bird via inheritance. I can do this no worries, but the problem comes when I try and record the inheritance path and write it out (ulitmatly for the purpose of loop detection).
?- fask(tweetie, beak [], Inheritance_History).
Inheritance_History = [tweetie, canary, flying_bird, bird, subclass_of, subclass_of, instance_of].
Yes
As you can see, it works, except for the fact that the two halfs need merging, if that makes sense..
Bit of an obscure area I know, but if anyone feels like shedding some light on this, I would be very grateful. In the mean time, I'm gonna keep hitting the books in search of an answer..