Are there any established ways of representing mathematical formulas or expressions in RDF?

A web search turned up a paper by Marchiori (2003) which provides an overview of relevant Semantic Web standards, and even contains an example of how a MathML fragment like this:

  <csymbol encoding="text"
  <cn> 2 </cn>
  <cn> 6 </cn>

could be represented in RDF like this:

:_1 <http://www.w3.org/TR/MathML2#apply> :_2
:_1 <http://www.w3.org/TR/MathML2#csymbol> "p"
:_1 <http://www.w3.org/TR/MathML2#definitionURL> 
:_1 <http://www.w3.org/TR/MathML2#encoding> "text"
:_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#:_1> "2"
:_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#:_2> "6"

However, that was just an example, and I couldn't find anything which would describe a complete framework for something like that.

Edit for clarification. I am looking for something which would allow to represent mathematical expressions which refer to other resources described in RDF as sub-expressions. Even perhaps something that would allow to construct mathematical expressions by some sort of rule language (like SPARQL CONSTRUCT queries). Therefore just using MathML (or OpenMath) markup in a XML Literal does not seem like a good solution.

asked 10 May '10, 23:03

Jukka%20Matilainen's gravatar image

Jukka Matila...
accept rate: 75%

edited 28 May '10, 10:33

In terms of the direct question I don't know of an established way of doing this.

What you want to achieve?

If you want to convey some mathematical markup over RDF but that maths is not "executable" or doesn't need to interact with the RDF itself then the obvious approach would be to use MathML to encode the content and embed the MathML fragments as rdf:XMLLiterals.

OTOH if you are trying to express some mathematics that will interact with the RDF data - for example integrity constraint checking or formulae for deriving computed values - then you might want to consider an RDF rule language. RIF Core can express some interesting maths and the semantics of RIF + RDF combinations is well defined, though there is not yet a standardized way of embedding RIF rules directly in RDF. SWRL, is another alternative, has been around for longer and has reasonable tool support.

permanent link

answered 11 May '10, 16:18

Dave%20Reynolds's gravatar image

Dave Reynolds
accept rate: 46%

Edited my question to hopefully clarify a bit what I am trying to achieve.

