Skip to main content

inference_engine/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use datalog_structural_model::Program;
4use rdf_reasoning::{Exclusion, Preset, PresetParseError};
5use serde::Serialize;
6
7mod cooperative;
8pub mod entailment;
9pub mod reasoning;
10pub mod shacl12;
11
12/// An exact shared RDF profile, compiled into portable checked Datalog rules.
13///
14/// This is a program description, not an evaluated closure or engine capability claim.
15#[derive(Debug, Serialize)]
16pub struct CompiledProfile {
17    /// The selected semantic contract.
18    pub preset: Preset,
19    /// The shared rule catalogue's checked program.
20    pub program: Program,
21    /// Obligations deliberately excluded by this profile.
22    pub exclusions: &'static [Exclusion],
23}
24
25impl CompiledProfile {
26    /// Compile the finite rule catalogue for this preset without loading graph data.
27    #[must_use]
28    pub fn new(preset: Preset) -> Self {
29        Self {
30            preset,
31            program: preset.program(),
32            exclusions: preset.exclusions(),
33        }
34    }
35}
36
37/// Compile a named shared RDF profile, rejecting unknown or unsupported selectors.
38///
39/// # Errors
40/// Returns the shared catalogue's typed parse error for an unsupported selector.
41pub fn compile_profile(selector: &str) -> Result<CompiledProfile, PresetParseError> {
42    selector.parse().map(CompiledProfile::new)
43}
44
45/// Enumerate exactly the finite set of available rule-profile selectors.
46pub fn profiles() -> impl ExactSizeIterator<Item = &'static str> {
47    Preset::ALL.iter().map(|preset| preset.name())
48}