As gusbro said, not / 1 is a predefined static procedure (and therefore it is not recommended to use the same name). However, this is not the reason why you get an error in swi-prolog, since you can overwrite the standard definition:
?- assert(not(42)). true. ?- not(42). true.
the problem is that you have already defined non / 1 in your code, and when you do not declare the predicate explicitly as dynamic, swi-prolog will assume that it is static and will not allow you to change it.
You can declare it dynamic by inserting this line in your code:
:-dynamic(not/1).
I think this will not solve the problem in other prolog implementations (e.g. gnu-prolog), because the error message says permission_error(modify,static_procedure,not/1) ; in any case, it is strongly recommended that you change the name.
By the way, it would be easier and cleaner to just check what the argument is and print the corresponding message. If, however, you want to create something more complex (using possibly state), you can use global variables, as they are more efficient than assert / retract.
source share