CS 244/444:
Logical Foundations of
Artificial Intelligence

Fall 2009

Instructor: Prof. Lenhart Schubert
See his class page.

TA: Jonathan Gordonjgordon@cs.rochester.edu
Office hours: Friday 10:00–12:00 (in CSB 630)

News

Office hours are a guaranteed time when you can see me in my office and ask questions about the class material. If you want to ask at a different time, you can email me your question or a re­quest to meet by appointment.

Homework

Note: Late homework will be accepted but will lose 10% credit per day (counted as 24 hours from the day/time it was originally due). Saturday and Sunday count as one day.

To turn in late homework without penalty, you must have permission from the instructor.

Written Assignments

Programming Assignments

Grading Breakdown

Approximately:

On Programming

Comments

“Students are taught that it's important to comment every­thing … But the purpose of commenting can be lost in blindly following rules. Comments are meant to help a reader under­stand parts of the program that are not readily understood from the code itself. As much as possible, write code that is easy to understand; the better you do this, the fewer com­ments you need. Good code needs fewer com­ments than bad code.”

— Brian W. Kernighan and Rob Pike,
The Practice of Programming

You must comment your code. It is unlikely that you, two days after you write the code, will know what you were thinking when you wrote it. It is much less likely that I will have any idea what you were thinking.

However, needless comments of the type

;; Print the current value of x
(format t "~A" x)

should make you ashamed.

Explain big decisions and anything that would be unclear to a competant Lisp programmer looking at your code. If any part of your code is so confusing that it requires extensive comments, rewrite the code.

Naming

Choose the shortest names for variables and functions that clearly express what they are. Follow Lisp conventions such as the use of asterisks around global variable names or suffixing “p” to predicate names.

Lisp Style

Just because the language provides it doesn’t mean it’s a good idea:

Indent your code consistently. Lisp is a language with fairly standard indenting practices – look at how Emacs autoformats the code or see the examples in Common Lisp: The Language. Do not use tabs as the interpretation of their width varies – your code may be rendered illegible to others.

Always ask yourself what the clearest, most elegant solution would be: If you’re nesting if statements deeply, use a cond instead! If your function is doing several conceptually distinct operations, split it into multiple functions.

Your code should not contain more than 80 characters per line.

Learning and Using Common Lisp

There are many fine introductions to Lisp available online. You should try looking at these and see which helps you. If you are confused and cannot find your answer, email me.

Online:

In print:

Additionally, Structure and Interpretation of Computer Programs by Abelson, Sussman, and Sussman uses the closely related Scheme language and is a great text about programming.

Emacs

Unless you are very attached to another text editor, you will find that using Emacs to write and debug Lisp will make your life easier. In particular, you should use SLIME, which is a Lisp-editing mode that is installed on the URCS grad. systems in /usr/grads/share/emacs/site-lisp/

I add to my Emacs configuration file (~/.emacs):

(add-to-list 'load-path 
             "/usr/grads/share/emacs/site-lisp/slime/")
(setq inferior-lisp-program "/usr/staff/bin/alisp")
(require 'slime-autoloads)
(eval-after-load "slime"
  '(progn 
     (slime-setup '(slime-fancy))
     (setq slime-complete-symbol*-fancy t)))

Undergrads should change the first line to contain "/u/cs244/share/slime" as the path.

To start a SLIME session, type M-x slime (where M is the “meta” key – usually escape). To exit this interactive session, type , quit.

You can also read what Ben Van Durme wrote about Emacs and Lisp though a few details about the local SLIME installation are out of date.

Debugging

See Myros’s write-up.