Alexandria University
Faculty of Business-ISC Department
Intelligent DSS
Questions on Prolog
1. Represent the following in Prolog:
1. Marcellus kills everyone who gives Mia a footmassage.
kills(marcellus, X) :- givesFootMassage(X, mia).
2. Butch is a killer.
killer(butch).
3. Mia and Marcellus are married.
married(mia, marcellus).
4. Lily loves anything that is a fruit or vegetable.
loves (lily, X) :- fruit(X); vegetable(X).
5. Lily mother of john .
mother(lily,john).
2. How does Prolog respond to the following queries?
A)
cat(fubby).
black_spots(fubby).
dog(figaro).
white_spots(figaro).
owns(mary, Pet):- cat(Pet), black_spots(Pet).
loves(Who, What):-owns(Who, What).
?- cat(figaro).
False
?- loves(Who, What).
Who = mary, What = fubby
?- owns(mary, _).
True
B)
owns(mary,pet(cat(fubby))).
?- owns(X,_).
X= mary.
?- owns(mary,Z).
Z= pet(cat(fubby)).
3. Which of the following sequences of characters are Constant, which are
variables, and which are Structure?
fOOD Constant
Orangejuice variable
variable23 Constant
orange_juice Constant
'Delicious' Constant
_food variable
owns(X,pet(cat(fubby))). Structure
'_food' Constant
'big orange juice ' Constant
study(alex,python(programming_cource,code123)). Structure
4. MCQ
1. In Prolog, knowledge is represented using:
a) Variables
b) Loops
c) Facts and rules
d) Functions
Answer: C
2. Which one of the following is not a variable?
A) X_yz
B) g_23A
C) !_Xyz
D) B & C both.
Answer: D
3. ?- Y is 3+2*4-1. This sentence result,
a) Y= 19
b) Y= 10
c) Y is 3+2*4-1
d) Non of the above
Answer: B
4. ?- X = 3+2*4-1. This sentence result,
a) X= 19
b) X= 10
c) X = 3+2*4-1
d) Non of the above
Answer: C
5. Which one from the options would return true/yes for given prolog program?
boy(john,123).
girl(jane,234).
student(john,123).
A) ? - girl(jane,X).
B) ?- boy('john',123).
C) All of above.
D) None of above.
Answer: B
6. likes (joe, fish).
likes (joe, mary).
likes (mary, fish).
likes (albert, joe).
? - likes (Who, fish).
A) Who = joe.
B) Who = mary.
C) Who = albert.
D) Who = joe. ; Who = mary.
Answer: D
** For questions from 5 to 8
bigger (elephant, horse).
bigger (horse, monkey).
bigger (horse, donkey).
bigger (donkey, dog).
bigger (donkey, monkey).
7. ? - bigger (donkey, Animal).
A) Animal = horse
B) Animal = monkey
C) Animal = donkey
D) Animal = dog; Animal = monkey
Answer: D
8. bigger (horse, X), bigger (donkey, X).
A) X = horse
B) X = monkey
C) X = donkey
D) X = dog
Answer: B
9. ? - bigger (horse, _).
A) monkey
B) donkey
C) True
D) False
Answer: C
10. ? - is_bigger(X, dog) = is_bigger(elephant, dog).
A) X= elephant
B) X= monkey
C) X= donkey
D) False
Answer: A
11. In Prolog, which symbol is used to represent the end of a query?
a) !
b) .
c) :
d) ?
Answer: B
12. love(jin, mary). and (mary, jin).
a) Same direction
b) Different direction
c) Same meaning
d) Different meaning
e) Bothe B and D
Answer: E
13. owns(X,pet(cat(fubby))). The owns relation has :
a) 1 object
b) 2 objects
c) 3 objects
d) 4 objects
Answer: B