prologiso-prolog

About Prolog syntax


Sometimes I see terms like: X = a:b or X = a-b

I can do requests like X = Y:Z and the compiler unifies Y with a and Z with b, as expected.

Now my answer: Which characters (or sequence of characters) am I allowed to use to combine two Prolog atoms?!

Maybe you can give me some links with further informations about this issue.

Thanks for your help and kind regards from Germany


Solution

  • let's see what's inside X = Y:Z

    ?- display( X = Y:Z ).
    =(_G3,:(_G1,_G2))
    true.
    

    then we have a nested structure, where functors are operators.

    An operator is an atom, and the rule for atom syntax says that we have 3 kind to consider:

    edit

    A functor (shorthand for function constructor, I think, but function is misleading in Prolog context) it's the symbol that 'ties' several arguments. The number of arguments is named arity. In Prolog a term is an atomic literal (like a number, or an atom), or a recursive structure, composed of a functor and a number of arguments, each being a term itself (at least 1).

    Given the appropriate declaration, i.e. op/3, unary and binary terms can be represented as expressions, like that one you show.

    An example of operator, using the : special char, is ':-'

    member(X,[X|_]).
    member(X,[_|T]) :- member(X, T).