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