[m-users.] Tabling a semidet predicate
Volker Wysk
post at volker-wysk.de
Wed Jun 9 02:25:25 AEST 2021
Am Dienstag, den 08.06.2021, 14:47 +0200 schrieb Volker Wysk:
> Hi!
>
> I have a semidet predicate, and want to achieve termination with tabling.
> Like this:
>
>
> :- pred test(int::in) is semidet.
> :- pragma minimal_model(test/1).
>
> test(X) :- test(X).
> test(1).
> test(2).
>
>
> This won't compile. I get this error message:
>
>
> tab_semidet.m:010: Error: `:- pragma minimal_model' declaration not allowed
> for
> tab_semidet.m:010: procedure with determinism `semidet'.
> tab_semidet.m:010: The pragma requested is only valid for the following
> tab_semidet.m:010: determinisms: multi and nondet.
>
>
> However, I can work around this limitation like this:
>
>
> :- pred test(int::in, {}::out) is nondet.
> :- pragma minimal_model(test/2).
>
> test(X, B) :- test(X, B).
> test(1, {}).
> test(2, {}).
>
>
> I'm not sure if I understand this fully. Is this the way to go? Why the
> restriction on the determinism category of the tabled predicate?
Actually, I've tried to apply this workaround to my real project and get
this:
desktop ~/src/mtt $ ./mtt "a"
...
*** Mercury runtime: caught segmentation violation ***
cause: address not mapped to object
PC at signal: 139993005971239 (7f52a9645727)
address involved: (nil)
This may have been caused by a stack overflow, due to unbounded recursion.
exiting from signal handler
This looks like the minimal model tabling, which is implemented in Mercury,
can't be used to achieve termination, in my case.
I've searched for a textbook, which explains the theory behind tabling, but
couldn't find any. I need to know, to what classes of problems tabling can
be applied to achieve termination, and how.
I've done the same in SWI-Prolog, which supports tabling as well, and *there
it works*. I don't get an equivalent of the error message above.
Cheers,
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20210608/94f7b938/attachment.sig>
More information about the users
mailing list