<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>OpenMath Language Extensions</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Computer Science</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jacobs University http://kwarc.info/kohlhase</string-name>
        </contrib>
      </contrib-group>
      <abstract>
        <p>We propose a language extension mechanism for OpenMath that will allow us to introduce new language features (as have been called for by the community) while keeping the underlying core language intact so that we can maintain compatibility with MathML3 and the upcoming ISO standard. We exhibit the mechanism on the example of extending OpenMath with sequences and discuss other language extensions.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Language Dictionaries have three functions: to
1. extend the syntax admissible in the extended language,
2. specify the meaning of the language extensions, and
3. specify when two objects of the extended language are equal.</p>
      <p>As the OpenMath and MathML speci cations give a RelaxNG schema [CM01] for the syntax,
we do the same in the LED. Following the MathML 3 lead we give the semantics of the \full
language" by translation into the strict core. Note that the rst two functions are addressed at
the user who wants to write meaningful expressions in the extended format. The third function
is only addressed to phrasebook implementors of the extended objects.
3</p>
      <p>An Example Language Extension: Argument Sequences
We now fortify our intuition with a small LED fragment that introduces two extension elements
from [HKR11]. Note that these have been chosen for expository reasons only, in particular, they
do not constitute a concrete extension proposal, that would be based on [CICM1414].
3.1</p>
      <p>Example A Language Extension Dictionary for Sequences</p>
      <p>Listing 1: A LED for sequences
&lt;OMLangExt xmlns=”http://www.openmath.org/OpenMathCD”&gt;
&lt;OLEName&gt;seq&lt;/OLEName&gt;
&lt;OLEDate&gt;2014 04 22&lt;/OLEDate&gt;
&lt;OLEStatus&gt;experimental&lt;/OLEStatus&gt;
&lt;OLEVersion&gt;1&lt;/OLEVersion&gt;
&lt;OLERevision&gt;1&lt;/OLERevision&gt;
&lt;schemaext&gt;</p>
      <p>OMNATS = element OMNATS fomelg
OMNTH = element OMNTH fomel,omelg
omel j= OMNTH j OMNATS
&lt;/schemaext&gt;
&lt;equality&gt;
&lt;OMBIND&gt;
&lt;OMS cd=”quant1” name=”forall”/&gt;
&lt;OMBVAR&gt;&lt;OMV name=”n”/&gt;&lt;OMV name=”m”/&gt;&lt;/OMBVAR&gt;
&lt;OMA&gt;
&lt;OMS cd=”logic1” name=”implies”/&gt;
&lt;OMA&gt;&lt;OMS cd=”relation1” name=”gt”/&gt;&lt;OMV name=”m”/&gt;&lt;OMV name=”n”/&gt;&lt;/OMA&gt;
&lt;OMA&gt;
&lt;OMS cd=”relation1” name=”eq”/&gt;
&lt;OMNTH&gt;
&lt;OMI&gt;n&lt;/OMI&gt;
&lt;OMNATS&gt;&lt;OMI&gt;m&lt;/OMI&gt;&lt;/OMNATS&gt;
&lt;/OMNTH&gt;
&lt;OMI&gt;n&lt;/OMI&gt;
&lt;/OMA&gt;
&lt;/OMA&gt;
&lt;/OMBIND&gt;
&lt;/equality&gt;
&lt;translation cd=”argseq”&gt;
&lt;rule&gt;
&lt;OMNTH&gt;
&lt;expr name=”n”/&gt;
&lt;exprlist name=”seq”&gt;
&lt;expr name=”elt”/&gt;
&lt;/exprlist&gt;
&lt;/OMNTH&gt;
&lt;OMA&gt;
&lt;OMS cd=”seqs” name=”nth”/&gt;
&lt;render name=”n”/&gt;
&lt;iterate name=”seq”&gt;</p>
      <p>&lt;render name=”elt”/&gt;
&lt;/iterate&gt;
&lt;/OMA&gt;
&lt;/rule&gt;
&lt;rule&gt;
&lt;OMNATS&gt;&lt;expr name=”n”/&gt;&lt;/OMNATS&gt;
&lt;OMA&gt;&lt;OMS cd=”seqs” name=”nats”/&gt;&lt;render name=”n”/&gt;&lt;/OMA&gt;
&lt;/rule&gt;
&lt;/translation&gt;
&lt;/OMLangExt&gt;</p>
      <p>The OMLangExt1 element is the top-level element of language de nitions. It contains
