Use case: reasoning & inference
little big brain can answer questions using facts you never explicitly
wrote, by deriving them from the schema statements you did write. Every
SPARQL read carries an entailment control that selects the reasoning
regime for that one query:
entailment |
What a query matches |
|---|---|
none (default) |
The facts exactly as written. |
subclass |
Adds the asserted rdfs:subClassOf closure: a query for a broad class also matches its subclasses. |
rdfs |
Adds subproperty value propagation and domain/range type derivation on top of subclass. |
owl |
Adds the OWL vocabulary on top of rdfs: equivalence, inverse, symmetric, and transitive properties, property chains, class constructors, restriction rules, and owl:sameAs identity. |
Reasoning is deterministic and snapshot-consistent: the regime is
evaluated at query time against the schema triples of the pinned published
snapshot, the same answer comes back every time for the same snapshot, and a
time-travel pin (as_of_valid_time, as_of_commit_seq) reasons over the
graph as it was. There is nothing to rebuild and nothing to republish when
the schema changes: the next generation’s queries read the next schema.
Type closure
Section titled “Type closure”Write ordinary RDFS schema triples with your data:
ex:ElectricCar rdfs:subClassOf ex:Car .ex:Car rdfs:subClassOf ex:Vehicle .ex:tesla3 a ex:ElectricCar .A default query matches asserted triples only, so ?v a ex:Vehicle returns
nothing here. Under entailment: "subclass" (or any broader regime) the same
query returns ex:tesla3, without duplicating any facts. The mode works on
already-published data, and a schema change takes effect with the next
published generation.
# Default: exact-type matching only.lbb.sparql("SELECT ?v WHERE { ?v a <https://example.com/Vehicle> }")
# Subclass closure: matches Vehicle and all its subclasses.lbb.sparql( "SELECT ?v WHERE { ?v a <https://example.com/Vehicle> }", entailment="subclass",)// Default: exact-type matching only.await lbb.sparqlRows({ query: `SELECT ?v WHERE { ?v a <https://example.com/Vehicle> }`,});
// Subclass closure.await lbb.sparqlRows({ query: `SELECT ?v WHERE { ?v a <https://example.com/Vehicle> }`, entailment: "subclass",});RDFS entailment
Section titled “RDFS entailment”entailment: "rdfs" applies the practical RDFS core: subclass membership and
transitivity, subproperty transitivity and value propagation (a query for
rdfs:label matches values written under a declared subproperty), and
domain/range type derivation (a subject of hasPet is a Person when the
schema declares that domain).
OWL entailment
Section titled “OWL entailment”entailment: "owl" is a strict superset of rdfs. On top of the RDFS core
it applies, from the asserted OWL schema triples:
- Equivalence:
owl:equivalentClassandowl:equivalentPropertyshare members and values in both directions. - Property semantics:
owl:inverseOfanswers a triple from either direction,owl:SymmetricPropertymatches both orders,owl:TransitivePropertycloses chains of the property and its subproperties, and bounded acyclicowl:propertyChainAxiomdeclarations derive head properties. One chain may use another chain head, up to eight composition levels and 256 expanded path terms. - Class constructors:
owl:unionOfoperands are subclasses of the union,owl:intersectionOfdecomposes and derives joint membership, andowl:oneOfenumerations declare their members. - Restrictions:
owl:hasValuederives membership from an entailed property value and the value from membership,owl:someValuesFromderives membership from an entailed filler-typed neighbor, andowl:allValuesFromtypes objects reached by an entailed restricted property. These rules compose with inverse, symmetric, transitive, subproperty, property-chain, andhasValue-derived assertions. - Identity: asserted
owl:sameAscliques make a constant match through any member and a variable bind every member.
lbb.sparql( "SELECT ?who WHERE { <https://example.com/rex> <https://example.com/ownedBy> ?who }", entailment="owl",)# Answers through the declared inverse of owns, no ownedBy triple stored.A schema outside the supported envelope fails closed with a typed error
instead of returning incomplete answers: a closure over the size cap, a
recursive, over-depth, or over-expanded property-chain composition, or an
owl:sameAs identity set over its caps
refuses entailment: "owl" while asserted queries keep working. Existential
superclasses, cardinality-derived inference, and owl:imports are out of
scope for the regime; cardinality-style declarations are checked as
validation in the published conformance report.
Performance
Section titled “Performance”The regimes stay inside the engine’s normal query bounds:
- The schema closure is extracted once per published generation, on the first entailed query, and cached; queries after that pay only their own pattern work.
- A query whose patterns the schema does not mention runs the same plan with and without entailment.
- Transitive and chain reach evaluate as guided index traversals from the bound end of the pattern, under the same read deadline as every query.
- Aggregations over large entailed classes scan the class members; the answer is exact and the cost is proportional to the member count.
Rules run at publish time
Section titled “Rules run at publish time”A branch’s stored inference rules run when a generation is published, and
the derived edges are part of the asserted dataset every query reads. There
is no query-time rule switch: requesting reason: true returns a typed
error pointing at the entailment regimes.
Why reasoning matters for agents
Section titled “Why reasoning matters for agents”An AI agent should not have to re-derive what the system can entail. Reasoning gives an agent:
- Deterministic derivation. Transitive relationships, classifications, and type generalizations are computed the same way every run, while ad-hoc LLM reasoning varies from call to call and consumes tokens.
- Broader answers without more writes. A query for a broad concept returns its specific instances through the closure, so the agent does not have to enumerate every subtype.
- One identity for one thing.
owl:sameAslets an agent write facts under the identifier it knows and read the facts written under every equivalent identifier.
See why RDF & SHACL suit AI agents for how this fits an agent’s write loop.
Related
Section titled “Related”- SPARQL, structured query & SHACL: the query surfaces that reasoning applies to.
- Time-travel audit: the bitemporal cursor reasoning pins to.
- Core concepts