<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet  type="text/xsl" href="pmathml.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://www.w3.org/1998/Math/MathML" xml:space="preserve">


<head>
<title>The OpenMath Standard</title>

<style>
p {text-align:justify;	   
  }
code {font-size: 125%;
      font-family: monospace; 
     }
.figure {
border-width:1px;
border-color: black;
}
.footnote{
font-size: 75%;
font-style: italic;
}
.delliteral {
font-size: 75%;
background-color: #cfcfcf;
border-color: black;
border-style: solid;
border-width: 1px;
padding: 1em;
color: red;
text-decoration: line-through;
}
.newliteral {
font-size: 75%;
background-color: #cfcfcf;
border-color: black;
border-style: solid;
border-width: 1px;
padding: 1em;
color: green;
}
.literal {
font-size: 75%;
background-color: #cfcfcf;
border-color: black;
border-style: solid;
border-width: 1px;
padding: 1em;
}
.del {
color: red;
text-decoration: line-through;
}
.new {
color: green;
}
.chg {
color: blue;
}
.changetoc {
border-style: solid;
border-color: black;
border-width: 1px;
margin: 2em 2em 2em 2em;
background-color: yellow;
}

.lowerroman {
list-style-type: lower-roman;
}
</style>
</head>
<body>
<h1>The <i>OpenMath</i> Standard</h1>
<div>
Version: 2.0 Public Draft 6c (11 May 2004)
</div>

<div>
The OpenMath Society
</div>

<div>Editors<br/>
S. Buswell, O. Caprotti, D. P. Carlisle, M. C. Dewar, M. Gaetano, M. Kohlhase
</div>

<div>
May 2004
</div>

<div>© 2000&#8211;2004 The OpenMath Society</div>

<div>
<h3>Abstract</h3>
<p class="del">This document proposes <i>OpenMath</i> as a standard for the communication of
  semantically rich mathematical objects. This draft of the <i>OpenMath</i> 
  standard comprises the following: a description of <i>OpenMath</i> objects, the
  grammar of <acronym>XML</acronym> and of the binary encoding of objects, a
  description of Content Dictionaries and an <acronym>XML</acronym> document type
  definition for validating Content Dictionaries. The non-normative
  <a href="#cha_his">Chapter </a> of this document briefly overviews the history
  of <i>OpenMath</i>.</p><p class="new">This document describes version 2 of
<i>OpenMath</i>: a standard for
the representation and communication of mathematical objects.  <i>OpenMath</i>
allows the <i>meaning</i> of an object to be encoded
rather than just a visual representation.  It is designed to allow the
free exchange of mathematical objects between software systems and human
beings.  On the worldwide web it is designed to allow mathematical
expressions embedded in web pages to be manipulated and computed with in
a meaningful and correct way.  It is designed to be machine-generatable
and machine-readable, rather than written by hand.
</p><p class="new">The <i>OpenMath</i> Standard is the official reference for
the <i>OpenMath</i> language and has been approved by the <i>OpenMath</i> Society.  It is not
intended as an introductory document or a user's guide, for the latest
available material of this nature please consult the <i>OpenMath</i> web-site at
<a href="http://www.openmath.org">http://www.openmath.org</a>.</p><p class="new">This document includes an overview of the
<i>OpenMath</i> architecture, an abstract description of <i>OpenMath</i> objects and two
mechanisms for producing concrete encodings of such objects.  The first,
in <acronym>XML</acronym>, is designed primarily for use on the web, in documents, and
for applications which want to mix <i>OpenMath</i> as a content representation with
MathML as a presentation format.  The second, a binary format, is
designed for applications which wish to exchange very large objects, or
a lot of data as efficiently as possible.  This document also includes a
description of Content Dictionaries - the mechanism by which the meaning
of a symbol in the <i>OpenMath</i> language is encoded, as well as an XML encoding
for them.  Finally it includes guidelines for the development of
<i>OpenMath</i>-compliant applications.</p>
</div>


<div class="changetoc">
<h3>Change-marked edition notes</h3>
<p>
This edition contains colour coded change markings
relative to the OpenMath 1.0 document...</p>
<ul>
<li class="new">New text is marked with css class "new" (green).</li>
<li class="del">Deleted text is marked with css class "del" (red).</li>
</ul>

<p>Sections with modified text</p>


<span>

<a href="#sec_hist" class="new">
.1 <span>
History
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_omsoc" class="new">
.2 <span>
<i>OpenMath</i> Society
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_om-arch" class="new">
1.1 <span>
<i>OpenMath</i> Architecture
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_intro-obj" class="new">
1.2 <span>
<i>OpenMath</i> Objects and Encodings
</span>
</a>
</span>
<br/>











<span>
 
<a href="#sec_basic" class="new">
2.1.1 <span>
Basic <i>OpenMath</i> objects
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_derived" class="new">
2.1.2 <span>
Derived <i>OpenMath</i> Objects
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_compound" class="new">
2.1.3 <span>
<span class="del">Compound</span><i>OpenMath</i> Objects
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_roles" class="new">
2.1.4 <span>
<i>OpenMath</i> Symbol Roles
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_omin" class="new">
2.2 <span>
Further Description of <i>OpenMath</i> Objects
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_names" class="new">
2.3 <span>
Names
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_summary" class="new">
2.4 <span>
Summary
</span>
</a>
</span>
<br/>





<span>
 
<a href="#ssec_xml" class="new">
3.1.1 <span>
A <span class="del">Grammar</span><span>Schema</span> for the <acronym>XML</acronym> Encoding
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_xml-desc" class="new">
3.1.2 <span>
<span class="new">Informal</span> description of
the <span class="del">Grammar</span><span class="new"><acronym>XML</acronym> Encoding</span>
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_references" class="new">
3.1.3 <span>
Some Notes on References
</span>
</a>
</span>
<br/>



<span>
  
<a href="#sec_acyclicity" class="new">
3.1.3.1 <span>
An Acyclicity Constraint
</span>
</a>
</span>
<br/>



<span>
  
<a href="#sec_sharing_bvars" class="new">
3.1.3.2 <span>
Sharing and Bound Variables
</span>
</a>
</span>
<br/>



<span>
 
<a href="#xmldoc" class="new">
3.1.4 <span>
Embedding <i>OpenMath</i> in <acronym>XML</acronym> Documents
</span>
</a>
</span>
<br/>





<span>
 
<a href="#sec_binary_grammar" class="new">
3.2.1 <span>
A Grammar for the Binary Encoding
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_bin-desc" class="new">
3.2.2 <span>
Description of the Grammar
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_bin_example" class="new">
3.2.3 <span>
Example of Binary Encoding
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_both_sharing" class="new">
3.2.4 <span>
Sharing
</span>
</a>
</span>
<br/>



<span>
  
<a href="#sec_sharing" class="new">
3.2.4.1 <span>
Sharing <span class="new">in Objects beginning with the identifier [24]</span>
</span>
</a>
</span>
<br/>



<span>
  
<a href="#sec_sharing_references" class="new">
3.2.4.2 <span>
Sharing with References (beginning with [24+64])
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_impl_note" class="new">
3.2.5 <span>
Implementation Note
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_relation_OM1_binary" class="new">
3.2.6 <span>
Relation to the <i>OpenMath</i> 1 binary encoding
</span>
</a>
</span>
<br/>





<span>

<a href="#sec_cd_summary" class="new">
4.1 <span>
Introduction
</span>
</a>
</span>
<br/>



<span>

<a href="#sect_func" class="new">
4.2 <span>
Abstract Content Dictionaries
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_status" class="new">
4.2.1 <span>
Content Dictionary Status
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_version" class="new">
4.2.2 <span>
Content Dictionary Version Numbers
</span>
</a>
</span>
<br/>



<span>

<a href="#sec_xml_cd" class="new">
4.3 <span>
The <span class="del"><acronym>XML</acronym></span><span class="new">Reference</span> Encoding for Content Dictionaries
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sec_cd_schema" class="new">
4.3.1 <span>
The Relax NG Schema for Content Dictionaries
</span>
</a>
</span>
<br/>





<span>
 
<a href="#sect_pcdata" class="new">
4.3.2 <span>
Further <span class="del">Requirements of an <i>OpenMath</i>
Content Dictionary</span><span class="new">Description of
the CD Schema</span>
</span>
</a>
</span>
<br/>



<span>

<a href="#addfiles" class="new">
4.4 <span>
Additional Information
</span>
</a>
</span>
<br/>



<span>
 
<a href="#sigfiles" class="new">
4.4.1 <span>
Signature
<span class="del">Files</span><span class="new">Dictionaries</span>

</span>
</a>
</span>
<br/>





<span>
  
<a href="#sect_sigpcdata" class="new">
4.4.1.1 <span>
<span class="del">Further
Requirements</span><span class="new">Abstract Specification</span>
 of a Signature Dictionary
</span>
</a>
</span>
<br/>



<span>
  
<a href="#sect_sigschema" class="new">
4.4.1.2 <span>
A Relax NG Schema for a Signature File
</span>
</a>
</span>
<br/>







<span>
  
<a href="#sec_dtd_cdg" class="new">
4.4.2.1 <span>
The Specification of CDGroups
</span>
</a>
</span>
<br/>



<span>
  
<a href="#sect_cdgpcdata" class="new">
4.4.2.2 <span>
Further Requirements of a CDGroup
</span>
</a>
</span>
<br/>







<span>
 
<a href="#sec_compl_xml_encoding" class="new">
5.1.1 <span>
The XML Encoding
</span>
</a>
</span>
<br/>









<span>

<a href="#sec_compl_cd" class="new">
5.3 <span>
Content Dictionaries
</span>
</a>
</span>
<br/>


































</div>





  
<h2>Contents</h2><a href="#cha_his"> <i>OpenMath</i> Movement</a><br/>
    <a href="#sec_hist">.1 History</a><br/>
    <a href="#sec_omsoc">.2 <i>OpenMath</i> Society</a><br/><a href="#cha_int">1 Introduction to <i>OpenMath</i></a><br/>
    <a href="#sec_om-arch">1.1 <i>OpenMath</i> Architecture</a><br/>
    <a href="#sec_intro-obj">1.2 <i>OpenMath</i> Objects and Encodings</a><br/>
    <a href="#sec_intro-cd">1.3 Content Dictionaries</a><br/>
    <a href="#sec_addnfiles">1.4 Additional Files</a><br/>
    <a href="#sec_phrasebooks">1.5 Phrasebooks</a><br/><a href="#cha_obj">2 <i>OpenMath</i> Objects</a><br/>
    <a href="#sec_omabs">2.1 Formal Definition of <i>OpenMath</i> Objects</a><br/>
        <a href="#sec_basic">2.1.1 Basic <i>OpenMath</i> objects</a><br/>
        <a href="#sec_derived" class="new">2.1.2 Derived <i>OpenMath</i> Objects</a><br/>
        <a href="#sec_compound">2.1.3 <span class="del">Compound</span><i>OpenMath</i> Objects</a><br/>
        <a href="#sec_roles" class="new">2.1.4 <i>OpenMath</i> Symbol Roles</a><br/>
    <a href="#sec_omin">2.2 Further Description of <i>OpenMath</i> Objects</a><br/>
    <a href="#sec_names" class="new">2.3 Names</a><br/>
    <a href="#sec_summary">2.4 Summary</a><br/><a href="#cha_enco">3 <i>OpenMath</i> Encodings</a><br/>
    <a href="#sec_xml">3.1 The <acronym>XML</acronym> Encoding</a><br/>
        <a href="#ssec_xml">3.1.1 A <span class="del">Grammar</span><span>Schema</span> for the <acronym>XML</acronym> Encoding</a><br/>
        <a href="#sec_xml-desc">3.1.2 <span class="new">Informal</span> description of
the <span class="del">Grammar</span><span class="new"><acronym>XML</acronym> Encoding</span></a><br/>
        <a href="#sec_references" class="new">3.1.3 Some Notes on References</a><br/>
            <a href="#sec_acyclicity" class="new">3.1.3.1 An Acyclicity Constraint</a><br/>
            <a href="#sec_sharing_bvars" class="new">3.1.3.2 Sharing and Bound Variables</a><br/>
        <a href="#xmldoc">3.1.4 Embedding <i>OpenMath</i> in <acronym>XML</acronym> Documents</a><br/>
    <a href="#sec_binary">3.2 The Binary Encoding</a><br/>
        <a href="#sec_binary_grammar">3.2.1 A Grammar for the Binary Encoding</a><br/>
        <a href="#sec_bin-desc">3.2.2 Description of the Grammar</a><br/>
        <a href="#sec_bin_example">3.2.3 Example of Binary Encoding</a><br/>
        <a href="#sec_both_sharing">3.2.4 Sharing</a><br/>
            <a href="#sec_sharing">3.2.4.1 Sharing <span class="new">in Objects beginning with the identifier [24]</span></a><br/>
            <a href="#sec_sharing_references" class="new">3.2.4.2 Sharing with References (beginning with [24+64])</a><br/>
        <a href="#sec_impl_note">3.2.5 Implementation Note</a><br/>
        <a href="#sec_relation_OM1_binary" class="new">3.2.6 Relation to the <i>OpenMath</i> 1 binary encoding</a><br/>
    <a href="#sec_enc_summary">3.3 Summary</a><br/><a href="#cha_cd">4 Content Dictionaries</a><br/>
    <a href="#sec_cd_summary">4.1 Introduction</a><br/>
    <a href="#sect_func">4.2 Abstract Content Dictionaries</a><br/>
        <a href="#sec_status" class="new">4.2.1 Content Dictionary Status</a><br/>
        <a href="#sec_version" class="new">4.2.2 Content Dictionary Version Numbers</a><br/>
    <a href="#sec_xml_cd">4.3 The <span class="del"><acronym>XML</acronym></span><span class="new">Reference</span> Encoding for Content Dictionaries</a><br/>
        <a href="#sec_cd_schema" class="new">4.3.1 The Relax NG Schema for Content Dictionaries</a><br/>
        <a href="#sec_dtd_cd" class="del"> The DTD Specification of  Content Dictionaries</a><br/>
        <a href="#sect_pcdata">4.3.2 Further <span class="del">Requirements of an <i>OpenMath</i>
Content Dictionary</span><span class="new">Description of
the CD Schema</span></a><br/>
    <a href="#addfiles">4.4 Additional Information</a><br/>
        <a href="#sigfiles">4.4.1 Signature
<span class="del">Files</span><span class="new">Dictionaries</span>
</a><br/>
            <a href="#sec_dtd_sig" class="del"> The  DTD Specification of Signature Files</a><br/>
            <a href="#sect_sigpcdata">4.4.1.1 <span class="del">Further
Requirements</span><span class="new">Abstract Specification</span>
 of a Signature Dictionary</a><br/>
            <a href="#sect_sigschema" class="new">4.4.1.2 A Relax NG Schema for a Signature File</a><br/>
            <a href="#sect_sigex">4.4.1.3 Examples</a><br/>
        <a href="#ssec_cdgroups">4.4.2 CDGroups</a><br/>
            <a href="#sec_dtd_cdg">4.4.2.1 The Specification of CDGroups</a><br/>
            <a href="#sect_cdgpcdata">4.4.2.2 Further Requirements of a CDGroup</a><br/>
    <a href="#cdapprove">4.5 Content Dictionaries Reviewing Process</a><br/><a href="#cha_comp">5 <i>OpenMath</i> Compliance</a><br/>
    <a href="#sec_compl_encoding">5.1 Encodings</a><br/>
        <a href="#sec_compl_xml_encoding" class="new">5.1.1 The XML Encoding</a><br/>
            <a href="#sec_compl_xml_encoding_val">5.1.1.1 Generating Valid XML</a><br/>
            <a href="#sec_compl_xml_encoding_float">5.1.1.2 Decimal versus Hexadecimal Float Representation</a><br/>
    <a href="#sec_compl_omforeign">5.2 <i>OpenMath</i> Foreign Objects</a><br/>
    <a href="#sec_compl_cd">5.3 Content Dictionaries</a><br/>
    <a href="#sec_comp_lex">5.4 Lexical Errors</a><br/>
    <a href="#sec_compl_om1">5.5 <i>OpenMath</i> 1 Objects</a><br/><a href="#cha_conc"> Conclusion</a><br/><a href="#app_cdfiles">A CD Files</a><br/>
    <a href="#app_cdcd">A.1 The <b>meta</b> Content Dictionary</a><br/>
    <a href="#arith1.ocd">A.2 The  <b>arith1</b> Content Dictionary File</a><br/>
    <a href="#arith1.sts">A.3 The  <b>arith1</b> STS Signature File</a><br/>
    <a href="#mathml.cdg">A.4 The  <b>MathML</b> CDGroup</a><br/>
    <a href="#errorcd">A.5 The <b>error</b> Content Dictionary</a><br/><a href="#app_openmath.rng">B <i>OpenMath</i> Schema in Relax NG XML Syntax (Normative)</a><br/><a href="#app_relaxrestricted">C Restricting the <i>OpenMath</i> Schema (Non-Normative)</a><br/><a href="#app_xsd">D <i>OpenMath</i> Schema in XSD Syntax (Non-Normative)</a><br/><a href="#app_dtd">E <i>OpenMath</i> DTD (Non-Normative)</a><br/><a href="#app_whats_new">F Changes between <i>OpenMath</i> 1.1 and <i>OpenMath</i> 2 (Non-Normative)</a><br/>
    <a href="#chgformal">F.1 Changes to the Formal Definition of Objects</a><br/>
    <a href="#chgenc">F.2 Changes to the encodings</a><br/>
    <a href="#chgcd">F.3 Changes to Content Dictionaries</a><br/><a href="#bibliography">G Bibliography</a><br/>
