Basic Mathematical Viewing

This section helps you understand the basic structure of the mathematical expressions you will be editing using Zed, and the mechanisms you will use to interact with both content and presentation MathML.


Basic Viewing Example
Presentation and Content
MathML Expression Markup
Zed Expression Markup
Editing the Markup
What Meets the Eye
Layout Transformations
As You Like It

Editing a mathematical expression is inherently more interesting than editing a sentence with a word processor. The two-dimensional structure of mathematical notation means that when you are using Zed, you will need to think about what you are creating in new ways—both in terms of how the math appears on the page, and in terms of how the math is built up out of operators and arguments. The following paragraphs describe these distinctions in more detail by showing you how to access the different kinds of markup used by the editor, by illustrating how things that look the same may in fact be quite different, and by illustrating how the same expression can be made to appear in quite different ways.


Basic Viewing Example

Example: quadratic.mml

The quadratic equation can be used to illustrate the different kinds of markup that can be used in Zed to represent an expression. If you are using frames, clicking on the above link should bring up a smallish frame at the top of the page so you can interact with the example while you read the following sections. All of the operations described below from the Source menu can be accessed in the example frame by using the context menu as described in Context Menus.

If at any point you want to dismiss the example, give the example frame window the focus and press the Enter key.


Presentation and Content

When viewing a mathematical expression in Zed what you see should resemble, quite closely, the common two-dimensional mathematical notation for the expression contained in the document. Notational conventions for infix operators, prefix operators and postfix operators are all observed as you would expect, fractions are arranged vertically, square roots are presented accurately, font symbols are displayed appropriately, and so forth. Behind the scenes, however, a great deal more information is available, and understanding the extent of that information will often prove helpful in creating mathematical expressions in Zed.

As an expression is being created, Zed maintains information on both the presentation and the content encodings of the expression. The presentation information is a formal description of the particular arrangement of symbols used to communicate the expression so you can read it. The content information is a formal description of the composition structure of the expression, that is, how the expression is composed of operators applied to their arguments. Items on the Source menu and on the Source toolbar provide detailed access to both the content and presentation markup used to represent the expression, both in MathML syntax, and in an internal syntax used to represent Zed expressions.


MathML Expression Markup

Zed is primarily an application for rendering, authoring, converting, and interacting with expressions encoded using MathML content and presentation elements. For this reason, much of the information maintained by the editor is directed toward creating MathML structures of one kind or another.

On a fundamental level, when you are working with a MathML expression in a Zed document, the primary encoding for the expression is the MathML content markup for the expression. This encoding is the one that is used for cut and paste operations, for drag and drop operations, for saving an expression to the filesystem, and so on, as described in Basic Editing. To view the MathML content markup for an expression, select Source→MathML-C.

While the content markup is often used to communicate with other applications, it may have a much different structure than what one might anticipate from the arrangement of the symbols on the screen. This arrangement is captured by the MathML presentation markup for the expression. To view the MathML presentation markup for an expression, select Source→MathML-P. While the content markup is the format exported by the operations described in Basic Editing, it is still possible to copy and paste the presentation markup by using the View MathML Presentation dialog that is used to display the presentation markup.

These features provide a quick-and-easy way to convert from MathML content to presentation: just open a MathML file containing content markup, and use Zed to view the MathML presentation. The other direction, however, is not supported; if you open a file that contains MathML presentation in the editor, both the content and the presentation views will show the original source markup for the expression.


Zed Expression Markup

MathML is a markup language designed by a committee. As such, there are a number of competing and sometimes conflicting goals that went into its definition, and there are times where the particular choices made for representing mathematical expressions in MathML are not always the most convenient for mathematical editing. To address this situation, when Zed manipulates an expression encoded in MathML it is actually operating on a simplified internal variant form of MathML known as a Zed expression. The Zed expression encoding for an expression is primarily intended as an internal form, but you can view it in the same way as you can view the MathML encoding. To view the Zed content markup for an expression, select Source→Zed-C. To view the Zed presentation markup for an expression, select Source→Zed-P.

Those familiar with the Lisp programming language will recognize the Zed expression syntax as simply the result of performing an XML to Lisp translation on the corresponding MathML encoding. A few additional transformations are performed that simplify the Zed expression form for editing operations.


Editing the Markup

While it should be possible to create any particular MathML element structure using the editing operations provided by Zed, from time to time you may find it convenient to modify the underlying MathML content markup directly, as if the markup were contained in a text editor. While one can use the cut and paste operations described in Basic Editing to copy the MathML content markup into another application, edit the markup, and paste back the new version, Zed provides a dialog box to make this operation somewhat more convenient for those situations where you find it useful. To edit the MathML content markup for an expression, select Edit→Source.

