Prolog Flashcards

QUIZ (64 cards)

1
Q

In Prolog, who developed the language in the early 1970s based upon the work of Robert Kowalski?

A

Alain Colmerauer.

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

The name ‘Prolog’ is an abbreviation for this French phrase.

A

PROgrammation en LOGique.

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

The first interpreter, implemented in ALGOL-W by Philippe Roussel, is retrospectively known by this name.

A

Prolog 0.

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

The initial motivation for Prolog was not general-purpose computing but the processing of natural language.
True or False

A

True

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

In 1965, J.A. Robinson introduced this complete method for proving theorems in first-order logic, which became a theoretical foundation for Prolog.

A

The Resolution Principle.

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

Alain Colmerauer insisted on a language that could handle infinite trees and symbolic manipulation.
True or False

A

True

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

In Prolog, Horn Clauses are restricted logical formulas of the form

A

A <- B1, B2, … Bn.

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

Who implemented the first Prolog interpreter and contributed to the decision to use depth-first search with backtracking?

A

Philippe Roussel.

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

This specific implementation of Prolog is the latest stable release that uses an open-source platform and introduces native GUI tools based on SDL3 and Cairo.

A

SWI-Prolog version 10.0.

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

Definite Clause Grammars (DCGs) were formally standardized in ISO/IEC TS 13211-3:2025 for what specific application?

A

Natural language processing.

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

Prolog II marked a theoretical expansion by replacing standard unification with equation solving over these structures.

A

Trees (specifically, infinite or rational trees).

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

This implementation of Prolog was the first compiler to generate machine code and established the standard “Edinburgh Syntax”.

A

DEC-10 Prolog.

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

SWI-Prolog maps Prolog threads to native Operating System threads, allowing it to utilize modern multi-core CPUs efficiently. True or False

A

True

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

Prolog relies on this primary mechanism for data manipulation, which attempts to make two terms identical rather than just setting a value.

A

Unification

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

Prolog is primarily classified as an imperative programming language because it executes instructions sequentially.
True or False

A

False

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

In Prolog, data is represented and handled through structures called terms.
True or False

A

True

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

This type of constant in Prolog represents specific objects or concepts, is immutable, and starts with a lowercase letter.

A

Atom

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

Prolog variables do not require explicit declaration or type definition before use. True or False

A

True

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

Create a statement in Prolog defining a fact that ‘jude’ is a ‘student’.

A

student(jude).

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

This built-in data type is built out of a functor followed by a sequence of arguments placed in ordinary brackets.

A

Complex terms (or structures).

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

Arrays are natively supported as a primitive data structure in Prolog.
True or False

A

False

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

Prolog possesses explicit type definitions such as typedef found in imperative languages like C or Java.
True or False

A

False

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

In Prolog, lists are represented as an ordered sequence of elements that are either empty [] or a structure composed of these two parts.

A

Head and Tail ([Head | Tail]).

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

