Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
% http://icebergsystems.ca/articles/propositional-logic-in-prolog % Representing Propositional Logic Sentences in Prolog % Nicholas Paun % Logical Connectives and(P,Q) :- P, Q, !. or(P,Q) :- (P; Q), !. % use TRUE and FALSE in our logical sentences t. f :- fail. % Tagged True and False values, to tag sentences which hold or donĀ“t hold t(_). f(_) :- fail. % infix syntax for logical connectives % https://www.swi-prolog.org/pldoc/man?predicate=op/3 :- 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. % connectives for implication and equivalence P implies Q :- not P or Q. P equiv Q :- (P and Q) or (not P and not Q). % P = t('A is a knight'),Q = t('B is a knight'), P <=> ~P ^ Q.