TelecomParis_IPParis.png Telecom Paris
Dep. Informatique & Réseaux

nils.png Nils HolzenbergerHome page

February 2026

5

NeurSymAI.png Logic, Knowledge Representation and Probabilities

with             Samuel Reyd     Samuel.jpeg

            other AI courses


5

Quiz lecture 2


Unification
What will the unification of a(X,Y) and a(b(c,Y),Z) return?

It will fail X = b(c, Z), Y = Z X = Y, Y = Z X = b(c(Z)), Y = Z

    

Cut
Consider the following predicates, a1, a2, a3 and a4:


a1(X) :- b(X,X), !.
a1(X) :- c(X,Y).

a2(X) :- b(X,X), \+ c(X,Y).
a2(X) :- c(X,Y).

a3(X) :- b(X,X).
a3(X) :- \+ b(X,X), c(X,Y).

a4(X) :- b(X,X).
a4(X) :- c(X,Y), !.

Which of these predicates are equivalent?

a1 and a2 a1 and a3 a2 and a4 a1 and a4

    

Buying groceries
Nils (first names have been changed) needs to buy groceries. For that, he needs to withdraw cash from the bank. Initially, Nils is at home without groceries and without cash, and he would like to be at home again but with groceries. As a computer scientist, he wants to be sure his plan is feasible, so he writes a Prolog program:


action(state(shop, cash, no_groceries), buy_groceries,
    state(shop, no_cash, groceries)).
action(state(bank, no_cash, Groceries_status), withdraw_money,
    state(bank, cash, Groceries_status)).
action(state(X, Cash_status, Groceries_status), move(X,Y),
    state(Y, Cash_status, Groceries_status)).
success(state(home, _, groceries)).
:- success(state(home, no_cash, no_groceries)).

Which line is missing from his program?
L1: success(State) :- action(State, Action, NextState), success(NextState).
L2: success(State) :- action(NextState, Action, State), success(NextState).
L3: success(NextState) :- action(NextState, Action, State), success(State).
No line is missing, the program is complete. L1 L2 L3

    

            
Line.jpg

Back to the main page