Re: in praise of tabling
- From: rafe@xxxxxxxxxxx
- Date: 20 Apr 2005 21:48:48 -0700
Nick Wedd wrote:
> I wish I could find a
> simple, Clocksin & Mellish-level, tutorial on how tabling works and
how
> to use it.
Well, tabling is, to a first order approximation, Prolog-speak for
memoization. I think the Mercury Reference Manual section on it
says all you need to get the gist in a few paragraphs:
http://www.mercury.cs.mu.oz.au/information/doc-latest/mercury_ref/Tabled-evaluation.html
In a nutshell, a tabled predicate is associated with a hash table of
some kind. Whenever a new result for the predicate is computed, the
result is recorded in the hash table. When the predicate is invoked
the hash table is first consulted to see if the answer(s) is (are)
already known; if so, they can be returned immediately. Otherwise,
if there is no entry in the hash table then the predicate proper must
be evaluated to obtain a result.
The decision as to whether a predicate should be tabled or not depends
upon whether the cost of recomputation outweighs the cost of checking
the hash table and the cost of having the hash table in memory.
-- Ralph
.
- Follow-Ups:
- Re: in praise of tabling
- From: Maori Scarey
- Re: in praise of tabling
- References:
- in praise of tabling
- From: Nick Wedd
- in praise of tabling
- Prev by Date: Re: in praise of tabling
- Next by Date: Re: in praise of tabling
- Previous by thread: Re: in praise of tabling
- Next by thread: Re: in praise of tabling
- Index(es):
Relevant Pages
|