Search code examples
prologiso-prolog

What is the difference between :- and ?- in Prolog?


This Prolog program prints Hello:

main :-
    write('Hello'), nl.

:- main.

I changed (:-)/1 to (?-)/1:

main :-
    write('Hello'), nl.

?- main.

This produces exactly the same result. This also prints Hello.

So what's the difference between (:-)/1 and (?-)/1?


Solution

  • The argument of term with principal functor (:-)/1 is called a directive. In the Prolog standard, it is defined in 7.4.2 Directives.

    In addition, 5.5.5 states:

    A processor may support one or more additional directive indicators (7.4.2) as an implementation specific feature.

    So, in some Prolog systems, (?-)/1 is available as additional directive indicator.