[eclipse-clp-users] Checking for existing clauses without dynamic definition?

From: Gesche Gierse <gierse_at_...358...>
Date: Wed, 28 May 2014 12:19:58 +0200

I'm using eclipse to run Golog programs. However I do not have a special
parser for Golog, thus I frequently debug errors which could have been
easily found with some simple syntax checks.

Therefore I'm trying to implement such checks, e.g. the definitions
needed are complete. So  as an example I want to check that whenever
there is a clause prim_action(X) that there is also an execute(X, _) and
poss(X, _).

So far I used the clause/2 predicate to check this. This works, but
unfortunately requires my predicates (e.g. prim_action, execute, poss)
to be dynamic and my normal program does not work properly with dynamic
clauses. Therefore I can only either check my code or run it properly.

Is there any way to check this properties without need to declare my
predicates as dynamic? Or can I alternatively somehow say at runtime
"well I finished the check, so from now on please compile these
predicates as static, they won't change" (like compile_predicates/1 in
swi prolog:

I would really appreciate any help.

Following are example of my source code:

As a (very brief) example, a piece of Golog code might look like this:
:- module(golog_agent).

% definition of possible actions

poss(drive, some_condition).

execute(drive(N), Sensing_result) :- drive_to(N), writeln(N).

% an actual golog program
proc(do_something, drive("location")).

run :- call_golog_execution(do_something).

And this is an extract from the checker I wrote:

:- module(check_indigolog).

:- export basic_check/0.
:- tool(basic_check/0, basic_check/1).
:- use_module("logging").

:- dynamic(action/1).

basic_check(M) :-
    log_info("GologChecker: checking actions..."),

debug_action(M) :- has_action(A, M), assert(action(A)),
check_action(A,M), fail.
debug_action(M) :-
    log_info("GologChecker: Found actions: %D_w", [List]),
    log_info("GologChecker: basic action check finished.").

has_action(A, M) :- clause(prim_action(A), _body)@M.
has_execute(A, M) :- clause(execute(A,_), _body)@M.
has_poss(A, M) :- clause(poss(A,_))@M.

% When prim_fluent(A) is found, check if execute and poss exist, too.
check_action(A,M) :-
        (has_execute(A, M)
                ; !,
                  log_warn("GologChecker: WARNING: Action \"%w\"
defined, but no execute() found!", [A])),
        (has_poss(A, M), ! ; !, log_warn("GologChecker: WARNING: Action
\"%w\" defined, but no poss() found!", [A])).


Received on Wed May 28 2014 - 10:56:15 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST