oxiz/lib.rs
1//! # OxiZ - Next-Generation SMT Solver in Pure Rust
2//!
3//! **OxiZ** is a high-performance SMT (Satisfiability Modulo Theories) solver written entirely in Pure Rust,
4//! designed to achieve feature parity with Z3 while leveraging Rust's safety, performance, and concurrency features.
5//!
6//! ## 🎯 Key Features
7//!
8//! - **Pure Rust Implementation**: No C/C++ dependencies, no FFI, complete memory safety
9//! - **Z3-Compatible**: Extensive theory support and familiar API patterns
10//! - **High Performance**: Optimized SAT core with advanced heuristics (VSIDS, LRB, CHB)
11//! - **Modular Design**: Use only what you need via feature flags
12//! - **SMT-LIB2 Support**: Full parser and printer for standard format
13//!
14//! ## 📦 Module Overview
15//!
16//! ### Core Infrastructure
17//!
18//! | Module | Description |
19//! |--------|-------------|
20//! | [`core`] | Term management, sorts, and SMT-LIB2 parsing |
21//! | [`math`] | Mathematical utilities (polynomials, rationals, CAD) |
22//!
23//! ### Solver Components (enabled by `solver` feature)
24//!
25//! | Module | Description |
26//! |--------|-------------|
27//! | `sat` | CDCL SAT solver with advanced heuristics |
28//! | `theories` | Theory solvers (EUF, LRA, LIA, Arrays, BV, etc.) |
29//! | `solver` | Main SMT solver with DPLL(T) |
30//!
31//! ### Advanced Features
32//!
33//! | Module | Feature Flag | Description |
34//! |--------|--------------|-------------|
35//! | `nlsat` | `nlsat` | Nonlinear real arithmetic solver |
36//! | `opt` | `optimization` | MaxSMT and optimization |
37//! | `spacer` | `spacer` | CHC solver for program verification |
38//! | `proof` | `proof` | Proof generation and checking |
39//!
40//! ## 🚀 Quick Start
41//!
42//! ### Installation
43//!
44//! Add OxiZ to your `Cargo.toml`:
45//!
46//! ```toml
47//! [dependencies]
48//! oxiz = "0.1.3" # Default: solver feature
49//! ```
50//!
51//! With additional features:
52//!
53//! ```toml
54//! [dependencies]
55//! oxiz = { version = "0.1.3", features = ["nlsat", "optimization"] }
56//! ```
57//!
58//! Or use all features:
59//!
60//! ```toml
61//! [dependencies]
62//! oxiz = { version = "0.1.3", features = ["full"] }
63//! ```
64//!
65//! ### Basic SMT Solving
66//!
67//! ```rust
68//! use oxiz::{Solver, TermManager, SolverResult};
69//! use num_bigint::BigInt;
70//!
71//! let mut solver = Solver::new();
72//! let mut tm = TermManager::new();
73//!
74//! // Create variables
75//! let x = tm.mk_var("x", tm.sorts.int_sort);
76//! let y = tm.mk_var("y", tm.sorts.int_sort);
77//!
78//! // x + y = 10
79//! let sum = tm.mk_add([x, y]);
80//! let ten = tm.mk_int(BigInt::from(10));
81//! let eq1 = tm.mk_eq(sum, ten);
82//!
83//! // x > 5
84//! let five = tm.mk_int(BigInt::from(5));
85//! let gt = tm.mk_gt(x, five);
86//!
87//! // Assert constraints
88//! solver.assert(eq1, &mut tm);
89//! solver.assert(gt, &mut tm);
90//!
91//! // Check satisfiability
92//! match solver.check(&mut tm) {
93//! SolverResult::Sat => {
94//! println!("SAT");
95//! if let Some(model) = solver.model() {
96//! println!("Model: {:?}", model);
97//! }
98//! }
99//! SolverResult::Unsat => println!("UNSAT"),
100//! SolverResult::Unknown => println!("Unknown"),
101//! }
102//! ```
103//!
104//! ### SMT-LIB2 Format
105//!
106//! ```rust
107//! use oxiz::{Solver, TermManager};
108//!
109//! let mut solver = Solver::new();
110//! let mut tm = TermManager::new();
111//!
112//! // Parse SMT-LIB2 script
113//! let script = r#"
114//! (declare-const x Int)
115//! (declare-const y Int)
116//! (assert (= (+ x y) 10))
117//! (assert (> x 5))
118//! (check-sat)
119//! "#;
120//!
121//! // Execute commands
122//! // solver.execute_script(script, &mut tm)?;
123//! ```
124//!
125//! ## 🔧 Feature Flags
126//!
127//! | Feature | Description | Default |
128//! |---------|-------------|---------|
129//! | `solver` | Core SMT solver (SAT + theories) | ✓ |
130//! | `nlsat` | Nonlinear real arithmetic | |
131//! | `optimization` | MaxSMT and optimization | |
132//! | `spacer` | CHC solver | |
133//! | `proof` | Proof generation | |
134//! | `standard` | All common features except SPACER | |
135//! | `full` | All features | |
136//!
137//! ## 📚 Theory Support
138//!
139//! - **EUF**: Equality and uninterpreted functions
140//! - **LRA**: Linear real arithmetic (simplex)
141//! - **LIA**: Linear integer arithmetic (branch-and-bound, cuts)
142//! - **NRA**: Nonlinear real arithmetic (NLSAT, CAD)
143//! - **Arrays**: Theory of arrays with extensionality
144//! - **BitVectors**: Bit-precise reasoning
145//! - **Strings**: String operations with regex
146//! - **Datatypes**: Algebraic data types
147//! - **Floating-Point**: IEEE 754 semantics
148//!
149//! ## 🎓 Examples
150//!
151//! See the [examples directory](https://github.com/cool-japan/oxiz/tree/main/examples) for more:
152//!
153//! - Basic constraint solving
154//! - Program verification
155//! - Optimization problems
156//! - Theory combinations
157//!
158//! ## 🔗 Related Projects
159//!
160//! - [oxiz-cli](https://crates.io/crates/oxiz-cli): Command-line interface
161//! - [oxiz-wasm](https://www.npmjs.com/package/oxiz-wasm): WebAssembly bindings
162//!
163//! ## 📖 More Information
164//!
165//! - [GitHub Repository](https://github.com/cool-japan/oxiz)
166//! - [Documentation](https://docs.rs/oxiz)
167//! - [SMT-LIB Standard](https://smtlib.cs.uiowa.edu/)
168
169#![warn(missing_docs)]
170#![cfg_attr(docsrs, feature(doc_cfg))]
171
172// Re-export core modules (always available)
173pub use oxiz_core as core;
174pub use oxiz_math as math;
175
176// Re-export core types for convenience
177pub use oxiz_core::{Sort, SortId, Term, TermId, TermManager};
178
179// Re-export solver components (feature-gated)
180#[cfg(feature = "solver")]
181#[cfg_attr(docsrs, doc(cfg(feature = "solver")))]
182pub use oxiz_sat as sat;
183
184#[cfg(feature = "solver")]
185#[cfg_attr(docsrs, doc(cfg(feature = "solver")))]
186pub use oxiz_theories as theories;
187
188#[cfg(feature = "solver")]
189#[cfg_attr(docsrs, doc(cfg(feature = "solver")))]
190pub use oxiz_solver as solver;
191
192#[cfg(feature = "solver")]
193#[cfg_attr(docsrs, doc(cfg(feature = "solver")))]
194pub use oxiz_solver::{Solver, SolverResult};
195
196// Re-export advanced features
197#[cfg(feature = "nlsat")]
198#[cfg_attr(docsrs, doc(cfg(feature = "nlsat")))]
199pub use oxiz_nlsat as nlsat;
200
201#[cfg(feature = "optimization")]
202#[cfg_attr(docsrs, doc(cfg(feature = "optimization")))]
203pub use oxiz_opt as opt;
204
205#[cfg(feature = "spacer")]
206#[cfg_attr(docsrs, doc(cfg(feature = "spacer")))]
207pub use oxiz_spacer as spacer;
208
209#[cfg(feature = "proof")]
210#[cfg_attr(docsrs, doc(cfg(feature = "proof")))]
211pub use oxiz_proof as proof;
212
213/// Current version of OxiZ
214pub const VERSION: &str = env!("CARGO_PKG_VERSION");
215
216#[cfg(test)]
217mod tests {
218 #[test]
219 fn test_version() {
220 assert!(!super::VERSION.is_empty());
221 }
222}