[data-shapes] Rule tuples - workspace during rule evaluation (#752)

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

== Rule tuples - workspace during rule evaluation ==
[Datalog](https://en.wikipedia.org/wiki/Datalog) is based around "atoms". An atom consists of a name (a predicate symbol) and zero or more terms, where each term is a constant or a variable. Atoms are also called literals. Atoms do not contains atoms (unlike prolog).

Viewed as datalog, SHACL Rules has one type of atom used as triple/triple pattern/triple template, depending on position.

Having other tuples forms can be useful during rule execution.

A rule might emit a tuple to represent intermediate matching results to be shared by several other rules. Without some working space during execution, either the same pattern will be repeated in the other rules, or some intermediate triples are needed and these will end up in the output inference graph.

Rule tuples are workspace elements and are disjoint from triples. They are tuples of RDF terms (no variables).

Syntax of tuple patterns, templates and tuples:

```
TUPLE(termOrVar , ...)
```
with a shorthand:
```
$(termOrVar , ...)
```

Often, the first argument will be a fixed name - think of it as an SQL table name or a programming language struct.

There is a tuple store which holds tuples for the lifetime of the evaluation.
The tuple store holds duplicate data tuples (unlike an RDF graph which is a set).

A rule tuple pattern can appear in the body of a rule, where it matches in a similar fashion to a triple pattern -- look in the tuple store for matches based on arity and any constant RDF terms, returning a sequence of solution mappings. (Implementation note: indexing by first argument will greatly speed up access for the "fixed name" style.)

A rule tuple template can appear in the head of a rule, where it acts to generate grounded data tuples (i.e. no variables) which are added to the tuple store.

A rule data tuple can appear in a `DATA` block, where it is added to the tuple store at the start of execution.

The tuple store is ephemeral. It is not defined as an output of the evaluation process.


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


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

Received on Saturday, 31 January 2026 12:42:46 UTC