You cannot do this. Neither in ISO Prolog, nor in SWI. While the vertical bar serves as the operator; if an appropriate operator declaration is present, it cannot be used without quotation marks as part of an operator with two or more characters. The best you can get in your situation is to declare the |-
operator and use it in quotation marks. In both cases below, quotes are strictly necessary.
:- op(1200, xfx, '|-'). a '|-' b.
Doesn't look too attractive. One, like one character, bar serves as an infix operator.
?- ( a | b ) = '|'(a, b). true. ?- current_op(Pri,Fix,'|'). Pri = 1105, Fix = xfy.
There is another use |
as a head-tail separator in lists. Due to the restrictions on the priority that the infix panel can take, there is no ambiguity between [A|As]
and above.
Note that [a|-].
is a valid Prolog text. Even gamma |- a.
valid in the SWI and even the actual Prolog text in ISO, provided that there is an operator declaration!
?- write_canonical((gamma|-a)). '|'(gamma,-(a))
false source share