Skip to main content

ontologos_rl/
lib.rs

1//! OWL RL forward-chaining facade over [`reasonable`](https://crates.io/crates/reasonable).
2//!
3//! # Start here — load a file and saturate
4//!
5//! ```no_run
6//! use ontologos_parser::load_ontology;
7//! use ontologos_rl::RlEngine;
8//!
9//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
10//! let mut ontology = load_ontology(std::path::Path::new("ontology.owl"))?;
11//! let report = RlEngine::new(1).saturate(&mut ontology)?;
12//! println!("inferred {}", report.inferred_total());
13//! # Ok(())
14//! # }
15//! ```
16
17pub mod abox;
18mod engine;
19mod native_eval;
20pub mod rdfs;
21mod reasoner;
22mod report;
23
24pub use abox::{
25    AboxReport, SameAsClosure, is_abox_consistent, materialize_abox, object_property_values,
26    same_as_closure,
27};
28pub use engine::RlEngine;
29pub use native_eval::transitive_subclass_closure;
30pub use rdfs::{
31    MaterializationReport as RdfsMaterializationReport, RdfsEngine, RdfsRule,
32    classify_reasoner as rdfs_classify_reasoner, materialize_reasoner as rdfs_materialize_reasoner,
33    materialize_routed as rdfs_materialize_routed,
34};
35pub use reasoner::{classify_reasoner, materialize_reasoner, saturate_routed};
36pub use report::{InferenceRecord, MaterializationReport, RlRule};
37
38use ontologos_core::Error as CoreError;
39use thiserror::Error;
40
41pub type Result<T> = std::result::Result<T, Error>;
42
43#[derive(Debug, Error)]
44pub enum Error {
45    #[error("expected profile {expected:?}, got {actual:?}")]
46    WrongProfile {
47        expected: ontologos_core::Profile,
48        actual: ontologos_core::Profile,
49    },
50    #[error(transparent)]
51    Core(#[from] CoreError),
52    #[error(transparent)]
53    Bridge(#[from] ontologos_bridge::Error),
54    #[error(transparent)]
55    Reasonable(#[from] reasonable::error::ReasonableError),
56}
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn try_new_rejects_invalid_parallelism() {
64        assert!(RlEngine::try_new(0).is_err());
65        assert!(RlEngine::try_new(65).is_err());
66        assert!(RlEngine::try_new(1).is_ok());
67    }
68}