I’m currently working on a forward chaining inference engine. It uses a natural language like representation for facts and rules, implemented with Prolog operators (similarly to Bratko: “Prolog Programming for Artificial Intelligence”).
So far so good, the inference engine works as expected.
The problem I’m facing is with integration tests using PL-Unit. When I’m testing the inference engine, I would like to provide the facts and rules from the tests. However, it seems that although the operators are provided correctly to the Pl-Unit module scope, I keep getting this
**Unknown procedure** error, since in the inference engine there are no defined predicates corresponding to those operators.
I wrote an example piece of code for this problem. The ‘greets’ operator is defined for demonstration.
:- module(scope,[ op(700,xfy,greets), say_hello/0 ]). say_hello :- X greets Y, writef('%w says hello to %w', [X,Y]). :- begin_tests(say_hello). alice greets bob. test(say_hello) :- say_hello. :- end_tests(say_hello).
Welcome to SWI-Prolog (threaded, 64 bits, version 8.2.3) … ?- run_tests. % PL-Unit: say_hello **ERROR: scope.pl:13:** **test say_hello: received error: scope:say_hello/0: Unknown procedure: scope:(greets)/2** done % 1 test failed % 0 tests passed **false.**
If you move
alice greets bob. to the main module, the test passes, but I would naturally like to provide it from the test module. How should I construct the tests?