Question

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.

Was it helpful?

Solution

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
?-
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top