Docsity

Artificial Intelligence - Assignment 5 Practice | CAP 4621, Assignments of Computer Science

Toggle sidebar
bg1
Homework 5 โ€“ CAP4621 FALL 2003
Due on Wednesday, October 8
All problems in this homework are programming problems. Please return
actual listings. Provide explanations as comments in your programs.
1. Family Database
Assume the following family database:
%father(?Father,?Child)
father(tearch,abraham).
father(tearch,nachor).
father(tearch,haran).
father(abraham,isaac).
father(haran,lot).
father(haran,milcah).
father(haran,yiscah).
%mother(?Mother,?Child)
mother(sarah,isaac).
male(tearch).
male(abraham).
male(nachor).
male(haran).
male(isaac).
male(lot).
female(sarah).
female(milcah).
1
pf3
pf4

Partial preview of the text

Download Artificial Intelligence - Assignment 5 Practice | CAP 4621 and more Assignments Computer Science in PDF only on Docsity!

Homework 5 โ€“ CAP4621 FALL 2003

Due on Wednesday, October 8

All problems in this homework are programming problems. Please return actual listings. Provide explanations as comments in your programs.

  1. Family Database Assume the following family database:

%father(?Father,?Child) father(tearch,abraham). father(tearch,nachor). father(tearch,haran). father(abraham,isaac). father(haran,lot). father(haran,milcah). father(haran,yiscah).

%mother(?Mother,?Child) mother(sarah,isaac).

male(tearch). male(abraham). male(nachor). male(haran). male(isaac). male(lot).

female(sarah). female(milcah).

female(yiscah)

Specify the following Prolog predicates:

% is_mother(X) X is a mother % son(X,Y) X is the son of Y % sister(X,Y) X is the sister of Y % grandfather(X,Y) X is the grandfather of Y % ancestor(X,Y) X is the ancestor of Y

Show all results of posing the goals:

?- is_mother(X). ?- son(X,X). ?- ancestor(X,isaac).

for your implementation. Explain the meaning of the results obtained with these goals.

  1. List Manipulations

Write Prolog predicates for the following list operations:

(a) deleting and element from a list: delete(X,L,R)(delete all in- stances of element X from the list L and put the result into list R). Show all results of posing the goal

?- delete(X,[a,b,c],R).

for your implementation. (b) length of a list: length(List,Length). ( Hint: To compute the length of a list you have to use the is operator. For example A is B+1 will first add 1 to the numerical value of B and then assign it to A if it is unbound or compare it with value of A if bound. ) (c) smallest element of a list: smallestElem(X,List)

Each character corresponds to a digit. The same digit may not be assigned to two different characters. Show the goal posed to solve the puzzle with your implementation and the result obtained.

Bonus problems are intended to be fairly complicated and tricky. Obtain- ing a good solution might require a significant effort, thus first make sure you solve the regular homework problems before tackling the bonus problems. The following rules apply to the bonus problems:

  • Each point for a bonus problem is worth 1% of the final grade.
  • You are not allowed to talk with anyone about the bonus problems or to consult any resource other than the textbook unless explicitly given permission. Failure to adhere to this rule will result in the cancellation of all bonus points for the entire class.
  • No assistance will be provided during or outside office hours for bonus problems.
  • Unless otherwise stated, the solution must be returned together with the the homework, on a separate piece of paper. The instructor will grade the bonus problems.
  • No partial credit will be awarded. For a solution to be considered correct, thus for points to be awarded, the solution must be near perfect (without any significant flaws) and must be carefully written.
  • No extension under any circumstances will be given for bonus problems.