Menu

#255 The Datalog engine hang on recursive query

wrong answer
open
nobody
None
5
2022-11-29
2022-11-28
chi
No

Hi,

I find the following program, which has a recursive query, makes the Datalog engine hang.

:- table sxud/1.

kuts(-28).

sxud(A) :- kuts(A).
huvd(B) :- kuts(B).
kuts(B) :- huvd(B).

I run it with the command:

xsb --noprompt --quietload --nobanner --nofeedback -e "example.P, sxud(A), writeln([A]), fail. halt."

But if I query the result of kuts, I can get the result, as follow:

:- table kuts/1.

kuts(-28).

sxud(A) :- kuts(A).
huvd(B) :- kuts(B).
kuts(B) :- huvd(B).

I run it with command:

xsb --noprompt --quietload --nobanner --nofeedback -e "example.P, kuts(A), writeln([A]), fail. halt."

the result is -28.

Did I do something wrong?

Related

Bugs: #255

Discussion

  • Michael Kifer

    Michael Kifer - 2022-11-28
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style id="user-content-bidiui-paragraph-margins" type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>

    you are tabling sxud/1 but the recursive predicate is kuts/1 or huvd/1, not sxud/1.



    On 11/28/22 8:00 AM, chi wrote:
    ---
    
    ** [bugs:#255] The Datalog engine hang on recursive query**
    
    **Status:** open
    **Group:** wrong answer
    **Created:** Mon Nov 28, 2022 01:00 PM UTC by chi
    **Last Updated:** Mon Nov 28, 2022 01:00 PM UTC
    **Owner:** nobody
    
    
    Hi,
    
    I find the following program, which has a recursive query, makes the Datalog engine hang. 
    
    
    :- table sxud/1.
    
    kuts(-28).
    
    sxud(A) :- kuts(A).
    huvd(B) :- kuts(B).
    kuts(B) :- huvd(B).
    
    I run it with the command:
    xsb --noprompt --quietload --nobanner --nofeedback -e "example.P, sxud(A), writeln([A]), fail. halt."
    
    But if I query the result of kuts, I can get the result, as follow:
    :- table kuts/1.
    
    kuts(-28).
    
    sxud(A) :- kuts(A).
    huvd(B) :- kuts(B).
    kuts(B) :- huvd(B).
    
    I run it with command:
    xsb --noprompt --quietload --nobanner --nofeedback -e "example.P, kuts(A), writeln([A]), fail. halt."
    
    the result is -28. Did I do something wrong? --- Sent from sourceforge.net because you indicated interest in <https://sourceforge.net/p/xsb/bugs/255/> To unsubscribe from further messages, please visit <https://sourceforge.net/auth/subscriptions/>
     
    • chi

      chi - 2022-11-29

      Hi,

      Thank you very much for your quick answer. I still have a very small question, even if I am tabling sxud/1, shouldn't the fix point be reached when the facts of the relation in the recursive query are unchanged?

       
      • Michael Kifer

        Michael Kifer - 2022-11-29

        Without tabling recursive preds it won't.

        Nov 28, 2022 20:34:12 chi cztest@users.sourceforge.net:

        Hi,

        Thank you very much for your quick answer. I still have a very small question, even if I am tabling sxud/1, shouldn't the fix point be reached when the facts of the relation in the recursive query are unchanged?


        ** [bugs:#255] The Datalog engine hang on recursive query**

        Status: open
        Group: wrong answer
        Created: Mon Nov 28, 2022 01:00 PM UTC by chi
        Last Updated: Mon Nov 28, 2022 01:00 PM UTC
        Owner: nobody

        Hi,

        I find the following program, which has a recursive query, makes the Datalog engine hang.
        ~~~
        :- table sxud/1.

        kuts(-28).

        sxud(A) :- kuts(A).
        huvd(B) :- kuts(B).
        kuts(B) :- huvd(B).
        ~~~

        I run it with the command:
        ~~~
        xsb --noprompt --quietload --nobanner --nofeedback -e "example.P, sxud(A), writeln([A]), fail. halt."
        ~~~

        But if I query the result of kuts, I can get the result, as follow:
        ~~~
        :- table kuts/1.

        kuts(-28).

        sxud(A) :- kuts(A).
        huvd(B) :- kuts(B).
        kuts(B) :- huvd(B).
        ~~~
        I run it with command:
        ~~~
        xsb --noprompt --quietload --nobanner --nofeedback -e "example.P, kuts(A), writeln([A]), fail. halt."
        ~~~
        the result is -28.

        Did I do something wrong?


        Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/xsb/bugs/255/

        To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

         

        Related

        Bugs: #255

        • chi

          chi - 2022-11-29

          Thank you very much for your patient answer! I got it! We can close this ticket now.

           

Log in to post a comment.