Sale!

# Assignment: Unification & Prolog

\$30.00

CS314
Extra Credit Assignment: Unification & Prolog
Reminder: Lowercase letters and words beginning with a lowercase letter are values/constants. Uppercase letters and words beginning with an uppercase letter are variable names.
Problem 1 – Unification
Can the following expressions be unified? If so, give the unifier.
(a) UNIFY(pointer(a), pointer(pointer(b)))
(b) UNIFY(boo, Baz)
(c) UNIFY([H, T], [a, b, c])
(d) UNIFY(foo(a), foo(X, Y))

Category:

## Description

CS314
Extra Credit Assignment: Unification & Prolog
Reminder: Lowercase letters and words beginning with a lowercase letter are values/constants. Uppercase letters and words beginning with an uppercase letter are variable names.
Problem 1 – Unification
Can the following expressions be unified? If so, give the unifier.
(a) UNIFY(pointer(a), pointer(pointer(b)))
(b) UNIFY(boo, Baz)
(c) UNIFY([H, T], [a, b, c])
(d) UNIFY(foo(a), foo(X, Y))
Problem 2 – Facts & Queries in Prolog
Translate the following into a set of Prolog facts and rules. From (a) through (d), it should be possible
for Prolog to infer (e). Define what your function means. For instance, if you use Department(X, Y)
to mean ”X is in department Y”, please say so.
(a) j is in the cs department
(b) If someone is in a department, they report to the head of that department.
(c) h is the head of the cs department.
(d) Everyone’s salary is less that the salary of the person they report to.
(e) j’s salary is less than h’s salary.
Problem 3 – Cut
Let’s suppose we have the following facts:
likes (a , dogs ).
likes (a , cats ).
likes (b , cats ).
dislikes (c , dogs ).
dislikes (d , dogs ).
dislikes (d , cats ).
What would the following queries print? (Suppose we keep pressing ”;” until ”false.” is the output.)
(a) ?- likes(a, Animaltype), dislikes(Person, Animaltype).
(b) ?- likes(a, Animaltype), !, dislikes(Person, Animaltype).
(c) ?- likes(a, Animaltype), dislikes(Person, Animaltype), !.
1