# Prolog/Glossary

This is a glossary of common Prolog terms[1].

Argument
Arguments are terms that appear in a compound term. E.g. A1 and a2 are the first and the second argument of the term `myterm(A1, a2)`.
Arity
The number of arguments that a predicate takes. E.g. `member(X,List)` has arity 2. In documentation, the arity of a predicate is written as predicate/arity. E.g. `member/2`.
Backtracking
If a sub-goal fails, the built-in Prolog search mechanism will go back to the parent-goal. Any variables that were instantiated in the sub-goal will be un-instantiated. Prolog will then search for a new way of satisfying the sub-goal. This process is called backtracking.
Clause
Compound term

Also called structure. It consists of a name followed by N arguments, each of which are terms. N is called the arity of the term.

Fact
A clause with no body, that is a head on its own.
Functor
Combination of name and arity of a compound term. The term `foo(a, b, c)` is said to be a term belonging to the functor foo/3 . foo/0 is used to refer to the atom foo.
Goal
Question stated to the Prolog engine. A goal is either an atom or a compound term. A goal succeeds, in which case the variables in the compound terms have a binding or fails if Prolog fails to prove the goal.
Ground Term
A Term which has no logic variables in it.
Predicate
A set of clauses or a relation.
Query
See goal.
Relation
Synonym for Predicate.
Recursion/Recursive
Definition missing
Rule
See clause.
Term
Every object in Prolog is a term, that includes variables, compounds, numbers, source code.
Unification
Prolog process to make two terms equal by assigning variables in one term to values at the corresponding location of the other term. E.g.,

```?- foo(a, B) = foo(A, b). A = a, B = b.``` Unlike assignment, which does not exist in Prolog, unification is not directed.

Singleton Variable
If a variable is named only once in a clause, usually it is replace with _.