1. (50) Write a horn clause definition to create a palindrome. A palindrome is a sequence of letters that are the same forwards and backwards, such as

- Dennis sinned
- Naive evian
- Sleep on no peels

One way to create a palindrome is to append the list to the reversal of that list.

You can use any definition from list-rules.lisp (and will probably need reverse
and append). You will need to load "unify" and "fast-traced-prove". **Don't
forget to use "store-clauses" as described in the lecture notes.**

You should test it on one of the above examples, for example

(prove-and-ask '((palindrome (d e n n i s) ?p )))

Solved: ?P = (d e n n i s s i n n e d)

(prove-and-ask '((palindrome ?l (d e n n i s s i n n e d))))

Solved: ?L = (d e n n i s)

2. (50). Write a horn clause definition of a predicate (remove ?e ?list ?result) where the ?result is formed by removing every element ?e from ?list. For example

(prove-and-ask '((remove n (d e n n i s) ?r )))

Solved: ?R = (d e i s)

(prove-and-ask '((remove x (d e n n i s) ?r )))

Solved: ?R = (d e n n i s)

(prove-and-ask '((remove x () ?r )))

Solved: ?R = ()

Hint:

- Removing ?e from () results in ().
- Removing ?e from a list that starts with ?e, results in a list that is formed by removing ?e from the remainder of the list.
- Removing ?e from a list that starts with ?f (which does not equal ?e), results in a list that starts with ?f and whose remainder is formed by removing ?e from the remainder of the list. (See the definition of "constant" in derivative.lisp to see an example of not equal.

**EXTRA CREDIT** . Extend the derivative and simplification clauses to handle
trigonometric, and logarithmic and exponential functions.

Back to http://www.ics.uci.edu/~pazzani/171-p.html (text only) or http://www.ics.uci.edu/~pazzani/171.html .

Michael Pazzani

Department of Information and Computer Science,

University of California, Irvine

Irvine, CA 92717-3425

pazzani@ics.uci.edu