Skip to content

psychologyPillar 3 — Materialization (OWL 2 RL + RDFS)

pgrdf.materialize(graph_id BIGINT, profile TEXT DEFAULT 'owl-rl') → JSONB runs forward-chaining inference (via the reasonable reasoner) over the named graph, and writes every entailed triple back to the same graph with is_inferred = TRUE. The profile argument selects the rule set — 'owl-rl' (default, full OWL 2 RL) or 'rdfs' (RDFS closures only).

The call is idempotent: re-running drops the previously inferred rows first and replaces them. The base graph is never touched. When the closure is written, pgrdf.materialize refreshes planner statistics automatically, so SPARQL queries stay fast on the enlarged graph.

v0.6 operating model — reason over a right-sized graph

Ingest is parallel and scales to billions; reasoning is single-threaded. Materialization runs the reasonable reasoner in-process on a single core — an upstream limit tracked in #1 (proposal: gtfierro/reasonable#57). The staged bulk loader ingests the full 8.2-billion-triple Wikidata graph, but materialize is not for the billion-scale graph — it runs on a graph sized to your hardware, and going forward over a carved slice of a larger graph (roadmap). The proven reasoning regime is LUBM-100 on a laptop with zero tuning, and a full 112-million-quad LUBM-500 closure on a single box. See Scale of reasoning.

Topics in this pillar

At a glance

sql
SELECT pgrdf.materialize(100);
--  → {"base_triples": 3, "inferred_triples_written": 11, "profile": "owl-rl", ...}

Next — Mental model →

auto_storiesTraining

Inference is shorter than the other pillars — it's one UDF with a deep semantic. The recommended path is short and linear:

  • info Start with the Mental model — what is_inferred = TRUE really means and how materialized quads sit alongside base quads.
  • description Walk through the Worked example — copy-paste-runnable subclass-chain demo, ~20 lines of SQL.
  • psychology Then the OWL 2 RL rule set — what the reasoner actually entails in practice (subclass closure, transitive properties, equivalence, inverse, sameAs).
  • settings Read Idempotence + operator safety — the guarantees you need before scheduling materialization as a cron job.
  • tune Then Reasoning profile selector — pick 'rdfs' instead of the default 'owl-rl' when you want to bound per-graph materialization cost.
  • speed Finish with Scale of reasoning — why reasoning is single-threaded, and how to size the graph you reason over.

Learn more

  • school OWL 2 Profiles — RL — the W3C profile spec pgRDF implements.
  • school OWL 2 RL/RDF Rules — the forward-chaining rules verbatim.
  • code reasonable — the Rust reasoner pgRDF wraps.
  • school Pascal Hitzler et al., Foundations of Semantic Web Technologies — chapters on OWL 2 RL.

MIT licensed. Documentation for pgRDF — built with VitePress, served via GitHub Pages.