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 consistency;
42mod dirty;
43mod dl;
44mod engine;
45mod entity;
46mod error;
47mod graph;
48mod iri;
49mod limits;
50mod ontology;
51mod parse_meta;
52mod reasoner;
53mod serialize;
54mod session;
55mod swrl;
56mod taxonomy;
57mod trace;
58
59pub use axiom::{Axiom, AxiomId, DataLiteral};
60pub use consistency::ConsistencyResult;
61pub use dirty::{DirtySet, OntologyRevision, axiom_signature};
62pub use dl::{CeId, ClassExpr, DataExpr, DeId, DlAxiom, DlStore, RoleExpr};
63pub use engine::{DetectedProfileKind, EngineKind, ResolvedRoute, uses_dl_entailment};
64pub use entity::{EntityId, EntityKind, EntityRecord, EntityRegistry};
65pub use error::{Error, Result};
66pub use graph::{AxiomIndex, AxiomStore};
67pub use iri::{
68    InternPool, IriId, validate_iri, validate_snapshot_iri, validate_snapshot_iri_with_max_len,
69};
70pub use limits::Limits;
71pub use ontology::{Ontology, OntologyBuilder};
72pub use parse_meta::{OwlConstruct, ParseMeta, ParseMetaSummary};
73pub use reasoner::{Profile, Reasoner, ReasonerBuilder, ReasonerConfig};
74pub use session::ReasonerSession;
75pub use swrl::{SwrlAtom, SwrlDArg, SwrlIArg, SwrlRule};
76pub use taxonomy::Taxonomy;
77pub use trace::{InferenceTrace, TraceConclusion, TracePremise, TraceStep};
78
79#[cfg(test)]
80mod integration_tests {
81    use super::*;
82
83    #[test]
84    fn reasoner_rejects_invalid_parallelism() {
85        let ontology = Ontology::default();
86        let err = Reasoner::builder()
87            .config(ReasonerConfig {
88                parallelism: 0,
89                ..ReasonerConfig::default()
90            })
91            .build(ontology)
92            .expect_err("parallelism");
93        assert!(matches!(err, Error::Message(_)));
94    }
95}