Rust and Python guide¶
This guide shows the same workflow from both public APIs: the Rust crate and the Python extension module. Pick the language tab you are using; the choice is remembered across the documentation.
Installation¶
Add the crate to Cargo.toml:
For local workspace development:
The default feature set includes optimal5, so default builds need a C++
compiler. For a pure-Rust build:
Create a Boolean function¶
Inspect the function¶
Compute partition metrics¶
Trait imports make the metric methods available:
Work with witness sets¶
Fragmentation profile¶
Sensitivity, influence, and spectral metrics¶
use fbool::sensitivity::Sensitivity;
let max_sensitivity = f.max_sensitivity();
let mean_sensitivity = f.mean_sensitivity();
let influence_0 = f.influence(0);
let total_influence = f.total_influence();
let degree = f.degree();
let spectral_entropy = f.spectral_entropy();
let non_linearity = f.no_linearity();
Frontier and certificates¶
Structural descriptors¶
counting() and repetitiveness() are Rust-only for now:
The Python binding does not expose counting() or repetitiveness() yet.
Use the Rust API when you need those descriptors.
Minimal gates and NPN representatives¶
The optimal5 engine supports exactly 5-variable Boolean functions. Calls return
None outside that domain.
Tables and binary serialization¶
Python returns table() as a NumPy array. The binary encoding is shared with
the CLI bin input format.