Dear Gesche, Maybe you could use abolish/1 to remove the dynamic predicate and then use compile_term/1 to re-add the predicate in compiled form. Example: ------------------------------------------------------------------ [eclipse 1]: assert(p:-q). Yes (0.00s cpu) [eclipse 2]: compile_term(q). source_processor.eco loaded in 0.00 seconds ... ecl_compiler.eco loaded in 0.05 seconds Yes (0.05s cpu) [eclipse 3]: clause(p,X). X = q Yes (0.00s cpu) [eclipse 4]: abolish(p/0). Yes (0.00s cpu) [eclipse 5]: p. calling an undefined procedure p in module eclipse Abort [eclipse 6]: compile_term(p:-q). Yes (0.00s cpu) [eclipse 7]: clause(p,X). procedure not dynamic in clause(p, X) in module eclipse Abort [eclipse 8]: p. Yes (0.00s cpu) --------------------------------------------------------------------- Best, Marco On 28/05/14 12:19, Gesche Gierse wrote: > Hi, > > 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: > http://www.swi-prolog.org/pldoc/man?predicate=compile_predicates/1)? > > 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 > prim_action(drive(N)). > > 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). > > debug_action(M) :- has_action(A, M), assert(action(A)), > check_action(A,M), fail. > debug_action(M) :- > list_all_actions(List), > 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])). > > ------------------------- > > Thanks, > Gesche -- Marco Gavanelli, Ph.D. in Computer Science Dept of Engineering University of Ferrara Tel/Fax +39-0532-97-4833 http://docente.unife.it/marco.gavanelliReceived on Thu May 29 2014 - 10:46:23 CEST
This archive was generated by hypermail 2.2.0 : Thu May 29 2014 - 18:13:14 CEST