I am trying to encode basic logical inferences in Prolog, and I want to define some custom operators to streamline the notation. It would be handy if I can type |-
for ⊢. So I tried
:- op(1150, xfy, [ '|-' ]).
gamma |- a.
Gamma |- or(A,_) :- Gamma |- A.
Gamma |- or(_,A) :- Gamma |- A.
but when I try the query gamma |- or(a,X)
, I get the error message
ERROR: '<meta-call>'/1: Undefined procedure: gamma/0
instead of the true
I expect.
The problem seems to be that the defined operator includes a vertical bar character. If I modify the knowledge base to
:- op(1150, xfy, [ imp ]).
gamma imp a.
Gamma imp or(A,_) :- Gamma imp A.
Gamma imp or(_,A) :- Gamma imp A.
Then Prolog has no problems answering the query gamma imp or(a,X)
. Is the vertical bar a reserved character that I'm not allowed to use in definitions? Or is there some way around this?