Abstract

MathML is a W3C recommendation that represents mathematical expressions. This note describes a way to add semantic intent to presentation markup.

Table of Contents
Introduction

The presentation of an expression consists of special symbols arranged to convey mathematical meaning. Conventional math notation includes ambiguities that a human reader is taught to resolve in context in ways that may be difficult to infer by computational systems.

The content of an expression consists of operator symbols applied to sequences of arguments, which may themselves be function applications or ground terms such as numerals or variables. The content markup used to encode such expressions is often complex, and often not included with the presentation.

The intent of an element is a functional expression that captures the meaning conveyed by the author. It is meant to bridge the gap between the presentation of an expression, and its underlying content and semantics, to resolve ambiguities that may affect the reading and understanding of the notation.


The intent attribute

The intent of an element is a functional expression that captures the meaning conveyed by the author. It should reflect the meaning that would be understood by a human reader. The intent may often be inferred from the presentation, especially when the author supplies information such as the subject area.

The intent attribute encodes the intent of an element in terms of the intent of its sub elements.

intent :=
    {numeral} |
    {NCName} |
    {NCName} '(' ')' |
    {NCName} '(' {intent} [ ',' {intent} ]* ')' |
    '$' {numeral} |
    '$' {NCName} |
    '@' {NCName}

The intent attribute value may contain:


Explicit intent values

Explicit examples of the intent attribute may express:


Default intent values

Many presentation elements have predefined default intent values:

<mn>@cdata
<mi>@cdata
<mo>@opname
<mtext>@ignore
<mspace>@ignore
<ms>[none]
<mrow>@op | @append
<mfrac>@divide
<msqrt>@sqrt
<mroot>@root
<mstyle>@mrow
<merror>@mrow
<mpadded>@mrow
<mphantom>@ignore
<msub>[none]
<msup>@power
<msubsup>[none]
<munder>[none]
<mover>[none]
<munderover>[none]
<mmultiscripts>[none]
<mtable>[none]
<mtr>@append
<mtd>@mrow
<maction>[none]

There are a few special cases with specific behavior:

The default intent of an atomic element mn or mi is taken from the character data of the element. The atomic element mo may be given a predefined default intent based on the character data of the operator. Several presentation elements are given a predefined intent @ignore which treats the element has having no intent.

An mrow element that contains a unique visible descendant mo element on its implied argument list is given a predefined default intent @op which applies the unique operator to the implied argument list. Any other mrow element is given a predefined default intent @append which concatenates the intent of its child elements. Several presentation elements are defined as having an implied mrow around its child elements. These elements use the intent of the implied mrow element.

See below for examples of other rules for inferring default intent for presentation elements. These rules may be influenced by subject area information provided by the author.

These rules provide default intent values for tools that process the intent values. They are not intended to provide default values for the XML attributes as part of the document markup.


Default intent examples

Examples of default intent values:


The arg attribute

The arg attribute provides a numeric index or a symbolic name for a sub element that may be used within an enclosing intent attribute to refer to the intent of the sub element. The form of an argument reference is the "$" sign, followed by the numeric index or symbolic name.

arg := {numeral} | {NCName}

The arg attribute behaves like an ID attribute that need only be unique within the enclosing expression that uses it. The "$" sign argument reference behaves like an IDREF attribute that refers to the arg attribute values.


Argument index references

The arg attribute may assign a numeric index for an element.

arg := {numeral}

The argument index can be used in an argument index reference.

ref := '$' {numeral}

The argument list for an element consists of its visible descendant elements with intent in document order, that is, its descendant elements with either an explicit intent attribute or an inferred default intent, that are not contained within an intervening element with intent, and that are not otherwise assigned an argument name.

Within an element, the first mo element that would otherwise appear in the argument list is assigned the argument name op by default, and is excluded from the argument list. Any other mo element with the same intent is likewise excluded from the argument list.

The elements in the argument list are assigned a default argument index to fill the unassigned numeric argument index values starting from one.


Argument index examples

The argument index may be used to reference the intent of a sub expression:


Argument name references

The arg attribute may assign a symbolic name for an element.

arg := {NCName}

The argument name can be used in an argument name reference.

