Two clauses belong to the same predicate if they have the same functor (name) and the same arity (number of arguments). Thus,
<program> ::= <predicate> | <program><predicate> <predicate> ::= <clause> | <predicate><clause> <clause> ::= <base clause> | <nonbase clause>
mother(jane, jim)are different predicates.
A structure is a functor followed by zero or more arguments; the arguments are enclosed in parentheses and separated by commas. There must be no space between the functor and the opening parenthesis! If there are no arguments, the parentheses are omitted.
<base clause> ::= <structure> . <nonbase clause> ::= <structure> :- <structures> . <structures> ::= <structure> | <structure> , <structures>
Arguments may be any legal Prolog values or variables.
<structure> ::= <name> | <name> ( <arguments> ) <arguments> ::= <argument> | <argument> , <arguments>
A variable is written as a sequence of letters and digits, beginning with a capital letter. The underscore (_) is considered to be a capital letter.
An atom is any sequence of letters and digits, beginning with a
lowercase letter. Alternatively, an atom is any sequence of
characters, enclosed by single quotes ('); an internal single quote
must be doubled. Examples:
As syntactic sugar, Prolog allows certain infix operators: ','
(comma), ';' (semicolon), ':-' (turnstile), +, -, *, /, =, ==, and
many others. These are the same as the operator written as the
functor of a structure; for example,
2+2 is the same as
Comments begin with the characters
/* and end with
*/. Comments are not restricted to a single line, but may
not be nested.
/* This is a comment. */