Skip to main content

ontologos_core/
lib.rs

1//! Core data model and reasoner API for OntoLogos.
2//!
3//! v0.4 provides an in-memory ontology representation with interned IRIs,
4//! typed entities, structured axioms, secondary indexes, and JSON v3 serialization
5//! (v2 read supported).
6//!
7//! # Start here — load and reason
8//!
9//! **Do not use [`Ontology::from_file`] for file loading.** Use `ontologos_parser::load_ontology` and `ontologos_facade::classify` for reasoning.
10//!
11//! ```ignore
12//! use ontologos_parser::load_ontology;
13//! use ontologos_rl::rdfs::RdfsEngine;
14//!
15//! let mut ontology = load_ontology(std::path::Path::new("ontology.owl"))?;
16//! let report = RdfsEngine::new().materialize(&mut ontology)?;
17//! println!("inferred {}", report.inferred_total());
18//! ```
19//!
20//! OWL RL saturation: `ontologos_rl::RlEngine::new(1)?.saturate(&mut ontology)?`
21//!
22//! # Builder-only (no parser)
23//!
24//! ```
25//! use ontologos_core::{Error, Ontology};
26//!
27//! fn main() -> Result<(), Error> {
28//!     let ontology = Ontology::builder()
29//!         .class("http://example.org/Pizza")?
30//!         .class("http://example.org/Food")?
31//!         .subclass_of("http://example.org/Pizza", "http://example.org/Food")?
32//!         .build()?;
33//!     assert_eq!(ontology.axiom_count(), 1);
34//!     Ok(())
35//! }
36//! ```
37
38#![warn(missing_docs)]
39
40mod axiom;
41mod cancel;
42mod consistency;
43mod dirty;
44mod dl;
45mod engine;
46mod entity;
47mod error;
48mod graph;
49mod iri;
50mod limits;
51mod ontology;
52mod parse_meta;
53mod reasoner;
54mod serialize;
55mod session;
56mod swrl;
57mod taxonomy;
58mod trace;
59
60pub use axiom::{Axiom, AxiomId, DataLiteral};
61pub use cancel::{cancel_requested, set_current_cancel};
62pub use consistency::ConsistencyResult;
63pub use dirty::{DirtySet, OntologyRevision, axiom_signature};
64pub use dl::{CeId, ClassExpr, DataExpr, DeId, DlAxiom, DlStore, RoleExpr};
65pub use engine::{DetectedProfileKind, EngineKind, ResolvedRoute, uses_dl_entailment};
66pub use entity::{EntityId, EntityKind, EntityRecord, EntityRegistry};
67pub use error::{Error, Result};
68pub use graph::{AxiomIndex, AxiomStore};
69pub use iri::{
70    InternPool, IriId, validate_iri, validate_snapshot_iri, validate_snapshot_iri_with_max_len,
71};
72pub use limits::Limits;
73pub use ontology::{Ontology, OntologyBuilder};
74pub use parse_meta::{OwlConstruct, ParseMeta, ParseMetaSummary};
75pub use reasoner::{Profile, Reasoner, ReasonerBuilder, ReasonerConfig};
76pub use session::ReasonerSession;
77pub use swrl::{SwrlAtom, SwrlDArg, SwrlIArg, SwrlRule};
78pub use taxonomy::Taxonomy;
79pub use trace::{InferenceTrace, TraceConclusion, TracePremise, TraceStep};
80
81#[cfg(test)]
82mod integration_tests {
83    use super::*;
84
85    #[test]
86    fn reasoner_rejects_invalid_parallelism() {
87        let ontology = Ontology::default();
88        let err = Reasoner::builder()
89            .config(ReasonerConfig {
90                parallelism: 0,
91                ..ReasonerConfig::default()
92            })
93            .build(ontology)
94            .expect_err("parallelism");
95        assert!(matches!(err, Error::Message(_)));
96    }
97}