ref := '$' {NCName}

An argument name may be used within the intent attribute of any ancestor element of the element where it is assigned. The intent attribute of an element may refer to the argument name assigned to any of its descendant elements.

An argument name must be unique within the element that uses it.

Within an element, the first mo element that would otherwise appear in the argument list is assigned the argument name op by default, and is excluded from the argument list.


Argument name examples

An element may be assigned an argument name that may be used as a way to reference its intent within an ancestor element:


Implied arguments examples

The intent attribute may express the application of a named function to a list of implied arguments collected from the sub elements. The implied argument list is collected from sub elements that have an intent attribute, supplied either as an explicit attribute value, or as a default intent value.


Examples -- Transpose

The transpose operation may be expressed as the letter "T", either using superscript notation or using prefix function notation.

Either case works out to supply intent="transpose(A)". There are good reasons to voice these notations differently. Doing so requires using both the markup and the intent to select the voicing.


Examples -- Superscript

When the same notation may express different intent in printed material, the author and reader typically use other means to agree on the intent, such as notational conventions or expository text. For online markup, the intent can resolve the ambiguity directly. For example, the superscript notation may intend:


Superscript as exponent

The most common use of superscript is to denote exponentiation.

$x^2$ as $power(x,2)$

<msup>
  <mi>x</mi>
  <mn>2</mn>
</msup>

$x^n$ as $power(x,n)$

<msup>
  <mi>x</mi>
  <mi>n</mi>
</msup>

The default intent for msup is to apply the power operation.


Superscript as tensor or matrix index

Another important use to index into tensors or matrices.

$c_ix^i$ as $times(index(c,i),index(x,i))$

<mrow>
  <msub intent="@index">
    <mi>c</mi>
    <mi>i</mi>
  </msub>
  <mo>&#x2062;</mo>
  <msup intent="@index">
    <mi>x</mi>
    <mi>i</mi>
  </msup>
</mrow>

The default intent for the mo element for invisible times is to apply the times operation. The msub and msup element have intent="@index" to apply the index operation.


Superscript as the operator

The superscript itself may supply the operator.

$z^*$ as $conjugate(z)$

<msup intent="@conjugate">
  <mi>z</mi>
  <mo>*</mo>
</msup>
<msup intent="@op">
  <mi>z</mi>
  <mo intent="conjugate">*</mo>
</msup>

$A^T$ as $transpose(A)$

<msup intent="@transpose">
  <mi>A</mi>
  <mo>T</mo>
</msup>
<msup intent="@op">
  <mi>A</mi>
  <mo intent="transpose">T</mo>
</msup>

$A^\dagger$ as $adjoint(A)$

<msup intent="@adjoint">
  <mi>A</mi>
  <mo>†</mo>
</msup>
<msup intent="@op">
  <mi>A</mi>
  <mo intent="adjoint">†</mo>
</msup>

In each of these cases, the intent may be supplied on the msup element directly, or using @op to collect the intent supplied on the mo element.


Examples -- Binomial

The same intent may be expressed by different printed notations. For example, the binomial coefficient may be expressed as:


Binomial as stacked numbers

One notation for the binomial coefficient is as a stack of two numbers, enclosed in parentheses.

$\binom{n}{m}$ as $binomial(n,m)$

<mrow intent="$1">
  <mo>(</mo>
  <mfrac linethickness="0" intent="@binomial">
    <mi>n</mi>
    <mi>m</mi>
  </mfrac>
  <mo>)</mo>
</mfenced>

The mfrac element supplies intent="@binomial" to apply binomial to the arguments in the mi elements, and the mrow element supplies intent="$1" to use the intent of the mfrac element.


Binomial as subscript and superscript

Another notation for the binomial coefficient is as a literal C with subscript and superscript.

$C^n_m$ as $binomial(n,m)$

<msubsup intent="@binomial">
  <mo>C</mo>
  <mi arg="2">m</mi>
  <mi arg="1">n</mi>
</msubsup>
<msubsup intent="@op">
  <mo intent="binomial">C</mo>
  <mi arg="2">m</mi>
  <mi arg="1">n</mi>
</msubsup>