(28 May '10, 10:34) Jukka Matila... Jukka%20Matilainen's gravatar image

As Dave says, there is no established way. In section 3.4.1 and 3.4.2 of this survey – http://www.semantic-web-journal.net/content/new-submission-ontologies-and-languages-representing-mathematical-knowledge-semantic-web, page 16 –, I provide a review of all ways known to date:

  1. complete representation of formulae in RDF: Marchiori's way was a mere proposal that has never been worked out, but there is a more elaborate alternative by Robbins (not applied in pratice either, AFAIK); see http://straymindcough.blogspot.com/2009/06/semantic-mathml.html. Using the N3 extensions over RDF makes the whole thing more elegant but less compatible with RDF tools. RDF-based approaches hardly give you access to the semantic essence of a mathematical formula.
  2. MathML or OpenMath fragments as rdf:XMLLiterals: basically what Dave says above, and that has actually been worked out at least once, in combination with an RDF representation of "higher-level" math structures, such as symbols and definitions, by an ontology. But for the formulae it means that they are mostly opaque to RDF tools (with a few exceptions).
  3. RDFa: There is the theoretical possibility of annotating MathML with RDFa, e.g. using Robbins's ontology mentioned unter (1). However that doesn't conform with the specification of MathML, and combined XML/RDF queries are not yet well supported.
  4. Standoff markup: represent the math as XML, but have RDF "pointers" from externally, which point to those subterms/symbols in your formula that are relevant for your application. This has been practiced in several projects and implementations. Again there is no single standard solution or ontology for these RDF pointers into math XML, but from my experience I'd say that this approach works best.
permanent link

answered 10 Feb '11, 10:14

Christoph%20Lange's gravatar image

Christoph Lange
accept rate: 0%

I've presented an approach for the integration of mathematical expressions into RDF datasets for the purpose of mathematical reasoning on the OpenMath workshop 2012.

The paper Mathematical Computations for Linked Data Applications with OpenMath covers an OpenMath content dictionary for RDF that allows to reference RDF resources and their properties from mathematical expressions. This is complemented by an OWL ontology for OpenMath objects (available at http://numerateweb.org/vocab/math) to enable the encoding of mathematical expressions in RDF for cross-referencing between mathematical expressions and RDF data.

The simple example taken from our paper (in an extended Popcorn notation)

[foaf:Person] : 
@e:bmi = @e:mass / @e:height ^ 2

[foaf:Group] :
@e:aBMI = sum(@@foaf:member, $x -> @e:bmi($x)) / set1.size(@@foaf:member)

is based on the FOAF vocabulary and defines the properties e:mass and e:height for the class foaf:Person and uses them to compute the e:bmi properties of individual persons and their average e:aBMI over a group.

An interesting point is that we can use an RDF graph for storing intermediate results of computations. For example, e:bmi is stored as a property of an foaf:Person and later reused for computing e:aBMI.

Library for Java

We also provide an Open Source Java library for encoding and decoding OpenMath objects in XML, RDF, (extended) POPCORN and Symja at https://github.com/numerateweb/. The library project is called org.numerateweb.math. Additionally, the project openmath-cd contains an RDF serialization of all OpenMath Content Dictionaries.

Please note that the org.numerateweb.math library depends on KOMMA, an RDF framework for Java. We can also provide an all-in-one binary bundle if someone is interested.

permanent link

answered 26 Jul '12, 05:26

Ken%20Wenzel's gravatar image

Ken Wenzel
accept rate: 20%

edited 19 Aug '14, 04:06

the popcorn link seems to be broken...

(25 Oct '12, 20:26) Andrew ♦♦ Andrew's gravatar image

The java.symcomp.org server seems to be down from time to time. Our numerateweb.org server is also not very stable at the moment.

(29 Oct '12, 10:57) Ken Wenzel Ken%20Wenzel's gravatar image

I faced the same need to represent expressions in RDF. Not only mathematical expressions, but any symbolic expressions and data structures (e.g., type expressions from programming languages, queries). I came up with a solution that I presented at ESWC'13 (as a poster, but a longer version is available as a technical report). It was designed to be simple, standard RDF, generic, and suitable for structural querying with SPARQL or other RDF query language.

The principle I followed was to reuse the structure of RDF containers, which are not much used in practice. The math expression $\int x^2 + 1 dx$ is represented in RDF/Turtle by (assuming math: is a namespace for mathematical symbols)

[ a math:Integral ;
  rdf:_1 [ a math:Addition ;
           rdf:_1 [ a math:Power ;
                    rdf:_1 _:x ;
                    rdf:_2 "2"^^xsd:integer ] ;
           rdf:_2 "1"^^xsd:integer ] ;
  rdf:_2 _:x ]

The type of the container is a mathematical symbol/operation/function, and its elements are its arguments. Typed literals are used for constants. Named blank nodes (here, _:x) are used to represent bound variables, and support alpha-equivalence (renaming of bound variables).

To make Turtle notations lighter, I also proposed a new syntactic abbreviation for Turtle (which already has abbreviations for lists), allowing for functional notation of expressions.

[ a C; rdf:_1 E1 ; ... ; rdf:_N EN ] can be noted C(E1,...,EN)

The above expression can now be represented as


Such representations allow for rich queries based on the structure of expressions. For example, it is possible to retrieve all integrals in x whose body contains x^2 as a sub-expression.

SELECT ?e WHERE { ?e is math:Integral(...math:Power(?x,2)..., ?x) }

This query uses additional abbreviations, and is equivalent to the following query, which only uses standard notations.

  ?e a math:Integral ;
     rdf:_1 [ rdfs:member* [ a math:Power ; rdf:_1 ?x ; rdf:_2 2 ] ] ;
     rdf:_2 ?x .

The use of a SPARQL variable ?x for the bound variable of the integral, enables to retrieve the expression $\int y^2 - y dy$ as well as $\int x^2 + 1 dx$.

The technical report provides more details, and also what can done with such RDF expressions (pretty-printing, interactive exploration).

permanent link

answered 24 Feb '14, 09:50

sebferre's gravatar image

accept rate: 0%

edited 24 Feb '14, 09:58

The simplest approach is to define a new datatype for MathML literals. Let say http://www.w3c.org/datatypes/mathMLLiteral. (ideally it should be defined by W3C). Other serialization datatypes could be introduced for Latex or Mathematica expressions.

In Turtle format, this would look like this:

@prefix math:<http://example.org/ont/math#>

:APlusB a math:Addition
   math:serialization """<apply> <csymbol cd="arith1">plus</csymbol>
                         <ci id='exampleontology#a'>a</ci>
                         <ci id='exampleontology#b'>b</ci>
                         </apply> """^^<http://www.w3c.org/datatypes/mathMLLiteral> .

A similar encoding pattern is used in GeoSPARQL standard, where geometries are encoded in WKT or GML. Geosparql introduces two different datatypes for each: http://www.opengis.net/ont/geosparql#wktLiteral and <http://www.opengis.net/ont/geosparql#gmlLiteral

permanent link

answered 12 Apr '14, 17:15

fellahst's gravatar image

accept rate: 12%

edited 12 Apr '14, 17:37


This is indeed a simple and efficient solution to include mathematical expressions in RDF, but this makes them mostly opaque to RDF tools. For example, you can't search for math. expressions with SPARQL, unlike with my answer above.

(13 Apr '14, 04:51) sebferre sebferre's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 May '10, 23:03

question was seen: 8,432 times

last updated: 19 Aug '14, 04:06