On the Edit Source dialog box, the Get button can be used to fill the dialog with the content markup for the current expression, and the Set button can be used to replace the current expression with the markup found in the dialog. The Done button is used to dismiss the dialog, without applying any changes to the current expression.

These features support a quick-and-easy way to pretty print a MathML expression: just paste it into the dialog box, press the Set button to put it in the document, and press the Get button to get the pretty printed form back into the dialog.


What Meets the Eye

As the preceding paragraphs illustrate, with Zed you quite often get much more than what meets the eye. In fact, what meets the eye is determined only by the presentation markup for an expression; the content markup may be quite different, even for expressions that have the same presentation. A few examples will help illustrate the kinds of things to remember.

Example: cconst.mml

Special numeric and constant elements are examples of the kind of ambiguity inherent in mathematical notation. If you click on the above example link, you will see two complex numbers that look to have the same form. As far as the presentation markup is concerned, they are identical. But the content markup for the number on the left is formed with arithmetic operators like <plus> and <times>, while the content markup for the number on the right is formed by a single <cn> element describing the complex number. Other examples could be formed that use the special constant elements defined in MathML, or with elements like <ident> that present themselves in special ways.

Example: dderiv.mml

If you click on this next example link, you will see two sides of an inequality that look the same, but are very different. The left hand side is the application of the element <diff>, while the right hand side is a collection of products and quotients. In fact, the presentation markup for the two expression is almost identical, except for the insertion of a few references to the entity invisible times (&it;), and for the use of <mo> versus <mi>. Even so, the content markup on each side of the relation is quite different, and reveals the full structure of what has been created. While the two expressions look almost identical on the surface, when evaluated by a suitable tool they would behave quite differently.

Example: ppower.mml

There are also expressions that one would reasonably expect to behave the same, but which appear quite different in Zed. Quite often the application of a simple algebraic relation will cause an expression to take on quite a different structure. The above example contrasts negative exponents with quotients, but there are numerous others. While these two expressions are equivalent with the usual interpretation of the operators involved, Zed maintains the structural distinction between the two, and so the presentation of the two forms is quite different.

These examples all demonstrate how Zed approaches the viewing, and ultimately the editing, of mathematical expressions. Instead of "What You See Is What You Get", Zed will remember and respect the particular way you choose to create each expression, and so "What You Create Is What You Get", whether it looks like what you had intended to create, or not.


Layout Transformations

Since Zed works to create both the content and the presentation encodings for the expressions you create, it must keep track of both encodings in such a way that it can translate from one to the other on demand. Because of the inherent ambiguities involved in presentation markup, Zed does not attempt to translate from presentation to content, but instead uses the content encoding as the primary form, as described above. As you make changes to the expression, the editing operations you use create and edit content elements representing the expression.

As the content markup is being created and modified, Zed produces the appropriate presentation markup for the expression by incrementally applying a collection of layout transformations to map from the content form to the presentation form. These layout transformations are selected based on the operators that appear in the expression, as well as their arguments. In the process of applying these layout transformations, Zed remembers the reverse mappings from the presentation back to the content that created it. By doing so, the editor allows you to use the symbols you see in the presentation to initiate editing operations that modify the expression in ways that are determined by the underlying content associated with the presentation being manipulated.

Each of the editing operations described in the sections on Navigating, Inserting, and Deleting MathML elements implicitly operates in this fashion. So, for example, the navigation operations allow you to traverse the presentation of an expression in a visually acceptable fashion, while at the same time traversing only those pieces of the notation that denote a well-formed content expression.


As You Like It

The layout transformations can be customized, as described in the Layout Rules subsection of the Configuration section. These customizations allow you to configure how various content operators are converted to presentation in a uniform way.

Example: ttimes.mml

The practical effect of such customizations is that the appearance of a mathematical expression can be changed to suit your preferences. If you click on the above example link, you will see the now familiar quadratic equation. Multiplication in MathML is represented by the content element called <times>. Typically <times> is displayed using juxtaposition with the help of the MathML entity invisible times (&it;). But in some cases it may be useful to make the multiplication more explicit, either with a centered dot (&cdot;) or with a times symbol (&times;). If you click the buttons provided above, a little piece of scripting code uses the programming interfaces provided by Zed to demonstrate how the layout transformations can be customized to allow for different ways to present multiplication.