The msubsup element supplies an intent attribute to apply the binomial operation to the arguments in the mi elements. The operator itself may be supplied on the msubsup element directly, or on the mo element.


Examples -- Multiple Operators

When the presentation supplies an element for each intended structure, the intent attribute can be placed naturally on the element that presents the structure. When the presentation combines multiple structures into a single element, that element can be marked with the intent of the multiple structures:


One mrow with multiple infix operators

The default intent of an mrow that contains multiple infix operators is to append the intent of the child elements.

$a+b-c+d$ as $append(a,plus,b,minus,c,plus,d)$

<mrow intent="@append">
  <mi>a</mi>
  <mo>+</mo>
  <mi>b</mi>
  <mo>-</mo>
  <mi>c</mi>
  <mo>+</mo>
  <mi>d</mi>
</mrow>

A single mrow that contains multiple infix operators may be marked with the intent of the multiple infix operators.

$a+b-c+d$ as $plus(a,plus(minus(b,c),d))$

<mrow intent="$p1($a,$p2($m($b,$c),$d))">
  <mi arg="a">a</mi>
  <mo arg="p1">+</mo>
  <mi arg="b">b</mi>
  <mo arg="m">-</mo>
  <mi arg="c">c</mi>
  <mo arg="p2">+</mo>
  <mi arg="d">d</mi>
</mrow>

A single mrow that contains multiple infix operators may be interpreted with different implied groupings of the operators.

$a+b-c+d$ as $plus(plus(a,minus(b,c)),d)$

<mrow intent="$p2($p1($a,$m($b,$c)),$d)">
  <mi arg="a">a</mi>
  <mo arg="p1">+</mo>
  <mi arg="b">b</mi>
  <mo arg="m">-</mo>
  <mi arg="c">c</mi>
  <mo arg="p2">+</mo>
  <mi arg="d">d</mi>
</mrow>

The nesting may also be made clear using additional mrow elements:

$a+b-c+d$ as $plus(a,plus(minus(b,c),d))$

<mrow>
  <mi>a</mi>
  <mo>+</mo>
  <mrow>
    <mrow>
      <mi>b</mi>
      <mo>-</mo>
      <mi>c</mi>
    </mrow>
    <mo>+</mo>
    <mi>d</mi>
  </mrow>
</mrow>

$a+b-c+d$ as $plus(plus(a,minus(b,c)),d)$

<mrow>
  <mrow>
    <mi>a</mi>
    <mo>+</mo>
    <mrow>
      <mi>b</mi>
      <mo>-</mo>
      <mi>c</mi>
    </mrow>
  </mrow>
  <mo>+</mo>
  <mi>d</mi>
</mrow>

One mrow with unary prefix operators

A single mrow that contains unary prefix operators can be marked with the intent of the unary prefix operators.

$a+b-c+d$ as $plus(a,b,minus(c),d)$

<mrow intent="$p1($a,$b,$m($c),$d)">
  <mi arg="a">a</mi>
  <mo arg="p1">+</mo>
  <mi arg="b">b</mi>
  <mo arg="m">-</mo>
  <mi arg="c">c</mi>
  <mo arg="p2">+</mo>
  <mi arg="d">d</mi>
</mrow>

The nesting may also be made clear using additional mrow elements:

<mrow>
  <mi>a</mi>
  <mo>+</mo>
  <mi>b</mi>
  <mrow>
    <mo>-</mo>
    <mi>c</mi>
  </mrow>
  <mo>+</mo>
  <mi>d</mi>
</mrow>

One mrow with unary postfix operators

A single mrow that contains unary postfix operators can be marked with the intent of the unary postfix operators.

$a+b!$ as $plus(a,factorial(b))$

<mrow intent="$p($a,$f($b))">
  <mi arg="a">a</mi>
  <mo arg="p" intent="plus">+</mo>
  <mi arg="b">b</mi>
  <mo arg="f" intent="factorial">!</mo>
</mrow>
<mrow>
  <mi>a</mi>
  <mo>+</mo>
  <mrow>
    <mi>b</mi>
    <mo>!</mo>
  </mrow>
</mrow>

Examples -- Derivative Operators

