_
is called the anonymous
variable. Multiple occurrences of _
in a single term
are not shared.myterm(A1, a2)
.:-
).:-
)
or it is a
fact. For example:
parent(X) :- father(X, _).
Expressed as “X is a parent if X is a father of someone''. See also variable and predicate.
john
is
a person.
person(john).
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
.:-
). This is an atom
or compound
term.:-
)
separating head
from body in a clause.
In Prolog, the expression a+b
is exactly the same as the
canonical term +(a,b)
.
a+b*c
as +(a, *(b,c))
.?- A = B, A = a. A = B, B = a.
_
(see anonymous).
Rules for naming a variable and avoiding a warning are given in section
2.16.1.10.?- foo(a, B) = foo(A, b). A = a, B = b.
Unlike assignment (which does not exist in Prolog), unification is not directed.
?- A = b, A = c. false. ?- (A = b; true; A = c). A = b ; true ; A = c .
See also unify.