alias `(not)/1` in prolog
题
I have recieved a piece of code for an assignment called exShell. In it, the code uses (not)/1
for negation, I have currently replaced all instances with (\+)/1
but I was wondering why that would be there in the first place. Is it possible to alias (\+)/1
with (not)/1
or is that a convention of cprolog or some other prolog compiler (for instance cprolog).
solve(not A, C, Rules, (not Proof, C), T, Ask) :- !,
T1 is -1 * T,
solve(A, C1, Rules, Proof, T1, Ask),
C is -1 * C1.
This is an example of it being used.
解决方案
looks like not
here is a unary operator, declared e.g. with op(500,fy,not)
, so is used as symbolic data which the solve/6
predicate is processing. E.g.,
?- op(500,fy,not).
Yes
?- write( not 3).
not 3
Yes
?- write_canonical( not 3).
not(3)
Yes
?- not 3 =.. X .
X = [not, 3]
Yes
?-
不隶属于 StackOverflow