0% found this document useful (0 votes)
144 views

Oct, 2020: Lab 3

The document contains details of an assignment submission such as the course code, instructor name, student name and ID, assignment number and title, and signature. It also lists 13 logic programming problems related to unification and constructing a family tree from parent relationships that must be solved. The problems define new predicates for relations like father, sister, grandmother and cousin in terms of the given male, female and parent predicates.

Uploaded by

alalelel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views

Oct, 2020: Lab 3

The document contains details of an assignment submission such as the course code, instructor name, student name and ID, assignment number and title, and signature. It also lists 13 logic programming problems related to unification and constructing a family tree from parent relationships that must be solved. The problems define new predicates for relations like father, sister, grandmother and cousin in terms of the given male, female and parent predicates.

Uploaded by

alalelel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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 [email protected]

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

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