_
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 ``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
.:-
)
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 = a, B = a
_
(see anonymous).
Rules for naming a variable and avoiding a warning are given in section
2.15.1.5.?- 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. No ?- (A = b; true; A = c). A = b ; A = _G283 ; A = c ; No
See also unify.