prologmetaprogrammingprolog-metainterpreter

No permission to access private_procedure `var/1'


I have written a simple unification algorithm (with occurs check) in Prolog, using meta-programming techniques. I am using SWI-Prolog 7.4.2.

I want to use it inside a meta-interpreter, such as the classic vanilla meta-interpreter:

solve(true) :- !.
solve((A,B)) :- solve(A), solve(B).
solve(A) :- clause(A,B), solve(B).

If I try for example solve(odd(X)) it works, giving as the first solution X = s(0). (Where the clauses are odd(s(0)). and odd(s(s(X))) :- odd(X).)

But if I try to execute the unification algorithm using solve, it doesn't work any more. Since I use meta-predicates like var/1 inside my unification algorithm, I tried with simpler goals.

The problem is this one: if I input solve(var(X)), it says No permission to access private_procedure 'var/1'. I can't find useful information about this, can someone help? Thanks.


Solution

  • Try:

    solve(true) :- !.
    solve((A,B)) :- solve(A), solve(B).
    solve(A) :- predicate_property(A,built_in), !, call(A).
    solve(A) :- clause(A,B), solve(B).
    

    But this will not work the same in all Prolog systems... but the implicit hint should help you move forward.