SPARQL in N3: SPARQL construct as a rule language for the Semantic Web (Extended Version)
Dörthe Arndt, William Van Woensel, Dominik Tomaszuk · 2025
Read SPARQL in N3: SPARQL construct as a rule language for the Semantic Web (Extended Version) by Dörthe Arndt, William Van Woensel, Dominik Tomaszuk (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2508-13041.txt.
Introduction
Dorthe Arndt and co-authors turn SPARQL queries into a rule language for the Semantic Web in a 2025 extended paper. Web reasoning today leans on description logics or rule formats that sit outside the core data model.
SPARQL CONSTRUCT queries can act as logic rules, giving a familiar and strong rule tongue. Queries can also run on results of other queries, which allows recursion. The team translates the queries into Notation3 rules for use with current reasoners. A one-to-one mapping keeps rules readable and easy to swap. Benchmarks show speed in line with rival tools. Web engineers get rules built from a query language they already know.
Catalog record
| CREATOR | Dörthe Arndt, William Van Woensel, Dominik Tomaszuk |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 57 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2508-13041
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
SPARQL in N3: SPARQL construct as a rule language for the Semantic Web (Extended Version) Dörthe Arndt, William Van Woensel, Dominik Tomaszuk Abstract Reasoning in the Semantic Web (SW) commonly uses Description Logics (DL) via OWL2 DL ontologies, or SWRL for variables and Horn clauses. The Rule Interchange Format (RIF) offers more expressive rules but is defined outside RDF and rarely adopted. For querying, SPARQL is a well-established standard operating directly on RDF triples. We leverage SPARQL construct queries as logic rules, enabling (1) an expressive, familiar SW rule language, and (2) general recursion, where queries can act on the results of others. We translate these queries to the Notation3 Logic (N3) rule language, allowing use of existing reasoning machinery with forward and backward chaining. Targeting a one-to-one query–rule mapping improves exchangeability and interpretability. Benchmarks indicate competitive performance, aiming to advance the potential of rule-based reasoning in the SW. 1 Introduction In our experience, most reasoning on the Semantic Web (SW) relies on Description Logics (DL) in the form of OWL2 DL [ 25 ] ontologies. DL is less expressive than first-order logic, and expressing the desired (e.g., rule-based) logic can be challenging. SWRL [ 23 ] extends OWL interpretations with variables and Horn-like rules, but operates on OWL rather than RDF, and cannot generate blank nodes. The more expressive Rule Interchange Format (RIF) offers 3 dialects to cover the different needs of rule systems. However, it is defined outside of the RDF data model, and is, to the best of our knowledge, not widely adopted. We thus argue that the potential of logic SW reasoning has not been realized. On the other hand, when it comes to querying RDF data, SPARQL [ 18 ] is an expressive and well-established standard, with native support for RDF triples. Notably, since SPARQL construct queries are closed, i.e., RDF graphs are used as both input and output, they can be used to represent logical rules: if the where clause holds, then the query template can be inferred. The expressivity and popularity of SPARQL can be leveraged to express logic rules on the SW. Moreover, this adds general recursion in SPARQL: i.e., when executed as rules, construct queries can operate on the results of other construct queries. In this work, we support SPARQL 1.1 query patterns, filters, and the select and construct forms. Others have proposed using SPARQL as a logic rule language. Two types of approaches exist: (a) translating SPARQL into a non-SW logic rule language, namely Datalog [ 28 , 17 , 3 ] , so that rule engines can be used for reasoning; and (b) extending an existing query engine with reasoning capabilities [ 30 , 24 ] . However, Datalog does not follow SW principles; and while query engines allow dealing with large datasets and many joins, they lack backward reasoning capabilities. We propose a translation of SPARQL into the Notation3 (N3) [ 12 , 36 ] logic rule language, called SiN3 (SPARQL-in-N3). This allows leveraging the existing rule machinery (eye [ 37 ] , cwm [ 11 ] , jen3 [ 35 ] ) for implementing backward and forward reasoning reasoning. Moreover, as N3 follows SW principles, translations are not restricted to local use and can be exchanged on the SW. A “runtime” set of rules, which is novel in the literature on SPARQL to rule translation, allows (1) translating a single query into a single rule, which makes it easier to exchange, and even manually tweak, translations; and even (2) a true cross-fertilization, by also allowing SPARQL features to be used in N3. To illustrate its meta-reasoning capabilities, we used N3 itself to translate from a triple-based SPARQL (SPIN [ 24 ] ) to N3 rules. Our evaluation shows a competitive performance for our preliminary work. A demo paper was previously published about this work [ 6 ] . Contributions . (1) We translate SPARQL into the SW-compliant N3 rule language; (2) In doing so, we add general recursion to SPARQL, a feature that is still lacking [ 30 , 3 ] ; (3) We provide correctness results for our approach; (4) We evaluate and compare our approach to other similar systems, using large datasets from the literature. As far as we know, this is the first effort to translate SPARQL into a SW rule language, with a one-to-one mapping between queries and rules. Paper Organization. Section 2 introduces the overall idea of our approach. Section 3 discusses related work. Sections 4 and 5 explain SPARQL, and N3, respectively. Section 6 describes our translation of SPARQL queries into N3 rules, including complex constructs and runtime rules. Section 7 evaluates the performance of our method. Finally, Section 8 concludes the paper. 2 Motivation To motivate our choice for logic rule language, we provide examples of SPARQL and N3 which illustrate how closely these two frameworks are related. SPARQL and N3 both operate on RDF triples like for example: 1 1 1 For brevity, we omit prefixes if they are not relevant or well-known. :John a :Researcher. (1) With SPARQL we can query for patterns on sets of triples and retrieve variable bindings ( select ) or create new graphs ( construct ). Applying the query CONSTRUCT {?x a :Person . } WHERE {?x a :Researcher . } (2) on a graph containing triple 1 results in: :John a :Person. (3) Since a new graph is being constructed from the original graph, this is comparable to the application of the following N3 rule {?x a :Researcher .}=>{?x a :Person .} (4) where => is a logical implication; the conclusion (second clause) is inferred if the premise holds (first clause). Applying rule 4 on triple 1 also yields triple 3 . An important difference between executing rule 4 and query 2 , however, is that N3 applies rules recursively: triple 3 becomes part of the knowledge, and other rules can be applied on this derivation. In contrast to that, SPARQL is a query language and only produces triple 3 to provide it as output to the user. When choosing a logic rule language, the close relation in terms of syntax between SPARQL and N3 makes the latter a good candidate: users coming from SPARQL, while they will likely not be N3 experts, will be better able to understand and—if needed—tweak the N3 translation. To further facilitate such manual editing, as well as the exchange of translations on the Web, we translate each query to exactly one N3 rule. Users can also combine these rules with existing, “native” N3 rules from other sources to suit their needs (e.g., OWL2 RL [ 16 ] , OWL-P [ 33 ] and L2 [ 15 ] inferencing). 3 Related Work Below, we review approaches that utilize SPARQL to perform reasoning. 3.1 SPARQL Translation to Rule Languages Polleres [ 28 ] first translated SPARQL into Datalog, with negation as failure based on Answer Set Programming (ASP). It allows blank node-free construct queries to act as a recursive rule language over RDF. Gottlob et al. [ 17 ] target general recursion in SPARQL by developing TriQ-Lite 1.0 based on Warded Datalog^{\exists,\neg sg,\bot} . The authors translate SPARQL queries under the OWL2 QL entailment regime into TriQ-Lite 1.0.