You are on page 1of 5

Name of Course Instructor: Purnima Mulmi

Course Code: CC303n Course Name: Programming Models


Program Name: B.Sc. (Hons) Computing Semester: 9th
Assignment No: 3 Assignment Type: Individual
Batch: 5th

Submission date: 2nd Oct , 2020


Assignment Title : Lab 3
Name of the Student ID number Contact no. E-mail Signature
Nikesh Maharjan 1001849588 9813503419 niku.mhr.111@gmail.com

………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

Evaluators Signature and Comment


1. Which of the following pairs of terms unify? Where relevant, give the variable instantiations
that lead to successful unification.
1. bread = bread
-true
2. 'Bread' = bread
-false
4. bread = sausage
-false
5. food(bread) = bread
-false
6. food(bread) = X
-X=food(bread)
7. food(X)=food(bread)
-X=bread
8. food(bread, X) = food(Y, sausage)
- X = sausage,
Y = bread.
9. food(bread, X, beer) = food(Y, sausage, X)
-false
10. food(bread, X, beer) = food(Y, kahuna_burger)
-false
11. food(X) = X
- X = food(X).
12. meal(food(bread), drink(beer)) = meal(X,Y)
- X = food(bread),
Y = drink(beer).
13. meal(food(bread), X) = meal(X, drink(beer))
-false
2. Draw the family tree corresponding to the following Prolog program:

female(mary).
female(sandra).
female(juliet).
female(lisa).
male(peter).
male(paul).
male(dick).
male(bob).
male(harry).
parent(bob, lisa).
parent(bob, paul).
parent(bob, mary).
parent(juliet, lisa).
parent(juliet, paul).
parent(juliet, mary).
parent(peter, harry).
parent(lisa, harry).
parent(mary, dick).
parent(mary, sandra).
Juliet Bob

Paul Lisa Peter Marry

Harry Dick Sandra

Figure 1: Parent Tree

Define new predicates (in terms of rules using male/1, female/1 and parent/2) for the
following family relations:
(a) father
- father(F,X) :- parent(F,X), male(F).
(b) sister
- sister(S,X) :- sibling(S,X), female(S).
(c) grandmother
- grandmother(GM,X) :- parent(P,X), parent(GM,P), female(GM).
(d) cousin
- cousin(C,X) :- parent(P,X), sibling(P,OA), parent(OA,C).
Learning Outcome
 Understand the basic principles and techniques of logic programming and how these can be
applied in practice.
 Learn the idea of recursing down list.
 Describe the main concept of Logic Programming.
 Learn how make parent tree.

You might also like