Page 205 - DCAP506_ARTIFICIAL_INTELLIGENCE
P. 205
Unit 14: Prolog
parentof(Z,X), Notes
parentof(Z,Y),
X Y.
The relation brotherof is alike but adds the condition that X must be a male.
brotherof(X,Y) :-
parentof(Z,X),
male(X),
parentof(Z,Y),
X Y.
Self Assessment
Fill in the blanks:
3. In ProLog, ......................... describe the relationships between different objects and are
independent of each other.
4. In ProLog, ......................... are used in the process of decision-making and can deduce new
facts from existing ones.
14.3 Goals
Proposing a query means demanding Prolog to attempt to prove that the statement(s) implied
by the query can be prepared true given the right variable instantiations are prepared. The
search for such a proof is generally pointed to as goal execution. Every predicate in the query
comprises a (sub)goal, which Prolog attempts to please one after the other. If variables are
shared among numerous subgoals their instantiations have to be similar throughout the whole
expression.
If a goal goes with the head of a rule, the particular variable instantiations are made within the
rule’s body, which then turns out to be the new goal to be satisfied. If the body includes numerous
predicates the goal is again split into subgoals to be executed in turn.
Alternatively, the head of a rule is measured provably true, if the conjunction of all its body
predicates are provably true. If a goal goes with a fact in our program the proof for that goal is
absolute and the variable instantiations made throughout matching are conversed back to the
surface.
Notes The order in which facts and rules emerge in our program is significant here.
Prolog will for all time attempt to match its existing goal with the first possible fact or
rule-head it can find.
If the principal function of a goal is an incorporated predicate the connected action is executed
whilst the goal is being satisfied.
Example: As far as goal execution is regarded the predicate write (‘Hello World!’) will
just succeed, but simultaneously it will also print the words Hello World! on the screen.
LOVELY PROFESSIONAL UNIVERSITY 199