Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

retract problem in SWI-Prolog

1,258 views
Skip to first unread message

Qiong Cai

unread,
Jun 1, 2001, 1:33:10 AM6/1/01
to
Hi all,
Some codes from the book "First-Order logic
and Automated Theorem proving"(2nd) are as follows:

funcount(1).

newfuncount(N) :-
funcount(N),
retract(funcount(N)),
M is N + 1,
assert(funcount(M)).

reset :-
retract(funcount(_)),
assert(funcount(1)),
!.

But, when I actually call reset or newfuncount,
SWI-Prolog has a ERROR message:
ERROR: No permission to modify static procedure "funcount/1".

Could anyone tell me how to avoid this problem? Thanks


Yours
Qiong


Pascal Bouvier

unread,
Jun 1, 2001, 1:58:05 AM6/1/01
to

You probably have to declare funcount/1 as dynamic before any use
of it. You certainly have to use a directive or a build-in predicate
for that, putting
:- dynamic funcount/1 .
at top of your program.

HTH
--
Pascal

Casper Kuijjer

unread,
Jun 1, 2001, 4:38:31 AM6/1/01
to

"Qiong Cai" <qio...@cse.unsw.edu.au> wrote in message
news:3b1728e...@nancy.pacific.net.au...

> Hi all,
> Some codes from the book "First-Order logic
> and Automated Theorem proving"(2nd) are as follows:
>
> funcount(1).
>
> newfuncount(N) :-
> funcount(N),
> retract(funcount(N)),
> M is N + 1,
> assert(funcount(M)).
>
> reset :-
> retract(funcount(_)),
> assert(funcount(1)),
> !.
>
> But, when I actually call reset or newfuncount,
> SWI-Prolog has a ERROR message:
> ERROR: No permission to modify static procedure "funcount/1".

Defining it dynamic will probably work though I'm not really sure about it.
The problem you're facing didn't appear in the pre-ISO-prolog versions of
SWI prolog so it's probably forced by the ISO definitions.

Why it occurs is that with writing funcount(1) you statically (in your
programcode) define something. Asserting is done dynamically. If defining it
dynamic doesn't work you can always remove funcount(1) and make an procedure
that does nothing but asserting funcount(1). So make a procedure like

initialize :-
assert(funcount(1))

BTW. what does this program do? It seems to be only a snippet of a larger
example.

Casper Kuijjer
http://www.science.uva.nl/~ckuijjer


Qiong Cai

unread,
Jun 2, 2001, 9:33:10 PM6/2/01
to
>
> BTW. what does this program do? It seems to be only a snippet of a larger
> example.
>
Both of solutions work for my program.

It's a help predicate in a theorem prover for first-order logic using
tableau
method.

Thanks
Qiong


"Casper Kuijjer" <ckui...@wins.uva.nl> wrote in message
news:9f7k5e$gb5$1...@news1.xs4all.nl...

jazzbox

unread,
Jun 3, 2001, 12:57:50 AM6/3/01
to
On Fri, 1 Jun 2001 10:38:31 +0200, "Casper Kuijjer"
<ckui...@wins.uva.nl> wrote:

>
>"Qiong Cai" <qio...@cse.unsw.edu.au> wrote in message
>news:3b1728e...@nancy.pacific.net.au...
>> Hi all,
>> Some codes from the book "First-Order logic
>> and Automated Theorem proving"(2nd) are as follows:
>>
>> funcount(1).
>>
>> newfuncount(N) :-
>> funcount(N),
>> retract(funcount(N)),
>> M is N + 1,
>> assert(funcount(M)).
>>
>> reset :-
>> retract(funcount(_)),
>> assert(funcount(1)),
>> !.
>>
>> But, when I actually call reset or newfuncount,
>> SWI-Prolog has a ERROR message:
>> ERROR: No permission to modify static procedure "funcount/1".
>
>Defining it dynamic will probably work though I'm not really sure about it.
>The problem you're facing didn't appear in the pre-ISO-prolog versions of
>SWI prolog so it's probably forced by the ISO definitions.
>

It seems like dynanic should be the default to me. Another
politically incorrect way to delete something is with the "abolish"
predicate.