The intent of the fraction is to express the derivative operator, which is applied to the expression $\sin x$, and the differentiation variable $x$.

${d \over dx}\sin x$ as $diff(sin(x),x)$

<mrow intent="$op($1,x)">
  <mfrac arg="op" intent="diff">
    <mo>&#x2146;</mo>
    <mrow>
      <mo>&#x2146;</mo>
      <mi>x</mi>
    </mrow>
  </mfrac>
  <mrow>
    <mo>sin</mo>
    <mi>x</mi>
  </mrow>
</mrow>

Examples -- Integrals of Fractions

Integrals of fractions are often presented with the differential $dx$ as part of the fraction. For these cases, the intent of the integral uses a named argument reference to find the bound variable, and special care to arrange for the correct intent for the integrand:


Differential alone in the numerator

The intent of the fraction uses the numeral 1 as the numerator, and no other elements contribute to the numerator.

$\int_0^1 {dx \over x^2+1}$ as $integral(divide(1,plus(power(x,2),1)),x,0,1)$

<mrow intent="$op($3,x,$1,$2)">
  <msubsup>
    <mo>&x222B;</mo>
    <mn>0</mn>
    <mn>1</mn>
  </msubsup>
  <mfrac>
    <mrow intent="1">
      <mo>&#x2146;</mo>
      <mi>x</mi>
    </mrow>
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</mrow>

So the intent constructed by the outer mrow works out to be integral(divide(1,plus(power(x,2),1)),x,0,1).


Differential in a binary product

The intent of the fraction uses the initial $x$ as the numerator, and no other elements contribute to the numerator.

$\int_0^1 {x\,dx \over x^2+1}$ as $integral(divide(x,plus(power(x,2),1)),x,0,1)$

<mrow intent="$op($3,x,$1,$2)">
  <msubsup>
    <mo>&x222B;</mo>
    <mn>0</mn>
    <mn>1</mn>
  </msubsup>
  <mfrac>
    <mrow intent="$1">
      <mi>x</mi>
      <mo>&#x2146;</mo>
      <mi>x</mi>
    </mrow>
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</mrow>

So the intent constructed by the outer mrow works out to be integral(divide(x,plus(power(x,2),1)),x,0,1).


Differential in an nary product

The intent of the fraction uses $2x$ as the numerator, and no other elements contribute to the product.

$\int_0^1 {2x\,dx \over x^2+1}$ as $integral(divide(times(2,x),plus(power(x,2),1)),x,0,1)$

<mrow intent="$op($3,x,$1,$2)">
  <msubsup>
    <mo>&x222B;</mo>
    <mn>0</mn>
    <mn>1</mn>
  </msubsup>
  <mfrac>
    <mrow intent="$1">
      <mrow>
        <mn>2</mn>
        <mo>⁢</m0>
        <mi>x</mi>
      </mrow>
      <mo>&#x2146;</mo>
      <mi>x</mi>
    </mrow>
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</mrow>

So the intent constructed by the outer mrow works out to be integral(divide(times(2,x),plus(power(x,2),1)),x,0,1).


Differential next to an exponent

The intent of the fraction uses $x^2$ as the numerator, and no other elements contribute to the numerator.

$\int_0^1 {x^2\,dx \over x^2+1}$ as $integral(divide(power(x,2),plus(power(x,2),1)),x,0,1)$

<mrow intent="$op($3,x,$1,$2)">
  <msubsup>
    <mo intent="integral">&x222B;</mo>
    <mn>0</mn>
    <mn>1</mn>
  </msubsup>
  <mfrac>
    <mrow intent="$1">
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>&#x2146;</mo>
      <mi>x</mi>
    </mrow>
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</mrow>

So the intent constructed by the outer mrow works out to be integral(divide(power(x,2),plus(power(x,2),1)),x,0,1).


Differentials within nested integrals

$\int_0^1 {\int_0^x {dy \over y} dx \over x+1}$ as $integral(divide(integral(divide(1,y),y,0,x),plus(x,1)),x,0,1)$

