Any Prolog implementation that allows you to leave recursion?

I wonder if there is any implementation of Prolog that allows you to leave recursion in sentences. My intuition is that if an implementation uses a breadth-first search for the target, it can support left recursion. But I'm not quite sure. Please note that I'm not really interested in efficiency.

+4
source share
1 answer

Your intuition is correct, but Prolog uses the depth of the first design search (see the SLDNF resolution here ) and with good reasons, this limitation is not easily avoided.

OTOH, Ciao Prolog offers an appropriate extension.

You can simulate the width of the first recursion using a meta-interpreter, as is done, for example, here for left recursive DCG (left recursive grammars are a common case), but this is not an easy way to follow.

IMO - the most common extension that can approximate / satisfy your request is a tab, you can find it in YAP Prolog, XSB, B-Prolog.

+5
source

Source: https://habr.com/ru/post/1484162/


All Articles