axiom.structural_element¶
OWL 2 structural element bases, RDF list fragments, and declaration helpers.
Classes¶
Universal base for graph-scoped Pydantic models in this package. |
|
Owned scaffolding for a single |
|
Universal base for OWL 2 structural elements (axiom heads; DR-031). |
|
One RDF list cell: |
|
OWL / RDF list helper encoding |
|
OWL 2 declaration axiom head with a fixed |
Module Contents¶
- class axiom.structural_element.GraphBacked(/, **data: Any)¶
Bases:
pydantic.BaseModel,abc.ABCUniversal base for graph-scoped Pydantic models in this package.
Each instance MUST have a single required
context(graph identifier). Cross-context structure MUST be expressed only at the triple or quad level, not by composing models defined in another context.Three roles partition models in this hierarchy (DR-031; see package
AGENTS.md):StructuralElementaxiom heads. One OWL 2 structural element per partition. Cross-axiom references MUST use RDF node-level types only; axiom heads MUST NOT compose otherStructuralElementinstances.StructuralFragmentowned scaffolding. May be embedded as a Pydantic field on a single owningStructuralElement; itsas_triplescontributes to the owner’s partition; MUST share the owner’scontext.Node references via package-defined annotated aliases (
N3Resource,N3IRIRef,N3Node,N3ContextIdentifier). Used for cross-axiom links by identity.
Models MUST NOT embed rdflib.Graph, ConjunctiveGraph, SPARQL result objects, or other container/session/handle types. Schema-facing fields MUST use the annotated RDF aliases above rather than raw rdflib node classes; raw rdflib node classes MAY still be used in internal non-schema logic.
- context: axiom.common.ContextIdentifier = None¶
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class axiom.structural_element.StructuralFragment(/, **data: Any)¶
Bases:
GraphBacked,abc.ABCOwned scaffolding for a single
StructuralElement(DR-031).A fragment models a graph fragment that is co-essential to one OWL axiom’s RDF mapping (for example an
rdf:Listcarryingowl:intersectionOfmembers). Fragments MAY be embedded as Pydantic fields on a single owningStructuralElement; theiras_triplesbelong to the owner’s partition.A fragment MUST share its owner’s
context;StructuralElementenforces this via a centralized validator. Fragments are not partition units on their own and are not OWL axioms.- property as_triples: collections.abc.Sequence[axiom.common.Triple]¶
- Abstractmethod:
Triples for this fragment; flow into the owning element’s partition.
- property as_quads: collections.abc.Sequence[axiom.common.Quad]¶
each triple from
as_tripleswithcontext.- Type:
Quads for this fragment
- class axiom.structural_element.StructuralElement(/, **data: Any)¶
Bases:
GraphBacked,abc.ABCUniversal base for OWL 2 structural elements (axiom heads; DR-031).
Concrete class names SHOULD match the paired structural element’s name (e.g.
NegativeDataPropertyAssertion). Each concrete subclass MUST correspond to a well-identified OWL 2 structural element;as_triples(andas_quads) MUST conform toowl2-mapping-to-rdfand transitive specs.as_triplesMUST NOT recurse into other axiom heads. Owned scaffolding expressed asStructuralFragmentfields contributes triples to this element’s partition and MUST share this element’scontext(enforced). Cross-axiom references MUST use RDF node-level types only.- property name: rdflib.IdentifiedNode¶
- Abstractmethod:
type triple.
- Type:
Canonical identifier for this element; SHOULD be the subject of a rdf
- property as_triples: collections.abc.Sequence[axiom.common.Triple]¶
- Abstractmethod:
Triples representing this element as RDF; MUST NOT recurse into other axiom heads.
- property as_quads: collections.abc.Sequence[axiom.common.Quad]¶
each triple from as_triples with context as fourth element.
- Type:
Quads for this element
- class axiom.structural_element.SeqEntry(/, **data: Any)¶
Bases:
pydantic.BaseModelOne RDF list cell:
cellis the list node;valueis therdf:firstobject.The terminal sentinel row uses
cell == rdf:nilandvalue is None; that row emits nordf:firsttriple in Seq.as_triples. Non-sentinel rows MUST supply avalue(the list member, typically an IRI, blank node, or literal).- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- cell: axiom.common.N3Resource = None¶
- check_rdf_nil_or_value() Self¶
Require
rdf:nilrows to omitrdf:firstand non-terminal rows to supply a value.
- class axiom.structural_element.Seq(/, **data: Any)¶
Bases:
StructuralFragmentOWL / RDF list helper encoding
T(SEQ v1 ... vn)(finiterdf:List).Seqis aStructuralFragment: it models ownedrdf:Listscaffolding for a single owningStructuralElement(for example the operand list ofDataIntersectionOf). Each member is an RDF term referenced byrdf:first(no nested axiom instances; DR-031).entriespairs each list cell node with itsrdf:firstvalue; the last row is the sentinel(rdf:nil, None)(OWL empty list uses only that row).nameis the list head:entries[0].cell.as_triplesemits list scaffolding only; the owning element’sas_triplesis responsible for chaining these triples into its partition.Triples (omit
rdf:firstwherevalueisNone):Ei.cell rdf:first Ei.value . # when Ei.value is not None Ei.cell rdf:rest entries[i+1].cell . # i < len(entries)-1
- kind: Literal['seq'] = 'seq'¶
- entries: collections.abc.Sequence[SeqEntry] = None¶
- property name: rdflib.IdentifiedNode¶
List head node taken from the first
SeqEntrycell.
- property as_triples: collections.abc.Sequence[axiom.common.Triple]¶
Emit
rdf:firstandrdf:resttriples for this finiterdf:List.
- check_list_integrity() Self¶
Validate non-empty entries, a terminal
rdf:nil, and unique list cells.
- classmethod from_rdflib(graph: rdflib.Graph, head: rdflib.IdentifiedNode) Self¶
Walk
rdf:first/rdf:restfromheadand build aSeqingraph’s context.
- class axiom.structural_element.DeclarationElement(/, **data: Any)¶
Bases:
StructuralElement,abc.ABCOWL 2 declaration axiom head with a fixed
rdf:typefor the declared name.- name_value: axiom.common.N3Resource = None¶
- property name: rdflib.IdentifiedNode¶
Declared entity identifier (alias of
name_value).
- property rdf_type: rdflib.IdentifiedNode¶
- Abstractmethod:
rdf:typeobject for the declaration triple.
- property as_triples: collections.abc.Sequence[axiom.common.Triple]¶
Single
name rdf:type rdf_typedeclaration triple.