based on my question Prolog: define logical operator in Prolog as placeholder for other operator for building a proposition-predicate now I want to make the double negation possible in prolog. Unfortunately I established: calls like (? :- proposition(--a)) lead to a syntax error.
Is there a way to solve this without loss of my operator -?
Prolog has some complex syntax rules around operators to avoid ambiguities. In some cases you have to insert spaces or parentheses to make clear what you want.
This works (and is the form I prefer):
?- X = -(-a).
X = - -a.
?- proposition(-(-a)).
true.
This works as well:
?- X = - -a.
X = - -a.
?- proposition(- -a).
true.
If you find this inconvenient, one thing you could do would be to define --
, ---
, etc. as operators analogously to -
:
?- op(200, fy, --).
true.
?- op(200, fy, ---).
true.
?- X = --a, Y = ---a.
X = --a,
Y = ---a.
?- --a = -(-a).
false.
Then every time you accept user input, you could first run a "preprocessor" that translates a term like --a
into -(-a)
. Personally I think this would not be worth it, but it might be a fun exercise.