?- lectures(john, Subject), studies(Student, Subject).
there are two goals,
A goal is something that Prolog tries to satisfy by finding
values of the variables (in this case
Subject) that make the goal succeed.
These value(s) are then said to be bound to
If Prolog is unable to do this, the goal fails (and Prolog
will print "false" in response to the query).
If all the goals in a query succeed, Prolog prints the bindings
necessary to make the query succeed. (If you then, in SWI Prolog,
type a semicolon (
;) Prolog will
backtrack and look for another set of bindings that will
satisfy the goals in the query.
Sometimes it is not necessary to bind variables in order
to satisfy a goal. For example, there is no variable to
bind, when the goal is
likes(mary, pizza) and the Prolog database
In this case, Prolog will print "true"
in response to the query, rather than printing bindings.
Goals occur in rules as well as in queries. In
happy(Dog) :- is_dog(Dog), go_for_walk(Dog).
go_for_walk(Dog)are the two goals that form the body of the rule.