OWL2 Ontology (.owl, .owl2, .ofn, .ttl)
@modelscript/owl2 (languages/owl2) brings formal ontological engineering, Description Logic (
Supported Extensions & Formats
| Extension | Format |
|---|---|
.owl, .owl2, .ofn | W3C OWL 2 Functional-Style Syntax (Prefix(...), Ontology(...)) |
.ttl | RDF Turtle / Ontological Triple Assertions |
OWL 2 DL Axiom & Class Expression Lowering
lowerCstToAxioms(tree, sourceText) (languages/owl2/src/cst-lowering.ts) lowers the linear-memory CST into an arena-backed OntologyStore supporting over 35 OWL 2 DL axiom and class expression constructs:
| Category | Supported OWL 2 Functional-Style Constructs |
|---|---|
| Declarations | Declaration(Class(...)), Declaration(ObjectProperty(...)), Declaration(DataProperty(...)), Declaration(NamedIndividual(...)) |
| Class Axioms | SubClassOf, EquivalentClasses, DisjointClasses |
| Boolean & Nominal Class Expressions | ObjectIntersectionOf, ObjectUnionOf, ObjectComplementOf, ObjectOneOf |
| Object Property Restrictions | ObjectSomeValuesFrom, ObjectAllValuesFrom, ObjectHasSelf, ObjectHasValue, ObjectMinCardinality, ObjectMaxCardinality, ObjectExactCardinality |
| Data Property Restrictions | DataSomeValuesFrom, DataAllValuesFrom, DataMinCardinality, DataMaxCardinality, DataExactCardinality |
| Property Hierarchy & Inversion | SubObjectPropertyOf, SubDataPropertyOf, InverseObjectProperties, DisjointObjectProperties |
| Property Domains & Ranges | ObjectPropertyDomain, ObjectPropertyRange, DataPropertyDomain, DataPropertyRange |
| Property Characteristics | FunctionalObjectProperty, InverseFunctionalObjectProperty, ReflexiveObjectProperty, IrreflexiveObjectProperty, SymmetricObjectProperty, AsymmetricObjectProperty, TransitiveObjectProperty, FunctionalDataProperty |
| ABox Individual Assertions | ClassAssertion, ObjectPropertyAssertion, DataPropertyAssertion, NegativeObjectPropertyAssertion, NegativeDataPropertyAssertion, SameIndividual, DifferentIndividuals |
Prefix(:=<http://example.org/spacecraft#>)
Ontology(<http://example.org/spacecraft>
Declaration(Class(:Thruster))
Declaration(Class(:Actuator))
Declaration(ObjectProperty(:mountedOn))
Declaration(DataProperty(:nominalThrustN))
SubClassOf(:Thruster :Actuator)
SubClassOf(:Thruster ObjectSomeValuesFrom(:mountedOn :ReactionControlPod))
ClassAssertion(:Thruster :RCS_Thruster_A1)
DataPropertyAssertion(:nominalThrustN :RCS_Thruster_A1 "22.0"^^xsd:double)
)Description Logic Tableau Reasoner & Leapfrog Triejoin
@modelscript/owl2 includes an in-memory TableauReasoner in languages/owl2/src/reasoner/) and a worst-case optimal Leapfrog Triejoin engine (executeBGP in languages/owl2/src/query/leapfrog.ts):
- Consistency & Satisfiability Checking: Detects unsatisfiable classes (
DisjointClassesviolations, cardinality contradictions, irreflexive/asymmetric cycles, negative property assertion conflicts) and surfaces exact source diagnostics (OWL2001–OWL2005). - Justification & Explanation Tracing: Computes minimal unsatisfiability justifications (
explain_inference) explaining why a class or individual violates ontology axioms. - SPARQL & Multi-Way BGP Joins: Evaluates conjunctive Basic Graph Patterns (BGPs) in
worst-case optimal time without materializing intermediate Cartesian products.
Interactive 2D Ontology Diagram & Bidirectional Writeback
languages/owl2/src/diagram/ provides an interactive 2D graph visualization and editing surface for OWL 2 ontologies:
- Visual Graph Projection: Renders
Classnodes,NamedIndividualinstances,SubClassOfinheritance hierarchies, andObjectPropertyDomain/ObjectPropertyRangedirected edges. - Bidirectional CST Writeback (
owl2Language.writeback): Adding/deleting nodes or edges in the diagram (add_node,delete_node,add_edge,delete_edge,rename_node,update_parameter) patches the Functional-Style.owlsource text directly—inserting or removingDeclaration(...),SubClassOf(...), orDataPropertyAssertion(...)axioms in place.
Dedicated owl2-mcp Server Tools
The @modelscript/owl2 MCP server (languages/owl2/src/mcp/server.ts) exposes five specialized tools to AI agents:
| MCP Tool | Description |
|---|---|
validate_system_consistency | Parses an OWL 2 Functional Syntax ontology, runs the SubClassOf hierarchy |
query_ontology_sparql | Executes a SPARQL SELECT WHERE query over the ontology's inferred RDF triple graph |
query_ontology_bgp | Evaluates a conjunctive Basic Graph Pattern (BGP) using the worst-case optimal Leapfrog Triejoin algorithm |
explain_inference | Computes formal axiomatic justifications explaining why an entailment holds or why a class is unsatisfiable |
trace_fault_propagation | Traces transitive fault propagation (TransitiveObjectProperty / causal links) from a starting component individual across the system topology |
Polyglot TGG Rules
@modelscript/owl2 defines 5 bidirectional Triple Graph Grammar (TGG) rules in languages/owl2/src/language.ts:
| Rule Name | Source (owl2) | Target Language | Target Construct |
|---|---|---|---|
OWL2ClassToSysML2Part | Declaration (Class) | sysml2 | PartDef |
OWL2SubClassToSysML2Specialization | SubClassOf | sysml2 | Specialization (:>) |
OWL2ObjectPropertyToSysML2Port | Declaration (ObjectProperty) | sysml2 | PortUsage |
OWL2DataPropertyToSysML2Attribute | Declaration (DataProperty) | sysml2 | AttributeUsage |
OWL2ClassToModelicaModel | Declaration (Class) | modelica | ClassDefinition (model) |
Command Line Interface (msx polyglot)
OWL2 ontologies can be queried, projected, and validated using ModelScript's polyglot digital thread commands:
# Project OWL 2 DL class hierarchies and axioms into formal SysML v2 part definitions
msx polyglot project SpacecraftOntology.ofn --target=sysml2 -o Spacecraft.sysml
# Cross-query ontology symbols and digital thread twins in the unified Salsa index
msx polyglot query Spacecraft::ReactionControlPod --domain=owl2
# Verify losslessness and critical pair confluence across OWL 2 TGG synchronization rules
msx polyglot verify --strictDiagnostic Rules
24 rules16 error7 warning1 info Run with msx lint
| Code | Rule | Severity | Message |
|---|---|---|---|
O1001 | parse-error | error | Syntax error near '<snippet>'. |
O1002 | undeclared-prefix | error | Prefix '<prefix>:' used in abbreviated IRI '<iri>' is not declared. |
O1003 | duplicate-prefix | warning | Prefix '<prefix>:' is declared multiple times in the ontology header. |
O1004 | invalid-iri | error | Invalid or malformed IRI '<iri>'. |
O1005 | insufficient-arity | error | OWL 2 construct '<construct>' requires at least <minArity> arguments, but got <actualArity>. |
O2001 | undeclared-entity | warning | Entity '<iri>' is used as a <role> without an explicit Declaration axiom. |
O2002 | duplicate-declaration | warning | Duplicate Declaration(<kind>(<iri>)) in ontology. |
O2003 | reserved-vocabulary-declaration | error | Cannot declare or redefine built-in OWL 2 / RDF / RDFS / XSD vocabulary IRI '<iri>'. |
O3001 | illegal-property-punning | error | Illegal OWL 2 DL punning: '<iri>' is used as both '<kindA>' and '<kindB>' (ObjectProperty, DataProperty, and AnnotationProperty vocabularies must be disjoint). |
O3002 | expected-object-property | error | Expected an ObjectProperty in '<construct>', but '<iri>' is declared as a DataProperty. |
O3003 | expected-data-property | error | Expected a DataProperty in '<construct>', but '<iri>' is declared as an ObjectProperty. |
O3004 | expected-class-expression | error | Expected a Class expression in '<construct>', but '<iri>' is a Datatype. |
O3005 | invalid-datatype | warning | Datatype '<datatypeIri>' is not in the standard OWL 2 datatype map. |
O3006 | datatype-literal-mismatch | error | Lexical value '<literal>' is not a valid literal for datatype '<datatypeIri>'. |
O4001 | non-simple-property-restriction | error | OWL 2 DL global restriction violation: non-simple (transitive or composite) property '<propertyIri>' cannot be used in '<construct>'. |
O4002 | contradictory-property-characteristics | error | Object property '<propertyIri>' has contradictory characteristics '<charA>' and '<charB>'. |
O4003 | property-hierarchy-cycle | warning | Cycle detected in property hierarchy: '<cycle>'. |
O4004 | class-hierarchy-cycle | info | SubClassOf cycle detected (equivalent classes): '<cycle>'. |
O4005 | self-referential-axiom | warning | Redundant or contradictory self-referential axiom '<axiomType>' on '<iri>'. |
O5001 | functional-property-clash | error | Functional/InverseFunctional property '<propertyIri>' violation: <detail>. |
O5002 | negative-assertion-clash | error | Negative property assertion on '<propertyIri>' for '<subjectIri>' clashes with asserted or inferred value '<target>'. |
O5003 | unsatisfiable-class | error | Class '<classIri>' is unsatisfiable (equivalent to owl:Nothing): <reason>. |
O5004 | ontology-inconsistent | error | Ontology is logically inconsistent: <explanation> |
O6001 | profile-el-violation | warning | Construct '<construct>' is outside the OWL 2 EL profile. |
Generated from languages/owl2/src/errors.ts. All languages →

