pynmms.rdf.convert¶
pynmms.rdf.convert
¶
Converters between the ontology extension and the RDF layer.
The onto vocabulary is the rdf:type fragment of the triple encoding
(def:triplebearers): C(x) is (x rdf:type C) and R(x, y) is (x R y).
Schema commitments become schema triples, read by a regime's rules:
| schema | triple(s) |
|---|---|
| subClassOf(C, D) | C rdfs:subClassOf D |
| range(R, C) / domain(R, C) | R rdfs:range C / R rdfs:domain C |
| subPropertyOf(R, S) | R rdfs:subPropertyOf S |
| disjointWith(C, D) | C owl:disjointWith D |
| disjointProperties(R, S) | R owl:propertyDisjointWith S |
| jointCommitment([C1..Cn], D) | a rule ?x a C1, ..., ?x a Cn -> ?x a D |
The RDF reading is monotone: a schema triple licenses every instance
regardless of context, which is the MONOTONE policy. EXACT schemas lose their
brittleness and GUARDED schemas lose their defeaters in the conversion; both
are reported in the returned notes so the caller can add explicit guarded
entries on the :class:~pynmms.rdf.base.RDFBase instead.
atom_to_triple(atom, ns=DEFAULT_NS)
¶
C(x) -> (x rdf:type C); R(x,y) -> (x R y).
Source code in src/pynmms/rdf/convert.py
consequences_to_triples(base, ns=DEFAULT_NS)
¶
Ground consequences of base as triple-atom pairs with their policies.
The policy's defeaters are translated too, so a guarded entry keeps its defeaters as triple atoms.
Source code in src/pynmms/rdf/convert.py
install_onto(target, base, ns=DEFAULT_NS, *, exact='monotone')
¶
Install base's schemas as pattern entries and its consequences as ground entries
of an RDFBase/RegimeBase; returns (rules, entries) added.
Source code in src/pynmms/rdf/convert.py
onto_to_defeasible(base, ns=DEFAULT_NS, *, exact='monotone')
¶
Every schema of base as a pattern entry (pynmms.rdf.defeasible).
subClassOf(C, D) becomes ?x a C |~ ?x a D; range(R, C)
?x R ?y |~ ?y a C; domain(R, C) ?x R ?y |~ ?x a C;
subPropertyOf(R, S) ?x R ?y |~ ?x S ?y; disjointWith(C, D)
?x a C, ?x a D |~ false; disjointProperties(R, S) ?x R ?y, ?x S ?y
|~ false; jointCommitment([C1..Cn], D) ?x a C1, ..., ?x a Cn |~ ?x a D.
A guarded schema's defeater concepts become defeaters on each individual of
the match (?x a E ; ?y a E), conjunctive exclusions conjunctions on
one individual. An exact schema, defeated by any addition, has no pattern
counterpart: with exact="monotone" (default) it is compiled as monotone
and logged, with exact="skip" it is left out.
Source code in src/pynmms/rdf/convert.py
onto_to_graph(base, ns=DEFAULT_NS, *, prefix='onto')
¶
The ABox and schema triples of base; returns (graph, notes).
notes lists every schema whose robustness policy is not representable
in RDF (EXACT brittleness and GUARDED defeaters are dropped) and every
jointCommitment (which needs a rule; see :func:onto_to_rules).
Source code in src/pynmms/rdf/convert.py
onto_to_rules(base, ns=DEFAULT_NS)
¶
Rules for the schemas a regime cannot read from triples (jointCommitment).
The jointCommitment entries of :func:onto_to_defeasible as plain regime
rules: guarded jointCommitments become unguarded rules; the defeaters are
logged.