MathML

Neil Soiffer
  Robby Villegas

Introduction to MathML

Drawbacks to current situation of  math of the web:
•  separate files for gifs
•  apriori fixed font size, background, foreground
•  fixed linewidth
•  baseline alignment of inline math
•  uneditable, unselectable, unevaluateable

XML and friends

XML is derived from SGML ("20% of the complexity, 80% of the power").
In other words, XML is not HTML++, it's SGML--.
The basic idea is to separate the data from the presentation.

<tag (Subscript[attribute, 1])= "(Subscript[value, 1])" …>
    contents
</tag>

Document Type Definition (DTD) defines what tags are legal, what the children tags of
a tag can/must be, what attributes a tag allows/requires, along with what attributes values are allowed.

DTDs can be used to verify that a document is "legal".  They use a different syntax than SGML/XML, and work is progressing on Schemas which would use XML syntax to describe the same things.

Presentation of tags is handled by Cascading Style Sheets (CSS) or by (very recently) eXensible Style Language (XSL).  These are typically listed at the start of an XML document.

CSS is similar to Mathematica's style sheets in that it associates with each style, a list of properties that effect the display of the style.

XSL takes a very different approach.  It is essentially a pattern matcher that matches patterns involving tags and transforms them into tags the browser understands (eg, today HTML, in the future, formatting objects).  XSL is more powerful than CSS, but the transformation it does destroys the logical structure of the document.

Document Object Model (DOM) exposes the tree that represent the document and defines an API for querying and manipulating the tree.

Mathematical Markup Language (MathML) came into being as XML was being developed.

Several much more elegant (and concise) syntaxes were proposed and considered, but in the end, the committee came to the conclusion that plain text editing of XML documents was not the way the world was going and that
the virtues of being part of XML world greatly outweighed the benefits of human authorability and conciseness that a separate "black box" syntax would bring.
The benefits of being part of the XML world include "free" parsing, verification, indexing, XSL, DOM…

Presentation Tags

Presentation tags are used when presentation is more important than the semantics.  Because a major source of documents will be from TEX, most MathML will probably be presentation-based.

Presentation tags are similar to Mathematica boxes.  Tags include <mrow>, <msup>, <mfrac>, and <mn>.

(lim_(x -> 0))((sin(x))/x)

<math>
<mrow>
  <munder>
    <mi>lim</mi>
    <mrow>
      <mi>x</mi>
      <mo>-></mo>
      <mn>0</mn>
    </mrow>
  </munder>
  <mo>&it;</mo>
  <mfrac>
    <mrow>
      <mi>sin</mi>
      <mo>&af;</mo>
      <mrow>
        <mo>(</mo>
        <mi>x</mi>
        <mo>)</mo>
      </mrow>
    </mrow>
    <mi>x</mi>
  </mfrac>
</mrow>
</math>

Semantic Tags

Semantics tags are used when semantics are important and you don't care about the presentation.  For common math, either set of tags will do.  Examples of semantic tags include <int/>, <gcd/>, <cos/>, and <limit/>.

Example of the same expression using semantics tags

(lim_(x -> 0))((sin(x))/x)

<math> 
  <apply>
    <limit/>
    <bvar>
      <ci> x </ci>
    </bvar>
    <lowlimit>
      <cn> 0 </cn>
    </lowlimit>
    <apply> <divide/>
      <apply> <sin/>
	<ci> x </ci>
      </apply>
      <ci> x </ci>
    </apply>
  </apply>
</math>

Semantics and presentation tags can be freely mixed.

Semantics Tag

The semantics tags provides a way to specify both the presentation and semantics of its contents.

<math> 
  <semantics>
    <apply> <divide/>
       <ci> a </ci>
       <ci> b </ci>
    </apply>
    <annotation-xml encoding="MathML-Presentation">
       <mrow>
		<ci> a </ci>
		<mo> / </mo>
		<ci> b </ci>
       </mrow>
    </annotation-xml>
    <annotation encoding="Mathematica">
		Sin[x] + 5
    </annotation>
  </semantics>
</math>

Characters

One of the thorny issues is representing all of the characters used in Mathematics.

Getting the characters into Unicode
STIX project, Unicode V4

Fonts for the browsers

MathML and Mathematica

Export

There's not much to say (other than HTMLSave is much better in V4 than V3).  Simply choose the
	File:Save As Special:HTML/MathML
and give a file name to save to.
This produces presentation tags.

A future project is to allow saving the math using semantic tags.

Import

Pasting
	Presentation example
	Content example

You can also use the kernel to cause interpretation of the MathML

CellPrint[Cell[
MathMLText["
	<math>
      <mrow>
        <mo>&Integral;</mo>
        <mrow>
          <msup>
            <mi>&ee;</mi>
            <mi>x</mi>
          </msup>
          <mo>&it;</mo>
          <mrow><mo>&dd;</mo> <mi>x</mi></mrow>
        </mrow>
      </mrow>
    </math>
  "], "Input"]]

Note:  this is an undocumented feature and in some future version, it is likely that the kernel will handle MathML directly.

HTML w/MathML ⟶ HTML

<< "\\soiffer\\developer conference99\\gifsplicer.m"

SpliceMathMLToGIF["\\soiffer\\developer \
conference99\\HistoryOfPi\\index.html",  "\\soiffer\\developer \
conference99\\ConvertedHistoryOfPi"];

Patent Office Application

Theo is going to spend a few minutes showing how the patent office is using MathML.

Current Status of MathML

MathML 2.0

A few additions to presentation tags:  long division, automatic numbering support, ...
Cleanup and additions to content tags:  "arg" (angle of  a complex number), "grad",  ...
This should become a proposed W3C recommendation in February, 2001.

Test suite to help establish conformance to the standard.  Test suites are useful for both implementators and customers.

Browsers

Netscape (actually Mozilla) — group of people volunteered to implement MathML.
	As of the end of August, the MathML implementation is part of the Mozilla CVS source tree.

Internet Explorer — version 5 has the necessary support for third parties to implement MathML (modulo some bugs). Microsoft did a proof of concept.  However, some tests showed it was really slow.  Now that MathML is being added to Mozilla…

Amaya — free browser from W3C — not MathML conformant despite their claim...

E-Lite/ICEBrowser — lightweight Java broweser and browser component (uses WebEq for rendering MathML)

Other Applications

Publicon…

MathType — exports MathML presentation tags

WebEq (www.webeq.com) -- applet that renders MathML (authors using presentation tags)

IBM techexplorer -- can read "most" of MathML

TEX — "Omega" has LATEX-to-HTML/MathML translator.  LATEX2HTML and other translators are being worked on (presentation tags).

See www.w3c.org/math for a complete list along with hyperlinks...

Related work

OpenMath (www.openmath.org)
an attempt at more precise content tags

Math metadata [K-16] (ucs.orst.edu/~robsonr/work/metadata.html)
categorization of mathematical content for searching