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 - Binary Decision Diagrams - Canonical representation with efficient operations and automatic caching
- Flexible Parser - Supports both mathematical (
*,+) and logical (&,|) operator notations - Expression Composition - Seamlessly compose parsed, minimized, and constructed expressions
- Both Algorithms - Exposes both heuristic and exact minimization 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
use ;
API Overview
High-Level API (Recommended)
Use BoolExpr, Bdd, and Cover for most applications:
- Automatic memory management and dimension tracking
- Thread-safe by design
- Clean, idiomatic Rust API
- BDD caching for efficient repeated operations
use ;
// Parse with flexible notation: * or & for AND, + or | for OR
let xor = expr!;
let xor_alt = parse?;
// Minimize and get canonical BDD representation
let minimized = xor.minimize?;
let bdd = xor.to_bdd; // Cached for efficiency
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.