Re: Question from a Prolog dummy

In message <1183533482.517825.116350@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, nowhereface@xxxxxxx writes
I'm currently reading my first book on Prolog.

The book was going over some simple examples for how Prolog searches
the tree in order to find a solution. It used an example "A happy
person is healty, wealthy, and wise," i.e.

happy(X) :- health(X), wealthy(X), wise(X). (Hope I did that right)

Then it showed all the information that had been entered, i.e.
happy(jane)... wise(jim)... etc. and traced through the whole search
thing with happy(jane) as the goal.

My question is "How does Prolog store the information in memory?" for
instance happy(jane)? The reason I ask is, the book showed it
comparing jane with jim and fred and everyone else before discarding
them and arriving at a bona-fide jane in memory to compare to. The
question that popped into my head was "if jane was stored as a hash,
we wouldn't need to compare her to everyone else, we could just go
right to her to determine if she exists or not."

"jane" as such is not stored anywhere. What is stored is the various facts such as 'happy(jane)'. And these are stored under the predicate that they are facts for - in this case, under happy/1. [They are probably stored as a linked list for happy/1 - but they might not be, and anyway it should be no concern of the programmer.]

Understanding that this could quite well be (and probably is) a stupid
question because I'm about as new to this as one could get, is jane
(and/or happy(jane), healthy(jane), etc) stored as a hash in Prolog?
Would this then eliminate having to search everything in memory one by
one until one reaches jane? I'm just trying to get a feel for the
internals of Prolog.

If you want to know if there is any mention of 'jane' anywhere among all the facts and rules known by your Prolog system, it can be done. But it's not what you want at the moment.

Nick
--
Nick Wedd nick@xxxxxxxxxxxxx
.