<mrow intent="$op($3,x,$1,$2)">
  <msubsup>
    <mo>&x222B;</mo>
    <mn>0</mn>
    <mn>1</mn>
  </msubsup>
  <mfrac>
    <mrow intent="$1">
      <mrow intent="$op($3,y,$1,$2)">
        <msubsup>
          <mo>&x222B;</mo>
          <mn>0</mn>
          <mi>x</mi>
        </msubsup>
        <mfrac>
          <mrow intent="1">
            <mo>&#x2146;</mo>
            <mi>y</mi>
          </mrow>
          <mi>y</mi>
        </mfrac>
      </mrow>
      <mo>&#x2146;</mo>
      <mi>x</mi>
    </mrow>
    <mrow>
      <mi>x</mi>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</mrow>

Each integral expression includes its own bound variable as an explicit intent value.


Examples -- Matrices and Tables
Matrices

The intent of an mtable may be used to construct a matrix.

$array(arrayrow(1,0),arrayrow(0,1))$

<mtable intent="@array">
  <mtr intent="@arrayrow">
    <mtd><mn>1</mn></mtd>
    <mtd><mn>0</mn></mtd>
  </mtr>
  <mtr intent="@arrayrow">
    <mtd><mn>0</mn></mtd>
    <mtd><mn>1</mn></mtd>
  </mtr>
</mtable>

The intent of the table uses @array, the intent of each row uses @arrayrow and the intent of each element uses the default intent @mrow.


Equation arrays

The intent of an mtable can be used to construct a list of equations.

$list(append(times(2,x),eq,1),append(y,gt,minus(x,3)))$

<mtable intent="@list">
  <mtr intent="@append">
    <mtd columnalign="right">
      <mn>2</mn>
      <mo>&#x2062;<mo>
      <mi>x</mi>
    </mtd>
    <mtd columnalign="center">
      <mo>=</mo>
    </mtd>
    <mtd columnalign="left">
      <mn>1</mn>
    </mtd>
  </mtr>
  <mtr intent="@append">
    <mtd columnalign="right">
      <mi>y</mi>
    </mtd>
    <mtd columnalign="center">
      <mo>&gt;</mo>
    </mtd>
    <mtd columnalign="left">
      <mi>x</mi>
      <mo>-</mo>
      <mn>3</mn>
    </mtd>
  </mtr>
</mtable>

The intent of each element is constructed by treating each mtd element as an implicit mrow. So the first row contains times(2,x), eq, and 1, and the second row contains y, gt, and minus(x,3).

The intent of each row is constructed using append to combine the intent values from each element. So the intent of the first row is append(times(2,x),eq,1) and the intent of the second row is append(y,gt,minus(x,3)).

The intent of the table uses @list to construct the list of equations.


Equation arrays

The intent of an mtable can be used to line break an equation.

$list(append(a,eq,append(b,plus,c,minus,d),append(plus,e,minus,f)))$

<mtable intent="@list">
  <mtr intent="@append">
    <mtd columnalign="right">
      <mi>a</mi>
    </mtd>
    <mtd columnalign="center">
      <mo>=</mo>
    </mtd>
    <mtd columnalign="left">
      <mi>b</mi>
      <mo>+</mo>
      <mi>c</mi>
      <mo>-</mo>
      <mi>d</mi>
    </mtd>
  </mtr>
  <mtr intent="@extend">
    <mtd columnalign="right"></mtd>
    <mtd columnalign="center"></mtd>
    <mtd columnalign="left">
      <mo>+</mo>
      <mi>e</mi>
      <mo>-</mo>
      <mi>f</mi>
    </mtd>
  </mtr>
</mtable>

The intent of each element is constructed by treating each mtd element as an implicit mrow. So the first row contains a, eq, and append(b,plus,c,minus,d), and the second row contains append(plus,e,minus,f) since the other elements are empty.

The intent of each row is constructed using append to combine the intent values from each element. So the intent of the first row is append(a,eq,append(b,plus,c,minus,d)), and the intent of the second row is append(append(plus,e,minus,f)). Since the second row uses intent="@extend", the intent of the second row is concatenated onto the intent of the first row to produce append(a,eq,append(b,plus,c,minus,d),append(plus,e,minus,f)).

The intent of the table uses @list to construct the list of equations.