Convert a "global variable"



Hi All,

I use assert / retract to set a value which should be accessible in the same
way as a global variable in a functional language. I know that this is not a
good programming style in PROLOG. As long as my program contains assert /
retract I can not use automatic theorem provers (like LPTP:
http://www.inf.ethz.ch/personal/staerk/lptp.html ) in order to prove
left-termination. Robert Staerk writes on this page:

"Non-logical predicates and control operators like cut (!), assert/1,
retract/1, var/1 are forbidden, since they destroy either the lifting
property or modify the program during run-time."

Is there any standard way to convert a global variable to a local one?

I could pass the "global" variable as argument between all predicates of my
program. For example let Path be such a variable. I call the predicate
-? test(x, px, Path).
and it fails. Now, Path should contain the path of the derivation, i.e. the
reason why test failed. However, since test failed, Path is unbound, e.g.
Path = _L123.

Thanks for your help,
Thomas


.



Relevant Pages

  • Re: canonical alternative to assert and retract
    ... is there something like a canonical alternative to assert and retract? ... are there algorithms for translating any Prolog ... to backtracking, it will get very hard to convert the one ...
    (comp.lang.prolog)
  • canonical alternative to assert and retract
    ... is there something like a canonical alternative to assert and retract? ... are there algorithms for translating any Prolog ... more compilers. ...
    (comp.lang.prolog)
  • Re: canonical alternative to assert and retract
    ... is there something like a canonical alternative to assert and retract? ... are there algorithms for translating any Prolog ... I noticed you mentioned Yield Prolog. ...
    (comp.lang.prolog)
  • Re: Networking in Prolog - a survey
    ... I don't think that is a problem, no more than an assert in single- ... If the interpreter starts solving a goal, ... clause or it won't. ... with the retract being the problematic one. ...
    (comp.lang.prolog)
  • Re: Help Im stuck!
    ... > use retract to find the maximum score: ... I'm not a big fan of assert/retract, so I'm not sure of this, but shouln't ...
    (comp.lang.prolog)