On 05/03/2015 05:00 PM, Bruce Colletti wrote:
> What I seek is a way to recognize ~~x, ~~~~x, ~~~~~~x, etc. as the
> term x.
Ah, so you want to normalize logical expressions which are represented
as Prolog terms. To my best knowledge, SWIPL does not come with anything
to help with that particular task, here's a way to implement it
(provided your terms are always ground):
remove_double_negation(not(not(X)), Y) :-
!,
remove_double_negation(X, Y).
remove_double_negation(X, X).
Note that this only removes double negation from the very outside of the
term. If you need more normalization, consider implementing a full
conversion to conjunctive normal form.
Note also that when Prolog programmers read "double negation", they
usually think of double negation by failure, which Jan mentioned. It is
a useful technique in Prolog programming, but a very different thing.