Re: newbie: Out of local stack, matching values from 0 to 10



Hello Jan and Bart,
Thanks for the information.
I had never heard of tabling and XSB before, so I gave it a quick google. I can't say I understand it. I have little knowledge about resolution, but I understand tabling is another approach? I think I'll dig up my prolog books and read up on tabling, might be interesting..


For the time being, between(0, 9, X). Is good enough for me :)

Thanks again,
Matthijs.

Bart Demoen wrote:
Jan Wielemaker wrote:

in_bounds(0).

in_bounds(X) :-
    in_bounds(Y),
    X is Y + 1,
    X < 10.
---

[..]


A Prolog system with tabling like XSB will (as far as I understand it) fix this. (but not for in_bounds(-1), right?)


No.
I assume you added
:- table in_bounds/1.
to the program.

Then also the query ?- in_bounds(-1). finishes in XSB, because:

    the goal with -1 does not unify with the first head
    the goal with -1 unifies with the second head, and in the
        body a new subgoal in_bounds(Y) is spawned and you were
        already convinced that when in_bounds is called with a
        free var, it finishes after some time, so this goal
        also consumes its answers - there are exactly 10 values
        for Y, but none of them is 1 less than the -1 (the X),
        so failure results

Right ?

Tabling is wonderfull, isn't it !

Cheers

Bart Demoen

.



Relevant Pages

  • Re: in praise of tabling
    ... to the lack of gnuconf toolchain, ... XSB and trying it out - after you did that, ... something which would enlight us about the performance, the quality of documentation, the ease to integrate with other langage, quality of built-in predicate, etc.... ... difficult to measure objectively I think) or of integration ease, but about performance (tabling, builtins, other issues) there is a fair amount of published literature. ...
    (comp.lang.prolog)
  • Re: Prolog for highschool students
    ... >>Never subject students to a version of prolog without tabling. ... the right hand side of a horn clause is a conjunction. ... XSB doesn't compile on Fedora. ...
    (comp.lang.prolog)