Documente Academic
Documente Profesional
Documente Cultură
j ') (\
University of Jordan
ComputerJU.com
Question 1 [5 Points]
Express in First Order Predicate Calculus (FOPC) each of the following sentences
. P3 --:} P2. Q) ~
,P2. Q) ~l
We can infer Pl .
Is this conclu sion valid? Answer with Y for Yes or N for No ye s
Explain: Why: b U ' ~ VS t o> ,2.. t-(\( us -I- V1C \ f-- ., ~ ) /
Ci AcJ 'r p ) h:>l"f5 u ~ ~- "' 0\ l- . 't (r 9\ z: \~ \/
o r V:; i .'\.") ~. ~ s ~ {)r
2. what is the answer to each of the following queries
(a) ?- X = := 3+5.
D (
( {)\ :, 't V
I)
/
U II
ev
(be
cy
; ",ch . \'~ '1'0, ?-el )
( l)(\ix) (M(x)VP (X) ~S(x) 1 ( (V\ (x) V f Cf ») V ) eX) =) ~;v' (x) ;,, -t Pex( V5 (;
(2) ("1 x)(K(x) ~ L(x)) . ' t< l X) V ~ t» )
r
/
/ /
/ I
X ) 17~X )( LU))
./
\\
ComputerJU.com
Question 4 [6 Points]
What is the value of each of the Zi's in each of the following Prolog Clauses?
1. b([] ,l]).
b([XIY], [X1IL1J) :- X mod 3 =:= 2, Xl is X-1,b(Y, L1) .
b([XIY] , L1):- b(Y, L1) .
b([XIY] , L1) :- X mod 2 =:= 1, b(Y , L1).
Zl=
. I) I '-.J ( R. I \.1
'"
'tv!
\/
I
/'
---r
/
R.
2. d(X , N, [], [D.
d(X , 0, L, L).
d(X, 1, [YIZ]' Z).
d(X,N,[XIL],L1) :- N1 is N-2, d(X, N1, L,L1).
d(X,N,[Y IL]'[YIL2J) :- N2 is N-1 , d(X , N2, L,L2).
?- d(l0,10 , [5,10 ,11 ,10 ,64 ,10 ,102 ,10 ,103], Z2) . <; / U
cA
Z2= - - - -' 7 - - -
?- f{-81, ([6,42, 18
Z3= [ 60
ComputerJU.com
Question 5 [8 Points]
Write in prolog the following clauses.
I, split(L, L I, L2) that take s a list L and returns two lists LI and L2 where L I contains
the numbers of L, which are divisible by 3 and L2 contain s the numbers of L, which are
Example:
?split([11 ,12,13,14,24,26,49,18,69,lll], ZI ,Z2) yields
Z2 = [14,49]
i'
2. del(A,K ,L, L I) where L I is the same as L except that the x" occurrence of A in L is
deleted.
Example:
?del(5,2,[11,5, 10,5,20,5,30,40], V) returns -CJ
h[;\5;O;2t;~~'\:~iLl . / (y
J-:-b~ I ~
~C)\fi=rr
d{ ( (P ( V\ / [~ \ L J t \): I
~ ~
K\ ~.; \{ - \ j