logic-and-learning-lab / Popper

An inductive logic programming system
MIT License
206 stars 36 forks source link

janus.PrologError: '$c_call_prolog'/0: Arguments are not sufficiently instantiated #83

Closed Timisorean closed 8 months ago

Timisorean commented 8 months ago

When adding a rule like the following to my bk.pl file (in my case, to the files as in #81):

arg(X, [X]).

I get following error:

Traceback (most recent call last):
  File "/bin/popper-ilp", line 8, in <module>
    prog, score, stats = learn_solution(settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/loop.py", line 1711, in learn_solution
    timeout(settings, popper, (settings, tester, bkcons), timeout_duration=int(settings.timeout-time_so_far),)
  File "/lib/python3.12/site-packages/popper/util.py", line 81, in timeout
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/loop.py", line 1640, in popper
    Popper(settings, tester, bkcons).run()
  File "/lib/python3.12/site-packages/popper/loop.py", line 314, in run
    cons_ = tuple(self.explain_incomplete(prog))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/loop.py", line 858, in explain_incomplete
    unsat_cores = self.explain_totally_incomplete(prog)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/loop.py", line 1298, in explain_totally_incomplete
    return list(self.explain_totally_incomplete_aux2(prog, set(), set()))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/loop.py", line 1451, in explain_totally_incomplete_aux2
    xs = self.explain_totally_incomplete_aux2(subprog, sat, unsat)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/loop.py", line 1477, in explain_totally_incomplete_aux2
    if self.tester.is_body_sat(body):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/tester.py", line 222, in is_body_sat
    return bool_query(query)
           ^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/popper/tester.py", line 22, in bool_query
    return query_once(query)['truth']
           ^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/janus_swi/janus.py", line 243, in query_once
    return _swipl.call(query, inputs, keep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
janus.PrologError: '$c_call_prolog'/0: Arguments are not sufficiently instantiated
andrewcropper commented 8 months ago

For some Prolog bk, you need to provide directions:

https://github.com/logic-and-learning-lab/Popper?tab=readme-ov-file#directions

Otherwise, Popper could generate a rule that calls arg/2 without either argument being ground.

Alternatively, you could add a check to your arg/2 relation to ensure at least one argument is ground.

On 8 Mar 2024, at 16:16, Samuel Stante @.***> wrote:

When adding a rule like the following to my bk.pl file (in my case, to the files as in #81): arg(X, [X]). I get following error: Traceback (most recent call last): File "/bin/popper-ilp", line 8, in prog, score, stats = learn_solution(settings) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/loop.py", line 1711, in learn_solution timeout(settings, popper, (settings, tester, bkcons), timeout_duration=int(settings.timeout-time_sofar),) File "/lib/python3.12/site-packages/popper/util.py", line 81, in timeout result = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/loop.py", line 1640, in popper Popper(settings, tester, bkcons).run() File "/lib/python3.12/site-packages/popper/loop.py", line 314, in run cons = tuple(self.explain_incomplete(prog)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/loop.py", line 858, in explain_incomplete unsat_cores = self.explain_totally_incomplete(prog) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/loop.py", line 1298, in explain_totally_incomplete return list(self.explain_totally_incomplete_aux2(prog, set(), set())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/loop.py", line 1451, in explain_totally_incomplete_aux2 xs = self.explain_totally_incomplete_aux2(subprog, sat, unsat) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/loop.py", line 1477, in explain_totally_incomplete_aux2 if self.tester.is_body_sat(body): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/tester.py", line 222, in is_body_sat return bool_query(query) ^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/popper/tester.py", line 22, in bool_query return query_once(query)['truth'] ^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/janus_swi/janus.py", line 243, in query_once return _swipl.call(query, inputs, keep) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ janus.PrologError: '$c_call_prolog'/0: Arguments are not sufficiently instantiated

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Timisorean commented 8 months ago

Thanks again for the fast response! Works perfectly now with directions.