[m-users.] Tabling a semidet predicate

Volker Wysk post at volker-wysk.de
Tue Jun 8 22:47:59 AEST 2021


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).

This won't compile. I get this error message:

tab_semidet.m:010: Error: `:- pragma minimal_model' declaration not allowed
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?

-------------- 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/b146fe16/attachment.sig>

More information about the users mailing list