Sie sind auf Seite 1von 7

Lecture1:introduction

Q1#What are the main differences between the procedural programming languages
and the descriptive programming language (with examples).

Q2# There are many uses for Prolog programming language, what are they?

Q3# There are only three basic elements in Prolog program, describe them with
examples.

Q4# Fill the following blanks with suitable words:


 In prolog the collection of facts is called---------.
 Variable name must begin with ---------
 comma in prolog means ------- while semicolon(;) means -------- .
 Prolog stand for---------.

Lecture2: facts, rules and queries.

Q5# Convert the following sentences to its corresponding facts or rules in Prolog:

 John is the father of Mary.


 Person1 is the grandparent of Person2 if Person3 is the parent of Person2
and Person1 is the parent of Person3.
 John owns gold
 A person may steal something if the person is a thief and he likes the
thing and the thing is valuable.
 Gold is valuable
 Person1 is a parent of Person2 if Person1 is the father of Person2 or
Person1 is the mother of Person2.

Q6# Prolog program structure consists of five segments, describe them.

Q7# Prolog language supports several data type to define program entries, what are
they? Describe with example.
Q8# What is the output for the following program?

predicates
f(string,string)
gf(string,string)
clauses
f("ali","zaki").
f("mohamed","ali").
f("ali","ahmed").
f("zaki","suha").
gf(X,Y):- f(X,Z), f(Z,Y).
goal
gf(X,Y).

Q9# Find the output for each of the following goals:

 degree(ali,X).
 degree(X,Y).
 degree(_,Y).
 degree(_,_).
 degree(X,Y), Y>=50.
 degree(Ahmed,X).
 degree(suha,X).
If you have the following facts:

degree(suha,40).
degree(ali,50).
degree(ahmed,30).
degree(suha,55).

lecture3: reading and writing


Q10# write a Prolog program that can repeat reading and printing characters until
the input character is equal to ‘#’.
Q11# What are the standard read predicates that found in prolog.

Q12# Write prolog program to read an integer number and test it, if the number>65
then return its corresponding character, otherwise print the number itself.

Lecture4: Backtracking, cut and fail

Q13# Describe backtracking concept using the following example:


Predicates

start(integer,integer)

a(integer)

b(integer)

clauses

a(10).

a(20).

b(30).

b(20).

b(40).

start(X,Y):-a(X),b(Y), X<=10,Y>=30.

goal

start(X,Y).
Q14# compare between cut and fail using examples

Q15# What is the output of the following programs:


Domains

i =integer
s = symbol

Predicates

a(i )

b (s )

c (i, s )

Clauses

a(10).

a(20).

a(30).

b(a).

b(c):-!.

b(d).

c (X, Y):- a (X), !,b (Y).

Goal

c(X,Y).

lecture5: recursion

Q16#Convert the following prolog program from tail recursion to non-tail recursion.

Domains
I= integer
L=I*
Predicates
sum (L,I, I)
Clauses
sum ([],S,S):-!.
sum([H|T],X,S):- X1 = X+H , sum (T,X1,S).
Goal
sum ([ 1,4,6,9],0 ,S).
Q17# Write a prolog program that can find the multiplication of odd numbers from
1 to 5 using non tail recaursion. (with tracing)
Q18# Write a prolog program that can find the summation of odd numbers in a
given list using tail recursion. (with tracing)
Q19# Show the difference between tail and non-tail recursion (using an example).
Q20# What is the output to the following prolog program?
Domains
I=integer*
predicates
check(l).
clauses
check([]).
check ([H|T]):- check (T),write(H),nl.
goal
check([1,2,3,4]).

Lecture6: list
Q21# Write a prolog program to split a list into an even list and an odd list.

Q22#write a prolog program that repeat reading integer numbers and putting them in a
list until the input number is equal to zero.

Q23#Write a prolog program that can delete an element from a list, such as if your goal is
del(5,[1,3,5,4,5],L), then the output will be L=[1,3,4].

Q24#Make a trace for the following program:


domains
ilist=integer*
predicates
list(ilist,integer)
clauses
list([H],H).
list([H1,H2|T],M):-H1<H2,!,list([H1|T],M).
list([_|T,M):-list(T,M).
Goal
list([5,3,9,8],M).

Q25#Find the average of the even numbers in a given list using non tail recursion.

Lecture7: standard string predicates


Q26#Write a prolog program that take a string as upper case then return the integer
value of each character in lower case such as: sen(“ABCD”), Output: 97 98
99 100.
Q27#Write a prolog program that prints each name in a specific sentence with its
length in a line.

Q28#Suppose you have the following sentence “work hard in silent and let your
success make the noise”, write a prolog program to convert this sentence to a
list of words.

Q29# Describe with examples five standard string predicates found in prolog.

Lecture8: introduction to AI
Q30#Answer the following:
 What are the main goals of AI research?
 Give two different definitions for AI?
 What are the main AI applications?
 What do we mean by intelligence?
 What are the main fundamental issues of AI?
 What are knowledge representation schemes?

Das könnte Ihnen auch gefallen