ICS 171 Homework #11

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

Of course, we'll represent these as lists such as (d e n n i s s i n n e d).

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:

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