If we have
loves(jane,jim).then jane and jim refer to specific objects. Both jane and jim are constants. In particular, in DEC-10 Prolog terminology, both are atoms. Also, ``loves'' happens to be an atom too because it refers to a specific relationship. Generally speaking, if a string of characters starts with a lower case letter, the DEC-10 family of Prologs assume that the entity is an atom.
There are constants other than atoms ---including integers and real numbers.
A constant is an atom or a number. A number is an integer or a real number. The rules for an atom are quite complicated:
So the following are all atoms:likes_chocolate, fooX23, ++*++, ::=, 'What Ho!'By the way, you can include a single quote within a quoted atom ---just duplicate the single quote. This gives the quoted atom with a single quote as:A practical warning: remember to pair off your (single) quote signs when inputing a quoted atom or Prolog may keep on swallowing your input looking for that elusive single quote character. This is one of the most common syntactic errors for beginners.
While we are on the subject, another common error is to assume that a double quote (
") behaves like a single quote --- i.e. that the term
"Hello"is an atom just like
'Hello'. This is not so. When you do find out what sensible things can be done with the double quote then remember to pair them off.
Because Prolog is modelled on a subset of first order predicate logic, all predicate names must be constants ---but not numbers. In particular,
That is, we cannot have X(jane,jim) as representing the fact that jane and jim are related in some unknown way.