Prolog (source code)
= Prolog
{c}
<Prolog> expresses programs through facts and rules and answers queries by solving goals. A rule such as `ancestor(X,Y) :- parent(X,Y).` provides one way to establish a relationship. A recursive rule can search through intermediate parents. <Unification> matches a goal with a rule head and propagates bindings; <backtracking> explores alternative matches when a branch fails or another answer is requested.<Getting started quickly in the SWI-Prolog manual>[§2.1, rules and queries]{ref}
The logical core is associated with Horn clauses and <SLD resolution>, but clause order and goal order also determine a conventional Prolog program's search behavior. A logically valid recursive specification can loop before reaching an available answer. Predicates with input/output effects and control operations add further operational behavior. Arithmetic evaluation is also distinct from term matching: `X = 1+2` builds a term, whereas `X is 1+2` evaluates arithmetic in the usual Prolog interface.
Back to article page