Make your own free website on
Leibniz: Implementing a Drag-and-Drop Calculator

Joe Gregg
Lawrence University
Appleton, WI 54911

Leibniz is a combination word processor and front end for Mathematica designed for
use in mathematics education. Leibniz uses a sophisticated pattern matching scheme to
implement a simple and elegant interface for performing symbolic calculations. This
article will describe the architecture of the Leibniz system and discuss some of the
special techniques used in Leibniz to control evaluation.

What is Leibniz?
Leibniz is a stand-alone text and equation editor for Windows and MacOS computers implemented in C++.
Leibniz communicates with the Mathematica kernel via MathLink, sending requests for calculations to the
kernel and formatting and displaying the results. In addition to the application itself, the system also
includes LZCompute.m, a Mathematica package that mediates the communication between the Leibniz
front end and the kernel.
Leibniz implements a powerful and easy to use mouse driven calculation system. Users perform
calculations by selecting a portion of an expression to evaluate and pressing enter, or by dragging a
selection from one part of an expression to a new location to rearrange the expression. For example, to
compute an integral the user would type the integral, select it, and hit enter. To move a term from one side
of an equation to the other by, say, subtracting the term from both sides, the user selects the term and drags
it to the other side of the equation. This system is particularly powerful and easy to use because Leibniz takes advantage of Mathematicašs powerful pattern matching capabilities to match the form of an
expression to manipulations that could be performed on it.
When the user selects a portion of an equation, the application parses the equation and translates it into an
internal data structure that reflects the structure of the equation. At the same time, the application calls a
function contained in the LZCompute package. The purpose of this function is to examine the structure of
expression the user has selected and return a list of possible mathematical manipulations that could be
performed on the expression. These possible manipulations come back ranked in order of likelihood, with
the most likely option displayed to the user in a message panel located in the lower left corner of the
document window. The user can then press enter to have that calculation carried out, or hold down the
command key and click on the selection to pop up a menu containing the other calculation options
contained in the list.