Strings in SWI-Prolog are distinct text objects enclosed in double quotes and are not interned.
True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
What is the output of the following program snippet in Prolog? ?- [Head | Tail] = [jude, jona, ace, ecie].
Head = jude, Tail = [jona, ace, ecie]
25
What is the output of the following program snippet in Prolog? get_array_item(Index, Array, Value) :- arg(Index, Array, Value). ?- Arr = array(10, 20, 30), get_array_item(2, Arr, Val).
Val = 20.
26
Create a statement in Prolog that defines a rule valid_year(Y) ensuring Y is an integer greater than or equal to 1.
valid_year(Y) :- integer(Y), Y >= 1.
27
This operator in Prolog is used for term unification.
=
28
What symbol is used in Prolog to initiate a single-line comment?
%
29
Prolog is a free-format language, meaning the compiler ignores whitespace, indentation, and line breaks. True or False
True
30
This punctuation mark terminates clauses and queries in Prolog.
Period (.)
31
In Prolog, the semicolon (;) represents conjunction (logical AND). True or False
False (The semicolon represents disjunction/logical OR; the comma represents conjunction).
32
This symbol serves as the anonymous variable in Prolog.
Underscore (_)
33
Create a statement in Prolog using the turnstile operator to define a rule where grandfather(X, Z) depends on father(X, Y) and parent(Y, Z).
grandfather(X, Z) :- father(X, Y), parent(Y, Z).
34
The assignment operator (=) in Prolog overwrites the memory location of a variable. True or False
False
35
What is the output of the following program snippet in Prolog? demo_no_reassignment :- X = 5, X = 6. ?- demo_no_reassignment.
False
36
What is the output of the following program snippet in Prolog? ?- X is 2 + 3 * 4.
X = 14.
37
In Prolog, predicates serve the role of subprograms or functions from imperative languages. True or False
True
38
Variables in Prolog have global scope across the entire program by default. True or False
False (Variables are strictly local to the clause they appear in).
39
Create a statement in Prolog that declares a predicate named score with arity 1 as dynamic so it can be modified at runtime.
:- dynamic score/1.
40
In Prolog, arithmetic structures like 3 + 2 are automatically evaluated without needing specific predicates. True or False
False (They are treated as complex terms and only compute when passed to specific predicates like is/2)
41
Prolog uses goal evaluation where predicates either succeed (true) or fail (false), rather than traditional boolean expressions. True or False
True
42
This punctuation sequence represents Negation as Failure in Prolog.
\+
43
Prolog execution is driven by this type of search through the knowledge base.
Depth-first search
44
Prolog supports traditional loops like 'for' and 'while' for iteration. True or False
False (Iteration is achieved through recursion).
45
This control mechanism is used to force backtracking in Prolog execution.
fail/0 (or fail).
46
What is the output of the following program snippet in Prolog? factorial(0, 1). factorial(N, F) :- N > 0, N1 is N - 1, factorial(N1, F1), F is N * F1. ?- factorial(3, A).
A = 6.
47
What is the output of the following program snippet in Prolog? ?- Goal = writeln('Hello'), call(Goal).
Hello.
48
Create a statement in Prolog that uses the once/1 predicate to limit the results of user(Name, admin) to the first success.
?- once(user(Name, admin)).
49
SWI-Prolog natively supports coroutine-like behavior through delayed goals using predicates like when/2 or freeze/2. True or False
True
50
- He is widely recognized as the creator of Prolog and drove its practical implementation for natural language processing.
Alain Colmerauer
51
- What are the three basic constructs used to build programs in Prolog?
facts, rules, and queries.
52
- This specific symbol must be used at the end of every Prolog statement to terminate a clause or query.
( . ) (Period)
53
- It is the combination of an atom and its arity used to name compound terms.
Functor
54
- Prolog is classified as an imperative programming language because the programmer specifies exactly how to compute a result. True or False
False (It is a Declarative Logic Programming language)
55
- Variables in Prolog must always begin with an uppercase letter or an underscore (_). True or False
True
56
- Prolog uses traditional for and while loops to perform repetitive tasks. True or False
False (Iteration is achieved through recursion)
57
- The "Cut" operator, which is used to prevent backtracking, is represented by the exclamation mark symbol (!). True or False
True
58
- The standard file extension for Prolog source files is typically .pl or .pro. True or False
True
59
- Given the query, what is the value of Tail? ?- [Head | Tail] = [jude, jona, kaye].
Tail = [jona, kaye]
60
- Given the facts and rules, what query can invoke the output? dog(ringgo). dog(georgia). owns(kaye, Pet):- dog(Pet). loves(Who, What):- owns(Who, What).
-? loves(Who, What) Who = kaye, What = ringgo ; Who = kaye, What = georgia
61
- Given the facts, what is the result of the query? friend(ace, mark). friend(mark, jude). ?- friend(ace, X), friend(X, jude).
X = mark
62
Given the facts and rules, what is the result of the query? is_compsci(ace). is_compsci(ecie). is_nursing(alecs). is_business(sophia). not_compsci(X) :- \+ is_compsci(X). ?- not_compsci(sophia).
true.
63
If a rule is defined as follows, what is the result of the query? double(X, Y) :- Y is X * 2 ?- double(10, Result).
Result = 20