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:
could be represented in RDF like this:
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.
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.
answered 11 May '10, 16:18
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:
answered 10 Feb '11, 10:14
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)
is based on the FOAF vocabulary and defines the properties
An interesting point is that we can use an RDF graph for storing intermediate results
of computations. For example,
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)
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.
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.
This query uses additional abbreviations, and is equivalent to the following query, which only uses standard notations.
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).
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:
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