Ch 5 Flashcards

1
Q

Which of the following programming languages most closely follows the stored program concept?

A

C

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

Prolog is based on…

A

Predicate logic

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

There are three kinds of clauses in a Prolog program: facts, rules and goals.

A

A fact can be considered a special case of a rule.

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

What mechanism cannot be used for passing values between clauses within a Prolog rule?

A

Return value

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

If you want to pass multiple values out of a Prolog rule, which of the following methods is valid?

A

Use multiple named variables to hold the values.

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

A goal clause and a fact unify, if…

A

their predicates are the same,
their arities are the same,
and
their corresponding arguments match.

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

The arity of a predicate is…

A

the number of arguments of the predicate.

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

The scope of a Prolog variable is within…

A

a single rule.

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

A circular definition of a Prolog rule…

A

will cause a dead loop when no match can be found.

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

An anonymous variable in Prolog is a…

A

placeholder.

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

What is the output when the following Prolog goal is executed?
?-member(apple, [orange, apple, pearl]).

A

true?

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

Assume we have the following fact in a Prolog factbase:
child_of(mary, [amy, david, conrad]).

What is the output when the following Prolog goal is executed?
?- child_of(mary, [amy | T]).

A

T = [david, conrad]

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

Assume that we have the following fact in a Prolog factbase:
child_of(mary, [amy, david, conrad]).

What is the output when the following goal is executed?
?- child_of(mary, [amy | [H | [conrad]]]).

A

H = david

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

What is the output when the following Prolog goal is executed?
?- member(X, [81, 25, 9, 29,]), Y is X*X, Y<400.

A

X = 9 Y = 81

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

Given the following recursive rules in Prolog:
foo(X, [X]).
foo(X, [ _ | T]) :- foo(X, T).

The rules find…

A

whether an element is a member of a list.

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

When Prolog is searching for possible matches and a cut “!” is encountered,

A

all existing backtrack points will be removed.

17
Q

What does the built-in predicate cut (!) do?

A

Remove all existing backtracking points.

18
Q

What does the built-in predicate fail do?

A

Return false.

19
Q

The built-in Prolog predicate repeat always…

A

succeeds and adds a backtracking point.

20
Q

What does the following code do?
go :- repeat, get(X), write(X), nl, fail.

A

It takes a character from the keyboard, prints it, and exits if the character is NOT printable.

21
Q

What is the key difference between the semantic web and the syntactic web?

A

Semantic web better supports automatic processing and integration of web information.

22
Q

How is Prolog related to the semantic web?

A

Prolog is frequently used for writing the parsers of the semantic description language.