metadata that is isomorphic to that of OpenMath CDS and three children for the three functions
mentioned above.
3.1.1 The Schema Extension
The schemaext contains contains RelaxNG rules in compact form that extend the OpenMath 2
schema. In our example, the language of OpenMath objects is extended by two new constructs:
the sequence constructor OMNATS that (given a natural number n) represents the sequence
of the rst n natural numbers starting at zero.
the sequence selector OMNTH takes an OpenMath object representing a natural number n
and a sequence S as arguments and represents the nth element of S (if it exists).
Correspondingly, the schemaExt element contains a rule for both of the elements, an extension
of the OpenMath expressions by OMNTH elements and a new syntactic category omseq that
contains OMNATS elements. From the LED in Listing 1, we can generate RelaxNG schema for
the extended language in Figure 1.</p>
      <p>We probably need to have an extension for OMCDs as well. Maybe we can use a dynamic
extension mechanism, where an OMOBJ speci es what extensions it uses in a special attribute,
which lists the extensions it uses. If we have a list of LEDs supported by OM, then we can
probably compile such a RelaxNG schema from them.
input ”openmath2.rnc”
OMNATS = element OMNATS fomelg
OMNTH = element OMNTH fomel,omseqg
omseq = OMNATS
omel j= OMNTH
3.1.2</p>
      <sec id="sec-1-1">
        <title>Equality</title>
        <p>The equality element contains equality rules that say when two elements in the extended language
are equal expressed as OpenMath elements. Here, we have the relation:
8n:n &gt; m ) nth(nats(n)) = n
(1)
3.1.3</p>
      </sec>
      <sec id="sec-1-2">
        <title>Translation to OpenMath 2</title>
        <p>And nally, the translation element contains rules that allow to translate objects from the
extended language into core OpenMath 2 objects.</p>
        <p>We propose the OMDoc presentation rewriting for translation since it is relatively restricted
