Sie sind auf Seite 1von 3

TME 2073 Intelligent Systems Prolog Discussion Facts, Rules, Query 1.

1. a) Write the following using predicates bigger to represent it as facts in Prolog. A whale is bigger than a shark. A shark is bigger than a stingray. A stingray is bigger than a grouper. A grouper is bigger than a clownfish. b) Write a query and state the responds from Prolog to know the following: i) Is a stingray bigger than a grouper? ii) Is a clownfish larger than a whale? iii) Is a whale bigger than a clownfish? c) For question in b(iii), if the query answer is False, write one rules using predicates is_bigger to make the answer of the query to True 2. Given the following set of Prolog facts: job(ali, tutor). job(abu, lecturer). job(ahmad, tutor). job(ravi, head-of-department). job(shirley, tutor). job(christine, assistant-registrar). job(shapiee, deputy-dean). job(nara, dean). boss(head-of-department, tutor,). boss(head-of-department, lecturer,). boss(assistant-registrar, head-of-department,). boss(deputy-dean, assistant-registrar,). boss(dean, assistant-registrar). a) From the facts, write a query and state the responds from Prolog. i. A person whose job is a tutor. ii. A person whose job is a lecturer.

b) i. ii. iii. iv.

Find out what is the PROLOGs response to the following queries. ?- job(christine, X), boss(X, Y), job(Z,Y). ?-boss(lecturer, X) ; boss(dean, X). ?-boss(lecturer, X); boss(tutor, X). Add the following rules in the knowledge base and compare the answer in 2b(i) and 2b(iii). boss(X,Z) :- boss(X,Y), boss(Y,Z).

Note: In Prolog, operator AND(conjunction) is represented by a coma (,), while OR (disjunction) is represented by a semicolon(;). The :- symbol is to represent implication and is to represent negation. 3. Based on the Twilight family tree below,

Carlisle

Esme

Charlie

Renee

Emmet

Rosalie

Edward

Bella

Billy

Renesmee

a) Construct a Prolog facts using predicates male, female and parentof to represent the family tree in the knowledge base. b) Add the following rules in the knowledge base
father_of(X,Y) :- male(X), parent_of(X,Y). mother_of(X,Y) :- female(X), parent_of(X,Y). grandfather_of(X,Y) :- father_of(X,Z), parent(Z,Y). grandmother_of(X,Y) :- mother_of(X,Z), parent(Z,Y).

c) Based on the example in 3 (b), add rules for the followings: i. X is a sister of Y if X is female and Z is a parent of both X and Y. ii. X is a brother of Y if X is female and Z is a parent of both X and Y. iii. X is an aunt of Y if X is a female and Z is a parent of Y. iv. X is an uncle of Y if X is male and Z is a parent of both X and Y.

Das könnte Ihnen auch gefallen