Prolog Flashcards

1
Q

In Prolog, the most natural way to express the fact that a lion is a cat is ANSWER.

A

cat(lion)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In Prolog, the most natural way to express the query “what animals are cats?” is ANSWER.

A

animal(What), cat(What)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In Prolog, the most natural way to express the rule that “I am an ancestor of you if I am a parent of you” is ANSWER.

A

ancestor(I, You) :- parent(I, You)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In Prolog, the most natural way to express the rule that “I am an ancestor of you if I am a parent of an ancestor of you” is ANSWER.

A

ancestor(I, You) :- parent(I, Ancestor), ancestor(Ancestor, You)

(Both lines are one answer)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In Prolog, the expression hi(X, 4) = hi(3, Y) causes X to have the value ANSWER.

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In Prolog, the expression hi(X, 4) = hi(3, Y) causes Y to have the value ANSWER.

A

4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In Prolog, the expression hi(X, 4) = hi(3, X) causes X to have the value ANSWER

A

X will not be bound

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In Prolog, the expression [1, 2, 3] = [X | Y] causes X to have the value ANSWER.

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In Prolog, the expression [1, 2, 3] = [X | Y] causes Y to have the value ANSWER.

A

[2, 3]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In Prolog, the expression X = [[1,2] | [3,4]] causes X to have the value ANSWER.

A

[[1, 2], 3, 4]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In Prolog, the expression X = 1 + 2 causes X to have the value ANSWER.

A

1+2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In Prolog, the expression 2 = 1 + X causes X to have the value ANSWER.

A

X remains unbound

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In Prolog, the expression that would cause an unbound variable X to take on the sum of the values of a bound variable Y and a bound variable Z is ANSWER.

A

X is Y + Z

How well did you know this?
1
Not at all
2
3
4
5
Perfectly