oxiz-sat
CDCL SAT solver implementation for OxiZ.
Overview
This crate implements a modern Conflict-Driven Clause Learning (CDCL) SAT solver with:
- Two-Watched Literals - Efficient unit propagation
- VSIDS - Variable State Independent Decaying Sum branching heuristic
- Clause Learning - First-UIP conflict analysis
- Incremental Solving - Push/pop for assumption-based solving
Architecture
┌─────────────────────────────────────────┐
│ Solver │
├─────────────────────────────────────────┤
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Trail │ │ Watched │ │ VSIDS │ │
│ │ │ │ Lists │ │ │ │
│ └─────────┘ └─────────┘ └─────────┘ │
├─────────────────────────────────────────┤
│ Clause Database │
└─────────────────────────────────────────┘
Usage
use ;
let mut solver = new;
// Create variables
let x = solver.new_var;
let y = solver.new_var;
let z = solver.new_var;
// Add clauses: (x OR y) AND (NOT x OR z) AND (NOT y OR NOT z)
solver.add_clause;
solver.add_clause;
solver.add_clause;
match solver.solve
Modules
literal
Literal and variable representation:
Var- Variable indexLit- Signed literal (variable + polarity)LBool- Three-valued logic (True, False, Undef)
clause
Clause representation and database:
Clause- Immutable clause with literalsClauseRef- Reference to clause in databaseClauseDatabase- Storage for all clauses
trail
Assignment trail for backtracking:
- Decision levels
- Propagation reasons
- Efficient backtracking
watched
Two-watched literal scheme:
- O(1) watch updates during propagation
- Lazy watch list maintenance
vsids
VSIDS branching heuristic:
- Activity-based variable selection
- Exponential decay
- Conflict-driven bumping
Performance
The solver is optimized for:
- Cache-friendly clause storage
- Minimal allocations during solving
- Fast unit propagation via two-watched literals
License
MIT OR Apache-2.0