pynmms.rdf.rules¶
pynmms.rdf.rules
¶
Entailment regimes as Horn rules over generalized RDF triples.
The paper's def:entailmentregime: a regime is a set of rules <A, c> with a finite
premise set A of triples and a conclusion c that is a triple or ⊥,
range-restricted and uniform under substitution. Here a rule is a schema over
variables; its instances are the regime's rules.
Shipped regimes:
SIMPLE-- the empty regime (simple entailment,cor:simple).RDFS-- the RDF and RDFS entailment patterns of RDF 1.1 Semantics §9.2.1 (rdf1, rdfs2-13 except the literal-typing rules rdfs1 and rdfD1, which need a side condition) with the finite axiomatic triples of §9.2.2 (the container-membership familyrdf:_iexcluded). Seecor:rdfs.
Custom regimes are built from :func:parse_rule lines such as::
?x ex:parentOf ?y -> ?y ex:childOf ?x
?x a ex:Alive, ?x a ex:Dead -> false
OWL2RL_OMITTED = ('eq-ref', 'cls-thing', 'cls-nothing1', 'dt-type1', 'dt-type2', 'dt-eq', 'dt-diff', 'dt-not-type')
module-attribute
¶
OWL 2 RL/RDF rules not implemented: the axiomatic-only rules (eq-ref,
cls-thing, cls-nothing1 add a triple per term or one fixed triple) and the
datatype rules, which need the datatype value spaces. The list-valued rule
families are implemented procedurally (OWL2RL_LIST_RULES).
ProceduralRule
dataclass
¶
A rule family implemented in Python rather than as one pattern.
triggers are the predicates of triples that can activate it (None
for any predicate); fire(t, lookup) yields the conclusions that follow
from a triggering triple t given a lookup over the current closure
(None for ⊥). Used for the OWL 2 RL rules whose premises range over an
rdf:List of arbitrary length, and for rdfD1, whose conclusion is
computed from a literal's datatype.
Source code in src/pynmms/rdf/rules.py
Regime
dataclass
¶
A named rule set plus axiomatic triples.
Source code in src/pynmms/rdf/rules.py
Rule
dataclass
¶
A Horn rule schema. conclusion is None means ⊥ (false-concluding).
guard is an optional side condition on the bindings (def:entailmentregime
admits conditions such as "is a literal" that substitution preserves).
Source code in src/pynmms/rdf/rules.py
Var
dataclass
¶
content_lines(text)
¶
The lines of a rules or entries file that carry a rule or an entry.
Blank lines and # comments are skipped; ordering name: a < b lines
are consumed (the ordering is declared for rank guards, see
:func:pynmms.rdf.values.parse_ordering_line) and not yielded. Lines
are stripped.
Source code in src/pynmms/rdf/rules.py
custom(name, rules, axioms=(), *, extends=None)
¶
A user regime, optionally extending a shipped one.
Source code in src/pynmms/rdf/rules.py
parse_premises(text, resolver)
¶
Parse a premise list p1, p2, [guard], ... into its patterns and one guard.
Several [...] guards are conjoined; the result's guard is None
when there is none (a :class:pynmms.rdf.values.Guard otherwise).
Source code in src/pynmms/rdf/rules.py
parse_rule(text, resolver=None, name=None)
¶
Parse p1, p2, ... -> conclusion where conclusion is a pattern or false.
Source code in src/pynmms/rdf/rules.py
parse_rules_text(text, resolver=None)
¶
Parse a rules file: one rule per line, # comments, and ordering name: a < b
lines declaring orderings for rank(name, x) guards.
Source code in src/pynmms/rdf/rules.py
rdf_list(head, lookup)
¶
Members of the rdf:List starting at head, or None if malformed.
A cell may carry several rdf:first or rdf:rest values once
owl:sameAs substitution has run over it (eq-rep-o); the smallest is
taken so the walk stays deterministic, and every alternative first value
is included as a member.
Source code in src/pynmms/rdf/rules.py
split_premises(text)
¶
Split a premise list on commas outside [guards], (...), "..." and <iri>.
A guard may contain < ([?a < ?b]), so the quoted-atom rule of
:func:pynmms.syntax.split_top_level cannot apply inside brackets.
Parts are stripped; empty parts are dropped.