Espresso Logic Minimizer
A Rust library for minimizing Boolean functions using the classic Espresso heuristic logic minimizer from UC Berkeley. Perfect for digital logic synthesis, PLA optimization, and Boolean function simplification.
Why Espresso?
Espresso takes Boolean functions in sum-of-products form and produces minimal or near-minimal equivalents. This Rust crate provides safe, thread-safe bindings with modern features like expression parsing and operator overloading.
Features
- Thread-Safe - Safe concurrent execution via C11 thread-local storage
- Boolean Expressions - High-level API with parsing, operators, and
expr!macro - Unified BDD Representation (v3.1.1+) - All boolean expressions use BDD as their canonical internal representation, providing efficient operations, structural sharing, and automatic simplification
- Flexible Parser - Supports both mathematical (
*,+) and logical (&,|) operator notations - Expression Composition - Seamlessly compose parsed, minimised, and constructed expressions
- Algebraic Factorisation (v3.1.1+) - Beautiful multi-level logic display with common factor extraction
- Both Algorithms - Exposes both heuristic and exact minimisation algorithms from Espresso
- PLA File Support - Read and write Berkeley PLA format
- Two API Levels - High-level for ease of use, low-level for maximum control
- Well Documented - Comprehensive API docs and examples
Quick Start
Add to your Cargo.toml:
[]
= "3.1"
Boolean Expression Minimization
use ;
Truth Table Minimization
use ;
PLA File Processing
use ;
Binary Decision Diagrams
Note (v3.1.1+): BoolExpr and Bdd are now unified—Bdd is a type alias for BoolExpr. All expressions use BDD as their internal representation, providing canonical form, efficient operations, and automatic simplification.
use ;
API Overview
High-Level API (Recommended)
Use BoolExpr (alias Bdd) and Cover for most applications:
- Unified BDD representation (v3.1.1+) - All expressions are BDDs internally
- Automatic memory management and dimension tracking
- Thread-safe by design
- Clean, idiomatic Rust API
- Canonical representation with structural sharing
- Efficient operations via hash consing and memoisation
use ;
// Parse with flexible notation: * or & for AND, + or | for OR
let xor = expr!;
let xor_alt = parse?;
// All expressions ARE BDDs - canonical representation
// Minimise to get optimal logic
let minimised = xor.minimize?;
println!; // Uses algebraic factorisation (v3.1.1+)
Low-Level API (Advanced)
Direct espresso::Espresso access for specialized needs:
- Access to intermediate covers (ON-set, don't-care, OFF-set)
- Custom don't-care/off-set optimization
- Maximum performance (~5-10% faster)
See the espresso module documentation for details.
Installation
Prerequisites: Rust 1.70+, C compiler, libclang
# macOS
# Ubuntu/Debian
See docs/INSTALLATION.md for detailed platform-specific instructions.
Command Line Tool
Install the optional CLI:
Usage:
See docs/CLI.md for more options.
Examples
Run included examples:
See docs/EXAMPLES.md for comprehensive code examples.
Documentation
- API Reference - Complete API documentation
- Examples Guide - Comprehensive usage examples
- Boolean Expressions - Expression API details
- PLA Format - PLA file format specification
- CLI Guide - Command-line usage
- Installation - Platform-specific setup
Testing
See TESTING.md for comprehensive testing documentation.
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
License
This project contains three layers of licensed work:
- Original Espresso: UC Berkeley (permissive license)
- Modernized C Code: Sébastien Cottinet (MIT)
- Rust Wrapper: Marcos Sartori (MIT)
See LICENSE and ACKNOWLEDGMENTS.md for details.
Acknowledgments
Espresso was developed by Robert K. Brayton and his team at UC Berkeley. Special thanks to the original developers and Sébastien Cottinet for the modernized C version.
Citation
If you use this library in academic work, please cite:
Made with ❤️ for the Rust and digital logic communities.