SWRL quick start¶
Run DLSafe SWRL rules with OWL 2 DL on v1.0.0 (stable on crates.io and PyPI).
Profile matrix: Profile stability. Constructs: Supported constructs.
Prerequisites¶
- Rust 1.88+ or Python 3.10+
- An ontology that includes SWRL rules in a supported serialization (RDF/XML or OWL Functional)
SWRL support is DLSafe — rules must not bind variables to anonymous individuals in unsafe positions. Unsupported rules are skipped with parser warnings.
Python¶
from ontologos import Reasoner
# Replace with your ontology path containing SWRL rules
reasoner = Reasoner(path="my-rules.owl", profile="swrl", budget_secs=30)
consistency = reasoner.check_consistency()
print("consistent:", consistency["consistent"], "complete:", consistency["complete"])
if consistency["complete"] and consistency["consistent"]:
report = reasoner.classify()
print(report)
Inspect load warnings:
Rust (facade)¶
use ontologos_core::{Profile, Reasoner, ReasonerConfig};
use ontologos_facade::{check_consistency, classify};
use ontologos_parser::load_ontology;
let ontology = load_ontology("my-rules.owl".as_ref())?;
let mut reasoner = Reasoner::builder()
.profile(Profile::Swrl)
.config(ReasonerConfig {
budget_secs: Some(30),
..ReasonerConfig::default()
})
.build(ontology)?;
let consistency = check_consistency(&reasoner)?;
if consistency.complete && consistency.consistent {
classify(&mut reasoner)?;
}
See Rust integration contract.
CLI¶
cargo install --git https://github.com/eddiethedean/ontologos --tag v1.0.0 ontologos-cli
ontologos classify --profile swrl --budget-secs 30 my-rules.owl
Install details: CLI installation.
What to expect¶
| Step | Behavior |
|---|---|
| Load | Rules mapped via map_swrl.rs; unsafe rules may be skipped |
| Consistency | DL + rule grounding; check complete before trusting consistent |
| Classify | Materialized rule consequences + DL taxonomy where applicable |
Troubleshooting¶
| Issue | Action |
|---|---|
| Rules ignored | Check parse_meta.warnings; verify DLSafe shape |
IncompleteConsistency |
Increase budget_secs or ONTOLOGOS_DL_BUDGET_SECS |
| Wrong profile | Run ontologos profile file.owl — SWRL ontologies often detect as DL |