prolog2/lib.rs
1//! # Prolog²
2//!
3//! A Meta-Interpretive Learning (MIL) framework implementing native second-order
4//! SLD resolution. Prolog² extends traditional Prolog with the ability to learn
5//! logical rules from examples through predicate invention.
6//!
7//! ## Library usage
8//!
9//! The primary use case for the library is writing custom predicate modules and
10//! hooking them into the engine. The [`app::App`] builder handles configuration
11//! loading, module registration, and execution.
12//!
13//! ```no_run
14//! use std::process::ExitCode;
15//! use std::sync::Arc;
16//! use prolog2::{app::App, Config};
17//! use prolog2::predicate_modules::{
18//! MATHS, META_PREDICATES, PredReturn, PredicateFunction, PredicateModule,
19//! };
20//! use prolog2::heap::query_heap::QueryHeap;
21//! use prolog2::program::hypothesis::Hypothesis;
22//! use prolog2::program::predicate_table::PredicateTable;
23//!
24//! fn my_pred(
25//! heap: &mut QueryHeap,
26//! hypothesis: &mut Hypothesis,
27//! goal: usize,
28//! pred_table: &PredicateTable,
29//! config: Config,
30//! ) -> PredReturn {
31//! // Custom predicate logic here
32//! PredReturn::True
33//! }
34//!
35//! static MY_MODULE: PredicateModule = &[
36//! ("my_pred", 1, my_pred),
37//! ];
38//!
39//! fn main() -> ExitCode {
40//! App::from_args()
41//! .add_module(&MATHS)
42//! .add_module(&META_PREDICATES)
43//! .add_module(&MY_MODULE)
44//! .run()
45//! }
46//! ```
47
48/// Application builder and configuration types.
49pub mod app;
50/// Heap memory management: cells, query heaps, and the symbol database.
51pub mod heap;
52/// Prolog source parsing: tokenisation, syntax tree construction, and term encoding.
53pub mod parser;
54/// Built-in predicate modules and the predicate module system.
55pub mod predicate_modules;
56/// Program representation: clauses, hypotheses, and the predicate table.
57pub mod program;
58/// Resolution engine: proof search, unification, and term building.
59pub mod resolution;
60/// Implementation of the Top Program Consturction algorithm with parallelism
61pub mod top_prog;
62
63// Re-export commonly used types at crate root.
64pub use app::{BodyClause, Config, Examples, SetUp};
65
66#[cfg(test)]
67mod examples;