Prolog - Artificial Intelligence - Past Exam, Exams of Artificial Intelligence

Main points of this exam paper are: N-Queens Problem, Generates, Four Queens, Intersection, Predicate, Intersect, Symbol System, Physical Symbol, System Hypothesis, Good Representational

Typology: Exams

2012/2013

Uploaded on 03/24/2013

bakula
bakula 🇮🇳

4.4

(5)

35 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Page 1 of 3
Bachelor of Science (Honours) in Computer Applications - Award
(Bachelor of Science in Computer Applications – Award)
(NFQ – Level 8)
Autumn 2005
Artificial Intelligence
(Time: 3 Hours)
Answer question any FOUR questions
(All questions carry equal marks).
Examiners: Mr. P. Rothwell
Mr. E. A. Parslow
Mr. P. O Connor
Dr. D. Chambers
1. (a) Using the following program and query as an example write a general
description of Prolog in terms of its syntax, list handling, and the use of
recursion. Include a brief description of the effect of this program.
prog( _, [] ,[]).
prog(L2, [ X | L1], [ X | L3 ]):- member(X, L2), prog(L2, L1, L3),!.
prog(L2,[ _ | L1], L3):- prog(L2, L1, L3),!.
?- prog([p, f, d, a, g, c], [ a, p, b, q, c, r], L). [10 marks]
(b) The following Prolog program can be used to solve the N-Queens problem:
%gen(X,Y,L) generates a list L of numbers from X to Y
nqs(N,S):- gen(1,N,Dxy), Nu1 is 1-N, Nu2 is N-1, gen(Nu1,Nu2,Du),
Nv2 is N+N, gen(2,Nv2,Dv), sol(S,Dxy,Dxy,Du,Dv).
Sol([],[],Dy,Du,Dv).
Sol([Y|Ylist],[X|Dx1],Dy,Du,Dv):-
del(Y,Dy,Dy1), U is X-Y, del(U,Du,Du1), V is X+Y,
del(V,Dv,Dv1), sol(Ylist,Dx1,Dy1,Du1,Dv1).
In your own words, explain how the above program would try to generate a
solution S for the four queens problem. Include an explanation of each line
(refer to line numbers) of the program in terms of the representation being
used. [10 marks]
(c) Write and fully explain a Prolog program to define the predicate
intersect(A, B, C) which assigns to the list C the intersection of the lists A and
B (you may use system defined predicates):.
E.g. ?- intersect([a,b,c], [d,e,b,c], L).
L=[b,c] [5 marks]
[Total: 25 marks]
pf3

Partial preview of the text

Download Prolog - Artificial Intelligence - Past Exam and more Exams Artificial Intelligence in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Science (Honours) in Computer Applications - Award

(Bachelor of Science in Computer Applications – Award)

(NFQ – Level 8)

Autumn 2005

Artificial Intelligence

(Time: 3 Hours)

Answer question any FOUR questions (All questions carry equal marks).

Examiners: Mr. P. Rothwell Mr. E. A. Parslow Mr. P. O Connor Dr. D. Chambers

  1. (a) Using the following program and query as an example write a general description of Prolog in terms of its syntax, list handling, and the use of recursion. Include a brief description of the effect of this program.

prog( _, [] ,[]). prog(L2, [ X | L1], [ X | L3 ]):- member(X, L2), prog(L2, L1, L3),!. prog(L2,[ _ | L1], L3):- prog(L2, L1, L3),!.

?- prog([p, f, d, a, g, c], [ a, p, b, q, c, r], L). [10 marks]

(b) The following Prolog program can be used to solve the N-Queens problem: %gen(X,Y,L) generates a list L of numbers from X to Y nqs(N,S):- gen(1,N,Dxy), Nu1 is 1-N, Nu2 is N-1, gen(Nu1,Nu2,Du), Nv2 is N+N, gen(2,Nv2,Dv), sol(S,Dxy,Dxy,Du,Dv).

Sol([],[],Dy,Du,Dv). Sol([Y|Ylist],[X|Dx1],Dy,Du,Dv):- del(Y,Dy,Dy1), U is X-Y, del(U,Du,Du1), V is X+Y, del(V,Dv,Dv1), sol(Ylist,Dx1,Dy1,Du1,Dv1). In your own words, explain how the above program would try to generate a solution S for the four queens problem. Include an explanation of each line (refer to line numbers) of the program in terms of the representation being used. [10 marks]

(c) Write and fully explain a Prolog program to define the predicate intersect(A, B, C) which assigns to the list C the intersection of the lists A and B (you may use system defined predicates):. E.g. ?- intersect([a,b,c], [d,e,b,c], L). L=[b,c] [5 marks] [Total: 25 marks]

  1. (a) Outline the physical symbol system hypothesis. [3 marks] List and explain the four important properties of a good representational formalism. [4 marks]

(b) Briefly discuss the following statement with particular reference to the underlined phrases: “Expert systems are knowledge-based programs that provide expert-quality solutions in narrow, well-defined domains.”[6 marks]

(c) With the aid of an example, give a full description of the details of a production rule-based system. Your description should cover: rules, working memory, rule interpreter, conflict resolution, and control of reasoning. [12 marks] [Total: 25 marks]

  1. (a) Define and explain a full state-space representation of the states and operators that you would use in attempting to solve the following “Farmer, Wolf, Goat, and Cabbage” problem. [10 marks]

A Farmer has a wolf, a goat and a cabbage on the left bank of a river. He has one boat. He must row the boat. Only the farmer and one of his possessions can occupy the boat at a time. Also he cannot leave the following pairs alone together: goat and cabbage, wolf and goat. Determine a sequence of moves that will get the farmer and all of his possessions onto the right bank safely.

(b) Based on the representation in part (a) above, outline the essentials of a Prolog program that would solve the problem. [8 marks]

(c) Explain the operation of your program in part (b) above. [7 marks]