Fergus Henderson

unread,
Jun 3, 2001, 12:56:29 PM6/3/01
to
jazzbox writes:

>"Casper Kuijjer" <ckui...@wins.uva.nl> wrote:
>
>>Defining it dynamic will probably work though I'm not really sure about it.
>>The problem you're facing didn't appear in the pre-ISO-prolog versions of
>>SWI prolog so it's probably forced by the ISO definitions.
>
>It seems like dynanic should be the default to me.

Making procedures `dynamic' by default would lead to less efficient code.

The ISO standard allows implementations to make procedures static by default,
but IIRC does not require it.

--
Fergus Henderson <f...@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.

jazzbox

unread,
Jun 4, 2001, 3:21:34 PM6/4/01
to
On 3 Jun 2001 16:56:29 GMT, f...@cs.mu.oz.au (Fergus Henderson) wrote:

>jazzbox writes:
>
>>"Casper Kuijjer" <ckui...@wins.uva.nl> wrote:
>>
>>>Defining it dynamic will probably work though I'm not really sure about it.
>>>The problem you're facing didn't appear in the pre-ISO-prolog versions of
>>>SWI prolog so it's probably forced by the ISO definitions.
>>
>>It seems like dynanic should be the default to me.
>
>Making procedures `dynamic' by default would lead to less efficient code.
>
>The ISO standard allows implementations to make procedures static by default,
>but IIRC does not require it.

I guess I'd still put in my vote for dynamic-default. I had the same
problem at first as the original poster. Anyway, the standard
approach to inefficient code these days seems to be just buy a faster
computer.
Mike

Fergus Henderson

unread,
Jun 5, 2001, 9:58:13 AM6/5/01
to
jazzbox writes:

>On 3 Jun 2001 16:56:29 GMT, f...@cs.mu.oz.au (Fergus Henderson) wrote:
>
>>jazzbox writes:
>>
>>>"Casper Kuijjer" <ckui...@wins.uva.nl> wrote:
>>>
>>>>Defining it dynamic will probably work though I'm not really sure about it.
>>>>The problem you're facing didn't appear in the pre-ISO-prolog versions of
>>>>SWI prolog so it's probably forced by the ISO definitions.
>>>
>>>It seems like dynanic should be the default to me.
>>
>>Making procedures `dynamic' by default would lead to less efficient code.
>>
>>The ISO standard allows implementations to make procedures static by default,
>>but IIRC does not require it.
>
>I guess I'd still put in my vote for dynamic-default. I had the same
>problem at first as the original poster.

assert/1 and retract/1 should be better documented, then.

Part of the problem is that a lot of the Prolog documentation,
textbooks, etc., predate the ISO Prolog standard.

Making things dynamic by default would have a *major* impact on efficiency
for optimizing compilers.

Hoang Nguyen Duy

unread,
Nov 18, 2021, 3:21:26 AM11/18/21
to
Vào lúc 12:33:10 UTC+7 ngày Thứ Sáu, 1 tháng 6, 2001, Qiong Cai đã viết:
I'm have to prove the equality of left and right neutral element of a semi group using PROLOG
here is my code:
m(m(x,y),z):- m(x,m(y,z)).
m(el,x)=x.
m(x,er)=x.
and the error is No permission to modify static procedure `(=)/2'
can some one please help me
Thanks so much


Julio Di Egidio

unread,
Nov 18, 2021, 1:43:32 PM11/18/21
to
On Thursday, 18 November 2021 at 09:21:26 UTC+1, Hoang Nguyen Duy wrote:

You should have opened a new thread, not reply to one that is from 2001:
next time, if you think the old discussion is relevant, please just put a link.

> I'm have to prove the equality of left and right neutral element of a semi group using PROLOG
> here is my code:
> m(m(x,y),z):- m(x,m(y,z)).
> m(el,x)=x.
> m(x,er)=x.
> and the error is No permission to modify static procedure `(=)/2'
> can some one please help me
> Thanks so much

That code makes no sense: looks like some kind of Python... Have you
gone through at least one tutorial before attempting to write any Prolog?

Julio
0 new messages