Skip to main content

xlog_logic/
lib.rs

1//! Datalog frontend for XLOG
2#![warn(missing_docs)]
3//!
4//! This crate provides the parsing, analysis, and compilation pipeline
5//! for XLOG Datalog programs.
6//!
7//! # Main Entry Point
8//!
9//! The primary way to use this crate is through the [`Compiler`] struct:
10//!
11//! ```ignore
12//! use xlog_logic::Compiler;
13//!
14//! let mut compiler = Compiler::new();
15//! let plan = compiler.compile(r#"
16//!     edge(1, 2).
17//!     edge(2, 3).
18//!     reach(X, Y) :- edge(X, Y).
19//!     reach(X, Z) :- reach(X, Y), edge(Y, Z).
20//! "#)?;
21//! ```
22//!
23//! # Modules
24//!
25//! - [`parser`] - Pest-based parser for XLOG syntax
26//! - [`ast`] - Abstract Syntax Tree types
27//! - [`mod@stratify`] - Stratification analysis for negation/aggregation
28//! - [`lower`] - Lowering from AST to Relational IR
29//! - [`mod@compile`] - Full compilation pipeline
30
31pub mod ast;
32pub mod compile;
33pub mod compiler_config;
34pub mod diagnostics;
35pub mod eir;
36pub mod epistemic;
37pub mod expand;
38pub mod function;
39pub mod hypergraph;
40pub mod incremental_parse;
41pub mod list_normalize;
42pub mod lower;
43pub mod magic_sets;
44pub mod meta_normalize;
45pub mod module;
46pub mod module_diagnostics;
47pub mod optimizer;
48pub mod parser;
49pub mod promote;
50pub mod proof_trace;
51pub mod resolver;
52pub mod stratify;
53#[allow(dead_code)] // reserved API: type inference not yet wired to main pipeline
54pub mod typeinfer;
55pub mod wcoj_var_ordering;
56
57// Re-export main types
58pub use ast::{
59    AnnotatedDisjunction, Atom, BodyLiteral, Constraint, Directives, EpistemicLiteral,
60    EpistemicMode, EpistemicOp, Evidence, MagicSetsMode, ProbCache, ProbEngine, ProbFact,
61    ProbMethod, ProbQuery, Program, Query, Rule, Term, Univ,
62};
63pub use compile::{compile, Compiler};
64pub use diagnostics::{
65    build_query_proof_traces, build_rule_provenance, format_atom, query_proof_traces,
66    rule_provenance, QueryProofTrace, RuleProvenance, RuleSourceKind,
67};
68pub use eir::build_eir;
69pub use expand::expand_program_functions;
70pub use incremental_parse::{
71    IncrementalParseResult, ParseCacheStats, ParserSession, StatementSpan, StatementUnit,
72};
73pub use list_normalize::normalize_list_builtins;
74pub use lower::Lowerer;
75pub use magic_sets::{rewrite_magic_sets, MagicSetReport, MagicSetRewrite, MagicSetStatus};
76pub use meta_normalize::normalize_meta_builtins;
77pub use module_diagnostics::{
78    diagnose_module_boundaries, CandidateSourceKind, ModuleBoundaryInput, ModuleBoundaryReport,
79    ModuleDeclaration, ModuleDeclarationKind, ModuleManifest, ModuleRole, ModuleViolation,
80    ModuleViolationKind,
81};
82pub use optimizer::{Optimizer, OptimizerConfig, PlanCost};
83pub use parser::{parse_program, parse_statement};
84pub use proof_trace::{DifferentiableProofTraceMap, ProofTrace, ProofTraceSpec};
85pub use stratify::{find_sccs_for_lowering, stratify, DependencyGraph, Stratum};