axiom.structural_element

OWL 2 structural element bases, RDF list fragments, and declaration helpers.

Classes

GraphBacked

Universal base for graph-scoped Pydantic models in this package.

StructuralFragment

Owned scaffolding for a single StructuralElement (DR-031).

StructuralElement

Universal base for OWL 2 structural elements (axiom heads; DR-031).

SeqEntry

One RDF list cell: cell is the list node; value is the rdf:first object.

Seq

OWL / RDF list helper encoding T(SEQ v1 ... vn) (finite rdf:List).

DeclarationElement

OWL 2 declaration axiom head with a fixed rdf:type for the declared name.

Module Contents

class axiom.structural_element.GraphBacked(/, **data: Any)

Bases: pydantic.BaseModel, abc.ABC

Universal 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):

  • StructuralElement axiom heads. One OWL 2 structural element per partition. Cross-axiom references MUST use RDF node-level types only; axiom heads MUST NOT compose other StructuralElement instances.

  • StructuralFragment owned scaffolding. May be embedded as a Pydantic field on a single owning StructuralElement; its as_triples contributes to the owner’s partition; MUST share the owner’s context.

  • 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.ABC

Owned 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:List carrying owl:intersectionOf members). Fragments MAY be embedded as Pydantic fields on a single owning StructuralElement; their as_triples belong to the owner’s partition.

A fragment MUST share its owner’s context; StructuralElement enforces 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_triples with context.

Type:

Quads for this fragment

class axiom.structural_element.StructuralElement(/, **data: Any)

Bases: GraphBacked, abc.ABC

Universal 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 (and as_quads) MUST conform to owl2-mapping-to-rdf and transitive specs.

as_triples MUST NOT recurse into other axiom heads. Owned scaffolding expressed as StructuralFragment fields contributes triples to this element’s partition and MUST share this element’s context (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.BaseModel

One RDF list cell: cell is the list node; value is the rdf:first object.

The terminal sentinel row uses cell == rdf:nil and value is None; that row emits no rdf:first triple in Seq.as_triples. Non-sentinel rows MUST supply a value (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
value: axiom.common.N3Node | None = None
check_rdf_nil_or_value() → Self

Require rdf:nil rows to omit rdf:first and non-terminal rows to supply a value.

class axiom.structural_element.Seq(/, **data: Any)

Bases: StructuralFragment

OWL / RDF list helper encoding T(SEQ v1 ... vn) (finite rdf:List).

Seq is a StructuralFragment: it models owned rdf:List scaffolding for a single owning StructuralElement (for example the operand list of DataIntersectionOf). Each member is an RDF term referenced by rdf:first (no nested axiom instances; DR-031).

entries pairs each list cell node with its rdf:first value; the last row is the sentinel (rdf:nil, None) (OWL empty list uses only that row). name is the list head: entries[0].cell.

as_triples emits list scaffolding only; the owning element’s as_triples is responsible for chaining these triples into its partition.

Triples (omit rdf:first where value is None):

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 SeqEntry cell.

property as_triples: collections.abc.Sequence[axiom.common.Triple]

Emit rdf:first and rdf:rest triples for this finite rdf: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:rest from head and build a Seq in graph’s context.

class axiom.structural_element.DeclarationElement(/, **data: Any)

Bases: StructuralElement, abc.ABC

OWL 2 declaration axiom head with a fixed rdf:type for 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:type object for the declaration triple.

property as_triples: collections.abc.Sequence[axiom.common.Triple]

Single name rdf:type rdf_type declaration triple.