and declarative here. But arguably having XSLT for translation would be more
standardsconformant and more powerful { which might or might not be a good thing. In principle any
translation mechanism would work, the concrete choice of a mechanism is an open design choice.
The XSLT for our example is in Figure 3.</p>
        <p>The translation element gives objects in the extended language their meaning by translation
into strict OpenMath 2 (with a special content dictionary argseq speci ed in the cd attribute of
the translation element2; see Listing 2).
&lt;OMNTH&gt;
&lt;OMA&gt;
&lt;OMS cd=”arith1” name=”plus”/&gt;
&lt;OMI&gt;1&lt;/OMI&gt;
&lt;OMI&gt;2&lt;/OMI&gt;
&lt;/OMA&gt;
&lt;OMNATS&gt;&lt;OMI&gt;7&lt;/OMI&gt;&lt;/OMNATS&gt;
&lt;/OMNTH&gt;
(a) A OpenMath object with Sequences
&lt;OMA&gt;
&lt;OMS cd=”argseq” name=”nth”/&gt;
&lt;OMA&gt;
&lt;OMS cd=”arith1” name=”plus”/&gt;
&lt;OMI&gt;1&lt;/OMI&gt;
&lt;OMI&gt;2&lt;/OMI&gt;
&lt;/OMA&gt;
&lt;OMA&gt;
&lt;OMA&gt;
&lt;OMS cd=”argseq” name=”omnats”/&gt;
&lt;OMI&gt;7&lt;/OMI&gt;
&lt;/OMA&gt;
&lt;/OMA&gt;</p>
        <p>(b) Its Translation</p>
        <p>With the LED from Listing 1 we can express OpenMath objects like the one in Figure 2a with
the new OpenMath elements licensed by the language de nition: The sequence selector OMNTH
expects an openmath object (denoting a natural number) as the rst child and a sequence as
the second. The latter is represented by the OMNATS element that represents the sequence of
the rst seven natural numbers.
3.2</p>
        <p>The Corresponding CD
The translation in the LED above uses special symbols from the argseq CD, which we give
in Listing 2. The CD introduces two symbols nth and nats. Note that a full development of
2We probably need to allow multiple CDs here, since we may need combinations. Unfortunately, we do not
have inheritance in CDs, so we need more. But on the other hand, the whole attribute is unnecessary, since we
can just pick up the necessary CDs from the translation objects themselves.
&lt;xsl:template match=”om:OMNTH”&gt;
&lt;om:OMA&gt;
&lt;OMS cd=”argseq” name=”nth”/&gt;
&lt;xsl:apply templates/&gt;
&lt;/om:OMA&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match=”om:OMNATS”&gt;
&lt;om:OMA&gt;
&lt;OMS cd=”argseq” name=”nth”/&gt;
&lt;xsl:apply templates/&gt;
&lt;/om:OMA&gt;
&lt;/xsl:template&gt;
argument sequences would contain more symbols and relations.</p>
        <p>The CMP and FMP elements state mathematical properties that specify the relations between
the symbols, here the strict OpenMath variant of 13</p>
        <p>Listing 2: The CD for the LED in 1
&lt;CD xmlns=”http://www.openmath.org/OpenMathCD”&gt;
&lt;CDComment&gt;</p>
        <p>This CD contains a (part of a) specification of argument sequences
for an OpenMath language extension.
&lt;/CDComment&gt;
&lt;CDName&gt;argseq&lt;/CDName&gt;
&lt;CDBase&gt;http://www.openmath.org/cd&lt;/CDBase&gt;
&lt;CDURL&gt;http://www.openmath.org/cd/argseq.ocd &lt;/CDURL&gt;
&lt;CDReviewDate&gt;2014 03 01&lt;/CDReviewDate&gt;
&lt;CDStatus&gt;experimental&lt;/CDStatus&gt;
&lt;CDDate&gt;2013 10 01&lt;/CDDate&gt;
&lt;CDVersion&gt;0&lt;/CDVersion&gt;
&lt;CDRevision&gt;1&lt;/CDRevision&gt;
&lt;Description&gt;</p>
        <p>This CD defines argument sequences for the use in an OpenMaht3
language extension.
&lt;/Description&gt;
&lt;CDDefinition&gt;
&lt;Name&gt;nth&lt;/Name&gt;
&lt;Role&gt;application&lt;/Role&gt;
&lt;Description&gt;</p>
        <p>This symbol represents the sequence selector. The first argument
is a natural number n and the second an argument sequence S.</p>
        <p>The argument selector returns the n th element in S, if it exits.</p>
        <p>3Here it would be good to have an id attribute on the FMP, so that we can reference it in the LED as a
justi cation.
&lt;/Description&gt;
&lt;/CDDefinition&gt;
&lt;CDDefinition&gt;
&lt;Name&gt;nats&lt;/Name&gt;
&lt;Role&gt;application&lt;/Role&gt;
&lt;Description&gt;</p>
        <p>Given a natural number n, this symbol returns the sequence of the
first n natural numbers (starting at zero).</p>
        <p>&lt;/Description&gt;
&lt;CMP&gt;</p>
        <p>For any natural numbers n and m with m&gt;n, the n th component of nats(m) is n
&lt;/CMP&gt;
&lt;FMP&gt;
&lt;OMOBJ xmlns=”http://www.openmath.org/OpenMath”&gt;
&lt;OMBIND&gt;
&lt;OMS cd=”quant1” name=”forall”/&gt;
&lt;OMBVAR&gt;&lt;OMV name=”n”/&gt;&lt;OMV name=”m”/&gt;&lt;/OMBVAR&gt;
&lt;OMA&gt;
&lt;OMS cd=”logic1” name=”implies”/&gt;
&lt;OMA&gt;&lt;OMS cd=”relation1” name=”gt”/&gt;&lt;OMV name=”m”/&gt;&lt;OMV name=”n”/&gt;&lt;/OMA&gt;
&lt;OMA&gt;
&lt;OMS cd=”relation1” name=”eq”/&gt;
&lt;OMA&gt;
&lt;OMS cd=”argseq” name=”nth”/&gt;
&lt;OMA&gt;&lt;OMS cd=”argseq” name=”nats”/&gt;&lt;OMV name=”n”/&gt;&lt;/OMA&gt;
&lt;/OMA&gt;
&lt;/OMA&gt;
&lt;OMV name=”n”/&gt;
&lt;/OMA&gt;
&lt;/OMBIND&gt;
&lt;/OMOBJ&gt;
&lt;/FMP&gt;
&lt;/CDDefinition&gt;
&lt;/CD&gt;
4</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>Conclusion</title>
      <p>We have sketched an extension mechanism for OpenMath that allows to interpret pragmatic
extensions in terms of a core language using speci c CDs. That would allow use to obtain
OpenMath 3 as a collection of language extensions while retaining OpenMath 2 as a strict core
language { which is important, since it is referenced as a semantic basis of MathML 3 [Aus+10].
The language extension mechanism might be interesting as a tool for formally recast the full
MathML 3 language as a collection of extensions to strict content MathML. This would be a
nice test case for the extension mechanisms expressivity.
[Aus+10]</p>
      <p>Ron Ausbrooks et al. Mathematical Markup Language (MathML) Version 3.0.
W3C Recommendation. World Wide Web Consortium (W3C), 2010. url: http:
//www.w3.org/TR/MathML3.</p>
      <p>Stephen Buswell et al. The Open Math Standard, Version 2.0. Tech. rep. The
OpenMath Society, 2004. url: http://www.openmath.org/standard/om20.</p>
    </sec>
    <sec id="sec-3">
      <title>A A RelaxNG Schema for LEDs</title>
      <p>Here we have a RelaxNG schema for LEDs, note that OLEs are self-referential in the sense
that they already contain the language extensions they introduce, so we have to include a
subschema ext.rnc that is the contents oft he schemaext element. But with this little trick, we can
validate quite nicely.</p>
      <p>Listing 3: The CD for the LED in 1
#
#
# Relax NG Schema for OpenMath Language Extensions
#
#
default namespace = ”http://www.openmath.org/OpenMathCD”
## we include an encapsulated version of the OpenMath Schema
omelorig = grammar finclude ”openmath2.rnc” fstart=omelgg
## and one we extend with the generated extension (extract from the LED in question)
omelext = grammarfinclude ”openmath2.rnc” fstart=omelg include ”ext.rnc”g
## metadata analogous to the one of CDs.</p>
      <p>OLEComment = element OLEComment f text g
OLEName = element OLEName f xsd:NCName g
OLEUses = element OLEUses f OLEName g
OLEURL = element OLEURL f xsd:anyURI g
OLEBase = element OLEBase f xsd:anyURI g
OLEReviewDate = element OLEReviewDate f xsd:date g
OLEDate = element OLEDate f xsd:date g
OLEVersion = element OLEVersion f xsd:nonNegativeInteger g
OLERevision = element OLERevision f xsd:nonNegativeInteger g
OLEStatus = element OLEStatus f ”official” j ”experimental” j ”private” j ”obsolete”g
Description = element Description f text g
## the top level element
start = OMLangExt
OMLangExt =
element OMLangExt f
(OLEComment &amp; Description? &amp;
OLEName &amp; OLEURL? &amp; OLEBase? &amp;
OLEReviewDate? &amp; OLEDate &amp; OLEStatus &amp;
OLEUses? &amp;
OLEVersion &amp; OLERevision),
schemaext, equality, translationg
name.attrib = attribute name fxsd:NCNameg?
exprlist.attribs = name.attrib
exprlist.model = headexp
exprlist = element exprlist fexprlist.attribs &amp; exprlist.modelg
expr.attribs = name.attrib
expr.model = empty
expr = element expr fexpr.attribs &amp; expr.modelg
head.class = exprlist j expr
headexp = grammar finclude ”openmath2.rnc” fstart = omelg
include ”ext.rnc”
omel j= parent head.class
omvar j= parent head.classg
## and now the LED specific elements
schemaext = element schemaext ftextg
equality = element equality fomelext+g
translation = element translation fattribute cd ftextg,rule+g
rule = element rule fheadexp,omelorigg</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [CICM1414]
          <string-name>
            <given-names>Fulya</given-names>
            <surname>Horozal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Michael</given-names>
            <surname>Kohlhase</surname>
          </string-name>
          , and Florian Rabe. \
          <article-title>Flexary Operators for Formalized Mathematics"</article-title>
          . In: Intelligent Computer Mathematics 2014. Ed. by
          <source>Stephan Watt et al. Lecture Notes in Computer Science</source>
          . accepted. Springer,
          <year>2014</year>
          . url: https://svn.kwarc.info/repos/fhorozal/papers/submitted/ cicm14_flex-op.pdf. Forthcoming.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>James</given-names>
            <surname>Clark</surname>
          </string-name>
          and
          <string-name>
            <given-names>Makoto</given-names>
            <surname>Murata. RELAX NG</surname>
          </string-name>
          <article-title>Speci cation</article-title>
          .
          <source>Tech. rep. OASIS, Dec. 3</source>
          ,
          <year>2001</year>
          . url: http://www.relaxng.org/spec-20011203.html.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>Fulya</given-names>
            <surname>Horozal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Michael</given-names>
            <surname>Kohlhase</surname>
          </string-name>
          , and Florian Rabe. \
          <article-title>Extending OpenMath with Sequences"</article-title>
          . In: ed. by A.
          <string-name>
            <surname>Asperti</surname>
          </string-name>
          et al.
          <source>Vol. UBLCS-2011-04</source>
          . Technical Reports of University of Bologna. University of Bologna,
          <year>2011</year>
          , pp.
          <volume>58</volume>
          {
          <fpage>72</fpage>
          . url: http : //kwarc.eecs.iu-bremen.de/frabe/Research/HKR_sequences_11.pdf.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>