<h2>List of Figures</h2><a href="#fig_om">2.1 The <i>OpenMath</i> Architecture</a><br/><a href="#fig_obj">3.1 The <i>OpenMath</i> application and binding objects for
<m:math><m:mi>sin</m:mi> <m:mo>(</m:mo><m:mi>x</m:mi> <m:mo>)</m:mo></m:math> and
<m:math><m:mi>&#955;</m:mi> <m:mi>x</m:mi><m:mo>.</m:mo><m:mi>x</m:mi> <m:mo>+</m:mo>
<m:mn>2</m:mn></m:math> in tree-like notation.</a><br/><a href="#fig_shared_vs_unshared">4.1 Shared vs. unshared representations</a><br/><a href="#fig_sharing_between" class="new">4.2 Sharing between <i>OpenMath</i> objects (A cycle of order <m:math><m:mn>2</m:mn></m:math>.</a><br/><a href="#fig_bin-enc">4.3 Grammar of the binary encoding of <i>OpenMath</i> objects.</a><br/><a href="#fig_bin-enc_stream">4.4 Streaming a large Integer in the Binary Encoding.</a><br/><a href="#fig_bin-enc_ex">4.5 A Simple example of the <i>OpenMath</i> binary encoding.</a><br/><a href="#fig_bin-enc2" class="new">4.6 A binary encoding of the <i>OpenMath</i> object from <a href="#fig_shared_vs_unshared">Figure 4.1</a>.</a><br/><a href="#fig_cd-dtd" class="del"> DTD Specification of  Content Dictionaries</a><br/><a href="#fig_omcdsig.dtd" class="del"> DTD Specification of Signature Files</a><br/><a href="#fig_cdgroup.dtd">5.1 <span class="del">DTD</span><span class="new">Relax NG</span> Specification of CDGroups</a><br/>

<h2 name="cha_his" id="cha_his">
  Chapter <br/><i>OpenMath</i> Movement</h2>


<p>This chapter is a historical account of <i>OpenMath</i> and should be regarded
as non-normative.</p>

<p><i>OpenMath</i> is a standard for representing mathematical objects,
allowing them to be exchanged between computer programs, stored in
databases, or published on the worldwide web.  While the original
designers were mainly developers of computer algebra systems, it
<span class="del">is now attracting</span>
<span class="new">has since attracted</span>
interest from other areas of scientific computation and
from many publishers of electronic documents with a significant
mathematical content.  There is a strong relationship to the MathML
recommendation <a href="#MathML_2003">[15]</a> from the Worldwide Web
Consortium, and a large overlap between the two developer communities.
MathML deals principally with the <i>presentation</i> of
mathematical objects, while <i>OpenMath</i> is solely concerned with their
semantic meaning or <i>content</i>.  While MathML does
have some limited facilities for dealing with content, it also allows
semantic information encoded in <i>OpenMath</i> to be embedded inside a MathML
structure.  Thus the two technologies may be seen as highly
complementary.</p>

<div><h3 name="sec_hist" id="sec_hist">.1 History</h3>


<p><i>OpenMath</i> was originally developed through a series of workshops held
in Zurich (1993 and 1996), Oxford (1994), Amsterdam (1995), Copenhagen
(1995), Bath (1996), Dublin (1996), Nice (1997), Yorktown Heights
(1997), Berlin (1998), and Tallahassee (1998).  The participants in
these workshops formed a global <i>OpenMath</i> community which was coordinated
by a Steering Committee and operated through electronic mailing groups
and ad-hoc working parties.  This loose arrangement has been
formalised through the establishment of an <i>OpenMath</i> Society.  Up until the
end of 1996 much of the work of the community was funded through a
grant from the Human Capital and Mobility program of the European
Union, 
<span class="new"> and by</span>
the contributions of several institutions and individuals.  A
document outlining the objectives and basic design of <i>OpenMath</i> was
produced (later published as
<a href="#Abbott_Leeuwen_Strotmann_98">[]</a>).  By the end of 1996
a simplified specification had been agreed upon and some prototype
implementations had come about
<a href="#Dalmas_Gaetano_Watt_97">[]</a>.</p>

<p>In 1996 a group of European participants in <i>OpenMath</i> decided to bid
for funding under the European Union's Fourth Framework Programme for
strategic research in information technology.  This bid was successful
and the project started in late 1997.  The principal aims of the
project were to formalise <i>OpenMath</i> as a standard and to develop it
further through industrial applications; this process led to the
OpenMath 1.0 and 1.1 standards which were endorsed at
workshops in Tallahassee (November 1998) and Eindhoven (June
1999).</p>

<p class="new">In November 1998 the <i>OpenMath</i> Society was established to coordinate
all <i>OpenMath</i> activities. The society is based in Helsinki, Finland and is
coordinated by the executive committee whose members are elected by the
society. The official web page of the society is
<a href="http://www.openmath.org">http://www.openmath.org</a>.</p>

<p class="new">In 2001 the European Union agreed to fund a Thematic Network
under its Fifth Framework programme to coordinate further work on
<i>OpenMath</i> and MathML, and in particular to support a further series of workshops.  
This document is one outcome of that project, and seeks to update <i>OpenMath</i>
in the light of recent developments in XML and of the <i>OpenMath</i> community's
collective experience working with the old standard.</p>
</div>

<div><h3 name="sec_omsoc" id="sec_omsoc">.2 <i>OpenMath</i> Society</h3>


<p class="del">In November 1998 the <i>OpenMath</i> Society has been established to coordinate
all <i>OpenMath</i> activities. The society is based in Helsinki, Finland and is
steered by the executive committee whose members are elected by the
society. The official web page of the society is
<a href="http://www.openmath.org">http://www.openmath.org</a>.</p>

<p class="new">The <i>OpenMath</i> Society continues to provide
long-term coordination of <i>OpenMath</i> activities.  Membership is open to
anybody who is active in <i>OpenMath</i>; for further details see the web-site
at 
<a href="http://www.openmath.org/society/index.html">
http://www.openmath.org/society/index.html</a>.</p>

</div>



<h2 name="cha_int" id="cha_int">
  Chapter 1<br/>Introduction to <i>OpenMath</i></h2>





<p>This chapter briefly introduces <i>OpenMath</i> concepts and notions that are
referred to in the rest of this document.</p>

<div><h3 name="sec_om-arch" id="sec_om-arch">1.1 <i>OpenMath</i> Architecture</h3>



<div class="figure"><a name="fig_om" id="fig_om"/>
    
    <img src="om-arch.png" alt="om-arch.png"/>
<div>
  Figure 2.1 The <i>OpenMath</i> Architecture</div></div>

<p>The architecture of <i>OpenMath</i> is described in <a href="#fig_om">Figure 2.1</a> and summarizes the interactions among the different
<i>OpenMath</i> components.  There are three layers of representation of a
mathematical object <a href="#OM_98">[]</a>. The first is
a  private layer that
is the internal representation used by an application.  The second is
an abstract layer that is the representation as an <i>OpenMath</i> object.
<span class="new">Note that these
two layers may, in some cases, be the same.</span>
The third is a
communication layer that translates the <i>OpenMath</i> object representation into
a stream of bytes. An application dependent program manipulates the
mathematical objects using its internal representation, it can convert
them to <i>OpenMath</i> objects and communicate them by using the byte stream
representation of <i>OpenMath</i> objects.</p>
</div>

<div><h3 name="sec_intro-obj" id="sec_intro-obj">1.2 <i>OpenMath</i> Objects and Encodings</h3>



<p><i>OpenMath</i> objects are representations of mathematical entities that
can be communicated among various software applications in a
meaningful way, that is, preserving their
<span>"semantics"</span>.</p>

<p><i>OpenMath</i> objects and encodings are described in detail in <a href="#cha_obj">Chapter 2</a> and <a href="#cha_enco">Chapter 3</a>.</p>


<p>The standard endorses two encodings in <acronym>XML</acronym> and binary
formats.
<span class="new">At the time of writing, these are the encodings
supported by most existing <i>OpenMath</i> tools and applications,</span>
<span class="del"> These are the encodings supported by 
the official <i>OpenMath</i> libraries</span>
however they are not the only possible encodings of <i>OpenMath</i>
objects. Users who wish to define their own encoding
<span class="del">using some other
specific language (e.g. Lisp) may</span>
<span class="new">, are free to</span>
do so provided that there is
<span class="del">an
effective translation from this encoding to an official one
</span>
<span class="new">a well-defined correspondence
between the new encoding and the abstract model defined in <a href="#cha_obj">Chapter 2</a>. </span>
</p>

</div>

<div><h3 name="sec_intro-cd" id="sec_intro-cd">1.3 Content Dictionaries</h3>



<p>Content Dictionaries (CDs) are used to assign informal and formal
semantics to all symbols used in the <i>OpenMath</i> objects. They define the
symbols used to represent concepts arising in a particular area of
mathematics.</p>

<p>The Content Dictionaries are public, they represent the actual
common knowledge among <i>OpenMath</i> applications.  Content Dictionaries fix
the <span>"meaning"</span> of objects independently of the
application.  The application receiving the object may then recognize
whether or not, according to the semantics of the symbols defined in
the Content Dictionaries, the object can be transformed to the
corresponding internal representation used by the application.</p>
</div>

<div><h3 name="sec_addnfiles" id="sec_addnfiles">1.4 Additional Files</h3>
 
<p>Several
additional files are related to Content Dictionaries.  Signature files
contain the signatures of symbols defined in some <i>OpenMath</i> Content
Dictionary and their format is endorsed by this standard.</p>

<p>Furthermore, the standard fixes how to define a specific
set of Content Dictionaries as a CDGroup.</p>

<p>Auxiliary files that define presentation and rendering or that
are used for manipulating and processing Content Dictionaries are not
discussed by the standard.</p>

</div>
<div><h3 name="sec_phrasebooks" id="sec_phrasebooks">1.5 Phrasebooks</h3>




<p>The conversion of an <i>OpenMath</i> object to/from the internal
representation in a software application is performed by an interface
program called a <i>Phrasebook</i>. The translation is
governed by the Content Dictionaries and the specifics of the
application. It is envisioned that a software application dealing with
a specific area of mathematics declares which Content Dictionaries it
understands. As a consequence, it is expected that the Phrasebook of
the application is able to translate <i>OpenMath</i> objects built using symbols
from these Content Dictionaries to/from the internal mathematical
objects of the application.
</p>

 <p><i>OpenMath</i> objects do not
specify any computational behaviour, they merely represent mathematical
expressions.  Part of the <i>OpenMath</i> philosophy is to leave it to the
application to decide what it does with an object once it has received
it.  <i>OpenMath</i> is not a query or programming language. Because of this,
<i>OpenMath</i> does not prescribe a way of forcing <span>"evaluation"</span> or
<span>"simplification"</span> of objects like
<m:math><m:mn>2</m:mn><m:mo>+</m:mo><m:mn>3</m:mn></m:math> or
<m:math><m:mi>sin</m:mi><m:mo>(</m:mo><m:mi>&#960;</m:mi><m:mo>)</m:mo></m:math>. Thus,
the same object <m:math><m:mn>2</m:mn><m:mo>+</m:mo><m:mn>3</m:mn></m:math> could be
transformed to <m:math><m:mn>5</m:mn></m:math> by a computer algebra system,
or displayed as <m:math><m:mn>2</m:mn><m:mo>+</m:mo><m:mn>3</m:mn></m:math> by a
typesetting tool.</p>
</div>


<h2 name="cha_obj" id="cha_obj">
  Chapter 2<br/><i>OpenMath</i> Objects</h2>




<p>In this chapter we provide a self-contained description of <i>OpenMath</i>
objects. We first do so by means of an abstract grammar
description (<a href="#sec_omabs">Section 2.1</a>)
and then give a more informal description (<a href="#sec_omin">Section 2.2</a>).</p>


<div><h3 name="sec_omabs" id="sec_omabs">2.1 Formal Definition of <i>OpenMath</i> Objects</h3>



<p><i>OpenMath</i> represents mathematical objects as terms or as labelled
trees that are called <i>OpenMath</i> objects or <i>OpenMath</i> expressions. The definition
of an abstract <i>OpenMath</i> object is then the following.</p>


<div><h4 name="sec_basic" id="sec_basic">2.1.1 Basic <i>OpenMath</i> objects</h4>
 <p>The Basic <i>OpenMath</i> Objects form
the leaves of the <i>OpenMath</i> Object tree.  A Basic <i>OpenMath</i> Object is of one of
the following.</p> 
<ul>
<li><p><span>(i)</span> Integer.</p><p>Integers in
  the mathematical sense, with no predefined range.  They are
  <span>"infinite precision"</span> integers (also called
  <span>"bignums"</span> in computer algebra).</p></li>
<li><p><span>(ii)</span> <acronym>IEEE</acronym> floating point
    number.</p><p>Double precision floating-point numbers
    following the <acronym>IEEE</acronym> 754-1985
    standard <a href="#ieee754_85">[6]</a>.</p></li>
<li><p><span>(iii)</span> Character string.</p><p>A Unicode Character string. This also corresponds to `characters' in
  <acronym>XML</acronym>.</p></li>
<li><p><span>(iv)</span> Bytearray.</p><p>A sequence of bytes.</p></li>
<li><p><span>(v)</span> Symbol.</p><p class="del">A Symbol
encodes two fields of information, a <i>name</i> and a
<i>Content Dictionary</i>. Each is a sequence of
characters matching a regular expression, as described below.</p><p class="new">A Symbol encodes three fields of
    information, a <i>symbol name</i>, a <i>Content
    Dictionary name</i>, and (optionally) a <i>Content
    Dictionary base URI</i>, The name of a symbol is a sequence
    of characters matching the regular expression described in <a href="#sec_names">Section 2.3</a>.  The Content Dictionary is the location of
    the definition of the symbol, consisting of a name (a sequence of
    characters matching the regular expression described in <a href="#sec_names">Section 2.3</a>) and, optionally, a unique prefix called a
    <i>cdbase</i> which is used to disambiguate multiple
    Content Dictionaries of the same name.  There are other properties
    of the symbol that are not explicit in these fieleds but whose
    values may be obtained by inspecting the Content Dictionary
    specified. these include the symbol definition, formal properties
    and examples and, optionally, a <i>Role</i> which is
    a restriction on where the symbol may appear in an <i>OpenMath</i> object.  The
    possible roles are described in <a href="#sec_roles">Section 2.1.4</a>.
    </p></li>
<li><p><span>(vi)</span> Variable.</p><p>A Variable <span class="del">consists of</span>
<span class="new">must have</span> a
<i>name</i> which is a sequence of characters matching a
regular expression, as described in <a href="#sec_names">Section 2.3</a>.
</p></li>
</ul>
</div>

<div class="new"><h4 name="sec_derived" id="sec_derived">2.1.2 Derived <i>OpenMath</i> Objects</h4>


<p>Derived <i>OpenMath</i> objects are currently used as a way by which non-<i>OpenMath</i>
data is embedded inside an <i>OpenMath</i> object.
A derived <i>OpenMath</i> object is built as follows: 
<ul>
<li><p><span>(i)</span> If <m:math><m:mi>A</m:mi></m:math> is
<i>not</i> an <i>OpenMath</i> object, then <m:math><m:mi mathvariant="bold">foreign</m:mi><m:mfenced><m:mi>A</m:mi></m:mfenced></m:math> is an <i>OpenMath</i>
<i>foreign object</i>.  An <i>OpenMath</i> foreign object may optionally
have an <i>encoding</i> field which describes how its contents
should be interpreted.</p></li>
</ul>
</p>
</div>

<div><h4 name="sec_compound" id="sec_compound">2.1.3 <span class="del">Compound</span><i>OpenMath</i> Objects</h4>

  
<p><i>OpenMath</i> objects are built recursively as follows.
<ul>
<li><p><span>(i)</span> Basic <i>OpenMath</i> objects are <i>OpenMath</i> objects.
(<span class="new">Note that derived <i>OpenMath</i> objects are
<i>not</i> <i>OpenMath</i> objects, but are used to construct <i>OpenMath</i>
objects as described below.)</span></p></li>

<li><p>
    <span>(ii)</span> If
    <m:math><m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub></m:math>,
    <span>&#8230;</span>,
    <m:math><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub></m:math>     <m:math><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>&gt;</m:mo><m:mn>0</m:mn><m:mo>)</m:mo></m:math>     are <i>OpenMath</i> objects, then
  <m:math display="block">
  <m:mi mathvariant="bold">application</m:mi><m:mo>(</m:mo><m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo> <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub><m:mo>)</m:mo>
  </m:math>
  is an <i>OpenMath</i> <i>application object</i>.</p></li> <li><p><span>(iii)</span> If
  <m:math><m:msub><m:mi>S</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo>
  <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub></m:math>   are <i>OpenMath</i> symbols, and
<span class="del">
<m:math><m:mi>A</m:mi></m:math>,
  <m:math><m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub></m:math>,
  <span>&#8230;</span>, <m:math><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub></m:math>, <m:math><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>&gt;</m:mo><m:mn>0</m:mn><m:mo>)</m:mo></m:math> are <i>OpenMath</i> objects, then
</span>
<span class="new">
<m:math><m:mi>A</m:mi></m:math> is an <i>OpenMath</i> object, and
  <m:math><m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub></m:math>,
  <span>&#8230;</span>, <m:math><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub></m:math> <m:math><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>&gt;</m:mo><m:mn>0</m:mn><m:mo>)</m:mo></m:math> are <i>OpenMath</i> objects or <i>OpenMath</i> derived objects, then
</span>

  <m:math display="block"><m:mi mathvariant="bold">attribution</m:mi>
  <m:mo>(</m:mo><m:mi>A</m:mi><m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mn>1</m:mn></m:msub>
  <m:mspace width=".3em"/> <m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo>
  <m:mspace width=".3em"/> <m:mi>&#8230;</m:mi> <m:mspace width=".3em"/>
  <m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub> <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub><m:mo>)</m:mo></m:math> is an <i>OpenMath</i>
  <i>attribution object</i>.
  </p><p>
  <span class="del">and</span> <m:math><m:mi>A</m:mi></m:math>   is the object <i>stripped of attributions</i>. <span class="new">
  <m:math><m:msub><m:mi>S</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo>
  <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub></m:math>   are referred to as <i>keys</i> and
  <m:math><m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub></m:math>,
  <span>&#8230;</span>,
  <m:math><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub></m:math> as their associated
  <i>values</i></span>.
  <span class="del">The operation of recursively
  applying stripping to the stripped object is called
  <i>flattening of the attribution</i>.

                  When the stripped object after flattening is a
  variable, the attributed object is called <i>attributed
  variable</i>.</span>
  <span class="new">If, after  recursively
  applying stripping to remove attributions, the resulting
  un-attributed object is a 
  variable, the original attributed object is called an <i>attributed
  variable</i>.</span>
  </p></li>

<li><p><span>(iv)</span> If <m:math><m:mi>B</m:mi></m:math> and
  <m:math><m:mi>C</m:mi></m:math> are <i>OpenMath</i> objects, and
  <m:math><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub></m:math>,
  <m:math><m:mi>&#8230;</m:mi></m:math>,
  <m:math><m:msub><m:mi>v</m:mi><m:mi>n</m:mi></m:msub></m:math>   <m:math><m:mo>(</m:mo><m:mi>n</m:mi> <m:mo>&#8805;</m:mo>
  <m:mn>0</m:mn><m:mo>)</m:mo></m:math> are <i>OpenMath</i> variables or attributed
  variables, then
  <m:math display="block">
  <m:mi mathvariant="bold">binding</m:mi> <m:mo>(</m:mo><m:mi>B</m:mi><m:mo>,</m:mo> <m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo> <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>v</m:mi><m:mi>n</m:mi></m:msub><m:mo>,</m:mo> <m:mi>C</m:mi><m:mo>)</m:mo>
  </m:math>
is an <i>OpenMath</i> <i>binding object</i>.</p></li>
<li><p><span>(v)</span> If <m:math><m:mi>S</m:mi></m:math> is an
<i>OpenMath</i> symbol and <m:math><m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub></m:math>,
<span>&#8230;</span>,
<m:math><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub></m:math> <m:math><m:mo>(</m:mo><m:mi>n</m:mi> <m:mo>&#8805;</m:mo>
<m:mn>0</m:mn><m:mo>)</m:mo></m:math> are <i>OpenMath</i> objects <span class="new">or
<i>OpenMath</i> derived objects</span>, then <m:math display="block"><m:mi mathvariant="bold">error</m:mi>
<m:mo>(</m:mo><m:mi>S</m:mi><m:mo>,</m:mo>
<m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:mi>&#8230;</m:mi><m:mo>,</m:mo><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub><m:mo>)</m:mo>
  </m:math>
  is an <i>OpenMath</i> <i>error object</i>.</p></li>
</ul>
</p>
</div>

<div class="new"><h4 name="sec_roles" id="sec_roles">2.1.4 <i>OpenMath</i> Symbol Roles</h4>


<p>
We say that an <i>OpenMath</i> symbol is used to <i>construct</i>
an <i>OpenMath</i> object if it is the first child of an <i>OpenMath</i> application,
binding or error object, or an even-indexed child of an <i>OpenMath</i>
attribution object (i.e. the <i>key</i> in a
<i>(key, value)</i> pair).
The <i>role</i> of an <i>OpenMath</i> symbol is a restriction
on how it may be used to construct a compound <i>OpenMath</i> object and, in the
case of the key in an attribution object, a clarification of how that
attribution should be interpreted.  Possible roles are:
<ol class="lowerroman">

<li><p><i>binder</i> The symbol may 
appear as the first child of an <i>OpenMath</i> binding object.
</p></li>

<li><p> <i>attribution</i> The symbol may 
be used as key in an <i>OpenMath</i> attribution object, i.e. as the first
element of a (key, value) pair, or in an equivalent context (for example
to refer to the value of an attribution).  This form of attribution
may be ignored by an application, so should be used for information
which does not change the meaning of the attributed <i>OpenMath</i> object.
</p></li> 

<li><p> <i>semantic-attribution</i> This is the
same as <i>attribution</i> except that it modifies the
meaning of the attributed <i>OpenMath</i> object and thus cannot be ignored by an
application.  </p></li> 

<li><p> <i>error</i> The symbol can appear
as the first child of an <i>OpenMath</i> error object.  </p></li>

<li><p> <i>application</i> The symbol can appear
as the first child of an <i>OpenMath</i> application object.  </p></li>

<li><p> <i>constant</i> The symbol cannot be
used to construct an <i>OpenMath</i> compound object.

</p></li>

</ol>

A symbol cannot have more than one role and 
cannot be used to construct a compound <i>OpenMath</i> object in a way
which requires a different role (using the definition of construct given
earlier in this section).
This means that one cannot use a symbol which binds some variables to
construct, say, an application object.  However it does not prevent
the use of that symbol as an <i>argument</i> in an
application object (where by argument we mean a child with index
greater than 1). 
</p>

<p> 
If no role is indicated then the symbol can be used anywhere.  Note
that this is not the same as saying that the symbol's role is
<i>constant</i>.
</p>


</div>

</div>
<div><h3 name="sec_omin" id="sec_omin">2.2 Further Description of <i>OpenMath</i> Objects</h3>




  

<p>Informally, an <i>OpenMath</i> <span><i>object</i></span> can be
viewed as a tree and is also referred to as a term.  The objects at
the leaves of <i>OpenMath</i> trees are called <span><i>basic
objects</i></span>.  The basic objects supported by <i>OpenMath</i> are:
<dl>
<dt>Integer</dt><dd><p>Arbitrary Precision
integers.</p> </dd>
<dt>Float</dt><dd> <p><i>OpenMath</i> floats are
<acronym>IEEE</acronym> 754 Double precision floating-point
numbers. Other types of floating point number may be encoded in <i>OpenMath</i>
by the use of suitable content dictionaries.</p>
  
</dd>

<dt>Character strings</dt><dd><p>are
  sequences of characters. These characters come from the Unicode
  standard <a href="#UNICODE">[10]</a>.</p>
  
</dd>
<dt>Bytearrays</dt><dd><p>are sequences of
bytes. There is no <span>"byte"</span> in <i>OpenMath</i> as an object of its
own. However, a single byte can of course be represented by a
bytearray of length 1.  The difference between strings and bytearrays
is the following: a character string is a sequence of bytes with a
fixed interpretation (as characters, Unicode texts may require several
bytes to code one character), whereas a bytearray is an uninterpreted
sequence of bytes with no intrinsic meaning.  Bytearrays could be used
inside <i>OpenMath</i> errors to provide information to, for example, a debugger;
they could also contain intermediate results of calculations, or
`handles' into computations or databases.</p>
</dd>

<dt>Symbols</dt><dd>
  
  
  <p>
 are uniquely defined by the Content Dictionary in which they occur
  and by a name.
<span class="del">In definition in <a href="#sec_omabs">Section 2.1</a> we have
  left this information implicit. However, it should be kept in mind
  that all symbols appearing in an <i>OpenMath</i> object are defined in a
  Content Dictionary.
</span>The form of these definitions is explained in
  <a href="#cha_cd">Chapter 4</a>.  Each symbol has no more than one
  definition in a Content Dictionary. Many Content Dictionaries may
  define differently a symbol with the same name (e.g. the symbol
  <small><code>union</code></small> is defined as
  associative-commutative set theoretic union in a Content Dictionary
  <small><code>set1</code></small> but another Content Dictionary,
  <small><code>multiset1</code></small> might define a symbol
  <small><code>union</code></small> as the union of multi-sets).
<span class="del">The name
  of a symbol can only contain alphanumeric characters and
  underscores.  More precisely, a symbol name matches the following
  regular expression:</span>
<blockquote class="del"><p>
  [<small><code>A</code></small>-<small><code>Z</code></small><small><code>a</code></small>-<small><code>z</code></small>]
  [<small><code>A</code></small>-<small><code>Z</code></small><small><code>a</code></small>-<small><code>z</code></small><small><code>0</code></small>-<small><code>9</code></small><small><code>_</code></small>]*
  </p></blockquote>
  <span class="del">Notice that these symbol names are case sensitive.  <i>OpenMath</i>
  <i>recommends</i> that symbol names should be no longer than
  100 characters.</span>
</p>
  
 
  </dd>

<dt>Variables</dt><dd><p>are meant to
  denote parameters, variables or indeterminate (such as bound
  variables of function definitions, variables in summations and
  integrals, independent variables of derivatives).  <span class="del">Plain variable names are restricted to use a
  subset of the printable ASCII characters.  Formally the names must
  match the regular expression:</span> <blockquote class="del"><p>
  [A-Za-z0-9=+(),-./:?!#$%*;=@[]^_`{|}]+ </p></blockquote>
</p>
</dd>

</dl> </p>


<p class="new">Derived <i>OpenMath</i> objects are constructed from
non-<i>OpenMath</i> data.  They differ from bytearrays in that they can have any
structure.  Currently there is only one way of making a derived <i>OpenMath</i>
object.</p>

<dl class="new">
<dt>Foreign</dt><dd><p>is used to import a
non-<i>OpenMath</i> object into an <i>OpenMath</i> attribution.  Examples of its use could
be to annotate a formula with a visual or aural rendering, an
animation etc.  They may also appear in <i>OpenMath</i> error objects, for
example to allow an application to report an error in processing such
an object.  
</p>
</dd>

</dl>


<p>The four following constructs can be used to make compound
 <i>OpenMath</i> objects <span class="new"> out of basic or derived <i>OpenMath</i>
objects</span>.</p>
<dl>
<dt>Application</dt><dd><p>constructs an
  <i>OpenMath</i> object from a sequence of one or more <i>OpenMath</i> objects. The first
  argument of an application is referred to as its <span>"head"</span> while
  the remaining objects are called its <span>"arguments"</span>.  An <i>OpenMath</i>
  application object can be used to convey the mathematical notion of
  application of a function to a set of arguments.  For instance,
  suppose that the <i>OpenMath</i> symbol <m:math><m:mi>sin</m:mi></m:math> is defined in
  a <span class="new">suitable</span> Content Dictionary,
  <span class="del">for trigonometry</span> then <m:math><m:mi mathvariant="bold">application</m:mi><m:mo>(</m:mo><m:mi>sin</m:mi><m:mo>,</m:mo>
  <m:mi>x</m:mi> <m:mo>)</m:mo></m:math> is the abstract <i>OpenMath</i> object
  corresponding to <m:math><m:mi>sin</m:mi> <m:mo>(</m:mo><m:mi>x</m:mi>
  <m:mo>)</m:mo></m:math>.  More generally, an <i>OpenMath</i> application object can
  be used as a constructor to convey a mathematical object built from
  other objects such as a polynomial constructed from a set of
  monomials.  Constructors build inhabitants of some symbolic type,
  for instance the type of rational numbers or the type of
  polynomials.  The rational number, usually denoted as
  <m:math><m:mn>1</m:mn><m:mo>/</m:mo><m:mn>2</m:mn></m:math>, is represented by the
  <i>OpenMath</i> application object <m:math><m:mi mathvariant="bold">application</m:mi><m:mo>(</m:mo><m:mi>Rational</m:mi><m:mo>,</m:mo>
  <m:mn>1</m:mn><m:mo>,</m:mo> <m:mn>2</m:mn><m:mo>)</m:mo></m:math>. The symbol
  <m:math><m:mi>Rational</m:mi></m:math> must be defined, by a Content
  Dictionary, as a constructor symbol for the rational numbers.</p>
   
<div class="figure"><a name="fig_obj" id="fig_obj"/>
      <img src="lambda.png" alt="lambda.png"/>
<div>
  Figure 3.1 The <i>OpenMath</i> application and binding objects for
<m:math><m:mi>sin</m:mi> <m:mo>(</m:mo><m:mi>x</m:mi> <m:mo>)</m:mo></m:math> and
<m:math><m:mi>&#955;</m:mi> <m:mi>x</m:mi><m:mo>.</m:mo><m:mi>x</m:mi> <m:mo>+</m:mo>
<m:mn>2</m:mn></m:math> in tree-like notation.</div></div>

  
</dd>

<dt>Binding</dt><dd><p>objects are
  constructed from an <i>OpenMath</i> object, and from a sequence of zero or more
  variables followed by another <i>OpenMath</i> object.  The first <i>OpenMath</i> object is
  the <span>"binder"</span> object. Arguments 2 to
  <m:math><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:math> are always variables to
  be bound in the <span>"body"</span> which is the
  <m:math><m:msup><m:mi>n</m:mi><m:mi>th</m:mi></m:msup></m:math> argument object. It
  is allowed to have no bound variables, but the binder object and the
  body should be present. Binding can be used to express functions or
  logical statements.  The function <m:math><m:mi>&#955;</m:mi>
  <m:mi>x</m:mi><m:mo>.</m:mo><m:mi>x</m:mi> <m:mo>+</m:mo><m:mn>2</m:mn></m:math>, in which
  the variable <m:math><m:mi>x</m:mi></m:math> is bound by
  <m:math><m:mi>&#955;</m:mi></m:math>, corresponds to a binding object having
  as binder the <i>OpenMath</i> symbol <m:math><m:mi>lambda</m:mi></m:math>: <m:math display="block"><m:mi mathvariant="bold">binding</m:mi><m:mo>(</m:mo><m:mi>lambda</m:mi><m:mo>,</m:mo>
  <m:mi>x</m:mi> <m:mo>,</m:mo> <m:mi mathvariant="bold">application</m:mi><m:mo>(</m:mo><m:mi>plus</m:mi><m:mo>,</m:mo>
  <m:mi>x</m:mi> <m:mo>,</m:mo>
  <m:mn>2</m:mn><m:mo>)</m:mo><m:mo>)</m:mo><m:mtext>.</m:mtext></m:math></p>
  
  
  


<p>Phrasebooks are allowed to use <m:math><m:mi>&#945;</m:mi></m:math>   conversion in order to avoid clashes of variable names. Suppose an
  object <m:math><m:mi>&#937;</m:mi></m:math> contains an occurrence of the
  object <m:math><m:mi mathvariant="bold">binding</m:mi>
  <m:mo>(</m:mo><m:mi>B</m:mi> <m:mo>,</m:mo> <m:mi>v</m:mi> <m:mo>,</m:mo> <m:mi>C</m:mi>
  <m:mo>)</m:mo></m:math>.  This object <m:math><m:mi mathvariant="bold">binding</m:mi> <m:mo>(</m:mo><m:mi>B</m:mi> <m:mo>,</m:mo>
  <m:mi>v</m:mi> <m:mo>,</m:mo> <m:mi>C</m:mi> <m:mo>)</m:mo></m:math> can be replaced
  in <m:math><m:mi>&#937;</m:mi></m:math> by <m:math><m:mi mathvariant="bold">binding</m:mi> <m:mo>(</m:mo><m:mi>B</m:mi> <m:mo>,</m:mo>
  <m:mi>z</m:mi> <m:mo>,</m:mo> <m:mi>C'</m:mi><m:mo>)</m:mo></m:math> where
  <m:math><m:mi>z</m:mi></m:math> is a variable not occurring free in
  <m:math><m:mi>C</m:mi></m:math> and <m:math><m:mi>C'</m:mi></m:math> is obtained
  from <m:math><m:mi>C</m:mi></m:math> by replacing each free (i.e., not bound
  by any intermediate <b>binding</b> construct) occurrence
  of <m:math><m:mi>v</m:mi></m:math> by <m:math><m:mi>z</m:mi></m:math>.  This
  operation preserves the semantics of the object
  <m:math><m:mi>&#937;</m:mi></m:math>. In the above example, a phrasebook is
  thus allowed to transform the object to, e.g.  <m:math revisionflag="deleted" display="block"><m:mi mathvariant="bold">binding</m:mi>
  <m:mo>(</m:mo><m:mi>lambda</m:mi><m:mo>,</m:mo> <m:mi>v</m:mi> <m:mo>,</m:mo> <m:mi mathvariant="bold">binding</m:mi> <m:mo>(</m:mo><m:mi>lambda</m:mi><m:mo>,</m:mo>
  <m:mi>z</m:mi> <m:mo>,</m:mo><m:mi mathvariant="bold">application</m:mi>
  <m:mo>(</m:mo><m:mi>times</m:mi><m:mo>,</m:mo><m:mi>z</m:mi>
  <m:mo>,</m:mo><m:mi>z</m:mi><m:mo>)</m:mo><m:mo>)</m:mo><m:mo>)</m:mo><m:mtext>.</m:mtext></m:math>
  <m:math revisionflag="added" display="block"><m:mi mathvariant="bold">binding</m:mi><m:mo>(</m:mo><m:mi>lambda</m:mi><m:mo>,</m:mo>
  <m:mi>z</m:mi> <m:mo>,</m:mo> <m:mi mathvariant="bold">application</m:mi><m:mo>(</m:mo><m:mi>plus</m:mi><m:mo>,</m:mo>
  <m:mi>z</m:mi> <m:mo>,</m:mo>
  <m:mn>2</m:mn><m:mo>)</m:mo><m:mo>)</m:mo><m:mtext>.</m:mtext></m:math>
</p>
<p>Repeated occurrences of the same variable in a binding operator
  are allowed. An <i>OpenMath</i> application should treat a binding with
  multiple occurrences of the same variable as equivalent to the
  binding in which all but the last occurrence of each variable is
  replaced by a new variable which does not occur free in the body of
  the binding.  <m:math display="block"><m:mi mathvariant="bold">binding</m:mi> <m:mo>(</m:mo><m:mi>lambda</m:mi><m:mo>,</m:mo>
  <m:mi>v</m:mi> <m:mo>,</m:mo> <m:mi>v</m:mi> <m:mo>,</m:mo><m:mi mathvariant="bold">application</m:mi>
  <m:mo>(</m:mo><m:mi>times</m:mi><m:mo>,</m:mo><m:mi>v</m:mi>
  <m:mo>,</m:mo><m:mi>v</m:mi><m:mo>)</m:mo> <m:mo>)</m:mo></m:math> is semantically
  equivalent to: <m:math display="block"><m:mi mathvariant="bold">binding</m:mi> <m:mo>(</m:mo><m:mi>lambda</m:mi> <m:mo>,</m:mo>
  <m:msup><m:mi>v</m:mi><m:mo>'</m:mo></m:msup> <m:mo>,</m:mo> <m:mi>v</m:mi>
  <m:mo>,</m:mo><m:mi mathvariant="bold">application</m:mi>
  <m:mo>(</m:mo><m:mi>times</m:mi><m:mo>,</m:mo><m:mi>v</m:mi>
  <m:mo>,</m:mo><m:mi>v</m:mi><m:mo>)</m:mo> <m:mo>)</m:mo></m:math> so that the
  resulting function is actually a constant in its first argument
  (<m:math><m:msup><m:mi>v</m:mi><m:mo>'</m:mo></m:msup></m:math> does not occur free
  in the body <m:math><m:mi mathvariant="bold">application</m:mi>
  <m:mo>(</m:mo><m:mi>times</m:mi><m:mo>,</m:mo><m:mi>v</m:mi>
  <m:mo>,</m:mo><m:mi>v</m:mi><m:mo>)</m:mo> <m:mo>)</m:mo></m:math>).</p>

  
</dd>

<dt>Attribution</dt><dd><p>decorates an
  object with a sequence of one or more pairs made up of an <i>OpenMath</i>
  symbol, the <span>"attribute"</span>, and an associated <span class="del"><i>OpenMath</i></span> object, the <span>"value of the
  attribute"</span>.  The value of the attribute can be an <span class="new"><i>OpenMath</i></span> attribution object itself. As an
  example of this, consider the <i>OpenMath</i> objects representing groups,
  automorphism groups, and group dimensions. It is then possible to
  attribute an <i>OpenMath</i> object representing a group by its automorphism
  group, itself attributed by its dimension.</p>

<p class="new">
<i>OpenMath</i> objects can be attributed with <i>OpenMath</i> foreign objects, which are
containers for non-<i>OpenMath</i> structures.  For example a mathematical
expression could be attributed with its spoken or visual rendering.
</p>

<p>Composition of attributions, as in
  <m:math display="block">
<m:mi mathvariant="bold">attribution</m:mi><m:mo>(</m:mo><m:mi mathvariant="bold">attribution</m:mi><m:mo>(</m:mo><m:mi>A</m:mi><m:mo>,</m:mo>
  <m:msub><m:mi>S</m:mi><m:mn>1</m:mn></m:msub> <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:mi>&#8230;</m:mi><m:mo>,</m:mo><m:msub><m:mi>S</m:mi><m:mi>h</m:mi></m:msub>
  <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mi>h</m:mi></m:msub><m:mo>)</m:mo><m:mo>,</m:mo>
  <m:msub><m:mi>S</m:mi><m:mrow><m:mi>h</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
  <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mrow><m:mi>h</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub><m:mo>,</m:mo>
  <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub> <m:mspace width=".3em"/> <m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub><m:mo>)</m:mo></m:math> is
  semantically equivalent to a single attribution, that is <m:math display="block"><m:mi mathvariant="bold">attribution</m:mi><m:mo>(</m:mo><m:mi>A</m:mi><m:mo>,</m:mo>
  <m:msub><m:mi>S</m:mi><m:mn>1</m:mn></m:msub> <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo>
  <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mi>h</m:mi></m:msub> <m:mspace width=".3em"/> <m:msub><m:mi>A</m:mi><m:mi>h</m:mi></m:msub><m:mo>,</m:mo>
  <m:msub><m:mi>S</m:mi><m:mrow><m:mi>h</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
  <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mrow><m:mi>h</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub><m:mo>,</m:mo>
  <m:mi>&#8230;</m:mi><m:mo>,</m:mo> <m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub> <m:mspace width=".3em"/>
  <m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub><m:mo>)</m:mo><m:mtext>.</m:mtext></m:math>
  The operation that produces an object with a single layer of
  attribution is called <i>flattening</i>.</p>

<p>Multiple attributes with the same name are allowed.  While the
  order of the given attributes does not imply any notion of priority,
  potentially it could be significant. For instance, consider the case
  in which <m:math><m:msub><m:mi>S</m:mi><m:mi>h</m:mi></m:msub> <m:mo>=</m:mo>
  <m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub></m:math> (<m:math><m:mi>h</m:mi>
  <m:mo>&lt;</m:mo> <m:mi>n</m:mi></m:math>) in the example above. Then, the
  object is to be interpreted as if the value
  <m:math><m:msub><m:mi>A</m:mi><m:mi>n</m:mi></m:msub></m:math> overwrites the value
  <m:math><m:msub><m:mi>A</m:mi><m:mi>h</m:mi></m:msub></m:math>.  (<i>OpenMath</i> however does
  not mandate that an application preserves the attributes or their
  order.)</p>

<p class="new">Attribution acts as either adornment
  annotation or as semantical annotation. When the key has role
  <i>attribution</i>, then replacement of the
  attributed object by the object itself is not harmful and preserves
  the semantics. When the key has role
  <i>semantic-attribution</i> then the attributed
  object is modified by the attribution and cannot be viewed as
  semantically equivalent to the stripped object. If the attribute
  lacks the role specification then attribution is acting as adornment
  annotation.
  </p>


<p>Objects can be decorated in a multitude of ways.
<span class="del">In <a href="#OMD132b">[3]</a>, typing of <i>OpenMath</i> objects is
expressed by using an attribution.
</span>
<span class="new">An example of the use of an adornment attribution
would be to indicate the colour in which an <i>OpenMath</i> object should be
displayed, for example <m:math><m:mi mathvariant="bold">attribution</m:mi><m:mo>(</m:mo><m:mi>A</m:mi><m:mo>,</m:mo>
<m:mi>colour</m:mi> <m:mspace width=".3em"/> <m:mi>red</m:mi> <m:mo>)</m:mo></m:math>.
Note that both <m:math><m:mi>A</m:mi></m:math> and <m:math><m:mi>red</m:mi></m:math> are <i>OpenMath</i>
objects.
An example of the use of a semantic attribution would be to indicate the
type of an object.  For example</span>
the object <m:math><m:mi mathvariant="bold">attribution</m:mi><m:mo>(</m:mo><m:mi>A</m:mi><m:mo>,</m:mo>
<m:mi>type</m:mi> <m:mspace width=".3em"/> <m:mi>t</m:mi> <m:mo>)</m:mo></m:math> represents the judgment stating that object <m:math><m:mi>A</m:mi></m:math> has type <m:math><m:mi>t</m:mi></m:math>. Note that both
<m:math><m:mi>A</m:mi></m:math> and <m:math><m:mi>t</m:mi></m:math> are <i>OpenMath</i>
objects.</p>


<p class="del">Attribution can act as either annotation,
  in the sense of adornment, or as modifier. In the former case,
  replacement of the adorned object by the object itself is probably
  not harmful (preserves the semantics). In the latter case however,
  it may very well be.  Therefore, attribution in general should by
  default be treated as a construct rather than as adornment. Only
  when the CD definitions of the attributes make it clear that they
  are adornments, can the attributed object be viewed as semantically
  equivalent to the stripped object.</p>

            
  
  
</dd>

<dt>Error</dt><dd><p>is made up of an <i>OpenMath</i>
  symbol and a sequence of zero or more <i>OpenMath</i> objects. This object has
  no direct mathematical meaning.  Errors occur as the result of some
  treatment on an <i>OpenMath</i> object and are thus of real interest only when
  some sort of communication is taking place. Errors may occur inside
  other objects and also inside other errors.  Error objects might
  consist only of a symbol as in the object: <m:math><m:mi mathvariant="bold">error</m:mi> <m:mo>(</m:mo><m:mi>S</m:mi>
  <m:mo>)</m:mo></m:math>.</p> 
</dd>

</dl> 
</div>

<div class="new"><h3 name="sec_names" id="sec_names">2.3 Names</h3>


<p>The names of symbols, variables and content dictionaries must
conform to the production <small><code>Name</code></small> specified in the following
grammar
(which is identical to that for <acronym>XML</acronym> names in XML 1.1,
<a href="#xml_04">[14]</a>). Informally speaking, a name is a sequence
of Unicode <a href="#UNICODE">[10]</a>
characters which begins with a letter and cannot contain
certain punctuation and combining  characters.  The notation
<small><code>#x...</code></small> represents the hexadecimal value of 
the encoding of a Unicode character. 
Some of the character values or <i>code points</i> in the
following productions are currently unassigned, but this is
likely to change in the future as Unicode evolves<sup><a href="#xml1">*1</a></sup>.

</p><p class="footnote"><a name="xml1"/><sup>*1</sup>
We note that in XML 1 the name production explicitly listed 
the characters that were allowed, so all the characters added in
versions of Unicode after 2.0 (which amounted to tens of thousands of
characters) were not allowed in names.
</p>

<blockquote>
<table>
<tr>
<td>Name </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> NameStartChar (NameChar)* </td>
</tr>
<tr>
<td>NameStartChar</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td>  ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |</td></tr>
<tr><td/><td/><td>[#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] |</td></tr>
<tr><td/><td/><td>[#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |</td></tr>
<tr><td/><td/><td>[#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |</td></tr>
<tr><td/><td/><td>[#x10000-#xEFFFF] 
</td>
</tr>
<tr>
<td>NameChar</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td>  NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] |</td></tr>
<tr><td/><td/><td>[#x203F-#x2040] </td>
</tr>
</table>
</blockquote>


<p><b>CD Base</b>  A cdbase must conform to the grammar for URIs described in
<a href="#IETF2396">[7]</a>.  Note that if non-ASCII characters are
used in a CD or symbol name then when a URI for that symbol is
constructed it will be necessary to map the non-ASCII characters to a
sequence of octets.  The precise mechanism for doing this depends on
the URI scheme.</p>

<p><b>Note on content dictionary names</b>  
It is a common convention to store a Content Dictionary in a file of
the same name, which can cause difficulties on many file systems.  If
this convention is to be followed then <i>OpenMath</i>
<i>recommends</i> that the name be restricted to the
subset of the above grammar which is a legal POSIX
<a href="#POSIX">[5]</a> filename, namely:
<blockquote>
<table>
<tr>
<td>Name </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> (PosixLetter | '_') (Char)*
</td>
</tr>
<tr>
<td>Char</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> PosixLetter | Digit | '.' | '-' | '_' 
</td>
</tr>
<tr>
<td>PosixLetter</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> 
'a' | 'b' | ... | 'z' | 'A' | 'B' | ... | 'Z'
</td>
</tr>
</table>
</blockquote>
</p>

<p><b>Canonical URIs for Symbols</b>  
To facilitate the use of <i>OpenMath</i> within a URI-based framework (such as RDF
<a href="#rdf">[17]</a> or OWL <a href="#owl">[16]</a>), we provide the
following scheme for constructing a canonical URI
for an <i>OpenMath</i> Symbol:
<blockquote>
  <p><small><code>URI = cdbase-value + '/' + cd-value + '#' + name-value</code></small></p>
</blockquote>
So for example the URI for the symbol with cdbase
<small><code>http://www.openmath.org/cd</code></small>, cd
<small><code>transc1</code></small> and name <small><code>sin</code></small>
is:
<blockquote>
  <p><small><code>http://www.openmath.org/cd/transc1#sin</code></small></p>
</blockquote>
In particular, this now allows us to refer uniquely to an <i>OpenMath</i> symbol from a
MathML document <a href="#MathML_2003">[15]</a>:
<div class="literal"><pre>
&lt;mathml:csymbol xmlns:mathml="http://www.w3.org/1998/Math/MathML/"
                definitionURL="http://www.openmath.org/cd/transc1#sin"&gt;
  &lt;mo&gt; sin &lt;/mo&gt; 
&lt;/csymbol&gt;
</pre></div>
</p>

</div>

<div><h3 name="sec_summary" id="sec_summary">2.4 Summary</h3>


<ul>
<li><p><i>OpenMath</i> supports basic objects like integers, symbols,
  floating-point numbers, character strings, bytearrays, and
  variables.</p></li>
<li><p><i>OpenMath</i> compound objects are of four kinds:
  applications, bindings, errors, and attributions.</p></li>
<li class="new"><p><i>OpenMath</i> objects may be attributed
with non-<i>OpenMath</i> objects via the use of foreign <i>OpenMath</i> objects.
  </p></li>
<li><p><i>OpenMath</i> objects have the expressive power to cover all
  areas of computational mathematics.</p></li>
</ul>

 <p>Observe that an <i>OpenMath</i>
application object is viewed as a <span>"tree"</span> by software
applications that do not understand Content Dictionaries, whereas a
Phrasebook that understands the semantics of the symbols, as defined
in the Content Dictionaries, should interpret the object as functional
application, constructor, or binding accordingly. Thus, for example,
for some applications, the <i>OpenMath</i> object corresponding to
<m:math><m:mn>2</m:mn><m:mo>+</m:mo><m:mn>5</m:mn></m:math> may result in a command
that writes <m:math><m:mn>7</m:mn></m:math>.</p>
</div>


<h2 name="cha_enco" id="cha_enco">
  Chapter 3<br/><i>OpenMath</i> Encodings</h2>



<p>In this chapter, two encodings are defined that map between <i>OpenMath</i>
objects and byte streams.  These byte streams constitute a low level
representation that can be easily exchanged between processes (via
almost any communication method) or stored and retrieved from
files.</p>


<p class="del">The first encoding uses ISO 646:1983
characters <a href="#iso646_83">[]</a> (also known as
<acronym>ASCII</acronym> characters) and is an <acronym>XML</acronym>
application. Although the <acronym>XML</acronym> markup of the encoding uses only
<acronym>ASCII</acronym> characters, <i>OpenMath</i> strings may use arbitrary
Unicode/ISO 10646:1988 characters <a href="#UNICODE">[10]</a>.
It can be used, for example, to send <i>OpenMath</i> objects via e-mail, news,
cut-and-paste, etc. The texts produced by this encoding can be part of
<acronym>XML</acronym> documents.</p>

<p class="new">The first encoding is a character-based
encoding in <acronym>XML</acronym> format.  In previous versions of the <i>OpenMath</i> Standard
this encoding was a restricted subset of the full legal <acronym>XML</acronym> syntax.
In this version, however, we have removed all these restrictions so that
the earlier encoding is a strict subset of the existing one.  The
<acronym>XML</acronym> encoding can be used, for example, to send <i>OpenMath</i> objects via
e-mail, cut-and-paste, etc. and to embed <i>OpenMath</i> objects in <acronym>XML</acronym>
documents or to have <i>OpenMath</i> objects processed by <acronym>XML</acronym>-aware
applications.</p>

<p>The second encoding is a binary encoding that is meant to be
used when the compactness of the encoding is important (inter-process
communications over a network is an example).</p>

<p>Note that these two encodings are sufficiently different for
auto-detection to be effective: an application reading the bytes can
very easily determine which encoding is used.</p>

<div><h3 name="sec_xml" id="sec_xml">3.1 The <acronym>XML</acronym> Encoding</h3>


<p>This encoding has been designed with two main goals in mind:
<ol>
<li><p>to provide an encoding that uses common character sets
  (so that it can easily be included in most documents and transport
  protocols) and that is both readable and writable by a human.</p></li>
<li><p>to provide an encoding that can be included (embedded) in
  <acronym>XML</acronym> documents or processed by <acronym>XML</acronym>-aware applications.</p></li>
</ol> 
</p>

<div><h4 name="ssec_xml" id="ssec_xml">3.1.1 A <span class="del">Grammar</span><span>Schema</span> for the <acronym>XML</acronym> Encoding</h4>





<p class="new">The <acronym>XML</acronym> encoding of an <i>OpenMath</i> object is
defined by the Relax NG schema <a href="#RELAX">[8]</a> given below.
Relax NG has a number of advantages over the older XSD Schema format
<a href="#XSD">[11]</a>, in particular it allows for tighter control
of attributes and has a modular, extensible structure.  Although we
have made the <acronym>XML</acronym> form, which is given in <a href="#app_openmath.rng">Appendix B</a>, normative, it is generated from the
 compact syntax given below.  It is also very easy to restrict the schema to allow
a limited set of <i>OpenMath</i> symbols as described in <a href="#app_relaxrestricted">Appendix C</a>.  </p>

<p class="new"> Standard tools exist for generating a DTD
or an XSD schema from a Relax NG Schema.  Examples of such documents
are given in <a href="#app_dtd">Appendix E</a> and <a href="#app_xsd">Appendix D</a>
respectively.</p>

<div class="newliteral"><pre>
<span style="color:brown;"># RELAX NG Schema for OpenMath 2</span>


<span style="font-weight:bold;">default</span> <span style="font-weight:bold;">namespace</span> <a name="rncnamespaceom" style="color:blue;">om</a> = "http://www.openmath.org/OpenMath"

<a name="rncstart" style="color:blue;">start</a> = <a href="#rncOMOBJ">OMOBJ</a>

<span style="color:brown;"># OpenMath object constructor</span>
<a name="rncOMOBJ" style="color:blue;">OMOBJ</a> = <span style="font-weight:bold;">element</span> OMOBJ { <a href="#rnccompound.attributes">compound.attributes</a>,
                        <span style="font-weight:bold;">attribute</span> version { <span style="font-weight:bold;">xsd:float</span> }?,
                        <a href="#rncomel">omel</a> }


<span style="color:brown;"># Elements which can appear inside an OpenMath object</span>
<a name="rncomel" style="color:blue;">omel</a> = 
  <a href="#rncOMS">OMS</a> | <a href="#rncOMV">OMV</a> | <a href="#rncOMI">OMI</a> | <a href="#rncOMB">OMB</a> | <a href="#rncOMSTR">OMSTR</a> | <a href="#rncOMF">OMF</a> | <a href="#rncOMA">OMA</a> | <a href="#rncOMBIND">OMBIND</a> | <a href="#rncOME">OME</a> | <a href="#rncOMATTR">OMATTR</a> |<a href="#rncOMR">OMR</a>

<span style="color:brown;"># things which can be variables</span>
<a name="rncomvar" style="color:blue;">omvar</a> = <a href="#rncOMV">OMV</a> | <a href="#rncattvar">attvar</a>

<a name="rncattvar" style="color:blue;">attvar</a> = <span style="font-weight:bold;">element</span> OMATTR { <a href="#rnccommon.attributes">common.attributes</a>,(<a href="#rncOMATP">OMATP</a> , (<a href="#rncOMV">OMV</a> | <a href="#rncattvar">attvar</a>))}


<a name="rnccdbase" style="color:blue;">cdbase</a> = <span style="font-weight:bold;">attribute</span> cdbase { <span style="font-weight:bold;">xsd:anyURI</span>}?

<span style="color:brown;"># attributes common to all elements</span>
<a name="rnccommon.attributes" style="color:blue;">common.attributes</a> = (<span style="font-weight:bold;">attribute</span> id { <span style="font-weight:bold;">xsd:ID</span> })?

<span style="color:brown;"># attributes common to all elements that construct compount OM objects.</span>
<a name="rnccompound.attributes" style="color:blue;">compound.attributes</a> = <a href="#rnccommon.attributes">common.attributes</a>,<a href="#rnccdbase">cdbase</a>

<span style="color:brown;"># symbol</span>
<a name="rncOMS" style="color:blue;">OMS</a> = <span style="font-weight:bold;">element</span> OMS { <a href="#rnccommon.attributes">common.attributes</a>,
                    <span style="font-weight:bold;">attribute</span> name { <span style="font-weight:bold;">xsd:NCName</span>},
                    <span style="font-weight:bold;">attribute</span> cd { <span style="font-weight:bold;">xsd:NCName</span>},
                    <a href="#rnccdbase">cdbase</a> }

<span style="color:brown;"># variable</span>
<a name="rncOMV" style="color:blue;">OMV</a> = <span style="font-weight:bold;">element</span> OMV { <a href="#rnccommon.attributes">common.attributes</a>,
                    <span style="font-weight:bold;">attribute</span> name { <span style="font-weight:bold;">xsd:NCName</span>} }

<span style="color:brown;"># integer</span>
<a name="rncOMI" style="color:blue;">OMI</a> = <span style="font-weight:bold;">element</span> OMI { <a href="#rnccommon.attributes">common.attributes</a>,
                    <span style="font-weight:bold;">xsd:string</span> {<span style="font-weight:bold;">pattern</span> = "\s*(-\s?)?[0-9]+(\s[0-9]+)*\s*"}}
<span style="color:brown;"># byte array</span>
<a name="rncOMB" style="color:blue;">OMB</a> = <span style="font-weight:bold;">element</span> OMB { <a href="#rnccommon.attributes">common.attributes</a>, <span style="font-weight:bold;">xsd:base64Binary</span> }

<span style="color:brown;"># string</span>
<a name="rncOMSTR" style="color:blue;">OMSTR</a> = <span style="font-weight:bold;">element</span> OMSTR { <a href="#rnccommon.attributes">common.attributes</a>, <span style="font-weight:bold;">text</span> }

<span style="color:brown;"># IEEE floating point number</span>
<a name="rncOMF" style="color:blue;">OMF</a> = <span style="font-weight:bold;">element</span> OMF { <a href="#rnccommon.attributes">common.attributes</a>,
                    ( <span style="font-weight:bold;">attribute</span> dec { <span style="font-weight:bold;">xsd:double</span> } |
                      <span style="font-weight:bold;">attribute</span> hex { <span style="font-weight:bold;">xsd:string</span> {<span style="font-weight:bold;">pattern</span> = "[0-9A-F]+"}}) }

<span style="color:brown;"># apply constructor</span>
<a name="rncOMA" style="color:blue;">OMA</a> = <span style="font-weight:bold;">element</span> OMA { <a href="#rnccompound.attributes">compound.attributes</a>, <a href="#rncomel">omel</a>+ }

<span style="color:brown;"># binding constructor </span>
<a name="rncOMBIND" style="color:blue;">OMBIND</a> = <span style="font-weight:bold;">element</span> OMBIND { <a href="#rnccompound.attributes">compound.attributes</a>, <a href="#rncomel">omel</a>, <a href="#rncOMBVAR">OMBVAR</a>, <a href="#rncomel">omel</a> }

<span style="color:brown;"># variables used in binding constructor</span>
<a name="rncOMBVAR" style="color:blue;">OMBVAR</a> = <span style="font-weight:bold;">element</span> OMBVAR { <a href="#rnccommon.attributes">common.attributes</a>, <a href="#rncomvar">omvar</a>+ }

<span style="color:brown;"># error constructor</span>
<a name="rncOME" style="color:blue;">OME</a> = <span style="font-weight:bold;">element</span> OME { <a href="#rnccommon.attributes">common.attributes</a>, <a href="#rncOMS">OMS</a>, (<a href="#rncomel">omel</a>|<a href="#rncOMFOREIGN">OMFOREIGN</a>)* }

<span style="color:brown;"># attribution constructor and attribute pair constructor</span>
<a name="rncOMATTR" style="color:blue;">OMATTR</a> = <span style="font-weight:bold;">element</span> OMATTR { <a href="#rnccompound.attributes">compound.attributes</a>, <a href="#rncOMATP">OMATP</a>, <a href="#rncomel">omel</a> }

<a name="rncOMATP" style="color:blue;">OMATP</a> = <span style="font-weight:bold;">element</span> OMATP { <a href="#rnccompound.attributes">compound.attributes</a>, (<a href="#rncOMS">OMS</a>, (<a href="#rncomel">omel</a> | <a href="#rncOMFOREIGN">OMFOREIGN</a>) )+ }

<span style="color:brown;"># foreign constructor</span>
<a name="rncOMFOREIGN" style="color:blue;">OMFOREIGN</a> =  <span style="font-weight:bold;">element</span> OMFOREIGN {
    <a href="#rnccompound.attributes">compound.attributes</a>, <span style="font-weight:bold;">attribute</span> encoding {<span style="font-weight:bold;">xsd:string</span>}?,
   (<a href="#rncomel">omel</a>|<a href="#rncnotom">notom</a>)* }

<span style="color:brown;"># Any elements not in the om namespace</span>
<span style="color:brown;"># (valid om is allowed as a descendant)</span>
<a name="rncnotom" style="color:blue;">notom</a> =
  (<span style="font-weight:bold;">element</span> * - <a href="#rncnamespaceom">om:</a>* {<span style="font-weight:bold;">attribute</span> * { <span style="font-weight:bold;">text</span> }*,(<a href="#rncomel">omel</a>|<a href="#rncnotom">notom</a>)*}
   | <span style="font-weight:bold;">text</span>)

<span style="color:brown;"># reference constructor</span>
<a name="rncOMR" style="color:blue;">OMR</a> = <span style="font-weight:bold;">element</span> OMR { <a href="#rnccommon.attributes">common.attributes</a>,
                    <span style="font-weight:bold;">attribute</span> href { <span style="font-weight:bold;">xsd:anyURI</span> }
                  }


</pre></div>
<p><span class="del">the <acronym>XML</acronym> encoding of an
<i>OpenMath</i> object is defined by the dtd given in Figure 4.1 below with the
following additional rules not implied by the <acronym>XML</acronym>
<acronym>DTD</acronym>.</span></p>

<ul class="del">
<li><p class="del">Comments are permitted only between
elements, not within element character data.</p></li>

<li><p class="del">Processing Instructions are
 only allowed before the <acronym>OMOBJ</acronym> element.</p></li>

<li><p class="del">The content of an
<acronym>OMB</acronym> element, is a valid base64-encoded text.</p></li>

<li><p class="del">The character data forming
element content and attribute values matches the regular expressions
of <a href="#fig_xml">para </a>.</p></li>
</ul>



<p class="del">
    <span>DTD for the <i>OpenMath</i> <acronym>XML</acronym> encoding of objects.</span>
<div class="delliteral"><pre>
&lt;!-- DTD for OM Objects - sb 29.10.98 --&gt;
&lt;!-- sb 3.2.99 --&gt;

&lt;!--
     general list of embeddable elements
      : excludes OMATP as this is only embeddable in OMATTR
      : excludes OMBVAR as this is only embeddable in OMBIND
--&gt;

&lt;!ENTITY % omel "OMS | OMV | OMI | OMB | OMSTR
                                | OMF | OMA | OMBIND | OME
                                | OMATTR | "&gt;


&lt;!-- things which can be variables --&gt;

&lt;!ENTITY % omvar "OMV | OMATTR" &gt;



&lt;!-- symbol --&gt;
&lt;!ELEMENT OMS EMPTY&gt;

  &lt;!ATTLIST OMS 
              name CDATA #REQUIRED
              cd CDATA #REQUIRED &gt;

&lt;!-- variable --&gt;
&lt;!ELEMENT OMV EMPTY&gt;
&lt;!ATTLIST OMV  
              name CDATA #REQUIRED &gt;

&lt;!-- integer --&gt;
&lt;!ELEMENT OMI (#PCDATA) &gt;


&lt;!-- byte array --&gt;
&lt;!ELEMENT OMB (#PCDATA) &gt;


&lt;!-- string --&gt;
&lt;!ELEMENT OMSTR (#PCDATA) &gt;


&lt;!-- floating point --&gt;
&lt;!ELEMENT OMF EMPTY&gt;
&lt;!ATTLIST OMF  
              dec CDATA #IMPLIED
               hex CDATA #IMPLIED&gt;

&lt;!-- apply constructor --&gt;
&lt;!ELEMENT OMA (%omel;)+ &gt;



&lt;!-- binding constructor &amp; bound variables --&gt;
&lt;!ELEMENT OMBIND ((%omel;), OMBVAR, (%omel;)) &gt;


&lt;!ELEMENT OMBVAR (%omvar;)+ &gt;


&lt;!-- error --&gt;
&lt;!ELEMENT OME (OMS, (%omel;)* ) &gt;


&lt;!-- attribution constructor &amp; attribute pair constructor --&gt;
&lt;!ELEMENT OMATTR (OMATP, (%omel;)) &gt;


&lt;!ELEMENT OMATP (OMS, (%omel;))+ &gt;




&lt;!-- OM object constructor --&gt;
&lt;!ELEMENT OMOBJ (%omel;) &gt;
&lt;!ATTLIST OMOBJ 
                xlmns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'&gt;
</pre></div>
</p>


<p class="del">In addition, if the <acronym>XML</acronym> document
encoding the <i>OpenMath</i> object is linearised into the <acronym>XML</acronym> concrete
syntax, the following further constraints apply, which ensure that the
encoding may be read by <i>OpenMath</i> applications that may not include a full
<acronym>XML</acronym> parser.</p> 




<ul class="del">
<li><p class="del">The document should use <acronym>UTF-8</acronym> encoding.</p></li>
<li><p class="del">A <small><code>&lt;!DOCTYPE</code></small> declaration should not be used.</p></li>

<li><p class="del">Character references should not be used. As
<small><code>&lt;!DOCTYPE</code></small> is not used, the only entity
references that are allowed are the five predefined entity references:
<small><code>&amp;apos;</code></small> ('),
<small><code>&amp;quot;</code></small> ("),
<small><code>&amp;lt;</code></small> (&lt;),
<small><code>&amp;gt;</code></small> (&gt;),
<small><code>&amp;amp;</code></small> (&amp;).
</p></li>

<li><p class="del">The <acronym>XML</acronym> empty element form
<small><code>&lt;|#8230;/&gt;</code></small> should
always be used to encode elements such as <acronym>OMF</acronym> which
are specified in the <acronym>DTD</acronym> as being
<acronym>EMPTY</acronym>. It should never be used for elements that
may sometimes be empty, such as <acronym>OMSTR</acronym>.</p></li>
</ul>

<p class="del">Such a linearisation of an <acronym>XML</acronym> encoded <i>OpenMath</i> Object would
match the match the character based grammar given in <a href="#fig_xml">para </a>.</p>

<p class="del">The notation used in this section and in
<a href="#fig_xml">para </a> should be quite straightforward (+ meaning
<span>"one or more"</span>, ? meaning zero or one, and | meaning
<span>"or"</span>).  The start symbol of the grammar is
<span>"start"</span>, <span>"space"</span> stands for the space
character, <span>"cr"</span> for the carriage return character,
<span>"nl"</span> for the line feed character and <span>"tab"</span>
for the horizontal tabulation character.</p>

<p class="del">

    <span class="del">Grammar for the <acronym>XML</acronym> encoding of <i>OpenMath</i> objects.</span>


<table class="del">
<tr>
<td>S           </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> (space | tab | cr | nl)+  
</td>
</tr>

<tr>
<td>integer     </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> 
        (<small><code>-</code></small> S?)? [0-9]+ (S [0-9]+)*  |
        (<small><code>-</code></small> S?)? <small><code>x</code></small> S? [0-9A-F]+ (S [0-9A-F]+)* 
</td>
</tr>
<tr>
<td> 

cdname      </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td>  [a-z][a-z0-9<small><code>_</code></small>]*
</td>
</tr>

<tr>
<td>symbname    </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> [A-Za-z][A-Za-z0-9<small><code>_</code></small>]*
</td>
</tr>

<tr>
<td>fpdec       </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td>  
    (<small><code>-</code></small>?)([0-9]+)?(<small><code>.</code></small>[0-9]+)?(<small><code>e</code></small>([+-]?)[0-9]+)?
</td>
</tr>

<tr>
<td>fphex       </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td>  [0-9ABCDEF]+ 
</td>
</tr>

<tr>
<td>varname        </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> ([A-Za-z0-9+=(),-./:?!#$%*;@[]^_`{|}])+ 
</td>
</tr>

<tr>
<td>base64      </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> ([A-Za-z0-9 +/=] | S)+ 
</td>
</tr>

<tr>
<td>char  </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> <i><acronym>XML</acronym> Character Data</i>
</td>
</tr>
</table>




<table class="del">
<tr>
<td>symbnameatt</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> 
    <small><code>name</code></small> S? = S? (<small><code>"</code></small> symbname <small><code>"</code></small> <small><code>|</code></small> <small><code>'</code></small> symbname <small><code>'</code></small>) 
</td>
</tr>

<tr>
<td>cdnameatt</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> <small><code>cd</code></small> S? = S? (<small><code>"</code></small> cdname <small><code>"</code></small> <small><code>|</code></small> <small><code>'</code></small> cdname <small><code>'</code></small>) 
</td>
</tr>

<tr>
<td>varnameatt</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> <small><code>name</code></small> S? = S? (<small><code>"</code></small> varname <small><code>"</code></small> <small><code>|</code></small> <small><code>'</code></small> varname <small><code>'</code></small>) 
</td>
</tr>

<tr>
<td>fpdecatt</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> <small><code>dec</code></small> S? = S? (<small><code>"</code></small> fpdec <small><code>"</code></small> <small><code>|</code></small> <small><code>'</code></small> fpdec <small><code>'</code></small>) 
</td>
</tr>

<tr>
 <td>fphexatt</td>
 <td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
 <td><small><code>hex</code></small> S? = S? (<small><code>"</code></small> fphex <small><code>"</code></small> <small><code>|</code></small> <small><code>'</code></small> fphex <small><code>'</code></small>) 
</td>
</tr>


<tr>
<td>PI </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> &lt;<small><code>?</code></small> char <small><code>?</code></small><small><code>&gt;</code></small></td>
</tr>

<tr>
<td>comment</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> &lt;<small><code>!--</code></small> char <small><code>--</code></small><small><code>&gt;</code></small>
</td>
</tr>

<tr>
<td>SC</td>
<td><m:math><m:mo>&#8594;</m:mo></m:math></td>
<td> S+ <small><code>|</code></small> (comment S)+
</td>
</tr>

<tr>
<td>start  </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> 
 (SC <small><code>|</code></small> PI)* <small><code>&lt;OMOBJ</code></small> S?<small><code>&gt;</code></small> S? object S? <small><code>&lt;/OMOBJ</code></small> S?<small><code>&gt;</code></small> 
</td>
</tr>

<tr>
<td>symbol</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> 
  <small><code>&lt;OMS</code></small> [[(S  symbnameatt) (S cdnameatt) ]] S? <small><code>/&gt;</code></small>
</td>
</tr>


<tr>
<td>variable</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td><small><code>&lt;OMV</code></small>  varnameatt S? <small><code>/&gt;</code></small>
</td>
</tr>

<tr><td/>
<td>|</td>
<td> <small><code>&lt;OMATTRx</code></small> S?<small><code>&gt;</code></small> SC? omatp SC? variable SC? <small><code>&lt;/OMATTR</code></small> S?<small><code>&gt;</code></small>
</td>
</tr>

<tr>
<td>omatp </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td>     <small><code>&lt;OMATP</code></small>  S?<small><code>&gt;</code></small> SC? attrs SC? <small><code>&lt;/#1</code></small> S?<small><code>&gt;</code></small> 
</td>
</tr>

<tr>
<td>object </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> symbol</td>
</tr>

<tr>
<td/>
<td>|</td><td>variable</td>
</tr>

<tr><td/>
<td>|</td>
<td><small><code>&lt;OMI</code></small> S <small><code>&gt;</code></small> S? integer S? <small><code>&lt;/OMI</code></small> S?<small><code>&gt;</code></small>
</td>
</tr>

<tr><td/>
<td>|</td><td> <small><code>&lt;OMF</code></small> S fpdecatt  S?<small><code>/&gt;</code></small>
</td>
</tr>

<tr>
  <td/>
  <td>|</td><td> <small><code>&lt;OMF</code></small> S fphexatt  S?<small><code>/&gt;</code></small>
</td>
</tr>

<tr>
  <td/>  
  <td>|</td><td> <small><code>&lt;OMSTR</code></small>  S?<small><code>&gt;</code></small> char <small><code>&lt;/OMSTR</code></small> S?<small><code>&gt;</code></small> 
</td>
</tr>

<tr>
  <td/>  
  <td>|</td><td> <small><code>&lt;OMB</code></small>  S?<small><code>&gt;</code></small> base64  <small><code>&lt;/OMB</code></small> S?<small><code>&gt;</code></small> 
</td>
</tr>

<tr>
  <td/>
<td>|</td>
<td> <small><code>&lt;OMA</code></small>  S?<small><code>&gt;</code></small> SC? object SC? objects SC? <small><code>&lt;/OMA</code></small> S?<small><code>&gt;</code></small>
</td>
</tr>

<tr><td/>
<td>|</td><td> <small><code>&lt;OMBIND</code></small>  S?<small><code>&gt;</code></small> SC? object SC? 
</td>
</tr>

<tr><td/>
<td/>
<td> <small><code>&lt;OMBVAR</code></small>  S?<small><code>&gt;</code></small> SC? variables SC? <small><code>&lt;/OMBVAR</code></small> S?<small><code>&gt;</code></small> 
</td>
</tr>

<tr><td/>
<td/>
<td> SC? object SC? <small><code>&lt;/OMBIND</code></small> S?<small><code>&gt;</code></small>
</td>
</tr>

<tr>
  <td/>
<td>|</td>
<td> <small><code>&lt;OME</code></small>  S?<small><code>&gt;</code></small> SC? symbol SC? objects SC? <small><code>&lt;/OME</code></small> S?<small><code>&gt;</code></small> 
</td>
</tr>

<tr>
  <td/>
<td>|</td>
<td> <small><code>&lt;OMATTR</code></small>  S?<small><code>&gt;</code></small> SC?  <small><code>&lt;OMATP</code></small> S?<small><code>&gt;</code></small> SC? attrs SC? <small><code>&lt;/OMBVAR</code></small> S?<small><code>&gt;</code></small>   
</td>
</tr>

<tr><td/>
<td/>
<td>SC? object SC? <small><code>&lt;/OMATTR</code></small> S?<small><code>&gt;</code></small>  
</td>
</tr>

<tr>
<td>attrs</td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> symbol S? object   
</td>
</tr>

<tr>
  <td/>
<td>|</td>
<td> symbol S? object S? attrs 
</td>
</tr>

<tr>
<td>objects </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> SC?     
</td>
</tr>

<tr>
  <td/>
<td>|</td>
<td> object SC? objects  
</td>
</tr>

<tr>
<td>variables </td>
<td> <m:math><m:mo>&#8594;</m:mo></m:math> </td>
<td> SC?   
</td>
</tr>

<tr>
  <td/>
<td>|</td>
<td> variable SC? variables  
</td>
</tr>

</table>


</p>

<p><b>Note:</b> This schema 
specifies names as being of the <small><code>xsd:NCName</code></small>
type. At the time of writing, W3C Schema types are defined in terms of
XML 1 <a href="#xml_98">[13]</a>.  This limits the characters allowed
in a name to a subset of the characters available in Unicode 2.0, which
is far more restrictive than the definition for an
<i>OpenMath</i> name given in <a href="#sec_names">Section 2.3</a>.
It is expected that W3C Schema types will be augmented to match the
new XML 1.1 recommendation <a href="#xml_04">[14]</a>, but for portability
reasons applications
should avoid  using the new XML 1.1 name characters unless they are
absolutely required.
The XML 1.1 specification has a useful appendix giving
advice on good strategies to use when naming identifiers.</p>

</div>

<div><h4 name="sec_xml-desc" id="sec_xml-desc">3.1.2 <span class="new">Informal</span> description of
the <span class="del">Grammar</span><span class="new"><acronym>XML</acronym> Encoding</span></h4>


<p>An encoded <i>OpenMath</i> object is placed inside an <small><code>OMOBJ</code></small> element.  This 
element can contain the elements (and integers) described above.
<span class="new"> It can take an optional
<small><code>version</code></small> (<acronym>XML</acronym>) attribute which indicates to
which version of the <i>OpenMath</i> standard it conforms.  In previous versions of
this standard this attribute did not exist, so any <i>OpenMath</i> object without
such an attribute must conform to version 1 (or equivalently 1.1) of the
<i>OpenMath</i> standard.  Objects which conform to the description given in this
document should have <small><code>version="2.0"</code></small>.
</span></p>

<p>We briefly discuss the <acronym>XML</acronym> encoding for each type of <i>OpenMath</i> object
starting from the basic objects.</p>

<dl>
<dt>Integers</dt>
<dd>
 <p>are encoded using the
<small><code>OMI</code></small> element around the sequence of their
digits in base 10 or 16 (most significant digit first).  White space
may be inserted between the characters of the integer representation,
this will be ignored.  After ignoring white space, integers written in
base 10 match the regular expression
<small><code>-?[0-9]+</code></small>.  Integers written in base 16 match
<small><code>-?x[0-9A-F]+</code></small>.  The integer 10 can be thus
encoded as <small><code>&lt;OMI&gt; 10 &lt;/OMI&gt; </code></small> or as
<small><code>&lt;OMI&gt; xA &lt;/OMI&gt; </code></small> but neither
<small><code>&lt;OMI&gt; +10 &lt;/OMI&gt;</code></small> nor
<small><code>&lt;OMI&gt; +xA &lt;/OMI&gt;</code></small> can be used.</p>

<p>The negative integer <m:math><m:mn>-120</m:mn></m:math> can be encoded
       as either as decimal <small><code>&lt;OMI&gt; -120
       &lt;/OMI&gt;</code></small> or as hexadecimal <small><code>&lt;OMI&gt;
       -x78 &lt;/OMI&gt;</code></small>.</p>

  
</dd>

<dt>Symbols</dt><dd><p>are encoded using
  the <small><code>OMS</code></small> element. This element has
  <span class="del">two</span>
  <span class="new">three</span>
  (<acronym>XML</acronym>) attributes <small><code>cd</code></small>,
  <small><code>name</code></small><span class="new">,  and
    <small><code>cdbase</code></small></span>. The value of
  <small><code>cd</code></small> is the name of the Content Dictionary in
  which the symbol is defined and the value of
  <small><code>name</code></small> is the name of the symbol.
  <span class="new">The optional <small><code>cdbase</code></small>
    attribute is a URI that can be used to disambiguate between two  content
    dictionaries with the same name.
  If a symbol does not have an explicit <small><code>cdbase</code></small>
attribute, then it inherits its <small><code>cdbase</code></small> from the
first ancestor in the <acronym>XML</acronym> tree with one, should such an element
exist.  In this document we have tended to omit the
<small><code>cdbase</code></small> for clarity.
  </span>
<span class="del">
  The name
  of the Content Dictionary is compulsory, but a future revision of
  the <i>OpenMath</i> standard might introduce a defaulting mechanism.
</span> For
  example:
<blockquote class="del"><p><small><code>&lt;OMS
 cd="transc" name="sin"/&gt;</code></small></p>
</blockquote>
<blockquote class="new"><p><small><code>&lt;OMS
 cdbase="http://www.openmath.org/cd" cd="transc1" name="sin"/&gt;</code></small></p>
</blockquote>
  is the encoding of the symbol named <small><code>sin</code></small> in
  the Content Dictionary named <small><code>transc1</code></small>,
<span class="new">which is part of the collection
maintained by the <i>OpenMath</i> Society</span>.</p>

<p class="new">As described in <a href="#sec_names">Section 2.3</a>,
the three attributes of the
  <small><code>OMS</code></small> can be used to build a URI reference for the symbol,
for use in contexts where URI-based referencing mechanisms are used.
For example the URI for the above symbol is
 <small><code>http://www.openmath.org/cd/transc1#sin</code></small>.
</p>
<p class="new">
Note that the role attribute described in <a href="#sec_roles">Section 2.1.4</a> is contained in the Content Dictionary and is not
part of the encoding of a symbol, also the <small><code>cdbase</code></small> attribute need not
be explicit on each <small><code>OMS</code></small> as it is inherited
from any ancestor element.</p>
</dd>

<dt>Variables</dt><dd><p>are encoded using
  the <small><code>OMV</code></small> element, with only one
  (<acronym>XML</acronym>) attribute, <small><code>name</code></small>, whose value is the
  variable name. <span class="del">
The variable name is a subset of the printable
  <acronym>ASCII</acronym> set of characters.  In particular, neither
  spaces nor double-quote <small><code>"</code></small> are allowed
  in variable names.</span>  For instance, the encoding of the object
  representing the variable <m:math><m:mi>x</m:mi></m:math> is:
  <small><code>&lt;OMV name="x"/&gt;</code></small></p>

 
</dd>

<dt>Floating-point numbers</dt><dd><p>are
  encoded using the <small><code>OMF</code></small> element that has
  either the (<acronym>XML</acronym>) attribute <small><code>dec</code></small> or the
  (<acronym>XML</acronym>) attribute <small><code>hex</code></small>. The two
  (<acronym>XML</acronym>) attributes cannot be present simultaneously. The value of
  <small><code>dec</code></small> is the floating-point number expressed
  in base 10, using the common syntax:</p>
  
  <blockquote><p>
  <small><code class="chg">(-?)([0-9]+)?("."[0-9]+)?([eE](-?)[0-9]+)?</code></small>.
  </p>
  <p class="new">or one of the special values: INF, -INF or
  NaN.</p>
</blockquote>
  <p class="chg">The value of
  <small><code>hex</code></small> is a base 16 representation of the 
 64 bits of the <acronym>IEEE</acronym> Double.
 Thus the number represents mantissa, exponent, and sign from lowest
  to highest bits using a  least significant byte ordering.
 This consists of a string of 16 digits <small><code>0</code></small>-<small><code>9</code></small>, <small><code>A</code></small>-<small><code>F</code></small>.
  </p>
  <p class="chg">For example, both <small><code>&lt;OMF
    dec="1.0e-10"/&gt;</code></small> and 
   <small><code>&lt;OMF hex="3DDB7CDFD9D7BDBB"/&gt;</code></small>
  are valid representations of the floating point number
  <m:math><m:mn>1</m:mn><m:mo>×</m:mo>
<m:msup><m:mn>10</m:mn><m:mn>-10</m:mn></m:msup></m:math>.</p>
 
 <p class="new"> The symbols <small><code>INF</code></small>,
<small><code>-INF</code></small> and <small><code>NaN</code></small> represent
positive and negative infinity, and <i>not a number</i> as
defined in <a href="#ieee754_85">[6]</a>.  Note that while infinities
have a unique representation, it is possible for NaNs to contain extra
information about how they were generated and if this informations is to
be preserved then the hexadecimal representation must be used.  For
example
<small><code>&lt;OMF hex="FFF8000000000000"/&gt;</code></small> and
<small><code>&lt;OMF hex="FFF8000000000001"/&gt;</code></small> are both
hexadecimal representations of NaNs.
</p>


</dd>

<dt>Character strings</dt><dd><p>are encoded using the <small><code>OMSTR</code></small> element.
  Its content is  a Unicode text <span class="del">(The default encoding 
  is <acronym>UTF-8</acronym><a href="#utf8">[]</a>, although <acronym>XML</acronym> encoded <i>OpenMath</i> may be embedded
 in a containing <acronym>XML</acronym> document that specifies alternative encoding in
  the <acronym>XML</acronym> declaration</span>. Note that as always in <acronym>XML</acronym> the
  characters <small><code>&lt;</code></small> and <small><code>&amp;</code></small>  need to be represented by the
  entity references <small><code>&amp;lt;</code></small> and
<small><code>&amp;amp;</code></small> respectively.</p>
  
</dd>

<dt>Bytearrays</dt><dd><p>are encoded using the <small><code>OMB</code></small> element. Its content
  is a sequence of characters that is a base64 encoding of the data.
  The base64 encoding is defined in <acronym>RFC</acronym>
<span class="del">1521 <a href="#rfc1521">[]</a></span>
<span class="new">2045 <a href="#rfc2045">[1]</a></span>.
  Basically, it represents an arbitrary sequence of octets using 64
  <span>"digits"</span> (<small><code>A</code></small> through <small><code>Z</code></small>, <small><code>a</code></small> through <small><code>z</code></small>, <small><code>0</code></small> through <small><code>9</code></small>, <small><code>+</code></small> and /, in order of increasing
  value). Three octets are represented as four digits (the <small><code>=</code></small>
  character is used for padding at the end of the data). All line
  breaks and carriage return, space, form feed and horizontal
  tabulation characters are ignored. The reader is referred to
  <a href="#rfc1521">[]</a>
  <a href="#rfc2045">[1]</a>
for more detailed information.</p>

</dd>

</dl>
 
<p class="del">In detail the encoding of an <i>OpenMath</i> object is described below.</p>

<dl>
<dt>Applications</dt><dd><p>are encoded using the <small><code>OMA</code></small> element. The
  application whose head is the <i>OpenMath</i> object <m:math><m:msub><m:mi>e</m:mi><m:mn>0</m:mn></m:msub></m:math> and whose arguments
  are the <i>OpenMath</i> objects <m:math><m:msub><m:mi>e</m:mi><m:mn>1</m:mn></m:msub></m:math>, <span>&#8230;</span>, <m:math><m:msub><m:mi>e</m:mi><m:mi>n</m:mi></m:msub></m:math> is encoded as <small><code>&lt;OMA&gt;</code></small>
  <m:math><m:msub><m:mi>C</m:mi><m:mn>0</m:mn></m:msub></m:math> <m:math><m:msub><m:mi>C</m:mi><m:mn>1</m:mn></m:msub></m:math><span>&#8230;</span> <m:math><m:msub><m:mi>C</m:mi><m:mi>n</m:mi></m:msub></m:math> <small><code>&lt;/OMA&gt;</code></small> where <m:math><m:msub><m:mi>C</m:mi><m:mi>i</m:mi></m:msub></m:math> is the encoding of
  <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>.</p>

<p>For example, <m:math><m:mi mathvariant="bold">application</m:mi><m:mo>(</m:mo><m:mi>sin</m:mi><m:mo>,</m:mo><m:mi>x</m:mi> <m:mo>)</m:mo></m:math> is encoded as:
<div class="literal"><pre>&lt;OMA&gt;  
  &lt;OMS cd="transc1" name="sin"/&gt; 
  &lt;OMV name="x"/&gt;  
&lt;/OMA&gt;</pre></div>
  provided that the symbol <small><code>sin</code></small> is defined to be a function
  symbol in a Content Dictionary named <small><code>transc1</code></small>.</p>

  
</dd>

<dt>Binding</dt><dd><p>is encoded using the <small><code>OMBIND</code></small> element.  The binding
  by the <i>OpenMath</i> object <m:math><m:mi>b</m:mi></m:math> of the <i>OpenMath</i> variables <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>, <m:math><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub></m:math>,
  <m:math><m:mi>&#8230;</m:mi></m:math>, <m:math><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:math> in the object <m:math><m:mi>c</m:mi></m:math> is encoded as <small><code>&lt;OMBIND&gt;</code></small> <m:math><m:mi>B</m:mi></m:math>   <small><code>&lt;OMBVAR&gt;</code></small> <m:math><m:msub><m:mi>X</m:mi><m:mn>1</m:mn></m:msub></m:math> <m:math><m:mi>&#8230;</m:mi></m:math> <m:math><m:msub><m:mi>X</m:mi><m:mi>n</m:mi></m:msub></m:math> <small><code>&lt;/OMBVAR&gt;</code></small> <m:math><m:mi>C</m:mi></m:math> <small><code>&lt;/OMBIND&gt;</code></small> where <m:math><m:mi>B</m:mi></m:math>, <m:math><m:mi>C</m:mi></m:math>, and <m:math><m:msub><m:mi>X</m:mi><m:mi>i</m:mi></m:msub></m:math> are the encodings of <m:math><m:mi>b</m:mi></m:math>, <m:math><m:mi>c</m:mi></m:math>   and <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>, respectively.</p>

<p>For instance the encoding of
  <m:math><m:mi mathvariant="bold">binding</m:mi>
       <m:mo>(</m:mo><m:mi>lambda</m:mi><m:mo>,</m:mo>
  <m:mi>x</m:mi><m:mo>,</m:mo><m:mi mathvariant="bold">application</m:mi>
     <m:mo>(</m:mo><m:mi>sin</m:mi><m:mo>,</m:mo> <m:mi>x</m:mi><m:mo>)</m:mo><m:mo>)</m:mo></m:math> is:
<div class="literal"><pre>&lt;OMBIND&gt;
  &lt;OMS cd="fns1" name="lambda"/&gt;  
  &lt;OMBVAR&gt;&lt;OMV name="x"/&gt;&lt;/OMBVAR&gt;  
  &lt;OMA&gt;
    &lt;OMS cd="transc1" name="sin"/&gt; 
    &lt;OMV name="x"/&gt;  
  &lt;/OMA&gt;
&lt;/OMBIND&gt;</pre></div></p>
  
<p>Binders are defined in  Content Dictionaries, in particular,
  the symbol <small><code>lambda</code></small> is defined in the Content Dictionary
  <small><code>fns1</code></small> for functions over functions.</p>
  
</dd>

<dt>Attributions</dt><dd><p>are encoded using the <small><code>OMATTR</code></small> element.  If
  the <i>OpenMath</i> object <m:math><m:mi>e</m:mi></m:math> is attributed with (<m:math><m:msub><m:mi>s</m:mi><m:mn>1</m:mn></m:msub></m:math>, <m:math><m:msub><m:mi>e</m:mi><m:mn>1</m:mn></m:msub></m:math>), <span>&#8230;</span>, 
  (<m:math><m:msub><m:mi>s</m:mi><m:mi>n</m:mi></m:msub></m:math>, <m:math><m:msub><m:mi>e</m:mi><m:mi>n</m:mi></m:msub></m:math>) pairs (where <m:math><m:msub><m:mi>s</m:mi><m:mi>i</m:mi></m:msub></m:math> are the attributes), it is encoded
  as <small><code>&lt;OMATTR&gt;</code></small> <small><code>&lt;OMATP&gt;</code></small> <m:math><m:msub><m:mi>S</m:mi><m:mn>1</m:mn></m:msub></m:math> <m:math><m:msub><m:mi>C</m:mi><m:mn>1</m:mn></m:msub></m:math> <span>&#8230;</span> <m:math><m:msub><m:mi>S</m:mi><m:mi>n</m:mi></m:msub></m:math> <m:math><m:msub><m:mi>C</m:mi><m:mi>n</m:mi></m:msub></m:math> <small><code>&lt;/OMATP&gt;</code></small> <m:math><m:mi>E</m:mi></m:math> <small><code>&lt;/OMATTR&gt;</code></small> where <m:math><m:msub><m:mi>S</m:mi><m:mi>i</m:mi></m:msub></m:math> is the encoding of the
  symbol <m:math><m:msub><m:mi>s</m:mi><m:mi>i</m:mi></m:msub></m:math>, <m:math><m:msub><m:mi>C</m:mi><m:mi>i</m:mi></m:msub></m:math> of the object <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math> and <m:math><m:mi>E</m:mi></m:math> is the encoding of
  <m:math><m:mi>e</m:mi></m:math>.</p>

<p>Examples are the use of attribution to decorate a group by its
  automorphism group:
<div class="literal"><pre>&lt;OMATTR&gt;    
  &lt;OMATP&gt;
    &lt;OMS cd="groups" name="automorphism_group" /&gt;  
    [..group-encoding..] 
  &lt;/OMATP&gt;  
  [..group-encoding..] 
&lt;/OMATTR&gt;</pre></div>
or to express the type of a variable:
<div class="literal"><pre>&lt;OMATTR&gt;    
  &lt;OMATP&gt;
    &lt;OMS cd="ecc" name="type" /&gt; 
    &lt;OMS cd="ecc" name="real" /&gt;
  &lt;/OMATP&gt; 
  &lt;OMV name="x" /&gt;
&lt;/OMATTR&gt;</pre></div></p>

  
<p class="new">
A special use of attributions is to associate non-<i>OpenMath</i> data with an
<i>OpenMath</i> object.  This is done using the
<small><code>OMFOREIGN</code></small> element.  The children of this
element must be well-formed <acronym>XML</acronym>.  For example the attribution of the
<i>OpenMath</i> object 
  <m:math>
     <m:mi>sin</m:mi><m:mfenced><m:mi>x</m:mi></m:mfenced></m:math> with its
representation in Presentation MathML is:
<div class="literal"><pre>&lt;OMATTR&gt;
  &lt;OMATP&gt;
    &lt;OMS cd="annotations1" name="presentation-form"/&gt;  
    &lt;OMFOREIGN encoding="MathML-Presentation"&gt;
      &lt;math xmlns="http://www.w3.org/1998/Math/MathML"&gt;
        &lt;mi&gt;sin&lt;/mi&gt;&lt;mfenced&gt;&lt;mi&gt;x&lt;/mi&gt;&lt;/mfenced&gt;
      &lt;/math&gt;
    &lt;/OMFOREIGN&gt;  
  &lt;/OMATP&gt;
  &lt;OMA&gt;
   &lt;OMS cd="transc1" name="sin"/&gt; 
   &lt;OMV name="x"/&gt;  
  &lt;/OMA&gt;
&lt;/OMATTR&gt;</pre></div>
Of course not everything has a natural XML encoding in this way and
often the contents of a <small><code>OMFOREIGN</code></small> will just
be data or some kind of encoded string.  For example the attribution
of the previous object with its <span>LaTeX</span> representation could be achieved
as follows:
<div class="literal"><pre>&lt;OMATTR&gt;
  &lt;OMATP&gt;
    &lt;OMS cd="annotations1" name="presentation-form"/&gt;  
    &lt;OMFOREIGN encoding="text/x-latex"&gt;\sin(x)&lt;/OMFOREIGN&gt;  
  &lt;/OMATP&gt;
  &lt;OMA&gt;
    &lt;OMS cd="transc1" name="sin"/&gt; 
    &lt;OMV name="x"/&gt;  
  &lt;/OMA&gt;
&lt;/OMATTR&gt;</pre></div>
For a discussion on the use of the <small><code>encoding</code></small>
attribute see <a href="#sec_compl_omforeign">Section 5.2</a>.
</p>
</dd>




 <dt>Errors</dt> 
 <dd><p>are encoded using the <small><code>OME</code></small> element. The error whose
  symbol is <m:math><m:mi>s</m:mi></m:math> and whose arguments are the <i>OpenMath</i> objects
<span class="new">or <i>OpenMath</i> derived objects</span>
 <m:math><m:msub><m:mi>e</m:mi><m:mn>1</m:mn></m:msub></m:math>,
  <span>&#8230;</span>, <m:math><m:msub><m:mi>e</m:mi><m:mi>n</m:mi></m:msub></m:math> is encoded as <small><code>&lt;OME&gt;</code></small> <m:math><m:msub><m:mi>C</m:mi><m:mi>s</m:mi></m:msub></m:math> <m:math><m:msub><m:mi>C</m:mi><m:mn>1</m:mn></m:msub></m:math><span>&#8230;</span> <m:math><m:msub><m:mi>C</m:mi><m:mi>n</m:mi></m:msub></m:math> <small><code>&lt;/OME&gt;</code></small> where <m:math><m:msub><m:mi>C</m:mi><m:mi>s</m:mi></m:msub></m:math> is the encoding of <m:math><m:mi>s</m:mi></m:math> and <m:math><m:msub><m:mi>C</m:mi><m:mi>i</m:mi></m:msub></m:math> the encoding
  of <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>.</p>

<p>If an <small><code>aritherror</code></small> Content Dictionary contained a
  <small><code>DivisionByZero</code></small> symbol, then the object
  <m:math><m:mi mathvariant="bold">error</m:mi><m:mo>(</m:mo><m:mi>DivisionByZero</m:mi><m:mo>,</m:mo> <m:mi mathvariant="bold">application</m:mi>
  <m:mo>(</m:mo><m:mi>divide</m:mi><m:mo>,</m:mo> 
  <m:mi>x</m:mi><m:mo>,</m:mo> <m:mn>0</m:mn><m:mo>)</m:mo><m:mo>)</m:mo></m:math> would be encoded as follows:

<div class="literal"><pre>&lt;OME&gt;
  &lt;OMS cd="aritherror" name="DivisionByZero"/&gt;  
  &lt;OMA&gt;
    &lt;OMS cd="arith1" name="divide" /&gt;
    &lt;OMV name="x"/&gt;  
    &lt;OMI&gt; 0 &lt;/OMI&gt;
  &lt;/OMA&gt; 
 &lt;/OME&gt;</pre></div></p>
  
<p class="new">
If a <small><code>mathml</code></small> Content Dictionary contained an
  <small><code>unhandled_csymbol</code></small> symbol, then an <i>OpenMath</i> to
MathML translator might return an error such as:
<div class="literal"><pre>&lt;OME&gt;
  &lt;OMS cd="mathml" name="unhandled_csymbol"/&gt;  
  &lt;OMFOREIGN encoding="MathML-Content"&gt;
    &lt;mathml:csymbol xmlns:mathml="http://www.w3.org/1998/Math/MathML/"
                    definitionURL="http://www.nag.co.uk/Airy#A"&gt;
      &lt;mathml:mo&gt;Ai&lt;/mathml:mo&gt;
    &lt;/mathml:csymbol&gt;
  &lt;/OMFOREIGN&gt; 
 &lt;/OME&gt;</pre></div></p>

<p class="new"> Note that it is possible to embed fragments
of valid <i>OpenMath</i> inside an <small><code>OMFOREIGN</code></small> element but that it
cannot contain invalid <i>OpenMath</i>.  In addition, the arguments to an
<small><code>OMERROR</code></small> must be well-formed <acronym>XML</acronym>.  If an
application wishes to signal that the <i>OpenMath</i> it has received is invalid or
is not well-formed then the offending data must be encoded as a string.
For example:
<div class="literal"><pre>&lt;OME&gt;
  &lt;OMS cd="parser" name="invalid_XML"/&gt;  
  &lt;OMSTR&gt;
    &amp;ltOMA&amp;gt; &amp;lt;OMS name="cos" cd="transc1"&amp;gt;
      &amp;lt;OMV name="v"&amp;gt; &amp;lt;/OMA&amp;gt;
  &lt;/OMSTR&gt; 
 &lt;/OME&gt;</pre></div>
Note that the `&lt;' and `&gt;' characters have been escaped as is usual in
an <acronym>XML</acronym> document.
</p>

</dd>



 <dt class="new">References</dt>
 <dd class="new"><p>
 <i>OpenMath</i> integers, floating point numbers, character strings,
 bytearrays, applications, binding, attributions can also be encoded
 as an empty <small><code>OMR</code></small> element with an <small><code>href</code></small>
 attribute whose value is the value of a URI referencing an id
 attribute of an <i>OpenMath</i> object of that type.
The <i>OpenMath</i> element represented by this <small><code>OMR</code></small>
 reference is a copy of the <i>OpenMath</i> element referenced
 <small><code>href</code></small> attribute. Note that this copy
 is <i>structurally equal</i>, but not identical
 to the element referenced. </p>

 <p>For instance, the <i>OpenMath</i> object

 <m:math id="nestedap" display="block">
   <m:mrow>
     <m:mi mathvariant="bold">application</m:mi>
     <m:mrow>
       <m:mo fence="true">(</m:mo>
       <m:mrow>
         <m:mi>f</m:mi>
         <m:mo separator="true">,</m:mo>
         <m:mi mathvariant="bold">application</m:mi>
         <m:mrow>
           <m:mo fence="true">(</m:mo>
           <m:mrow>
             <m:mi>f</m:mi>
             <m:mo separator="true">,</m:mo>
             <m:mi mathvariant="bold">application</m:mi>
             <m:mrow>
               <m:mo fence="true">(</m:mo>
               <m:mrow><m:mi>f</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi></m:mrow>
               <m:mo fence="true">)</m:mo>
             </m:mrow>
             <m:mo separator="true">,</m:mo>
             <m:mi mathvariant="bold">application</m:mi>
             <m:mrow>
               <m:mo fence="true">(</m:mo>
               <m:mrow><m:mi>f</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi></m:mrow>
               <m:mo fence="true">)</m:mo>
             </m:mrow>
             <m:mo fence="true">)</m:mo>
           </m:mrow>
           <m:mo separator="true">,</m:mo>
           <m:mi mathvariant="bold">application</m:mi>
           <m:mrow>
             <m:mo fence="true">(</m:mo>
             <m:mrow>
               <m:mi>f</m:mi>
               <m:mo separator="true">,</m:mo>
               <m:mi mathvariant="bold">application</m:mi>
               <m:mrow>
                 <m:mo fence="true">(</m:mo>
                 <m:mrow><m:mi>f</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi></m:mrow>
                 <m:mo fence="true">)</m:mo>
               </m:mrow>
               <m:mo separator="true">,</m:mo>
               <m:mi mathvariant="bold">application</m:mi>
               <m:mrow>
                 <m:mo fence="true">(</m:mo>
                 <m:mrow><m:mi>f</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi><m:mo separator="true">,</m:mo><m:mi>a</m:mi></m:mrow>
                 <m:mo fence="true">)</m:mo>
               </m:mrow>
               <m:mo fence="true">)</m:mo>
             </m:mrow>
           </m:mrow>
           <m:mo fence="true">)</m:mo>
         </m:mrow>
       </m:mrow>
     </m:mrow>
   </m:mrow>
 </m:math>
</p>
<p>can be encoded in the <acronym>XML</acronym> encoding as either one of the
<acronym>XML</acronym> encodings given in <a href="#fig_shared_vs_unshared">Figure 4.1</a>
(and some intermediate versions as well).</p>
</dd>  </dl>

<div class="figure"><a name="fig_shared_vs_unshared" id="fig_shared_vs_unshared"/>
    
    
 <div class="literal"><pre>&lt;OMOBJ version="2.0"&gt;         &lt;OMOBJ version="2.0"&gt;
  &lt;OMA&gt;                         &lt;OMA&gt;
    &lt;OMV name="f"/&gt;               &lt;OMV name="f"/&gt; 
    &lt;OMA&gt;                         &lt;OMA id="t1"&gt;
      &lt;OMV name="f"/&gt;               &lt;OMV name="f"/&gt;
      &lt;OMA&gt;                         &lt;OMA id="t11"&gt;
        &lt;OMV name="f"/&gt;               &lt;OMV name="f"/&gt;
        &lt;OMV name="a"/&gt;               &lt;OMV name="a"/&gt;
        &lt;OMV name="a"/&gt;               &lt;OMV name="a"/&gt;
      &lt;/OMA&gt;                        &lt;/OMA&gt;
      &lt;OMA&gt;                         &lt;OMR href="#t11"/&gt;
        &lt;OMV name="f"/&gt;
        &lt;OMV name="a"/&gt; 
        &lt;OMV name="a"/&gt;
      &lt;/OMA&gt;                                
    &lt;/OMA&gt;                      &lt;/OMA&gt;
    &lt;OMA&gt;                       &lt;OMR href="#t1"/&gt;
      &lt;OMV name="f"/&gt;
      &lt;OMA&gt;
        &lt;OMV name="f"/&gt;
        &lt;OMV name="a"/&gt;
        &lt;OMV name="a"/&gt;
      &lt;/OMA&gt;
      &lt;OMA&gt;
        &lt;OMV name="f"/&gt;
        &lt;OMV name="a"/&gt;
        &lt;OMV name="a"/&gt;
      &lt;/OMA&gt;
    &lt;/OMA&gt;
  &lt;/OMA&gt;
&lt;/OMOBJ&gt;                     &lt;/OMOBJ&gt;
</pre></div>
<div>
  Figure 4.1 Shared vs. unshared representations</div></div>
</div>

<div class="new"><h4 name="sec_references" id="sec_references">3.1.3 Some Notes on References</h4>


<p>We say that an <i>OpenMath</i> element dominates all its children and all elements
they dominate. An <small><code>OMR</code></small> element dominates its target,
i.e. the element that carries the <small><code>id</code></small> attribute pointed to
by the <small><code>xref</code></small> attribute. For instance in the representation
in <a href="#fig_shared_vs_unshared">Figure 4.1</a>, the
<small><code>OMA</code></small> element with <small><code>id="t1"</code></small> and
also the second <small><code>OMR</code></small> dominate the
<small><code>OMA</code></small> element with <small><code>id="t11"</code></small>.
</p>

<div class="new"><h5 name="sec_acyclicity" id="sec_acyclicity">3.1.3.1 An Acyclicity Constraint</h5>


<p class="new">The occurrences of the <small><code>OMR</code></small> element must obey the following global
<i>acyclicity constraint</i>: An <i>OpenMath</i> element may not dominate itself.</p>

<p class="new">Consider for instance the following (illegal) <acronym>XML</acronym> representation
<div class="literal"><pre>&lt;OMOBJ version="2.0"&gt;
  &lt;OMA id="foo"&gt;
    &lt;OMS cd="arith1" name="divide"/&gt;
    &lt;OMI&gt;1&lt;/OMI&gt;
    &lt;OMA&gt;
       &lt;OMS cd="arith1" name="plus"/&gt;
       &lt;OMI&gt;1&lt;/OMI&gt;
       &lt;OMR xref="foo"/&gt;
    &lt;/OMA&gt; 
  &lt;/OMA&gt;
&lt;/OMOBJ&gt;
</pre></div>
</p>

<p class="new">Here, the <small><code>OMA</code></small> element with
<small><code>id="foo"</code></small> dominates its third child, which dominates the
<small><code>OMR</code></small> element, which dominates its target: the element with
<small><code>id="foo"</code></small>. So by transitivity, this element dominates itself, and
by the acyclicity constraint, it is not the <acronym>XML</acronym> representation of an <i>OpenMath</i>
element. Even though it could be given the interpretation of the continued fraction
<m:math display="block">
 <m:mfrac>
   <m:mn>1</m:mn>
   <m:mrow>
     <m:mn>1</m:mn>
     <m:mo>+</m:mo>
     <m:mfrac>
       <m:mn>1</m:mn>
       <m:mrow>
         <m:mn>1</m:mn>
         <m:mo>+</m:mo>
         <m:mfrac><m:mn>1</m:mn><m:mi>...</m:mi></m:mfrac>
       </m:mrow>
     </m:mfrac>
   </m:mrow>
 </m:mfrac>
</m:math> this would correspond to an infinite tree of applications,
which is not admitted by the structure of <i>OpenMath</i> objects described
in <a href="#cha_obj">Chapter 2</a>.</p>

<p class="new">Note that the acyclicity constraints is not restricted
to such simple cases, as the example in <a href="#fig_sharing_between">Figure 4.2</a>
shows.</p>

<div class="new"><a name="fig_sharing_between" id="fig_sharing_between"/>
    
<div class="literal"><pre>&lt;OMOBJ version="2.0"&gt;                   &lt;OMOBJ version="2.0"&gt;
  &lt;OMA id="bar"&gt;                         &lt;OMA id="baz"&gt;
    &lt;OMS cd="arith1" name="plus"/&gt;         &lt;OMS cd="arith1" name="plus"/&gt;
    &lt;OMI&gt;1&lt;/OMI&gt;                           &lt;OMI&gt;1&lt;/OMI&gt;
    &lt;OMR xref="baz"/&gt;                      &lt;OMR xref="bar"/&gt;
  &lt;/OMA&gt;                                 &lt;/OMA&gt;
&lt;/OMOBJ&gt;                               &lt;/OMOBJ&gt;
</pre></div><div>
  Figure 4.2 Sharing between <i>OpenMath</i> objects (A cycle of order <m:math><m:mn>2</m:mn></m:math>.</div></div>

<p class="new"> Here, the <small><code>OMA</code></small> with
<small><code>id="bar"</code></small> dominates its third child, the
<small><code>OMR</code></small> with <small><code>xref="baz"</code></small>,
which dominates its target <small><code>OMA</code></small> with
<small><code>id="baz"</code></small>, which in turn dominates its third
child, the <small><code>OMR</code></small> with
<small><code>xref="bar"</code></small>, this finally dominates its
target, the original <small><code>OMA</code></small> element with
<small><code>id="bar"</code></small>. So this pair of <i>OpenMath</i> objects
violates the acyclicity constraint and is not the <acronym>XML</acronym>
representation of an <i>OpenMath</i> object.</p>
</div>


<div class="new"><h5 name="sec_sharing_bvars" id="sec_sharing_bvars">3.1.3.2 Sharing and Bound Variables</h5>


<p>Note that the <small><code>OMR</code></small> element is a
<i>syntactic</i> referencing mechanism: an
<small><code>OMR</code></small> element stands for the exact <acronym>XML</acronym>
element it points to. In particular, referencing does not interact
with binding in a semantically intuitive way, since it allows for
variable capture. Consider for instance the following <acronym>XML</acronym>
representation: <div class="literal"><pre>&lt;OMBIND id="outer"&gt;
  &lt;OMS cd="fns1" name="lambda"/&gt;
  &lt;OMBVAR&gt;&lt;OMV name="X"/&gt;&lt;/OMBVAR&gt;
  &lt;OMA&gt;
    &lt;OMV name="f"/&gt;
    &lt;OMBIND id="inner"&gt;
      &lt;OMS cd="fns1" name="lambda"/&gt;
      &lt;OMBVAR&gt;&lt;OMV name="X"/&gt;&lt;/OMBVAR&gt;
      &lt;OMR id="copy" href="#orig"/&gt;
    &lt;/OMBIND&gt;
    &lt;OMA id="orig"&gt;&lt;OMV name="g"/&gt;&lt;OMV name="X"/&gt;&lt;/OMA&gt;
  &lt;/OMA&gt;
&lt;/OMBIND&gt;
</pre></div>
it represents the <i>OpenMath</i> object
<m:math display="block">
  <m:mi mathvariant="bold">binding</m:mi>
  <m:mrow>
    <m:mo fence="true">(</m:mo>
    <m:mo>&#955;</m:mo>
      <m:mo separator="true">,</m:mo>
    <m:mi>X</m:mi>
    <m:mo separator="true">,</m:mo>
    <m:mrow>
      <m:mi mathvariant="bold">application</m:mi>
      <m:mo fence="true">(</m:mo>
      <m:mi>f</m:mi>
      <m:mo separator="true">,</m:mo>
      <m:mi mathvariant="bold">binding</m:mi>
      <m:mrow>
        <m:mo fence="true">(</m:mo>
        <m:mo>&#955;</m:mo>
        <m:mo separator="true">,</m:mo>
        <m:mi>X</m:mi>
        <m:mo separator="true">,</m:mo>
        <m:mrow>
          <m:mi mathvariant="bold">application</m:mi>
          <m:mo fence="true">(</m:mo>
          <m:mi>g</m:mi>
          <m:mo separator="true">,</m:mo>
          <m:mi>X</m:mi>
          <m:mo fence="true">)</m:mo>
        </m:mrow>
        <m:mo fence="true">)</m:mo>
      </m:mrow>
      <m:mo separator="true">,</m:mo>
      <m:mrow>
        <m:mi mathvariant="bold">application</m:mi>
        <m:mo fence="true">(</m:mo>
        <m:mi>g</m:mi>
        <m:mo separator="true">,</m:mo>
        <m:mi>X</m:mi>
        <m:mo fence="true">)</m:mo>
      </m:mrow>
      <m:mo fence="true">)</m:mo>
    </m:mrow>
    <m:mo fence="true">)</m:mo>
  </m:mrow>
  <m:mo fence="true">)</m:mo> </m:math> which has two sub-terms of the form
<m:math>
  <m:mi mathvariant="bold">application</m:mi>
  <m:mo fence="true">(</m:mo>
  <m:mi>g</m:mi>
  <m:mo separator="true">,</m:mo>
  <m:mi>X</m:mi>
  <m:mo fence="true">)
  </m:mo> </m:math>, one with <small><code>id="orig"</code></small> (the one explicitly
represented) and one with <small><code>id="copy"</code></small>, represented by the
<small><code>OMR</code></small> element. In the original, the variable
<m:math><m:mi>X</m:mi></m:math> is bound by the <i>outer</i>
<small><code>OMBIND</code></small> element, and in the copy, the variable
<m:math><m:mi>X</m:mi></m:math> is bound by the <i>inner</i>
<small><code>OMBIND</code></small> element. We say that the inner
<small><code>OMBIND</code></small> has captured the variable <m:math><m:mi>X</m:mi></m:math>.
</p>

<p>It is well-known that variable capture does not conserve semantics. For
  instance, we could use <m:math><m:mi>&#945;</m:mi></m:math>-conversion to rename the inner occurrence of
  <m:math><m:mi>X</m:mi></m:math> into, say, 
  <m:math><m:mi>Y</m:mi></m:math> arriving at the (same) object
<m:math display="block">
  <m:mi mathvariant="bold">binding</m:mi>
  <m:mrow>
    <m:mo fence="true">(</m:mo>
    <m:mo>&#955;</m:mo>
      <m:mo separator="true">,</m:mo>
    <m:mi>X</m:mi>
    <m:mo separator="true">,</m:mo>
    <m:mrow>
      <m:mi mathvariant="bold">application</m:mi>
      <m:mo fence="true">(</m:mo>
      <m:mi>f</m:mi>
      <m:mo separator="true">,</m:mo>
      <m:mi mathvariant="bold">binding</m:mi>
      <m:mrow>
        <m:mo fence="true">(</m:mo>
        <m:mo>&#955;</m:mo>
        <m:mo separator="true">,</m:mo>
        <m:mi mathcolor="red">Y</m:mi>
        <m:mo separator="true">,</m:mo>
        <m:mrow>
          <m:mi mathvariant="bold">application</m:mi>
          <m:mo fence="true">(</m:mo>
          <m:mi>g</m:mi>
          <m:mo separator="true">,</m:mo>
          <m:mi mathcolor="red">Y</m:mi>
          <m:mo fence="true">)</m:mo>
        </m:mrow>
        <m:mo fence="true">)</m:mo>
      </m:mrow>
      <m:mo separator="true">,</m:mo>
      <m:mrow>
        <m:mi mathvariant="bold">application</m:mi>
        <m:mo fence="true">(</m:mo>
        <m:mi>g</m:mi>
        <m:mo separator="true">,</m:mo>
        <m:mi>X</m:mi>
        <m:mo fence="true">)</m:mo>
      </m:mrow>
      <m:mo fence="true">)</m:mo>
    </m:mrow>
    <m:mo fence="true">)</m:mo>
  </m:mrow>
  <m:mo fence="true">)</m:mo> </m:math>
 Using references that
capture variables in this way can easily lead to representation errors, and is not
  recommended.
</p>
</div>
</div>

<div><h4 name="xmldoc" id="xmldoc">3.1.4 Embedding <i>OpenMath</i> in <acronym>XML</acronym> Documents</h4>


     
<p>The above encoding of <acronym>XML</acronym> encoded <i>OpenMath</i> specifies the grammar to be
used in files that encode a single <i>OpenMath</i> object, and specifies the
character streams that a conforming <i>OpenMath</i> application should be able
to accept or produce.</p>

<p>When embedding <acronym>XML</acronym> encoded <i>OpenMath</i> objects into a larger <acronym>XML</acronym> document
one may wish, or need, to use other <acronym>XML</acronym> features. For example use of
extra <acronym>XML</acronym> attributes to specify <acronym>XML</acronym> Namespaces <a href="#xmlns">[12]</a>
or <small><code>xml:lang</code></small> attributes to specify the language used in
strings <a href="#xml_04">[14]</a>. 
<span class="del">
Also, the encoding used in the larger document may not be
<acronym>UTF-8</acronym>.</span>
</p>

 <p class="del">In particular, if <i>OpenMath</i> is used with applications that use the
<acronym>XML</acronym> Namespace Recommendation  <a href="#xmlns">[12]</a> then they should ensure
that <i>OpenMath</i> elements are in the <span class="new">namespace
</span> <code>http://www.openmath.org/OpenMath</code>.
This is most conveniently achieved by adding the namespace declaration <div class="literal"><pre>
xmlns="http://www.openmath.org/OpenMath" </pre></div> as an attribute to each
<small><code>OMOBJ</code></small> element in the document.</p>



<p>If such <acronym>XML</acronym> features are used then the <acronym>XML</acronym> application controlling the
document must, if passing the <i>OpenMath</i> fragment to an <i>OpenMath</i> application,
remove any such extra attributes and must ensure that the
fragment is encoded according to the grammar specified above.</p>
</div>
</div>

<div><h3 name="sec_binary" id="sec_binary">3.2 The Binary Encoding</h3>


<p>The binary encoding was essentially designed to be more compact than
the <acronym>XML</acronym> encodings, so that it can be more efficient if large
amounts of data are involved. For the current encoding, we tried to
keep the right balance between compactness, speed of encoding and
decoding and simplicity (to allow a simple specification and easy
implementations).</p>

<div><h4 name="sec_binary_grammar" id="sec_binary_grammar">3.2.1 A Grammar for the Binary Encoding</h4>


     

<div class="figure"><a name="fig_bin-enc" id="fig_bin-enc"/>
    
    
    <table>
          <tr>
            <td>start </td>
            <td><m:math><m:mo>&#8594;</m:mo></m:math></td>
            <td> [24] object [25] </td>
            <td class="new">|</td>
            <td class="new">
	      [24+64]
	      [<m:math><m:mi>m</m:mi></m:math>]
              [<m:math><m:mi>n</m:mi></m:math>]
	      object [25]</td>
          </tr>
          
          <tr>
            <td>object </td>
            <td><m:math><m:mo>&#8594;</m:mo></m:math></td>
            <td> integer </td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> float</td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> variable</td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> symbol</td>
          </tr>

          <tr>
            <td/>
            <td>|</td>
            <td>cdbase</td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> string</td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> bytearray</td>
          </tr>
          
          <tr class="new">
            <td/>
            <td>|</td>
            <td>foreign</td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> construct</td>
          </tr>
          
          <tr class="new">
            <td/>
            <td>|</td>
            <td>internal_reference</td>
          </tr>
          
          <tr class="new">
            <td/>
            <td>|</td>
            <td>external_reference</td>
          </tr>
          
          <tr>
            <td>integer </td>
            <td><m:math><m:mo>&#8594;</m:mo></m:math></td>
            <td> [1] [_] </td>
            <td class="new">|</td>
            <td class="new"> [1+64]
              [<m:math><m:mi>n</m:mi></m:math>]
              id:<m:math><m:mi>n</m:mi></m:math>               [_]
            </td>
          </tr>

          <tr class="new">
            <td/>
            <td><m:math><m:mo>|</m:mo></m:math></td>
            <td> [1+32] [_] </td>
            <td/>
            <td/>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> [1+128] {_} </td>
            <td class="new">|</td>
            <td class="new"> [1+64+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              id:<m:math><m:mi>n</m:mi></m:math>               {_}
            </td>
          </tr>

          <tr class="new">
            <td/>
            <td>|</td>
            <td> [1+32+128] {_} </td>
            <td/>
            <td/>
          </tr>

          <tr>
            <td/>
            <td>|</td>
            <td> [2]
              [<m:math><m:mi>n</m:mi></m:math>]
              [_] digits:<m:math><m:mi>n</m:mi></m:math>             </td>
            <td class="new">|</td>
            <td class="new"> [2+64]
              [<m:math><m:mi>n</m:mi></m:math>]
              [<m:math><m:mi>m</m:mi></m:math>]
              [_] digits:<m:math><m:mi>n</m:mi></m:math>               id:<m:math><m:mi>m</m:mi></m:math>             </td>
          </tr>

          <tr class="new">
            <td/>
            <td>|</td>
            <td> [2+32]
              [<m:math><m:mi>n</m:mi></m:math>]
              [_] digits:<m:math><m:mi>n</m:mi></m:math>             </td>
            <td/>
            <td/>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> [2+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              [_] digits:<m:math><m:mi>n</m:mi></m:math>             </td>
            <td class="new">|</td>
            <td class="new"> [2+64+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              {<m:math><m:mi>n</m:mi></m:math>}
              [_]
              digits:<m:math><m:mi>n</m:mi></m:math>               id:<m:math><m:mi>n</m:mi></m:math>             </td>
          </tr>
          
          <tr class="new">
            <td/>
            <td>|</td>
            <td> [2+32+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              [_] digits:<m:math><m:mi>n</m:mi></m:math>             </td>
            <td/>
            <td/>
          </tr>
          
          <tr>
            <td>float </td>
            <td><m:math><m:mo>&#8594;</m:mo></m:math></td>
            <td> [3] {_}{_} </td>
            <td class="new">|</td>
            <td class="new"> [3+64]
              [<m:math><m:mi>n</m:mi></m:math>]
              id:<m:math><m:mi>n</m:mi></m:math>               {_}{_}</td>
          </tr>
          
          <tr>
            <td>variable </td>
            <td><m:math><m:mo>&#8594;</m:mo></m:math></td>
            <td> [5]
              [<m:math><m:mi>n</m:mi></m:math>]
              varname:<m:math><m:mi>n</m:mi></m:math>             </td>
            <td class="new">|</td>
            <td class="new"> [5+64]
              [<m:math><m:mi>n</m:mi></m:math>]
              [<m:math><m:mi>m</m:mi></m:math>]
              varname:<m:math><m:mi>n</m:mi></m:math>               id:<m:math><m:mi>m</m:mi></m:math>             </td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> [5+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              varname:<m:math><m:mi>n</m:mi></m:math>             </td>
            <td>|</td>
            <td class="new"> [5+64+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              {<m:math><m:mi>m</m:mi></m:math>}
              varname:<m:math><m:mi>n</m:mi></m:math>               id:<m:math><m:mi>m</m:mi></m:math>             </td>
          </tr>
          
          <tr>
            <td>symbol</td>
            <td><m:math><m:mo>&#8594;</m:mo></m:math></td>
            <td> [8]
              [<m:math><m:mi>n</m:mi></m:math>]
              [<m:math><m:mi>m</m:mi></m:math>]
              cdname:<m:math><m:mi>n</m:mi></m:math>               symbname:<m:math><m:mi>m</m:mi></m:math>             </td>
            <td class="new">|</td>
            <td class="new"> [8+64]
              [<m:math><m:mi>n</m:mi></m:math>]
              [<m:math><m:mi>m</m:mi></m:math>]
              [<m:math><m:mi>k</m:mi></m:math>]
              cdname:<m:math><m:mi>n</m:mi></m:math>               symbname:<m:math><m:mi>m</m:mi></m:math>               id:<m:math><m:mi>k</m:mi></m:math>             </td>
          </tr>
          
          <tr>
            <td/>
            <td>|</td>
            <td> [8+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              {<m:math><m:mi>m</m:mi></m:math>}
              cdname:<m:math><m:mi>n</m:mi></m:math>               symbname:<m:math><m:mi>m</m:mi></m:math>             </td>
            <td class="new">|</td>
            <td class="new"> [8+64+128]
              {<m:math><m:mi>n</m:mi></m:math>}
              {<m:math><m:mi>m</m:mi></m:math>}
              {<m:math><m:mi>k</m:mi></m:math>}
              cdname:<m:math><m:mi>n</m:mi></m:math>               symbname: