Logic Programming Skills Quiz Form
Logic Programming Skills Quiz Form
Which of the following is a fact in Prolog?
*
parent(john, mary).
?- parent(john, mary).
parent(X, Y) :- mother(X, Y).
:- dynamic parent/2.
What does the following Prolog query return? ?- member(X, [a, b, c]).
*
X = a ; X = b ; X = c
true
false
X = [a, b, c]
In logic programming, what is unification?
*
A process of making two terms identical
A way to declare variables
A method for sorting lists
A type of recursion
Which of the following is a recursive rule in Prolog?
*
ancestor(X, Y) :- parent(X, Y).
ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
parent(john, mary).
male(john).
What is the result of the following query? ?- append([1,2], [3,4], X).
*
X = [1,2,3,4]
X = [1,2],[3,4]
X = [3,4,1,2]
X = [[1,2],[3,4]]
Fill in the blank: In Prolog, a ______ is a statement that is always true.
*
Write a simple Prolog rule that defines 'grandparent' in terms of 'parent'.
*
Which predicate is used to check if an element is a member of a list in Prolog?
*
Given the rule: even(0). even(X) :- X > 0, Y is X-2, even(Y). What will the query ?- even(4). return?
*
true
false
error
undefined
Explain the difference between a fact and a rule in logic programming.
*
Submit Quiz
Should be Empty: