我在Prolog中有一些代码,在编译时我有以下错误:
PERMISSION ERROR- dynamic user:examples/2: modifying static procedure examples/2
这是我的部分代码(用于测试的代码):
/* This part is for creating a cache and storing solutions, I got it from false */
:- dynamic(examples/2).
reset :-
retractall(examples(_, _)).
eq(A, B) :-
subsumes_term(A, B),
subsumes_term(B, A).
cached_call(Goal) :-
\+ (examples(First,_), eq(First, Goal)),
copy_term(Goal, First),
catch(
( Goal,
assertz(examples(First, Goal)),
fail
),
Pat,
(reset, throw(Pat))).
cached_call(Goal) :-
examples(First, Results),
eq(First, Goal),
Results = Goal.
/* my function, just for testing the cached technology */
myFunction(V1, V2, Result) :-
cached_call(keepValue(V1, V2, V1cover, V2cover)),
Result is V1/V1cover + V2/V2cover. /* V1cover, V2cover are the value of the first called time of myFunction, they become constants for next called times of myFunction */
myFunction(0,0,0).
keepValue(V1, V2, V1cover, V2cover) :-
V1cover is V1,
V2cover is V2.
当我编译这段代码时,我收到了错误。请告诉我为什么?非常感谢。