Problems with large terms

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with large terms

Simile support
I am finding that manipulating terms with large (actually not that
large!) numbers of primitives is causing gprolog to run out of stack
space, even when it is set very generously. For instance, the attached
file just contains B = 9.4+9.4+...+9.4. (total of 1024 values). But I
have tried to consult it with the v1.4.3 release and with the very
latest unstable version uploaded today, and I get:

$ export GLOBALSZ=524288
$ gprolog
GNU Prolog 1.4.4 (64 bits)
Compiled Feb  7 2014, 12:45:24 with gcc
By Daniel Diaz
Copyright (C) 1999-2014 Daniel Diaz
| ?- consult(big).
compiling /home/jaspert/Test/PrologLimits/big.pl for byte code...
/home/jaspert/Test/PrologLimits/big.pl:1: warning: singleton variables
[B] for (=)/2

Fatal Error: global stack overflow (size: 524288 Kb, reached: 524285 Kb,
environment variable used: GLOBALSZ)
compilation failed

no
| ?-
Is this a simple thing to fix? I use Prolog to parse equations entered
by my users, and some of them tend to write very long ones...
Cheers
     --Jasper

_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog

big.pl (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems with large terms

Daniel Diaz-3
Hi Jasper,

you are right, gplc (which is called by consult) has problems to compile large terms containing many nested structures or lists  (floats appearing inside compound terms are considered as structures). This would not occur with atoms or integers.

The problems comes from the register allocated. I have to rewrite this part.

The best I can suggest is to avoid the compilation, and instead read it and assert it. BTW you file contains B = … thus you cannot consult nor assert it since =/2 is a built-in predicate.

Example (I assert q(B = …)):

open('big.pl', read, Stream), read(X,Clause), assertz(q(Clause)), close(Stream).

then you can call:

q(X).

If you need to refer q/1 from a Prolog program, add in this program

:- dynamic(q/1).

you can add a directive

:- initialization(load_big).

load_big :-
        open('big.pl', read, Stream),
        read(X,Clause),
        assertz(q(Clause)),
        close(Stream).


Obviously you can read several clauses and add them using a repeat-fail loop.

Hope this helps.

Daniel


Le 7 févr. 2014 à 13:56, Simile support <[hidden email]> a écrit :

> I am finding that manipulating terms with large (actually not that large!) numbers of primitives is causing gprolog to run out of stack space, even when it is set very generously. For instance, the attached file just contains B = 9.4+9.4+...+9.4. (total of 1024 values). But I have tried to consult it with the v1.4.3 release and with the very latest unstable version uploaded today, and I get:
>
> $ export GLOBALSZ=524288
> $ gprolog
> GNU Prolog 1.4.4 (64 bits)
> Compiled Feb  7 2014, 12:45:24 with gcc
> By Daniel Diaz
> Copyright (C) 1999-2014 Daniel Diaz
> | ?- consult(big).
> compiling /home/jaspert/Test/PrologLimits/big.pl for byte code...
> /home/jaspert/Test/PrologLimits/big.pl:1: warning: singleton variables [B] for (=)/2
>
> Fatal Error: global stack overflow (size: 524288 Kb, reached: 524285 Kb, environment variable used: GLOBALSZ)
> compilation failed
>
> no
> | ?-
> Is this a simple thing to fix? I use Prolog to parse equations entered by my users, and some of them tend to write very long ones...
> Cheers
>    --Jasper
>
> --
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
>
> <big.pl>_______________________________________________
> Bug-prolog mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/bug-prolog


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog