Quantcast
Channel: public-shacl Mail Archives
Viewing all articles
Browse latest Browse all 220

[data-shapes] SHACL Rules - discussion of scope and direction (#282)

$
0
0
afs has just created a new issue for https://github.com/w3c/data-shapes:

== SHACL Rules - discussion of scope and direction ==
# SHACL Rules 

SHACL rules infer new triples. The input is a data graph and a shape graph with rules, the output is a graph of inferred triples.

Whether, and how, the output graph is added back into the data graph is a separate decision.

The design must respect both simple implementations as well as implementations focused on performance and scale.

The data graph may be large (= impractical in main memory). The shapes graph is assumed to be small enough it can be read and processed in memory.

There may be thousands of rules. (Generated mappings between datasets can easily have a large numbers of rules.)

*Syntax examples are not real, nor consistent; they are just for illustration and intentionally different from reality.*

## SHACL Rules so far

SHACL-AF has
* [Property Value Rules](https://w3c.github.io/shacl/shacl-af/index.html#PropertyValueRule)
* [Single Triple rules](https://w3c.github.io/shacl/shacl-af/index.html#TripleRule)
* [SPARQL Rules](https://w3c.github.io/shacl/shacl-af/index.html#SPARQLRule) (SPARQL `CONSTRUCT`)

and we now have [Derived properties](https://github.com/w3c/data-shapes/wiki/Proposal-on-Node-Expressions-for-SHACL-Core-1.2) which use [Node Expressions](https://github.com/w3c/data-shapes/issues/222) as generators of lists of nodes.

Targets are themselves "generators" - they are a pattern such as `?target sh:targetClass :SomeClass` generating a collection of nodes.

## Requirements

Please add use cases as issues, labelled with "Inferencing" and "UCR". Do not worry about overlaps or duplicates.

https://github.com/w3c/data-shapes/issues?q=is%3Aissue%20state%3Aopen%20label%3AInferencing%20label%3AUCR

* #227
* #220
* #219

## ["The latter is left to future work"](https://www.w3.org/TR/shacl-af/#:~:text=The%20latter%20is%20left%20to%20future%20work) 

This comment in SHACL-AF is about rules depending on inferred triples from other rules. The future has arrived.

One part of this is taming CONSTRUCT-based rules. 

1. CONSTRUCT-based rules can generate multiple triples and optional triples.
2. The triple patterns used to match by the rule are opaque and so a rules engine does not know how rules depends on each other
3. The pattern matching includes negation (`NOT EXISTS`), value negation (`FILTER(?x != )`) and creating new RDF terms, all of which affect evaluation when rules depend other rules.

## Outline

* One language (RDF syntax, hopefully with SHACL Compact as well for easy of authoring and maintenance).
* The rules language would be neutral to the execution - backward or forward chaining, create new nodes, rule recursion, etc.
* Multiple profiles of execution. More powerful profiles may generate more triples from the same language. Profiles may restrict the syntax.
* Some profiles have well-understood evaluation properties.
* There is a "production rules" profile. A set of rules can go wrong - infinite loops, order dependent outcomes. It is more akin to programming.

Datalog[^1] provides well-understood evaluation properties and there are various algorithms for execution ranging from simple-to-implement to complex. We are not starting from scratch.

## Out of scope

* Truth maintenance

## Note about transitivity

The rule for a transitive property is recursive. But it is a specific case of general recursive rules and might be a special case so we could have a profile that is "non-recursive + transitive properties".

The full rule:
```
IF (?x rdfs:subClassOf ?y) (?y rdfs:subClassOf ?z)
THEN 
   infer (?x rdfs:subClassOf ?z)
```
might be written:

```
TRANSITIVE(rdfs:subClassOf)
```

[^1]: See, for example, part D in the book [Foundations of Databases](http://webdam.inria.fr/Alice/) (chapters 12 to 15).  
   Many university course notes and slides are online.


Please view or discuss this issue at https://github.com/w3c/data-shapes/issues/282 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Viewing all articles
Browse latest Browse all 220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>