3B Symbolic Differentiation; Quotation
# Part 1
# Recap
Highlights
In order to make a system that’s robust, it has to be insensitive to small changes, that is, a small change in the problem should lead to only a small change in the solution. There ought to be a continuity. The space of solutions ought to be continuous in this space of problems. —Sussman
- Don’t solve a particular problem at each level: solve a class of problems in the neighborhood of the particular problem by building a language suited to them.
- We’ve seen the power of embedding languages.
- We’re going to confuse the distinction between procedures and data even more badly!
# Derivatives and integrals
- Instead of computing a numerical approximation of the derivative, we want to apply the rules of calculus to algebraic expressions.
- Producing derivatives are easy. Producing integrals, the inverse operation, is hard.
- Why is it easy to go one way but not the other? Because the rules for differentiation are reduction rules.
# Differentiation procedure
- We can write the rules of differentiation as a case analysis that uses recursion.
- But first, we need to be able to represent the expressions.
- Taking an expression as an argument is very different from taking a function.
- You can’t open up a function. You can only get answers from it.
- An expression is data representing the algebraic expression that defines a function.
- We can write the procedure
deriv
using lots of wishful thinking.
# Expression representation
- To represent sums, products, quotients, etc., why not use the same language we’re writing the program in? We can just use list structure.
- There are more built-in predicates we haven’t seen yet:
atom?
andeq?
.
# Quotation
- We are also introducing quotation. The words of English are ambiguous, so we need punctuation: “say your name” is different from “say ‘your name’.”
- The notation in Lisp is to precede the expression with a single quotation mark.
- Quotation makes a language more complex because we can no longer substitute equals for equals (see Bertrand Russell’s “On Denoting”).
- The names
car
andcdr
have survived (originally referring to the address register and the decrement register) because we can use shorthands likecadddr
andcadar
.
# Part 2
# Simplifying expressions
- The expressions we get from the
deriv
procedure are ugly. - Nothing is simplified, and it’s hard to read.
- The solution is to change the representation to add a simplification step.
So the way we might solve this problem is … change the representation … it’s one of the pieces of artillery we have in our war against complexity. —Sussman
- We have an abstraction barrier between the rules of differentiation and the representation of algebraic expressions.
# Conclusion
- Quotation stops and says, “I’m talking about this expression itself.”
- We can write languages that are not only embedded in Lisp, but that are completely different, using quotation. Quotation gives us tremendous power.