Intent: Transformation to Content MathML

Author: Deyan Ginev

Abstract

This note suggests a two-step alogrithm for transforming intent expressions into Content MathML. First, we offer rules to build an operator tree with symbols in the “intent” virtual content dictionary. Second, we suggest a “phrase book” for mapping those operator trees into Full Content MathML.

Preliminaries - The Grammar for intent

This is the December 2022 state of MathML 4’s 5.1.1 The Grammar for intent.

The value of the intent attribute, after ignoring white space between tokens, should match the following grammar.

intent             := concept-or-literal | number | reference | application
concept-or-literal := NCName
number             := '-'? digit+ ( '.' digit+ )?
reference          := '$' NCName
application        := intent hint? '(' arguments? ')'
arguments          := intent ( ',' intent )*
hint               := '@' ( 'prefix' | 'infix' | 'postfix' | 'function' | 'silent' )

Here NCName is as defined in [[xml-names]], and digit is a character in the range 0–9.

Creating an Operator Tree

Starting with an intent expression, we offer a to_content procedure to create an operator tree, via the following list of transformation rules:

The rules are ordered, and should be matched top-first to bottom-last.

intent inputto_content outputExtra Requirement
hintignore
literalignore
concept
<csymbol cd="intent">concept</csymbol>
number
<cn>number</cn>
reference
to_content(ref_target_node)
intent hint? '(' arguments? ')'
ignore "intent" head is a literal,
arguments are all literals
intent hint? '(' arguments? ')'
<apply>
  to_content(intent)
  to_content(argument_1)
  ...
  to_content(argument_n)
</apply>
"intent" head is
concept, reference,
number, compound expression,
or literal different from "_".
_ hint? '('
  (pre_concept_arguments ',')?
  only_concept_argument
  (',' post_arguments)? ')'
<apply>
  to_content(only_concept_argument)
  to_content(pre_concept_arguments_1)
  ...
  to_content(pre_concept_arguments_n)
  to_content(post_concept_arguments_1)
  ...
  to_content(post_concept_arguments_n)
</apply>
"intent" head is the underscore literal,
arguments contain
exactly one concept argument.
_ hint? '(' arguments? ')'
<apply>
  <csymbol cd="intent">narrative-pieces</csymbol>
  to_content(argument_1)
  ...
  to_content(argument_n)
</apply>
"intent" head is the underscore literal,
all other cases

Example transformations to operator trees

intent inputto_content outputExtra Requirement
_@silent
_to
euler-constant
<csymbol cd="intent">euler-constant</csymbol>
0.01
<cn>0.01</cn>
$operator

to_content(<mo arg="operator">+</mo>)
absolute-value($inner)
<apply>
  <csymbol cd="intent">absolute-value</csymbol>
  to_content(<mrow arg="inner">...</mrow>)
</apply>
"intent" head is
concept, reference,
number, compound expression,
or literal different from "_".
$op@infix(1,2,3)
<apply>
  to_content(<mo arg="op">...</mo>)
  <cn>1</cn>
  <cn>2</cn>
  <cn>3</cn>
</apply>
"intent" head is
concept, reference,
number, compound expression,
or literal different from "_".
inverse(f)(x)
<apply>
  <apply>
    <csymbol cd="intent">inverse</csymbol>
    <csymbol cd="intent">f</csymbol>
 </apply>
  <csymbol cd="intent">x</csymbol>
</apply>
"intent" head is
concept, reference,
number, compound expression,
or literal different from "_".
_our_altered_minus(1,2,3)
<apply>
  <csymbol cd="intent">_our_altered_minus</csymbol>
  <cn>1</cn>
  <cn>2</cn>
  <cn>3</cn>
</apply>
"intent" head is
concept, reference,
number, compound expression,
or literal different from "_".
_note(_used,_for,_brevity)
"intent" head is a literal,
arguments are all literals
_(_the, open-interval, _from, $arg1, _to, $arg2)
<apply>
  <csymbol cd="intent">open-interval</csymbol>
  to_content(<msub arg="arg1">...</msub>)
  to_content(<msub arg="arg2">...</msub>)
</apply>
"intent" head is the underscore literal,
arguments contain
exactly one concept argument.
_(_the, open-interval, _from, x, _to, $arg2)
<apply>
  <csymbol cd="intent">narrative-pieces</csymbol>
  <csymbol cd="intent">open-interval</csymbol>
  <csymbol cd="intent">x</csymbol>
  to_content(<mi arg="arg2">...</mi>)
</apply>
"intent" head is the underscore literal,
all other cases

Phrase book to Full Content MathML

The following (partial) map can be used to rewrite the virtual content dictionary trees as Full Content MathML.

It covers the chapter 4.4 Content MathML for Specific Operators and Constants.

