RETE-based RDFS and OWL 2 RL entailment for RDFLib
Project description
RDFLib Reasoning Engine
Agentic AI should be able to take advantage of basic reasoning in an efficient manner.
RDFS and OWL 2 RL reasoning define the semantics for two entailment regimes.
These regimes can be computed using forward-chaining rules, though practical approaches may also benefit from special handling for transitive closures.
The rdflib-reasoning-engine package provides an efficient general purpose forward chaining rule engine (i.e., RETE) that works with RDFLib.
Tutorials and demos
If you want to see the current RDFS inference surface in action, start with:
- ../notebooks/demo-rdfs-inference.ipynb: compact end-to-end tutorial for RDFLib-backed RDFS materialization plus a proof view of the rule applications behind one inferred triple
- ../notebooks/demo-proof-reconstructor.ipynb: proof-focused companion notebook covering proof reconstruction, Mermaid rendering, markdown rendering, and raw proof inspection
Feature Matrix
Status values:
Implemented: available in the package todayIn progress: scaffolding or partial implementation exists, but the feature is not yet wired end-to-endNot started: identified feature target with no concrete implementation yet
RDFS entailment rules
This matrix tracks the intermediate RDFS rule target using the cached RDF 1.1 Semantics specification at docs/specs/rdf11-semantics/optimized.html. The informative RDFS entailment rules are identified there as rdfs1 through rdfs13.
| Feature | Spec reference | Status |
|---|---|---|
| Property typing | rdfs1 |
Implemented |
| Domain inference | rdfs2 |
Implemented |
| Range inference | rdfs3 |
Implemented |
| Resource typing axioms | rdfs4a, rdfs4b |
Implemented |
| Subproperty transitivity | rdfs5 |
Implemented |
| Every property is a subproperty of itself | rdfs6 |
Implemented |
| Subproperty inheritance | rdfs7 |
Implemented |
Class typing for rdfs:Class |
rdfs8 |
Implemented |
| Subclass typing propagation | rdfs9 |
Implemented |
| Every class is a subclass of itself | rdfs10 |
Implemented |
| Subclass transitivity | rdfs11 |
Implemented |
| Container membership property inheritance | rdfs12 |
Implemented |
| Datatype subclass typing | rdfs13 |
Implemented |
OWL 2 RL rules
The authoritative local reference for this matrix is docs/specs/owl2-reasoning-profiles/INDEX.md, which indexes Section 4.3 of the cached OWL 2 Profiles specification.
| Feature | Spec reference | Status |
|---|---|---|
| Equality rules | eq-ref, eq-sym, eq-trans, eq-rep-s, eq-rep-p, eq-rep-o, eq-diff1, eq-diff2, eq-diff3 |
Not started |
| Property assertion and typing rules | prp-ap, prp-dom, prp-rng |
Not started |
| Functional and inverse-functional property rules | prp-fp, prp-ifp |
Not started |
| Irreflexive, symmetric, asymmetric, and transitive property rules | prp-irp, prp-symp, prp-asyp, prp-trp |
Not started |
| Subproperty, equivalent property, and property disjointness rules | prp-spo1, prp-spo2, prp-eqp1, prp-eqp2, prp-pdw, prp-adp |
Not started |
| Inverse property rules | prp-inv1, prp-inv2 |
Not started |
| Key and negative property assertion rules | prp-key, prp-npa1, prp-npa2 |
Not started |
| Core class rules | cls-thing, cls-nothing1, cls-nothing2, cls-int1, cls-int2, cls-uni, cls-com, cls-oo |
Not started |
| Some/all values from and has-value rules | cls-svf1, cls-svf2, cls-avf, cls-hv1, cls-hv2 |
Not started |
| Max cardinality rules | cls-maxc1, cls-maxc2, cls-maxqc1, cls-maxqc2, cls-maxqc3, cls-maxqc4 |
Not started |
| Class axiom rules | cax-sco, cax-eqc1, cax-eqc2, cax-dw, cax-adc |
Not started |
| Datatype rules | dt-type1, dt-type2, dt-eq, dt-diff, dt-not-type |
Not started |
| Schema vocabulary rules | scm-cls, scm-sco, scm-eqc1, scm-eqc2, scm-op, scm-dp, scm-spo, scm-eqp1, scm-eqp2, scm-dom1, scm-dom2, scm-rng1, scm-rng2, scm-hv, scm-svf1, scm-svf2, scm-avf1, scm-avf2, scm-int, scm-uni |
Not started |
Engine capabilities
This matrix tracks functional engine features independent of standards coverage.
| Feature | Status | Notes |
|---|---|---|
| Alpha memory / node support | Implemented | Shared alpha nodes perform literal filtering and retain persistent alpha memory across incremental updates |
| Beta memory / join node support | Implemented | Shared beta nodes perform left-deep joins and retain persistent partial-match memory across incremental updates |
| Triple pattern matching | Implemented | Public Rule IR, compiler normalization, and NetworkMatcher execute RDFLib-variable triple patterns end-to-end |
| Rule firing and agenda management | Implemented | Agenda orders activations by salience and breadth-first depth; richer conflict resolution policy remains future work |
| Inference materialization | Implemented | Compiled logical productions execute to fixed point in RETEEngine, and RETEStore materializes inferred triples into RDFLib contexts |
| RDF triple well-formedness enforcement | Implemented | The engine rejects or warns-and-skips triples with literal subjects or non-IRI predicates, preventing malformed triples from entering working memory or derived outputs |
| Builtin predicate / function support | Implemented | Predicate conditions compile and execute through the RETE matcher using injected read-only predicate hooks |
| Rule action callbacks | Implemented | Callback consequents execute through the agenda with read-only invocation context; richer signature validation and retraction-time policy remain future work |
| Derivation / trace logging | Implemented | Engine-native DerivationRecord values are emitted for new logical conclusions produced by fired rules |
| JTMS-compatible support bookkeeping | Implemented | WorkingMemory, DependencyGraph, and Justification records track stated facts and multi-parent support for derived facts; recursive retraction remains future work |
| Explanation reconstruction | Implemented | DerivationProofReconstructor rebuilds DirectProof trees from non-silent derivation records for triple-goal explanations |
| Proof rendering (markdown and Mermaid) | Implemented | Presentation-focused rendering over canonical DirectProof data includes namespace-aware shortening and notebook display adapters via optional extras |
| Contradiction / inconsistency handling | Not started | Detecting, surfacing, or managing incompatible conclusions |
| Specialized transitive relation index | Not started | Intended optimization path for rdfs:subClassOf and rdfs:subPropertyOf first; broader general transitive-property support remains a later design question |
Current integration baseline
The supported RDFLib integration path is Store events -> BatchDispatcher ->
RETEStore -> RETEEngine.
The rdflib-reasoning-engine package is part of the rdflib-reasoning metapackage.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rdflib_reasoning_engine-0.3.0.tar.gz.
File metadata
- Download URL: rdflib_reasoning_engine-0.3.0.tar.gz
- Upload date:
- Size: 57.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bb5a6fcfbee76e6a59e227a465d164c72bde462b0b1784a78adec6e28387967
|
|
| MD5 |
ac367a3fb42293ceb0aa9bb255b48de4
|
|
| BLAKE2b-256 |
7fe2da9f7ff94ae4e6c290e84feb784ab69ed77d644d36df417e0e5d45ca70e3
|
Provenance
The following attestation bundles were made for rdflib_reasoning_engine-0.3.0.tar.gz:
Publisher:
release.yml on kvjrhall/rdflib-reasoning
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rdflib_reasoning_engine-0.3.0.tar.gz -
Subject digest:
4bb5a6fcfbee76e6a59e227a465d164c72bde462b0b1784a78adec6e28387967 - Sigstore transparency entry: 1391835143
- Sigstore integration time:
-
Permalink:
kvjrhall/rdflib-reasoning@f9512caee118000d5a45444e173449efe363fabb -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/kvjrhall
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9512caee118000d5a45444e173449efe363fabb -
Trigger Event:
release
-
Statement type:
File details
Details for the file rdflib_reasoning_engine-0.3.0-py3-none-any.whl.
File metadata
- Download URL: rdflib_reasoning_engine-0.3.0-py3-none-any.whl
- Upload date:
- Size: 45.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddf605577f8320b4e4699c386891de78ba97779372af2adfdf0fe3d951c8d2ce
|
|
| MD5 |
44f4010cc8a195b37c7bc8e9a82c5887
|
|
| BLAKE2b-256 |
d4565ab4d637b6113c15aede99cc6fee7bd79faa375f2f1e625ed533f670bbb1
|
Provenance
The following attestation bundles were made for rdflib_reasoning_engine-0.3.0-py3-none-any.whl:
Publisher:
release.yml on kvjrhall/rdflib-reasoning
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rdflib_reasoning_engine-0.3.0-py3-none-any.whl -
Subject digest:
ddf605577f8320b4e4699c386891de78ba97779372af2adfdf0fe3d951c8d2ce - Sigstore transparency entry: 1391835144
- Sigstore integration time:
-
Permalink:
kvjrhall/rdflib-reasoning@f9512caee118000d5a45444e173449efe363fabb -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/kvjrhall
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9512caee118000d5a45444e173449efe363fabb -
Trigger Event:
release
-
Statement type: