Currently, we only export the MathML representation of a formula to RDF, not the original TeX string (T126349). This makes it impossible to efficiently query for statements with a certain math value – you have to use `REGEX` (`CONTAINS` is not enough, because the TeX annotation embedded in the MathML is not identical to the original TeX string). It also means that any external application that wants to use the TeX string based on the RDF export must use an XML parser to analyze the MathML and extract the TeX annotation.
I think we should add full value nodes for math values, with a structure a bit like this:
```lang=sparql
wd:Q4115189 a wikibase:Item;
# ...
wdt:P2534 "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\" alttext=\"{\\displaystyle a}\">\n <semantics>\n <mrow class=\"MJX-TeXAtom-ORD\">\n <mstyle displaystyle=\"true\" scriptlevel=\"0\">\n <mi>a</mi>\n </mstyle>\n </mrow>\n <annotation encoding=\"application/x-tex\">{\\displaystyle a}</annotation>\n </semantics>\n</math>"^^<http://www.w3.org/1998/Math/MathML>.
wd:Q4115189 p:P2534 wds:Q4115189-af122b69-484b-2edd-1af8-f0a691b05039.
wds:Q4115189-af122b69-484b-2edd-1af8-f0a691b05039 a wikibase:Statement;
ps:P2534 "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\" alttext=\"{\\displaystyle a}\">\n <semantics>\n <mrow class=\"MJX-TeXAtom-ORD\">\n <mstyle displaystyle=\"true\" scriptlevel=\"0\">\n <mi>a</mi>\n </mstyle>\n </mrow>\n <annotation encoding=\"application/x-tex\">{\\displaystyle a}</annotation>\n </semantics>\n</math>"^^<http://www.w3.org/1998/Math/MathML>;
psv:P2534 wdv:d961720c22709f7991be5be0ddf51c88.
wdv:d961720c22709f7991be5be0ddf51c88 a wikibase:MathValue;
wikibase:mathML "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\" alttext=\"{\\displaystyle a}\">\n <semantics>\n <mrow class=\"MJX-TeXAtom-ORD\">\n <mstyle displaystyle=\"true\" scriptlevel=\"0\">\n <mi>a</mi>\n </mstyle>\n </mrow>\n <annotation encoding=\"application/x-tex\">{\\displaystyle a}</annotation>\n </semantics>\n</math>"^^<http://www.w3.org/1998/Math/MathML>;
wikibase:mathTeX "a"^^<http://latex.example/TODO>.
```
Side note: the “math” datatype currently seems to be missing completely from the [RDF Dump Format](https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format) page – once we’ve implemented this, we should rectify that.
```
The string as input in Wikidata (whatever format) should to be available on Wikidata Query Service. Currently it's in the json format, but not on WQS. See T126349#2014848 for more information
```
See also the discussion on the [request a query](https://www.wikidata.org/wiki/Wikidata:Request_a_query#Defining_formula_(P2534%29) page.