Hi, teaching myself prolog I found an interesting article about how to rewrite Prolog operators to represent propositional logic, so that you can formulate propositions like:
P = t('A is a knight'),Q = t('B is a knight'), P <=> ~P ^ Q.
I created this notbook on swish with the complete code.
It redefines the operators two times and aliases them. But the not
alias ~
, the implies
and the equiv
alias don´t work and I get an “operator expected” error in swish and swipl. The code looks ok, but what am I missing, or misunderstanding?
% infix syntax for logical connectives
:- op(400,xf,not).
:- op(500,xfx,and).
:- op(500,xfx,or).
:- op(600,xfx,implies).
:- op(600,xfx,equiv).
% logical operators for the connectives
:- op(400,xf,~).
:- op(500,xfx,^).
:- op(500,xfx,v).
:- op(600,xfx,=>).
:- op(600,xfx,<=>).
% aliases of the connectives
~P :- not P.
P ^ Q :- P and Q.
P v Q :- P or Q.
P => Q :- P implies Q.
P <=> Q :- P equiv Q.