CSE 341 -- Programming Languages

Winter 2000

Department of Computer Science and Engineering, University of Washington

Steve Tanimoto (instructor) and Jeremy Baer (teaching assistant).

Assignment L2

Version 1.05 of January 18.  Subject to change.

Lisp on the Web 

Due date and time: Monday, January 24, 2000 at 10:30 (Submit your assignment electronically by filling out an online submission form.). (Fill out the milestone form by 5:00 PM Tuesday, January 18.

 

Title: Lisp on the Web.

Purposes:  Explore the use of Lisp to manipulate language expressions (either English text or logical formulas) and perform limited reasoning with them in a World-Wide Web context.

Instructions:  Read the information about creating web-based agents in Lisp.  Choose one of the following two options:

1. Doctoring up the Doctor.  Have a conversation with the SHRINK program by first downloading the MATCH function and SHRINK program itself, and then loading them into a Lisp session and typing (SHRINK) to start it. .  To load these files after downloading them into a working directory, go into that directory and start Lisp, and then type (LOAD "MATCH.CL") followed by (LOAD "SHRINK.LSP"). Implement the saving of session state using techniques to be given in the links from this page.  Then alter the character so as to create an agent that exhibits some distinct personality or that offers some identifiable service.  Implement at least two of the following features: (1) the agent's recollection of things the user has mentioned earlier in the conversation, (2) the agent's suggesting web sites to the user on the basis of words or phrases the user has entered, (3) match-making service wherein the agent identifies one or more previous users who seemed to have some things in common with the current user.

Here are some tips on converting strings to lists and vice versa.

2. A Solver for Word Problems Using Algebra.  An example of a word problem, encoded as a list, is the following:

     (if the area of a circle is pi times the square of the radius
     and the radius is 10 meters
     then what is the area of the circle ?)
In 1964, the Ph.D. thesis of Daniel Bobrow presented a program called STUDENT which could solve problems posed in this manner.  In this option, you will use modern-day Lisp facilities to reimplement STUDENT, and to make it accessible over the web.

Here is some additional information on STUDENT.  The sample code shown on Friday, 14 January is available here.  As an overall strategy for implementing the student, you might break the program down into several parts: (a) translating the user's description of the problem into a set of equations -- this involves translating English descriptions of expressions into Lisp/mathematical representations which is what the sample code gives you, (b) solving the equations for the particular variable that corresponds to the solution, and (c) setting the program up to run on the web server.  This last step should be fairly easy since, unlike the SHRINK, the STUDENT doesn't carry on long conversations with the user.  The equation-solving part can be done by defining a function that tests for various conditions and makes appropriate changes to the equations -- for example, if trying to solve (= (+ X Y) 5) for X, a rule could check whether X occurs on the left hand side of the equation as part of a sum, and if so, subtracts the other part of the sum from each side, in this case giving the new equation (= X (- 5 Y)).  It will be a good idea to create some helping functions that test expressions and equations for certain properties; for example you could define a function HAS-ONE-UNKNOWN that would return true for (= (+ X 5) (+ (* 2 X) 10)) but false for (= Y (+ X 1)). Then an equation having one unknown could be solved and the result plugged in to help solve another equation.

Programming style:  Comment your function definitions clearly.  In all of your exercises, use a neat and consistent format for your code, indenting subexpressions appropriately and choosing symbol names that are appropriate to the function they perform in your programs.

Here is some additional information about the assignment, especially for the STUDENT option.