MathML is a W3C recommendation that represents mathematical expressions, using both presentation and content markup. This note describes a way to add semantic information to presentation markup using an intent attribute to bridge the gap between the presentation and content forms.
The presentation of an expression consists of special symbols spatially arranged to convey mathematical meaning. Conventional math notation includes visual ambiguities that a sighted human reader is taught to resolve in context in ways that may be difficult to infer by software tools, especially for the visually impaired.
The content of an expression consists of function and 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 an expression may be quite complex, and is often not included with the presentation markup.
This document describes the intent of an element as 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, and to resolve ambiguities that may affect the reading and understanding of the notation, whether for human users, screen readers, or other assistive technology.
The intent of an expression should capture the meaning the author wants to convey, and should reflect the meaning a human reader would be expected to understand from the expression. Often, the intent may be inferred from presentation markup, especially when the author provides additional information, such as the subject area.
The intent attribute encodes the intent of an element as a functional expression that may be constructed using the intent values of any subordinate elements contained in the element being described.
The value of the intent attribute is an {intent} expression that takes one of the following forms, as specified by the intent grammar included below. This section provides a brief description of these forms, each of which is described in detail, with examples, in its own section.
An explicit function application is a function {value} followed by zero or more comma-separated {intent} arguments contained in parentheses.
An implicit function application, indicated by the @ sign, provides a function {value} to be applied to the implicit arguments contained in the current element.
An argument reference, indicated by the $ sign, provides a named or numeric reference to an argument contained in the current element.
A function name is a {name} standing alone that indicates that the expression describes a named operator in isolation, separate from the arguments to which it may be applied.
A literal value, indicated by the # sign, provides an encoding for literal identifiers and numbers used in an {intent} expression.
A special form, indicated by the character ! or /, encodes the default intent for elements with special behaviors, such as token elements, container elements, and elements with empty intent.
The following grammar provides the definition for the intent attribute value.
intent := {explicit} | {implicit} | {reference} | {name} | {literal} | {special} explicit := {value} '(' ( {intent} [ ',' {intent} ]* )? ')' implicit := {value} '@' | '@' {value} | '@' reference := '$' {name} | '$' {number} literal := '#' {name} | '#'? {number} special := '!' {name} | '!' | '/' {name} | '/' value := {reference} | {literal} | {name} name := [A-Za-z_][A-Za-z0-9_.]* number := [0-9.][A-Za-z0-9_.]*
A function {value} is a function name, a named or numeric argument reference, or an identifier or numeric literal. A function {value} may be used in function position within an explicit or implicit function application, or it may stand on its own as a self-contained {intent} expression. Other special forms for the intent attribute are not used in function position.
A {name} is a word that starts with a letter or underscore, and may include subsequent letters, numbers, underscores, and decimal points. A {name} to be used as an XML element name should not include a decimal point, and should not begin with the string xml, in either upper or lower case.
A {number} is a word that starts with a numeral or decimal point, and may include subsequent letters, numbers, underscores, and decimal points. The {number} used in a numeric argument reference should contain only numerals.
Since the empty string is not a valid intent expression, an empty intent attribute value should be treated as if the intent attribute were not present, and if a default intent is defined for the element, it should be used.
explicit := {value} '(' ( {intent} [ ',' {intent} ]* )? ')'
An explicit function application is a function {value} followed by zero or more comma-separated {intent} arguments contained in parentheses.
The intent values use function application syntax to create the intent of an element in terms of the intent of its parts. The functional expression denotes the application of a named function to zero or more arguments.
The intent value {name} ( {intent} , ... , {intent} ) produces an <apply> element with a specific named operator, and processes the child intent expressions to supply the arguments of the operator.
<mrow intent="plus($x,$y)"> <mi arg="x">a</mi> <mo>+</mo> <mi arg="y">b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
<mrow intent="factorial($x)"> <mi arg="x">n</mi> <mo>!</mo> </mrow> --> <apply> <factorial/> <ci>n</ci> </apply>
<mi intent="identity()">I</mi> --> <apply> <identity/> </apply>
The intent value ${name} ( {intent} , ... , {intent} ) produces an <apply> element where the operator is found using a named argument reference, and processes the child intent expressions to supply the arguments of the operator.
<mrow intent="$f($x,$y)"> <mi arg="x">a</mi> <mo arg="f" intent="plus">+</mo> <mi arg="y">b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
<mrow intent="$f($x)"> <mi arg="x">n</mi> <mo arg="f" intent="factorial">!</mo> </mrow> --> <apply> <factorial/> <ci>n</ci> </apply>
The other intent forms that may be used in function position in an explicit function application are numeric argument references, or identifier or numeric literals.
implicit := {value} '@' | '@' {value} | '@'
An implicit function application, indicated by the @ sign, provides a function {value} to be applied to the implicit arguments contained in the current element.
Implicit function application takes one of the following forms.
@ | Apply sequence | <mrow> |
@{name} | Apply function name | <mfrac> |
${name}@ | Apply named reference | |
${number}@ | Apply numeric reference | |
#{name}@ | Apply identifier literal | |
#?{number}@ | Apply numeric literal |
The intent value @ is used for the <mrow> element (and other elements that contain an implied <mrow>) to process its child elements to produce an <apply> element whose operator is taken from the <mo> element contained in the row, when that operator is unique, even if it appears multiple times, and to process the child elements to supply the arguments of the operator.
<mrow intent="@"> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
<mrow intent="@"> <mn>4</mn> <mo>⁢</mo> <mi>a</mi> <mo>⁢</mo> <mi>c</mi> </mrow> --> <apply> <times/> <cn>4</cn> <ci>a</ci> <ci>c</ci> </apply>
The intent value @{name} is used as the default intent for special presentation elements (<mfrac>, <msqrt>, <mroot>, and <msup>) to produce an <apply> element with a specific named operator, and to process the child elements to supply the arguments of the operator.
The intent value @{name} is also used for the <mrow> element (and other elements that contain an implied <mrow>) to produce an <apply> element with a specific named operator, and to process the child elements to supply the arguments of the operator.
<mfrac intent="@divide"> <mi>x</mi> <mn>3</mn> </mfrac> --> <apply> <divide/> <ci>x</ci> <cn>3</cn> </apply>
<mrow intent="@plus"> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
The intent value {name}@ is equivalent to @{name}.
<mrow intent="plus@"> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
The intent value ${name}@ is used to produce an <apply> element where the operator is found using a named argument reference, and to process the child elements to supply the arguments of the operator.
<mrow intent="$f@"> <mi>a</mi> <mo arg="f">+</mo> <mi>b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
The intent value @${name} is equivalent to ${name}@.
The intent value ${number}@ is used to produce an <apply> element where the operator is found using a numeric argument reference, and to process the child elements to supply the arguments of the operator.
<mrow intent="$1@"> <mi>x</mi> <mi>y</mi> </mrow> --> <apply> <ci>x</ci> <ci>y</ci> </apply>
The intent value @${number} is equivalent to ${number}@.
The intent value #{name}@ is used to produce an <apply> element where the operator is created as a ci element with the given name as the character data of the operator, and to process the child elements to supply the arguments of the operator.
<mrow intent="#x@"> <mi>a</mi> </mrow> --> <apply> <ci>x</ci> <ci>a</ci> </apply>
Note that the intent value #{name}@ differs from {name}@, which creates the operator as an empty element.
<mrow intent="x@"> <mi>a</mi> </mrow> --> <apply> <x/> <ci>a</ci> </apply>
The intent value @#{name} is equivalent to #{name}@.
The intent value #?{number}@ is used to produce an <apply> element where the operator is created as a cn element with the given number as the character data of the operator, and to process the child elements to supply the arguments of the operator.
<mrow intent="#42@"> <mi>a</mi> </mrow> --> <apply> <cn>42</cn> <ci>a</ci> </apply>
Note that the # sign for a numeric literal is optional, as it is elsewhere.
<mrow intent="42@"> <mi>a</mi> </mrow> --> <apply> <cn>42</cn> <ci>a</ci> </apply>
The intent value @#?{number} is equivalent to #?{number}@.
reference := '$' {name} | '$' {number}
An argument reference, indicated by the $ sign, provides a named or numeric reference to an argument contained in the current element.
The arg attribute assigns a symbolic name for an element.
arg := {name}
The argument name can then be used in a named argument reference.
reference := '$' {name}
The intent value ${name} is used to include the intent value of the element assigned to the given symbolic name.
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.
When an argument name is used within the intent attribute of an ancestor element, it is not visible to be used by enclosing ancestor elements. That is, the nearest ancestor use of an argument name defines a local scope for the argument name.
An argument name must be unique within the element that uses it.
<mrow intent="plus($x,$y)"> <mi arg="x">a</mi> <mo>+</mo> <mi arg="y">b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
<mrow intent="factorial($x)"> <mi arg="x">n</mi> <mo>!</mo> </mrow> --> <apply> <factorial/> <ci>n</ci> </apply>
<mrow intent="$f($x)"> <mi arg="x">n</mi> <mo arg="f" intent="factorial">!</mo> </mrow> --> <apply> <factorial/> <ci>n</ci> </apply>
<mrow intent="$int($fn,$var,$lo,$hi)"> <msubsup> <mo arg="int" intent="integral">∫</mo> <mn arg="lo">0</mn> <mn arg="hi">1</mn> </msubsup> <msup arg="fn" intent="power($base,$exp)"> <mi arg="base">x</mi> <mn arg="exp">2</mn> </msup> <mo>ⅆ</mo> <mi arg="var">x</mi> </mrow> --> <apply> <integral/> <apply> <power/> <ci>x</ci> <cn>2</cn> </apply> <ci>x</ci> <cn>0</cn> <cn>1</cn> </apply>
An argument index can be used in a numeric argument reference.
reference := '$' {number}
The intent value ${number} is used to include the intent value of the argument element at the given index in the argument list.
The argument list for an element consists of its non-operator descendant elements with intent that are not contained in another descendant element with intent.
<mrow intent="plus($1,$2)"> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> --> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply>
<mrow intent="factorial($1)"> <mi>n</mi> <mo>!</mo> </mrow> --> <apply> <factorial/> <ci>n</ci> </apply>
<mrow intent="$f($1)"> <mi>n</mi> <mo arg="f" intent="factorial">!</mo> </mrow> --> <apply> <factorial/> <ci>n</ci> </apply>
<mrow intent="$int($3,$4,$1,$2)"> <msubsup> <mo arg="int" intent="integral">∫</mo> <mn>0</mn> <mn>1</mn> </msubsup> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>ⅆ</mo> <mi>x</mi> </mrow> --> <apply> <integral/> <apply> <power/> <ci>x</ci> <cn>2</cn> </apply> <ci>x</ci> <cn>0</cn> <cn>1</cn> </apply>
intent := {name}
A function name is a {name} standing alone that indicates that the expression describes a named operator in isolation, separate from the arguments to which it may be applied.
The intent value {name} creates an empty element with the given name. It is not used as the default intent for any presentation element, but may be used as an explicit intent value to specify an operator symbol.
<mo intent="plus">+</mo> --> <plus/>
<mo intent="cross">×</mo> --> <cross/>
literal := '#' {name} | '#'? {number}
A literal value, indicated by the # sign, provides an encoding for literal identifiers and numbers used in an {intent} expression.
The intent value #{name} creates a <ci> token element with the given name as the character data of the token element. It is not used as the default intent for any presentation element, but may be used as a explicit intent value to specify a literal identifier. The initial # sign is required to specify an identifier literal, instead of an operator symbol.
<mrow intent="#x"> <mi>a</mi> </mrow> --> <ci>x</ci>
Note that the intent value #{name} differs from {name}, which creates an operator as an empty element.
<mrow intent="x"> <mi>a</mi> </mrow> --> <x/>
The intent value #{number} creates a <cn> token element with the given number as the character data of the token element. It is not used as the default intent for any presentation element, but may be used as a explicit intent value to specify a literal number. The initial # sign is optional, since a numeric literal must begin with a numeral and so it can stand by itself.
<mrow intent="#42"> <mi>a</mi> </mrow> --> <cn>42</cn>
<mrow intent="42"> <mi>a</mi> </mrow> --> <cn>42</cn>
special := '!' {name} | '!' | '/' {name} | '/'
A special form, indicated by the character ! or /, encodes the default intent for elements with special behaviors, such as token elements, container elements, and elements with empty intent.
The intent values use these special forms.
!{name} | Token intent | <mi> <mn> |
! | Operator intent | <mo> |
/{name} | Container intent | <math> |
/ | Empty intent |
The intent value !{name} is used for the token elements <mi> and <mn> to create content elements <ci> and <cn>, respectively, to contain the character data from the token element.
<mi intent="!ci">x</mi> --> <ci>x</ci>
<mn intent="!cn">3</mn> --> <cn>3</cn>
Since this special form is the default intent value for the <mi> and <mn> elements, it is rarely needed elsewhere.
The intent value ! is used for the <mo> element to allow it to create an empty operator element using the name found in the operator lookup table for the character data it contains. If the operator is not found in the operator lookup table, but represents a valid XML name, an empty operator element with the operator name will be created instead. Otherwise, the presentation element is considered to have empty intent.
<mo intent="!">+</mo> --> <plus/>
Since the operator lookup table defines + as plus.
<mo intent="!">times</mo> --> <times/>
Since the word times represents a valid XML name.
<mo intent="!">⊕</mo> --> []
If the ⊕ operator is not in the operator lookup table.
<mo intent="oplus">⊕</mo> --> <oplus/>
The intent attribute can override the default behavior.
Since the ! special form is the default intent value for the <mo> element, it is rarely needed elsewhere.
The intent value /{name} allows elements like <math> to create a named container element, and to process its presentation child elements to create the content child elements of the container.
<math intent="/math"> <mi>x</mi> </math> --> <math> <ci>x</ci> </math>
Since this special form is the default intent value for the <math> element, it is rarely needed elsewhere.
The intent value / is used for those elements (<mtext>, <mspace>, and <mphantom>) that have empty intent. It may be used as an explicit intent value. An element with empty intent does not create a content element, and is not included in the intent of its parent element.
<mtext intent="/">Theorem 1</mtext> --> []
<mspace width="2ex" intent="/"/> --> []
Many presentation elements have predefined default intent values. 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.
<math> | /math |
<mi> | !ci |
<mn> | !cn |
<mo> | ! |
<mtext> | / |
<mspace> | / |
<ms> | / |
<mrow> | @ |
<mfrac> | @divide |
<msqrt> | @root |
<mroot> | @root |
<mstyle> | @ |
<merror> | @ |
<mpadded> | @ |
<mphantom> | / |
<mfenced> | / |
<menclose> | / |
<msub> | / |
<msup> | @power |
<msubsup> | / |
<munder> | / |
<mover> | / |
<munderover> | / |
<mmultiscripts> | / |
<mtable> | / |
<mlabeledtr> | / |
<mtr> | / |
<mtd> | @ |
<maligngroup> | / |
<malignmark> | / |
<mstack> | / |
<mlongdiv> | / |
<msgroup> | / |
<msrow> | / |
<mscarries> | / |
<mscarry> | / |
<msline> | / |
<maction> | / |
The default intent value for the <math> element creates a new <math> element and processes the presentation child elements to create the content child elements of the result.
<math> <mi>x</mi> </math> --> <math> <ci>x</ci> </math>
The default intent values for the token elements <mi>, <mn>, and <mo> allow the character data within these elements to create content elements <ci>, <cn>, and empty operator elements, respectively. The <mo> element creates an empty operator element using the name found in the operator lookup table for the character data it contains.
<mi>x</mi> --> <ci>x</ci>
<mn>3</mn> --> <cn>3</cn>
<mo>+</mo> --> <plus/>
The default intent values for the token elements <mtext>, <mspace>, and <ms> do not create content elements.
<mtext>Theorem 1</mtext> --> []
<mspace width="2ex"/> --> []
<ms>&</ms> --> []
The default intent value for the <mrow> element processes its child elements to produce an <apply> element whose operator is taken from the <mo> element contained in the row, when that operator is unique, even if it appears multiple times.
<mrow> <mi>x</mi> <mo>+</mo> <mn>3</mn> </mrow> --> <apply> <plus/> <ci>x</ci> <cn>3</cn> </apply>
<mrow> <mn>4</mn> <mo>⁢</mo> <mi>a</mi> <mo>⁢</mo> <mi>c</mi> </mrow> --> <apply> <times/> <cn>4</cn> <ci>a</ci> <ci>c</ci> </apply>
The default intent values for the layout elements <mfrac>, <msqrt>, and <mroot> create <apply> elements using the operators <divide/>, <root/>, and <root/>, respectively, and process the child elements to supply the arguments of the operator.
<mfrac> <mi>x</mi> <mn>3</mn> </mfrac> --> <apply> <divide/> <ci>x</ci> <cn>3</cn> </apply>
<msqrt> <mn>3</mn> </msqrt> --> <apply> <root/> <cn>3</cn> </apply>
<mroot> <mi>x</mi> <mn>3</mn> </mroot> --> <apply> <root/> <ci>x</ci> <cn>3</cn> </apply>
The default intent values for the layout elements <mstyle>, <merror>, and <mpadded> process the child elements of the inferred mrow contained in these elements.
<mstyle> <mi>x</mi> <mo>+</mo> <mn>3</mn> </mstyle> --> <apply> <plus/> <ci>x</ci> <cn>3</cn> </apply>
<merror> <mi>x</mi> <mo>+</mo> <mn>3</mn> </merror> --> <apply> <plus/> <ci>x</ci> <cn>3</cn> </apply>
<mpadded> <mi>x</mi> <mo>+</mo> <mn>3</mn> </mpadded> --> <apply> <plus/> <ci>x</ci> <cn>3</cn> </apply>
The default intent values for the layout elements <mphantom>, <mfenced>, and <menclose> do not create content elements.
<mphantom> <mi>x</mi> <mo>+</mo> <mn>3</mn> </mphantom> --> []
<mfenced> <mi>x</mi> <mo>+</mo> <mn>3</mn> </mfenced> --> []
<menclose> <mi>x</mi> <mo>+</mo> <mn>3</mn> </menclose> --> []
The default intent value for the <msup> script element creates an <apply> element using the <power/> operator, and processes the child elements to supply the arguments of the operator. The default intent values for the other script elements <msub>, <msubsup>, <munder>, <mover>, <munderover>, and <mmultiscripts> do not create content elements.
<msup> <mi>x</mi> <mn>3</mn> </msup> --> <apply> <power/> <ci>x</ci> <cn>3</cn> </apply>
<msub> <mi>x</mi> <mn>3</mn> </msub> --> []
The default intent value for the <mtd> element processes the child elements of the inferred mrow contained in the <mtd>. The default intent values for the other table elements <mtable>, <mlabeledtr>, <mtr>, <maligngroup>, and <malignmark> do not create content elements.
The default intent values for the elementary math elements <mstack>, <mlongdiv>, <msgroup>, <msrow>, <mscarries>, <mscarry>, and <msline> do not create content elements.
The default intent value for the <maction> element does not create content elements.