exam 2 Flashcards
“A or B -> C” is in the form of a Horn Clause.
True or False
False
Logic programming is based on lambda calculus.
True or False
False
a -> d
c -> b
d -> c
Using the statements above, which of the following statement can be derived using inference rules.
a - > d
How can you write the fact “A parrot is a bird” in predicate calculus?
bird(parrot).
__________________ are statements that are assumed to be true and from which all true statements about natural numbers can be proved.
Axioms
The language Curry brings together the advantages of functional and logic programming in a single language.
True or False
True
_________________________ refers to the issue that arises when a variable is unified with a term that contains that variable itself, leading to potentially infinite structures or circular references.
Occur-check problem
What is the value of Y in Prolog if you write the following statement:
[X|Y] = [1,2,3,4].
[2, 3, 4]
In Prolog, any statement that is not known to be true is considered false.
True or False
True
Every logical statement can be turned into Horn clauses.
True or False
False
What is implication operator in Prolog?
:-
Which predicate in Prolog can be used to force backtracking and to find all solutions to a query?
fail
writenum(l, J) :- num(X),
I =< X,
X =< J,
write(X),
nl,
fail.
For the given Prolog code, writenum(1,10) will go into an infinite loop after X = 10.
True or False
True
Prolog queries always have one answer.
True or False
False
Changing the order of the right-hand side of a clause may cause an infinite loop in Prolog.
True or False
True
The cut operator is used to “cut” off parts of the search space, effectively preventing Prolog from backtracking past the point where the cut is encountered. Which of the following is the cut operator?
!
Curry is dynamically typed, Prolog uses strong static typing with type inference,
True or False
False
In logic programming, a statement is proved if all subgoals are eventually eliminated and the empty Horn clause is derived.
True or False
True
Prolog’s search strategy is breadh-first search.
True or False
False
If you have the fact human(bob) in Prolog, the query not(not(human(X))) returns X = bob.
True or False
False
In Java, all classes inherit from the _______________ class by default.
Object
Simula is the first purely object-oriented language. Everything in Simula is an object, including numbers and code itself.
True or False
False
What is the output of the following Java code:
String a = new String(“hello”);
String b = new String(“hello”);
System.out.println(a == b);
True or False
False
When there is a method overloading in Java, the method that gets called is always determined at run-time based on the method signature.
True or False
False