Skip to content

Instantly share code, notes, and snippets.

@afs
Last active November 4, 2025 11:45
Show Gist options
  • Select an option

  • Save afs/0c63131faedf4baec74248fe56cb13cc to your computer and use it in GitHub Desktop.

Select an option

Save afs/0c63131faedf4baec74248fe56cb13cc to your computer and use it in GitHub Desktop.
2025-11-03 Notes fo SHACL Rules doc.
  1. Introduction

1.1 Terminology
1.2 Document Conventions
1.3 Conformance
Test suite

1.x Working notes:

  • NX aggregate functions. These may not work.
  1. SHACL Rules
    (informative section (non-normative) explaining the main features)

Basic outline, key features, not all features. Audience: rules engineer

Example.

What are "rules"? A set of conditions of the form that infer new information from existing data.

Apply rules: rules+data -> new information

2.1 Structure of a Rule

Head-Body: match body (the "if",) and generate new informtion ("triples") Or as H is true when B

Body is a pattern, with value restriction.

** Example 1 of a rule that does not depend on other rules. ** Example 2 of a rule with a filter.

2.2 Operations - infer(), query()

A rules system can provide one or both of these operations.

  • "infer" - create all new information
  • "query" - given a simple pattern, can it be inferred by the rules+data.

2.3 Rule Dependencies

Rules can depend on rules.

Including recursion.

** Example3: A rule that depends on another rule. :ancestor

2.4 Rule Dependency and Rule Set Stratification

Explanation

"We say that rule1 depends on rule2 if ..."

2.5 Negation-as-failure

{:s :p ?z . NOT EXISTS { ?z :q ?v } ... }

2.6 Assignment

and why it is beyond datalog

"safe assignment" - previous stratification.

  1. Shape Rules Abstract Syntax (Definition section)

3.1 Well-formedness Condition for a rule body FILTERs, Assignments

3.2 Dependency Relationship Definition

3.3 Stratification Definition
... and well-formedness conditions (NAF and recursion)
EXISTS - with body pattern (a limited graph pattern)

  1. Concrete Syntax forms for Shapes Rules
    4.1 RDF Rules Syntax
    4.2 Compact Rules Syntax
    4.2.1 Compact Syntax Abbreviations
    4.3 SPARQL function restrictions

No BOUND, FILTER (NOT) EXISTS (available as a pattern)

Added pattern EXISTS/NOT EXISTS, arg is a body pattern.

?? IF

  1. Shape Rules Evaluation

5.1 Evaluation of an expression
5.2 Evaluation of a rule
5.3 Evaluation of a Rule Set

Evaluation of

  • positive datalog infer(), query().
  • semi-positve datalog

In semi-positive Datalog => Pattern for the EXISTS only mentions pattens that do not occur in any rule head.

  1. Possible variants

Are simpler to implement subsets well-defined enough? Stratified NAF

  1. Attaching Rules to Shapes
    Does (some) targets as patterns work for a definition?

  2. Workspace named tuples

Syntax:

? TUPLE(name/string, varTerm1, varTerm2, ...) -- include this and maybe a short form.

  • &name(varTerm1, varTerm2, ...)
  • other charcater: % (caveat %xx), ^, *, \name, |name|(varTerm1, varTerm2, ...)

Appendix A: SHACL Rules Grammar
Appendix B: Relationship to SHACL-AF

Triple rules
SPARQL rules

Appendix C: Relationship to node expressions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment