Tracing with out using trace?
- From: Bruce Horrocks <news@xxxxxxxxxxxxxxxxx>
- Date: Sat, 02 Sep 2006 16:09:30 +0100
Background:
A friend wanted something that would help him graphically illustrate relationships between people - your typical "friend of a friend's wife's mother" type thing.
I suggested using Prolog to store and analyse the relationships and GraphViz [1] to draw them. I dredged my memory, having studied Prolog briefly at college decades ago, and produced an example program to give him an idea of the kind of thing that is possible.[2]
An extract from the program is:
parent( homer, bart).
parent( gramps, homer).
married( homer, marge).
grandparent(X, Y) :-
parent(X, _someone),
parent(_someone, Y).
Problem:
If I ask the program to draw the grandparent relationship then I get a direct link gramps-->bart, which is great but it doesn't show how the relationship was arrived at. It should be possible to illustrate this by highlighting gramps-->homer-->bart.
I don't want to do this by editing the definition of grandparent, if I can help it, because I want my friend to be able to specify his own rules without having to worry about my drawing bit.
So, another way might be to trace the execution of grandparent and output drawing statements for each of the component relationships as they are resolved. I have a vague memory of having written something like a "trace program in prolog" at college but cannot now remember how. So...
The question:
How do I write a trace program in Prolog that would allow me to "get at" each part of the clause body?
Thanks in advance.
Oh, and suggestions for all-singing, all-dancing graphical relationship analysis packages, preferably free, that can be passed onto my friend are also welcome!
[1] http://www.graphviz.org
[2] http://www.horrocks.plus.com/downloads/graphical_relationships.pdf
--
Bruce Horrocks
Surrey
England
<firstname>@<surname>.plus.com -- fix the obvious for email
.
- Follow-Ups:
- Re: Tracing with out using trace?
- From: Markus Triska
- Re: Tracing with out using trace?
- Prev by Date: Re: SWI-Prolog: Undocumented predicates?
- Next by Date: Re: SWI-Prolog: Undocumented predicates?
- Previous by thread: SWI-Prolog: Undocumented predicates?
- Next by thread: Re: Tracing with out using trace?
- Index(es):