CIS 554 -- Prolog Quiz Name __________________________________

1. (2 points) Write a Prolog predicate `last` that you can use to find the last element of a list. It declares that the second parameter is the last element of the list given as the first parameter. The predicate should fail if given an empty list. (Hint: two clauses.)

2. (1 point) Call your `last` predicate to find the last element in the list `[a, b, c]`.

3.  (1 point) What will be the value of `X` after you call your function as `last(X, c)`.  ?

4. (1 point) Help the prisoner to escape!
```   dynamic locked/1.    locked(cell_door).    escape :- locked(cell_door), !, write('You are locked in!'), nl, fail.    escape :- write('You are free!'), nl. ```Do it by completing the following clause:``` ```     ` pick_lock :-`

5. (1 point) Briefly define the term "homoiconic."

6.  (1 point) Turn the following into logical (not Prolog) clause form:
`female(X) ∧ rich(X) ⇒ loves(john, X).`

7.  (1 point) Circle the logical statements that, when turned into clause form, require a Skolem function:

```     ∀x∀y, p(x, y)      ∀x∃y, p(x, y)      ∃x∀y, p(x, y)      ∃x∃y, p(x, y) ```
8. (1 point) How do you indicate a "commit point" in Prolog?

9. (1 point) State the resolution principle.