Note that there are quite often known aliases for mathematical concepts (in narration, “addition” may be referred to as simply speaking the operator “plus” sign), and they would need to be included inside such phrase books in order to gain coverage (or, alternatively, an external “alias-resolution” mechanism would be needed, maybe provided by an Intent Open list).

intent CD input symbolFull Content MathML output
<csymbol cd="intent">\p{Letter}</csymbol>
<ci>\p{Letter}</ci>
<csymbol cd="intent">plus</csymbol>
<plus/>
<csymbol cd="intent">addition</csymbol>
<plus/>
<csymbol cd="intent">interval</csymbol>
<interval/>
<csymbol cd="intent">inverse</csymbol>
<inverse/>
<csymbol cd="intent">function-composition</csymbol>
<compose/>
<csymbol cd="intent">identity-function</csymbol>
<ident/>
<csymbol cd="intent">domain</csymbol>
<domain/>
<csymbol cd="intent">codomain</csymbol>
<codomain/>
<csymbol cd="intent">image</csymbol>
<image/>
<csymbol cd="intent">piecewise-function</csymbol>
<piecewise/>
<csymbol cd="intent">otherwise</csymbol>
<otherwise/>
<csymbol cd="intent">quotient</csymbol>
<quotient/>
<csymbol cd="intent">factorial</csymbol>
<factorial/>
<csymbol cd="intent">division</csymbol>
<divide/>
<csymbol cd="intent">maximum</csymbol>
<max/>
<csymbol cd="intent">minimum</csymbol>
<min/>
<csymbol cd="intent">subtraction</csymbol>
<minus/>
<csymbol cd="intent">exponentiation</csymbol>
<power/>
<csymbol cd="intent">remainder</csymbol>
<rem/>
<csymbol cd="intent">multiplication</csymbol>
<times/>
<csymbol cd="intent">root</csymbol>
<root/>
<csymbol cd="intent">greatest-common-divisor</csymbol>
<gcd/>
<csymbol cd="intent">and</csymbol>
<and/>
<csymbol cd="intent">or</csymbol>
<or/>
<csymbol cd="intent">exclusive-or</csymbol>
<xor/>
<csymbol cd="intent">not</csymbol>
<not/>
<csymbol cd="intent">implies</csymbol>
<implies/>
<csymbol cd="intent">for-all</csymbol>
<forall/>
<csymbol cd="intent">exists</csymbol>
<exists/>
<csymbol cd="intent">absolute-value</csymbol>
<abs/>
<csymbol cd="intent">complex-conjugate</csymbol>
<conjugate/>
<csymbol cd="intent">argument</csymbol>
<arg/>
<csymbol cd="intent">real-part</csymbol>
<real/>
<csymbol cd="intent">imaginary-part</csymbol>
<imaginary/>
<csymbol cd="intent">lowest-common-multiple</csymbol>
<lcm/>
<csymbol cd="intent">floor</csymbol>
<floor/>
<csymbol cd="intent">ceiling</csymbol>
<ceiling/>
<csymbol cd="intent">equals</csymbol>
<eq/>
<csymbol cd="intent">not-equals</csymbol>
<neq/>
<csymbol cd="intent">greater-than</csymbol>
<gt/>
<csymbol cd="intent">less-than</csymbol>
<lt/>
<csymbol cd="intent">greater-than-or-equal</csymbol>
<geq/>
<csymbol cd="intent">less-than-or-equal</csymbol>
<leq/>
<csymbol cd="intent">equivalent</csymbol>
<equivalent/>
<csymbol cd="intent">approximately</csymbol>
<approx/>
<csymbol cd="intent">factor-of</csymbol>
<factorof/>
<csymbol cd="intent">integral</csymbol>
<int/>
<csymbol cd="intent">differentiation</csymbol>
<diff/>
<csymbol cd="intent">partial-differentiation</csymbol>
<partialdiff/>
<csymbol cd="intent">divergence</csymbol>
<divergence/>
<csymbol cd="intent">gradient</csymbol>
<grad/>
<csymbol cd="intent">curl</csymbol>
<curl/>
<csymbol cd="intent">laplacian</csymbol>
<laplacian/>
<csymbol cd="intent">set</csymbol>
<set/>
<csymbol cd="intent">list</csymbol>
<list/>
<csymbol cd="intent">union</csymbol>
<union/>
<csymbol cd="intent">intersect</csymbol>
<intersect/>
<csymbol cd="intent">set-inclusion</csymbol>
<in/>
<csymbol cd="intent">set-exclusion</csymbol>
<notin/>
<csymbol cd="intent">subset</csymbol>
<subset/>
<csymbol cd="intent">proper-subset</csymbol>
<prsubset/>
<csymbol cd="intent">not-subset</csymbol>
<notsubset/>
<csymbol cd="intent">not-proper-subset</csymbol>
<notprsubset/>
<csymbol cd="intent">set-difference</csymbol>
<setdiff/>
<csymbol cd="intent">cardinality</csymbol>
<card/>
<csymbol cd="intent">cartesian-product</csymbol>
<cartesianproduct/>
<csymbol cd="intent">sum</csymbol>
<sum/>
<csymbol cd="intent">product</csymbol>
<product/>
<csymbol cd="intent">limits</csymbol>
<limit/>
<csymbol cd="intent">tends-to</csymbol>
<tendsto/>
<csymbol cd="intent">sine</csymbol>
<sin/>
<csymbol cd="intent">cosine</csymbol>
<cos/>
<csymbol cd="intent">tangent</csymbol>
<tan/>
<csymbol cd="intent">secant</csymbol>
<sec/>
<csymbol cd="intent">cosecant</csymbol>
<csc/>
<csymbol cd="intent">cotangent</csymbol>
<cot/>
<csymbol cd="intent">arcsine</csymbol>
<arcsin/>
<csymbol cd="intent">arccosine</csymbol>
<arccos/>
<csymbol cd="intent">arctangent</csymbol>
<arctan/>
<csymbol cd="intent">arcsecant</csymbol>
<arcsec/>
<csymbol cd="intent">arccosecant</csymbol>
<arccsc/>
<csymbol cd="intent">arccotangent</csymbol>
<arccot/>
<csymbol cd="intent">hyperbolic-sine</csymbol>
<sinh/>
<csymbol cd="intent">hyerpbolic-cosine</csymbol>
<cosh/>
<csymbol cd="intent">hyperbolic-tangent</csymbol>
<tanh/>
<csymbol cd="intent">hyperbolic-secant</csymbol>
<sech/>
<csymbol cd="intent">hyperbolic-cosecant</csymbol>
<csch/>
<csymbol cd="intent">hyperbolic-cotangent</csymbol>
<coth/>
<csymbol cd="intent">hyperbolic-arcsine</csymbol>
<arcsinh/>
<csymbol cd="intent">hyperbolic-arccosine</csymbol>
<arccosh/>
<csymbol cd="intent">hyperbolic-arctangent</csymbol>
<arctanh/>
<csymbol cd="intent">hyperbolic-arcsecant</csymbol>
<arcsech/>
<csymbol cd="intent">hyperbolic-arccosecant</csymbol>
<arccsch/>
<csymbol cd="intent">hyperbolic-arccotangent</csymbol>
<arccoth/>
<csymbol cd="intent">exponential-function</csymbol>
<exp/>
<csymbol cd="intent">natural-logarithm</csymbol>
<ln/>
<csymbol cd="intent">logarithm</csymbol>
<log/>
<csymbol cd="intent">mean</csymbol>
<mean/>
<csymbol cd="intent">standard-deviation</csymbol>
<sdev/>
<csymbol cd="intent">variance</csymbol>
<variance/>
<csymbol cd="intent">median</csymbol>
<median/>
<csymbol cd="intent">mode</csymbol>
<mode/>
<csymbol cd="intent">moment</csymbol>
<moment/>
<csymbol cd="intent">vector</csymbol>
<vector/>
<csymbol cd="intent">matrix</csymbol>
<matrix/>
<csymbol cd="intent">determinant</csymbol>
<determinant/>
<csymbol cd="intent">transpose</csymbol>
<transpose/>
<csymbol cd="intent">selector</csymbol>
<selector/>
<csymbol cd="intent">vector-product</csymbol>
<vectorproduct/>
<csymbol cd="intent">scalar-product</csymbol>
<scalarproduct/>
<csymbol cd="intent">outer-product</csymbol>
<outerproduct/>
<csymbol cd="intent">integer-numbers</csymbol>
<integers/>
<csymbol cd="intent">real-numbers</csymbol>
<reals/>
<csymbol cd="intent">rational-numbers</csymbol>
<rationals/>
<csymbol cd="intent">natural-numbers</csymbol>
<naturalnumbers/>
<csymbol cd="intent">complex-numbers</csymbol>
<complexes/>
<csymbol cd="intent">prime-numbers</csymbol>
<primes/>
<csymbol cd="intent">euler-constant</csymbol>
<exponentiale/>
<csymbol cd="intent">imaginary-unit</csymbol>
<imaginaryi/>
<csymbol cd="intent">not-a-number</csymbol>
<notanumber/>
<csymbol cd="intent">true</csymbol>
<true/>
<csymbol cd="intent">false</csymbol>
<false/>
<csymbol cd="intent">empty-set</csymbol>
<emptyset/>
<csymbol cd="intent">pi</csymbol>
<pi/>
<csymbol cd="intent">euler-gamma</csymbol>
<eulergamma/>
<csymbol cd="intent">infinity</csymbol>
<infinity/>

Phrasebook Caveat

Note that this table only covers a selection of the simplest leaf-to-leaf mapping and remains silent on all tree-to-tree structural issues, such as: