WorksheetsCSC305: TOPIC 4
Total questions: 15
Worksheet time: 6mins
Logic programming is also known as declarative programming.
True
False
Ruby is one of the major programming languages for logic programming.
False
True
A Horn Clause has a head and a body.
True
False
Resolution happens when the system fails to prove a sub-goal or sub-query.
False
True
A term in Prolog can exist in THREE (3) forms:
constant
data type
structure
query
variable
Choose a statement that is FALSE about Prolog.
A Prolog term is an atom, a variable, a numeric value or a structure.
A variable is any string of letters, digits and underscores that begins with a lowercase letter.
Atoms are symbolic values of Prolog.
Structures represent the composite value of Prolog.
Given the following Prolog statements, identify the control structure used.
calcDistance(D1, D2, Distance):-
( D1 > D2, Distance is D1-D2, !;
D2 > D1, Distance is D2 - D1, !;
Distance is 0).
Multiple-selection statements
One-way selection statements
Three-way statements
Two-way selection statements
The Prolog query given below is an example of a(n) _____ query.
?- append([1,2],[b,c],Z).
anonymous
goal
simple
variable
Analyze the following Prolog facts about totalfees for a day care center for kids.
totalfees(15, halfday, 200).
totalfees(15, fullday, 350).
totalfees(20, halfday, 250).
totalfees(20, fullday, 400).
What will be the output if you run the following query?
?- totalfees(Day, halfday, Total), Day > 15.
Day = 15, Total 200.
Day = 15, Total = 350.
Day = 20, Total = 250.
Day = 20, Total = 400.
Based on the given database in Prolog, which of the following queries will yield TRUE?
parent(tiffany, lisa).
parent(tiffany, lily).
parent(brian, lisa).
parent(brian, lily).
sibling(X,Y) :- parent(Z, X), parent(Z, Y).
?- parent(tiffany, brian).
?- sibling(lisa, lily).
?- sibling(tiffany, lisa).
?- sister(lisa, lily).
Based on the given rules and facts in Prolog, which of the following queries will yields FALSE only as answer?
score(ali, 90).
score(amy, 75).
score(abu, 45).
score(ali, _).
score(_, 60).
score(abu,X).
score(A,B).
In logic programming languages, the basic form of statement can be constructed as follows EXCEPT _____.
fact statements
declaration statements
rule statements
goal statements
Discover the correct meaning of the following Prolog rule.
sibling (X, Y) : -
mother(M,X) ,mother(M,Y) ,father(F,X) ,father(F,Y) ,not(X=Y).
X and Y are different people
M is a mother of Y
F is not a father of Y
Fis a father of X
Examine the Prolog expressions below that is/are syntactically true.
father(azmi,ali).
parent (wati, qaisara) :- mother(wati,qaisara).
?- sibling(X,amir).
define parent :- parent (X, Y) .
Based on the given fact below:
p ( [X1x2] ,X1,X2) .
What will be the output for this query?
?- p( [ [ orange,mango] ,banana,watermelon,kiwi] ,H,T) .
X1 = orange,
X2 = [mango, banana, watermelon, kiwi]
X1 =[orange,mango],
X2 = [banana, watermelon, kiwi]
H =[orange, mango] ,
T = [banana, watermelon, kiwi]
H = orange,mango,
T = banana, watermelon, kiwi
